@fantastic.dev/better-stripe 0.107.0 → 0.109.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/observation/freshActor.d.ts +31 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +112 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +17 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +191 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts +29 -0
- package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invocation.js +205 -0
- package/dist/client/billing/renewalAttach/internal/observation/invocation.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/profile.js +5 -1
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/reader.d.ts +10 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.js +30 -0
- package/dist/client/billing/renewalAttach/internal/observation/reader.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts +44 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js +145 -0
- package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +9 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +2 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +9 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +107 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/observation/freshActor.integration.test.ts +360 -0
- package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +175 -0
- package/src/client/billing/renewalAttach/internal/observation/freshActorControls.integration.test.ts +442 -0
- package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +252 -0
- package/src/client/billing/renewalAttach/internal/observation/invocation.ts +299 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +9 -1
- package/src/client/billing/renewalAttach/internal/observation/reader.integration.test.ts +93 -0
- package/src/client/billing/renewalAttach/internal/observation/reader.ts +35 -0
- package/src/client/billing/renewalAttach/internal/observation/readerAuthorization.ts +179 -0
- package/src/client/billing/renewalAttach/internal/observation/readerControls.integration.test.ts +553 -0
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +11 -0
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +12 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/freshObservation.ts +94 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +5 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationReader.ts +101 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +41 -4
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.109.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.108.0...v0.109.0) (2026-10-31)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- observe renewal evidence through fresh authorized GETs ([#460](https://github.com/FantasticDevHQ/better-stripe/issues/460)) ([7a0f2dd](https://github.com/FantasticDevHQ/better-stripe/commit/7a0f2dd0fc2e578af368b905deedfb0ae2a1e4b1))
|
|
34
|
+
|
|
35
|
+
## [0.108.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.107.0...v0.108.0) (2026-10-31)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
- bind observation history reads to fresh host authorization ([#458](https://github.com/FantasticDevHQ/better-stripe/issues/458)) ([455ccaf](https://github.com/FantasticDevHQ/better-stripe/commit/455ccaf9c64709c8e5d61eb9017a89891c3beeb6))
|
|
40
|
+
|
|
29
41
|
## [0.107.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.106.0...v0.107.0) (2026-10-31)
|
|
30
42
|
|
|
31
43
|
### Features
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
|
|
|
5
5
|
syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
|
|
6
6
|
hooks and headless UI components.
|
|
7
7
|
|
|
8
|
-
**Version**: `0.
|
|
8
|
+
**Version**: `0.109.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
|
|
9
9
|
|
|
10
10
|
Connect platforms use the default GA API version. Non-Connect merchants using
|
|
11
11
|
customer-only Accounts v2 need preview access and an explicit preview version.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ObservationReads, ReadFailure } from "./types.js";
|
|
2
|
+
/** Fresh authorized bounded current evidence. No caller DATA can create an invocation. */
|
|
3
|
+
export declare function captureFreshRenewalObservation(root: object, raw: unknown): Promise<Readonly<{
|
|
4
|
+
invoke(): Promise<{
|
|
5
|
+
history: Awaited<ReturnType<typeof import("./history.js").captureRetainedObservationHistory>>;
|
|
6
|
+
authorization: ReturnType<typeof import("./readerAuthorization.js").captureReaderAuthorization>;
|
|
7
|
+
status: "fresh_observation_data" | "observation_conflict" | "observation_provider_rejected" | "unsupported_observation_profile";
|
|
8
|
+
reads: ObservationReads | null;
|
|
9
|
+
evidence: Readonly<{
|
|
10
|
+
version: 1;
|
|
11
|
+
kind: "renewal_evidence_data";
|
|
12
|
+
apiVersion: import("../../../renewalObservation/evidence-v1-types.js").API;
|
|
13
|
+
identity: import("../../../renewalObservation/evidence-v1-types.js").IdentityV1 | null;
|
|
14
|
+
lifecycle: import("../../../renewalObservation/evidence-v1-types.js").LifecycleV1;
|
|
15
|
+
currentMaterial: import("../../../renewalObservation/evidence-v1-types.js").CurrentMaterialV1;
|
|
16
|
+
historicalMaterial: import("../../../renewalObservation/evidence-v1-types.js").HistoricalMaterialV1;
|
|
17
|
+
invoiceEvidence: import("../../../renewalObservation/evidence-v1-types.js").InvoiceEvidenceV1;
|
|
18
|
+
acknowledgementEstablished: false;
|
|
19
|
+
authenticationEstablished: false;
|
|
20
|
+
operationalAuthority: false;
|
|
21
|
+
providerQualificationRequired: true;
|
|
22
|
+
}> | null;
|
|
23
|
+
couponInventory: "complete" | "incomplete" | "not_acquired";
|
|
24
|
+
observedAt: number;
|
|
25
|
+
analysis: "admitted" | "analysis_not_admitted";
|
|
26
|
+
reason: string | null;
|
|
27
|
+
failure: ReadFailure | null;
|
|
28
|
+
operationalAuthority: false;
|
|
29
|
+
}>;
|
|
30
|
+
}>>;
|
|
31
|
+
//# sourceMappingURL=freshActor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshActor.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/freshActor.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,0FAA0F;AAC1F,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmJb"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { captureObservationInvocation, readObservationInvocation, closeObservationInvocation, } from "./invocation.js";
|
|
2
|
+
import { captureFreshObservationProfile, captureFreshGetTransport, freshNeed as need, } from "./freshTransport.js";
|
|
3
|
+
import { baseReadRows, validateObservationIdentityRouting, validateBaseRouting, observationCouponIds, couponReadRow, validateCoupon, } from "./profile.js";
|
|
4
|
+
import { inspectRenewalEvidenceV1 } from "../../../renewalObservation/evidence-v1.js";
|
|
5
|
+
import { captureReaderQueryDATA } from "./readerAuthorization.js";
|
|
6
|
+
/** Fresh authorized bounded current evidence. No caller DATA can create an invocation. */
|
|
7
|
+
export async function captureFreshRenewalObservation(root, raw) {
|
|
8
|
+
need(arguments.length === 2);
|
|
9
|
+
const profile = captureFreshObservationProfile(root);
|
|
10
|
+
const token = await captureObservationInvocation(root, raw);
|
|
11
|
+
let state;
|
|
12
|
+
try {
|
|
13
|
+
state = readObservationInvocation(token);
|
|
14
|
+
need(state.historyEntry === profile.historyEntry);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
closeObservationInvocation(token);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
let used = false;
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
async invoke() {
|
|
23
|
+
need(arguments.length === 0 && !used);
|
|
24
|
+
used = true;
|
|
25
|
+
try {
|
|
26
|
+
const captured = await state.captureHistory();
|
|
27
|
+
const transport = captureFreshGetTransport(token, profile);
|
|
28
|
+
async function release(status, reads, evidence, couponInventory, reason, failure = null) {
|
|
29
|
+
await state.authorizeUnchanged();
|
|
30
|
+
transport.guard();
|
|
31
|
+
const output = captureReaderQueryDATA({
|
|
32
|
+
status,
|
|
33
|
+
...captured,
|
|
34
|
+
reads,
|
|
35
|
+
evidence,
|
|
36
|
+
couponInventory,
|
|
37
|
+
observedAt: Math.floor(state.check().wallMs / 1000),
|
|
38
|
+
analysis: evidence === null
|
|
39
|
+
? "analysis_not_admitted"
|
|
40
|
+
: "admitted",
|
|
41
|
+
reason,
|
|
42
|
+
failure,
|
|
43
|
+
operationalAuthority: false,
|
|
44
|
+
});
|
|
45
|
+
transport.guard();
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
const base = [];
|
|
49
|
+
for (const row of baseReadRows(captured.history.record)) {
|
|
50
|
+
const result = await transport.read(row);
|
|
51
|
+
if (result.kind === "provider_rejected")
|
|
52
|
+
return await release("observation_provider_rejected", null, null, "not_acquired", null, result.failure);
|
|
53
|
+
base.push(result.body);
|
|
54
|
+
}
|
|
55
|
+
const reads = {
|
|
56
|
+
schedule: base[0],
|
|
57
|
+
subscription: base[1],
|
|
58
|
+
targetPrice: base[2],
|
|
59
|
+
billingCustomer: base[3],
|
|
60
|
+
coupons: [],
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
validateObservationIdentityRouting(captured.history.record, reads);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return await release("observation_conflict", null, null, "incomplete", "PROVIDER_IDENTITY_CONFLICT");
|
|
67
|
+
}
|
|
68
|
+
async function analyze() {
|
|
69
|
+
return state.owned(async () => {
|
|
70
|
+
try {
|
|
71
|
+
return await inspectRenewalEvidenceV1({
|
|
72
|
+
version: 1,
|
|
73
|
+
apiVersion: "2026-09-30.endive",
|
|
74
|
+
configuration: captured.history.record.configuration,
|
|
75
|
+
configureReceipt: captured.history.rawConfigureReceipt,
|
|
76
|
+
reads,
|
|
77
|
+
invoiceContext: null,
|
|
78
|
+
historicalSnapshot: null,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}, transport.guard);
|
|
85
|
+
}
|
|
86
|
+
let ids;
|
|
87
|
+
try {
|
|
88
|
+
validateBaseRouting(captured.history.record, reads);
|
|
89
|
+
ids = observationCouponIds(captured.history.record, reads.subscription);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
const analysis = await analyze();
|
|
93
|
+
return await release("unsupported_observation_profile", reads, analysis, "incomplete", "COUPON_INVENTORY_UNSUPPORTED");
|
|
94
|
+
}
|
|
95
|
+
for (const id of ids) {
|
|
96
|
+
const row = couponReadRow(id, 5 + reads.coupons.length);
|
|
97
|
+
const result = await transport.read(row);
|
|
98
|
+
if (result.kind === "provider_rejected")
|
|
99
|
+
return await release("observation_provider_rejected", null, null, "incomplete", null, result.failure);
|
|
100
|
+
validateCoupon(captured.history.record, id, result.body);
|
|
101
|
+
reads.coupons.push(result.body);
|
|
102
|
+
}
|
|
103
|
+
const evidence = await analyze();
|
|
104
|
+
return await release("fresh_observation_data", reads, evidence, "complete", null);
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
closeObservationInvocation(token);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=freshActor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshActor.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/freshActor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,OAAO,EAAE,CAAC;oBACjC,OAAO,MAAM,OAAO,CAClB,iCAAiC,EACjC,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,8BAA8B,CAC/B,CAAC;gBACJ,CAAC;gBACD,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;oBACrB,MAAM,GAAG,GAAG,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACxD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACzC,IAAI,MAAM,CAAC,IAAI,KAAK,mBAAmB;wBACrC,OAAO,MAAM,OAAO,CAClB,+BAA+B,EAC/B,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,MAAM,CAAC,OAAO,CACf,CAAC;oBACJ,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;oBACzD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAClC,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,OAAO,EAAE,CAAC;gBACjC,OAAO,MAAM,OAAO,CAClB,wBAAwB,EACxB,KAAK,EACL,QAAQ,EACR,UAAU,EACV,IAAI,CACL,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,0BAA0B,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FreshObservationProfile } from "../operations/sourceOperations.js";
|
|
2
|
+
import type { ObservationReadRow, ReadFailure } from "./types.js";
|
|
3
|
+
export declare function freshStop(): never;
|
|
4
|
+
export declare function freshNeed(value: unknown): asserts value;
|
|
5
|
+
export declare function captureFreshObservationProfile(root: object): FreshObservationProfile;
|
|
6
|
+
/** Actual fresh class selection and GET-only fixed rows. No caller transport or old lineage. */
|
|
7
|
+
export declare function captureFreshGetTransport(token: object, profile: FreshObservationProfile): Readonly<{
|
|
8
|
+
guard: () => void;
|
|
9
|
+
read(raw: ObservationReadRow): Promise<Readonly<{
|
|
10
|
+
kind: "fulfilled";
|
|
11
|
+
body: unknown;
|
|
12
|
+
}> | Readonly<{
|
|
13
|
+
kind: "provider_rejected";
|
|
14
|
+
failure: ReadFailure;
|
|
15
|
+
}>>;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=freshTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshTransport.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/freshTransport.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAc3C,OAAO,KAAK,EACV,kBAAkB,EAElB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,wBAAgB,SAAS,IAAI,KAAK,CAEjC;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAEvD;AAMD,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,MAAM,GACX,uBAAuB,CAoBzB;AAMD,gGAAgG;AAChG,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,uBAAuB;;cAyEvB,kBAAkB,GACtB,OAAO,CACN,QAAQ,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,GAC9C,QAAQ,CAAC;QAAE,IAAI,EAAE,mBAAmB,CAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,CAAC,CAChE;GA0GJ"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import { COMPILED_FRESH_OBSERVATION_ENTRIES, COMPILED_OBSERVATION_HISTORY_ENTRIES, } from "../operations/sourceOperations.js";
|
|
4
|
+
import { readMaintainedRootComponent, captureInitialJournalSelection, } from "../producer/classOwnedActionRoot.js";
|
|
5
|
+
import { readObservationInvocation } from "./invocation.js";
|
|
6
|
+
import { closed, freeze } from "../c10/ownData.js";
|
|
7
|
+
import { baseReadRows, couponReadRow, observationCouponIds, validateBaseRouting, } from "./profile.js";
|
|
8
|
+
import { captureObservationReply, safeReadDiagnostics } from "./capture.js";
|
|
9
|
+
export function freshStop() {
|
|
10
|
+
throw Error("FRESH_OBSERVATION_UNBOUND");
|
|
11
|
+
}
|
|
12
|
+
export function freshNeed(value) {
|
|
13
|
+
if (!value)
|
|
14
|
+
freshStop();
|
|
15
|
+
}
|
|
16
|
+
const method = Object.getOwnPropertyDescriptor(Stripe.prototype, "rawRequest")?.value;
|
|
17
|
+
const nativeThen = Promise.prototype.then;
|
|
18
|
+
export function captureFreshObservationProfile(root) {
|
|
19
|
+
if (COMPILED_FRESH_OBSERVATION_ENTRIES.length === 0)
|
|
20
|
+
freshStop();
|
|
21
|
+
const component = readMaintainedRootComponent(root);
|
|
22
|
+
const candidates = COMPILED_FRESH_OBSERVATION_ENTRIES.filter((entry) => {
|
|
23
|
+
freshNeed(!types.isProxy(entry));
|
|
24
|
+
closed(entry, ["historyEntry", "readProfile", "coversObservation"]);
|
|
25
|
+
return entry.historyEntry.component === component;
|
|
26
|
+
});
|
|
27
|
+
freshNeed(candidates.length === 1);
|
|
28
|
+
const profile = candidates[0];
|
|
29
|
+
freshNeed(Object.isFrozen(profile) &&
|
|
30
|
+
profile.readProfile === "endive-schedule-first-44-v1" &&
|
|
31
|
+
COMPILED_OBSERVATION_HISTORY_ENTRIES.includes(profile.historyEntry));
|
|
32
|
+
freshNeed(typeof profile.coversObservation === "function" &&
|
|
33
|
+
!types.isProxy(profile.coversObservation));
|
|
34
|
+
return profile;
|
|
35
|
+
}
|
|
36
|
+
/** Actual fresh class selection and GET-only fixed rows. No caller transport or old lineage. */
|
|
37
|
+
export function captureFreshGetTransport(token, profile) {
|
|
38
|
+
freshNeed(arguments.length === 2);
|
|
39
|
+
const state = readObservationInvocation(token), captured = state.readCaptured();
|
|
40
|
+
freshNeed(state.historyEntry === profile.historyEntry);
|
|
41
|
+
const covers = profile.coversObservation;
|
|
42
|
+
function profileGuard() {
|
|
43
|
+
readObservationInvocation(token);
|
|
44
|
+
freshNeed(COMPILED_FRESH_OBSERVATION_ENTRIES.includes(profile) &&
|
|
45
|
+
COMPILED_FRESH_OBSERVATION_ENTRIES.filter((e) => e.historyEntry === state.historyEntry).length === 1);
|
|
46
|
+
freshNeed(profile.historyEntry === state.historyEntry &&
|
|
47
|
+
profile.coversObservation === covers &&
|
|
48
|
+
profile.readProfile === "endive-schedule-first-44-v1");
|
|
49
|
+
}
|
|
50
|
+
profileGuard();
|
|
51
|
+
freshNeed(Reflect.apply(covers, profile, [captured.history.record]) === true);
|
|
52
|
+
profileGuard();
|
|
53
|
+
const selection = captureInitialJournalSelection(state.binding, "2026-09-30.endive");
|
|
54
|
+
const client = selection.select();
|
|
55
|
+
freshNeed(client &&
|
|
56
|
+
typeof client === "object" &&
|
|
57
|
+
!types.isProxy(client) &&
|
|
58
|
+
Object.getPrototypeOf(client) === Stripe.prototype &&
|
|
59
|
+
!Object.prototype.hasOwnProperty.call(client, "rawRequest") &&
|
|
60
|
+
typeof method === "function");
|
|
61
|
+
function guard() {
|
|
62
|
+
profileGuard();
|
|
63
|
+
selection.check();
|
|
64
|
+
freshNeed(Object.getPrototypeOf(client) === Stripe.prototype &&
|
|
65
|
+
!Object.prototype.hasOwnProperty.call(client, "rawRequest") &&
|
|
66
|
+
Object.getOwnPropertyDescriptor(Stripe.prototype, "rawRequest")
|
|
67
|
+
?.value === method);
|
|
68
|
+
}
|
|
69
|
+
guard();
|
|
70
|
+
const base = baseReadRows(captured.history.record), bodies = [];
|
|
71
|
+
let ordinal = 0, busy = false, ended = false;
|
|
72
|
+
function expected() {
|
|
73
|
+
if (ordinal < 4)
|
|
74
|
+
return base[ordinal];
|
|
75
|
+
const reads = {
|
|
76
|
+
schedule: bodies[0],
|
|
77
|
+
subscription: bodies[1],
|
|
78
|
+
targetPrice: bodies[2],
|
|
79
|
+
billingCustomer: bodies[3],
|
|
80
|
+
coupons: [],
|
|
81
|
+
};
|
|
82
|
+
validateBaseRouting(captured.history.record, reads);
|
|
83
|
+
const ids = observationCouponIds(captured.history.record, reads.subscription);
|
|
84
|
+
freshNeed(ordinal - 4 < ids.length);
|
|
85
|
+
return couponReadRow(ids[ordinal - 4], ordinal + 1);
|
|
86
|
+
}
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
guard,
|
|
89
|
+
async read(raw) {
|
|
90
|
+
if (busy || ended) {
|
|
91
|
+
ended = true;
|
|
92
|
+
state.close();
|
|
93
|
+
freshStop();
|
|
94
|
+
}
|
|
95
|
+
busy = true;
|
|
96
|
+
try {
|
|
97
|
+
guard();
|
|
98
|
+
freshNeed(ordinal < 44 && !types.isProxy(raw));
|
|
99
|
+
const row = expected(), actual = closed(raw, [
|
|
100
|
+
"resource",
|
|
101
|
+
"id",
|
|
102
|
+
"ordinal",
|
|
103
|
+
"method",
|
|
104
|
+
"path",
|
|
105
|
+
"body",
|
|
106
|
+
"options",
|
|
107
|
+
]);
|
|
108
|
+
freshNeed(!types.isProxy(actual.options));
|
|
109
|
+
const options = closed(actual.options, [
|
|
110
|
+
"apiVersion",
|
|
111
|
+
"maxNetworkRetries",
|
|
112
|
+
]);
|
|
113
|
+
freshNeed(actual.resource === row.resource &&
|
|
114
|
+
actual.id === row.id &&
|
|
115
|
+
actual.ordinal === row.ordinal &&
|
|
116
|
+
actual.method === "GET" &&
|
|
117
|
+
actual.path === row.path &&
|
|
118
|
+
actual.body === undefined &&
|
|
119
|
+
options.apiVersion === row.options.apiVersion &&
|
|
120
|
+
options.maxNetworkRetries === 0);
|
|
121
|
+
await state.authorizeUnchanged();
|
|
122
|
+
guard();
|
|
123
|
+
ordinal++;
|
|
124
|
+
let promise = null;
|
|
125
|
+
const cell = { capsule: null };
|
|
126
|
+
const result = await state.owned(() => {
|
|
127
|
+
const actualPromise = Reflect.apply(method, client, [
|
|
128
|
+
"GET",
|
|
129
|
+
row.path,
|
|
130
|
+
undefined,
|
|
131
|
+
row.options,
|
|
132
|
+
]);
|
|
133
|
+
freshNeed(actualPromise &&
|
|
134
|
+
typeof actualPromise === "object" &&
|
|
135
|
+
!types.isProxy(actualPromise) &&
|
|
136
|
+
types.isPromise(actualPromise));
|
|
137
|
+
promise = actualPromise;
|
|
138
|
+
return Reflect.apply(nativeThen, actualPromise, [
|
|
139
|
+
(value) => (cell.capsule = Object.freeze({
|
|
140
|
+
promise: actualPromise,
|
|
141
|
+
kind: "fulfilled",
|
|
142
|
+
value,
|
|
143
|
+
})),
|
|
144
|
+
(value) => (cell.capsule = Object.freeze({
|
|
145
|
+
promise: actualPromise,
|
|
146
|
+
kind: "rejected",
|
|
147
|
+
value,
|
|
148
|
+
})),
|
|
149
|
+
]);
|
|
150
|
+
}, guard);
|
|
151
|
+
guard();
|
|
152
|
+
const capsule = cell.capsule;
|
|
153
|
+
freshNeed(capsule && result === capsule && capsule.promise === promise);
|
|
154
|
+
const settled = capsule;
|
|
155
|
+
if (settled.kind === "rejected") {
|
|
156
|
+
ended = true;
|
|
157
|
+
return Object.freeze({
|
|
158
|
+
kind: "provider_rejected",
|
|
159
|
+
failure: freeze({
|
|
160
|
+
category: "provider_rejected",
|
|
161
|
+
phase: "read",
|
|
162
|
+
resource: row.resource,
|
|
163
|
+
ordinal: row.ordinal,
|
|
164
|
+
request: {
|
|
165
|
+
method: "GET",
|
|
166
|
+
path: row.path,
|
|
167
|
+
apiVersion: row.options.apiVersion,
|
|
168
|
+
},
|
|
169
|
+
diagnostics: safeReadDiagnostics(settled.value),
|
|
170
|
+
outcome: "unknown",
|
|
171
|
+
operationalAuthority: false,
|
|
172
|
+
}),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const body = captureObservationReply(settled.value);
|
|
176
|
+
guard();
|
|
177
|
+
bodies.push(body);
|
|
178
|
+
return Object.freeze({ kind: "fulfilled", body });
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
ended = true;
|
|
182
|
+
state.close();
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
busy = false;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=freshTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshTransport.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/freshTransport.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,kCAAkC,EAClC,oCAAoC,GAErC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAO5E,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC3C,CAAC;AACD,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,IAAI,CAAC,KAAK;QAAE,SAAS,EAAE,CAAC;AAC1B,CAAC;AACD,MAAM,MAAM,GAAG,MAAM,CAAC,wBAAwB,CAC5C,MAAM,CAAC,SAAS,EAChB,YAAY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IAAI,KAAK,UAAU,EAAE,CAAC;oBAChC,KAAK,GAAG,IAAI,CAAC;oBACb,OAAO,MAAM,CAAC,MAAM,CAAC;wBACnB,IAAI,EAAE,mBAA4B;wBAClC,OAAO,EAAE,MAAM,CAAC;4BACd,QAAQ,EAAE,mBAA4B;4BACtC,KAAK,EAAE,MAAe;4BACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;4BACtB,OAAO,EAAE,GAAG,CAAC,OAAO;4BACpB,OAAO,EAAE;gCACP,MAAM,EAAE,KAAc;gCACtB,IAAI,EAAE,GAAG,CAAC,IAAI;gCACd,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU;6BACnC;4BACD,WAAW,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC;4BAC/C,OAAO,EAAE,SAAkB;4BAC3B,oBAAoB,EAAE,KAAc;yBACrC,CAAC;qBACH,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,IAAI,GAAG,uBAAuB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACpD,KAAK,EAAE,CAAC;gBACR,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAClB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,KAAK,GAAG,IAAI,CAAC;gBACb,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,MAAM,KAAK,CAAC;YACd,CAAC;oBAAS,CAAC;gBACT,IAAI,GAAG,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { captureRetainedObservationHistory } from "./history.js";
|
|
2
|
+
import { captureReaderAuthorization } from "./readerAuthorization.js";
|
|
3
|
+
import type { ObservationHistorySourceEntry } from "./readerAuthorization.js";
|
|
4
|
+
type CapturedHistory = Readonly<{
|
|
5
|
+
history: Awaited<ReturnType<typeof captureRetainedObservationHistory>>;
|
|
6
|
+
authorization: ReturnType<typeof captureReaderAuthorization>;
|
|
7
|
+
}>;
|
|
8
|
+
export interface ObservationInvocationState {
|
|
9
|
+
readonly binding: object;
|
|
10
|
+
readonly historyEntry: ObservationHistorySourceEntry;
|
|
11
|
+
guard(): void;
|
|
12
|
+
check(): {
|
|
13
|
+
wallMs: number;
|
|
14
|
+
ns: bigint;
|
|
15
|
+
};
|
|
16
|
+
close(): void;
|
|
17
|
+
owned<T>(work: () => T | PromiseLike<T>, extra?: () => void): Promise<T>;
|
|
18
|
+
captureHistory(): Promise<CapturedHistory>;
|
|
19
|
+
authorizeUnchanged(): Promise<ReturnType<typeof captureReaderAuthorization>>;
|
|
20
|
+
readCaptured(): CapturedHistory;
|
|
21
|
+
}
|
|
22
|
+
/** Cleanup does not need a still-valid context and cannot mint or read authority. */
|
|
23
|
+
export declare function closeObservationInvocation(token: unknown): void;
|
|
24
|
+
/** Actual private invocation identity only. DATA cannot register a grant. */
|
|
25
|
+
export declare function readObservationInvocation(token: unknown): ObservationInvocationState;
|
|
26
|
+
/** One fresh lifetime and actual class/Action binding, shared by private wrappers. */
|
|
27
|
+
export declare function captureObservationInvocation(actualRoot: object, raw: unknown): Promise<Readonly<{}>>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=invocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invocation.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/observation/invocation.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAIL,0BAA0B,EAG3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAC9E,KAAK,eAAe,GAAG,QAAQ,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,iCAAiC,CAAC,CAAC,CAAC;IACvE,aAAa,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;CAC9D,CAAC,CAAC;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,6BAA6B,CAAC;IACrD,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3C,kBAAkB,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC;IAC7E,YAAY,IAAI,eAAe,CAAC;CACjC;AAED,qFAAqF;AACrF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAG/D;AACD,6EAA6E;AAC7E,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,0BAA0B,CAM5B;AAED,sFAAsF;AACtF,wBAAsB,4BAA4B,CAChD,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,OAAO,yBA2Ob"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { getFunctionAddress, } from "convex/server";
|
|
3
|
+
import { COMPILED_OBSERVATION_HISTORY_ENTRIES } from "../operations/sourceOperations.js";
|
|
4
|
+
import { readMaintainedRootComponent, captureMaintainedJournalBinding, readCheckedJournalActionRPC, } from "../producer/classOwnedActionRoot.js";
|
|
5
|
+
import { closed, freeze } from "../c10/ownData.js";
|
|
6
|
+
import { object, matchConfigureDATA, } from "../producer/configureJournalData.js";
|
|
7
|
+
import { captureRetainedObservationHistory } from "./history.js";
|
|
8
|
+
import { readerNeed as need, readerText as text, readerStop, captureReaderAuthorization, createObservationReaderLifetime, captureReaderQueryDATA, } from "./readerAuthorization.js";
|
|
9
|
+
const invocations = new WeakMap();
|
|
10
|
+
/** Cleanup does not need a still-valid context and cannot mint or read authority. */
|
|
11
|
+
export function closeObservationInvocation(token) {
|
|
12
|
+
if (token !== null && typeof token === "object")
|
|
13
|
+
invocations.get(token)?.close();
|
|
14
|
+
}
|
|
15
|
+
/** Actual private invocation identity only. DATA cannot register a grant. */
|
|
16
|
+
export function readObservationInvocation(token) {
|
|
17
|
+
need(token !== null && typeof token === "object");
|
|
18
|
+
const state = invocations.get(token);
|
|
19
|
+
need(state);
|
|
20
|
+
state.guard();
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
/** One fresh lifetime and actual class/Action binding, shared by private wrappers. */
|
|
24
|
+
export async function captureObservationInvocation(actualRoot, raw) {
|
|
25
|
+
need(arguments.length === 2);
|
|
26
|
+
if (COMPILED_OBSERVATION_HISTORY_ENTRIES.length === 0)
|
|
27
|
+
readerStop();
|
|
28
|
+
const component = readMaintainedRootComponent(actualRoot);
|
|
29
|
+
const matches = COMPILED_OBSERVATION_HISTORY_ENTRIES.filter((e) => e.component === component);
|
|
30
|
+
need(matches.length === 1);
|
|
31
|
+
const entry = matches[0];
|
|
32
|
+
closed(entry, ["component", "componentScope", "authorizationQuery"]);
|
|
33
|
+
need(Object.isFrozen(entry));
|
|
34
|
+
need(!types.isProxy(raw));
|
|
35
|
+
const input = closed(raw, [
|
|
36
|
+
"actualActionCtx",
|
|
37
|
+
"operationId",
|
|
38
|
+
"parentOperationId",
|
|
39
|
+
]);
|
|
40
|
+
const args = freeze({
|
|
41
|
+
componentScope: text(entry.componentScope),
|
|
42
|
+
operationId: text(input.operationId),
|
|
43
|
+
parentOperationId: text(input.parentOperationId),
|
|
44
|
+
});
|
|
45
|
+
need(args.operationId !== args.parentOperationId);
|
|
46
|
+
need(input.actualActionCtx &&
|
|
47
|
+
typeof input.actualActionCtx === "object" &&
|
|
48
|
+
!types.isProxy(input.actualActionCtx));
|
|
49
|
+
const ctx = input.actualActionCtx;
|
|
50
|
+
const auth = ctx.auth, getIdentity = auth?.getUserIdentity;
|
|
51
|
+
need(auth &&
|
|
52
|
+
!types.isProxy(auth) &&
|
|
53
|
+
typeof getIdentity === "function" &&
|
|
54
|
+
!types.isProxy(getIdentity));
|
|
55
|
+
const captured = {
|
|
56
|
+
query: ctx.runQuery,
|
|
57
|
+
mutation: ctx.runMutation,
|
|
58
|
+
meta: ctx.meta,
|
|
59
|
+
metadata: ctx.meta?.getFunctionMetadata,
|
|
60
|
+
};
|
|
61
|
+
const q = component.renewalOperations.queries;
|
|
62
|
+
const references = () => {
|
|
63
|
+
const current = component.renewalOperations.queries;
|
|
64
|
+
return [
|
|
65
|
+
current.loadAuthorizedOperation,
|
|
66
|
+
current.readAttempt,
|
|
67
|
+
current.readStageEvent,
|
|
68
|
+
current.readProviderAcknowledgement,
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
const refs = {
|
|
72
|
+
load: q.loadAuthorizedOperation,
|
|
73
|
+
attempt: q.readAttempt,
|
|
74
|
+
event: q.readStageEvent,
|
|
75
|
+
acknowledgement: q.readProviderAcknowledgement,
|
|
76
|
+
};
|
|
77
|
+
const addresses = references().map((ref) => JSON.stringify(getFunctionAddress(ref)));
|
|
78
|
+
const authAddress = JSON.stringify(getFunctionAddress(entry.authorizationQuery));
|
|
79
|
+
const lifetime = createObservationReaderLifetime();
|
|
80
|
+
let binding = null;
|
|
81
|
+
let authorizedUntil = null;
|
|
82
|
+
function guard() {
|
|
83
|
+
if (authorizedUntil !== null)
|
|
84
|
+
need(lifetime.check().wallMs < authorizedUntil);
|
|
85
|
+
need(readMaintainedRootComponent(actualRoot) === component);
|
|
86
|
+
need(COMPILED_OBSERVATION_HISTORY_ENTRIES.filter((e) => e.component === component).length === 1 && COMPILED_OBSERVATION_HISTORY_ENTRIES.includes(entry));
|
|
87
|
+
need(ctx.auth === auth &&
|
|
88
|
+
auth.getUserIdentity === getIdentity &&
|
|
89
|
+
ctx.runQuery === captured.query &&
|
|
90
|
+
ctx.runMutation === captured.mutation &&
|
|
91
|
+
ctx.meta === captured.meta &&
|
|
92
|
+
ctx.meta.getFunctionMetadata === captured.metadata);
|
|
93
|
+
need(JSON.stringify(getFunctionAddress(entry.authorizationQuery)) ===
|
|
94
|
+
authAddress);
|
|
95
|
+
references().forEach((ref, index) => need(JSON.stringify(getFunctionAddress(ref)) === addresses[index]));
|
|
96
|
+
if (binding) {
|
|
97
|
+
const rpc = readCheckedJournalActionRPC(binding);
|
|
98
|
+
need(rpc.receiver === ctx &&
|
|
99
|
+
rpc.component === component &&
|
|
100
|
+
rpc.operationId === args.operationId &&
|
|
101
|
+
rpc.runQuery === captured.query &&
|
|
102
|
+
rpc.runMutation === captured.mutation);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const owned = (work) => lifetime.owned(work, guard);
|
|
106
|
+
try {
|
|
107
|
+
binding = await owned(() => captureMaintainedJournalBinding(actualRoot, {
|
|
108
|
+
actualActionCtx: ctx,
|
|
109
|
+
operationId: args.operationId,
|
|
110
|
+
}));
|
|
111
|
+
guard();
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
lifetime.close();
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
async function authorize() {
|
|
118
|
+
const who = await owned(() => getIdentity.call(auth));
|
|
119
|
+
need(who && !types.isProxy(who));
|
|
120
|
+
const token = Object.getOwnPropertyDescriptor(who, "tokenIdentifier");
|
|
121
|
+
need(token && token.enumerable && "value" in token);
|
|
122
|
+
const tokenIdentifier = text(token.value, 2048);
|
|
123
|
+
const reply = await owned(() => captured.query.call(ctx, entry.authorizationQuery, args));
|
|
124
|
+
return captureReaderAuthorization(reply, args, tokenIdentifier, lifetime.check().wallMs);
|
|
125
|
+
}
|
|
126
|
+
async function stage(operationId) {
|
|
127
|
+
const operation = captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.load, { operationId })));
|
|
128
|
+
const load = object(operation), active = object(load.activeAttempt);
|
|
129
|
+
const attemptId = text(active.attemptId);
|
|
130
|
+
const attempt = captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.attempt, { operationId, attemptId })));
|
|
131
|
+
const manifest = closed(attempt, ["reservation", "events"]);
|
|
132
|
+
need(Array.isArray(manifest.events) && manifest.events.length <= 3);
|
|
133
|
+
const count = manifest.events.length;
|
|
134
|
+
const events = [];
|
|
135
|
+
for (let index = 0; index < count; index++) {
|
|
136
|
+
const sequence = index === 0 ? 1 : index === 1 ? 2 : 3;
|
|
137
|
+
events.push(captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.event, {
|
|
138
|
+
operationId,
|
|
139
|
+
attemptId,
|
|
140
|
+
sequence,
|
|
141
|
+
}))));
|
|
142
|
+
}
|
|
143
|
+
const acknowledgement = captureReaderQueryDATA(await owned(() => captured.query.call(ctx, refs.acknowledgement, { operationId })));
|
|
144
|
+
return { operation, attempt, events, acknowledgement };
|
|
145
|
+
}
|
|
146
|
+
let capturedHistory = null;
|
|
147
|
+
let used = false;
|
|
148
|
+
async function captureHistory() {
|
|
149
|
+
need(!used);
|
|
150
|
+
used = true;
|
|
151
|
+
lifetime.check();
|
|
152
|
+
guard();
|
|
153
|
+
const authorization = await authorize();
|
|
154
|
+
authorizedUntil = authorization.expiresAtMs;
|
|
155
|
+
const parent = await stage(args.parentOperationId), configure = await stage(args.operationId);
|
|
156
|
+
const history = await owned(() => captureRetainedObservationHistory({ parent, configure }));
|
|
157
|
+
const receipt = history.attachmentReceipt;
|
|
158
|
+
matchConfigureDATA(authorization.providerScope, {
|
|
159
|
+
mode: "platform",
|
|
160
|
+
stripeAccount: null,
|
|
161
|
+
livemode: receipt.livemode,
|
|
162
|
+
customerAccountId: receipt.customerAccountId,
|
|
163
|
+
subscriptionId: receipt.subscriptionId,
|
|
164
|
+
scheduleId: receipt.scheduleId,
|
|
165
|
+
});
|
|
166
|
+
capturedHistory = Object.freeze({ history, authorization });
|
|
167
|
+
return capturedHistory;
|
|
168
|
+
}
|
|
169
|
+
async function authorizeUnchanged() {
|
|
170
|
+
need(capturedHistory);
|
|
171
|
+
const final = await authorize();
|
|
172
|
+
matchConfigureDATA(final, capturedHistory.authorization);
|
|
173
|
+
need(lifetime.check().wallMs < capturedHistory.authorization.expiresAtMs);
|
|
174
|
+
guard();
|
|
175
|
+
return final;
|
|
176
|
+
}
|
|
177
|
+
need(binding);
|
|
178
|
+
const token = Object.freeze({});
|
|
179
|
+
invocations.set(token, Object.freeze({
|
|
180
|
+
binding,
|
|
181
|
+
historyEntry: entry,
|
|
182
|
+
guard() {
|
|
183
|
+
lifetime.check();
|
|
184
|
+
guard();
|
|
185
|
+
},
|
|
186
|
+
check: lifetime.check,
|
|
187
|
+
close: lifetime.close,
|
|
188
|
+
owned(work, extra) {
|
|
189
|
+
return lifetime.owned(work, () => {
|
|
190
|
+
guard();
|
|
191
|
+
extra?.();
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
captureHistory,
|
|
195
|
+
authorizeUnchanged,
|
|
196
|
+
readCaptured() {
|
|
197
|
+
lifetime.check();
|
|
198
|
+
guard();
|
|
199
|
+
need(capturedHistory);
|
|
200
|
+
return capturedHistory;
|
|
201
|
+
},
|
|
202
|
+
}));
|
|
203
|
+
return token;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=invocation.js.map
|