@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,507 @@
1
+ import assert from "node:assert/strict";
2
+ import { it, vi } from "vitest";
3
+ import {
4
+ configureWriteFixture,
5
+ type ConfigureWriteFixture,
6
+ } from "../test-fixtures/configureWriteOperation.js";
7
+ import { assertProviderFailure } from "../test-fixtures/configureWriteAssertions.js";
8
+
9
+ for (const name of [
10
+ "get-reject",
11
+ "post-reject",
12
+ "conflict",
13
+ "error-envelope-missing-optionals",
14
+ ] as const)
15
+ it(
16
+ "writer actual strict provider rejection remains visible without retry: " +
17
+ name,
18
+ async () => {
19
+ const h = await configureWriteFixture(name);
20
+ try {
21
+ const error = await h
22
+ .captureWriter()
23
+ .invoke()
24
+ .then(
25
+ () => assert.fail("EXPECTED_ACTUAL_PROVIDER_REJECTION"),
26
+ (error: unknown) => error,
27
+ );
28
+ assertProviderFailure(
29
+ h,
30
+ error,
31
+ name === "get-reject" ? "read" : "post",
32
+ );
33
+ if (name === "error-envelope-missing-optionals") {
34
+ assert(error !== null && typeof error === "object");
35
+ const descriptor = Object.getOwnPropertyDescriptor(error, "failure");
36
+ assert(descriptor && "value" in descriptor);
37
+ const failure: unknown = descriptor.value;
38
+ assert(failure !== null && typeof failure === "object");
39
+ const diagnostics = Object.getOwnPropertyDescriptor(
40
+ failure,
41
+ "diagnostics",
42
+ );
43
+ assert(diagnostics && "value" in diagnostics);
44
+ assert.deepEqual(diagnostics.value, {
45
+ type: "StripeAPIError",
46
+ statusCode: 409,
47
+ requestId: "req_SYNTHETIC_CONFIGURE_WRITE",
48
+ });
49
+ }
50
+ assert.equal(
51
+ h.writeState.calls.filter((row) => row.method === "POST").length,
52
+ name === "get-reject" ? 0 : 1,
53
+ );
54
+ assert(h.writeState.calls.length <= 45);
55
+ assert.equal(
56
+ h.writeState.records.length,
57
+ name === "get-reject" ? 0 : 1,
58
+ );
59
+ assert.equal(h.writeState.explicitC9, 0);
60
+ } finally {
61
+ await h.cleanup();
62
+ }
63
+ },
64
+ );
65
+
66
+ for (const name of [
67
+ "unsafe-body",
68
+ "unsafe-metadata",
69
+ "diagnostics-empty",
70
+ "redirect307",
71
+ "redirect308",
72
+ ] as const)
73
+ it(
74
+ "writer unsafe or non-2xx fulfilled response stays unknown: " + name,
75
+ async () => {
76
+ const h = await configureWriteFixture(name);
77
+ try {
78
+ assert.deepEqual(await h.captureWriter().invoke(), {
79
+ status: "configure_unknown",
80
+ reason: "post_unverified",
81
+ operationalAuthority: false,
82
+ });
83
+ assert.equal(
84
+ h.writeState.calls.filter((row) => row.method === "POST").length,
85
+ 1,
86
+ );
87
+ assert.equal(h.writeState.records.length, 1);
88
+ assert.equal(h.writeState.explicitC9, 0);
89
+ if (name === "redirect307" || name === "redirect308") {
90
+ // The fake fetch asserts redirect:error but deliberately returns raw 3xx.
91
+ // This proves non-2xx refusal, not native redirect following/rejection.
92
+ assert.equal(
93
+ h.writeState.calls.length,
94
+ 5 + h.write.currentBundle.couponReads.length,
95
+ );
96
+ assert.equal(h.writeState.compilerC9, 0);
97
+ assert.equal(h.writeState.replies.length, 0);
98
+ assert.equal(h.writeState.trace.includes("sink:2"), false);
99
+ }
100
+ } finally {
101
+ await h.cleanup();
102
+ }
103
+ },
104
+ );
105
+
106
+ for (const name of [
107
+ "retire-get",
108
+ "retire-post",
109
+ "retire-response",
110
+ "retire-receipt",
111
+ ] as const)
112
+ it(
113
+ "writer original Owner closes at actual held boundary: " + name,
114
+ async () => {
115
+ const h = await configureWriteFixture(name),
116
+ boundary = name.slice(7);
117
+ const pending = h.captureWriter().invoke();
118
+ const observed = pending.then(
119
+ (value: unknown) => ({ ok: true as const, value }),
120
+ (error: unknown) => ({ ok: false as const, error }),
121
+ );
122
+ try {
123
+ await h.writeGates.entered(boundary, pending);
124
+ h.OWNER.retire();
125
+ h.writeGates.release(boundary);
126
+ const out = await observed;
127
+ if (name === "retire-get") {
128
+ assert.equal(out.ok, false);
129
+ if (!out.ok)
130
+ assert.equal((out.error as Error).message, "CONFIGURE_WRITE_STOP");
131
+ } else {
132
+ assert.equal(out.ok, true);
133
+ if (out.ok)
134
+ assert.deepEqual(out.value, {
135
+ status: "configure_unknown",
136
+ reason: "owner_closed_after_post",
137
+ operationalAuthority: false,
138
+ });
139
+ }
140
+ assert.equal(
141
+ h.writeState.calls.filter((row) => row.method === "POST").length,
142
+ name === "retire-get" ? 0 : 1,
143
+ );
144
+ assert.equal(
145
+ h.writeState.records.length,
146
+ name === "retire-receipt"
147
+ ? 3
148
+ : name === "retire-response"
149
+ ? 2
150
+ : name === "retire-post"
151
+ ? 1
152
+ : 0,
153
+ );
154
+ assert.equal(
155
+ h.writeState.explicitC9,
156
+ name === "retire-receipt" ? 1 : 0,
157
+ );
158
+ assert.deepEqual(h.expectedRecord.attachReceipt, h.acknowledgement);
159
+ } finally {
160
+ h.writeGates.release(boundary);
161
+ await observed;
162
+ await h.cleanup();
163
+ }
164
+ },
165
+ );
166
+
167
+ it("retirement during actualC9 digest blocks owned receipt publication", async () => {
168
+ const h = await configureWriteFixture("retire-c9");
169
+ const subtle = globalThis.crypto.subtle,
170
+ method = subtle.digest;
171
+ let retired = false;
172
+ vi.stubGlobal("crypto", {
173
+ subtle: {
174
+ digest(...args: Parameters<typeof method>) {
175
+ const promise = Reflect.apply(method, subtle, args) as ReturnType<
176
+ typeof method
177
+ >;
178
+ const input = args[1];
179
+ assert(ArrayBuffer.isView(input));
180
+ const tuple: unknown = JSON.parse(
181
+ new TextDecoder().decode(
182
+ new Uint8Array(input.buffer, input.byteOffset, input.byteLength),
183
+ ),
184
+ );
185
+ if (
186
+ Array.isArray(tuple) &&
187
+ tuple[0] === "betterstripe-renewal-binding" &&
188
+ tuple[1] === 2 &&
189
+ tuple[2] === "renewal-configure-receipt"
190
+ )
191
+ h.writeGates.pending.push(
192
+ promise.then(
193
+ () => {
194
+ assert.equal(retired, false);
195
+ assert.equal(h.writeGates.activeDigests.size, 0);
196
+ retired = true;
197
+ h.OWNER.retire();
198
+ },
199
+ () => {},
200
+ ),
201
+ );
202
+ return promise;
203
+ },
204
+ },
205
+ });
206
+ try {
207
+ assert.deepEqual(await h.captureWriter().invoke(), {
208
+ status: "configure_unknown",
209
+ reason: "owner_closed_after_post",
210
+ operationalAuthority: false,
211
+ });
212
+ assert.equal(retired, true);
213
+ assert.equal(h.writeState.explicitC9, 1);
214
+ assert.equal(h.writeState.records.length, 2);
215
+ } finally {
216
+ await h.cleanup();
217
+ }
218
+ });
219
+
220
+ it("retirement after actual receipt3 ACK retains history and blocks late success", async () => {
221
+ let h: ConfigureWriteFixture | undefined;
222
+ vi.doMock("../c10/configureEvents.js", async () => {
223
+ const actual = await vi.importActual<
224
+ typeof import("../c10/configureEvents.js")
225
+ >("../c10/configureEvents.js");
226
+ return {
227
+ ...actual,
228
+ createConfigureEventCompiler(
229
+ ...args: Parameters<typeof actual.createConfigureEventCompiler>
230
+ ) {
231
+ const compiler = Reflect.apply(
232
+ actual.createConfigureEventCompiler,
233
+ actual,
234
+ args,
235
+ ) as ReturnType<typeof actual.createConfigureEventCompiler>;
236
+ return Object.freeze({
237
+ ...compiler,
238
+ receipt(...xs: Parameters<typeof compiler.receipt>) {
239
+ const promise = Reflect.apply(
240
+ compiler.receipt,
241
+ compiler,
242
+ xs,
243
+ ) as ReturnType<typeof compiler.receipt>;
244
+ assert(h);
245
+ const owned = h;
246
+ owned.writeGates.pending.push(
247
+ promise.then(
248
+ () => {
249
+ assert.equal(owned.writeState.records.length, 3);
250
+ owned.OWNER.retire();
251
+ },
252
+ () => {},
253
+ ),
254
+ );
255
+ return promise;
256
+ },
257
+ });
258
+ },
259
+ };
260
+ });
261
+ try {
262
+ h = await configureWriteFixture("retire-final");
263
+ assert.deepEqual(await h.captureWriter().invoke(), {
264
+ status: "configure_unknown",
265
+ reason: "owner_closed_after_post",
266
+ operationalAuthority: false,
267
+ });
268
+ assert.equal(h.writeState.records.length, 3);
269
+ assert.equal(h.writeState.explicitC9, 1);
270
+ assert.equal(h.writeState.compilerC9, 1);
271
+ } finally {
272
+ if (h) await h.cleanup();
273
+ vi.doUnmock("../c10/configureEvents.js");
274
+ }
275
+ });
276
+
277
+ for (const mode of ["foreign-catch", "catch-once"] as const)
278
+ it("actual pair catch origin and one-use: " + mode, async () => {
279
+ const results: string[] = [];
280
+ let firstReply: unknown;
281
+ vi.doMock("./transport.js", async () => {
282
+ const actual =
283
+ await vi.importActual<typeof import("./transport.js")>(
284
+ "./transport.js",
285
+ );
286
+ const wrap = (
287
+ pair: ReturnType<typeof actual.createConfigureWriteTransport>,
288
+ ) => {
289
+ const capability = Object.fromEntries(
290
+ Object.entries(pair.capability).map(([key, method]) => [
291
+ key,
292
+ (...args: unknown[]) => {
293
+ if (key !== "consumePostCatch")
294
+ return Reflect.apply(method, pair.capability, args);
295
+ const foreign =
296
+ firstReply ?? Object.freeze({ outcome: "post_unknown" });
297
+ assert.equal(
298
+ Reflect.apply(method, pair.capability, [foreign]),
299
+ null,
300
+ );
301
+ results.push("foreign-refused");
302
+ const fact: unknown = Reflect.apply(
303
+ method,
304
+ pair.capability,
305
+ args,
306
+ );
307
+ assert(fact);
308
+ assert.equal(Reflect.apply(method, pair.capability, args), null);
309
+ results.push("genuine-once");
310
+ firstReply = args[0];
311
+ return fact;
312
+ },
313
+ ]),
314
+ ) as typeof pair.capability;
315
+ return Object.freeze({
316
+ ...pair,
317
+ capability: Object.freeze(capability),
318
+ });
319
+ };
320
+ return {
321
+ ...actual,
322
+ createConfigureWriteTransport: () =>
323
+ wrap(actual.createConfigureWriteTransport()),
324
+ createConfigureReplayTransport: () =>
325
+ wrap(actual.createConfigureReplayTransport()),
326
+ };
327
+ });
328
+ let h: ConfigureWriteFixture | undefined;
329
+ try {
330
+ h = await configureWriteFixture(
331
+ mode === "foreign-catch" ? "unknown-replay-repeat" : "post-reject",
332
+ );
333
+ const Aerror = await h
334
+ .captureWriter()
335
+ .invoke()
336
+ .then(
337
+ () => assert.fail("EXPECTED_A_UNKNOWN"),
338
+ (error: unknown) => error,
339
+ );
340
+ assertProviderFailure(h, Aerror, "post");
341
+ if (mode === "foreign-catch") {
342
+ const Berror = await h
343
+ .captureReplayB()
344
+ .invoke()
345
+ .then(
346
+ () => assert.fail("EXPECTED_B_UNKNOWN"),
347
+ (error: unknown) => error,
348
+ );
349
+ assertProviderFailure(
350
+ { ...h, writeState: h.replayStates.B },
351
+ Berror,
352
+ "post",
353
+ );
354
+ }
355
+ assert.deepEqual(
356
+ results,
357
+ mode === "foreign-catch"
358
+ ? [
359
+ "foreign-refused",
360
+ "genuine-once",
361
+ "foreign-refused",
362
+ "genuine-once",
363
+ ]
364
+ : ["foreign-refused", "genuine-once"],
365
+ );
366
+ } finally {
367
+ if (h) await h.cleanup();
368
+ vi.doUnmock("./transport.js");
369
+ }
370
+ });
371
+
372
+ // Requires separately reviewed Source-fault TEST-family extension; not actual SDK/provider rejection evidence.
373
+ for (const name of [
374
+ "source-post-sync-throw",
375
+ "source-post-nonpromise",
376
+ ] as const)
377
+ it(
378
+ "ambiguous Source start cannot qualify explicit replay: " + name,
379
+ async () => {
380
+ const h = await configureWriteFixture(name);
381
+ try {
382
+ assert.deepEqual(await h.captureWriter().invoke(), {
383
+ status: "configure_unknown",
384
+ reason: "post_unverified",
385
+ operationalAuthority: false,
386
+ });
387
+ assert.equal(
388
+ h.writeState.calls.filter((row) => row.method === "POST").length,
389
+ 0,
390
+ );
391
+ assert.equal(
392
+ h.writeState.trace.filter((value) => value === name).length,
393
+ 1,
394
+ );
395
+ assert.equal(h.writeState.records.length, 1);
396
+ assert.equal(h.writeState.explicitC9, 0);
397
+ assert.equal(h.OWNER.check().retired, false);
398
+ assert.deepEqual(await h.captureReplayB().invoke(), {
399
+ status: "not_dispatched",
400
+ reason: "prior_attempt_not_replayable",
401
+ operationalAuthority: false,
402
+ });
403
+ assert.equal(h.replayStates.B.calls.length, 0);
404
+ assert.equal(h.replayStates.B.pairLoads, 0);
405
+ } finally {
406
+ await h.cleanup();
407
+ }
408
+ },
409
+ );
410
+
411
+ for (const [resource, ordinal] of [
412
+ ["subscription", 1],
413
+ ["price", 2],
414
+ ["customer", 3],
415
+ ["coupon0", 4],
416
+ ["coupon1", 5],
417
+ ["schedule", 6],
418
+ ] as const)
419
+ it(
420
+ "original Owner closes at each actual declared GET await: " + resource,
421
+ async () => {
422
+ const h = await configureWriteFixture();
423
+ assert.equal(
424
+ 4 + h.write.currentBundle.couponReads.length,
425
+ 6,
426
+ "DECLARED_SIX_READ_PROFILE_PREREQUISITE",
427
+ );
428
+ const originalFetch = globalThis.fetch;
429
+ // Deliberate fakeHTTP hold; the original stock SDK rawRequest Promise is unchanged.
430
+ vi.stubGlobal("fetch", (input: RequestInfo | URL, init?: RequestInit) => {
431
+ const promise = Reflect.apply(originalFetch, globalThis, [
432
+ input,
433
+ init,
434
+ ]) as ReturnType<typeof originalFetch>;
435
+ const held = promise.then(async (response: Response) => {
436
+ if (init?.method === "GET" && h.writeState.calls.length === ordinal)
437
+ await h.writeGates.hold("selected-get");
438
+ return response;
439
+ });
440
+ h.writeGates.pending.push(
441
+ held.then(
442
+ () => {},
443
+ () => {},
444
+ ),
445
+ );
446
+ return held;
447
+ });
448
+ const pending = h.captureWriter().invoke();
449
+ const observed = pending.then(
450
+ (value: unknown) => ({ ok: true as const, value }),
451
+ (error: unknown) => ({ ok: false as const, error }),
452
+ );
453
+ try {
454
+ await h.writeGates.entered("selected-get", pending);
455
+ assert.equal(h.writeState.calls.length, ordinal);
456
+ h.OWNER.retire();
457
+ h.writeGates.release("selected-get");
458
+ const out = await observed;
459
+ assert.equal(out.ok, false);
460
+ if (!out.ok)
461
+ assert.equal((out.error as Error).message, "CONFIGURE_WRITE_STOP");
462
+ assert.equal(
463
+ h.writeState.calls.filter((row) => row.method === "POST").length,
464
+ 0,
465
+ );
466
+ assert.equal(h.writeState.records.length, 0);
467
+ } finally {
468
+ h.writeGates.release("selected-get");
469
+ await observed;
470
+ await h.cleanup();
471
+ }
472
+ assert.equal(h.writeState.calls.length, ordinal);
473
+ },
474
+ );
475
+
476
+ it("retired owned continuation never reflects late hostile Source rejection", async () => {
477
+ const h = await configureWriteFixture("source-post-hostile-late-reject");
478
+ const pending = h.captureWriter().invoke();
479
+ const observed = pending.then(
480
+ (value: unknown) => ({ ok: true as const, value }),
481
+ (error: unknown) => ({ ok: false as const, error }),
482
+ );
483
+ try {
484
+ await h.writeGates.entered("source-rejection", pending);
485
+ h.OWNER.retire();
486
+ h.writeGates.release("source-rejection");
487
+ const out = await observed;
488
+ assert.equal(out.ok, true);
489
+ if (out.ok)
490
+ assert.deepEqual(out.value, {
491
+ status: "configure_unknown",
492
+ reason: "owner_closed_after_post",
493
+ operationalAuthority: false,
494
+ });
495
+ assert.equal(h.writeState.records.length, 1);
496
+ assert.equal(
497
+ h.writeState.calls.filter((row) => row.method === "POST").length,
498
+ 0,
499
+ );
500
+ assert.equal(h.writeState.traps, 0);
501
+ } finally {
502
+ h.writeGates.release("source-rejection");
503
+ await observed;
504
+ await h.cleanup();
505
+ }
506
+ assert.equal(h.writeState.traps, 0);
507
+ });