@fantastic.dev/better-stripe 0.98.0 → 0.99.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 +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/attachEvents.d.ts +22 -0
- package/dist/client/billing/renewalAttach/internal/c10/attachEvents.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/attachEvents.js +13 -5
- package/dist/client/billing/renewalAttach/internal/c10/attachEvents.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.d.ts +17 -0
- package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.js +140 -0
- package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +9 -11
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +3 -380
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +138 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +64 -139
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/transportKernel.d.ts +63 -0
- package/dist/client/billing/renewalAttach/internal/operations/transportKernel.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/transportKernel.js +380 -0
- package/dist/client/billing/renewalAttach/internal/operations/transportKernel.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +6 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.d.ts +56 -0
- package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.js +49 -0
- package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/operationFactory.d.ts +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/operationFactory.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/operationFactory.js +3 -2
- package/dist/client/billing/renewalAttach/internal/producer/operationFactory.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js +87 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.d.ts +368 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.js +106 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/output.js +22 -8
- package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/record.js +10 -2
- package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +69 -156
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +18 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js +15 -1
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/earnings/triggers.d.ts +16 -16
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +44 -3
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +3 -3
- package/src/client/billing/renewalAttach/internal/c10/attachEvents.ts +17 -5
- package/src/client/billing/renewalAttach/internal/operations/actorFailureControl.ts +165 -0
- package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +4 -498
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +83 -160
- package/src/client/billing/renewalAttach/internal/operations/transportKernel.ts +500 -0
- package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +6 -0
- package/src/client/billing/renewalAttach/internal/producer/journalWorkFactory.ts +54 -0
- package/src/client/billing/renewalAttach/internal/producer/operationFactory.ts +3 -2
- package/src/client/billing/renewalAttach/internal/producer/producerRecovery.integration.test.ts +394 -0
- package/src/client/billing/renewalAttach/internal/producer/producerRecoveryControls.integration.test.ts +437 -0
- package/src/client/billing/renewalAttach/internal/producer/producerRecoveryIsolation.integration.test.ts +332 -0
- package/src/client/billing/renewalAttach/internal/producer/recoveryEntry.ts +109 -0
- package/src/client/billing/renewalAttach/internal/producer/recoveryFactory.ts +135 -0
- package/src/client/billing/renewalAttach/internal/recovery/output.ts +34 -8
- package/src/client/billing/renewalAttach/internal/recovery/record.ts +16 -2
- package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +107 -188
- package/src/client/billing/renewalAttach/internal/recovery/relation.ts +17 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +14 -1
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { sevenWire } from "../c10/ownData.js";
|
|
2
2
|
import { types } from "node:util";
|
|
3
|
-
import { OWNER } from "../originalOwner.js";
|
|
3
|
+
import { OWNER as LEGACY_OWNER } from "../originalOwner.js";
|
|
4
|
+
import { readInitialLineage } from "../producer/lineageAuthority.js";
|
|
5
|
+
import { ownerForInitialLineage } from "../producer/ownerFactory.js";
|
|
6
|
+
import { ownedForInitialLineage } from "../operations/ownedAwait.js";
|
|
7
|
+
import { createInitialMaterialClassifiers } from "../material/classifiers.js";
|
|
8
|
+
import {
|
|
9
|
+
recoveryOperationForLineage,
|
|
10
|
+
assertReplayFrontierForLineage,
|
|
11
|
+
} from "../producer/recoveryFactory.js";
|
|
12
|
+
import { createRecoveryAttachEventCompiler } from "../c10/attachEvents.js";
|
|
13
|
+
import { retainInitialReceiptForLineage } from "../producer/operationFactory.js";
|
|
4
14
|
import {
|
|
5
15
|
prepareRenewalPriceReplacementV2 as c1,
|
|
6
16
|
prepareRenewalScheduleAttachmentV2 as c2,
|
|
@@ -14,13 +24,12 @@ import {
|
|
|
14
24
|
import { validateOwnedReadMaterial } from "../material/readMaterial.js";
|
|
15
25
|
import {
|
|
16
26
|
closed,
|
|
17
|
-
type AttachRequest,
|
|
18
27
|
type SourceMethod,
|
|
19
28
|
type FailureControl,
|
|
20
29
|
} from "../operations/types.js";
|
|
21
30
|
import { equal } from "../../../renewalAggregate/shared.js";
|
|
22
|
-
import { owned } from "../operations/ownedAwait.js";
|
|
23
|
-
import
|
|
31
|
+
import { owned as legacyOwned } from "../operations/ownedAwait.js";
|
|
32
|
+
import { captureActorFailureControl } from "../operations/actorFailureControl.js";
|
|
24
33
|
import { bindRawAcquisitionFromSource } from "../acquisition/ownedAcquisition.js";
|
|
25
34
|
import { createAttachEventCompiler } from "../c10/attachEvents.js";
|
|
26
35
|
import {
|
|
@@ -29,9 +38,19 @@ import {
|
|
|
29
38
|
ORIGINAL_ORIGIN_ASSOCIATION,
|
|
30
39
|
} from "../operations/sourceOperations.js";
|
|
31
40
|
import { createRecoveryOwnedTransportWithAttemptCapability as createPair } from "../operations/fixedTransport.js";
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
import {
|
|
42
|
+
captureRecoveryRecord,
|
|
43
|
+
captureRecoveryRecordForLineage,
|
|
44
|
+
verifyRecoveryRecord,
|
|
45
|
+
} from "./record.js";
|
|
46
|
+
import {
|
|
47
|
+
replayCouponEligibility,
|
|
48
|
+
replayCouponEligibilityForLineage,
|
|
49
|
+
} from "./relation.js";
|
|
50
|
+
import {
|
|
51
|
+
admitRecoveryOutput,
|
|
52
|
+
admitRecoveryOutputForLineage,
|
|
53
|
+
} from "./output.js";
|
|
35
54
|
import { admitReplayMaterial, assertReplayMaterial } from "./material.js";
|
|
36
55
|
|
|
37
56
|
type Pair = ReturnType<typeof createPair>;
|
|
@@ -66,6 +85,14 @@ const refuse = (reason: string) =>
|
|
|
66
85
|
/** Explicit recovery retains one record and class relation; it never replaces the initial pair. */
|
|
67
86
|
export function captureOwnedExplicitAttachRecoveryV2() {
|
|
68
87
|
need(arguments.length === 0);
|
|
88
|
+
return recoveryKernel(null);
|
|
89
|
+
}
|
|
90
|
+
export function captureExplicitAttachRecoveryForLineage(token: object) {
|
|
91
|
+
need(arguments.length === 1);
|
|
92
|
+
readInitialLineage(token);
|
|
93
|
+
return recoveryKernel(token);
|
|
94
|
+
}
|
|
95
|
+
function recoveryKernel(token: object | null) {
|
|
69
96
|
let consumed = false;
|
|
70
97
|
return Object.freeze({
|
|
71
98
|
async invoke() {
|
|
@@ -74,6 +101,15 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
74
101
|
consumed = true;
|
|
75
102
|
need(!types.isProxy(ENTRIES) && Array.isArray(ENTRIES));
|
|
76
103
|
if (ENTRIES.length === 0) return refuse("no_qualified_recovery_class");
|
|
104
|
+
const OWNER =
|
|
105
|
+
token === null ? LEGACY_OWNER : ownerForInitialLineage(token);
|
|
106
|
+
const owned =
|
|
107
|
+
token === null ? legacyOwned : ownedForInitialLineage(token);
|
|
108
|
+
const classifyRetained =
|
|
109
|
+
token === null
|
|
110
|
+
? classifyOwnedRetainedInitialAttachment
|
|
111
|
+
: (_raw: unknown) =>
|
|
112
|
+
createInitialMaterialClassifiers(token).retained();
|
|
77
113
|
let pair: Pair | null = null,
|
|
78
114
|
failureControl: FailureControl | null = null,
|
|
79
115
|
postEligible = false;
|
|
@@ -92,7 +128,14 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
92
128
|
};
|
|
93
129
|
try {
|
|
94
130
|
OWNER.check();
|
|
95
|
-
const
|
|
131
|
+
const frame =
|
|
132
|
+
token === null
|
|
133
|
+
? null
|
|
134
|
+
: await owned(() => recoveryOperationForLineage(token));
|
|
135
|
+
const live =
|
|
136
|
+
token === null
|
|
137
|
+
? loadFixedExplicitRecoveryOperation()
|
|
138
|
+
: frame?.operation;
|
|
96
139
|
OWNER.check();
|
|
97
140
|
if (live === null) return refuse("recovery_source_unbound");
|
|
98
141
|
const op = closed(live, [
|
|
@@ -110,7 +153,10 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
110
153
|
op.originAssociation !== null &&
|
|
111
154
|
typeof op.originAssociation === "object" &&
|
|
112
155
|
!types.isProxy(op.originAssociation) &&
|
|
113
|
-
op.originAssociation ===
|
|
156
|
+
op.originAssociation ===
|
|
157
|
+
(token === null
|
|
158
|
+
? ORIGINAL_ORIGIN_ASSOCIATION
|
|
159
|
+
: readInitialLineage(token).originAssociation),
|
|
114
160
|
);
|
|
115
161
|
const reserve = sourceMethod(live, "reserve"),
|
|
116
162
|
retainedPredicate = sourceMethod(op.originalEntry, "coversRetained");
|
|
@@ -140,7 +186,10 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
140
186
|
!types.isProxy(reservation),
|
|
141
187
|
);
|
|
142
188
|
// The cached record, reconstructed values and replay classifier remain invocation-local.
|
|
143
|
-
const capturedRecord =
|
|
189
|
+
const capturedRecord =
|
|
190
|
+
token === null
|
|
191
|
+
? captureRecoveryRecord(op.originalRecord)
|
|
192
|
+
: captureRecoveryRecordForLineage(token, op.originalRecord);
|
|
144
193
|
OWNER.check();
|
|
145
194
|
const original = captureRetainedInput(capturedRecord.originalRaw),
|
|
146
195
|
raw = original.attachRequest;
|
|
@@ -156,9 +205,7 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
156
205
|
}),
|
|
157
206
|
);
|
|
158
207
|
OWNER.check();
|
|
159
|
-
const retained = await owned(() =>
|
|
160
|
-
classifyOwnedRetainedInitialAttachment(original),
|
|
161
|
-
);
|
|
208
|
+
const retained = await owned(() => classifyRetained(original));
|
|
162
209
|
OWNER.check();
|
|
163
210
|
if (retained.status !== "classified")
|
|
164
211
|
return refuse("replay_material_unsupported");
|
|
@@ -178,7 +225,8 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
178
225
|
OWNER.check();
|
|
179
226
|
if (coveredRetained !== true) return refuse("replay_coverage_missing");
|
|
180
227
|
OWNER.check();
|
|
181
|
-
pair = createPair();
|
|
228
|
+
pair = token === null ? createPair() : (frame?.pair ?? null);
|
|
229
|
+
need(pair);
|
|
182
230
|
OWNER.check();
|
|
183
231
|
need(
|
|
184
232
|
pair.capability.assertSourceOperationBinding(
|
|
@@ -192,169 +240,21 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
192
240
|
const activePair = pair;
|
|
193
241
|
|
|
194
242
|
// Only this invocation's pair and actual locally rebuilt C2 enter this capsule.
|
|
195
|
-
const control = (
|
|
196
|
-
const capability = activePair.capability,
|
|
197
|
-
takeQuarantine = capability.takeFulfilledQuarantine;
|
|
198
|
-
Object.freeze(request.payload);
|
|
199
|
-
Object.freeze(request.requestIdentity);
|
|
200
|
-
Object.freeze(request);
|
|
201
|
-
OWNER.check();
|
|
202
|
-
type Token = {
|
|
203
|
-
invocation: object;
|
|
204
|
-
phase: "read" | "post";
|
|
205
|
-
ordinal: number;
|
|
206
|
-
request: AttachRequest;
|
|
207
|
-
diagnostics: Diagnostics;
|
|
208
|
-
};
|
|
209
|
-
const tokens = new WeakMap<object, Token>(),
|
|
210
|
-
invocation = Object.freeze({});
|
|
211
|
-
let phase = "unused";
|
|
212
|
-
const tokenValue = (error: unknown) =>
|
|
213
|
-
error !== null &&
|
|
214
|
-
(typeof error === "object" || typeof error === "function")
|
|
215
|
-
? tokens.get(error)
|
|
216
|
-
: undefined;
|
|
217
|
-
function consume(error: unknown, kind: "read" | "post") {
|
|
218
|
-
OWNER.check();
|
|
219
|
-
const value = tokenValue(error);
|
|
220
|
-
if (
|
|
221
|
-
error !== null &&
|
|
222
|
-
(typeof error === "object" || typeof error === "function")
|
|
223
|
-
)
|
|
224
|
-
tokens.delete(error);
|
|
225
|
-
if (
|
|
226
|
-
!value ||
|
|
227
|
-
value.invocation !== invocation ||
|
|
228
|
-
value.phase !== kind ||
|
|
229
|
-
phase !== (kind === "read" ? "failed" : "failed_post")
|
|
230
|
-
)
|
|
231
|
-
return null;
|
|
232
|
-
phase = kind === "read" ? "consumed" : "consumed_post";
|
|
233
|
-
const failure = Object.freeze({
|
|
234
|
-
category: "provider_rejected",
|
|
235
|
-
phase: kind,
|
|
236
|
-
ordinal: value.ordinal,
|
|
237
|
-
request: value.request,
|
|
238
|
-
diagnostics: value.diagnostics,
|
|
239
|
-
outcome: "unknown",
|
|
240
|
-
operationalAuthority: false,
|
|
241
|
-
});
|
|
242
|
-
const out = Error("INITIAL_PROVIDER_REJECTED");
|
|
243
|
-
Object.defineProperty(out, "failure", {
|
|
244
|
-
value: failure,
|
|
245
|
-
enumerable: false,
|
|
246
|
-
writable: false,
|
|
247
|
-
configurable: false,
|
|
248
|
-
});
|
|
249
|
-
return out;
|
|
250
|
-
}
|
|
251
|
-
return Object.freeze({
|
|
252
|
-
takePostQuarantine(...args: unknown[]) {
|
|
253
|
-
if (args.length !== 0) return null;
|
|
254
|
-
return Reflect.apply(takeQuarantine, capability, []) as
|
|
255
|
-
object | null;
|
|
256
|
-
},
|
|
257
|
-
begin() {
|
|
258
|
-
OWNER.check();
|
|
259
|
-
if (phase !== "unused") stop();
|
|
260
|
-
if (capability.assertVirginAcquisition() !== true) {
|
|
261
|
-
phase = "closed";
|
|
262
|
-
stop();
|
|
263
|
-
}
|
|
264
|
-
OWNER.check();
|
|
265
|
-
phase = "acquiring";
|
|
266
|
-
},
|
|
267
|
-
complete() {
|
|
268
|
-
OWNER.check();
|
|
269
|
-
if (phase !== "acquiring") stop();
|
|
270
|
-
phase = "complete";
|
|
271
|
-
},
|
|
272
|
-
takeReadFailure() {
|
|
273
|
-
OWNER.check();
|
|
274
|
-
if (phase !== "acquiring") stop();
|
|
275
|
-
const record = capability.consumeReadCatch();
|
|
276
|
-
OWNER.check();
|
|
277
|
-
if (record === null) {
|
|
278
|
-
phase = "unsupported";
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
need(
|
|
282
|
-
record.phase === "read" &&
|
|
283
|
-
Number.isSafeInteger(record.ordinal) &&
|
|
284
|
-
record.ordinal >= 1 &&
|
|
285
|
-
record.ordinal <= 43,
|
|
286
|
-
);
|
|
287
|
-
const token = Object.freeze(Object.create(null)) as object;
|
|
288
|
-
tokens.set(
|
|
289
|
-
token,
|
|
290
|
-
Object.freeze({
|
|
291
|
-
invocation,
|
|
292
|
-
phase: "read",
|
|
293
|
-
ordinal: record.ordinal,
|
|
294
|
-
request,
|
|
295
|
-
diagnostics: record.diagnostics,
|
|
296
|
-
}),
|
|
297
|
-
);
|
|
298
|
-
phase = "failed";
|
|
299
|
-
return token;
|
|
300
|
-
},
|
|
301
|
-
beginPost() {
|
|
302
|
-
OWNER.check();
|
|
303
|
-
if (phase !== "complete") stop();
|
|
304
|
-
phase = "posting";
|
|
305
|
-
},
|
|
306
|
-
takePostFailure(actualReply: unknown) {
|
|
307
|
-
OWNER.check();
|
|
308
|
-
if (phase !== "posting") stop();
|
|
309
|
-
const record = capability.consumePostCatch(actualReply);
|
|
310
|
-
OWNER.check();
|
|
311
|
-
if (record === null) {
|
|
312
|
-
phase = "post_without_token";
|
|
313
|
-
return null;
|
|
314
|
-
}
|
|
315
|
-
need(
|
|
316
|
-
record.phase === "post" &&
|
|
317
|
-
Number.isSafeInteger(record.ordinal) &&
|
|
318
|
-
record.ordinal >= 1 &&
|
|
319
|
-
record.ordinal <= 44,
|
|
320
|
-
);
|
|
321
|
-
const token = Object.freeze(Object.create(null)) as object;
|
|
322
|
-
tokens.set(
|
|
323
|
-
token,
|
|
324
|
-
Object.freeze({
|
|
325
|
-
invocation,
|
|
326
|
-
phase: "post",
|
|
327
|
-
ordinal: record.ordinal,
|
|
328
|
-
request,
|
|
329
|
-
diagnostics: record.diagnostics,
|
|
330
|
-
}),
|
|
331
|
-
);
|
|
332
|
-
phase = "failed_post";
|
|
333
|
-
return token;
|
|
334
|
-
},
|
|
335
|
-
forward(error: unknown) {
|
|
336
|
-
OWNER.check();
|
|
337
|
-
const value = tokenValue(error);
|
|
338
|
-
return value &&
|
|
339
|
-
value.invocation === invocation &&
|
|
340
|
-
(phase === "failed" || phase === "failed_post")
|
|
341
|
-
? (error as object)
|
|
342
|
-
: null;
|
|
343
|
-
},
|
|
344
|
-
consume(error: unknown) {
|
|
345
|
-
return consume(error, "read");
|
|
346
|
-
},
|
|
347
|
-
consumePost(error: unknown) {
|
|
348
|
-
return consume(error, "post");
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
})();
|
|
243
|
+
const control = captureActorFailureControl(OWNER, activePair, request);
|
|
352
244
|
OWNER.check();
|
|
353
245
|
failureControl = control;
|
|
354
|
-
const reader =
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
246
|
+
const reader =
|
|
247
|
+
token === null
|
|
248
|
+
? bindRawAcquisitionFromSource(
|
|
249
|
+
OWNER,
|
|
250
|
+
activePair.transport.readTransport,
|
|
251
|
+
)
|
|
252
|
+
: {
|
|
253
|
+
async acquire(_expected: unknown) {
|
|
254
|
+
need(frame?.reader);
|
|
255
|
+
return frame.reader.acquire();
|
|
256
|
+
},
|
|
257
|
+
};
|
|
358
258
|
OWNER.check();
|
|
359
259
|
let acquiredOnce = false;
|
|
360
260
|
const acquire = async () => {
|
|
@@ -402,8 +302,7 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
402
302
|
firstDispatchedAt: raw.firstDispatchedAt,
|
|
403
303
|
});
|
|
404
304
|
OWNER.check();
|
|
405
|
-
const replayRetained =
|
|
406
|
-
await classifyOwnedRetainedInitialAttachment(original);
|
|
305
|
+
const replayRetained = await classifyRetained(original);
|
|
407
306
|
OWNER.check();
|
|
408
307
|
need(replayRetained.status === "classified");
|
|
409
308
|
verifyRecoveryRecord(
|
|
@@ -414,7 +313,10 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
414
313
|
original,
|
|
415
314
|
);
|
|
416
315
|
OWNER.check();
|
|
417
|
-
const discounts =
|
|
316
|
+
const discounts =
|
|
317
|
+
token === null
|
|
318
|
+
? replayCouponEligibility(value)
|
|
319
|
+
: replayCouponEligibilityForLineage(token, value),
|
|
418
320
|
current = value.currentBundle,
|
|
419
321
|
observedAt = value.observedAt;
|
|
420
322
|
// Historical original eligibility; never fabricate a current-null subscription.
|
|
@@ -501,15 +403,21 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
501
403
|
OWNER.check();
|
|
502
404
|
return Reflect.apply(send, op.sink, [record, ack]);
|
|
503
405
|
};
|
|
504
|
-
const compiler =
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
406
|
+
const compiler =
|
|
407
|
+
token === null
|
|
408
|
+
? createAttachEventCompiler(raw, {
|
|
409
|
+
send: sourceSend,
|
|
410
|
+
timeoutMs: 5000,
|
|
411
|
+
})
|
|
412
|
+
: createRecoveryAttachEventCompiler(token);
|
|
508
413
|
OWNER.check();
|
|
509
414
|
await owned(() =>
|
|
510
415
|
compiler.dispatch({ event: "dispatch", stage: "attach", request }),
|
|
511
416
|
);
|
|
512
417
|
OWNER.check();
|
|
418
|
+
if (token !== null)
|
|
419
|
+
await owned(() => assertReplayFrontierForLineage(token));
|
|
420
|
+
OWNER.check();
|
|
513
421
|
postEligible = true;
|
|
514
422
|
let postedOnce = false;
|
|
515
423
|
const post = async () => {
|
|
@@ -549,6 +457,8 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
549
457
|
}),
|
|
550
458
|
);
|
|
551
459
|
OWNER.check();
|
|
460
|
+
if (token !== null)
|
|
461
|
+
await owned(() => retainInitialReceiptForLineage(token, receipt));
|
|
552
462
|
await owned(() =>
|
|
553
463
|
compiler.receipt({
|
|
554
464
|
event: "receipt",
|
|
@@ -558,12 +468,21 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
558
468
|
}),
|
|
559
469
|
);
|
|
560
470
|
OWNER.check();
|
|
561
|
-
const result =
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
471
|
+
const result =
|
|
472
|
+
token === null
|
|
473
|
+
? admitRecoveryOutput(
|
|
474
|
+
receipt,
|
|
475
|
+
acquired.bundle.wireSubscription.schedule,
|
|
476
|
+
prepared,
|
|
477
|
+
request,
|
|
478
|
+
)
|
|
479
|
+
: admitRecoveryOutputForLineage(
|
|
480
|
+
token,
|
|
481
|
+
receipt,
|
|
482
|
+
acquired.bundle.wireSubscription.schedule,
|
|
483
|
+
prepared,
|
|
484
|
+
request,
|
|
485
|
+
);
|
|
567
486
|
OWNER.check();
|
|
568
487
|
control.takePostQuarantine();
|
|
569
488
|
return result;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ownerForInitialLineage } from "../producer/ownerFactory.js";
|
|
1
2
|
import { need, closed, freeze } from "../material/nodeKernel.js";
|
|
2
3
|
import { equal, referenceId } from "../../../renewalAggregate/shared.js";
|
|
3
4
|
import type { Bundle, FreshInput } from "../material/capture.js";
|
|
@@ -79,6 +80,20 @@ function rebuild(b: Bundle) {
|
|
|
79
80
|
|
|
80
81
|
/** One explicit root schedule association transition, with all residual material equal. */
|
|
81
82
|
export function replayCouponEligibility(value: FreshInput) {
|
|
83
|
+
return replayEligibility(value, false);
|
|
84
|
+
}
|
|
85
|
+
export function replayCouponEligibilityForLineage(
|
|
86
|
+
token: object,
|
|
87
|
+
value: FreshInput,
|
|
88
|
+
) {
|
|
89
|
+
need(arguments.length === 2);
|
|
90
|
+
const owner = ownerForInitialLineage(token);
|
|
91
|
+
owner.check();
|
|
92
|
+
const result = replayEligibility(value, true);
|
|
93
|
+
owner.check();
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function replayEligibility(value: FreshInput, allowUnchanged: boolean) {
|
|
82
97
|
const p = value.attachRequest.preparation,
|
|
83
98
|
original = value.originalBundle,
|
|
84
99
|
current = value.currentBundle;
|
|
@@ -92,7 +107,7 @@ export function replayCouponEligibility(value: FreshInput) {
|
|
|
92
107
|
current.wireSubscription,
|
|
93
108
|
"schedule",
|
|
94
109
|
) &&
|
|
95
|
-
current.wireSubscription.schedule !== null,
|
|
110
|
+
(allowUnchanged || current.wireSubscription.schedule !== null),
|
|
96
111
|
);
|
|
97
112
|
const { schedule: oldAssociation, ...oldResidual } =
|
|
98
113
|
original.wireSubscription,
|
|
@@ -111,6 +126,7 @@ export function replayCouponEligibility(value: FreshInput) {
|
|
|
111
126
|
rebuild(original);
|
|
112
127
|
const joined = rebuild(current);
|
|
113
128
|
need(equal(original.couponReads, current.couponReads));
|
|
129
|
+
if (allowUnchanged && currentAssociation === null) return freeze(joined);
|
|
114
130
|
const expected = p.expected,
|
|
115
131
|
context = {
|
|
116
132
|
customerAccountId: expected.customerAccountId,
|
|
@@ -36,6 +36,7 @@ export async function initialOperations(
|
|
|
36
36
|
endWallMs?: number;
|
|
37
37
|
afterBind?: () => Promise<void>;
|
|
38
38
|
afterAppend?: () => Promise<void>;
|
|
39
|
+
beforeAppend?: () => Promise<void>;
|
|
39
40
|
afterRetain?: () => Promise<void>;
|
|
40
41
|
source?: RetainedInput;
|
|
41
42
|
sources?: readonly RetainedInput[];
|
|
@@ -162,8 +163,20 @@ export async function initialOperations(
|
|
|
162
163
|
args: {},
|
|
163
164
|
handler: async (ctx): Promise<null> => {
|
|
164
165
|
const runMutation = ctx.runMutation;
|
|
165
|
-
if (
|
|
166
|
+
if (
|
|
167
|
+
options.afterBind ||
|
|
168
|
+
options.afterAppend ||
|
|
169
|
+
options.afterRetain ||
|
|
170
|
+
options.beforeAppend
|
|
171
|
+
)
|
|
166
172
|
ctx.runMutation = async (ref, ...args) => {
|
|
173
|
+
if (
|
|
174
|
+
getFunctionAddress(ref).reference?.endsWith(
|
|
175
|
+
"/appendStageEvent",
|
|
176
|
+
) &&
|
|
177
|
+
options.beforeAppend
|
|
178
|
+
)
|
|
179
|
+
await options.beforeAppend();
|
|
167
180
|
const result = await runMutation(ref, ...args);
|
|
168
181
|
if (
|
|
169
182
|
getFunctionAddress(ref).reference?.endsWith(
|