@fantastic.dev/better-stripe 0.90.0 → 0.92.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 (239) hide show
  1. package/CHANGELOG.md +12 -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 +14 -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 +444 -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/ownedContinuation.d.ts +3 -0
  29. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts.map +1 -0
  30. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js +61 -0
  31. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js.map +1 -0
  32. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
  33. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
  34. package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
  35. package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
  36. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
  37. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
  38. package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
  39. package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
  40. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
  41. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
  42. package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
  43. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
  44. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
  45. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
  46. package/dist/client/billing/renewalAttach/internal/observation/actor.js +383 -0
  47. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
  48. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
  49. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
  50. package/dist/client/billing/renewalAttach/internal/observation/capture.js +216 -0
  51. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
  52. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts +5 -0
  53. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts.map +1 -0
  54. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js +11 -0
  55. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js.map +1 -0
  56. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
  57. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
  58. package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
  59. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
  60. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
  61. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
  62. package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
  63. package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
  64. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +84 -0
  65. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
  66. package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
  67. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
  68. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
  69. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
  70. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
  71. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
  72. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
  73. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
  74. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
  75. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
  76. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
  77. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
  78. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
  79. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
  80. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
  81. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
  82. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
  83. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
  84. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
  85. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
  86. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
  87. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
  88. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
  89. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
  90. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
  91. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
  92. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
  93. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
  94. package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
  95. package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
  96. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
  97. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
  98. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
  99. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
  100. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
  101. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
  102. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
  103. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
  104. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
  105. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
  106. package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
  107. package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
  108. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
  109. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
  110. package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
  111. package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
  112. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
  113. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
  114. package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
  115. package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
  116. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
  117. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
  118. package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
  119. package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
  120. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
  121. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
  122. package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
  123. package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
  124. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
  125. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
  126. package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
  127. package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
  128. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
  129. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
  130. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
  131. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
  132. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
  133. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
  134. package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
  135. package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
  136. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  137. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
  138. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  139. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  140. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  141. package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
  142. package/docs/renewal-context-reads.md +26 -8
  143. package/docs/renewal-material-observation.md +58 -0
  144. package/docs/renewal-phase-assembly.md +68 -0
  145. package/docs/renewal-raw-acquisition.md +19 -5
  146. package/package.json +1 -1
  147. package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
  148. package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
  149. package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
  150. package/src/client/billing/renewalAttach/internal/configure/actor.ts +586 -0
  151. package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
  152. package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
  153. package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
  154. package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
  155. package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
  156. package/src/client/billing/renewalAttach/internal/configure/ownedContinuation.ts +56 -0
  157. package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
  158. package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
  159. package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
  160. package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
  161. package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
  162. package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
  163. package/src/client/billing/renewalAttach/internal/observation/actor.ts +487 -0
  164. package/src/client/billing/renewalAttach/internal/observation/capture.ts +251 -0
  165. package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -0
  166. package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
  167. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +36 -0
  168. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +48 -0
  169. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +44 -0
  170. package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +34 -0
  171. package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
  172. package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
  173. package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
  174. package/src/client/billing/renewalAttach/internal/observation/types.ts +107 -0
  175. package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
  176. package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
  177. package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
  178. package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
  179. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
  180. package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
  181. package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
  182. package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
  183. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
  184. package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
  185. package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
  186. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
  187. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
  188. package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
  189. package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
  190. package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
  191. package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
  192. package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
  193. package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
  194. package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
  195. package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
  196. package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
  197. package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
  198. package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
  199. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
  200. package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
  201. package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
  202. package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
  203. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
  204. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
  205. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
  206. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
  207. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
  208. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
  209. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
  210. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
  211. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
  212. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
  213. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +537 -0
  214. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
  215. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +325 -0
  216. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
  217. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +471 -0
  218. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
  219. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +587 -0
  220. package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
  221. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +115 -0
  222. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +141 -0
  223. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +74 -0
  224. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +79 -0
  225. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +207 -0
  226. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +494 -0
  227. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +452 -0
  228. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +88 -0
  229. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +170 -0
  230. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +99 -0
  231. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +411 -0
  232. package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
  233. package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
  234. package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
  235. package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
  236. package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
  237. package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
  238. package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
  239. package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
