@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,148 @@
1
+ import assert from "node:assert/strict";
2
+ import { it, vi } from "vitest";
3
+ import { configureWriteFixture } from "../test-fixtures/configureWriteOperation.js";
4
+ import { assertConfigureACK } from "../test-fixtures/configureWriteAssertions.js";
5
+ import { writeCases } from "../test-fixtures/configureWriteDeclarations.js";
6
+
7
+ for (const name of writeCases.ownership.filter((value) => value !== "empty"))
8
+ it(
9
+ "bounded configure writer closes ownership frontier: " + name,
10
+ async () => {
11
+ const h = await configureWriteFixture(name);
12
+ try {
13
+ if (name === "capture-arity")
14
+ assert.throws(() => Reflect.apply(h.captureWriter, undefined, [{}]), {
15
+ message: "CONFIGURE_WRITE_STOP",
16
+ });
17
+ else if (name === "invoke-arity")
18
+ await assert.rejects(
19
+ Reflect.apply(h.captureWriter().invoke, undefined, [{}]),
20
+ { message: "CONFIGURE_WRITE_STOP" },
21
+ );
22
+ else if (name === "consumed") {
23
+ const handle = h.captureWriter();
24
+ assertConfigureACK(h, await handle.invoke());
25
+ await assert.rejects(handle.invoke(), {
26
+ message: "CONFIGURE_WRITE_STOP",
27
+ });
28
+ } else if (name === "original-failure") {
29
+ const result = await h.captureWriter().invoke();
30
+ assert.equal(result, h.writeState.requests[0]);
31
+ assert.notEqual(
32
+ (result as { status?: unknown }).status,
33
+ "projected_configure_request",
34
+ );
35
+ } else
36
+ await assert.rejects(async () => h.captureWriter().invoke(), {
37
+ message: "CONFIGURE_WRITE_STOP",
38
+ });
39
+ if (name === "consumed") {
40
+ assert.equal(
41
+ h.writeState.calls.filter((row) => row.method === "POST").length,
42
+ 1,
43
+ );
44
+ return;
45
+ }
46
+ assert.equal(h.writeState.calls.length, 0);
47
+ assert.equal(h.writeState.records.length, 0);
48
+ assert.equal(h.writeState.traps, 0);
49
+ if (name === "original-failure") {
50
+ assert.equal(h.writeState.requests.length, 1);
51
+ assert.equal(h.writeState.pairLoads, 0);
52
+ assert.equal(h.writeState.coverage, 0);
53
+ }
54
+ } finally {
55
+ await h.cleanup();
56
+ }
57
+ },
58
+ );
59
+
60
+ it("normal writer EMPTY returns refusal before Source, Owner, clock and API effects", async () => {
61
+ vi.resetModules();
62
+ const counts = {
63
+ Source: 0,
64
+ Owner: 0,
65
+ check: 0,
66
+ sample: 0,
67
+ client: 0,
68
+ api: 0,
69
+ };
70
+ const effect = (key: keyof typeof counts): never => {
71
+ counts[key]++;
72
+ throw Error("EMPTY_EFFECT_" + key);
73
+ };
74
+ vi.doMock("../originalOwner.js", () => ({
75
+ OWNER: new Proxy(
76
+ Object.freeze({
77
+ check: () => effect("check"),
78
+ sample: () => effect("sample"),
79
+ }),
80
+ {
81
+ get(target, key, receiver) {
82
+ counts.Owner++;
83
+ return Reflect.get(target, key, receiver);
84
+ },
85
+ },
86
+ ),
87
+ }));
88
+ vi.doMock("../sourceBindings.js", () => ({
89
+ loadOwnedOriginalSource: () => effect("Source"),
90
+ loadFixedStockClient: () => effect("client"),
91
+ }));
92
+ vi.doMock("../operations/sourceOperations.js", async () => {
93
+ const actual = await vi.importActual<
94
+ typeof import("../operations/sourceOperations.js")
95
+ >("../operations/sourceOperations.js");
96
+ assert.deepEqual(actual.COMPILED_CONFIGURE_WRITE_ENTRIES, []);
97
+ return {
98
+ ...actual,
99
+ loadFixedConfigureWriteOperation: () => effect("Source"),
100
+ loadConfigureWriteTransportSource: () => effect("Source"),
101
+ loadFixedConfigureReplayOperation: () => effect("Source"),
102
+ loadConfigureReplayTransportSource: () => effect("Source"),
103
+ };
104
+ });
105
+ vi.doMock("../../../renewalV2/index.js", async () => {
106
+ const actual = await vi.importActual<
107
+ typeof import("../../../renewalV2/index.js")
108
+ >("../../../renewalV2/index.js");
109
+ return {
110
+ ...actual,
111
+ projectRenewalConfigurationV2: () => effect("api"),
112
+ constructRenewalScheduleAttachmentReceiptV2: () => effect("api"),
113
+ constructRenewalConfigurationReceiptV2: () => effect("api"),
114
+ };
115
+ });
116
+ try {
117
+ const actual = await import("./actor.js");
118
+ const expected = {
119
+ status: "not_dispatched",
120
+ reason: "no_qualified_configure_class",
121
+ operationalAuthority: false,
122
+ };
123
+ assert.deepEqual(await actual.captureOwnedConfigureV2().invoke(), expected);
124
+ assert.deepEqual(
125
+ await actual.captureOwnedConfigureReplayV2().invoke(),
126
+ expected,
127
+ );
128
+ assert.deepEqual(counts, {
129
+ Source: 0,
130
+ Owner: 0,
131
+ check: 0,
132
+ sample: 0,
133
+ client: 0,
134
+ api: 0,
135
+ });
136
+ } finally {
137
+ for (const path of [
138
+ "../originalOwner.js",
139
+ "../sourceBindings.js",
140
+ "../operations/sourceOperations.js",
141
+ "../../../renewalV2/index.js",
142
+ ])
143
+ vi.doUnmock(path);
144
+ vi.restoreAllMocks();
145
+ vi.unstubAllGlobals();
146
+ vi.resetModules();
147
+ }
148
+ });
@@ -0,0 +1,173 @@
1
+ import assert from "node:assert/strict";
2
+ import { it } from "vitest";
3
+ import { configureWriteFixture } from "../test-fixtures/configureWriteOperation.js";
4
+ import { writeCases } from "../test-fixtures/configureWriteDeclarations.js";
5
+ import {
6
+ assertProviderFailure,
7
+ assertConfigureACK,
8
+ } from "../test-fixtures/configureWriteAssertions.js";
9
+
10
+ for (const name of writeCases.replay)
11
+ it(
12
+ "bounded configure writer explicit original-key replay: " + name,
13
+ async () => {
14
+ const h = await configureWriteFixture(name);
15
+ let initial: Promise<unknown> | undefined;
16
+ try {
17
+ assert.equal(h.replayDeclaration.persistentCustody, false);
18
+ assert.equal(h.replayDeclaration.permitsJSONRehydration, false);
19
+ if (name === "not-posted-prior") {
20
+ assert.deepEqual(await h.captureReplayB().invoke(), {
21
+ status: "not_dispatched",
22
+ reason: "prior_attempt_unavailable",
23
+ operationalAuthority: false,
24
+ });
25
+ assert.equal(h.replayStates.B.calls.length, 0);
26
+ return;
27
+ }
28
+ const firstHandle = h.captureWriter();
29
+ const firstPending = firstHandle.invoke();
30
+ initial = firstPending;
31
+ const firstObserved = firstPending.then(
32
+ (value: unknown) => ({ ok: true as const, value }),
33
+ (error: unknown) => ({ ok: false as const, error }),
34
+ );
35
+ if (name === "pending-prior") {
36
+ await h.writeGates.entered("post", firstPending);
37
+ assert.deepEqual(await h.captureReplayB().invoke(), {
38
+ status: "not_dispatched",
39
+ reason: "prior_attempt_not_replayable",
40
+ operationalAuthority: false,
41
+ });
42
+ assert.equal(h.replayStates.B.calls.length, 0);
43
+ h.writeGates.release("post");
44
+ const settled = await firstObserved;
45
+ assert.equal(settled.ok, true);
46
+ return;
47
+ }
48
+ const first = await firstObserved;
49
+ if (name === "acknowledged-prior") {
50
+ assert.equal(first.ok, true);
51
+ if (first.ok) assertConfigureACK(h, first.value);
52
+ } else {
53
+ assert.equal(first.ok, false);
54
+ if (!first.ok) assertProviderFailure(h, first.error, "post");
55
+ }
56
+ const firstPosts = h.writeState.calls.filter(
57
+ (row) => row.method === "POST",
58
+ );
59
+ assert.equal(firstPosts.length, 1);
60
+ await assert.rejects(firstHandle.invoke(), {
61
+ message: "CONFIGURE_WRITE_STOP",
62
+ });
63
+ assert.equal(
64
+ h.writeState.calls.filter((row) => row.method === "POST").length,
65
+ 1,
66
+ );
67
+ if (name === "expired-owner") h.OWNER.retire();
68
+ const refusal = [
69
+ "acknowledged-prior",
70
+ "foreign-prior",
71
+ "cloned-prior",
72
+ "already-applied",
73
+ "baseline-drift",
74
+ "expired-owner",
75
+ ].includes(name);
76
+ const B = h.captureReplayB();
77
+ if (refusal) {
78
+ if (name === "expired-owner")
79
+ await assert.rejects(B.invoke(), {
80
+ message: "CONFIGURE_WRITE_STOP",
81
+ });
82
+ else {
83
+ const reason =
84
+ name === "foreign-prior" || name === "cloned-prior"
85
+ ? "prior_attempt_unavailable"
86
+ : name === "already-applied" || name === "baseline-drift"
87
+ ? "preconfigure_baseline_changed"
88
+ : "prior_attempt_not_replayable";
89
+ assert.deepEqual(await B.invoke(), {
90
+ status: "not_dispatched",
91
+ reason,
92
+ operationalAuthority: false,
93
+ });
94
+ }
95
+ assert.equal(
96
+ h.replayStates.B.calls.filter((row) => row.method === "POST")
97
+ .length,
98
+ 0,
99
+ );
100
+ if (name === "already-applied" || name === "baseline-drift") {
101
+ assert.equal(
102
+ h.replayStates.B.calls.length,
103
+ 4 + h.write.currentBundle.couponReads.length,
104
+ );
105
+ assert.equal(h.replayStates.B.requests.length, 1);
106
+ } else {
107
+ assert.equal(h.replayStates.B.calls.length, 0);
108
+ assert.equal(h.replayStates.B.pairLoads, 0);
109
+ }
110
+ return;
111
+ }
112
+ const bView = { ...h, writeState: h.replayStates.B };
113
+ if (name === "unknown-replay-repeat") {
114
+ const error = await B.invoke().then(
115
+ () => assert.fail("EXPECTED_ACTUAL_B_UNKNOWN"),
116
+ (error: unknown) => error,
117
+ );
118
+ assertProviderFailure(bView, error, "post");
119
+ } else assertConfigureACK(bView, await B.invoke());
120
+ const bPosts = h.replayStates.B.calls.filter(
121
+ (row) => row.method === "POST",
122
+ );
123
+ assert.equal(bPosts.length, 1);
124
+ assert.deepEqual(bPosts[0], firstPosts[0]);
125
+ if (name === "unknown-replay-repeat") {
126
+ const C = h.captureReplayC();
127
+ assertConfigureACK(
128
+ { ...h, writeState: h.replayStates.C },
129
+ await C.invoke(),
130
+ );
131
+ const cPosts = h.replayStates.C.calls.filter(
132
+ (row) => row.method === "POST",
133
+ );
134
+ assert.equal(cPosts.length, 1);
135
+ assert.deepEqual(cPosts[0], firstPosts[0]);
136
+ }
137
+ if (name === "ack-closes-ancestor") {
138
+ assert.deepEqual(await h.captureReplayC().invoke(), {
139
+ status: "not_dispatched",
140
+ reason: "prior_attempt_not_replayable",
141
+ operationalAuthority: false,
142
+ });
143
+ assert.equal(h.replayStates.C.calls.length, 0);
144
+ assert.equal(h.replayStates.C.pairLoads, 0);
145
+ assert.equal(h.OWNER.check().retired, false);
146
+ }
147
+ assert.equal(h.replayDeclaration.originalRequest, h.projected);
148
+ assert.equal(h.replayDeclaration.permitsAutomaticRetry, false);
149
+ for (const stage of [
150
+ h.writeState,
151
+ h.replayStates.B,
152
+ h.replayStates.C,
153
+ ]) {
154
+ assert(
155
+ stage.calls.filter((row) => row.method === "POST").length <= 1,
156
+ );
157
+ for (const post of stage.calls.filter(
158
+ (row) => row.method === "POST",
159
+ )) {
160
+ assert.equal(post.path, h.projected.path);
161
+ assert.equal(post.key, h.projected.key);
162
+ }
163
+ }
164
+ for (const s of [h.writeState, h.replayStates.B, h.replayStates.C])
165
+ for (const request of s.requests)
166
+ assert.deepEqual(request, h.projected);
167
+ } finally {
168
+ h.writeGates.release("post");
169
+ if (initial) await initial.catch(() => {});
170
+ await h.cleanup();
171
+ }
172
+ },
173
+ );
@@ -0,0 +1,13 @@
1
+ /** Scalar retention DATA is not an Owner, origin, Source or replay capability. */
2
+ export function withinConfigureRetention(
3
+ nowSeconds: number,
4
+ firstDispatchedAt: number,
5
+ ): boolean {
6
+ return (
7
+ Number.isSafeInteger(nowSeconds) &&
8
+ Number.isSafeInteger(firstDispatchedAt) &&
9
+ firstDispatchedAt >= 0 &&
10
+ nowSeconds >= firstDispatchedAt &&
11
+ nowSeconds - firstDispatchedAt < 86400
12
+ );
13
+ }
@@ -0,0 +1,312 @@
1
+ import { types } from "node:util";
2
+ import { requiredJSONSnapshot } from "../material/requiredJson.js";
3
+ import { resourceId } from "../../../renewalAggregate/shared.js";
4
+ import { closed } from "../operations/types.js";
5
+ import type { PreflightRecord } from "../preflight/grammar.js";
6
+ import type { ProjectedRenewalConfigurationV2 } from "../../../renewalV2/index.js";
7
+
8
+ export const API = "2026-09-30.endive";
9
+ export const stop = (): never => {
10
+ throw Error("CONFIGURE_WRITE_STOP");
11
+ };
12
+ export function need(value: unknown): asserts value {
13
+ if (!value) stop();
14
+ }
15
+ export type SourceMethod = (...args: unknown[]) => unknown;
16
+ export function ownMethod(raw: unknown, key: string): SourceMethod {
17
+ need(raw !== null && typeof raw === "object" && !types.isProxy(raw));
18
+ const d = Object.getOwnPropertyDescriptor(raw, key);
19
+ need(
20
+ d &&
21
+ d.enumerable &&
22
+ "value" in d &&
23
+ typeof d.value === "function" &&
24
+ !types.isProxy(d.value),
25
+ );
26
+ return d.value as SourceMethod;
27
+ }
28
+ type Resource = "subscription" | "price" | "customer" | "coupon" | "schedule";
29
+ export type Row = Readonly<{
30
+ resource: Resource;
31
+ ordinal: number;
32
+ method: "GET";
33
+ path: string;
34
+ body: undefined;
35
+ id: string;
36
+ options: Readonly<{ apiVersion: typeof API; maxNetworkRetries: 0 }>;
37
+ }>;
38
+ const query =
39
+ "?" +
40
+ new URLSearchParams(
41
+ ["discounts", "items.data.discounts", "items.data.price"].map(
42
+ (value, i) => ["expand[" + i + "]", value],
43
+ ),
44
+ );
45
+ const plurals = {
46
+ subscription: "subscriptions",
47
+ price: "prices",
48
+ customer: "customers",
49
+ coupon: "coupons",
50
+ schedule: "subscription_schedules",
51
+ };
52
+ const prefixes = {
53
+ subscription: "sub",
54
+ price: "price",
55
+ customer: "cus",
56
+ schedule: "sub_sched",
57
+ };
58
+ function idFor(resource: Resource, path: string): string {
59
+ const root = "/v1/" + plurals[resource] + "/";
60
+ need(path.startsWith(root));
61
+ if (resource === "subscription") need(path.endsWith(query));
62
+ const encoded = path.slice(
63
+ root.length,
64
+ resource === "subscription" ? -query.length : undefined,
65
+ );
66
+ let id: string;
67
+ try {
68
+ id = decodeURIComponent(encoded);
69
+ } catch {
70
+ return stop();
71
+ }
72
+ need(encodeURIComponent(id) === encoded);
73
+ if (resource === "coupon")
74
+ need(
75
+ id.length >= 1 &&
76
+ id.length <= 255 &&
77
+ /\S/.test(id) &&
78
+ id !== "." &&
79
+ id !== "..",
80
+ );
81
+ else need(resourceId(prefixes[resource]).safeParse(id).success);
82
+ return id;
83
+ }
84
+ /** Stateless closed fixed44 profile; explicit undefined bodies are never JSON encoded. */
85
+ export function capturePlan(raw: unknown): readonly Row[] {
86
+ need(
87
+ !types.isProxy(raw) &&
88
+ Array.isArray(raw) &&
89
+ Object.getPrototypeOf(raw) === Array.prototype,
90
+ );
91
+ const length = Object.getOwnPropertyDescriptor(raw, "length"),
92
+ count: unknown = length?.value;
93
+ need(
94
+ length &&
95
+ "value" in length &&
96
+ typeof count === "number" &&
97
+ Number.isSafeInteger(count) &&
98
+ count >= 4 &&
99
+ count <= 44,
100
+ );
101
+ const keys = Reflect.ownKeys(raw);
102
+ need(keys.length === count + 1 && keys.every((k) => typeof k === "string"));
103
+ const result: Row[] = [],
104
+ coupons = new Set<string>();
105
+ for (let i = 0; i < count; i++) {
106
+ const d = Object.getOwnPropertyDescriptor(raw, String(i));
107
+ need(d && d.enumerable && "value" in d && !types.isProxy(d.value));
108
+ const row = closed(d.value, [
109
+ "resource",
110
+ "ordinal",
111
+ "method",
112
+ "path",
113
+ "body",
114
+ "options",
115
+ ]);
116
+ need(!types.isProxy(row.options));
117
+ const options = closed(row.options, ["apiVersion", "maxNetworkRetries"]);
118
+ const resource: Resource =
119
+ i === 0
120
+ ? "subscription"
121
+ : i === 1
122
+ ? "price"
123
+ : i === 2
124
+ ? "customer"
125
+ : i === count - 1
126
+ ? "schedule"
127
+ : "coupon";
128
+ need(
129
+ row.resource === resource &&
130
+ row.ordinal === i + 1 &&
131
+ row.method === "GET" &&
132
+ typeof row.path === "string" &&
133
+ row.body === undefined &&
134
+ options.apiVersion === API &&
135
+ options.maxNetworkRetries === 0,
136
+ );
137
+ const id = idFor(resource, row.path);
138
+ requiredJSONSnapshot(row.path);
139
+ if (resource === "coupon") {
140
+ need(!coupons.has(id));
141
+ coupons.add(id);
142
+ }
143
+ result.push(
144
+ Object.freeze({
145
+ resource,
146
+ ordinal: i + 1,
147
+ method: "GET",
148
+ path: row.path,
149
+ body: undefined,
150
+ id,
151
+ options: Object.freeze({ apiVersion: API, maxNetworkRetries: 0 }),
152
+ }),
153
+ );
154
+ }
155
+ need(coupons.size <= 40);
156
+ return Object.freeze(result);
157
+ }
158
+ export function samePlan(a: readonly Row[], b: readonly Row[]) {
159
+ return (
160
+ a.length === b.length &&
161
+ a.every((r, i) => {
162
+ const s = b[i];
163
+ return (
164
+ r.resource === s.resource &&
165
+ r.ordinal === s.ordinal &&
166
+ r.method === s.method &&
167
+ r.path === s.path &&
168
+ r.body === s.body &&
169
+ r.id === s.id &&
170
+ r.options.apiVersion === s.options.apiVersion &&
171
+ r.options.maxNetworkRetries === s.options.maxNetworkRetries
172
+ );
173
+ })
174
+ );
175
+ }
176
+ export function expectedPlan(record: PreflightRecord) {
177
+ const e = record.configuration.preparation.expected,
178
+ customer = record.originalBundle.wireBillingCustomer.id;
179
+ need(typeof customer === "string");
180
+ const paths = [
181
+ "/v1/subscriptions/" + encodeURIComponent(e.subscriptionId) + query,
182
+ "/v1/prices/" + encodeURIComponent(e.targetPriceId),
183
+ "/v1/customers/" + encodeURIComponent(customer),
184
+ ...record.originalBundle.couponReads.map((row) => {
185
+ need(typeof row.couponId === "string");
186
+ return "/v1/coupons/" + encodeURIComponent(row.couponId);
187
+ }),
188
+ "/v1/subscription_schedules/" +
189
+ encodeURIComponent(record.attachReceipt.scheduleId),
190
+ ];
191
+ return capturePlan(
192
+ paths.map((path, i) => ({
193
+ resource:
194
+ i === 0
195
+ ? "subscription"
196
+ : i === 1
197
+ ? "price"
198
+ : i === 2
199
+ ? "customer"
200
+ : i === paths.length - 1
201
+ ? "schedule"
202
+ : "coupon",
203
+ ordinal: i + 1,
204
+ method: "GET",
205
+ path,
206
+ body: undefined,
207
+ options: { apiVersion: API, maxNetworkRetries: 0 },
208
+ })),
209
+ );
210
+ }
211
+ export function assertRequest(
212
+ raw: unknown,
213
+ ): asserts raw is ProjectedRenewalConfigurationV2 {
214
+ need(!types.isProxy(raw));
215
+ const r = closed(raw, [
216
+ "version",
217
+ "stage",
218
+ "scope",
219
+ "apiVersion",
220
+ "logicalBinding",
221
+ "scheduleId",
222
+ "method",
223
+ "path",
224
+ "key",
225
+ "payload",
226
+ "firstDispatchedAt",
227
+ "attachReceiptBinding",
228
+ "baselineBinding",
229
+ "defaultSettingsBinding",
230
+ "status",
231
+ "providerQualification",
232
+ "profile",
233
+ "requestIdentity",
234
+ ]);
235
+ need(
236
+ r.version === 2 &&
237
+ r.stage === "configure" &&
238
+ r.scope === "platform" &&
239
+ r.apiVersion === API &&
240
+ r.method === "POST" &&
241
+ r.status === "projected_configure_request" &&
242
+ r.providerQualification === "required",
243
+ );
244
+ need(
245
+ typeof r.scheduleId === "string" &&
246
+ resourceId("sub_sched").safeParse(r.scheduleId).success &&
247
+ r.path === "/v1/subscription_schedules/" + r.scheduleId,
248
+ );
249
+ need(
250
+ typeof r.key === "string" &&
251
+ r.key.length >= 1 &&
252
+ r.key.length <= 255 &&
253
+ typeof r.firstDispatchedAt === "number" &&
254
+ Number.isSafeInteger(r.firstDispatchedAt) &&
255
+ r.firstDispatchedAt >= 0,
256
+ );
257
+ need(!types.isProxy(r.profile) && !types.isProxy(r.requestIdentity));
258
+ const p = closed(r.profile, [
259
+ "apiVersion",
260
+ "billingMode",
261
+ "cadence",
262
+ "anchor",
263
+ ]),
264
+ identity = closed(r.requestIdentity, ["key", "binding"]);
265
+ need(
266
+ p.apiVersion === API &&
267
+ (p.billingMode === "classic" || p.billingMode === "flexible") &&
268
+ (p.cadence === "same" || p.cadence === "changed") &&
269
+ (p.anchor === "ordinary" || p.anchor === "calendar_edge") &&
270
+ identity.key === r.key,
271
+ );
272
+ need(!types.isProxy(r.payload));
273
+ const payload = closed(r.payload, [
274
+ "end_behavior",
275
+ "proration_behavior",
276
+ "phases",
277
+ ]);
278
+ need(
279
+ payload.end_behavior === "release" &&
280
+ payload.proration_behavior === "none" &&
281
+ !types.isProxy(payload.phases) &&
282
+ Array.isArray(payload.phases) &&
283
+ payload.phases.length === 2,
284
+ );
285
+ requiredJSONSnapshot({ key: r.key, payload: r.payload, profile: p });
286
+ }
287
+ export function seven(
288
+ request: ProjectedRenewalConfigurationV2,
289
+ ): Readonly<
290
+ Pick<
291
+ ProjectedRenewalConfigurationV2,
292
+ | "scope"
293
+ | "apiVersion"
294
+ | "method"
295
+ | "path"
296
+ | "payload"
297
+ | "key"
298
+ | "firstDispatchedAt"
299
+ >
300
+ > {
301
+ const { scope, apiVersion, method, path, payload, key, firstDispatchedAt } =
302
+ request;
303
+ return Object.freeze({
304
+ scope,
305
+ apiVersion,
306
+ method,
307
+ path,
308
+ payload,
309
+ key,
310
+ firstDispatchedAt,
311
+ });
312
+ }