@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,535 @@
1
+ import { admitInitialOutput } from "../recovery/material.js";
2
+ import { types } from "node:util";
3
+ import { OWNER } from "../originalOwner.js";
4
+ import {
5
+ prepareRenewalPriceReplacementV2 as c1,
6
+ prepareRenewalScheduleAttachmentV2 as c2,
7
+ constructRenewalScheduleAttachmentReceiptV2 as c3,
8
+ } from "../../../renewalV2/index.js";
9
+ import {
10
+ classifyOwnedRetainedInitialAttachment,
11
+ classifyOwnedInitialAttachment,
12
+ } from "../material/classifiers.js";
13
+ import { captureRetainedInput } from "../material/capture.js";
14
+ import {
15
+ closed,
16
+ type AttachRequest,
17
+ type SourceMethod,
18
+ type FailureControl,
19
+ } from "./types.js";
20
+ import { equal } from "../../../renewalAggregate/shared.js";
21
+ import { owned } from "./ownedAwait.js";
22
+ import type { Diagnostics } from "./providerFailure.js";
23
+ import { bindRawAcquisitionFromSource } from "../acquisition/ownedAcquisition.js";
24
+ import { createAttachEventCompiler } from "../c10/attachEvents.js";
25
+ import {
26
+ COMPILED_INITIAL_ENTRIES as ENTRIES,
27
+ loadFixedInitialOperation,
28
+ ORIGINAL_ORIGIN_ASSOCIATION,
29
+ } from "./sourceOperations.js";
30
+ import { createInitialOwnedTransportWithAttemptCapability as createPair } from "./fixedTransport.js";
31
+
32
+ type Pair = ReturnType<typeof createPair>;
33
+
34
+ function sourceMethod(object: unknown, name: string): SourceMethod {
35
+ need(object !== null && typeof object === "object" && !types.isProxy(object));
36
+ const d = Object.getOwnPropertyDescriptor(object, name);
37
+ need(
38
+ d &&
39
+ d.enumerable &&
40
+ "value" in d &&
41
+ typeof d.value === "function" &&
42
+ !types.isProxy(d.value),
43
+ );
44
+ return d.value as SourceMethod;
45
+ }
46
+ const stop = (): never => {
47
+ throw Error("INITIAL_ACTOR_STOP");
48
+ };
49
+ function need(value: unknown): asserts value {
50
+ if (!value) stop();
51
+ }
52
+ function seven(request: AttachRequest) {
53
+ const { scope, apiVersion, method, path, payload, key, firstDispatchedAt } =
54
+ request;
55
+ return Object.freeze({
56
+ scope,
57
+ apiVersion,
58
+ method,
59
+ path,
60
+ payload,
61
+ key,
62
+ firstDispatchedAt,
63
+ });
64
+ }
65
+
66
+ const refuse = (reason: string) =>
67
+ Object.freeze({
68
+ status: "not_dispatched",
69
+ reason,
70
+ operationalAuthority: false,
71
+ });
72
+ /** Internal single-use actor. Empty class registry precedes every Source side effect. */
73
+ export function captureInitialAttach() {
74
+ need(arguments.length === 0);
75
+ return captureOwnedInitialAttachV2();
76
+ }
77
+ export function captureOwnedInitialAttachV2() {
78
+ need(arguments.length === 0);
79
+ let consumed = false;
80
+ return Object.freeze({
81
+ async invoke() {
82
+ need(arguments.length === 0);
83
+ if (consumed) return refuse("invocation_consumed");
84
+ consumed = true;
85
+ need(!types.isProxy(ENTRIES) && Array.isArray(ENTRIES));
86
+ if (ENTRIES.length === 0) return refuse("no_qualified_native_class");
87
+ let pair: Pair | null = null,
88
+ failureControl: FailureControl | null = null,
89
+ postEligible = false;
90
+ const uncertain = () => {
91
+ need(pair);
92
+ const state = pair.transport.postDisposition();
93
+ need(state === "FULFILLED_SAFE" || state === "FULFILLED_UNVERIFIED");
94
+ const q =
95
+ failureControl === null ? null : failureControl.takePostQuarantine();
96
+ return Object.freeze(
97
+ q === null
98
+ ? { status: "fulfilled_unverified", operationalAuthority: false }
99
+ : {
100
+ status: "fulfilled_unverified",
101
+ operationalAuthority: false,
102
+ quarantine: q,
103
+ },
104
+ );
105
+ };
106
+ try {
107
+ OWNER.check();
108
+ const live = loadFixedInitialOperation();
109
+ OWNER.check();
110
+ if (live === null) return refuse("original_slot_unbound");
111
+ const op = closed(live, [
112
+ "owner",
113
+ "originAssociation",
114
+ "slot",
115
+ "readPlan",
116
+ "delegate",
117
+ "sink",
118
+ ]);
119
+ need(
120
+ op.owner === OWNER &&
121
+ op.originAssociation !== null &&
122
+ typeof op.originAssociation === "object" &&
123
+ !types.isProxy(op.originAssociation) &&
124
+ op.originAssociation === ORIGINAL_ORIGIN_ASSOCIATION,
125
+ );
126
+ const takeOnce = sourceMethod(op.slot, "takeOnce");
127
+ OWNER.check();
128
+ const slot = Reflect.apply(takeOnce, op.slot, [OWNER]);
129
+ OWNER.check();
130
+ if (!slot) return refuse("original_slot_unbound");
131
+ const selected = closed(slot, ["rawAttachRequest", "originalBundle"]);
132
+ const original = captureRetainedInput({
133
+ attachRequest: selected.rawAttachRequest,
134
+ originalBundle: selected.originalBundle,
135
+ });
136
+ OWNER.check();
137
+ const raw = original.attachRequest;
138
+ const prepared = await owned(() => c1(raw.preparation));
139
+ OWNER.check();
140
+ const request = await owned(() =>
141
+ c2({
142
+ prepared,
143
+ apiVersion: raw.apiVersion,
144
+ attachKey: raw.attachKey,
145
+ firstDispatchedAt: raw.firstDispatchedAt,
146
+ }),
147
+ );
148
+ OWNER.check();
149
+ const retained = await owned(() =>
150
+ classifyOwnedRetainedInitialAttachment(original),
151
+ );
152
+ OWNER.check();
153
+ if (retained.status !== "classified")
154
+ return refuse("retained_material_unsupported");
155
+ const matches: { raw: unknown; fresh: SourceMethod }[] = [];
156
+ for (const entry of ENTRIES) {
157
+ OWNER.check();
158
+ const retainedPredicate = sourceMethod(entry, "coversRetained"),
159
+ freshPredicate = sourceMethod(entry, "coversFresh");
160
+ if (
161
+ Reflect.apply(retainedPredicate, entry, [
162
+ retained.material,
163
+ original.originalBundle,
164
+ ]) === true
165
+ )
166
+ matches.push({ raw: entry, fresh: freshPredicate });
167
+ OWNER.check();
168
+ }
169
+ if (matches.length !== 1) return refuse("retained_class_not_unique");
170
+ const entry = matches[0];
171
+ OWNER.check();
172
+ pair = createPair();
173
+ OWNER.check();
174
+ need(
175
+ pair.capability.assertSourceOperationBinding(
176
+ live,
177
+ request,
178
+ op.readPlan,
179
+ op.delegate,
180
+ ),
181
+ );
182
+ OWNER.check();
183
+
184
+ const activePair = pair;
185
+ // Only this invocation's pair and actual locally rebuilt C2 enter this capsule.
186
+ const control = (() => {
187
+ const capability = activePair.capability,
188
+ takeQuarantine = capability.takeFulfilledQuarantine;
189
+ Object.freeze(request.payload);
190
+ Object.freeze(request.requestIdentity);
191
+ Object.freeze(request);
192
+ OWNER.check();
193
+ type Token = {
194
+ invocation: object;
195
+ phase: "read" | "post";
196
+ ordinal: number;
197
+ request: AttachRequest;
198
+ diagnostics: Diagnostics;
199
+ };
200
+ const tokens = new WeakMap<object, Token>(),
201
+ invocation = Object.freeze({});
202
+ let phase = "unused";
203
+ const tokenValue = (error: unknown) =>
204
+ error !== null &&
205
+ (typeof error === "object" || typeof error === "function")
206
+ ? tokens.get(error)
207
+ : undefined;
208
+ function consume(error: unknown, kind: "read" | "post") {
209
+ OWNER.check();
210
+ const value = tokenValue(error);
211
+ if (
212
+ error !== null &&
213
+ (typeof error === "object" || typeof error === "function")
214
+ )
215
+ tokens.delete(error);
216
+ if (
217
+ !value ||
218
+ value.invocation !== invocation ||
219
+ value.phase !== kind ||
220
+ phase !== (kind === "read" ? "failed" : "failed_post")
221
+ )
222
+ return null;
223
+ phase = kind === "read" ? "consumed" : "consumed_post";
224
+ const failure = Object.freeze({
225
+ category: "provider_rejected",
226
+ phase: kind,
227
+ ordinal: value.ordinal,
228
+ request: value.request,
229
+ diagnostics: value.diagnostics,
230
+ outcome: "unknown",
231
+ operationalAuthority: false,
232
+ });
233
+ const out = Error("INITIAL_PROVIDER_REJECTED");
234
+ Object.defineProperty(out, "failure", {
235
+ value: failure,
236
+ enumerable: false,
237
+ writable: false,
238
+ configurable: false,
239
+ });
240
+ return out;
241
+ }
242
+ return Object.freeze({
243
+ takePostQuarantine(...args: unknown[]) {
244
+ if (args.length !== 0) return null;
245
+ return Reflect.apply(takeQuarantine, capability, []) as
246
+ object | null;
247
+ },
248
+ begin() {
249
+ OWNER.check();
250
+ if (phase !== "unused") stop();
251
+ if (capability.assertVirginAcquisition() !== true) {
252
+ phase = "closed";
253
+ stop();
254
+ }
255
+ OWNER.check();
256
+ phase = "acquiring";
257
+ },
258
+ complete() {
259
+ OWNER.check();
260
+ if (phase !== "acquiring") stop();
261
+ phase = "complete";
262
+ },
263
+ takeReadFailure() {
264
+ OWNER.check();
265
+ if (phase !== "acquiring") stop();
266
+ const record = capability.consumeReadCatch();
267
+ OWNER.check();
268
+ if (record === null) {
269
+ phase = "unsupported";
270
+ return null;
271
+ }
272
+ need(
273
+ record.phase === "read" &&
274
+ Number.isSafeInteger(record.ordinal) &&
275
+ record.ordinal >= 1 &&
276
+ record.ordinal <= 43,
277
+ );
278
+ const token = Object.freeze(Object.create(null)) as object;
279
+ tokens.set(
280
+ token,
281
+ Object.freeze({
282
+ invocation,
283
+ phase: "read",
284
+ ordinal: record.ordinal,
285
+ request,
286
+ diagnostics: record.diagnostics,
287
+ }),
288
+ );
289
+ phase = "failed";
290
+ return token;
291
+ },
292
+ beginPost() {
293
+ OWNER.check();
294
+ if (phase !== "complete") stop();
295
+ phase = "posting";
296
+ },
297
+ takePostFailure(actualReply: unknown) {
298
+ OWNER.check();
299
+ if (phase !== "posting") stop();
300
+ const record = capability.consumePostCatch(actualReply);
301
+ OWNER.check();
302
+ if (record === null) {
303
+ phase = "post_without_token";
304
+ return null;
305
+ }
306
+ need(
307
+ record.phase === "post" &&
308
+ Number.isSafeInteger(record.ordinal) &&
309
+ record.ordinal >= 1 &&
310
+ record.ordinal <= 44,
311
+ );
312
+ const token = Object.freeze(Object.create(null)) as object;
313
+ tokens.set(
314
+ token,
315
+ Object.freeze({
316
+ invocation,
317
+ phase: "post",
318
+ ordinal: record.ordinal,
319
+ request,
320
+ diagnostics: record.diagnostics,
321
+ }),
322
+ );
323
+ phase = "failed_post";
324
+ return token;
325
+ },
326
+ forward(error: unknown) {
327
+ OWNER.check();
328
+ const value = tokenValue(error);
329
+ return value &&
330
+ value.invocation === invocation &&
331
+ (phase === "failed" || phase === "failed_post")
332
+ ? (error as object)
333
+ : null;
334
+ },
335
+ consume(error: unknown) {
336
+ return consume(error, "read");
337
+ },
338
+ consumePost(error: unknown) {
339
+ return consume(error, "post");
340
+ },
341
+ });
342
+ })();
343
+ OWNER.check();
344
+ failureControl = control;
345
+ const reader = bindRawAcquisitionFromSource(
346
+ OWNER,
347
+ activePair.transport.readTransport,
348
+ );
349
+ OWNER.check();
350
+ let acquiredOnce = false;
351
+ const acquire = async () => {
352
+ OWNER.check();
353
+ if (acquiredOnce) stop();
354
+ acquiredOnce = true;
355
+ control.begin();
356
+ OWNER.check();
357
+ const result = await reader.acquire(prepared.expected);
358
+ OWNER.check();
359
+ if (result.ok) {
360
+ control.complete();
361
+ return result;
362
+ }
363
+ const token = control.takeReadFailure();
364
+ OWNER.check();
365
+ if (token !== null) throw token;
366
+ return result;
367
+ };
368
+ const acquired = await owned(acquire, control);
369
+ OWNER.check();
370
+ if (!acquired.ok) return refuse("current_read_unsupported");
371
+
372
+ const fresh = await owned(() =>
373
+ classifyOwnedInitialAttachment({
374
+ attachRequest: raw,
375
+ originalBundle: original.originalBundle,
376
+ currentBundle: acquired.bundle,
377
+ observedAt: acquired.observedAt,
378
+ }),
379
+ );
380
+ OWNER.check();
381
+ if (fresh.status !== "classified")
382
+ return refuse("fresh_material_unsupported");
383
+ const covered = Reflect.apply(entry.fresh, entry.raw, [
384
+ fresh.material,
385
+ original.originalBundle,
386
+ acquired.bundle,
387
+ ]);
388
+ OWNER.check();
389
+ if (covered !== true)
390
+ return refuse("same_entry_fresh_coverage_missing");
391
+ const material = closed(fresh.material, [
392
+ "classificationRevision",
393
+ "protocolRevision",
394
+ "stage",
395
+ "intent",
396
+ "scope",
397
+ "apiVersion",
398
+ "profile",
399
+ "quantity",
400
+ "currentPrice",
401
+ "targetPrice",
402
+ "source",
403
+ "nativeItem",
404
+ "billingCustomer",
405
+ "subscriptionDiscounts",
406
+ "itemDiscounts",
407
+ "settings",
408
+ "originalPrepared",
409
+ "completeRequest",
410
+ "stageEvidence",
411
+ "rawSources",
412
+ "freshness",
413
+ ]);
414
+ need(
415
+ material.classificationRevision === "renewal-material-v2" &&
416
+ material.protocolRevision === "renewal-stage-protocol-v1" &&
417
+ material.stage === "attach" &&
418
+ material.intent === "initial" &&
419
+ material.freshness === "fresh" &&
420
+ material.scope === request.scope &&
421
+ material.apiVersion === request.apiVersion,
422
+ );
423
+ need(
424
+ equal(material.originalPrepared, prepared) &&
425
+ equal(material.completeRequest, request),
426
+ );
427
+ need(
428
+ equal(material.rawSources, {
429
+ attachRequest: raw,
430
+ intent: "initial",
431
+ freshSubscription: acquired.bundle.wireSubscription,
432
+ targetPrice: acquired.bundle.wireTargetPrice,
433
+ billingCustomer: acquired.bundle.wireBillingCustomer,
434
+ observedAt: acquired.observedAt,
435
+ }),
436
+ );
437
+ OWNER.check();
438
+ closed(op.sink, ["send"]);
439
+ const send = sourceMethod(op.sink, "send");
440
+ const sourceSend = (record: unknown, ack: unknown) => {
441
+ OWNER.check();
442
+ return Reflect.apply(send, op.sink, [record, ack]);
443
+ };
444
+ const compiler = createAttachEventCompiler(raw, {
445
+ send: sourceSend,
446
+ timeoutMs: 5000,
447
+ });
448
+ OWNER.check();
449
+ await owned(() =>
450
+ compiler.dispatch({ event: "dispatch", stage: "attach", request }),
451
+ );
452
+ OWNER.check();
453
+ postEligible = true;
454
+ let postedOnce = false;
455
+ const post = async () => {
456
+ OWNER.check();
457
+ if (postedOnce) stop();
458
+ postedOnce = true;
459
+ control.beginPost();
460
+ OWNER.check();
461
+ const reply = await activePair.transport.postAttach();
462
+ OWNER.check();
463
+ const token = control.takePostFailure(reply);
464
+ OWNER.check();
465
+ if (token !== null) throw token;
466
+ return reply;
467
+ };
468
+ const reply = await owned(post, control);
469
+ OWNER.check();
470
+ if (reply.outcome === "not_started") return refuse("post_not_started");
471
+ if (reply.outcome === "provider_rejected") stop();
472
+ if (reply.outcome !== "fulfilled_safe") return uncertain();
473
+ const body = reply.body;
474
+ await owned(() =>
475
+ compiler.response({
476
+ event: "response",
477
+ stage: "attach",
478
+ request,
479
+ body,
480
+ status: reply.statusCode,
481
+ }),
482
+ );
483
+ OWNER.check();
484
+ const receipt = await owned(() =>
485
+ c3({
486
+ attachRequest: raw,
487
+ actualDispatch: seven(request),
488
+ providerSnapshot: body as Record<string, unknown>,
489
+ }),
490
+ );
491
+ OWNER.check();
492
+ await owned(() =>
493
+ compiler.receipt({
494
+ event: "receipt",
495
+ stage: "attach",
496
+ request,
497
+ receipt,
498
+ }),
499
+ );
500
+ OWNER.check();
501
+ const result = admitInitialOutput(receipt, prepared, request);
502
+ OWNER.check();
503
+ control.takePostQuarantine();
504
+ return result;
505
+ } catch (error) {
506
+ let live = false;
507
+ try {
508
+ OWNER.check();
509
+ live = true;
510
+ } catch {}
511
+ if (live && !postEligible && failureControl) {
512
+ const failure = failureControl.consume(error);
513
+ if (failure !== null) throw failure;
514
+ }
515
+ if (
516
+ live &&
517
+ postEligible &&
518
+ pair &&
519
+ failureControl &&
520
+ pair.transport.postDisposition() === "REJECTED"
521
+ ) {
522
+ const failure = failureControl.consumePost(error);
523
+ if (failure !== null) throw failure;
524
+ }
525
+ if (postEligible && pair) {
526
+ const state = pair.transport.postDisposition();
527
+ if (state === "FULFILLED_SAFE" || state === "FULFILLED_UNVERIFIED")
528
+ return uncertain();
529
+ if (state === "NOT_STARTED") return refuse("post_not_started");
530
+ }
531
+ return stop();
532
+ }
533
+ },
534
+ });
535
+ }
@@ -0,0 +1,63 @@
1
+ import { OWNER } from "../originalOwner.js";
2
+
3
+ export interface FailureForwarder {
4
+ forward(error: unknown): object | null;
5
+ }
6
+ /** Same original owner around each actor continuation; no new timer or origin. */
7
+ export function owned<T>(
8
+ work: () => T | PromiseLike<T>,
9
+ failureControl: FailureForwarder | null = null,
10
+ ): Promise<T> {
11
+ OWNER.check();
12
+ return new Promise((resolve, reject) => {
13
+ let done = false,
14
+ remove: (() => void) | null = null;
15
+ const finish = (ok: boolean, value: unknown) => {
16
+ if (done) return;
17
+ done = true;
18
+ if (remove) remove();
19
+ if (ok) resolve(value as T);
20
+ else reject(value);
21
+ };
22
+ const retire = () => finish(false, Error("INITIAL_ACTOR_STOP"));
23
+ remove = OWNER.subscribe(retire);
24
+ if (done) {
25
+ remove();
26
+ return;
27
+ }
28
+ let pending: T | PromiseLike<T>;
29
+ try {
30
+ OWNER.check();
31
+ pending = work();
32
+ } catch {
33
+ finish(false, Error("INITIAL_ACTOR_STOP"));
34
+ return;
35
+ }
36
+ void Promise.resolve(pending).then(
37
+ (value) => {
38
+ if (done) return;
39
+ try {
40
+ OWNER.check();
41
+ finish(true, value);
42
+ } catch {
43
+ retire();
44
+ }
45
+ },
46
+ (error: unknown) => {
47
+ if (done) return;
48
+ try {
49
+ OWNER.check();
50
+ const forwarded = failureControl
51
+ ? failureControl.forward(error)
52
+ : null;
53
+ finish(
54
+ false,
55
+ forwarded === null ? Error("INITIAL_ACTOR_STOP") : forwarded,
56
+ );
57
+ } catch {
58
+ retire();
59
+ }
60
+ },
61
+ );
62
+ });
63
+ }
@@ -0,0 +1,61 @@
1
+ import assert from "node:assert/strict";
2
+ import { it } from "vitest";
3
+ import { declaredInputs } from "../test-fixtures/attachEntries.js";
4
+ import { metrics, data } from "../test-fixtures/attachScenarioBarriers.js";
5
+ import {
6
+ prepareRenewalPriceReplacementV2,
7
+ prepareRenewalScheduleAttachmentV2,
8
+ constructRenewalScheduleAttachmentReceiptV2,
9
+ } from "../../../renewalV2/index.js";
10
+ import { admitInitialOutput } from "../recovery/material.js";
11
+
12
+ it("initial ACK whole DATA wrapper enforces exact receipt slots, bounds and freezing", async () => {
13
+ const raw = declaredInputs("INITIAL-ACK"),
14
+ prepared = await prepareRenewalPriceReplacementV2(
15
+ raw.original.attachRequest.preparation,
16
+ );
17
+ const request = await prepareRenewalScheduleAttachmentV2({
18
+ prepared,
19
+ apiVersion: raw.original.attachRequest.apiVersion,
20
+ attachKey: raw.original.attachRequest.attachKey,
21
+ firstDispatchedAt: raw.original.attachRequest.firstDispatchedAt,
22
+ });
23
+ const receipt = await constructRenewalScheduleAttachmentReceiptV2({
24
+ attachRequest: raw.original.attachRequest,
25
+ actualDispatch: {
26
+ scope: request.scope,
27
+ apiVersion: request.apiVersion,
28
+ method: request.method,
29
+ path: request.path,
30
+ payload: request.payload,
31
+ key: request.key,
32
+ firstDispatchedAt: request.firstDispatchedAt,
33
+ },
34
+ providerSnapshot: raw.post,
35
+ });
36
+ const admitted = admitInitialOutput(receipt, prepared, request);
37
+ assert(Object.isFrozen(admitted));
38
+ assert(Object.isFrozen(data(admitted).receipt));
39
+ const fit = metrics(admitted);
40
+ assert(
41
+ fit.chars <= 500000 &&
42
+ fit.bytes <= 500000 &&
43
+ fit.nodes <= 10000 &&
44
+ fit.depth <= 40,
45
+ );
46
+ // DATA-helper boundary only: a caller's extended receipt-shaped input is not C3 custody.
47
+ const overflow = { ...receipt, opaque: "x".repeat(500001) };
48
+ assert(
49
+ metrics({
50
+ status: "attach_acknowledged",
51
+ operationalAuthority: false,
52
+ receipt: overflow,
53
+ }).chars > 500000,
54
+ );
55
+ assert.throws(() => admitInitialOutput(overflow, prepared, request));
56
+ const wrong = {
57
+ ...receipt,
58
+ logicalBinding: "renewal:v2:sha256:" + "0".repeat(64),
59
+ };
60
+ assert.throws(() => admitInitialOutput(wrong, prepared, request));
61
+ });