@fantastic.dev/better-stripe 0.34.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +260 -0
- package/README.md +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +664 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +332 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +664 -2
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +332 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/refundCommandEvidence.d.ts +14 -0
- package/dist/client/connect/refundCommandEvidence.d.ts.map +1 -0
- package/dist/client/connect/refundCommandEvidence.js +20 -0
- package/dist/client/connect/refundCommandEvidence.js.map +1 -0
- package/dist/client/connect/refundCommandNormalization.d.ts +11 -0
- package/dist/client/connect/refundCommandNormalization.d.ts.map +1 -0
- package/dist/client/connect/refundCommandNormalization.js +12 -0
- package/dist/client/connect/refundCommandNormalization.js.map +1 -0
- package/dist/client/financialObservations.d.ts +42 -0
- package/dist/client/financialObservations.d.ts.map +1 -0
- package/dist/client/financialObservations.js +58 -0
- package/dist/client/financialObservations.js.map +1 -0
- package/dist/client/financialOwnership.d.ts +52 -0
- package/dist/client/financialOwnership.d.ts.map +1 -0
- package/dist/client/financialOwnership.js +72 -0
- package/dist/client/financialOwnership.js.map +1 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/observationPagination.d.ts +10 -0
- package/dist/client/observationPagination.d.ts.map +1 -0
- package/dist/client/observationPagination.js +12 -0
- package/dist/client/observationPagination.js.map +1 -0
- package/dist/client/operationEvidence.d.ts +37 -0
- package/dist/client/operationEvidence.d.ts.map +1 -0
- package/dist/client/operationEvidence.js +44 -0
- package/dist/client/operationEvidence.js.map +1 -0
- package/dist/client/publicTypes.d.ts +6 -0
- package/dist/client/publicTypes.d.ts.map +1 -1
- package/dist/client/readContracts.d.ts +31 -0
- package/dist/client/readContracts.d.ts.map +1 -1
- package/dist/client/readContracts.js +14 -0
- package/dist/client/readContracts.js.map +1 -1
- package/dist/client/transferObservations.d.ts +59 -0
- package/dist/client/transferObservations.d.ts.map +1 -0
- package/dist/client/transferObservations.js +82 -0
- package/dist/client/transferObservations.js.map +1 -0
- package/dist/component/_generated/component.d.ts +687 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -1
- package/dist/component/affiliateRecovery/mutations.js +4 -1
- package/dist/component/affiliateRecovery/mutations.js.map +1 -1
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +18 -2
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/queries.d.ts +8 -0
- package/dist/component/connect/queries.d.ts.map +1 -1
- package/dist/component/connect/reversalClaims.d.ts.map +1 -1
- package/dist/component/connect/reversalClaims.js +7 -1
- package/dist/component/connect/reversalClaims.js.map +1 -1
- package/dist/component/connect/reversalReceipts.d.ts.map +1 -1
- package/dist/component/connect/reversalReceipts.js +2 -0
- package/dist/component/connect/reversalReceipts.js.map +1 -1
- package/dist/component/connect/schema.d.ts +11 -1
- package/dist/component/connect/schema.d.ts.map +1 -1
- package/dist/component/connect/schema.js +9 -1
- package/dist/component/connect/schema.js.map +1 -1
- package/dist/component/connect/validators.d.ts +9 -1
- package/dist/component/connect/validators.d.ts.map +1 -1
- package/dist/component/connect/validators.js +2 -0
- package/dist/component/connect/validators.js.map +1 -1
- package/dist/component/earnings/pairedAdjustment.d.ts +12 -0
- package/dist/component/earnings/pairedAdjustment.d.ts.map +1 -0
- package/dist/component/earnings/pairedAdjustment.js +46 -0
- package/dist/component/earnings/pairedAdjustment.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +546 -2
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/earnings/triggers.js +17 -3
- package/dist/component/earnings/triggers.js.map +1 -1
- package/dist/component/financialObservations/continuation.d.ts +7 -0
- package/dist/component/financialObservations/continuation.d.ts.map +1 -0
- package/dist/component/financialObservations/continuation.js +131 -0
- package/dist/component/financialObservations/continuation.js.map +1 -0
- package/dist/component/financialObservations/generations.d.ts +6 -0
- package/dist/component/financialObservations/generations.d.ts.map +1 -0
- package/dist/component/financialObservations/generations.js +46 -0
- package/dist/component/financialObservations/generations.js.map +1 -0
- package/dist/component/financialObservations/mutations.d.ts +62 -0
- package/dist/component/financialObservations/mutations.d.ts.map +1 -0
- package/dist/component/financialObservations/mutations.js +69 -0
- package/dist/component/financialObservations/mutations.js.map +1 -0
- package/dist/component/financialObservations/queries.d.ts +307 -0
- package/dist/component/financialObservations/queries.d.ts.map +1 -0
- package/dist/component/financialObservations/queries.js +219 -0
- package/dist/component/financialObservations/queries.js.map +1 -0
- package/dist/component/financialObservations/schema.d.ts +182 -0
- package/dist/component/financialObservations/schema.d.ts.map +1 -0
- package/dist/component/financialObservations/schema.js +53 -0
- package/dist/component/financialObservations/schema.js.map +1 -0
- package/dist/component/financialObservations/settlement.d.ts +7 -0
- package/dist/component/financialObservations/settlement.d.ts.map +1 -0
- package/dist/component/financialObservations/settlement.js +118 -0
- package/dist/component/financialObservations/settlement.js.map +1 -0
- package/dist/component/financialObservations/settlementHelpers.d.ts +46 -0
- package/dist/component/financialObservations/settlementHelpers.d.ts.map +1 -0
- package/dist/component/financialObservations/settlementHelpers.js +70 -0
- package/dist/component/financialObservations/settlementHelpers.js.map +1 -0
- package/dist/component/financialObservations/transferBatches.d.ts +12 -0
- package/dist/component/financialObservations/transferBatches.d.ts.map +1 -0
- package/dist/component/financialObservations/transferBatches.js +76 -0
- package/dist/component/financialObservations/transferBatches.js.map +1 -0
- package/dist/component/financialObservations/transferContinuation.d.ts +5 -0
- package/dist/component/financialObservations/transferContinuation.d.ts.map +1 -0
- package/dist/component/financialObservations/transferContinuation.js +35 -0
- package/dist/component/financialObservations/transferContinuation.js.map +1 -0
- package/dist/component/financialObservations/transferContinuationState.d.ts +8 -0
- package/dist/component/financialObservations/transferContinuationState.d.ts.map +1 -0
- package/dist/component/financialObservations/transferContinuationState.js +69 -0
- package/dist/component/financialObservations/transferContinuationState.js.map +1 -0
- package/dist/component/financialObservations/transferContinuationSteps.d.ts +5 -0
- package/dist/component/financialObservations/transferContinuationSteps.d.ts.map +1 -0
- package/dist/component/financialObservations/transferContinuationSteps.js +174 -0
- package/dist/component/financialObservations/transferContinuationSteps.js.map +1 -0
- package/dist/component/financialObservations/transferHelpers.d.ts +18 -0
- package/dist/component/financialObservations/transferHelpers.d.ts.map +1 -0
- package/dist/component/financialObservations/transferHelpers.js +37 -0
- package/dist/component/financialObservations/transferHelpers.js.map +1 -0
- package/dist/component/financialObservations/transferReferenceSchema.d.ts +56 -0
- package/dist/component/financialObservations/transferReferenceSchema.d.ts.map +1 -0
- package/dist/component/financialObservations/transferReferenceSchema.js +21 -0
- package/dist/component/financialObservations/transferReferenceSchema.js.map +1 -0
- package/dist/component/financialObservations/transferSchema.d.ts +237 -0
- package/dist/component/financialObservations/transferSchema.d.ts.map +1 -0
- package/dist/component/financialObservations/transferSchema.js +65 -0
- package/dist/component/financialObservations/transferSchema.js.map +1 -0
- package/dist/component/financialObservations/transfers.d.ts +7 -0
- package/dist/component/financialObservations/transfers.d.ts.map +1 -0
- package/dist/component/financialObservations/transfers.js +79 -0
- package/dist/component/financialObservations/transfers.js.map +1 -0
- package/dist/component/financialOwnership/helpers.d.ts +37 -0
- package/dist/component/financialOwnership/helpers.d.ts.map +1 -0
- package/dist/component/financialOwnership/helpers.js +76 -0
- package/dist/component/financialOwnership/helpers.js.map +1 -0
- package/dist/component/financialOwnership/mutations.d.ts +28 -0
- package/dist/component/financialOwnership/mutations.d.ts.map +1 -0
- package/dist/component/financialOwnership/mutations.js +74 -0
- package/dist/component/financialOwnership/mutations.js.map +1 -0
- package/dist/component/financialOwnership/queries.d.ts +57 -0
- package/dist/component/financialOwnership/queries.d.ts.map +1 -0
- package/dist/component/financialOwnership/queries.js +50 -0
- package/dist/component/financialOwnership/queries.js.map +1 -0
- package/dist/component/financialOwnership/schema.d.ts +140 -0
- package/dist/component/financialOwnership/schema.d.ts.map +1 -0
- package/dist/component/financialOwnership/schema.js +35 -0
- package/dist/component/financialOwnership/schema.js.map +1 -0
- package/dist/component/operationEvidence/canonical.d.ts +4 -0
- package/dist/component/operationEvidence/canonical.d.ts.map +1 -0
- package/dist/component/operationEvidence/canonical.js +8 -0
- package/dist/component/operationEvidence/canonical.js.map +1 -0
- package/dist/component/operationEvidence/helpers.d.ts +87 -0
- package/dist/component/operationEvidence/helpers.d.ts.map +1 -0
- package/dist/component/operationEvidence/helpers.js +49 -0
- package/dist/component/operationEvidence/helpers.js.map +1 -0
- package/dist/component/operationEvidence/maintenance.d.ts +88 -0
- package/dist/component/operationEvidence/maintenance.d.ts.map +1 -0
- package/dist/component/operationEvidence/maintenance.js +59 -0
- package/dist/component/operationEvidence/maintenance.js.map +1 -0
- package/dist/component/operationEvidence/mutations.d.ts +97 -0
- package/dist/component/operationEvidence/mutations.d.ts.map +1 -0
- package/dist/component/operationEvidence/mutations.js +14 -0
- package/dist/component/operationEvidence/mutations.js.map +1 -0
- package/dist/component/operationEvidence/queries.d.ts +205 -0
- package/dist/component/operationEvidence/queries.d.ts.map +1 -0
- package/dist/component/operationEvidence/queries.js +75 -0
- package/dist/component/operationEvidence/queries.js.map +1 -0
- package/dist/component/operationEvidence/schema.d.ts +536 -0
- package/dist/component/operationEvidence/schema.d.ts.map +1 -0
- package/dist/component/operationEvidence/schema.js +53 -0
- package/dist/component/operationEvidence/schema.js.map +1 -0
- package/dist/component/refundHistory/commandBinding.d.ts +17 -0
- package/dist/component/refundHistory/commandBinding.d.ts.map +1 -0
- package/dist/component/refundHistory/commandBinding.js +41 -0
- package/dist/component/refundHistory/commandBinding.js.map +1 -0
- package/dist/component/refundHistory/commandEvidence.d.ts +50 -0
- package/dist/component/refundHistory/commandEvidence.d.ts.map +1 -0
- package/dist/component/refundHistory/commandEvidence.js +58 -0
- package/dist/component/refundHistory/commandEvidence.js.map +1 -0
- package/dist/component/refundHistory/commandEvidenceValidator.d.ts +89 -0
- package/dist/component/refundHistory/commandEvidenceValidator.d.ts.map +1 -0
- package/dist/component/refundHistory/commandEvidenceValidator.js +8 -0
- package/dist/component/refundHistory/commandEvidenceValidator.js.map +1 -0
- package/dist/component/refundHistory/commandFields.d.ts +8 -0
- package/dist/component/refundHistory/commandFields.d.ts.map +1 -0
- package/dist/component/refundHistory/commandFields.js +9 -0
- package/dist/component/refundHistory/commandFields.js.map +1 -0
- package/dist/component/refundHistory/mutations.d.ts +8 -0
- package/dist/component/refundHistory/mutations.d.ts.map +1 -0
- package/dist/component/refundHistory/mutations.js +25 -0
- package/dist/component/refundHistory/mutations.js.map +1 -0
- package/dist/component/refundHistory/originalSeller.d.ts +5 -0
- package/dist/component/refundHistory/originalSeller.d.ts.map +1 -0
- package/dist/component/refundHistory/originalSeller.js +35 -0
- package/dist/component/refundHistory/originalSeller.js.map +1 -0
- package/dist/component/refundHistory/queries.d.ts +51 -0
- package/dist/component/refundHistory/queries.d.ts.map +1 -1
- package/dist/component/refundHistory/queries.js +14 -0
- package/dist/component/refundHistory/queries.js.map +1 -1
- package/dist/component/schema.d.ts +332 -1
- package/dist/component/schema.js +15 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/settlement/mutations.d.ts.map +1 -1
- package/dist/component/settlement/mutations.js +5 -1
- package/dist/component/settlement/mutations.js.map +1 -1
- package/dist/shared/refundCommandScope.d.ts +10 -0
- package/dist/shared/refundCommandScope.d.ts.map +1 -0
- package/dist/shared/refundCommandScope.js +9 -0
- package/dist/shared/refundCommandScope.js.map +1 -0
- package/docs/financial-observations.md +244 -0
- package/docs/financial-ownership.md +54 -0
- package/docs/refund-command-evidence.md +55 -0
- package/package.json +5 -2
- package/src/client/connect/refundCommandEvidence.ts +41 -0
- package/src/client/connect/refundCommandNormalization.ts +28 -0
- package/src/client/financialObservations.test.ts +109 -0
- package/src/client/financialObservations.ts +106 -0
- package/src/client/financialOwnership.test.ts +80 -0
- package/src/client/financialOwnership.ts +116 -0
- package/src/client/index.ts +2 -2
- package/src/client/observationPagination.ts +11 -0
- package/src/client/operationEvidence.test.ts +110 -0
- package/src/client/operationEvidence.ts +92 -0
- package/src/client/publicTypes.ts +45 -0
- package/src/client/readContracts.ts +25 -0
- package/src/client/refund-command-evidence.test.ts +68 -0
- package/src/client/refund-command-normalization.test.ts +61 -0
- package/src/client/transferContinuation.test.ts +94 -0
- package/src/client/transferObservations.test.ts +98 -0
- package/src/client/transferObservations.ts +180 -0
- package/src/component/_generated/api.ts +54 -0
- package/src/component/_generated/component.ts +797 -0
- package/src/component/affiliateRecovery/mutations.ts +10 -1
- package/src/component/connect/mutations.ts +29 -2
- package/src/component/connect/reversalClaims.ts +19 -1
- package/src/component/connect/reversalReceipts.ts +2 -0
- package/src/component/connect/schema.ts +9 -1
- package/src/component/connect/validators.ts +2 -0
- package/src/component/core/reset.test.ts +8 -1
- package/src/component/earnings/earnings-totals.test.ts +14 -10
- package/src/component/earnings/paired-adjustment.test.ts +258 -0
- package/src/component/earnings/pairedAdjustment.ts +77 -0
- package/src/component/earnings/triggers.ts +23 -11
- package/src/component/financialObservations/continuation.test.ts +445 -0
- package/src/component/financialObservations/continuation.ts +159 -0
- package/src/component/financialObservations/generations.ts +53 -0
- package/src/component/financialObservations/mutations.ts +75 -0
- package/src/component/financialObservations/observation-boundaries.test.ts +466 -0
- package/src/component/financialObservations/queries.ts +246 -0
- package/src/component/financialObservations/schema.ts +68 -0
- package/src/component/financialObservations/settlement-observations.test.ts +86 -0
- package/src/component/financialObservations/settlement.ts +142 -0
- package/src/component/financialObservations/settlementHelpers.ts +92 -0
- package/src/component/financialObservations/transfer-batches.test.ts +61 -0
- package/src/component/financialObservations/transfer-boundaries.test.ts +116 -0
- package/src/component/financialObservations/transfer-continuation-guards.test.ts +428 -0
- package/src/component/financialObservations/transfer-continuation.test.ts +154 -0
- package/src/component/financialObservations/transfer-observations.test.ts +212 -0
- package/src/component/financialObservations/transfer-overflow.test.ts +181 -0
- package/src/component/financialObservations/transfer-writers.test.ts +162 -0
- package/src/component/financialObservations/transferBatches.ts +96 -0
- package/src/component/financialObservations/transferContinuation.ts +53 -0
- package/src/component/financialObservations/transferContinuationState.ts +85 -0
- package/src/component/financialObservations/transferContinuationSteps.ts +232 -0
- package/src/component/financialObservations/transferHelpers.ts +38 -0
- package/src/component/financialObservations/transferReferenceSchema.ts +20 -0
- package/src/component/financialObservations/transferSchema.ts +74 -0
- package/src/component/financialObservations/transfers.ts +99 -0
- package/src/component/financialOwnership/financial-ownership.test.ts +102 -0
- package/src/component/financialOwnership/helpers.ts +98 -0
- package/src/component/financialOwnership/mutations.ts +83 -0
- package/src/component/financialOwnership/ownership-boundaries.test.ts +308 -0
- package/src/component/financialOwnership/queries.ts +65 -0
- package/src/component/financialOwnership/schema.ts +35 -0
- package/src/component/operationEvidence/canonical.ts +10 -0
- package/src/component/operationEvidence/helpers.ts +65 -0
- package/src/component/operationEvidence/integrity.test.ts +257 -0
- package/src/component/operationEvidence/maintenance.test.ts +152 -0
- package/src/component/operationEvidence/maintenance.ts +89 -0
- package/src/component/operationEvidence/mutations.ts +14 -0
- package/src/component/operationEvidence/queries.ts +108 -0
- package/src/component/operationEvidence/reads.test.ts +140 -0
- package/src/component/operationEvidence/schema.ts +62 -0
- package/src/component/refundHistory/command-evidence.test.ts +288 -0
- package/src/component/refundHistory/command-normalization-resource.test.ts +77 -0
- package/src/component/refundHistory/command-normalization.test.ts +229 -0
- package/src/component/refundHistory/command-provenance.test.ts +59 -0
- package/src/component/refundHistory/commandBinding.ts +54 -0
- package/src/component/refundHistory/commandEvidence.ts +76 -0
- package/src/component/refundHistory/commandEvidenceValidator.ts +18 -0
- package/src/component/refundHistory/commandFields.ts +9 -0
- package/src/component/refundHistory/mutations.ts +33 -0
- package/src/component/refundHistory/original-seller-boundaries.test.ts +138 -0
- package/src/component/refundHistory/original-seller.test.ts +175 -0
- package/src/component/refundHistory/originalSeller.ts +48 -0
- package/src/component/refundHistory/queries.ts +15 -0
- package/src/component/schema.ts +28 -0
- package/src/component/settlement/mutations.ts +5 -1
- package/src/shared/refundCommandScope.ts +19 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
export declare const sourceFields: {
|
|
2
|
+
allocationId: import("convex/values").VId<import("convex/values").GenericId<"settlementAllocations">, "required">;
|
|
3
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
4
|
+
producer: import("convex/values").VLiteral<"settlement_allocation", "required">;
|
|
5
|
+
producerVersion: import("convex/values").VLiteral<1, "required">;
|
|
6
|
+
fingerprint: import("convex/values").VString<string, "required">;
|
|
7
|
+
observedFingerprint: import("convex/values").VString<string, "required">;
|
|
8
|
+
ownershipFingerprint: import("convex/values").VString<string, "required">;
|
|
9
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
10
|
+
legCount: import("convex/values").VFloat64<number, "required">;
|
|
11
|
+
indexedLegCount: import("convex/values").VFloat64<number, "required">;
|
|
12
|
+
isOverflow: import("convex/values").VBoolean<boolean, "required">;
|
|
13
|
+
isContradictory: import("convex/values").VBoolean<boolean, "required">;
|
|
14
|
+
continuation: import("convex/values").VObject<{
|
|
15
|
+
nextLeg: number;
|
|
16
|
+
state: "complete" | "held" | "indexing" | "validating";
|
|
17
|
+
validatedLegs: number;
|
|
18
|
+
} | undefined, {
|
|
19
|
+
state: import("convex/values").VUnion<"complete" | "held" | "indexing" | "validating", [import("convex/values").VLiteral<"indexing", "required">, import("convex/values").VLiteral<"validating", "required">, import("convex/values").VLiteral<"complete", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
|
|
20
|
+
nextLeg: import("convex/values").VFloat64<number, "required">;
|
|
21
|
+
validatedLegs: import("convex/values").VFloat64<number, "required">;
|
|
22
|
+
}, "optional", "nextLeg" | "state" | "validatedLegs">;
|
|
23
|
+
};
|
|
24
|
+
export declare const sourceDoc: import("convex/values").VObject<{
|
|
25
|
+
_creationTime: number;
|
|
26
|
+
_id: import("convex/values").GenericId<"financialSourceObservations">;
|
|
27
|
+
allocationId: import("convex/values").GenericId<"settlementAllocations">;
|
|
28
|
+
continuation?: {
|
|
29
|
+
nextLeg: number;
|
|
30
|
+
state: "complete" | "held" | "indexing" | "validating";
|
|
31
|
+
validatedLegs: number;
|
|
32
|
+
} | undefined;
|
|
33
|
+
fingerprint: string;
|
|
34
|
+
generation: number;
|
|
35
|
+
indexedLegCount: number;
|
|
36
|
+
isContradictory: boolean;
|
|
37
|
+
isOverflow: boolean;
|
|
38
|
+
legCount: number;
|
|
39
|
+
observedFingerprint: string;
|
|
40
|
+
ownershipFingerprint: string;
|
|
41
|
+
producer: "settlement_allocation";
|
|
42
|
+
producerVersion: 1;
|
|
43
|
+
sourceChargeId: string;
|
|
44
|
+
}, {
|
|
45
|
+
allocationId: import("convex/values").VId<import("convex/values").GenericId<"settlementAllocations">, "required">;
|
|
46
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
47
|
+
producer: import("convex/values").VLiteral<"settlement_allocation", "required">;
|
|
48
|
+
producerVersion: import("convex/values").VLiteral<1, "required">;
|
|
49
|
+
fingerprint: import("convex/values").VString<string, "required">;
|
|
50
|
+
observedFingerprint: import("convex/values").VString<string, "required">;
|
|
51
|
+
ownershipFingerprint: import("convex/values").VString<string, "required">;
|
|
52
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
53
|
+
legCount: import("convex/values").VFloat64<number, "required">;
|
|
54
|
+
indexedLegCount: import("convex/values").VFloat64<number, "required">;
|
|
55
|
+
isOverflow: import("convex/values").VBoolean<boolean, "required">;
|
|
56
|
+
isContradictory: import("convex/values").VBoolean<boolean, "required">;
|
|
57
|
+
continuation: import("convex/values").VObject<{
|
|
58
|
+
nextLeg: number;
|
|
59
|
+
state: "complete" | "held" | "indexing" | "validating";
|
|
60
|
+
validatedLegs: number;
|
|
61
|
+
} | undefined, {
|
|
62
|
+
state: import("convex/values").VUnion<"complete" | "held" | "indexing" | "validating", [import("convex/values").VLiteral<"indexing", "required">, import("convex/values").VLiteral<"validating", "required">, import("convex/values").VLiteral<"complete", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
|
|
63
|
+
nextLeg: import("convex/values").VFloat64<number, "required">;
|
|
64
|
+
validatedLegs: import("convex/values").VFloat64<number, "required">;
|
|
65
|
+
}, "optional", "nextLeg" | "state" | "validatedLegs">;
|
|
66
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"financialSourceObservations">, "required">;
|
|
67
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
68
|
+
}, "required", "_creationTime" | "_id" | "allocationId" | "continuation" | "continuation.nextLeg" | "continuation.state" | "continuation.validatedLegs" | "fingerprint" | "generation" | "indexedLegCount" | "isContradictory" | "isOverflow" | "legCount" | "observedFingerprint" | "ownershipFingerprint" | "producer" | "producerVersion" | "sourceChargeId">;
|
|
69
|
+
export declare const sourceObservationsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
70
|
+
allocationId: import("convex/values").GenericId<"settlementAllocations">;
|
|
71
|
+
continuation?: {
|
|
72
|
+
nextLeg: number;
|
|
73
|
+
state: "complete" | "held" | "indexing" | "validating";
|
|
74
|
+
validatedLegs: number;
|
|
75
|
+
} | undefined;
|
|
76
|
+
fingerprint: string;
|
|
77
|
+
generation: number;
|
|
78
|
+
indexedLegCount: number;
|
|
79
|
+
isContradictory: boolean;
|
|
80
|
+
isOverflow: boolean;
|
|
81
|
+
legCount: number;
|
|
82
|
+
observedFingerprint: string;
|
|
83
|
+
ownershipFingerprint: string;
|
|
84
|
+
producer: "settlement_allocation";
|
|
85
|
+
producerVersion: 1;
|
|
86
|
+
sourceChargeId: string;
|
|
87
|
+
}, {
|
|
88
|
+
allocationId: import("convex/values").VId<import("convex/values").GenericId<"settlementAllocations">, "required">;
|
|
89
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
90
|
+
producer: import("convex/values").VLiteral<"settlement_allocation", "required">;
|
|
91
|
+
producerVersion: import("convex/values").VLiteral<1, "required">;
|
|
92
|
+
fingerprint: import("convex/values").VString<string, "required">;
|
|
93
|
+
observedFingerprint: import("convex/values").VString<string, "required">;
|
|
94
|
+
ownershipFingerprint: import("convex/values").VString<string, "required">;
|
|
95
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
96
|
+
legCount: import("convex/values").VFloat64<number, "required">;
|
|
97
|
+
indexedLegCount: import("convex/values").VFloat64<number, "required">;
|
|
98
|
+
isOverflow: import("convex/values").VBoolean<boolean, "required">;
|
|
99
|
+
isContradictory: import("convex/values").VBoolean<boolean, "required">;
|
|
100
|
+
continuation: import("convex/values").VObject<{
|
|
101
|
+
nextLeg: number;
|
|
102
|
+
state: "complete" | "held" | "indexing" | "validating";
|
|
103
|
+
validatedLegs: number;
|
|
104
|
+
} | undefined, {
|
|
105
|
+
state: import("convex/values").VUnion<"complete" | "held" | "indexing" | "validating", [import("convex/values").VLiteral<"indexing", "required">, import("convex/values").VLiteral<"validating", "required">, import("convex/values").VLiteral<"complete", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
|
|
106
|
+
nextLeg: import("convex/values").VFloat64<number, "required">;
|
|
107
|
+
validatedLegs: import("convex/values").VFloat64<number, "required">;
|
|
108
|
+
}, "optional", "nextLeg" | "state" | "validatedLegs">;
|
|
109
|
+
}, "required", "allocationId" | "continuation" | "continuation.nextLeg" | "continuation.state" | "continuation.validatedLegs" | "fingerprint" | "generation" | "indexedLegCount" | "isContradictory" | "isOverflow" | "legCount" | "observedFingerprint" | "ownershipFingerprint" | "producer" | "producerVersion" | "sourceChargeId">, {
|
|
110
|
+
by_allocation_id: ["allocationId", "_creationTime"];
|
|
111
|
+
}, {}, {}>;
|
|
112
|
+
export declare const legFields: {
|
|
113
|
+
allocationId: import("convex/values").VId<import("convex/values").GenericId<"settlementAllocations">, "required">;
|
|
114
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
115
|
+
legIndex: import("convex/values").VFloat64<number, "required">;
|
|
116
|
+
bucketKey: import("convex/values").VString<string, "required">;
|
|
117
|
+
role: import("convex/values").VUnion<"affiliate" | "other" | "store", [import("convex/values").VLiteral<"store", "required">, import("convex/values").VLiteral<"affiliate", "required">, import("convex/values").VLiteral<"other", "required">], "required", never>;
|
|
118
|
+
registrationId: import("convex/values").VId<import("convex/values").GenericId<"financialOwnership"> | undefined, "optional">;
|
|
119
|
+
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
120
|
+
orgId: import("convex/values").VString<string | undefined, "optional">;
|
|
121
|
+
ownershipStatus: import("convex/values").VUnion<"ambiguous" | "contradictory" | "registered" | "unknown", [import("convex/values").VLiteral<"registered", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"ambiguous", "required">, import("convex/values").VLiteral<"contradictory", "required">], "required", never>;
|
|
122
|
+
};
|
|
123
|
+
export declare const legDoc: import("convex/values").VObject<{
|
|
124
|
+
_creationTime: number;
|
|
125
|
+
_id: import("convex/values").GenericId<"financialSourceLegs">;
|
|
126
|
+
allocationId: import("convex/values").GenericId<"settlementAllocations">;
|
|
127
|
+
bucketKey: string;
|
|
128
|
+
legIndex: number;
|
|
129
|
+
orgId?: string | undefined;
|
|
130
|
+
ownershipStatus: "ambiguous" | "contradictory" | "registered" | "unknown";
|
|
131
|
+
registrationId?: import("convex/values").GenericId<"financialOwnership"> | undefined;
|
|
132
|
+
role: "affiliate" | "other" | "store";
|
|
133
|
+
sourceChargeId: string;
|
|
134
|
+
userId?: string | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
allocationId: import("convex/values").VId<import("convex/values").GenericId<"settlementAllocations">, "required">;
|
|
137
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
138
|
+
legIndex: import("convex/values").VFloat64<number, "required">;
|
|
139
|
+
bucketKey: import("convex/values").VString<string, "required">;
|
|
140
|
+
role: import("convex/values").VUnion<"affiliate" | "other" | "store", [import("convex/values").VLiteral<"store", "required">, import("convex/values").VLiteral<"affiliate", "required">, import("convex/values").VLiteral<"other", "required">], "required", never>;
|
|
141
|
+
registrationId: import("convex/values").VId<import("convex/values").GenericId<"financialOwnership"> | undefined, "optional">;
|
|
142
|
+
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
143
|
+
orgId: import("convex/values").VString<string | undefined, "optional">;
|
|
144
|
+
ownershipStatus: import("convex/values").VUnion<"ambiguous" | "contradictory" | "registered" | "unknown", [import("convex/values").VLiteral<"registered", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"ambiguous", "required">, import("convex/values").VLiteral<"contradictory", "required">], "required", never>;
|
|
145
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"financialSourceLegs">, "required">;
|
|
146
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
147
|
+
}, "required", "_creationTime" | "_id" | "allocationId" | "bucketKey" | "legIndex" | "orgId" | "ownershipStatus" | "registrationId" | "role" | "sourceChargeId" | "userId">;
|
|
148
|
+
export declare const sourceLegsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
149
|
+
allocationId: import("convex/values").GenericId<"settlementAllocations">;
|
|
150
|
+
bucketKey: string;
|
|
151
|
+
legIndex: number;
|
|
152
|
+
orgId?: string | undefined;
|
|
153
|
+
ownershipStatus: "ambiguous" | "contradictory" | "registered" | "unknown";
|
|
154
|
+
registrationId?: import("convex/values").GenericId<"financialOwnership"> | undefined;
|
|
155
|
+
role: "affiliate" | "other" | "store";
|
|
156
|
+
sourceChargeId: string;
|
|
157
|
+
userId?: string | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
allocationId: import("convex/values").VId<import("convex/values").GenericId<"settlementAllocations">, "required">;
|
|
160
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
161
|
+
legIndex: import("convex/values").VFloat64<number, "required">;
|
|
162
|
+
bucketKey: import("convex/values").VString<string, "required">;
|
|
163
|
+
role: import("convex/values").VUnion<"affiliate" | "other" | "store", [import("convex/values").VLiteral<"store", "required">, import("convex/values").VLiteral<"affiliate", "required">, import("convex/values").VLiteral<"other", "required">], "required", never>;
|
|
164
|
+
registrationId: import("convex/values").VId<import("convex/values").GenericId<"financialOwnership"> | undefined, "optional">;
|
|
165
|
+
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
166
|
+
orgId: import("convex/values").VString<string | undefined, "optional">;
|
|
167
|
+
ownershipStatus: import("convex/values").VUnion<"ambiguous" | "contradictory" | "registered" | "unknown", [import("convex/values").VLiteral<"registered", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"ambiguous", "required">, import("convex/values").VLiteral<"contradictory", "required">], "required", never>;
|
|
168
|
+
}, "required", "allocationId" | "bucketKey" | "legIndex" | "orgId" | "ownershipStatus" | "registrationId" | "role" | "sourceChargeId" | "userId">, {
|
|
169
|
+
by_allocation_id_and_leg_index: ["allocationId", "legIndex", "_creationTime"];
|
|
170
|
+
by_bucket_key: ["bucketKey", "_creationTime"];
|
|
171
|
+
by_owner: ["userId", "orgId", "_creationTime"];
|
|
172
|
+
}, {}, {}>;
|
|
173
|
+
export declare const observationGenerationsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
174
|
+
generation: number;
|
|
175
|
+
scopeKey: string;
|
|
176
|
+
}, {
|
|
177
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
178
|
+
generation: import("convex/values").VFloat64<number, "required">;
|
|
179
|
+
}, "required", "generation" | "scopeKey">, {
|
|
180
|
+
by_scope_key: ["scopeKey", "_creationTime"];
|
|
181
|
+
}, {}, {}>;
|
|
182
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/financialObservations/schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;IACvB,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,eAAe;IACf,WAAW;IACX,mBAAmB;IACnB,oBAAoB;IACpB,UAAU;IACV,QAAQ;IACR,eAAe;IACf,UAAU;IACV,eAAe;IACf,YAAY;;;;;;;;;CAYb,CAAC;AACF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gWAIpB,CAAC;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAGnC,CAAC;AACF,eAAO,MAAM,SAAS;IACpB,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,SAAS;IACT,IAAI;IACJ,cAAc;IACd,MAAM;IACN,KAAK;IACL,eAAe;CAMhB,CAAC;AACF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;2KAIjB,CAAC;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;UAGa,CAAC;AAC1C,eAAO,MAAM,2BAA2B;;;;;;;;UAGF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { splitRecipientRoleValidator } from "../lib/fees.js";
|
|
4
|
+
export const sourceFields = {
|
|
5
|
+
allocationId: v.id("settlementAllocations"),
|
|
6
|
+
sourceChargeId: v.string(),
|
|
7
|
+
producer: v.literal("settlement_allocation"),
|
|
8
|
+
producerVersion: v.literal(1),
|
|
9
|
+
fingerprint: v.string(),
|
|
10
|
+
observedFingerprint: v.string(),
|
|
11
|
+
ownershipFingerprint: v.string(),
|
|
12
|
+
generation: v.number(),
|
|
13
|
+
legCount: v.number(),
|
|
14
|
+
indexedLegCount: v.number(),
|
|
15
|
+
isOverflow: v.boolean(),
|
|
16
|
+
isContradictory: v.boolean(),
|
|
17
|
+
continuation: v.optional(v.object({
|
|
18
|
+
state: v.union(v.literal("indexing"), v.literal("validating"), v.literal("complete"), v.literal("held")),
|
|
19
|
+
nextLeg: v.number(),
|
|
20
|
+
validatedLegs: v.number(),
|
|
21
|
+
})),
|
|
22
|
+
};
|
|
23
|
+
export const sourceDoc = v.object({
|
|
24
|
+
...sourceFields,
|
|
25
|
+
_id: v.id("financialSourceObservations"),
|
|
26
|
+
_creationTime: v.number(),
|
|
27
|
+
});
|
|
28
|
+
export const sourceObservationsTable = defineTable(sourceFields).index("by_allocation_id", ["allocationId"]);
|
|
29
|
+
export const legFields = {
|
|
30
|
+
allocationId: v.id("settlementAllocations"),
|
|
31
|
+
sourceChargeId: v.string(),
|
|
32
|
+
legIndex: v.number(),
|
|
33
|
+
bucketKey: v.string(),
|
|
34
|
+
role: splitRecipientRoleValidator,
|
|
35
|
+
registrationId: v.optional(v.id("financialOwnership")),
|
|
36
|
+
userId: v.optional(v.string()),
|
|
37
|
+
orgId: v.optional(v.string()),
|
|
38
|
+
ownershipStatus: v.union(v.literal("registered"), v.literal("unknown"), v.literal("ambiguous"), v.literal("contradictory")),
|
|
39
|
+
};
|
|
40
|
+
export const legDoc = v.object({
|
|
41
|
+
...legFields,
|
|
42
|
+
_id: v.id("financialSourceLegs"),
|
|
43
|
+
_creationTime: v.number(),
|
|
44
|
+
});
|
|
45
|
+
export const sourceLegsTable = defineTable(legFields)
|
|
46
|
+
.index("by_allocation_id_and_leg_index", ["allocationId", "legIndex"])
|
|
47
|
+
.index("by_bucket_key", ["bucketKey"])
|
|
48
|
+
.index("by_owner", ["userId", "orgId"]);
|
|
49
|
+
export const observationGenerationsTable = defineTable({
|
|
50
|
+
scopeKey: v.string(),
|
|
51
|
+
generation: v.number(),
|
|
52
|
+
}).index("by_scope_key", ["scopeKey"]);
|
|
53
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0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AM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC;KAClD,KAAK,CAAC,gCAAgC,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;KACrE,KAAK,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC;KACrC,KAAK,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,2BAA2B,GAAG,WAAW,CAAC;IACrD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Doc } from "../_generated/dataModel.js";
|
|
2
|
+
import type { MutationCtx } from "../_generated/server.js";
|
|
3
|
+
/** Larger allocations require explicit bounded continuation; aggregate coverage stays UNKNOWN. */
|
|
4
|
+
export declare const synchronousSettlementLegLimit = 100;
|
|
5
|
+
/** Persist diagnostic provenance in the SAME raw mutation; never mutate the financial source. */
|
|
6
|
+
export declare function observeSettlementAllocation(ctx: MutationCtx, row: Doc<"settlementAllocations">): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=settlement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement.d.ts","sourceRoot":"","sources":["../../../src/component/financialObservations/settlement.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAU3D,kGAAkG;AAClG,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAGjD,iGAAiG;AACjG,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,GAAG,CAAC,uBAAuB,CAAC,iBA0HlC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { generateIdempotencyKey } from "../lib/idempotency.js";
|
|
2
|
+
import { hasInvalidLegIdentity, invalidate, legOwnership, settlementFingerprint, } from "./settlementHelpers.js";
|
|
3
|
+
/** Larger allocations require explicit bounded continuation; aggregate coverage stays UNKNOWN. */
|
|
4
|
+
export const synchronousSettlementLegLimit = 100;
|
|
5
|
+
/** Persist diagnostic provenance in the SAME raw mutation; never mutate the financial source. */
|
|
6
|
+
export async function observeSettlementAllocation(ctx, row) {
|
|
7
|
+
const markers = await ctx.db
|
|
8
|
+
.query("financialSourceObservations")
|
|
9
|
+
.withIndex("by_allocation_id", (q) => q.eq("allocationId", row._id))
|
|
10
|
+
.take(2);
|
|
11
|
+
if (markers.length > 1)
|
|
12
|
+
return;
|
|
13
|
+
const prior = markers[0];
|
|
14
|
+
const oldLegs = await ctx.db
|
|
15
|
+
.query("financialSourceLegs")
|
|
16
|
+
.withIndex("by_allocation_id_and_leg_index", (q) => q.eq("allocationId", row._id))
|
|
17
|
+
.take(synchronousSettlementLegLimit + 1);
|
|
18
|
+
const fingerprint = await settlementFingerprint(row);
|
|
19
|
+
const sources = await ctx.db
|
|
20
|
+
.query("settlementAllocations")
|
|
21
|
+
.withIndex("by_source_charge", (q) => q.eq("sourceChargeId", row.sourceChargeId))
|
|
22
|
+
.take(2);
|
|
23
|
+
const isContinuedOverflow = prior?.isOverflow === true && prior.continuation !== undefined;
|
|
24
|
+
const hasInvalidLegs = hasInvalidLegIdentity(row, oldLegs) ||
|
|
25
|
+
(prior !== undefined &&
|
|
26
|
+
((!isContinuedOverflow && prior.indexedLegCount !== oldLegs.length) ||
|
|
27
|
+
(!prior.isOverflow &&
|
|
28
|
+
!prior.isContradictory &&
|
|
29
|
+
(prior.legCount !== row.transfers.length ||
|
|
30
|
+
oldLegs.length !== row.transfers.length))));
|
|
31
|
+
const isContradictory = hasInvalidLegs ||
|
|
32
|
+
sources.length !== 1 ||
|
|
33
|
+
sources[0]?._id !== row._id ||
|
|
34
|
+
prior?.isContradictory === true ||
|
|
35
|
+
(prior !== undefined && prior.fingerprint !== fingerprint) ||
|
|
36
|
+
(oldLegs.length > synchronousSettlementLegLimit && !isContinuedOverflow);
|
|
37
|
+
const isOverflow = row.transfers.length > synchronousSettlementLegLimit;
|
|
38
|
+
const legs = [];
|
|
39
|
+
if (!isOverflow && !isContradictory)
|
|
40
|
+
for (const [legIndex, leg] of row.transfers.entries()) {
|
|
41
|
+
const previous = oldLegs.find((l) => l.legIndex === legIndex);
|
|
42
|
+
legs.push({
|
|
43
|
+
allocationId: row._id,
|
|
44
|
+
sourceChargeId: row.sourceChargeId,
|
|
45
|
+
legIndex,
|
|
46
|
+
bucketKey: leg.destinationAccountId,
|
|
47
|
+
role: leg.role,
|
|
48
|
+
...(await legOwnership(ctx, leg.destinationAccountId, previous)),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (isContinuedOverflow && !isContradictory)
|
|
52
|
+
return;
|
|
53
|
+
const ownershipFingerprint = await generateIdempotencyKey("settlement-leg-ownership-v1", { legs });
|
|
54
|
+
if (prior &&
|
|
55
|
+
prior.observedFingerprint === fingerprint &&
|
|
56
|
+
prior.ownershipFingerprint === ownershipFingerprint &&
|
|
57
|
+
prior.isContradictory === isContradictory &&
|
|
58
|
+
prior.isOverflow === isOverflow)
|
|
59
|
+
return;
|
|
60
|
+
const generation = (prior?.generation ?? 0) + 1;
|
|
61
|
+
if (!Number.isSafeInteger(generation) ||
|
|
62
|
+
generation < 1 ||
|
|
63
|
+
(prior && prior.generation < 1)) {
|
|
64
|
+
if (prior && prior.generation !== 0) {
|
|
65
|
+
await ctx.db.patch("financialSourceObservations", prior._id, {
|
|
66
|
+
generation: 0,
|
|
67
|
+
isContradictory: true,
|
|
68
|
+
});
|
|
69
|
+
await invalidate(ctx, oldLegs);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!isOverflow && !isContradictory)
|
|
74
|
+
for (const leg of legs) {
|
|
75
|
+
const existing = oldLegs.find((l) => l.legIndex === leg.legIndex);
|
|
76
|
+
if (existing)
|
|
77
|
+
await ctx.db.patch("financialSourceLegs", existing._id, leg);
|
|
78
|
+
else
|
|
79
|
+
await ctx.db.insert("financialSourceLegs", leg);
|
|
80
|
+
}
|
|
81
|
+
if (isContradictory && !hasInvalidLegs)
|
|
82
|
+
for (const leg of oldLegs)
|
|
83
|
+
await ctx.db.patch("financialSourceLegs", leg._id, {
|
|
84
|
+
ownershipStatus: "contradictory",
|
|
85
|
+
});
|
|
86
|
+
const fields = {
|
|
87
|
+
allocationId: row._id,
|
|
88
|
+
sourceChargeId: prior?.sourceChargeId ?? row.sourceChargeId,
|
|
89
|
+
producer: "settlement_allocation",
|
|
90
|
+
producerVersion: 1,
|
|
91
|
+
fingerprint: prior?.fingerprint ?? fingerprint,
|
|
92
|
+
observedFingerprint: fingerprint,
|
|
93
|
+
ownershipFingerprint,
|
|
94
|
+
generation,
|
|
95
|
+
legCount: row.transfers.length,
|
|
96
|
+
indexedLegCount: isContinuedOverflow
|
|
97
|
+
? prior.indexedLegCount
|
|
98
|
+
: isOverflow || isContradictory
|
|
99
|
+
? oldLegs.length
|
|
100
|
+
: legs.length,
|
|
101
|
+
...(prior?.continuation && isContradictory
|
|
102
|
+
? {
|
|
103
|
+
continuation: {
|
|
104
|
+
...prior.continuation,
|
|
105
|
+
state: "held",
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
: {}),
|
|
109
|
+
isOverflow,
|
|
110
|
+
isContradictory,
|
|
111
|
+
};
|
|
112
|
+
if (prior)
|
|
113
|
+
await ctx.db.patch("financialSourceObservations", prior._id, fields);
|
|
114
|
+
else
|
|
115
|
+
await ctx.db.insert("financialSourceObservations", fields);
|
|
116
|
+
await invalidate(ctx, [...oldLegs, ...legs]);
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=settlement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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BACrB,KAAK,EAAE,MAAe;iBACvB;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,UAAU;QACV,eAAe;KAChB,CAAC;IACF,IAAI,KAAK;QACP,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;;QAClE,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Infer } from "convex/values";
|
|
2
|
+
import type { Doc } from "../_generated/dataModel.js";
|
|
3
|
+
import type { MutationCtx } from "../_generated/server.js";
|
|
4
|
+
import type { legDoc } from "./schema.js";
|
|
5
|
+
type Leg = Omit<Infer<typeof legDoc>, "_id" | "_creationTime">;
|
|
6
|
+
export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior: Pick<Doc<"financialSourceLegs">, "registrationId" | "userId" | "orgId"> | undefined): Promise<{
|
|
7
|
+
registrationId: import("convex/values").GenericId<"financialOwnership">;
|
|
8
|
+
userId: string | undefined;
|
|
9
|
+
orgId: string | undefined;
|
|
10
|
+
ownershipStatus: "ambiguous";
|
|
11
|
+
} | {
|
|
12
|
+
registrationId?: undefined;
|
|
13
|
+
userId?: undefined;
|
|
14
|
+
orgId?: undefined;
|
|
15
|
+
ownershipStatus: "ambiguous";
|
|
16
|
+
} | {
|
|
17
|
+
registrationId: import("convex/values").GenericId<"financialOwnership">;
|
|
18
|
+
userId: string | undefined;
|
|
19
|
+
orgId: string | undefined;
|
|
20
|
+
ownershipStatus: "unknown";
|
|
21
|
+
} | {
|
|
22
|
+
registrationId?: undefined;
|
|
23
|
+
userId?: undefined;
|
|
24
|
+
orgId?: undefined;
|
|
25
|
+
ownershipStatus: "unknown";
|
|
26
|
+
} | {
|
|
27
|
+
registrationId: import("convex/values").GenericId<"financialOwnership">;
|
|
28
|
+
userId: string | undefined;
|
|
29
|
+
orgId: string | undefined;
|
|
30
|
+
ownershipStatus: "contradictory";
|
|
31
|
+
} | {
|
|
32
|
+
registrationId?: undefined;
|
|
33
|
+
userId?: undefined;
|
|
34
|
+
orgId?: undefined;
|
|
35
|
+
ownershipStatus: "contradictory";
|
|
36
|
+
} | {
|
|
37
|
+
registrationId: import("convex/values").GenericId<"financialOwnership">;
|
|
38
|
+
userId: string;
|
|
39
|
+
orgId: string | undefined;
|
|
40
|
+
ownershipStatus: "registered";
|
|
41
|
+
}>;
|
|
42
|
+
export declare function invalidate(ctx: MutationCtx, legs: Pick<Leg, "bucketKey" | "userId" | "orgId">[]): Promise<void>;
|
|
43
|
+
export declare function hasInvalidLegIdentity(row: Doc<"settlementAllocations">, legs: Doc<"financialSourceLegs">[]): boolean;
|
|
44
|
+
export declare function settlementFingerprint(row: Doc<"settlementAllocations">): Promise<string>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=settlementHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlementHelpers.d.ts","sourceRoot":"","sources":["../../../src/component/financialObservations/settlementHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAO3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,KAAK,GAAG,eAAe,CAAC,CAAC;AAC/D,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EACD,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,gBAAgB,GAAG,QAAQ,GAAG,OAAO,CAAC,GACvE,SAAS;;;;qBAeuB,WAAW;;;;;qBAAX,WAAW;;;;;qBACM,SAAS;;;;;qBAAT,SAAS;;;;;qBAO1B,eAAe;;;;;qBAAf,eAAe;;;;;qBAKhC,YAAY;GAEhC;AACD,wBAAsB,UAAU,CAC9B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC,EAAE,iBAQpD;AACD,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,GAAG,CAAC,uBAAuB,CAAC,EACjC,IAAI,EAAE,GAAG,CAAC,qBAAqB,CAAC,EAAE,WAenC;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,uBAAuB,CAAC,mBAa5E"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { generateIdempotencyKey } from "../lib/idempotency.js";
|
|
2
|
+
import { advanceObservationGeneration, bucketScope, ownerScope, } from "./generations.js";
|
|
3
|
+
export async function legOwnership(ctx, bucketKey, prior) {
|
|
4
|
+
const registrations = await ctx.db
|
|
5
|
+
.query("financialOwnership")
|
|
6
|
+
.withIndex("by_bucket_key", (q) => q.eq("bucketKey", bucketKey))
|
|
7
|
+
.take(2);
|
|
8
|
+
const registration = registrations[0];
|
|
9
|
+
const pin = prior?.registrationId
|
|
10
|
+
? {
|
|
11
|
+
registrationId: prior.registrationId,
|
|
12
|
+
userId: prior.userId,
|
|
13
|
+
orgId: prior.orgId,
|
|
14
|
+
}
|
|
15
|
+
: {};
|
|
16
|
+
if (registrations.length > 1)
|
|
17
|
+
return { ...pin, ownershipStatus: "ambiguous" };
|
|
18
|
+
if (!registration)
|
|
19
|
+
return { ...pin, ownershipStatus: "unknown" };
|
|
20
|
+
if (prior?.registrationId &&
|
|
21
|
+
(prior.registrationId !== registration._id ||
|
|
22
|
+
prior.userId !== registration.userId ||
|
|
23
|
+
prior.orgId !== registration.orgId))
|
|
24
|
+
return { ...pin, ownershipStatus: "contradictory" };
|
|
25
|
+
return {
|
|
26
|
+
registrationId: registration._id,
|
|
27
|
+
userId: registration.userId,
|
|
28
|
+
orgId: registration.orgId,
|
|
29
|
+
ownershipStatus: "registered",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function invalidate(ctx, legs) {
|
|
33
|
+
const scopes = new Set();
|
|
34
|
+
for (const leg of legs) {
|
|
35
|
+
scopes.add(bucketScope(leg.bucketKey));
|
|
36
|
+
if (leg.userId !== undefined)
|
|
37
|
+
scopes.add(ownerScope(leg.userId, leg.orgId));
|
|
38
|
+
}
|
|
39
|
+
for (const scope of scopes)
|
|
40
|
+
await advanceObservationGeneration(ctx, scope);
|
|
41
|
+
}
|
|
42
|
+
export function hasInvalidLegIdentity(row, legs) {
|
|
43
|
+
const slots = new Set();
|
|
44
|
+
return legs.some((leg) => {
|
|
45
|
+
const original = row.transfers[leg.legIndex];
|
|
46
|
+
const isInvalid = slots.has(leg.legIndex) ||
|
|
47
|
+
!Number.isInteger(leg.legIndex) ||
|
|
48
|
+
!original ||
|
|
49
|
+
leg.sourceChargeId !== row.sourceChargeId ||
|
|
50
|
+
leg.bucketKey !== original.destinationAccountId ||
|
|
51
|
+
leg.role !== original.role;
|
|
52
|
+
slots.add(leg.legIndex);
|
|
53
|
+
return isInvalid;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export async function settlementFingerprint(row) {
|
|
57
|
+
return generateIdempotencyKey("settlement-allocation-observation-v1", {
|
|
58
|
+
sourceChargeId: row.sourceChargeId,
|
|
59
|
+
paymentIntentId: row.paymentIntentId,
|
|
60
|
+
sourceInvoiceId: row.sourceInvoiceId,
|
|
61
|
+
gross: row.gross,
|
|
62
|
+
currency: row.currency,
|
|
63
|
+
processingFee: row.processingFee,
|
|
64
|
+
platformNet: row.platformNet,
|
|
65
|
+
adjustmentAmount: row.adjustmentAmount,
|
|
66
|
+
paymentId: row.paymentId,
|
|
67
|
+
transfers: row.transfers,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=settlementHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlementHelpers.js","sourceRoot":"","sources":["../../../src/component/financialObservations/settlementHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACL,4BAA4B,EAC5B,WAAW,EACX,UAAU,GACX,MAAM,kBAAkB,CAAC;AAI1B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAgB,EAChB,SAAiB,EACjB,KAEa;IAEb,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,EAAE;SAC/B,KAAK,CAAC,oBAAoB,CAAC;SAC3B,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SAC/D,IAAI,CAAC,CAAC,CAAC,CAAC;IACX,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,KAAK,EAAE,cAAc;QAC/B,CAAC,CAAC;YACE,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB;QACH,CAAC,CAAC,EAAE,CAAC;IACP,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC;QAC1B,OAAO,EAAE,GAAG,GAAG,EAAE,eAAe,EAAE,WAAoB,EAAE,CAAC;IAC3D,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,GAAG,GAAG,EAAE,eAAe,EAAE,SAAkB,EAAE,CAAC;IAC1E,IACE,KAAK,EAAE,cAAc;QACrB,CAAC,KAAK,CAAC,cAAc,KAAK,YAA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AC/B,CAAC,QAAQ;YACT,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC,cAAc;YACzC,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC,oBAAoB;YAC/C,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC;QAC7B,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,GAAiC;IAC3E,OAAO,sBAAsB,CAAC,sCAAsC,EAAE;QACpE,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;QACtC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;KACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Doc, Id } from "../_generated/dataModel.js";
|
|
2
|
+
import type { MutationCtx, QueryCtx } from "../_generated/server.js";
|
|
3
|
+
export declare const synchronousTransferFactLimit = 100;
|
|
4
|
+
/** Preserve compact source references atomically before the original operation is deleted. */
|
|
5
|
+
export declare function deferTransferFacts(ctx: MutationCtx, operation: Doc<"transferReversalOps">, transferIds: Id<"transfers">[], producer?: "transfer_frontier_release" | "transfer_frontier_claim"): Promise<void>;
|
|
6
|
+
/** Global invalidation keeps a deferred batch visible even when its owner scopes are not indexed yet. */
|
|
7
|
+
export declare function transferReaderState(ctx: QueryCtx): Promise<{
|
|
8
|
+
coverage: "unknown";
|
|
9
|
+
producerGeneration: number | null;
|
|
10
|
+
hasDeferredWork: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=transferBatches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transferBatches.d.ts","sourceRoot":"","sources":["../../../src/component/financialObservations/transferBatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AASrE,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,8FAA8F;AAC9F,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,GAAG,CAAC,qBAAqB,CAAC,EACrC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,EAC9B,QAAQ,GACJ,2BAA2B,GAC3B,yBAAuD,iBAiE5D;AACD,yGAAyG;AACzG,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,QAAQ;cAMzC,SAAS;;;GAItB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { advanceObservationGeneration, observationGeneration, } from "./generations.js";
|
|
2
|
+
import { transferFingerprint, transferProducerScope, } from "./transferHelpers.js";
|
|
3
|
+
export const synchronousTransferFactLimit = 100;
|
|
4
|
+
/** Preserve compact source references atomically before the original operation is deleted. */
|
|
5
|
+
export async function deferTransferFacts(ctx, operation, transferIds, producer = "transfer_frontier_release") {
|
|
6
|
+
const existing = await ctx.db
|
|
7
|
+
.query("financialTransferBatches")
|
|
8
|
+
.withIndex("by_original_operation_producer", (q) => q.eq("originalOperationId", operation._id).eq("producer", producer))
|
|
9
|
+
.take(2);
|
|
10
|
+
const fingerprint = await transferFingerprint({
|
|
11
|
+
operation,
|
|
12
|
+
transferIds,
|
|
13
|
+
producer,
|
|
14
|
+
});
|
|
15
|
+
const prior = existing[0];
|
|
16
|
+
const isContradictory = !!prior && (prior.isContradictory || prior.fingerprint !== fingerprint);
|
|
17
|
+
if (existing.length === 1 &&
|
|
18
|
+
prior.observedFingerprint === fingerprint &&
|
|
19
|
+
prior.isContradictory === isContradictory)
|
|
20
|
+
return;
|
|
21
|
+
if (existing.length === 1) {
|
|
22
|
+
const generation = Number.isSafeInteger(prior.generation) &&
|
|
23
|
+
prior.generation >= 1 &&
|
|
24
|
+
Number.isSafeInteger(prior.generation + 1)
|
|
25
|
+
? prior.generation + 1
|
|
26
|
+
: 0;
|
|
27
|
+
await ctx.db.patch("financialTransferBatches", prior._id, {
|
|
28
|
+
observedFingerprint: fingerprint,
|
|
29
|
+
generation,
|
|
30
|
+
isContradictory: isContradictory || generation === 0,
|
|
31
|
+
...(isContradictory || generation === 0
|
|
32
|
+
? {
|
|
33
|
+
state: "pending",
|
|
34
|
+
...(prior.continuation
|
|
35
|
+
? {
|
|
36
|
+
continuation: {
|
|
37
|
+
...prior.continuation,
|
|
38
|
+
state: "held",
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
}
|
|
43
|
+
: {}),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (existing.length === 0)
|
|
47
|
+
await ctx.db.insert("financialTransferBatches", {
|
|
48
|
+
originalOperationId: operation._id,
|
|
49
|
+
operationId: operation.operationId,
|
|
50
|
+
sourceChargeId: operation.sourceChargeId,
|
|
51
|
+
producer,
|
|
52
|
+
producerVersion: 1,
|
|
53
|
+
fingerprint,
|
|
54
|
+
observedFingerprint: fingerprint,
|
|
55
|
+
isContradictory: false,
|
|
56
|
+
generation: 1,
|
|
57
|
+
referenceCount: transferIds.length,
|
|
58
|
+
transferIds,
|
|
59
|
+
isOverflow: true,
|
|
60
|
+
state: "pending",
|
|
61
|
+
});
|
|
62
|
+
await advanceObservationGeneration(ctx, transferProducerScope);
|
|
63
|
+
}
|
|
64
|
+
/** Global invalidation keeps a deferred batch visible even when its owner scopes are not indexed yet. */
|
|
65
|
+
export async function transferReaderState(ctx) {
|
|
66
|
+
const pending = await ctx.db
|
|
67
|
+
.query("financialTransferBatches")
|
|
68
|
+
.withIndex("by_state", (q) => q.eq("state", "pending"))
|
|
69
|
+
.take(1);
|
|
70
|
+
return {
|
|
71
|
+
coverage: "unknown",
|
|
72
|
+
producerGeneration: await observationGeneration(ctx, transferProducerScope),
|
|
73
|
+
hasDeferredWork: pending.length > 0,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=transferBatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transferBatches.js","sourceRoot":"","sources":["../../../src/component/financialObservations/transferBatches.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAChD,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAgB,EAChB,SAAqC,EACrC,WAA8B,EAC9B,QAAQ,GAEwB,2BAA2B;IAE3D,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE;SAC1B,KAAK,CAAC,0BAA0B,CAAC;SACjC,SAAS,CAAC,gCAAgC,EAAE,CAAC,CAAC,EAAE,EAAE,CACjD,CAAC,CAAC,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CACpE;SACA,IAAI,CAAC,CAAC,CAAC,CAAC;IACX,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC;QAC5C,SAAS;QACT,WAAW;QACX,QAAQ;KACT,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,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