@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,408 @@
|
|
|
1
|
+
// Bounded record DATA only. Source/ACK identity stays in the invoking actor.
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
4
|
+
import {
|
|
5
|
+
objectNode,
|
|
6
|
+
scalarNode,
|
|
7
|
+
encode,
|
|
8
|
+
materialize,
|
|
9
|
+
} from "../material/nodeKernel.js";
|
|
10
|
+
import { closed, need, freeze } from "../material/nodeKernel.js";
|
|
11
|
+
import { equal, referenceId } from "../../../renewalAggregate/shared.js";
|
|
12
|
+
import { observationData } from "./types.js";
|
|
13
|
+
import type {
|
|
14
|
+
Node,
|
|
15
|
+
Data,
|
|
16
|
+
ObservationRecord,
|
|
17
|
+
CapturedObservationRecord,
|
|
18
|
+
} from "./types.js";
|
|
19
|
+
import type { Bundle } from "../material/capture.js";
|
|
20
|
+
import type {
|
|
21
|
+
ProjectedRenewalConfigurationV2,
|
|
22
|
+
RenewalScheduleAttachmentReceiptV2,
|
|
23
|
+
} from "../../../renewalV2/index.js";
|
|
24
|
+
const families: Readonly<Record<string, string>> = Object.freeze({
|
|
25
|
+
"/record/request/logicalBinding": "renewal",
|
|
26
|
+
"/record/request/attachReceiptBinding": "renewal-attach-receipt",
|
|
27
|
+
"/record/request/baselineBinding": "renewal-baseline",
|
|
28
|
+
"/record/request/defaultSettingsBinding": "renewal-defaults",
|
|
29
|
+
"/record/request/requestIdentity/binding": "renewal-configure",
|
|
30
|
+
"/record/attachReceipt/logicalBinding": "renewal",
|
|
31
|
+
"/record/attachReceipt/request/logicalBinding": "renewal",
|
|
32
|
+
"/record/attachReceipt/request/requestIdentity/binding": "renewal-attach",
|
|
33
|
+
"/record/attachReceipt/binding": "renewal-attach-receipt",
|
|
34
|
+
});
|
|
35
|
+
const requestKeys = [
|
|
36
|
+
"version",
|
|
37
|
+
"stage",
|
|
38
|
+
"scope",
|
|
39
|
+
"apiVersion",
|
|
40
|
+
"logicalBinding",
|
|
41
|
+
"scheduleId",
|
|
42
|
+
"method",
|
|
43
|
+
"path",
|
|
44
|
+
"key",
|
|
45
|
+
"payload",
|
|
46
|
+
"firstDispatchedAt",
|
|
47
|
+
"attachReceiptBinding",
|
|
48
|
+
"baselineBinding",
|
|
49
|
+
"defaultSettingsBinding",
|
|
50
|
+
"status",
|
|
51
|
+
"providerQualification",
|
|
52
|
+
"profile",
|
|
53
|
+
"requestIdentity",
|
|
54
|
+
];
|
|
55
|
+
const schemas: Readonly<Record<string, readonly string[]>> = Object.freeze({
|
|
56
|
+
"": ["record"],
|
|
57
|
+
"/record": ["configuration", "request", "attachReceipt", "originalBundle"],
|
|
58
|
+
"/record/request": requestKeys,
|
|
59
|
+
"/record/request/requestIdentity": ["key", "binding"],
|
|
60
|
+
"/record/request/profile": ["apiVersion", "billingMode", "cadence", "anchor"],
|
|
61
|
+
"/record/attachReceipt": [
|
|
62
|
+
"version",
|
|
63
|
+
"stage",
|
|
64
|
+
"scope",
|
|
65
|
+
"logicalBinding",
|
|
66
|
+
"request",
|
|
67
|
+
"scheduleId",
|
|
68
|
+
"subscriptionId",
|
|
69
|
+
"customerAccountId",
|
|
70
|
+
"livemode",
|
|
71
|
+
"providerSnapshot",
|
|
72
|
+
"binding",
|
|
73
|
+
],
|
|
74
|
+
"/record/attachReceipt/request": [
|
|
75
|
+
"version",
|
|
76
|
+
"stage",
|
|
77
|
+
"scope",
|
|
78
|
+
"apiVersion",
|
|
79
|
+
"logicalBinding",
|
|
80
|
+
"method",
|
|
81
|
+
"path",
|
|
82
|
+
"payload",
|
|
83
|
+
"key",
|
|
84
|
+
"firstDispatchedAt",
|
|
85
|
+
"requestIdentity",
|
|
86
|
+
],
|
|
87
|
+
"/record/attachReceipt/request/requestIdentity": ["key", "binding"],
|
|
88
|
+
"/record/originalBundle": [
|
|
89
|
+
"wireSubscription",
|
|
90
|
+
"wireTargetPrice",
|
|
91
|
+
"wireBillingCustomer",
|
|
92
|
+
"couponReads",
|
|
93
|
+
"derivedCouponJoins",
|
|
94
|
+
],
|
|
95
|
+
"/record/originalBundle/derivedCouponJoins": ["subscription", "item"],
|
|
96
|
+
"/record/configuration/attachReceipt": [
|
|
97
|
+
"attachRequest",
|
|
98
|
+
"actualDispatch",
|
|
99
|
+
"providerSnapshot",
|
|
100
|
+
],
|
|
101
|
+
"/record/configuration/attachReceipt/attachRequest": [
|
|
102
|
+
"preparation",
|
|
103
|
+
"apiVersion",
|
|
104
|
+
"attachKey",
|
|
105
|
+
"firstDispatchedAt",
|
|
106
|
+
],
|
|
107
|
+
"/record/configuration/attachReceipt/actualDispatch": [
|
|
108
|
+
"scope",
|
|
109
|
+
"apiVersion",
|
|
110
|
+
"method",
|
|
111
|
+
"path",
|
|
112
|
+
"payload",
|
|
113
|
+
"key",
|
|
114
|
+
"firstDispatchedAt",
|
|
115
|
+
],
|
|
116
|
+
});
|
|
117
|
+
const pointer = (key: string) => key.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
118
|
+
function controls(value: unknown, path: string) {
|
|
119
|
+
if (Object.prototype.hasOwnProperty.call(schemas, path))
|
|
120
|
+
closed(value, schemas[path]!);
|
|
121
|
+
if (path === "/record/configuration")
|
|
122
|
+
closed(
|
|
123
|
+
value,
|
|
124
|
+
[
|
|
125
|
+
"preparation",
|
|
126
|
+
"attachReceipt",
|
|
127
|
+
"freshSubscription",
|
|
128
|
+
"targetPrice",
|
|
129
|
+
"schedule",
|
|
130
|
+
"apiVersion",
|
|
131
|
+
"observedAt",
|
|
132
|
+
"firstDispatchedAt",
|
|
133
|
+
"configureKey",
|
|
134
|
+
],
|
|
135
|
+
["billingCustomer"],
|
|
136
|
+
);
|
|
137
|
+
if (
|
|
138
|
+
path === "/record/configuration/preparation" ||
|
|
139
|
+
path === "/record/configuration/attachReceipt/attachRequest/preparation"
|
|
140
|
+
)
|
|
141
|
+
closed(
|
|
142
|
+
value,
|
|
143
|
+
["subscription", "targetPrice", "expected", "key"],
|
|
144
|
+
["billingCustomer"],
|
|
145
|
+
);
|
|
146
|
+
if (/^\/record\/originalBundle\/couponReads\/(0|[1-9][0-9]*)$/.test(path))
|
|
147
|
+
closed(value, ["couponId", "wireCoupon", "association"]);
|
|
148
|
+
if (
|
|
149
|
+
/^\/record\/originalBundle\/couponReads\/(0|[1-9][0-9]*)\/association$/.test(
|
|
150
|
+
path,
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
closed(value, ["resource", "ordinal"]);
|
|
154
|
+
if (
|
|
155
|
+
/^\/record\/originalBundle\/derivedCouponJoins\/(subscription|item)\/(0|[1-9][0-9]*)$/.test(
|
|
156
|
+
path,
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
closed(value, [
|
|
160
|
+
"index",
|
|
161
|
+
"discountId",
|
|
162
|
+
"originalCouponReference",
|
|
163
|
+
"couponReadIndex",
|
|
164
|
+
"joinedDiscount",
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
export function captureObservationRecord(
|
|
168
|
+
raw: unknown,
|
|
169
|
+
): CapturedObservationRecord {
|
|
170
|
+
const slots = new Map<string, string>(),
|
|
171
|
+
active = new Set<object>();
|
|
172
|
+
let nodes = 0,
|
|
173
|
+
characters = 0;
|
|
174
|
+
function walk(value: unknown, path: string, depth: number): Node {
|
|
175
|
+
need(++nodes <= 10000 && depth <= 40 && !types.isProxy(value));
|
|
176
|
+
if (Object.prototype.hasOwnProperty.call(families, path)) {
|
|
177
|
+
need(
|
|
178
|
+
typeof value === "string" &&
|
|
179
|
+
new RegExp("^" + families[path] + ":v2:sha256:[0-9a-f]{64}$").test(
|
|
180
|
+
value,
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
slots.set(path, value);
|
|
184
|
+
characters += value.length;
|
|
185
|
+
need(characters <= 500000);
|
|
186
|
+
return scalarNode(value);
|
|
187
|
+
}
|
|
188
|
+
if (value === null || typeof value !== "object") {
|
|
189
|
+
requiredJSONSnapshot(value);
|
|
190
|
+
if (typeof value === "string") characters += value.length;
|
|
191
|
+
need(characters <= 500000);
|
|
192
|
+
return scalarNode(value);
|
|
193
|
+
}
|
|
194
|
+
need(!active.has(value));
|
|
195
|
+
active.add(value);
|
|
196
|
+
const array = Array.isArray(value),
|
|
197
|
+
proto = Object.getPrototypeOf(value);
|
|
198
|
+
need(
|
|
199
|
+
array
|
|
200
|
+
? proto === Array.prototype
|
|
201
|
+
: proto === Object.prototype || proto === null,
|
|
202
|
+
);
|
|
203
|
+
const keys = Reflect.ownKeys(value);
|
|
204
|
+
need(keys.length <= 10001);
|
|
205
|
+
controls(value, path);
|
|
206
|
+
const length = array
|
|
207
|
+
? Object.getOwnPropertyDescriptor(value, "length")
|
|
208
|
+
: null;
|
|
209
|
+
if (array)
|
|
210
|
+
need(
|
|
211
|
+
length &&
|
|
212
|
+
"value" in length &&
|
|
213
|
+
Number.isSafeInteger(length.value) &&
|
|
214
|
+
length.value >= 0 &&
|
|
215
|
+
length.value <= 10000,
|
|
216
|
+
);
|
|
217
|
+
const entries: [string, Node][] = [];
|
|
218
|
+
for (const key of keys) {
|
|
219
|
+
need(typeof key === "string");
|
|
220
|
+
if (array && key === "length") continue;
|
|
221
|
+
const d = Object.getOwnPropertyDescriptor(value, key);
|
|
222
|
+
need(d && d.enumerable && "value" in d);
|
|
223
|
+
requiredJSONSnapshot(key);
|
|
224
|
+
requiredJSONSnapshot({ [key]: d.value === null ? null : true });
|
|
225
|
+
characters += key.length;
|
|
226
|
+
need(characters <= 500000);
|
|
227
|
+
need(
|
|
228
|
+
!array ||
|
|
229
|
+
(/^(0|[1-9][0-9]*)$/.test(key) && Number(key) < length!.value),
|
|
230
|
+
);
|
|
231
|
+
entries.push([key, walk(d.value, path + "/" + pointer(key), depth + 1)]);
|
|
232
|
+
}
|
|
233
|
+
active.delete(value);
|
|
234
|
+
if (array) {
|
|
235
|
+
need(entries.length === length!.value);
|
|
236
|
+
entries.sort(([a], [b]) => Number(a) - Number(b));
|
|
237
|
+
return Object.freeze({
|
|
238
|
+
kind: "array" as const,
|
|
239
|
+
entries: Object.freeze(
|
|
240
|
+
entries.map(
|
|
241
|
+
Object.freeze as (entry: [string, Node]) => readonly [string, Node],
|
|
242
|
+
),
|
|
243
|
+
),
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return objectNode(entries);
|
|
247
|
+
}
|
|
248
|
+
const node = walk({ record: raw }, "", 0);
|
|
249
|
+
need(slots.size === 9);
|
|
250
|
+
encode(node);
|
|
251
|
+
return Object.freeze({
|
|
252
|
+
record: freeze((materialize(node) as { record: ObservationRecord }).record),
|
|
253
|
+
slots,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
export function verifyObservationRecord(
|
|
257
|
+
captured: CapturedObservationRecord,
|
|
258
|
+
request: ProjectedRenewalConfigurationV2,
|
|
259
|
+
receipt: RenewalScheduleAttachmentReceiptV2,
|
|
260
|
+
) {
|
|
261
|
+
const expected = {
|
|
262
|
+
"/record/request/logicalBinding": request.logicalBinding,
|
|
263
|
+
"/record/request/attachReceiptBinding": request.attachReceiptBinding,
|
|
264
|
+
"/record/request/baselineBinding": request.baselineBinding,
|
|
265
|
+
"/record/request/defaultSettingsBinding": request.defaultSettingsBinding,
|
|
266
|
+
"/record/request/requestIdentity/binding": request.requestIdentity.binding,
|
|
267
|
+
"/record/attachReceipt/logicalBinding": receipt.logicalBinding,
|
|
268
|
+
"/record/attachReceipt/request/logicalBinding":
|
|
269
|
+
receipt.request.logicalBinding,
|
|
270
|
+
"/record/attachReceipt/request/requestIdentity/binding":
|
|
271
|
+
receipt.request.requestIdentity.binding,
|
|
272
|
+
"/record/attachReceipt/binding": receipt.binding,
|
|
273
|
+
};
|
|
274
|
+
need(captured.slots.size === 9);
|
|
275
|
+
for (const [path, value] of Object.entries(expected))
|
|
276
|
+
need(captured.slots.get(path) === value);
|
|
277
|
+
const record = captured.record;
|
|
278
|
+
need(equal(record.request, request) && equal(record.attachReceipt, receipt));
|
|
279
|
+
verifyOriginalRaw(record, receipt);
|
|
280
|
+
}
|
|
281
|
+
const couponID = (id: unknown): id is string =>
|
|
282
|
+
typeof id === "string" &&
|
|
283
|
+
id.length > 0 &&
|
|
284
|
+
id.length <= 255 &&
|
|
285
|
+
/\S/.test(id) &&
|
|
286
|
+
id !== "." &&
|
|
287
|
+
id !== "..";
|
|
288
|
+
function rebuild(
|
|
289
|
+
b: Pick<Bundle, "wireSubscription" | "couponReads" | "derivedCouponJoins">,
|
|
290
|
+
) {
|
|
291
|
+
const subscription = b.wireSubscription;
|
|
292
|
+
need(
|
|
293
|
+
subscription &&
|
|
294
|
+
subscription.items &&
|
|
295
|
+
Array.isArray(subscription.items.data) &&
|
|
296
|
+
subscription.items.data.length === 1,
|
|
297
|
+
);
|
|
298
|
+
const lists = [subscription.discounts, subscription.items.data[0]!.discounts];
|
|
299
|
+
need(lists.every((x) => Array.isArray(x) && x.length <= 20));
|
|
300
|
+
need(Array.isArray(b.couponReads) && b.couponReads.length <= 40);
|
|
301
|
+
const ids = new Map<string, number>();
|
|
302
|
+
const joined = lists.map((list) =>
|
|
303
|
+
list.map((discount, index) => {
|
|
304
|
+
need(discount && discount.source);
|
|
305
|
+
const ref = discount.source.coupon,
|
|
306
|
+
id = typeof ref === "string" ? ref : ref?.id;
|
|
307
|
+
need(couponID(id));
|
|
308
|
+
if (!ids.has(id)) {
|
|
309
|
+
const i = ids.size,
|
|
310
|
+
row = closed(b.couponReads[i], [
|
|
311
|
+
"couponId",
|
|
312
|
+
"wireCoupon",
|
|
313
|
+
"association",
|
|
314
|
+
]);
|
|
315
|
+
const association = closed(row.association, ["resource", "ordinal"]);
|
|
316
|
+
need(
|
|
317
|
+
row.couponId === id &&
|
|
318
|
+
association.resource === "coupon" &&
|
|
319
|
+
association.ordinal === 4 + i,
|
|
320
|
+
);
|
|
321
|
+
const c = observationData(row.wireCoupon);
|
|
322
|
+
need(c && c.id === id && c.object === "coupon" && c.deleted !== true);
|
|
323
|
+
ids.set(id, i);
|
|
324
|
+
}
|
|
325
|
+
const couponReadIndex = ids.get(id)!,
|
|
326
|
+
coupon = b.couponReads[couponReadIndex]!.wireCoupon;
|
|
327
|
+
need(typeof ref === "string" || equal(ref, coupon));
|
|
328
|
+
const joinedDiscount = {
|
|
329
|
+
...discount,
|
|
330
|
+
source: { ...discount.source, coupon },
|
|
331
|
+
};
|
|
332
|
+
return {
|
|
333
|
+
index,
|
|
334
|
+
discountId: discount.id,
|
|
335
|
+
originalCouponReference: ref,
|
|
336
|
+
couponReadIndex,
|
|
337
|
+
joinedDiscount,
|
|
338
|
+
};
|
|
339
|
+
}),
|
|
340
|
+
);
|
|
341
|
+
need(
|
|
342
|
+
ids.size === b.couponReads.length &&
|
|
343
|
+
equal(b.derivedCouponJoins, { subscription: joined[0], item: joined[1] }),
|
|
344
|
+
);
|
|
345
|
+
return {
|
|
346
|
+
subscription: joined[0]!.map((x) => x.joinedDiscount),
|
|
347
|
+
item: joined[1]!.map((x) => x.joinedDiscount),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function association(
|
|
352
|
+
value: unknown,
|
|
353
|
+
id: string,
|
|
354
|
+
configuration: ObservationRecord["configuration"],
|
|
355
|
+
) {
|
|
356
|
+
const e = configuration.preparation.expected,
|
|
357
|
+
ctx = { customerAccountId: e.customerAccountId, livemode: e.livemode };
|
|
358
|
+
need(referenceId(value, "sub_sched", "subscription_schedule", ctx) === id);
|
|
359
|
+
if (typeof value === "object")
|
|
360
|
+
need(
|
|
361
|
+
!Object.prototype.hasOwnProperty.call(value as object, "deleted") ||
|
|
362
|
+
(value as Data).deleted === false,
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
function verifyOriginalRaw(
|
|
366
|
+
record: ObservationRecord,
|
|
367
|
+
ack: RenewalScheduleAttachmentReceiptV2,
|
|
368
|
+
) {
|
|
369
|
+
const c = record.configuration,
|
|
370
|
+
o = record.originalBundle,
|
|
371
|
+
p = c.preparation,
|
|
372
|
+
a = c.attachReceipt.attachRequest;
|
|
373
|
+
need(
|
|
374
|
+
equal(c.schedule, ack.providerSnapshot) &&
|
|
375
|
+
equal(c.attachReceipt.providerSnapshot, ack.providerSnapshot) &&
|
|
376
|
+
equal(p, a.preparation) &&
|
|
377
|
+
c.apiVersion === a.apiVersion,
|
|
378
|
+
);
|
|
379
|
+
need(
|
|
380
|
+
c.configureKey !== a.attachKey &&
|
|
381
|
+
Object.prototype.hasOwnProperty.call(o.wireSubscription, "schedule") &&
|
|
382
|
+
o.wireSubscription.schedule === null &&
|
|
383
|
+
Object.prototype.hasOwnProperty.call(c.freshSubscription, "schedule") &&
|
|
384
|
+
c.freshSubscription.schedule !== null,
|
|
385
|
+
);
|
|
386
|
+
const { schedule: oldAssociation, ...oldResidual } = o.wireSubscription,
|
|
387
|
+
{ schedule: newAssociation, ...newResidual } = c.freshSubscription;
|
|
388
|
+
need(
|
|
389
|
+
oldAssociation === null &&
|
|
390
|
+
equal(oldResidual, newResidual) &&
|
|
391
|
+
equal(p.subscription, o.wireSubscription),
|
|
392
|
+
);
|
|
393
|
+
association(newAssociation, ack.scheduleId, c);
|
|
394
|
+
for (const [name, wire] of [
|
|
395
|
+
["targetPrice", "wireTargetPrice"],
|
|
396
|
+
["billingCustomer", "wireBillingCustomer"],
|
|
397
|
+
] as const)
|
|
398
|
+
need(equal(p[name], o[wire]) && equal(c[name], o[wire]));
|
|
399
|
+
rebuild(o);
|
|
400
|
+
const preconfigure = {
|
|
401
|
+
wireSubscription: c.freshSubscription,
|
|
402
|
+
wireTargetPrice: c.targetPrice,
|
|
403
|
+
wireBillingCustomer: c.billingCustomer,
|
|
404
|
+
couponReads: o.couponReads,
|
|
405
|
+
derivedCouponJoins: o.derivedCouponJoins,
|
|
406
|
+
};
|
|
407
|
+
rebuild(preconfigure);
|
|
408
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { closed, need } from "../operations/types.js";
|
|
3
|
+
import type { PreflightRecord } from "../preflight/grammar.js";
|
|
4
|
+
import type { Node } from "../material/nodeKernel.js";
|
|
5
|
+
import type { inspectRenewalScheduleMaterialV2 } from "../../../renewalV2/observation.js";
|
|
6
|
+
|
|
7
|
+
export type Data = Record<string, unknown>;
|
|
8
|
+
/** Captured DATA shape only; actual C6/C3/raw proof and Source pointers remain mandatory. */
|
|
9
|
+
export type ObservationRecord = PreflightRecord;
|
|
10
|
+
export interface CapturedObservationRecord {
|
|
11
|
+
readonly record: ObservationRecord;
|
|
12
|
+
readonly slots: ReadonlyMap<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export type { Node };
|
|
15
|
+
export type SourceMethod = (...args: unknown[]) => unknown;
|
|
16
|
+
export interface OwnerSample {
|
|
17
|
+
readonly wallMs: number;
|
|
18
|
+
readonly ns: bigint;
|
|
19
|
+
readonly nowSeconds: number;
|
|
20
|
+
readonly retired: false;
|
|
21
|
+
}
|
|
22
|
+
export type Resource =
|
|
23
|
+
"schedule" | "subscription" | "price" | "customer" | "coupon";
|
|
24
|
+
export interface ObservationReadRow {
|
|
25
|
+
readonly resource: Resource;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly ordinal: number;
|
|
28
|
+
readonly method: "GET";
|
|
29
|
+
readonly path: string;
|
|
30
|
+
readonly body: undefined;
|
|
31
|
+
readonly options: Readonly<{ apiVersion: string; maxNetworkRetries: 0 }>;
|
|
32
|
+
}
|
|
33
|
+
export interface ObservationReads {
|
|
34
|
+
schedule: unknown;
|
|
35
|
+
subscription: unknown;
|
|
36
|
+
targetPrice: unknown;
|
|
37
|
+
billingCustomer: unknown;
|
|
38
|
+
coupons: unknown[];
|
|
39
|
+
}
|
|
40
|
+
export type Diagnostics = Readonly<
|
|
41
|
+
Partial<{ type: string; code: string; requestId: string; statusCode: number }>
|
|
42
|
+
>;
|
|
43
|
+
export interface ReadRequest {
|
|
44
|
+
readonly method: "GET";
|
|
45
|
+
readonly path: string;
|
|
46
|
+
readonly apiVersion: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Attempt {
|
|
49
|
+
readonly invocation: object | null;
|
|
50
|
+
readonly generation: object | null;
|
|
51
|
+
readonly resource: Resource;
|
|
52
|
+
readonly ordinal: number;
|
|
53
|
+
readonly request: ReadRequest;
|
|
54
|
+
promise: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface StoredReadFailure {
|
|
57
|
+
readonly invocation: object | null;
|
|
58
|
+
readonly generation: object | null;
|
|
59
|
+
readonly attempt: Attempt;
|
|
60
|
+
readonly diagnostics: Diagnostics;
|
|
61
|
+
}
|
|
62
|
+
export interface ReadFailure {
|
|
63
|
+
readonly category: "provider_rejected";
|
|
64
|
+
readonly phase: "read";
|
|
65
|
+
readonly resource: Resource;
|
|
66
|
+
readonly ordinal: number;
|
|
67
|
+
readonly request: ReadRequest;
|
|
68
|
+
readonly diagnostics: Diagnostics;
|
|
69
|
+
readonly outcome: "unknown";
|
|
70
|
+
readonly operationalAuthority: false;
|
|
71
|
+
}
|
|
72
|
+
export type ObservationResult = Awaited<
|
|
73
|
+
ReturnType<typeof inspectRenewalScheduleMaterialV2>
|
|
74
|
+
>;
|
|
75
|
+
/** DATA-only validation, never a Source capability or Owner selector. */
|
|
76
|
+
export function checkOwnerResult(value: unknown): asserts value is OwnerSample {
|
|
77
|
+
const x = closed(value, ["wallMs", "ns", "nowSeconds", "retired"]);
|
|
78
|
+
need(
|
|
79
|
+
typeof x.wallMs === "number" &&
|
|
80
|
+
Number.isSafeInteger(x.wallMs) &&
|
|
81
|
+
x.wallMs >= 0 &&
|
|
82
|
+
typeof x.ns === "bigint" &&
|
|
83
|
+
x.ns >= 0n &&
|
|
84
|
+
x.ns <= 18446744073709551615n &&
|
|
85
|
+
typeof x.nowSeconds === "number" &&
|
|
86
|
+
Number.isSafeInteger(x.nowSeconds) &&
|
|
87
|
+
x.nowSeconds === Math.floor(x.wallMs / 1000) &&
|
|
88
|
+
x.retired === false,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
/** Only a raw DATA view after object guards; no pruning, schema or authority admission. */
|
|
92
|
+
export function observationData(value: unknown): Data {
|
|
93
|
+
need(
|
|
94
|
+
value !== null &&
|
|
95
|
+
typeof value === "object" &&
|
|
96
|
+
!types.isProxy(value) &&
|
|
97
|
+
!Array.isArray(value),
|
|
98
|
+
);
|
|
99
|
+
const prototype = Object.getPrototypeOf(value);
|
|
100
|
+
need(prototype === Object.prototype || prototype === null);
|
|
101
|
+
return value as Data;
|
|
102
|
+
}
|