@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.
Files changed (216) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts +41 -0
  4. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -0
  5. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +187 -0
  6. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -0
  7. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts +2 -23
  8. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js +1 -112
  10. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts +8 -3
  12. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts.map +1 -1
  13. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js +1 -0
  14. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +1 -1
  16. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +8 -0
  17. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
  18. package/dist/client/billing/renewalAttach/internal/configure/actor.js +454 -0
  19. package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -0
  20. package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts +12 -0
  21. package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts.map +1 -0
  22. package/dist/client/billing/renewalAttach/internal/configure/capture.js +99 -0
  23. package/dist/client/billing/renewalAttach/internal/configure/capture.js.map +1 -0
  24. package/dist/client/billing/renewalAttach/internal/configure/output.d.ts +16 -0
  25. package/dist/client/billing/renewalAttach/internal/configure/output.d.ts.map +1 -0
  26. package/dist/client/billing/renewalAttach/internal/configure/output.js +274 -0
  27. package/dist/client/billing/renewalAttach/internal/configure/output.js.map +1 -0
  28. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
  29. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
  30. package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
  31. package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
  32. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
  33. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
  34. package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
  35. package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
  36. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
  37. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
  38. package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
  39. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
  40. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
  41. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
  42. package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
  43. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
  44. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
  45. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
  46. package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
  47. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
  48. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
  49. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
  50. package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
  51. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
  52. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
  53. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
  54. package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
  55. package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
  56. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
  57. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
  58. package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
  59. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
  60. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
  61. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
  62. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
  63. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
  64. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
  65. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
  66. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
  67. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
  68. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
  69. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
  70. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
  71. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
  72. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
  73. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
  74. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
  75. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
  76. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
  77. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
  78. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
  79. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
  80. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
  81. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
  82. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
  83. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
  84. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
  85. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
  86. package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
  87. package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
  88. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
  89. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
  90. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
  91. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
  92. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
  93. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
  94. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
  95. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
  96. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
  97. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
  98. package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
  99. package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
  100. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
  101. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
  102. package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
  103. package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
  104. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
  105. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
  106. package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
  107. package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
  108. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
  109. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
  110. package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
  111. package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
  112. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
  113. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
  114. package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
  115. package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
  116. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
  117. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
  118. package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
  119. package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
  120. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
  121. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
  122. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
  123. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
  124. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
  125. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
  126. package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
  127. package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
  128. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  129. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  130. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  131. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  132. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  133. package/dist/component/payoutRelease/queries.d.ts +2 -2
  134. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  135. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  136. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  137. package/docs/renewal-context-reads.md +26 -8
  138. package/docs/renewal-material-observation.md +37 -0
  139. package/docs/renewal-phase-assembly.md +68 -0
  140. package/docs/renewal-raw-acquisition.md +19 -5
  141. package/package.json +1 -1
  142. package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
  143. package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
  144. package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
  145. package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
  146. package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
  147. package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
  148. package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
  149. package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
  150. package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
  151. package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
  152. package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
  153. package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
  154. package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
  155. package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
  156. package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
  157. package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
  158. package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
  159. package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
  160. package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
  161. package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
  162. package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
  163. package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
  164. package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
  165. package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
  166. package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
  167. package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
  168. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
  169. package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
  170. package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
  171. package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
  172. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
  173. package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
  174. package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
  175. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
  176. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
  177. package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
  178. package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
  179. package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
  180. package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
  181. package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
  182. package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
  183. package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
  184. package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
  185. package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
  186. package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
  187. package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
  188. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
  189. package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
  190. package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
  191. package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
  192. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
  193. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
  194. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
  195. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
  196. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
  197. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
  198. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
  199. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
  200. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
  201. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
  202. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
  203. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
  204. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
  205. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
  206. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
  207. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
  208. package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
  209. package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
  210. package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
  211. package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
  212. package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
  213. package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
  214. package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
  215. package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
  216. package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
