@fantastic.dev/better-stripe 0.98.0 → 0.100.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/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 +146 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +90 -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/attachAcknowledgement.d.ts +10 -0
- package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js +49 -0
- package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +12 -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 +13 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js +109 -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 +12 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +96 -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/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/component/balanceFunding/mutations.d.ts +27 -27
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +67 -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 +110 -160
- package/src/client/billing/renewalAttach/internal/operations/transportKernel.ts +500 -0
- package/src/client/billing/renewalAttach/internal/producer/attachAcknowledgement.ts +65 -0
- package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +14 -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/producerAcknowledgement.integration.test.ts +320 -0
- package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgementControls.integration.test.ts +411 -0
- 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 +143 -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 +146 -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,5 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
2
|
import { OWNER } from "../originalOwner.js";
|
|
3
|
+
import { ownerForInitialLineage } from "../producer/ownerFactory.js";
|
|
3
4
|
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
4
5
|
import {
|
|
5
6
|
closed,
|
|
@@ -78,7 +79,20 @@ export type CapturedRecord = Readonly<{
|
|
|
78
79
|
|
|
79
80
|
/** Detached unverified data only. The actor retains and proves its own record. */
|
|
80
81
|
export function captureRecoveryRecord(live: unknown): CapturedRecord {
|
|
81
|
-
OWNER
|
|
82
|
+
return captureRecord(live, OWNER);
|
|
83
|
+
}
|
|
84
|
+
export function captureRecoveryRecordForLineage(
|
|
85
|
+
token: object,
|
|
86
|
+
live: unknown,
|
|
87
|
+
): CapturedRecord {
|
|
88
|
+
need(arguments.length === 2);
|
|
89
|
+
return captureRecord(live, ownerForInitialLineage(token));
|
|
90
|
+
}
|
|
91
|
+
function captureRecord(
|
|
92
|
+
live: unknown,
|
|
93
|
+
owner: { check(): unknown },
|
|
94
|
+
): CapturedRecord {
|
|
95
|
+
owner.check();
|
|
82
96
|
const slots = new Map<string, string>(),
|
|
83
97
|
active = new Set<object>();
|
|
84
98
|
let nodes = 0,
|
|
@@ -189,7 +203,7 @@ export function captureRecoveryRecord(live: unknown): CapturedRecord {
|
|
|
189
203
|
const node = walk(live, "", 0);
|
|
190
204
|
need(slots.size === 6 && rawNode);
|
|
191
205
|
encode(node);
|
|
192
|
-
|
|
206
|
+
owner.check();
|
|
193
207
|
return Object.freeze({
|
|
194
208
|
node,
|
|
195
209
|
slots,
|
|
@@ -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,11 +38,41 @@ 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
|
|
|
56
|
+
const returnedAcknowledgements = new WeakMap<
|
|
57
|
+
object,
|
|
58
|
+
Readonly<{
|
|
59
|
+
originalEntry: unknown;
|
|
60
|
+
retainedPredicate: SourceMethod;
|
|
61
|
+
freshPredicate: SourceMethod;
|
|
62
|
+
output: unknown;
|
|
63
|
+
receipt: unknown;
|
|
64
|
+
}>
|
|
65
|
+
>();
|
|
66
|
+
/** Actual replay completion identity, independent of stored C3 receipt DATA. */
|
|
67
|
+
export function readReplayAttachAcknowledgement(token: object) {
|
|
68
|
+
need(arguments.length === 1);
|
|
69
|
+
readInitialLineage(token);
|
|
70
|
+
const actual = returnedAcknowledgements.get(token);
|
|
71
|
+
if (!actual) return null;
|
|
72
|
+
ownerForInitialLineage(token).check();
|
|
73
|
+
return actual;
|
|
74
|
+
}
|
|
75
|
+
|
|
37
76
|
type Pair = ReturnType<typeof createPair>;
|
|
38
77
|
|
|
39
78
|
function sourceMethod(object: unknown, name: string): SourceMethod {
|
|
@@ -66,6 +105,14 @@ const refuse = (reason: string) =>
|
|
|
66
105
|
/** Explicit recovery retains one record and class relation; it never replaces the initial pair. */
|
|
67
106
|
export function captureOwnedExplicitAttachRecoveryV2() {
|
|
68
107
|
need(arguments.length === 0);
|
|
108
|
+
return recoveryKernel(null);
|
|
109
|
+
}
|
|
110
|
+
export function captureExplicitAttachRecoveryForLineage(token: object) {
|
|
111
|
+
need(arguments.length === 1);
|
|
112
|
+
readInitialLineage(token);
|
|
113
|
+
return recoveryKernel(token);
|
|
114
|
+
}
|
|
115
|
+
function recoveryKernel(token: object | null) {
|
|
69
116
|
let consumed = false;
|
|
70
117
|
return Object.freeze({
|
|
71
118
|
async invoke() {
|
|
@@ -74,6 +121,15 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
74
121
|
consumed = true;
|
|
75
122
|
need(!types.isProxy(ENTRIES) && Array.isArray(ENTRIES));
|
|
76
123
|
if (ENTRIES.length === 0) return refuse("no_qualified_recovery_class");
|
|
124
|
+
const OWNER =
|
|
125
|
+
token === null ? LEGACY_OWNER : ownerForInitialLineage(token);
|
|
126
|
+
const owned =
|
|
127
|
+
token === null ? legacyOwned : ownedForInitialLineage(token);
|
|
128
|
+
const classifyRetained =
|
|
129
|
+
token === null
|
|
130
|
+
? classifyOwnedRetainedInitialAttachment
|
|
131
|
+
: (_raw: unknown) =>
|
|
132
|
+
createInitialMaterialClassifiers(token).retained();
|
|
77
133
|
let pair: Pair | null = null,
|
|
78
134
|
failureControl: FailureControl | null = null,
|
|
79
135
|
postEligible = false;
|
|
@@ -92,7 +148,14 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
92
148
|
};
|
|
93
149
|
try {
|
|
94
150
|
OWNER.check();
|
|
95
|
-
const
|
|
151
|
+
const frame =
|
|
152
|
+
token === null
|
|
153
|
+
? null
|
|
154
|
+
: await owned(() => recoveryOperationForLineage(token));
|
|
155
|
+
const live =
|
|
156
|
+
token === null
|
|
157
|
+
? loadFixedExplicitRecoveryOperation()
|
|
158
|
+
: frame?.operation;
|
|
96
159
|
OWNER.check();
|
|
97
160
|
if (live === null) return refuse("recovery_source_unbound");
|
|
98
161
|
const op = closed(live, [
|
|
@@ -110,7 +173,10 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
110
173
|
op.originAssociation !== null &&
|
|
111
174
|
typeof op.originAssociation === "object" &&
|
|
112
175
|
!types.isProxy(op.originAssociation) &&
|
|
113
|
-
op.originAssociation ===
|
|
176
|
+
op.originAssociation ===
|
|
177
|
+
(token === null
|
|
178
|
+
? ORIGINAL_ORIGIN_ASSOCIATION
|
|
179
|
+
: readInitialLineage(token).originAssociation),
|
|
114
180
|
);
|
|
115
181
|
const reserve = sourceMethod(live, "reserve"),
|
|
116
182
|
retainedPredicate = sourceMethod(op.originalEntry, "coversRetained");
|
|
@@ -140,7 +206,10 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
140
206
|
!types.isProxy(reservation),
|
|
141
207
|
);
|
|
142
208
|
// The cached record, reconstructed values and replay classifier remain invocation-local.
|
|
143
|
-
const capturedRecord =
|
|
209
|
+
const capturedRecord =
|
|
210
|
+
token === null
|
|
211
|
+
? captureRecoveryRecord(op.originalRecord)
|
|
212
|
+
: captureRecoveryRecordForLineage(token, op.originalRecord);
|
|
144
213
|
OWNER.check();
|
|
145
214
|
const original = captureRetainedInput(capturedRecord.originalRaw),
|
|
146
215
|
raw = original.attachRequest;
|
|
@@ -156,9 +225,7 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
156
225
|
}),
|
|
157
226
|
);
|
|
158
227
|
OWNER.check();
|
|
159
|
-
const retained = await owned(() =>
|
|
160
|
-
classifyOwnedRetainedInitialAttachment(original),
|
|
161
|
-
);
|
|
228
|
+
const retained = await owned(() => classifyRetained(original));
|
|
162
229
|
OWNER.check();
|
|
163
230
|
if (retained.status !== "classified")
|
|
164
231
|
return refuse("replay_material_unsupported");
|
|
@@ -178,7 +245,8 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
178
245
|
OWNER.check();
|
|
179
246
|
if (coveredRetained !== true) return refuse("replay_coverage_missing");
|
|
180
247
|
OWNER.check();
|
|
181
|
-
pair = createPair();
|
|
248
|
+
pair = token === null ? createPair() : (frame?.pair ?? null);
|
|
249
|
+
need(pair);
|
|
182
250
|
OWNER.check();
|
|
183
251
|
need(
|
|
184
252
|
pair.capability.assertSourceOperationBinding(
|
|
@@ -192,169 +260,21 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
192
260
|
const activePair = pair;
|
|
193
261
|
|
|
194
262
|
// 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
|
-
})();
|
|
263
|
+
const control = captureActorFailureControl(OWNER, activePair, request);
|
|
352
264
|
OWNER.check();
|
|
353
265
|
failureControl = control;
|
|
354
|
-
const reader =
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
266
|
+
const reader =
|
|
267
|
+
token === null
|
|
268
|
+
? bindRawAcquisitionFromSource(
|
|
269
|
+
OWNER,
|
|
270
|
+
activePair.transport.readTransport,
|
|
271
|
+
)
|
|
272
|
+
: {
|
|
273
|
+
async acquire(_expected: unknown) {
|
|
274
|
+
need(frame?.reader);
|
|
275
|
+
return frame.reader.acquire();
|
|
276
|
+
},
|
|
277
|
+
};
|
|
358
278
|
OWNER.check();
|
|
359
279
|
let acquiredOnce = false;
|
|
360
280
|
const acquire = async () => {
|
|
@@ -402,8 +322,7 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
402
322
|
firstDispatchedAt: raw.firstDispatchedAt,
|
|
403
323
|
});
|
|
404
324
|
OWNER.check();
|
|
405
|
-
const replayRetained =
|
|
406
|
-
await classifyOwnedRetainedInitialAttachment(original);
|
|
325
|
+
const replayRetained = await classifyRetained(original);
|
|
407
326
|
OWNER.check();
|
|
408
327
|
need(replayRetained.status === "classified");
|
|
409
328
|
verifyRecoveryRecord(
|
|
@@ -414,7 +333,10 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
414
333
|
original,
|
|
415
334
|
);
|
|
416
335
|
OWNER.check();
|
|
417
|
-
const discounts =
|
|
336
|
+
const discounts =
|
|
337
|
+
token === null
|
|
338
|
+
? replayCouponEligibility(value)
|
|
339
|
+
: replayCouponEligibilityForLineage(token, value),
|
|
418
340
|
current = value.currentBundle,
|
|
419
341
|
observedAt = value.observedAt;
|
|
420
342
|
// Historical original eligibility; never fabricate a current-null subscription.
|
|
@@ -501,15 +423,21 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
501
423
|
OWNER.check();
|
|
502
424
|
return Reflect.apply(send, op.sink, [record, ack]);
|
|
503
425
|
};
|
|
504
|
-
const compiler =
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
426
|
+
const compiler =
|
|
427
|
+
token === null
|
|
428
|
+
? createAttachEventCompiler(raw, {
|
|
429
|
+
send: sourceSend,
|
|
430
|
+
timeoutMs: 5000,
|
|
431
|
+
})
|
|
432
|
+
: createRecoveryAttachEventCompiler(token);
|
|
508
433
|
OWNER.check();
|
|
509
434
|
await owned(() =>
|
|
510
435
|
compiler.dispatch({ event: "dispatch", stage: "attach", request }),
|
|
511
436
|
);
|
|
512
437
|
OWNER.check();
|
|
438
|
+
if (token !== null)
|
|
439
|
+
await owned(() => assertReplayFrontierForLineage(token));
|
|
440
|
+
OWNER.check();
|
|
513
441
|
postEligible = true;
|
|
514
442
|
let postedOnce = false;
|
|
515
443
|
const post = async () => {
|
|
@@ -549,6 +477,8 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
549
477
|
}),
|
|
550
478
|
);
|
|
551
479
|
OWNER.check();
|
|
480
|
+
if (token !== null)
|
|
481
|
+
await owned(() => retainInitialReceiptForLineage(token, receipt));
|
|
552
482
|
await owned(() =>
|
|
553
483
|
compiler.receipt({
|
|
554
484
|
event: "receipt",
|
|
@@ -558,14 +488,42 @@ export function captureOwnedExplicitAttachRecoveryV2() {
|
|
|
558
488
|
}),
|
|
559
489
|
);
|
|
560
490
|
OWNER.check();
|
|
561
|
-
const result =
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
491
|
+
const result =
|
|
492
|
+
token === null
|
|
493
|
+
? admitRecoveryOutput(
|
|
494
|
+
receipt,
|
|
495
|
+
acquired.bundle.wireSubscription.schedule,
|
|
496
|
+
prepared,
|
|
497
|
+
request,
|
|
498
|
+
)
|
|
499
|
+
: admitRecoveryOutputForLineage(
|
|
500
|
+
token,
|
|
501
|
+
receipt,
|
|
502
|
+
acquired.bundle.wireSubscription.schedule,
|
|
503
|
+
prepared,
|
|
504
|
+
request,
|
|
505
|
+
);
|
|
567
506
|
OWNER.check();
|
|
568
507
|
control.takePostQuarantine();
|
|
508
|
+
if (token !== null) {
|
|
509
|
+
need(frame);
|
|
510
|
+
returnedAcknowledgements.set(
|
|
511
|
+
token,
|
|
512
|
+
Object.freeze({
|
|
513
|
+
originalEntry: op.originalEntry,
|
|
514
|
+
retainedPredicate,
|
|
515
|
+
freshPredicate: frame.snapshot.freshPredicate,
|
|
516
|
+
output: result,
|
|
517
|
+
receipt: closed(result, [
|
|
518
|
+
"kind",
|
|
519
|
+
"status",
|
|
520
|
+
"operationalAuthority",
|
|
521
|
+
"receipt",
|
|
522
|
+
"observation",
|
|
523
|
+
]).receipt,
|
|
524
|
+
}),
|
|
525
|
+
);
|
|
526
|
+
}
|
|
569
527
|
return result;
|
|
570
528
|
} catch (error) {
|
|
571
529
|
let live = false;
|
|
@@ -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(
|