@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,515 @@
1
+ import assert from "node:assert/strict";
2
+ import { vi } from "vitest";
3
+ import { data } from "./configurePreflightControls.js";
4
+ import type { configureWriteBarriers } from "./configureWriteBarriers.js";
5
+
6
+ export function writeObservationState() {
7
+ return {
8
+ phase: "prerequisite",
9
+ trace: [] as string[],
10
+ explicitC3: 0,
11
+ explicitC9: 0,
12
+ compilerC9: 0,
13
+ requests: [] as unknown[],
14
+ delegateArgs: [] as unknown[][],
15
+ replies: [] as unknown[],
16
+ originalPromises: [] as Promise<unknown>[],
17
+ records: [] as Record<string, unknown>[],
18
+ calls: [] as {
19
+ method: string;
20
+ path: string;
21
+ body: unknown;
22
+ key: string | null;
23
+ }[],
24
+ targetCalls: 0,
25
+ reserves: 0,
26
+ pairLoads: 0,
27
+ sourceLoads: 0,
28
+ coverage: 0,
29
+ traps: 0,
30
+ finalAdmission: 0,
31
+ failed: undefined as unknown,
32
+ };
33
+ }
34
+ export type WriteObservations = ReturnType<typeof writeObservationState>;
35
+
36
+ /** Writer TEST phase only: preserve selected factory wrappers and original pair identities. */
37
+ async function installWriteReadBinding() {
38
+ const selected = await import("../configure/transport.js");
39
+ const readers = new WeakSet<object>();
40
+ vi.doMock("../configure/transport.js", () => ({
41
+ ...selected,
42
+ createConfigureWriteTransport(
43
+ this: unknown,
44
+ ...args: Parameters<typeof selected.createConfigureWriteTransport>
45
+ ) {
46
+ const pair = Reflect.apply(
47
+ selected.createConfigureWriteTransport,
48
+ this,
49
+ args,
50
+ ) as ReturnType<typeof selected.createConfigureWriteTransport>;
51
+ readers.add(pair.transport.readTransport);
52
+ return pair;
53
+ },
54
+ createConfigureReplayTransport(
55
+ this: unknown,
56
+ ...args: Parameters<typeof selected.createConfigureReplayTransport>
57
+ ) {
58
+ const pair = Reflect.apply(
59
+ selected.createConfigureReplayTransport,
60
+ this,
61
+ args,
62
+ ) as ReturnType<typeof selected.createConfigureReplayTransport>;
63
+ readers.add(pair.transport.readTransport);
64
+ return pair;
65
+ },
66
+ }));
67
+ vi.doMock("../acquisition/ownedAcquisition.js", async () => {
68
+ const actual = await vi.importActual<
69
+ typeof import("../acquisition/ownedAcquisition.js")
70
+ >("../acquisition/ownedAcquisition.js");
71
+ return {
72
+ ...actual,
73
+ bindConfigureReadAcquisitionFromSource(
74
+ this: unknown,
75
+ ...args: Parameters<
76
+ typeof actual.bindConfigureReadAcquisitionFromSource
77
+ >
78
+ ) {
79
+ assert(readers.has(args[1]), "WRITER_TEST_PAIR_IDENTITY");
80
+ return Reflect.apply(
81
+ actual.bindConfigureReadAcquisitionFromSource,
82
+ this,
83
+ args,
84
+ ) as ReturnType<typeof actual.bindConfigureReadAcquisitionFromSource>;
85
+ },
86
+ };
87
+ });
88
+ }
89
+
90
+ export async function installWriteAPIObservers(
91
+ current: () => WriteObservations,
92
+ gates: ReturnType<typeof configureWriteBarriers>,
93
+ ) {
94
+ const actual = await vi.importActual<
95
+ typeof import("../../../renewalV2/index.js")
96
+ >("../../../renewalV2/index.js");
97
+ const observe = <T>(promise: Promise<T>, action: (value: T) => void) => {
98
+ current().originalPromises.push(promise);
99
+ gates.pending.push(promise.then(action, () => {}));
100
+ return promise;
101
+ };
102
+ const publicAPI = {
103
+ ...actual,
104
+ projectRenewalConfigurationV2(
105
+ ...args: Parameters<typeof actual.projectRenewalConfigurationV2>
106
+ ) {
107
+ const s = current();
108
+ s.trace.push("explicit:C6");
109
+ return observe(
110
+ Reflect.apply(actual.projectRenewalConfigurationV2, actual, args),
111
+ (value) => {
112
+ s.requests.push(value);
113
+ },
114
+ );
115
+ },
116
+ constructRenewalScheduleAttachmentReceiptV2(
117
+ this: unknown,
118
+ ...args: Parameters<
119
+ typeof actual.constructRenewalScheduleAttachmentReceiptV2
120
+ >
121
+ ) {
122
+ const state = current();
123
+ state.explicitC3++;
124
+ const promise = Reflect.apply(
125
+ actual.constructRenewalScheduleAttachmentReceiptV2,
126
+ this,
127
+ args,
128
+ ) as ReturnType<
129
+ typeof actual.constructRenewalScheduleAttachmentReceiptV2
130
+ >;
131
+ return observe(promise, () => {});
132
+ },
133
+ constructRenewalConfigurationReceiptV2(
134
+ ...args: Parameters<typeof actual.constructRenewalConfigurationReceiptV2>
135
+ ) {
136
+ const s = current();
137
+ s.explicitC9++;
138
+ s.trace.push("explicit:C9");
139
+ return observe(
140
+ Reflect.apply(
141
+ actual.constructRenewalConfigurationReceiptV2,
142
+ actual,
143
+ args,
144
+ ),
145
+ (value) => {
146
+ s.replies.push(value);
147
+ },
148
+ );
149
+ },
150
+ };
151
+ vi.doMock("../../../renewalV2/index.js", () => publicAPI);
152
+ vi.doMock("../c10/publicApi.js", () => ({
153
+ ...actual,
154
+ constructRenewalConfigurationReceiptV2(
155
+ ...args: Parameters<typeof actual.constructRenewalConfigurationReceiptV2>
156
+ ) {
157
+ const s = current();
158
+ s.compilerC9++;
159
+ s.trace.push("compiler:C9");
160
+ return observe(
161
+ Reflect.apply(
162
+ actual.constructRenewalConfigurationReceiptV2,
163
+ actual,
164
+ args,
165
+ ),
166
+ () => {},
167
+ );
168
+ },
169
+ }));
170
+ await installWriteReadBinding();
171
+ return actual;
172
+ }
173
+
174
+ export function assertActualWriteCounters(s: WriteObservations) {
175
+ assert.equal(s.targetCalls, 1);
176
+ assert.equal(s.reserves, 1);
177
+ assert.equal(s.pairLoads, 1);
178
+ assert.equal(s.calls.filter((r) => r.method === "POST").length, 1);
179
+ assert.equal(s.explicitC9, 1);
180
+ assert.equal(s.compilerC9, 1);
181
+ assert.equal(s.records.length, 3);
182
+ assert.deepEqual(
183
+ s.records.map((v) => data(v.data).event),
184
+ ["dispatch", "response", "receipt"],
185
+ );
186
+ }
187
+
188
+ /** Selected positive TEST diagnostics only: no original ENTRY or Source frame is replaced. */
189
+ export function writerFrontierDiagnostics() {
190
+ let retainedStats:
191
+ | ReturnType<typeof import("./attachEntries.js").declaredEntries>["stats"]
192
+ | null = null;
193
+ const counts = {
194
+ entryFactories: 0,
195
+ retainedClassifiers: 0,
196
+ retainedRejected: 0,
197
+ compilerEntered: 0,
198
+ compilerReturned: 0,
199
+ dispatch: 0,
200
+ response: 0,
201
+ receipt: 0,
202
+ c10Fulfilled: 0,
203
+ c10Rejected: 0,
204
+ requestCaptureEntered: 0,
205
+ requestCaptureReturned: 0,
206
+ requestCaptureThrew: 0,
207
+ planCaptureEntered: 0,
208
+ planCaptureReturned: 0,
209
+ planCaptureThrew: 0,
210
+ expectedPlanEntered: 0,
211
+ expectedPlanReturned: 0,
212
+ expectedPlanThrew: 0,
213
+ factoryEntered: 0,
214
+ factoryReturned: 0,
215
+ factoryThrew: 0,
216
+ };
217
+ const retainedStatuses: string[] = [];
218
+ const pending: Promise<unknown>[] = [];
219
+ const samePlanResults: boolean[] = [];
220
+ vi.doMock("../configure/output.js", async () => {
221
+ const actual = await vi.importActual<
222
+ typeof import("../configure/output.js")
223
+ >("../configure/output.js");
224
+ return {
225
+ ...actual,
226
+ captureConfigureRequest(
227
+ this: unknown,
228
+ ...args: Parameters<typeof actual.captureConfigureRequest>
229
+ ) {
230
+ counts.requestCaptureEntered++;
231
+ try {
232
+ const result = Reflect.apply(
233
+ actual.captureConfigureRequest,
234
+ this,
235
+ args,
236
+ ) as ReturnType<typeof actual.captureConfigureRequest>;
237
+ counts.requestCaptureReturned++;
238
+ return result;
239
+ } catch (error) {
240
+ counts.requestCaptureThrew++;
241
+ throw error;
242
+ }
243
+ },
244
+ };
245
+ });
246
+ vi.doMock("../configure/request.js", async () => {
247
+ const actual = await vi.importActual<
248
+ typeof import("../configure/request.js")
249
+ >("../configure/request.js");
250
+ return {
251
+ ...actual,
252
+ capturePlan(
253
+ this: unknown,
254
+ ...args: Parameters<typeof actual.capturePlan>
255
+ ) {
256
+ counts.planCaptureEntered++;
257
+ try {
258
+ const result = Reflect.apply(
259
+ actual.capturePlan,
260
+ this,
261
+ args,
262
+ ) as ReturnType<typeof actual.capturePlan>;
263
+ counts.planCaptureReturned++;
264
+ return result;
265
+ } catch (error) {
266
+ counts.planCaptureThrew++;
267
+ throw error;
268
+ }
269
+ },
270
+ expectedPlan(
271
+ this: unknown,
272
+ ...args: Parameters<typeof actual.expectedPlan>
273
+ ) {
274
+ counts.expectedPlanEntered++;
275
+ try {
276
+ const result = Reflect.apply(
277
+ actual.expectedPlan,
278
+ this,
279
+ args,
280
+ ) as ReturnType<typeof actual.expectedPlan>;
281
+ counts.expectedPlanReturned++;
282
+ return result;
283
+ } catch (error) {
284
+ counts.expectedPlanThrew++;
285
+ throw error;
286
+ }
287
+ },
288
+ samePlan(this: unknown, ...args: Parameters<typeof actual.samePlan>) {
289
+ const result = Reflect.apply(actual.samePlan, this, args) as ReturnType<
290
+ typeof actual.samePlan
291
+ >;
292
+ samePlanResults.push(result);
293
+ return result;
294
+ },
295
+ };
296
+ });
297
+ vi.doMock("../configure/transport.js", async () => {
298
+ const actual = await vi.importActual<
299
+ typeof import("../configure/transport.js")
300
+ >("../configure/transport.js");
301
+ return {
302
+ ...actual,
303
+ createConfigureWriteTransport(
304
+ this: unknown,
305
+ ...args: Parameters<typeof actual.createConfigureWriteTransport>
306
+ ) {
307
+ counts.factoryEntered++;
308
+ try {
309
+ const pair = Reflect.apply(
310
+ actual.createConfigureWriteTransport,
311
+ this,
312
+ args,
313
+ ) as ReturnType<typeof actual.createConfigureWriteTransport>;
314
+ counts.factoryReturned++;
315
+ return pair;
316
+ } catch (error) {
317
+ counts.factoryThrew++;
318
+ throw error;
319
+ }
320
+ },
321
+ createConfigureReplayTransport(
322
+ this: unknown,
323
+ ...args: Parameters<typeof actual.createConfigureReplayTransport>
324
+ ) {
325
+ counts.factoryEntered++;
326
+ try {
327
+ const pair = Reflect.apply(
328
+ actual.createConfigureReplayTransport,
329
+ this,
330
+ args,
331
+ ) as ReturnType<typeof actual.createConfigureReplayTransport>;
332
+ counts.factoryReturned++;
333
+ return pair;
334
+ } catch (error) {
335
+ counts.factoryThrew++;
336
+ throw error;
337
+ }
338
+ },
339
+ };
340
+ });
341
+ vi.doMock("./attachEntries.js", async () => {
342
+ const actual =
343
+ await vi.importActual<typeof import("./attachEntries.js")>(
344
+ "./attachEntries.js",
345
+ );
346
+ return {
347
+ ...actual,
348
+ declaredEntries(
349
+ this: unknown,
350
+ ...args: Parameters<typeof actual.declaredEntries>
351
+ ) {
352
+ counts.entryFactories++;
353
+ const result = Reflect.apply(
354
+ actual.declaredEntries,
355
+ this,
356
+ args,
357
+ ) as ReturnType<typeof actual.declaredEntries>;
358
+ retainedStats = result.stats;
359
+ return result;
360
+ },
361
+ };
362
+ });
363
+ vi.doMock("../material/classifiers.js", async () => {
364
+ const actual = await vi.importActual<
365
+ typeof import("../material/classifiers.js")
366
+ >("../material/classifiers.js");
367
+ return {
368
+ ...actual,
369
+ classifyOwnedRetainedInitialAttachment(
370
+ this: unknown,
371
+ ...args: Parameters<
372
+ typeof actual.classifyOwnedRetainedInitialAttachment
373
+ >
374
+ ) {
375
+ counts.retainedClassifiers++;
376
+ const promise = Reflect.apply(
377
+ actual.classifyOwnedRetainedInitialAttachment,
378
+ this,
379
+ args,
380
+ ) as ReturnType<typeof actual.classifyOwnedRetainedInitialAttachment>;
381
+ pending.push(
382
+ promise.then(
383
+ (value) => {
384
+ retainedStatuses.push(value.status);
385
+ },
386
+ () => {
387
+ counts.retainedRejected++;
388
+ },
389
+ ),
390
+ );
391
+ return promise;
392
+ },
393
+ };
394
+ });
395
+ vi.doMock("../c10/configureEvents.js", async () => {
396
+ const actual = await vi.importActual<
397
+ typeof import("../c10/configureEvents.js")
398
+ >("../c10/configureEvents.js");
399
+ return {
400
+ ...actual,
401
+ createConfigureEventCompiler(
402
+ this: unknown,
403
+ ...args: Parameters<typeof actual.createConfigureEventCompiler>
404
+ ) {
405
+ counts.compilerEntered++;
406
+ const compiler = Reflect.apply(
407
+ actual.createConfigureEventCompiler,
408
+ this,
409
+ args,
410
+ ) as ReturnType<typeof actual.createConfigureEventCompiler>;
411
+ counts.compilerReturned++;
412
+ const observe = <T>(promise: Promise<T>) => {
413
+ pending.push(
414
+ promise.then(
415
+ () => {
416
+ counts.c10Fulfilled++;
417
+ },
418
+ () => {
419
+ counts.c10Rejected++;
420
+ },
421
+ ),
422
+ );
423
+ return promise;
424
+ };
425
+ return Object.freeze({
426
+ ...compiler,
427
+ dispatch(...args: Parameters<typeof compiler.dispatch>) {
428
+ counts.dispatch++;
429
+ return observe(
430
+ Reflect.apply(compiler.dispatch, compiler, args) as ReturnType<
431
+ typeof compiler.dispatch
432
+ >,
433
+ );
434
+ },
435
+ response(...args: Parameters<typeof compiler.response>) {
436
+ counts.response++;
437
+ return observe(
438
+ Reflect.apply(compiler.response, compiler, args) as ReturnType<
439
+ typeof compiler.response
440
+ >,
441
+ );
442
+ },
443
+ receipt(...args: Parameters<typeof compiler.receipt>) {
444
+ counts.receipt++;
445
+ return observe(
446
+ Reflect.apply(compiler.receipt, compiler, args) as ReturnType<
447
+ typeof compiler.receipt
448
+ >,
449
+ );
450
+ },
451
+ });
452
+ },
453
+ };
454
+ });
455
+ return Object.freeze({
456
+ log(
457
+ state: WriteObservations | undefined,
458
+ preflightReaderBindings?: number,
459
+ ) {
460
+ const statuses =
461
+ state?.requests.map((value) => {
462
+ if (value === null || typeof value !== "object") return "non-object";
463
+ const descriptor = Object.getOwnPropertyDescriptor(value, "status");
464
+ return descriptor &&
465
+ "value" in descriptor &&
466
+ typeof descriptor.value === "string" &&
467
+ descriptor.value.length <= 64
468
+ ? descriptor.value
469
+ : "other";
470
+ }) ?? null;
471
+ const last = retainedStats?.lastRetainedResult;
472
+ console.log(
473
+ JSON.stringify({
474
+ kind: "WRITER_PREDISPATCH_FRONTIER_DIAGNOSTIC",
475
+ sourceLoads: state?.sourceLoads ?? null,
476
+ C6:
477
+ state?.trace.filter((value) => value === "explicit:C6").length ??
478
+ null,
479
+ C6Statuses: statuses,
480
+ C3: state?.explicitC3 ?? null,
481
+ pairLoads: state?.pairLoads ?? null,
482
+ reserves: state?.reserves ?? null,
483
+ GETs:
484
+ state?.calls.filter((value) => value.method === "GET").length ??
485
+ null,
486
+ POSTs:
487
+ state?.calls.filter((value) => value.method === "POST").length ??
488
+ null,
489
+ coverage: state?.coverage ?? null,
490
+ records: state?.records.length ?? null,
491
+ retainedCalls: retainedStats?.retainedCalls ?? null,
492
+ retainedMatches: retainedStats?.retainedMatches ?? null,
493
+ retainedResult:
494
+ last === true || last === false || last === 1 || last === null
495
+ ? last
496
+ : "other",
497
+ retainedStatuses,
498
+ preflightReaderBindings: preflightReaderBindings ?? null,
499
+ samePlanResults,
500
+ counts,
501
+ SourceLoadsCountSuccessfulBoundLookupOnly: true,
502
+ }),
503
+ );
504
+ },
505
+ async cleanup() {
506
+ await Promise.allSettled(pending);
507
+ vi.doUnmock("./attachEntries.js");
508
+ vi.doUnmock("../material/classifiers.js");
509
+ vi.doUnmock("../c10/configureEvents.js");
510
+ vi.doUnmock("../configure/output.js");
511
+ vi.doUnmock("../configure/request.js");
512
+ vi.doUnmock("../configure/transport.js");
513
+ },
514
+ });
515
+ }