@@ -0,0 +1,66 @@
1
+ import { types } from "node:util";
2
+ import { requiredJSONSnapshot } from "../material/requiredJson.js";
3
+
4
+ export type Diagnostics = Readonly<{
5
+ statusCode?: number;
6
+ code?: string;
7
+ requestId?: string;
8
+ type?: string;
9
+ }>;
10
+ export function safeDiagnostics(error: unknown): Diagnostics {
11
+ const result: {
12
+ statusCode?: number;
13
+ code?: string;
14
+ requestId?: string;
15
+ type?: string;
16
+ } = {};
17
+ if (!error || typeof error !== "object" || types.isProxy(error))
18
+ return Object.freeze(result);
19
+ for (const key of ["statusCode", "code", "requestId", "type"] as const) {
20
+ const d = Object.getOwnPropertyDescriptor(error, key);
21
+ if (!d || !("value" in d)) continue;
22
+ const value: unknown = d.value;
23
+ if (key === "statusCode") {
24
+ if (
25
+ typeof value === "number" &&
26
+ Number.isSafeInteger(value) &&
27
+ value >= 100 &&
28
+ value <= 599
29
+ )
30
+ result[key] = value;
31
+ continue;
32
+ }
33
+ if (key === "code") {
34
+ if (
35
+ typeof value === "string" &&
36
+ ["ECONNRESET", "EPIPE", "ETIMEDOUT"].includes(value)
37
+ )
38
+ result[key] = value;
39
+ continue;
40
+ }
41
+ if (typeof value === "string" && value.length <= 255)
42
+ try {
43
+ requiredJSONSnapshot(value);
44
+ result[key] = value;
45
+ } catch {
46
+ /* Unsafe details are omitted, not reclassified. */
47
+ }
48
+ }
49
+ return Object.freeze(result);
50
+ }
51
+
52
+ /** The opaque value is not recursively frozen, copied, serialized or reflected. */
53
+ export function opaqueRecord<T extends object>(
54
+ fields: T,
55
+ key: string,
56
+ value: unknown,
57
+ ): Readonly<T> {
58
+ const record = { ...fields };
59
+ Object.defineProperty(record, key, {
60
+ value,
61
+ enumerable: false,
62
+ writable: false,
63
+ configurable: false,
64
+ });
65
+ return Object.freeze(record);
66
+ }
@@ -0,0 +1,50 @@
1
+ /** Fixed internal operation associations. No production producer or class is bound. */
2
+ export const COMPILED_INITIAL_ENTRIES: readonly unknown[] = Object.freeze([]);
3
+ export const COMPILED_RECOVERY_ENTRIES: readonly unknown[] = Object.freeze([]);
4
+ export const COMPILED_PREFLIGHT_ENTRIES: readonly unknown[] = Object.freeze([]);
5
+ export const COMPILED_CONFIGURE_WRITE_ENTRIES: readonly unknown[] =
6
+ Object.freeze([]);
7
+ export const ORIGINAL_ORIGIN_ASSOCIATION: object | null = null;
8
+ export function loadFixedInitialOperation(): unknown {
9
+ throw Error("INITIAL_SOURCE_UNBOUND");
10
+ }
11
+ export function loadFixedExplicitRecoveryOperation(): unknown {
12
+ throw Error("RECOVERY_SOURCE_UNBOUND");
13
+ }
14
+ export function loadOwnedTransportSource(): unknown {
15
+ throw Error("OWNED_TRANSPORT_SOURCE_UNBOUND");
16
+ }
17
+ export function loadOwnedConfigureOperation(): unknown {
18
+ throw Error("CONFIGURE_PREFLIGHT_SOURCE_UNBOUND");
19
+ }
20
+
21
+ export function loadInitialOwnedTransportSource(): unknown {
22
+ throw Error("INITIAL_TRANSPORT_SOURCE_UNBOUND");
23
+ }
24
+ export function loadRecoveryOwnedTransportSource(): unknown {
25
+ throw Error("RECOVERY_TRANSPORT_SOURCE_UNBOUND");
26
+ }
27
+
28
+ export function loadConfigureOwnedReadTransportSource(): unknown {
29
+ throw Error("CONFIGURE_READ_TRANSPORT_SOURCE_UNBOUND");
30
+ }
31
+
32
+ export function loadFixedConfigureWriteOperation(): unknown {
33
+ throw Error("CONFIGURE_WRITE_SOURCE_UNBOUND");
34
+ }
35
+ export function loadFixedConfigureReplayOperation(): unknown {
36
+ throw Error("CONFIGURE_REPLAY_SOURCE_UNBOUND");
37
+ }
38
+ export function loadConfigureWriteTransportSource(): unknown {
39
+ throw Error("CONFIGURE_WRITE_TRANSPORT_SOURCE_UNBOUND");
40
+ }
41
+ export function loadConfigureReplayTransportSource(): unknown {
42
+ throw Error("CONFIGURE_REPLAY_TRANSPORT_SOURCE_UNBOUND");
43
+ }
44
+
45
+ export const COMPILED_OBSERVATION_ENTRIES: readonly unknown[] = Object.freeze(
46
+ [],
47
+ );
48
+ export function loadFixedObservationOperation(): unknown {
49
+ throw Error("OBSERVATION_SOURCE_UNBOUND");
50
+ }
@@ -0,0 +1,116 @@
1
+ import assert from "node:assert/strict";
2
+ import { afterEach, expect, it, vi } from "vitest";
3
+
4
+ afterEach(() => {
5
+ vi.doUnmock("../sourceBindings.js");
6
+ vi.doUnmock("./sourceOperations.js");
7
+ vi.resetModules();
8
+ vi.unstubAllGlobals();
9
+ vi.restoreAllMocks();
10
+ });
11
+
12
+ it("Source invocation acquisition must preserve its actual same-pair GET catch", async () => {
13
+ vi.resetModules();
14
+ const { ownedReadFailureFixture } =
15
+ await import("../test-fixtures/ownedOperations.js");
16
+ const h = await ownedReadFailureFixture();
17
+ const { bindRawAcquisitionFromSource } =
18
+ await import("../acquisition/ownedAcquisition.js");
19
+ h.OWNER.check();
20
+ expect(h.pair.capability.assertVirginAcquisition()).toBe(true);
21
+ const reader = bindRawAcquisitionFromSource(
22
+ h.OWNER,
23
+ h.pair.transport.readTransport,
24
+ );
25
+ const result = await reader.acquire(h.prepared.expected);
26
+ h.OWNER.check();
27
+ expect(result.ok).toBe(false);
28
+ expect(h.http.calls).toEqual([
29
+ { url: h.http.expectedURL, method: "GET", redirect: "error" },
30
+ ]);
31
+ expect(h.pair.transport.postDisposition()).toBe("NOT_STARTED");
32
+ // Intended new-binding RED: existing reader ran its real body and actual stock GET,
33
+ // but its isolated delegate bypassed this pair's real catch capability.
34
+ const record = h.pair.capability.consumeReadCatch();
35
+ expect(record !== null).toBe(true);
36
+ expect(record).toMatchObject({ phase: "read", ordinal: 1 });
37
+ expect(h.pair.capability.consumeReadCatch()).toBe(null);
38
+ });
39
+
40
+ it("fixed actor transport associations require operation, readPlan, delegate and whole C2 before HTTP", async () => {
41
+ const { scenario } = await import("../test-fixtures/attachScenario.js"),
42
+ h = await scenario("G01-scalar");
43
+ try {
44
+ const {
45
+ createInitialOwnedTransportWithAttemptCapability,
46
+ createRecoveryOwnedTransportWithAttemptCapability,
47
+ createOwnedTransportWithAttemptCapability,
48
+ } = await import("./fixedTransport.js");
49
+ const a = createInitialOwnedTransportWithAttemptCapability(),
50
+ b = createRecoveryOwnedTransportWithAttemptCapability(),
51
+ generic = createOwnedTransportWithAttemptCapability(),
52
+ f = h.binding;
53
+ assert.equal(
54
+ a.capability.assertSourceOperationBinding(
55
+ f.opB,
56
+ f.request,
57
+ f.plan,
58
+ f.delegate,
59
+ ),
60
+ false,
61
+ );
62
+ assert.equal(
63
+ b.capability.assertSourceOperationBinding(
64
+ f.opA,
65
+ f.request,
66
+ f.plan,
67
+ f.delegate,
68
+ ),
69
+ false,
70
+ );
71
+ assert.equal(
72
+ a.capability.assertSourceOperationBinding(
73
+ f.opA,
74
+ f.request,
75
+ [...f.plan],
76
+ f.delegate,
77
+ ),
78
+ false,
79
+ );
80
+ assert.equal(
81
+ a.capability.assertSourceOperationBinding(f.opA, f.request, f.plan, {}),
82
+ false,
83
+ );
84
+ assert.equal(
85
+ a.capability.assertSourceOperationBinding(
86
+ f.opA,
87
+ { ...f.request, firstDispatchedAt: f.request.firstDispatchedAt + 1 },
88
+ f.plan,
89
+ f.delegate,
90
+ ),
91
+ false,
92
+ );
93
+ assert.equal(
94
+ generic.capability.assertSourceOperationBinding(
95
+ f.opA,
96
+ f.request,
97
+ f.plan,
98
+ f.delegate,
99
+ ),
100
+ false,
101
+ );
102
+ assert.equal(
103
+ a.capability.assertSourceOperationBinding(
104
+ f.opA,
105
+ f.request,
106
+ f.plan,
107
+ f.delegate,
108
+ ),
109
+ true,
110
+ );
111
+ assert.equal(h.effectCounts().GET, 0);
112
+ assert.equal(h.effectCounts().POST, 0);
113
+ } finally {
114
+ await h.cleanup();
115
+ }
116
+ });
@@ -0,0 +1,223 @@
1
+ import { types } from "node:util";
2
+ import { requiredJSONSnapshot } from "../material/requiredJson.js";
3
+ import type { prepareRenewalScheduleAttachmentV2 } from "../../../renewalV2/index.js";
4
+
5
+ export type AttachRequest = Awaited<
6
+ ReturnType<typeof prepareRenewalScheduleAttachmentV2>
7
+ >;
8
+ export type ReadResource = "subscription" | "price" | "customer" | "coupon";
9
+ export type ReadOptions = Readonly<{
10
+ apiVersion: string;
11
+ maxNetworkRetries: 0;
12
+ }>;
13
+ export type ReadRow = Readonly<{
14
+ resource: ReadResource;
15
+ ordinal: number;
16
+ method: "GET";
17
+ path: string;
18
+ body: undefined;
19
+ options: ReadOptions;
20
+ id: string;
21
+ }>;
22
+ export type SourceMethod = (...args: unknown[]) => unknown;
23
+ export const stop = (): never => {
24
+ throw Error("OWNED_TRANSPORT_STOP");
25
+ };
26
+ export function need(value: unknown): asserts value {
27
+ if (!value) stop();
28
+ }
29
+
30
+ export function closed(
31
+ raw: unknown,
32
+ keys: readonly string[],
33
+ ): Record<string, unknown> {
34
+ need(
35
+ raw &&
36
+ typeof raw === "object" &&
37
+ !types.isProxy(raw) &&
38
+ !Array.isArray(raw),
39
+ );
40
+ const prototype = Object.getPrototypeOf(raw);
41
+ need(prototype === Object.prototype || prototype === null);
42
+ const names = Reflect.ownKeys(raw);
43
+ need(
44
+ names.length === keys.length && keys.every((key) => names.includes(key)),
45
+ );
46
+ return Object.fromEntries(
47
+ names.map((key) => {
48
+ need(typeof key === "string");
49
+ const d = Object.getOwnPropertyDescriptor(raw, key);
50
+ need(d && d.enumerable && "value" in d);
51
+ return [key, d.value];
52
+ }),
53
+ );
54
+ }
55
+
56
+ export function freezeJSON<T>(value: T): T {
57
+ if (value && typeof value === "object") {
58
+ for (const child of Object.values(value)) freezeJSON(child);
59
+ Object.freeze(value);
60
+ }
61
+ return value;
62
+ }
63
+
64
+ const API = "2026-09-30.endive";
65
+ const resourceID = (value: unknown, prefix: string): value is string =>
66
+ typeof value === "string" &&
67
+ new RegExp("^" + prefix + "_[A-Za-z0-9_]+$").test(value) &&
68
+ value.length <= 255;
69
+ const query = String(
70
+ new URLSearchParams(
71
+ ["discounts", "items.data.discounts", "items.data.price"].map((v, i) => [
72
+ "expand[" + i + "]",
73
+ v,
74
+ ]),
75
+ ),
76
+ );
77
+
78
+ /** Validates DATA only; never selects Owner, delegate, invocation or capability. */
79
+ export function captureRequestAndReads(
80
+ requestRaw: unknown,
81
+ readPlanRaw: unknown,
82
+ ) {
83
+ const r = closed(requestRaw, [
84
+ "version",
85
+ "stage",
86
+ "scope",
87
+ "apiVersion",
88
+ "method",
89
+ "path",
90
+ "payload",
91
+ "key",
92
+ "firstDispatchedAt",
93
+ "logicalBinding",
94
+ "requestIdentity",
95
+ ]);
96
+ const payload = closed(r.payload, ["from_subscription"]),
97
+ identity = closed(r.requestIdentity, ["key", "binding"]);
98
+ need(
99
+ r.version === 2 &&
100
+ r.stage === "attach" &&
101
+ r.scope === "platform" &&
102
+ r.apiVersion === API &&
103
+ r.method === "POST" &&
104
+ r.path === "/v1/subscription_schedules" &&
105
+ resourceID(payload.from_subscription, "sub"),
106
+ );
107
+ need(
108
+ typeof r.key === "string" &&
109
+ r.key.length > 0 &&
110
+ r.key.length <= 255 &&
111
+ identity.key === r.key &&
112
+ typeof r.firstDispatchedAt === "number" &&
113
+ Number.isSafeInteger(r.firstDispatchedAt) &&
114
+ r.firstDispatchedAt >= 0,
115
+ );
116
+ requiredJSONSnapshot(r.key);
117
+ need(
118
+ typeof r.logicalBinding === "string" &&
119
+ /^renewal:v2:sha256:[0-9a-f]{64}$/.test(r.logicalBinding) &&
120
+ typeof identity.binding === "string" &&
121
+ /^renewal-attach:v2:sha256:[0-9a-f]{64}$/.test(identity.binding),
122
+ );
123
+ // Every field in this closed C2 view was checked above; this is not proof admission.
124
+ const request = Object.freeze({
125
+ ...r,
126
+ payload: freezeJSON(requiredJSONSnapshot(payload)),
127
+ requestIdentity: Object.freeze(identity),
128
+ }) as AttachRequest;
129
+ need(
130
+ Array.isArray(readPlanRaw) &&
131
+ !types.isProxy(readPlanRaw) &&
132
+ readPlanRaw.length >= 3 &&
133
+ readPlanRaw.length <= 43,
134
+ );
135
+ const rawPlan: readonly unknown[] = readPlanRaw,
136
+ plan: ReadRow[] = [],
137
+ ids = new Set<string>();
138
+ for (let i = 0; i < rawPlan.length; i++) {
139
+ const row = closed(rawPlan[i], [
140
+ "resource",
141
+ "ordinal",
142
+ "method",
143
+ "path",
144
+ "body",
145
+ "options",
146
+ ]),
147
+ options = closed(row.options, ["apiVersion", "maxNetworkRetries"]);
148
+ need(
149
+ row.ordinal === i + 1 &&
150
+ row.method === "GET" &&
151
+ typeof row.path === "string" &&
152
+ row.body === undefined &&
153
+ options.apiVersion === API &&
154
+ options.maxNetworkRetries === 0,
155
+ );
156
+ let id: string;
157
+ const resource: ReadResource =
158
+ i === 0
159
+ ? "subscription"
160
+ : i === 1
161
+ ? "price"
162
+ : i === 2
163
+ ? "customer"
164
+ : "coupon";
165
+ if (i === 0) {
166
+ need(
167
+ row.resource === "subscription" &&
168
+ row.path ===
169
+ "/v1/subscriptions/" + payload.from_subscription + "?" + query,
170
+ );
171
+ id = payload.from_subscription;
172
+ } else if (i === 1) {
173
+ need(row.resource === "price" && row.path.startsWith("/v1/prices/"));
174
+ id = row.path.slice(11);
175
+ need(resourceID(id, "price"));
176
+ } else if (i === 2) {
177
+ need(
178
+ row.resource === "customer" && row.path.startsWith("/v1/customers/"),
179
+ );
180
+ id = row.path.slice(14);
181
+ need(resourceID(id, "cus"));
182
+ } else {
183
+ need(row.resource === "coupon" && row.path.startsWith("/v1/coupons/"));
184
+ const encoded = row.path.slice(12);
185
+ try {
186
+ id = decodeURIComponent(encoded);
187
+ } catch {
188
+ return stop();
189
+ }
190
+ need(
191
+ id.length > 0 &&
192
+ id.length <= 255 &&
193
+ /\S/.test(id) &&
194
+ id !== "." &&
195
+ id !== ".." &&
196
+ encodeURIComponent(id) === encoded &&
197
+ !ids.has(id),
198
+ );
199
+ ids.add(id);
200
+ }
201
+ plan.push(
202
+ Object.freeze({
203
+ ...row,
204
+ resource,
205
+ ordinal: i + 1,
206
+ method: "GET",
207
+ path: row.path,
208
+ body: undefined,
209
+ id,
210
+ options: Object.freeze({ apiVersion: API, maxNetworkRetries: 0 }),
211
+ }),
212
+ );
213
+ }
214
+ return Object.freeze({ request, plan: Object.freeze(plan) });
215
+ }
216
+
217
+ /** Actor continuation surface only; this type grants no Source capability. */
218
+ export type FailureControl = {
219
+ forward(error: unknown): object | null;
220
+ consume(error: unknown): Error | null;
221
+ consumePost(error: unknown): Error | null;
222
+ takePostQuarantine(): object | null;
223
+ };