Files
esign/packages/lib/jobs/definitions/internal/backport-subscription-claims.handler.ts
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign).
Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files)
and align docker/Dockerfile turbo --scope/--filter to the actual remix
package name @hanzo/esign (was a pre-existing mismatch with -remix that
broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
2026-06-21 19:56:09 -07:00

39 lines
1.2 KiB
TypeScript

import { prisma } from '@hanzo/esign-prisma';
import { AppError, AppErrorCode } from '../../../errors/app-error';
import type { JobRunIO } from '../../client/_internal/job';
import type { TBackportSubscriptionClaimJobDefinition } from './backport-subscription-claims';
export const run = async ({
payload,
io,
}: {
payload: TBackportSubscriptionClaimJobDefinition;
io: JobRunIO;
}) => {
const { subscriptionClaimId, flags } = payload;
const subscriptionClaim = await prisma.subscriptionClaim.findFirst({
where: {
id: subscriptionClaimId,
},
});
if (!subscriptionClaim) {
throw new AppError(AppErrorCode.NOT_FOUND, { message: 'Subscription claim not found' });
}
await io.runTask('backport-claims', async () => {
const newFlagsJson = JSON.stringify(flags);
// SQLite: `json_patch(a, b)` does an RFC-7396 shallow merge of `flags`
// (new keys added, existing keys overwritten). `flags` is stored as JSON
// text, so the patch operand is the stringified new flags.
await prisma.$executeRaw`
UPDATE "OrganisationClaim"
SET "flags" = json_patch("flags", ${newFlagsJson})
WHERE "originalSubscriptionClaimId" = ${subscriptionClaimId}
`;
});
};