@fantastic.dev/better-stripe 0.92.0 → 0.94.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 +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operationJournal.js +378 -0
- package/dist/client/billing/renewalAttach/internal/operationJournal.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +44 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +251 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +562 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +281 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +562 -0
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +281 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +16 -3
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +6 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +406 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/mutations.d.ts +27 -27
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/earnings/triggers.d.ts +294 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- package/dist/component/renewalOperations/helpers.d.ts +236 -0
- package/dist/component/renewalOperations/helpers.d.ts.map +1 -0
- package/dist/component/renewalOperations/helpers.js +457 -0
- package/dist/component/renewalOperations/helpers.js.map +1 -0
- package/dist/component/renewalOperations/mutations.d.ts +252 -0
- package/dist/component/renewalOperations/mutations.d.ts.map +1 -0
- package/dist/component/renewalOperations/mutations.js +340 -0
- package/dist/component/renewalOperations/mutations.js.map +1 -0
- package/dist/component/renewalOperations/queries.d.ts +163 -0
- package/dist/component/renewalOperations/queries.d.ts.map +1 -0
- package/dist/component/renewalOperations/queries.js +167 -0
- package/dist/component/renewalOperations/queries.js.map +1 -0
- package/dist/component/renewalOperations/schema.d.ts +1988 -0
- package/dist/component/renewalOperations/schema.d.ts.map +1 -0
- package/dist/component/renewalOperations/schema.js +227 -0
- package/dist/component/renewalOperations/schema.js.map +1 -0
- package/dist/component/schema.d.ts +281 -0
- package/dist/component/schema.js +5 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +281 -0
- package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +297 -16
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
- package/dist/shared/renewalOperationJournal.d.ts +43 -0
- package/dist/shared/renewalOperationJournal.d.ts.map +1 -0
- package/dist/shared/renewalOperationJournal.js +294 -0
- package/dist/shared/renewalOperationJournal.js.map +1 -0
- package/docs/renewal-context-reads.md +180 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/operationJournal.acknowledgement.integration.test.ts +500 -0
- package/src/client/billing/renewalAttach/internal/operationJournal.c10.integration.test.ts +560 -0
- package/src/client/billing/renewalAttach/internal/operationJournal.controls.integration.test.ts +356 -0
- package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +560 -0
- package/src/client/billing/renewalAttach/internal/operationJournal.methods.integration.test.ts +534 -0
- package/src/client/billing/renewalAttach/internal/operationJournal.ts +561 -0
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +334 -0
- package/src/client/billing/renewalAttach/internal/producer/producerGuards.integration.test.ts +323 -0
- package/src/client/billing/renewalAttach/internal/producer/producerInitial.integration.test.ts +301 -0
- package/src/client/billing/renewalAttach/internal/producer/producerIsolation.integration.test.ts +531 -0
- package/src/client/index.ts +24 -3
- package/src/component/_generated/api.ts +6 -0
- package/src/component/_generated/component.ts +450 -0
- package/src/component/renewalOperations/acknowledgement.fixtures.ts +552 -0
- package/src/component/renewalOperations/acknowledgement.test.ts +573 -0
- package/src/component/renewalOperations/acknowledgementReads.test.ts +442 -0
- package/src/component/renewalOperations/acknowledgementV2.test.ts +493 -0
- package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +373 -0
- package/src/component/renewalOperations/basisBinding.test.ts +567 -0
- package/src/component/renewalOperations/basisLifecycle.test.ts +569 -0
- package/src/component/renewalOperations/boundHistory.test.ts +474 -0
- package/src/component/renewalOperations/helpers.ts +592 -0
- package/src/component/renewalOperations/historyReads.test.ts +595 -0
- package/src/component/renewalOperations/initialBasis.test.ts +578 -0
- package/src/component/renewalOperations/journal.test.ts +567 -0
- package/src/component/renewalOperations/mutations.ts +456 -0
- package/src/component/renewalOperations/payload.test.ts +589 -0
- package/src/component/renewalOperations/payloadEncoding.test.ts +592 -0
- package/src/component/renewalOperations/queries.ts +204 -0
- package/src/component/renewalOperations/schema.ts +268 -0
- package/src/component/renewalOperations/timingPolicy.fixtures.ts +193 -0
- package/src/component/renewalOperations/timingPolicy.test.ts +523 -0
- package/src/component/schema.ts +11 -0
- package/src/shared/renewalOperationJournal.ts +333 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** Full immutable DATA, not a dispatch or Owner capability. */
|
|
2
|
+
export declare const loadAuthorizedOperation: import("convex/server").RegisteredQuery<"public", {
|
|
3
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
4
|
+
}, Promise<{
|
|
5
|
+
recordVersion: 2;
|
|
6
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
7
|
+
recordJSON: string;
|
|
8
|
+
revision: 0;
|
|
9
|
+
activeAttempt: null;
|
|
10
|
+
initialBasis: null;
|
|
11
|
+
} | {
|
|
12
|
+
recordVersion: 2;
|
|
13
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
14
|
+
recordJSON: string;
|
|
15
|
+
revision: 1;
|
|
16
|
+
activeAttempt: {
|
|
17
|
+
key: string;
|
|
18
|
+
apiVersion: string;
|
|
19
|
+
firstDispatchedAt: number;
|
|
20
|
+
accountJSON: string;
|
|
21
|
+
stage: "attach";
|
|
22
|
+
recordVersion: 2;
|
|
23
|
+
timingPolicyJSON: string;
|
|
24
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
25
|
+
payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
26
|
+
authorizationScope: string;
|
|
27
|
+
authorizationId: string;
|
|
28
|
+
authorizationRevision: number;
|
|
29
|
+
logicalOperationId: string;
|
|
30
|
+
requestBinding: string;
|
|
31
|
+
ordinal: 1;
|
|
32
|
+
preparedRevision: 0;
|
|
33
|
+
committedRevision: 1;
|
|
34
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
35
|
+
};
|
|
36
|
+
initialBasis: {
|
|
37
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
38
|
+
basisJSON: string;
|
|
39
|
+
policyJSON: string;
|
|
40
|
+
sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
41
|
+
stage: "attach";
|
|
42
|
+
version: 1;
|
|
43
|
+
} | null;
|
|
44
|
+
} | {
|
|
45
|
+
recordVersion?: undefined;
|
|
46
|
+
initialBasis?: undefined;
|
|
47
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
48
|
+
recordJSON: string;
|
|
49
|
+
revision: 0 | 1;
|
|
50
|
+
activeAttempt: Omit<{
|
|
51
|
+
stage: "attach" | "configure";
|
|
52
|
+
key: string;
|
|
53
|
+
apiVersion: string;
|
|
54
|
+
firstDispatchedAt: number;
|
|
55
|
+
accountJSON: string;
|
|
56
|
+
basisJSON: string;
|
|
57
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
58
|
+
payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
59
|
+
authorizationScope: string;
|
|
60
|
+
authorizationId: string;
|
|
61
|
+
authorizationRevision: number;
|
|
62
|
+
logicalOperationId: string;
|
|
63
|
+
requestBinding: string;
|
|
64
|
+
ordinal: 1;
|
|
65
|
+
preparedRevision: 0;
|
|
66
|
+
committedRevision: 1;
|
|
67
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
68
|
+
recordJSON: string;
|
|
69
|
+
}, "recordJSON"> | null;
|
|
70
|
+
} | null>>;
|
|
71
|
+
/** Checked bounded manifest; complete event JSON is retained separately. */
|
|
72
|
+
export declare const readAttempt: import("convex/server").RegisteredQuery<"public", {
|
|
73
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
74
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
75
|
+
}, Promise<{
|
|
76
|
+
reservation: {
|
|
77
|
+
key: string;
|
|
78
|
+
apiVersion: string;
|
|
79
|
+
firstDispatchedAt: number;
|
|
80
|
+
accountJSON: string;
|
|
81
|
+
stage: "attach";
|
|
82
|
+
recordVersion: 2;
|
|
83
|
+
timingPolicyJSON: string;
|
|
84
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
85
|
+
payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
86
|
+
authorizationScope: string;
|
|
87
|
+
authorizationId: string;
|
|
88
|
+
authorizationRevision: number;
|
|
89
|
+
logicalOperationId: string;
|
|
90
|
+
requestBinding: string;
|
|
91
|
+
ordinal: 1;
|
|
92
|
+
preparedRevision: 0;
|
|
93
|
+
committedRevision: 1;
|
|
94
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
95
|
+
recordJSON: string;
|
|
96
|
+
} | {
|
|
97
|
+
stage: "attach" | "configure";
|
|
98
|
+
key: string;
|
|
99
|
+
apiVersion: string;
|
|
100
|
+
firstDispatchedAt: number;
|
|
101
|
+
accountJSON: string;
|
|
102
|
+
basisJSON: string;
|
|
103
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
104
|
+
payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
105
|
+
authorizationScope: string;
|
|
106
|
+
authorizationId: string;
|
|
107
|
+
authorizationRevision: number;
|
|
108
|
+
logicalOperationId: string;
|
|
109
|
+
requestBinding: string;
|
|
110
|
+
ordinal: 1;
|
|
111
|
+
preparedRevision: 0;
|
|
112
|
+
committedRevision: 1;
|
|
113
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
114
|
+
recordJSON: string;
|
|
115
|
+
};
|
|
116
|
+
events: {
|
|
117
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
118
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
119
|
+
stage: "attach" | "configure";
|
|
120
|
+
sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
121
|
+
sequence: 1 | 2 | 3;
|
|
122
|
+
binding: string;
|
|
123
|
+
payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
124
|
+
eventId: import("convex/values").GenericId<"renewalOperationEvents">;
|
|
125
|
+
}[];
|
|
126
|
+
} | null>>;
|
|
127
|
+
/** One complete event, scoped to the checked operation and active attempt. */
|
|
128
|
+
export declare const readStageEvent: import("convex/server").RegisteredQuery<"public", {
|
|
129
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
130
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
131
|
+
sequence: 1 | 2 | 3;
|
|
132
|
+
}, Promise<{
|
|
133
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
134
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
135
|
+
stage: "attach" | "configure";
|
|
136
|
+
sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
137
|
+
sequence: 1 | 2 | 3;
|
|
138
|
+
binding: string;
|
|
139
|
+
payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
140
|
+
eventId: import("convex/values").GenericId<"renewalOperationEvents">;
|
|
141
|
+
dataJSON: string;
|
|
142
|
+
} | null>>;
|
|
143
|
+
/** Full retained acknowledgement DATA; never runtime ownership or replay authority. */
|
|
144
|
+
export declare const readProviderAcknowledgement: import("convex/server").RegisteredQuery<"public", {
|
|
145
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
146
|
+
}, Promise<{
|
|
147
|
+
retention: {
|
|
148
|
+
status: "retained";
|
|
149
|
+
operationId: import("convex/values").GenericId<"renewalOperations">;
|
|
150
|
+
attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
|
|
151
|
+
dispatchEventId: import("convex/values").GenericId<"renewalOperationEvents">;
|
|
152
|
+
dispatchPayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
153
|
+
receiptBinding: string;
|
|
154
|
+
receiptPayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
155
|
+
responseEventId: import("convex/values").GenericId<"renewalOperationEvents">;
|
|
156
|
+
responsePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
157
|
+
schemaVersion: 1;
|
|
158
|
+
sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
|
|
159
|
+
stage: "attach";
|
|
160
|
+
};
|
|
161
|
+
receiptJSON: string;
|
|
162
|
+
} | null>>;
|
|
163
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/renewalOperations/queries.ts"],"names":[],"mappings":"AAgBA,+DAA+D;AAC/D,eAAO,MAAM,uBAAuB;;;mBAeX,CAAC;;;cAGN,CAAC;;;;mBASE,CAAC;;;cAGN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuBjB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6BtB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;UAgCzB,CAAC;AAEH,uFAAuF;AACvF,eAAO,MAAM,2BAA2B;;;;gBA0BpB,UAAU;;;;;;;;;;;;;;UAqC5B,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { query } from "../_generated/server.js";
|
|
3
|
+
import { originalRecord, currentReservation, eventChain, validateAttachAcknowledgement, validateKnownAcknowledgement, validateV2KnownAcknowledgement, } from "./helpers.js";
|
|
4
|
+
import { loadedResult, attemptResult, providerAcknowledgementReadResult, } from "./schema.js";
|
|
5
|
+
/** Full immutable DATA, not a dispatch or Owner capability. */
|
|
6
|
+
export const loadAuthorizedOperation = query({
|
|
7
|
+
args: { operationId: v.id("renewalOperations") },
|
|
8
|
+
returns: loadedResult,
|
|
9
|
+
handler: async (ctx, args) => {
|
|
10
|
+
const row = await ctx.db.get("renewalOperations", args.operationId);
|
|
11
|
+
if (!row)
|
|
12
|
+
return null;
|
|
13
|
+
const full = await originalRecord(ctx, row);
|
|
14
|
+
const reservation = await currentReservation(ctx, row, full);
|
|
15
|
+
if (reservation && "recordVersion" in reservation) {
|
|
16
|
+
const events = await eventChain(ctx, reservation);
|
|
17
|
+
await validateV2KnownAcknowledgement(ctx, row, full, reservation, events);
|
|
18
|
+
}
|
|
19
|
+
if ("recordVersion" in full) {
|
|
20
|
+
if (!reservation)
|
|
21
|
+
return {
|
|
22
|
+
recordVersion: 2,
|
|
23
|
+
operationId: row._id,
|
|
24
|
+
recordJSON: full.json,
|
|
25
|
+
revision: 0,
|
|
26
|
+
activeAttempt: null,
|
|
27
|
+
initialBasis: null,
|
|
28
|
+
};
|
|
29
|
+
if (!("recordVersion" in reservation))
|
|
30
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
31
|
+
const { recordJSON: _recordJSON, ...summary } = reservation;
|
|
32
|
+
void _recordJSON;
|
|
33
|
+
return {
|
|
34
|
+
recordVersion: 2,
|
|
35
|
+
operationId: row._id,
|
|
36
|
+
recordJSON: full.json,
|
|
37
|
+
revision: 1,
|
|
38
|
+
activeAttempt: summary,
|
|
39
|
+
initialBasis: row.initialBasis ?? null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (reservation && "recordVersion" in reservation)
|
|
43
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
44
|
+
let activeAttempt = null;
|
|
45
|
+
if (reservation) {
|
|
46
|
+
const { recordJSON: _recordJSON, ...summary } = reservation;
|
|
47
|
+
void _recordJSON;
|
|
48
|
+
activeAttempt = summary;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
operationId: row._id,
|
|
52
|
+
recordJSON: full.json,
|
|
53
|
+
revision: row.revision,
|
|
54
|
+
activeAttempt,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
/** Checked bounded manifest; complete event JSON is retained separately. */
|
|
59
|
+
export const readAttempt = query({
|
|
60
|
+
args: {
|
|
61
|
+
operationId: v.id("renewalOperations"),
|
|
62
|
+
attemptId: v.id("renewalOperationAttempts"),
|
|
63
|
+
},
|
|
64
|
+
returns: attemptResult,
|
|
65
|
+
handler: async (ctx, args) => {
|
|
66
|
+
const row = await ctx.db.get("renewalOperations", args.operationId);
|
|
67
|
+
if (!row)
|
|
68
|
+
return null;
|
|
69
|
+
const full = await originalRecord(ctx, row);
|
|
70
|
+
const reservation = await currentReservation(ctx, row, full);
|
|
71
|
+
if (!reservation || reservation.attemptId !== args.attemptId)
|
|
72
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
73
|
+
const checkedEvents = await eventChain(ctx, reservation);
|
|
74
|
+
if ("recordVersion" in reservation)
|
|
75
|
+
await validateV2KnownAcknowledgement(ctx, row, full, reservation, checkedEvents);
|
|
76
|
+
const events = checkedEvents.map((event) => {
|
|
77
|
+
const { dataJSON: _dataJSON, ...descriptor } = event;
|
|
78
|
+
void _dataJSON;
|
|
79
|
+
return descriptor;
|
|
80
|
+
});
|
|
81
|
+
return { reservation, events };
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
/** One complete event, scoped to the checked operation and active attempt. */
|
|
85
|
+
export const readStageEvent = query({
|
|
86
|
+
args: {
|
|
87
|
+
operationId: v.id("renewalOperations"),
|
|
88
|
+
attemptId: v.id("renewalOperationAttempts"),
|
|
89
|
+
sequence: v.union(v.literal(1), v.literal(2), v.literal(3)),
|
|
90
|
+
},
|
|
91
|
+
returns: v.union(v.null(), v.object({
|
|
92
|
+
operationId: v.id("renewalOperations"),
|
|
93
|
+
attemptId: v.id("renewalOperationAttempts"),
|
|
94
|
+
stage: v.union(v.literal("attach"), v.literal("configure")),
|
|
95
|
+
sourcePayloadId: v.id("renewalOperationPayloads"),
|
|
96
|
+
sequence: v.union(v.literal(1), v.literal(2), v.literal(3)),
|
|
97
|
+
binding: v.string(),
|
|
98
|
+
payloadId: v.id("renewalOperationPayloads"),
|
|
99
|
+
eventId: v.id("renewalOperationEvents"),
|
|
100
|
+
dataJSON: v.string(),
|
|
101
|
+
})),
|
|
102
|
+
handler: async (ctx, args) => {
|
|
103
|
+
const row = await ctx.db.get("renewalOperations", args.operationId);
|
|
104
|
+
if (!row)
|
|
105
|
+
return null;
|
|
106
|
+
const full = await originalRecord(ctx, row);
|
|
107
|
+
const reservation = await currentReservation(ctx, row, full);
|
|
108
|
+
if (!reservation || reservation.attemptId !== args.attemptId)
|
|
109
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
110
|
+
const events = await eventChain(ctx, reservation);
|
|
111
|
+
if ("recordVersion" in reservation)
|
|
112
|
+
await validateV2KnownAcknowledgement(ctx, row, full, reservation, events);
|
|
113
|
+
return events.find((event) => event.sequence === args.sequence) ?? null;
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
/** Full retained acknowledgement DATA; never runtime ownership or replay authority. */
|
|
117
|
+
export const readProviderAcknowledgement = query({
|
|
118
|
+
args: { operationId: v.id("renewalOperations") },
|
|
119
|
+
returns: providerAcknowledgementReadResult,
|
|
120
|
+
handler: async (ctx, { operationId }) => {
|
|
121
|
+
try {
|
|
122
|
+
const row = await ctx.db.get("renewalOperations", operationId);
|
|
123
|
+
if (!row)
|
|
124
|
+
return null;
|
|
125
|
+
const full = await originalRecord(ctx, row);
|
|
126
|
+
const reservation = await currentReservation(ctx, row, full);
|
|
127
|
+
if (!reservation) {
|
|
128
|
+
if (row.knownAcknowledgement !== undefined)
|
|
129
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const events = await eventChain(ctx, reservation);
|
|
133
|
+
if ("recordVersion" in reservation) {
|
|
134
|
+
const known = await validateV2KnownAcknowledgement(ctx, row, full, reservation, events);
|
|
135
|
+
if (known === null)
|
|
136
|
+
return null;
|
|
137
|
+
return {
|
|
138
|
+
retention: {
|
|
139
|
+
status: "retained",
|
|
140
|
+
operationId,
|
|
141
|
+
...known.retained,
|
|
142
|
+
},
|
|
143
|
+
receiptJSON: known.admitted.receiptJSON,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (row.knownAcknowledgement === undefined)
|
|
147
|
+
return null;
|
|
148
|
+
if (reservation.stage !== "attach")
|
|
149
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
150
|
+
const payload = await ctx.db.get("renewalOperationPayloads", row.knownAcknowledgement.receiptPayloadId);
|
|
151
|
+
if (!payload)
|
|
152
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
153
|
+
const admitted = await validateAttachAcknowledgement(full, reservation, events, payload.json);
|
|
154
|
+
const retained = await validateKnownAcknowledgement(ctx, row, reservation, events, admitted);
|
|
155
|
+
if (retained === null)
|
|
156
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
157
|
+
return {
|
|
158
|
+
retention: { status: "retained", operationId, ...retained },
|
|
159
|
+
receiptJSON: admitted.receiptJSON,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
throw Error("RENEWAL_JOURNAL_CONFLICT");
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/renewalOperations/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,iCAAiC,GAClC,MAAM,aAAa,CAAC;AAErB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;IAC3C,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,EAAE;IAChD,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,M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