@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,487 @@
1
+ import { types } from "node:util";
2
+ import { OWNER as ORIGINAL_OWNER } from "../originalOwner.js";
3
+ import {
4
+ ORIGINAL_ORIGIN_ASSOCIATION,
5
+ COMPILED_INITIAL_ENTRIES,
6
+ COMPILED_OBSERVATION_ENTRIES,
7
+ loadFixedObservationOperation,
8
+ } from "../operations/sourceOperations.js";
9
+ import {
10
+ projectRenewalConfigurationV2,
11
+ constructRenewalScheduleAttachmentReceiptV2,
12
+ constructRenewalConfigurationReceiptV2,
13
+ } from "../../../renewalV2/index.js";
14
+ import { inspectRenewalScheduleMaterialV2 } from "../../../renewalV2/observation.js";
15
+ import { captureObservationRecord, verifyObservationRecord } from "./record.js";
16
+ import {
17
+ captureObservationReply,
18
+ captureObservationInput,
19
+ admitObservationOutput,
20
+ safeReadDiagnostics,
21
+ } from "./capture.js";
22
+ import {
23
+ baseReadRows,
24
+ validateBaseRouting,
25
+ observationCouponIds,
26
+ couponReadRow,
27
+ validateCoupon,
28
+ } from "./profile.js";
29
+ import { checkOwnerResult } from "./types.js";
30
+ import { admitRetainedConfigureAcknowledgement } from "./configureAcknowledgement.js";
31
+ import type {
32
+ Data,
33
+ SourceMethod,
34
+ ReadFailure,
35
+ Attempt,
36
+ StoredReadFailure,
37
+ ObservationReadRow,
38
+ ObservationReads,
39
+ } from "./types.js";
40
+ const stop = (): never => {
41
+ throw Error("OWNED_OBSERVATION_STOP");
42
+ };
43
+ const need: (value: unknown) => asserts value = (value) => {
44
+ if (!value) stop();
45
+ };
46
+ function object(value: unknown): Data {
47
+ need(
48
+ value !== null &&
49
+ typeof value === "object" &&
50
+ !types.isProxy(value) &&
51
+ !Array.isArray(value),
52
+ );
53
+ const proto = Object.getPrototypeOf(value);
54
+ need(proto === Object.prototype || proto === null);
55
+ return value as Data;
56
+ }
57
+ function field(value: unknown, key: string): unknown {
58
+ object(value);
59
+ const d = Object.getOwnPropertyDescriptor(value, key);
60
+ need(d && d.enumerable && "value" in d);
61
+ return d.value;
62
+ }
63
+ function closed(
64
+ value: unknown,
65
+ required: readonly string[],
66
+ optional: readonly string[] = [],
67
+ ): Data {
68
+ object(value);
69
+ const keys = Reflect.ownKeys(value as object);
70
+ need(
71
+ required.every((k) => keys.includes(k)) &&
72
+ keys.every(
73
+ (k) => typeof k === "string" && [...required, ...optional].includes(k),
74
+ ),
75
+ );
76
+ const out: Data = Object.create(null);
77
+ for (const key of keys)
78
+ Object.defineProperty(out, key, {
79
+ value: field(value, key as string),
80
+ enumerable: true,
81
+ });
82
+ return out;
83
+ }
84
+ function method(value: unknown, key: string): SourceMethod {
85
+ const fn = field(value, key);
86
+ need(typeof fn === "function" && !types.isProxy(fn));
87
+ return fn as SourceMethod;
88
+ }
89
+ function providerError(failure: ReadFailure) {
90
+ const error = Error("OWNED_OBSERVATION_PROVIDER_REJECTED");
91
+ Object.defineProperty(error, "failure", {
92
+ value: failure,
93
+ enumerable: false,
94
+ writable: false,
95
+ configurable: false,
96
+ });
97
+ return error;
98
+ }
99
+ export function captureOwnedRenewalObservationV2() {
100
+ if (arguments.length !== 0) throw Error("OWNED_OBSERVATION_ARITY");
101
+ let used = false;
102
+ return Object.freeze({
103
+ async invoke() {
104
+ if (arguments.length !== 0 || used) throw Error("OWNED_OBSERVATION_ONCE");
105
+ used = true;
106
+ if (COMPILED_OBSERVATION_ENTRIES.length === 0) {
107
+ return Object.freeze({
108
+ status: "not_dispatched",
109
+ reason: "OWNED_OBSERVATION_SOURCE_UNBOUND",
110
+ operationalAuthority: false,
111
+ });
112
+ }
113
+ // Fixed Source, never an input parameter or selected caller context.
114
+ const OWNER = ORIGINAL_OWNER,
115
+ check = method(OWNER, "check");
116
+ function ownerCheck() {
117
+ const sample: unknown = Reflect.apply(check, OWNER, []);
118
+ checkOwnerResult(sample);
119
+ return sample;
120
+ }
121
+ async function owned<T>(call: () => T | PromiseLike<T>): Promise<T> {
122
+ ownerCheck();
123
+ let value: T;
124
+ try {
125
+ value = await call();
126
+ } catch (error) {
127
+ ownerCheck();
128
+ throw error;
129
+ }
130
+ ownerCheck();
131
+ return value;
132
+ }
133
+ ownerCheck();
134
+ let raw: unknown;
135
+ try {
136
+ raw = loadFixedObservationOperation();
137
+ } catch {
138
+ ownerCheck();
139
+ stop();
140
+ }
141
+ ownerCheck();
142
+ const op = closed(
143
+ raw,
144
+ [
145
+ "owner",
146
+ "originAssociation",
147
+ "originalEntry",
148
+ "observationEntry",
149
+ "record",
150
+ "actualAttachAcknowledgement",
151
+ "readTransport",
152
+ ],
153
+ ["configureAcknowledgement", "configureOperation"],
154
+ );
155
+ need(op.owner === OWNER && OWNER === ORIGINAL_OWNER);
156
+ need(op.originAssociation === ORIGINAL_ORIGIN_ASSOCIATION);
157
+ object(op.originAssociation);
158
+ need(
159
+ COMPILED_INITIAL_ENTRIES.includes(op.originalEntry) &&
160
+ COMPILED_OBSERVATION_ENTRIES.includes(op.observationEntry),
161
+ );
162
+ need(field(op.observationEntry, "originalEntry") === op.originalEntry);
163
+ const hasConfigureAcknowledgement = Object.prototype.hasOwnProperty.call(
164
+ op,
165
+ "configureAcknowledgement",
166
+ );
167
+ need(
168
+ hasConfigureAcknowledgement ===
169
+ Object.prototype.hasOwnProperty.call(op, "configureOperation"),
170
+ );
171
+ const coversRetained = method(op.originalEntry, "coversRetained");
172
+ const coversObservation = method(
173
+ op.observationEntry,
174
+ "coversObservation",
175
+ );
176
+ closed(op.record, [
177
+ "configuration",
178
+ "request",
179
+ "attachReceipt",
180
+ "originalBundle",
181
+ ]);
182
+ need(
183
+ field(op.record, "attachReceipt") === op.actualAttachAcknowledgement,
184
+ );
185
+ object(op.actualAttachAcknowledgement);
186
+ const delegate = op.readTransport;
187
+ closed(delegate, ["rawRequest"]);
188
+ const send = method(delegate, "rawRequest");
189
+ const captured = captureObservationRecord(op.record),
190
+ record = captured.record;
191
+ ownerCheck();
192
+ let phase = "original-C6";
193
+ let invocation: object | null = null,
194
+ generation: object | null = null,
195
+ tokens: WeakMap<object, StoredReadFailure> | null = null,
196
+ tokenSlot: object | null = null,
197
+ lastRejected: Attempt | null = null;
198
+ let pending: Attempt | null = null;
199
+ let ordinal = 0,
200
+ readerState: string = "unused",
201
+ readState: string = "not_started";
202
+ function consume(token: unknown): ReadFailure | null {
203
+ ownerCheck();
204
+ if (tokens === null || token === null || typeof token !== "object")
205
+ return null;
206
+ const stored = tokens.get(token);
207
+ if (
208
+ !stored ||
209
+ stored.invocation !== invocation ||
210
+ stored.generation !== generation ||
211
+ stored.attempt !== lastRejected ||
212
+ readState !== "actual_rejected" ||
213
+ pending !== null
214
+ )
215
+ return null;
216
+ tokens.delete(token);
217
+ return Object.freeze({
218
+ category: "provider_rejected",
219
+ phase: "read",
220
+ resource: stored.attempt.resource,
221
+ ordinal: stored.attempt.ordinal,
222
+ request: stored.attempt.request,
223
+ diagnostics: stored.diagnostics,
224
+ outcome: "unknown",
225
+ operationalAuthority: false,
226
+ });
227
+ }
228
+ function takeReadFailure() {
229
+ ownerCheck();
230
+ const token = tokenSlot;
231
+ if (token === null || tokens === null) return null;
232
+ const stored = tokens.get(token);
233
+ if (
234
+ !stored ||
235
+ stored.invocation !== invocation ||
236
+ stored.generation !== generation ||
237
+ stored.attempt !== lastRejected ||
238
+ readState !== "actual_rejected" ||
239
+ pending !== null
240
+ )
241
+ return null;
242
+ tokenSlot = null;
243
+ return token;
244
+ }
245
+ async function read(row: ObservationReadRow) {
246
+ ownerCheck();
247
+ need(
248
+ readerState === "running" &&
249
+ pending === null &&
250
+ readState !== "actual_rejected" &&
251
+ ordinal < 44,
252
+ );
253
+ need(
254
+ row.ordinal === ordinal + 1 &&
255
+ row.method === "GET" &&
256
+ row.body === undefined &&
257
+ row.options.apiVersion === "2026-09-30.endive" &&
258
+ row.options.maxNetworkRetries === 0,
259
+ );
260
+ const request = Object.freeze({
261
+ method: "GET",
262
+ path: row.path,
263
+ apiVersion: row.options.apiVersion,
264
+ });
265
+ const attempt: Attempt = {
266
+ invocation,
267
+ generation,
268
+ resource: row.resource,
269
+ ordinal: ++ordinal,
270
+ request,
271
+ promise: null,
272
+ };
273
+ pending = attempt;
274
+ readState = "pending";
275
+ let promise: unknown;
276
+ try {
277
+ promise = Reflect.apply(send, delegate, [
278
+ "GET",
279
+ row.path,
280
+ undefined,
281
+ row.options,
282
+ ]);
283
+ } catch {
284
+ ownerCheck();
285
+ pending = null;
286
+ readerState = "failed";
287
+ stop();
288
+ }
289
+ attempt.promise = promise;
290
+ Object.freeze(attempt);
291
+ let reply: unknown;
292
+ try {
293
+ reply = await promise;
294
+ } catch (error) {
295
+ ownerCheck();
296
+ need(
297
+ pending === attempt &&
298
+ attempt.invocation === invocation &&
299
+ attempt.generation === generation &&
300
+ attempt.promise === promise,
301
+ );
302
+ readState = "actual_rejected";
303
+ readerState = "failed";
304
+ pending = null;
305
+ lastRejected = attempt;
306
+ const diagnostics = safeReadDiagnostics(error),
307
+ token = Object.freeze(Object.create(null));
308
+ need(tokens !== null);
309
+ tokens.set(
310
+ token,
311
+ Object.freeze({ invocation, generation, attempt, diagnostics }),
312
+ );
313
+ tokenSlot = token;
314
+ const forwarded = takeReadFailure();
315
+ need(forwarded === token);
316
+ throw forwarded;
317
+ }
318
+ ownerCheck();
319
+ need(
320
+ pending === attempt &&
321
+ attempt.invocation === invocation &&
322
+ attempt.generation === generation &&
323
+ attempt.promise === promise,
324
+ );
325
+ pending = null;
326
+ readState = "actual_fulfilled";
327
+ const body = captureObservationReply(reply);
328
+ ownerCheck();
329
+ return body;
330
+ }
331
+ try {
332
+ const desired = await owned(() =>
333
+ projectRenewalConfigurationV2(record.configuration),
334
+ );
335
+ ownerCheck();
336
+ if (desired.status !== "projected_configure_request") return desired;
337
+ phase = "proof";
338
+ const receipt = await owned(() =>
339
+ constructRenewalScheduleAttachmentReceiptV2(
340
+ record.configuration.attachReceipt,
341
+ ),
342
+ );
343
+ ownerCheck();
344
+ verifyObservationRecord(captured, desired, receipt);
345
+ ownerCheck();
346
+ const retainedModule = await import("../material/classifiers.js");
347
+ ownerCheck();
348
+ // Fixed internal package code; module exports may be native DATA or SSR accessors.
349
+ const classifyRetained =
350
+ retainedModule.classifyOwnedRetainedInitialAttachment;
351
+ ownerCheck();
352
+ need(
353
+ typeof classifyRetained === "function" &&
354
+ !types.isProxy(classifyRetained),
355
+ );
356
+ const retained = await owned(
357
+ (): ReturnType<
358
+ typeof retainedModule.classifyOwnedRetainedInitialAttachment
359
+ > =>
360
+ Reflect.apply(classifyRetained, retainedModule, [
361
+ {
362
+ attachRequest: record.configuration.attachReceipt.attachRequest,
363
+ originalBundle: record.originalBundle,
364
+ },
365
+ ]),
366
+ );
367
+ ownerCheck();
368
+ need(retained.status === "classified");
369
+ const covered = Reflect.apply(coversRetained, op.originalEntry, [
370
+ retained.material,
371
+ record.originalBundle,
372
+ ]);
373
+ ownerCheck();
374
+ need(covered === true);
375
+ let configureReceipt:
376
+ | import("../../../renewalV2/index.js").ConstructRenewalConfigurationReceiptV2Options
377
+ | undefined;
378
+ if (hasConfigureAcknowledgement) {
379
+ const writer = await owned(() => import("../configure/actor.js"));
380
+ ownerCheck();
381
+ const readOwnedConfigureAcknowledgement =
382
+ writer.readOwnedConfigureAcknowledgement;
383
+ ownerCheck();
384
+ need(
385
+ typeof readOwnedConfigureAcknowledgement === "function" &&
386
+ !types.isProxy(readOwnedConfigureAcknowledgement),
387
+ );
388
+ const retainedACK = readOwnedConfigureAcknowledgement(
389
+ op.configureOperation,
390
+ op.configureAcknowledgement,
391
+ record,
392
+ op.actualAttachAcknowledgement,
393
+ op.originAssociation,
394
+ op.originalEntry,
395
+ );
396
+ ownerCheck();
397
+ const configured = await owned(() =>
398
+ constructRenewalConfigurationReceiptV2(retainedACK.rawReceipt),
399
+ );
400
+ ownerCheck();
401
+ configureReceipt = admitRetainedConfigureAcknowledgement(
402
+ record,
403
+ retainedACK,
404
+ configured,
405
+ );
406
+ ownerCheck();
407
+ }
408
+ // New child/channel identity is allocated only after all original proof work.
409
+ invocation = Object.freeze({});
410
+ generation = Object.freeze({});
411
+ tokens = new WeakMap();
412
+ need(readerState === "unused" && ordinal === 0 && pending === null);
413
+ readerState = "running";
414
+ const rows = baseReadRows(record),
415
+ base: unknown[] = [];
416
+ for (const row of rows) {
417
+ const body = await owned(() => read(row));
418
+ ownerCheck();
419
+ base.push(body);
420
+ }
421
+ const reads: ObservationReads = {
422
+ schedule: base[0],
423
+ subscription: base[1],
424
+ targetPrice: base[2],
425
+ billingCustomer: base[3],
426
+ coupons: [],
427
+ };
428
+ validateBaseRouting(record, reads);
429
+ const couponIds = observationCouponIds(record, reads.subscription);
430
+ let finalSample = ownerCheck();
431
+ for (const id of couponIds) {
432
+ const body = await owned(() => read(couponReadRow(id, ordinal + 1)));
433
+ ownerCheck();
434
+ validateCoupon(record, id, body);
435
+ finalSample = ownerCheck();
436
+ reads.coupons.push(body);
437
+ }
438
+ need(
439
+ pending === null && ordinal === 4 + couponIds.length && ordinal <= 44,
440
+ );
441
+ const observedAt = Math.floor(finalSample.wallMs / 1000);
442
+ need(Number.isSafeInteger(observedAt) && observedAt >= 0);
443
+ readerState = "closed";
444
+ readState = "closed";
445
+ const input = captureObservationInput({
446
+ configuration: record.configuration,
447
+ reads,
448
+ ...(configureReceipt === undefined ? {} : { configureReceipt }),
449
+ });
450
+ phase = "observer";
451
+ const observation = await owned(() =>
452
+ inspectRenewalScheduleMaterialV2(input),
453
+ );
454
+ ownerCheck();
455
+ const complete = Reflect.apply(coversObservation, op.observationEntry, [
456
+ record,
457
+ input,
458
+ observation,
459
+ ]);
460
+ ownerCheck();
461
+ need(complete === true);
462
+ const output = admitObservationOutput({
463
+ status: "owned_observation_data",
464
+ observation,
465
+ reads: input.reads,
466
+ observedAt,
467
+ retainedConfigureAcknowledgement: hasConfigureAcknowledgement
468
+ ? "present"
469
+ : "absent",
470
+ operationalAuthority: false,
471
+ });
472
+ ownerCheck();
473
+ return output;
474
+ } catch (error) {
475
+ ownerCheck();
476
+ if (phase === "original-C6") throw error;
477
+ const failure = consume(error);
478
+ if (failure !== null) {
479
+ const outward = providerError(failure);
480
+ ownerCheck();
481
+ throw outward;
482
+ }
483
+ stop();
484
+ }
485
+ },
486
+ });
487
+ }