@@ -0,0 +1,513 @@
1
+ import assert from "node:assert/strict";
2
+ import { vi } from "vitest";
3
+ import { declaredEntries } from "./attachEntries.js";
4
+ import {
5
+ declarePreflightCase,
6
+ deepFreeze,
7
+ data,
8
+ replaceRecordToken,
9
+ type PreflightCase,
10
+ } from "./configurePreflightControls.js";
11
+ import {
12
+ preflightBarriers,
13
+ installPreflightDigestBarrier,
14
+ cleanPreflightMocks,
15
+ preflightObservationState,
16
+ installPreflightObservers,
17
+ } from "./configurePreflightBarriers.js";
18
+ import type { Configuration } from "../preflight/grammar.js";
19
+
20
+ /** Closed TEST Source. Real initial ACK is a prerequisite, never a fabricated receipt. */
21
+ export async function configurePreflightFixture(
22
+ name: PreflightCase = "positive",
23
+ tokenIndex = 0,
24
+ ) {
25
+ vi.resetModules();
26
+ const declared = declarePreflightCase(name);
27
+ const gates = preflightBarriers(name);
28
+ try {
29
+ const state = preflightObservationState();
30
+ let now = declared.firstAt;
31
+ const start = declared.original.attachRequest.firstDispatchedAt * 1000;
32
+ const basis = Object.freeze({
33
+ startWallMs: start,
34
+ startNs: BigInt(start) * 1000000n,
35
+ workEndWallMs: start + declared.workSeconds * 1000,
36
+ workEndNs: BigInt(start + declared.workSeconds * 1000) * 1000000n,
37
+ endWallMs: start + declared.endSeconds * 1000,
38
+ endNs: BigInt(start + declared.endSeconds * 1000) * 1000000n,
39
+ });
40
+ const advance = (next: number) => {
41
+ assert(next >= now && next < basis.workEndWallMs);
42
+ now = next;
43
+ };
44
+ const listeners = new Set<() => void>(),
45
+ origin = Object.freeze({});
46
+ const source = Object.freeze({
47
+ clock: Object.freeze({
48
+ basis,
49
+ sample: () => {
50
+ state.samples++;
51
+ return { wallMs: now, ns: BigInt(now) * 1000000n };
52
+ },
53
+ subscribeRetirement(fn: () => void) {
54
+ listeners.add(fn);
55
+ return () => listeners.delete(fn);
56
+ },
57
+ }),
58
+ originalPolicy: {
59
+ firstDispatchedAt: declared.original.attachRequest.firstDispatchedAt,
60
+ periodStart:
61
+ declared.original.attachRequest.preparation.expected.periodStart,
62
+ periodEnd:
63
+ declared.original.attachRequest.preparation.expected.periodEnd,
64
+ },
65
+ originAssociation: origin,
66
+ });
67
+ const NativeDate = Date;
68
+ vi.stubGlobal(
69
+ "Date",
70
+ class extends NativeDate {
71
+ constructor(value?: string | number) {
72
+ super(value ?? now);
73
+ }
74
+ static now() {
75
+ return now;
76
+ }
77
+ },
78
+ );
79
+ installPreflightDigestBarrier(gates, () => state.phase);
80
+ vi.doMock("../sourceBindings.js", () => ({
81
+ loadOwnedOriginalSource: () => source,
82
+ }));
83
+ const { OWNER } = await import("../originalOwner.js");
84
+ const originalBasis = OWNER.basis;
85
+ let retargetReadMethod: () => void = () => {
86
+ throw Error("METHOD_RETARGET_PREREQUISITE");
87
+ };
88
+ const actual = await installPreflightObservers(
89
+ state,
90
+ OWNER,
91
+ name,
92
+ gates,
93
+ () => advance(declared.laterAt),
94
+ () => retargetReadMethod(),
95
+ );
96
+ const { captureRetainedInput, ownedRetainedEligibility } =
97
+ await import("../material/capture.js");
98
+ const original = captureRetainedInput(declared.original);
99
+ const prepared = await actual.prepareRenewalPriceReplacementV2(
100
+ original.attachRequest.preparation,
101
+ );
102
+ OWNER.check();
103
+ const request = await actual.prepareRenewalScheduleAttachmentV2({
104
+ prepared,
105
+ apiVersion: original.attachRequest.apiVersion,
106
+ attachKey: original.attachRequest.attachKey,
107
+ firstDispatchedAt: original.attachRequest.firstDispatchedAt,
108
+ });
109
+ OWNER.check();
110
+ const { validateOwnedReadMaterial } =
111
+ await import("../material/readMaterial.js");
112
+ const reads = validateOwnedReadMaterial(
113
+ {
114
+ apiVersion: declared.apiVersion,
115
+ observedAt: original.attachRequest.firstDispatchedAt,
116
+ freshSubscription: original.originalBundle.wireSubscription,
117
+ targetPrice: original.originalBundle.wireTargetPrice,
118
+ billingCustomer: original.originalBundle.wireBillingCustomer,
119
+ },
120
+ prepared,
121
+ undefined,
122
+ ownedRetainedEligibility(original),
123
+ );
124
+ const entries = declaredEntries(
125
+ original,
126
+ prepared,
127
+ request,
128
+ reads,
129
+ original.originalBundle,
130
+ );
131
+ const query = String(
132
+ new URLSearchParams(
133
+ ["discounts", "items.data.discounts", "items.data.price"].map(
134
+ (value, i) => ["expand[" + i + "]", value],
135
+ ),
136
+ ),
137
+ );
138
+ const paths = [
139
+ "/v1/subscriptions/" + prepared.expected.subscriptionId + "?" + query,
140
+ "/v1/prices/" + prepared.expected.targetPriceId,
141
+ "/v1/customers/" + original.originalBundle.wireBillingCustomer.id,
142
+ ...original.originalBundle.couponReads.map((row) => {
143
+ assert(typeof row.couponId === "string");
144
+ return "/v1/coupons/" + encodeURIComponent(row.couponId);
145
+ }),
146
+ ];
147
+ const row = (path: string, i: number) =>
148
+ deepFreeze({
149
+ resource:
150
+ i === 0
151
+ ? "subscription"
152
+ : i === 1
153
+ ? "price"
154
+ : i === 2
155
+ ? "customer"
156
+ : "coupon",
157
+ ordinal: i + 1,
158
+ method: "GET",
159
+ path,
160
+ body: undefined,
161
+ options: { apiVersion: declared.apiVersion, maxNetworkRetries: 0 },
162
+ });
163
+ const initialPlan = Object.freeze(paths.map(row));
164
+ const schedulePath = "/v1/subscription_schedules/" + declared.schedule.id;
165
+ const configurePlan = Object.freeze([
166
+ ...initialPlan,
167
+ deepFreeze({ ...row(schedulePath, paths.length), resource: "schedule" }),
168
+ ]);
169
+ const originalBodies = [
170
+ original.originalBundle.wireSubscription,
171
+ original.originalBundle.wireTargetPrice,
172
+ original.originalBundle.wireBillingCustomer,
173
+ ...original.originalBundle.couponReads.map((value) => value.wireCoupon),
174
+ ];
175
+ const currentBodies = [
176
+ declared.currentBundle.wireSubscription,
177
+ declared.currentBundle.wireTargetPrice,
178
+ declared.currentBundle.wireBillingCustomer,
179
+ ...declared.currentBundle.couponReads.map((value) => value.wireCoupon),
180
+ ];
181
+ const table = deepFreeze([
182
+ ...paths.map((path, i) => ({
183
+ method: "GET",
184
+ path,
185
+ body: originalBodies[i],
186
+ schedule: false,
187
+ })),
188
+ {
189
+ method: "POST",
190
+ path: "/v1/subscription_schedules",
191
+ body: declared.schedule,
192
+ schedule: false,
193
+ },
194
+ ...paths.map((path, i) => ({
195
+ method: "GET",
196
+ path,
197
+ body: currentBodies[i],
198
+ schedule: false,
199
+ })),
200
+ {
201
+ method: "GET",
202
+ path: schedulePath,
203
+ body: declared.currentSchedule,
204
+ schedule: true,
205
+ },
206
+ ]);
207
+ vi.stubGlobal("fetch", async (input: unknown, init: RequestInit) => {
208
+ const next = table[state.calls.length],
209
+ url = new URL(String(input));
210
+ assert(next, "UNDECLARED_PREFLIGHT_HTTP");
211
+ assert.equal(url.origin, "https://api.stripe.com");
212
+ assert.equal(url.pathname + url.search, next.path);
213
+ assert.equal(init.method, next.method);
214
+ assert.equal(init.redirect, "error");
215
+ assert.equal(
216
+ new Headers(init.headers).get("stripe-version"),
217
+ declared.apiVersion,
218
+ );
219
+ state.calls.push({ method: String(init.method), path: next.path });
220
+ if (next.schedule) {
221
+ await gates.hold("schedule");
222
+ advance(declared.scheduleAt);
223
+ state.scheduleReplies++;
224
+ }
225
+ return new Response(JSON.stringify(next.body), {
226
+ status: 200,
227
+ headers: {
228
+ "content-type": "application/json",
229
+ "request-id": "req_SYNTHETIC_PREFLIGHT",
230
+ },
231
+ });
232
+ });
233
+ const { getStripeClient } = await import("../../../../helpers.js");
234
+ const client = getStripeClient(
235
+ "sk_test_SYNTHETIC_PREFLIGHT_NO_CREDENTIAL",
236
+ declared.apiVersion,
237
+ { singleAttempt: true },
238
+ );
239
+ const method = client.rawRequest;
240
+ const delegate = Object.freeze({
241
+ rawRequest(...args: unknown[]) {
242
+ return Reflect.apply(method, client, args) as Promise<unknown>;
243
+ },
244
+ });
245
+ const readonlyBody = {
246
+ rawRequest(...args: unknown[]) {
247
+ state.readonlyCalls++;
248
+ assert.equal(args[0], "GET");
249
+ return Reflect.apply(method, client, args) as Promise<unknown>;
250
+ },
251
+ };
252
+ const readonlyDelegate =
253
+ name === "method-retarget" ? readonlyBody : Object.freeze(readonlyBody);
254
+ retargetReadMethod = () => {
255
+ assert.equal(name, "method-retarget");
256
+ assert.equal(++state.methodRetargets, 1);
257
+ Object.defineProperty(readonlyDelegate, "rawRequest", {
258
+ enumerable: true,
259
+ configurable: true,
260
+ writable: true,
261
+ value() {
262
+ state.readonlyCalls++;
263
+ throw Error("RETARGETED_READ_CALLED");
264
+ },
265
+ });
266
+ };
267
+ const sink = Object.freeze({
268
+ send(value: unknown, acknowledge: (value: unknown) => void) {
269
+ OWNER.check();
270
+ const record = data(value);
271
+ state.records.push(record);
272
+ acknowledge({ sequence: record.sequence, binding: record.binding });
273
+ },
274
+ });
275
+ let slotTakes = 0;
276
+ const initialOperation = Object.freeze({
277
+ owner: OWNER,
278
+ originAssociation: origin,
279
+ slot: Object.freeze({
280
+ takeOnce(owner: unknown) {
281
+ assert.equal(owner, OWNER);
282
+ assert.equal(++slotTakes, 1);
283
+ return {
284
+ rawAttachRequest: original.attachRequest,
285
+ originalBundle: original.originalBundle,
286
+ };
287
+ },
288
+ }),
289
+ readPlan: initialPlan,
290
+ delegate,
291
+ sink,
292
+ });
293
+ const initialFrame = Object.freeze({
294
+ owner: OWNER,
295
+ operation: initialOperation,
296
+ request,
297
+ readPlan: initialPlan,
298
+ delegate,
299
+ });
300
+ // Each TEST Source cell is filled once after actual initial terminal ACK, then read unchanged.
301
+ let operation: object | null = null,
302
+ configureFrame: object | null = null;
303
+ const coverage = Object.freeze({
304
+ originalEntry: entries.entry,
305
+ coversPreflight(record: unknown, evidence: unknown, fresh: unknown) {
306
+ state.coverage++;
307
+ assert.deepEqual(record, expectedRecord);
308
+ assert.deepEqual(evidence, expectedEvidence);
309
+ assert.deepEqual(fresh, projected);
310
+ return true;
311
+ },
312
+ });
313
+ vi.doMock("../operations/sourceOperations.js", () => ({
314
+ COMPILED_INITIAL_ENTRIES: Object.freeze([entries.entry]),
315
+ COMPILED_RECOVERY_ENTRIES: Object.freeze([]),
316
+ COMPILED_PREFLIGHT_ENTRIES: Object.freeze([coverage]),
317
+ ORIGINAL_ORIGIN_ASSOCIATION: origin,
318
+ loadFixedInitialOperation: () => initialOperation,
319
+ loadInitialOwnedTransportSource: () => initialFrame,
320
+ loadOwnedConfigureOperation() {
321
+ state.operationLoads++;
322
+ assert(operation);
323
+ return operation;
324
+ },
325
+ loadConfigureOwnedReadTransportSource() {
326
+ state.pairLoads++;
327
+ assert(configureFrame);
328
+ return configureFrame;
329
+ },
330
+ }));
331
+ const { captureOwnedInitialAttachV2 } =
332
+ await import("../operations/initialAttach.js");
333
+ const initialOutput = data(await captureOwnedInitialAttachV2().invoke());
334
+ assert.equal(
335
+ initialOutput.status,
336
+ "attach_acknowledged",
337
+ "ACTUAL_INITIAL_ACK_PREREQUISITE",
338
+ );
339
+ assert.equal(state.records.length, 3);
340
+ assert.equal(
341
+ state.calls.filter((value) => value.method === "POST").length,
342
+ 1,
343
+ );
344
+ const acknowledgement = initialOutput.receipt;
345
+ assert(acknowledgement && typeof acknowledgement === "object");
346
+ assert.deepEqual(data(acknowledgement).providerSnapshot, declared.schedule);
347
+ assert.deepEqual(data(acknowledgement).request, request);
348
+ assert.deepEqual(data(state.records[2]!.data).receipt, acknowledgement);
349
+ advance(declared.baseAt);
350
+ const goodConfiguration = {
351
+ preparation: original.attachRequest.preparation,
352
+ attachReceipt: {
353
+ attachRequest: original.attachRequest,
354
+ actualDispatch: {
355
+ scope: request.scope,
356
+ apiVersion: request.apiVersion,
357
+ method: request.method,
358
+ path: request.path,
359
+ payload: request.payload,
360
+ key: request.key,
361
+ firstDispatchedAt: request.firstDispatchedAt,
362
+ },
363
+ providerSnapshot: declared.schedule,
364
+ },
365
+ freshSubscription: declared.baselineBundle.wireSubscription,
366
+ targetPrice: declared.baselineBundle.wireTargetPrice,
367
+ billingCustomer: declared.baselineBundle.wireBillingCustomer,
368
+ schedule: declared.schedule,
369
+ apiVersion: declared.apiVersion,
370
+ observedAt: declared.configureAt,
371
+ firstDispatchedAt: declared.configureAt,
372
+ configureKey: declared.configureKey,
373
+ };
374
+ const projected =
375
+ await actual.projectRenewalConfigurationV2(goodConfiguration);
376
+ OWNER.check();
377
+ assert.equal(
378
+ projected.status,
379
+ "projected_configure_request",
380
+ "EXPANDED_NATIVE_C6_PREREQUISITE",
381
+ );
382
+ if (projected.status !== "projected_configure_request")
383
+ throw Error("EXPANDED_NATIVE_C6_PREREQUISITE");
384
+ const expectedRecord = deepFreeze({
385
+ configuration: goodConfiguration,
386
+ request: projected,
387
+ attachReceipt: acknowledgement,
388
+ originalBundle: original.originalBundle,
389
+ });
390
+ const expectedEvidence = deepFreeze({
391
+ bundle: declared.baselineBundle,
392
+ schedule: declared.schedule,
393
+ observedAt: Math.floor(declared.scheduleAt / 1000),
394
+ });
395
+ let boundRecord: unknown = expectedRecord;
396
+ if (name === "original-failure")
397
+ boundRecord = {
398
+ ...expectedRecord,
399
+ configuration: {
400
+ ...goodConfiguration,
401
+ apiVersion: declared.originalAPI,
402
+ },
403
+ request: { ...projected, logicalBinding: declared.badRecordBinding },
404
+ };
405
+ if (name === "record-token")
406
+ boundRecord = replaceRecordToken(expectedRecord, tokenIndex);
407
+ // Restore the real pointer after TEST detached tampering of other DATA fields.
408
+ if (name === "record-token" && tokenIndex < 5)
409
+ boundRecord = { ...data(boundRecord), attachReceipt: acknowledgement };
410
+ operation = Object.freeze({
411
+ owner: name === "foreign-owner" ? Object.freeze({}) : OWNER,
412
+ originAssociation: name === "foreign-origin" ? Object.freeze({}) : origin,
413
+ originalEntry:
414
+ name === "foreign-entry" ? Object.freeze({}) : entries.entry,
415
+ preflightEntry:
416
+ name === "foreign-preflight-entry"
417
+ ? Object.freeze({ ...coverage })
418
+ : coverage,
419
+ actualAcknowledgement:
420
+ name === "foreign-ack"
421
+ ? structuredClone(acknowledgement)
422
+ : acknowledgement,
423
+ record: boundRecord,
424
+ readTransport: readonlyDelegate,
425
+ });
426
+ if (name === "retired-proxy")
427
+ operation = new Proxy(operation, {
428
+ get() {
429
+ state.tupleTraps++;
430
+ throw Error("RETIRED_TUPLE_TRAP");
431
+ },
432
+ ownKeys() {
433
+ state.tupleTraps++;
434
+ throw Error("RETIRED_TUPLE_TRAP");
435
+ },
436
+ getOwnPropertyDescriptor() {
437
+ state.tupleTraps++;
438
+ throw Error("RETIRED_TUPLE_TRAP");
439
+ },
440
+ getPrototypeOf() {
441
+ state.tupleTraps++;
442
+ throw Error("RETIRED_TUPLE_TRAP");
443
+ },
444
+ });
445
+ configureFrame = Object.freeze({
446
+ owner: OWNER,
447
+ operation: name === "foreign-pair" ? Object.freeze({}) : operation,
448
+ readPlan: configurePlan,
449
+ delegate:
450
+ name === "foreign-delegate"
451
+ ? Object.freeze({
452
+ rawRequest() {
453
+ state.readonlyCalls++;
454
+ throw Error("FOREIGN_DELEGATE_CALLED");
455
+ },
456
+ })
457
+ : readonlyDelegate,
458
+ });
459
+ const before = {
460
+ GET: state.calls.filter((value) => value.method === "GET").length,
461
+ POST: state.calls.filter((value) => value.method === "POST").length,
462
+ records: state.records.length,
463
+ };
464
+ state.initialFinished = true;
465
+ if (name === "retired-capture" || name === "retired-proxy") OWNER.retire();
466
+ const beforeCapture = Object.freeze({
467
+ samples: state.samples,
468
+ operationLoads: state.operationLoads,
469
+ });
470
+ // Load the actual actor only after real initial ACK and expanded C6 prerequisites.
471
+ const subject = await import("../preflight/configurePreflight.js");
472
+ return {
473
+ OWNER,
474
+ declared,
475
+ state,
476
+ basis: originalBasis,
477
+ expectedRecord,
478
+ expectedEvidence,
479
+ projected,
480
+ initialOutput,
481
+ acknowledgement,
482
+ boundRecord,
483
+ beforeCapture,
484
+ capture: subject.captureOwnedConfigurePreflightV2,
485
+ directOriginal: () =>
486
+ actual.projectRenewalConfigurationV2(
487
+ data(boundRecord).configuration as Configuration,
488
+ ),
489
+ gates,
490
+ deltas: () => ({
491
+ GET:
492
+ state.calls.filter((value) => value.method === "GET").length -
493
+ before.GET,
494
+ POST:
495
+ state.calls.filter((value) => value.method === "POST").length -
496
+ before.POST,
497
+ records: state.records.length - before.records,
498
+ }),
499
+ async cleanup() {
500
+ await gates.cleanup();
501
+ cleanPreflightMocks();
502
+ },
503
+ };
504
+ } catch (error) {
505
+ await gates.cleanup();
506
+ cleanPreflightMocks();
507
+ throw error;
508
+ }
509
+ }
510
+
511
+ export type PreflightFixture = Awaited<
512
+ ReturnType<typeof configurePreflightFixture>
513
+ >;