@fantastic.dev/better-stripe 0.90.0 → 0.91.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 +41 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +187 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts +2 -23
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js +1 -112
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts +8 -3
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +454 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js +99 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js +274 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
- 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/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- 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 +26 -8
- package/docs/renewal-material-observation.md +37 -0
- package/docs/renewal-phase-assembly.md +68 -0
- package/docs/renewal-raw-acquisition.md +19 -5
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
- package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
- package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
- package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
- package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
- package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
- package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
- package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
- package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
- package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
- package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
- package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
- package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
- package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
- package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
- package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
- package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
- package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
- package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
- package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
- package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
- package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
- package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
- package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
- package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
- package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
- package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
- package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
- package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
- package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
- package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
- package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
- package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
- package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { OWNER } from "../originalOwner.js";
|
|
3
|
+
import { closed, need, stop, type SourceMethod } from "./types.js";
|
|
4
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
5
|
+
import { resourceId } from "../../../renewalAggregate/shared.js";
|
|
6
|
+
import { loadConfigureOwnedReadTransportSource } from "./sourceOperations.js";
|
|
7
|
+
|
|
8
|
+
const API = "2026-09-30.endive";
|
|
9
|
+
type Resource = "subscription" | "price" | "customer" | "coupon" | "schedule";
|
|
10
|
+
type Row = Readonly<{
|
|
11
|
+
resource: Resource;
|
|
12
|
+
ordinal: number;
|
|
13
|
+
method: "GET";
|
|
14
|
+
path: string;
|
|
15
|
+
body: undefined;
|
|
16
|
+
id: string;
|
|
17
|
+
options: Readonly<{ apiVersion: typeof API; maxNetworkRetries: 0 }>;
|
|
18
|
+
}>;
|
|
19
|
+
const query =
|
|
20
|
+
"?" +
|
|
21
|
+
new URLSearchParams(
|
|
22
|
+
["discounts", "items.data.discounts", "items.data.price"].map(
|
|
23
|
+
(value, index) => ["expand[" + index + "]", value],
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
const plural = Object.freeze({
|
|
27
|
+
subscription: "subscriptions",
|
|
28
|
+
price: "prices",
|
|
29
|
+
customer: "customers",
|
|
30
|
+
coupon: "coupons",
|
|
31
|
+
schedule: "subscription_schedules",
|
|
32
|
+
});
|
|
33
|
+
const prefix = Object.freeze({
|
|
34
|
+
subscription: "sub",
|
|
35
|
+
price: "price",
|
|
36
|
+
customer: "cus",
|
|
37
|
+
schedule: "sub_sched",
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
function selectedID(resource: Resource, path: string): string {
|
|
41
|
+
const root = "/v1/" + plural[resource] + "/";
|
|
42
|
+
need(path.startsWith(root));
|
|
43
|
+
const encoded = path.slice(
|
|
44
|
+
root.length,
|
|
45
|
+
resource === "subscription" ? -query.length : undefined,
|
|
46
|
+
);
|
|
47
|
+
if (resource === "subscription") need(path.endsWith(query));
|
|
48
|
+
if (resource !== "coupon") {
|
|
49
|
+
const parsed = resourceId(prefix[resource]).safeParse(encoded);
|
|
50
|
+
need(parsed.success);
|
|
51
|
+
const id = parsed.data;
|
|
52
|
+
need(encodeURIComponent(id) === encoded);
|
|
53
|
+
return id;
|
|
54
|
+
}
|
|
55
|
+
let id: string;
|
|
56
|
+
try {
|
|
57
|
+
id = decodeURIComponent(encoded);
|
|
58
|
+
} catch {
|
|
59
|
+
return stop();
|
|
60
|
+
}
|
|
61
|
+
need(
|
|
62
|
+
id.length >= 1 &&
|
|
63
|
+
id.length <= 255 &&
|
|
64
|
+
/\S/.test(id) &&
|
|
65
|
+
id !== "." &&
|
|
66
|
+
id !== ".." &&
|
|
67
|
+
encodeURIComponent(id) === encoded,
|
|
68
|
+
);
|
|
69
|
+
return id;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Fixed DATA profile only. Undefined bodies remain explicit, never JSON-compared. */
|
|
73
|
+
function capturePlan(raw: unknown): readonly Row[] {
|
|
74
|
+
need(!types.isProxy(raw) && Array.isArray(raw));
|
|
75
|
+
need(Object.getPrototypeOf(raw) === Array.prototype);
|
|
76
|
+
const length = Object.getOwnPropertyDescriptor(raw, "length"),
|
|
77
|
+
count: unknown = length?.value;
|
|
78
|
+
need(
|
|
79
|
+
length &&
|
|
80
|
+
"value" in length &&
|
|
81
|
+
typeof count === "number" &&
|
|
82
|
+
Number.isSafeInteger(count) &&
|
|
83
|
+
count >= 4 &&
|
|
84
|
+
count <= 44,
|
|
85
|
+
);
|
|
86
|
+
const keys = Reflect.ownKeys(raw);
|
|
87
|
+
need(
|
|
88
|
+
keys.length === count + 1 && keys.every((key) => typeof key === "string"),
|
|
89
|
+
);
|
|
90
|
+
const rows: Row[] = [],
|
|
91
|
+
coupons = new Set<string>();
|
|
92
|
+
for (let index = 0; index < count; index++) {
|
|
93
|
+
const descriptor = Object.getOwnPropertyDescriptor(raw, String(index));
|
|
94
|
+
need(descriptor && descriptor.enumerable && "value" in descriptor);
|
|
95
|
+
const row = closed(descriptor.value, [
|
|
96
|
+
"resource",
|
|
97
|
+
"ordinal",
|
|
98
|
+
"method",
|
|
99
|
+
"path",
|
|
100
|
+
"body",
|
|
101
|
+
"options",
|
|
102
|
+
]),
|
|
103
|
+
options = closed(row.options, ["apiVersion", "maxNetworkRetries"]);
|
|
104
|
+
const resource: Resource =
|
|
105
|
+
index === 0
|
|
106
|
+
? "subscription"
|
|
107
|
+
: index === 1
|
|
108
|
+
? "price"
|
|
109
|
+
: index === 2
|
|
110
|
+
? "customer"
|
|
111
|
+
: index === count - 1
|
|
112
|
+
? "schedule"
|
|
113
|
+
: "coupon";
|
|
114
|
+
need(
|
|
115
|
+
row.resource === resource &&
|
|
116
|
+
row.ordinal === index + 1 &&
|
|
117
|
+
row.method === "GET" &&
|
|
118
|
+
typeof row.path === "string" &&
|
|
119
|
+
row.body === undefined &&
|
|
120
|
+
options.apiVersion === API &&
|
|
121
|
+
options.maxNetworkRetries === 0,
|
|
122
|
+
);
|
|
123
|
+
const id = selectedID(resource, row.path);
|
|
124
|
+
requiredJSONSnapshot(row.path);
|
|
125
|
+
if (resource === "coupon") {
|
|
126
|
+
need(!coupons.has(id));
|
|
127
|
+
coupons.add(id);
|
|
128
|
+
}
|
|
129
|
+
rows.push(
|
|
130
|
+
Object.freeze({
|
|
131
|
+
resource,
|
|
132
|
+
ordinal: index + 1,
|
|
133
|
+
method: "GET",
|
|
134
|
+
path: row.path,
|
|
135
|
+
body: undefined,
|
|
136
|
+
id,
|
|
137
|
+
options: Object.freeze({ apiVersion: API, maxNetworkRetries: 0 }),
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
need(coupons.size <= 40);
|
|
142
|
+
return Object.freeze(rows);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function sourceMethod(delegate: unknown): SourceMethod {
|
|
146
|
+
need(
|
|
147
|
+
delegate !== null &&
|
|
148
|
+
typeof delegate === "object" &&
|
|
149
|
+
!types.isProxy(delegate),
|
|
150
|
+
);
|
|
151
|
+
const value = closed(delegate, ["rawRequest"]).rawRequest;
|
|
152
|
+
need(typeof value === "function" && !types.isProxy(value));
|
|
153
|
+
return value as SourceMethod;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Separate fixed readonly operation pair. No POST or caller binding factory exists. */
|
|
157
|
+
export function createConfigureOwnedReadTransport() {
|
|
158
|
+
need(arguments.length === 0);
|
|
159
|
+
OWNER.check();
|
|
160
|
+
const source = loadConfigureOwnedReadTransportSource();
|
|
161
|
+
OWNER.check();
|
|
162
|
+
const frame = closed(source, ["owner", "operation", "readPlan", "delegate"]);
|
|
163
|
+
need(frame.owner === OWNER);
|
|
164
|
+
const operation = frame.operation,
|
|
165
|
+
delegate = frame.delegate,
|
|
166
|
+
readPlanReference = frame.readPlan,
|
|
167
|
+
plan = capturePlan(readPlanReference),
|
|
168
|
+
method = sourceMethod(delegate),
|
|
169
|
+
generation = Object.freeze({});
|
|
170
|
+
let phase = "unused",
|
|
171
|
+
index = 0,
|
|
172
|
+
closedOwner = false,
|
|
173
|
+
checking = false;
|
|
174
|
+
let pending: Readonly<{ generation: object; ordinal: number }> | null = null;
|
|
175
|
+
function gate() {
|
|
176
|
+
if (closedOwner || checking) {
|
|
177
|
+
closedOwner = true;
|
|
178
|
+
stop();
|
|
179
|
+
}
|
|
180
|
+
checking = true;
|
|
181
|
+
try {
|
|
182
|
+
OWNER.check();
|
|
183
|
+
if (closedOwner) stop();
|
|
184
|
+
} catch {
|
|
185
|
+
closedOwner = true;
|
|
186
|
+
stop();
|
|
187
|
+
} finally {
|
|
188
|
+
checking = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const capability = Object.freeze({
|
|
192
|
+
assertSourceOperationBinding(
|
|
193
|
+
actualOperation: unknown,
|
|
194
|
+
expectedPlan: unknown,
|
|
195
|
+
actualDelegate: unknown,
|
|
196
|
+
originalMethod: unknown,
|
|
197
|
+
) {
|
|
198
|
+
need(arguments.length === 4);
|
|
199
|
+
gate();
|
|
200
|
+
if (
|
|
201
|
+
phase !== "unused" ||
|
|
202
|
+
operation !== actualOperation ||
|
|
203
|
+
delegate !== actualDelegate ||
|
|
204
|
+
method !== originalMethod
|
|
205
|
+
) {
|
|
206
|
+
phase = "invalid";
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
const expected = capturePlan(expectedPlan);
|
|
210
|
+
const matches =
|
|
211
|
+
expected.length === plan.length &&
|
|
212
|
+
expected.every((row, ordinal) => {
|
|
213
|
+
const fixed = plan[ordinal];
|
|
214
|
+
return (
|
|
215
|
+
row.resource === fixed.resource &&
|
|
216
|
+
row.ordinal === fixed.ordinal &&
|
|
217
|
+
row.method === fixed.method &&
|
|
218
|
+
row.path === fixed.path &&
|
|
219
|
+
row.body === fixed.body &&
|
|
220
|
+
row.id === fixed.id &&
|
|
221
|
+
row.options.apiVersion === fixed.options.apiVersion &&
|
|
222
|
+
row.options.maxNetworkRetries === fixed.options.maxNetworkRetries
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
gate();
|
|
226
|
+
phase = matches ? "bound" : "invalid";
|
|
227
|
+
return matches;
|
|
228
|
+
},
|
|
229
|
+
reserveAcquisition() {
|
|
230
|
+
need(arguments.length === 0);
|
|
231
|
+
gate();
|
|
232
|
+
if (phase !== "bound" || index !== 0 || pending !== null) return false;
|
|
233
|
+
phase = "reserved";
|
|
234
|
+
return true;
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
const readTransport = Object.freeze({
|
|
238
|
+
async rawRequest(
|
|
239
|
+
methodName: "GET",
|
|
240
|
+
path: string,
|
|
241
|
+
body: undefined,
|
|
242
|
+
options: Readonly<{ apiVersion: typeof API; maxNetworkRetries: 0 }>,
|
|
243
|
+
): Promise<unknown> {
|
|
244
|
+
need(arguments.length === 4);
|
|
245
|
+
gate();
|
|
246
|
+
need(phase === "reserved" && pending === null && index < plan.length);
|
|
247
|
+
const row = plan[index],
|
|
248
|
+
actualOptions = closed(options, ["apiVersion", "maxNetworkRetries"]);
|
|
249
|
+
need(
|
|
250
|
+
methodName === row.method &&
|
|
251
|
+
path === row.path &&
|
|
252
|
+
body === row.body &&
|
|
253
|
+
actualOptions.apiVersion === API &&
|
|
254
|
+
actualOptions.maxNetworkRetries === 0,
|
|
255
|
+
);
|
|
256
|
+
const attempt = Object.freeze({ generation, ordinal: index + 1 });
|
|
257
|
+
need(attempt.ordinal <= 44);
|
|
258
|
+
pending = attempt;
|
|
259
|
+
let reply: unknown;
|
|
260
|
+
try {
|
|
261
|
+
reply = await Reflect.apply(method, delegate, [
|
|
262
|
+
methodName,
|
|
263
|
+
path,
|
|
264
|
+
body,
|
|
265
|
+
row.options,
|
|
266
|
+
]);
|
|
267
|
+
} catch {
|
|
268
|
+
gate();
|
|
269
|
+
phase = "failed";
|
|
270
|
+
pending = null;
|
|
271
|
+
return stop();
|
|
272
|
+
}
|
|
273
|
+
gate();
|
|
274
|
+
need(pending === attempt && attempt.generation === generation);
|
|
275
|
+
pending = null;
|
|
276
|
+
index++;
|
|
277
|
+
if (index === plan.length) phase = "readclosed";
|
|
278
|
+
return reply;
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
return Object.freeze({
|
|
282
|
+
transport: Object.freeze({ readTransport }),
|
|
283
|
+
capability,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
COMPILED_INITIAL_ENTRIES,
|
|
4
|
+
COMPILED_RECOVERY_ENTRIES,
|
|
5
|
+
COMPILED_PREFLIGHT_ENTRIES,
|
|
6
|
+
ORIGINAL_ORIGIN_ASSOCIATION,
|
|
7
|
+
loadFixedInitialOperation,
|
|
8
|
+
loadFixedExplicitRecoveryOperation,
|
|
9
|
+
loadOwnedConfigureOperation,
|
|
10
|
+
loadOwnedTransportSource,
|
|
11
|
+
} from "./sourceOperations.js";
|
|
12
|
+
|
|
13
|
+
it("internal operation Source defaults bind no class, producer or origin", () => {
|
|
14
|
+
for (const entries of [
|
|
15
|
+
COMPILED_INITIAL_ENTRIES,
|
|
16
|
+
COMPILED_RECOVERY_ENTRIES,
|
|
17
|
+
COMPILED_PREFLIGHT_ENTRIES,
|
|
18
|
+
]) {
|
|
19
|
+
expect(entries).toEqual([]);
|
|
20
|
+
expect(Object.isFrozen(entries)).toBe(true);
|
|
21
|
+
}
|
|
22
|
+
expect(ORIGINAL_ORIGIN_ASSOCIATION).toBe(null);
|
|
23
|
+
for (const load of [
|
|
24
|
+
loadFixedInitialOperation,
|
|
25
|
+
loadFixedExplicitRecoveryOperation,
|
|
26
|
+
loadOwnedConfigureOperation,
|
|
27
|
+
loadOwnedTransportSource,
|
|
28
|
+
])
|
|
29
|
+
expect(load).toThrow(/UNBOUND/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("normal actor captures stay EMPTY and consume each invocation without Source access", async () => {
|
|
33
|
+
const { captureOwnedInitialAttachV2 } = await import("./initialAttach.js");
|
|
34
|
+
const { captureOwnedExplicitAttachRecoveryV2 } =
|
|
35
|
+
await import("../recovery/recoveryActor.js");
|
|
36
|
+
for (const { capture, reason } of [
|
|
37
|
+
{
|
|
38
|
+
capture: captureOwnedInitialAttachV2,
|
|
39
|
+
reason: "no_qualified_native_class",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
capture: captureOwnedExplicitAttachRecoveryV2,
|
|
43
|
+
reason: "no_qualified_recovery_class",
|
|
44
|
+
},
|
|
45
|
+
]) {
|
|
46
|
+
expect(() => Reflect.apply(capture, undefined, [{}])).toThrow(
|
|
47
|
+
"INITIAL_ACTOR_STOP",
|
|
48
|
+
);
|
|
49
|
+
const handle = capture();
|
|
50
|
+
expect(await handle.invoke()).toMatchObject({
|
|
51
|
+
status: "not_dispatched",
|
|
52
|
+
reason,
|
|
53
|
+
operationalAuthority: false,
|
|
54
|
+
});
|
|
55
|
+
expect(await handle.invoke()).toMatchObject({
|
|
56
|
+
reason: "invocation_consumed",
|
|
57
|
+
});
|
|
58
|
+
await expect(Reflect.apply(handle.invoke, handle, [{}])).rejects.toThrow(
|
|
59
|
+
"INITIAL_ACTOR_STOP",
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("stage-specific transport Source loaders remain UNBOUND", async () => {
|
|
65
|
+
const { loadInitialOwnedTransportSource, loadRecoveryOwnedTransportSource } =
|
|
66
|
+
await import("./sourceOperations.js");
|
|
67
|
+
expect(loadInitialOwnedTransportSource).toThrow(/UNBOUND/);
|
|
68
|
+
expect(loadRecoveryOwnedTransportSource).toThrow(/UNBOUND/);
|
|
69
|
+
});
|