@fantastic.dev/better-stripe 0.90.0 → 0.91.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 (216) hide show
  1. package/CHANGELOG.md +6 -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 +8 -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 +454 -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/replay.d.ts +3 -0
  29. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
  30. package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
  31. package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
  32. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
  33. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
  34. package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
  35. package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
  36. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
  37. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
  38. package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
  39. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
  40. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
  41. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
  42. package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
  43. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
  44. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
  45. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
  46. package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
  47. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
  48. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
  49. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
  50. package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
  51. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
  52. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
  53. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
  54. package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
  55. package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
  56. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
  57. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
  58. package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
  59. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
  60. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
  61. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
  62. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
  63. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
  64. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
  65. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
  66. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
  67. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
  68. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
  69. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
  70. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
  71. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
  72. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
  73. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
  74. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
  75. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
  76. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
  77. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
  78. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
  79. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
  80. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
  81. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
  82. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
  83. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
  84. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
  85. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
  86. package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
  87. package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
  88. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
  89. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
  90. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
  91. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
  92. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
  93. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
  94. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
  95. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
  96. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
  97. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
  98. package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
  99. package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
  100. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
  101. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
  102. package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
  103. package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
  104. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
  105. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
  106. package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
  107. package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
  108. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
  109. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
  110. package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
  111. package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
  112. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
  113. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
  114. package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
  115. package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
  116. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
  117. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
  118. package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
  119. package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
  120. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
  121. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
  122. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
  123. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
  124. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
  125. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
  126. package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
  127. package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
  128. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  129. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  130. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  131. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  132. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  133. package/dist/component/payoutRelease/queries.d.ts +2 -2
  134. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  135. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  136. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  137. package/docs/renewal-context-reads.md +26 -8
  138. package/docs/renewal-material-observation.md +37 -0
  139. package/docs/renewal-phase-assembly.md +68 -0
  140. package/docs/renewal-raw-acquisition.md +19 -5
  141. package/package.json +1 -1
  142. package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
  143. package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
  144. package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
  145. package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
  146. package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
  147. package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
  148. package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
  149. package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
  150. package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
  151. package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
  152. package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
  153. package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
  154. package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
  155. package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
  156. package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
  157. package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
  158. package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
  159. package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
  160. package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
  161. package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
  162. package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
  163. package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
  164. package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
  165. package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
  166. package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
  167. package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
  168. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
  169. package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
  170. package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
  171. package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
  172. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
  173. package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
  174. package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
  175. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
  176. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
  177. package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
  178. package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
  179. package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
  180. package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
  181. package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
  182. package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
  183. package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
  184. package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
  185. package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
  186. package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
  187. package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
  188. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
  189. package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
  190. package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
  191. package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
  192. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
  193. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
  194. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
  195. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
  196. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
  197. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
  198. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
  199. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
  200. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
  201. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
  202. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
  203. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
  204. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
  205. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
  206. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
  207. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
  208. package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
  209. package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
  210. package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
  211. package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
  212. package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
  213. package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
  214. package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
  215. package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
  216. package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
@@ -0,0 +1,444 @@
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
+ } from "../../../renewalV2/index.js";
13
+ import { inspectRenewalScheduleMaterialV2 } from "../../../renewalV2/observation.js";
14
+ import { captureObservationRecord, verifyObservationRecord } from "./record.js";
15
+ import {
16
+ captureObservationReply,
17
+ captureObservationInput,
18
+ admitObservationOutput,
19
+ safeReadDiagnostics,
20
+ } from "./capture.js";
21
+ import {
22
+ baseReadRows,
23
+ validateBaseRouting,
24
+ observationCouponIds,
25
+ couponReadRow,
26
+ validateCoupon,
27
+ } from "./profile.js";
28
+ import { checkOwnerResult } from "./types.js";
29
+ import type {
30
+ Data,
31
+ SourceMethod,
32
+ ReadFailure,
33
+ Attempt,
34
+ StoredReadFailure,
35
+ ObservationReadRow,
36
+ ObservationReads,
37
+ } from "./types.js";
38
+ const stop = (): never => {
39
+ throw Error("OWNED_OBSERVATION_STOP");
40
+ };
41
+ const need: (value: unknown) => asserts value = (value) => {
42
+ if (!value) stop();
43
+ };
44
+ function object(value: unknown): Data {
45
+ need(
46
+ value !== null &&
47
+ typeof value === "object" &&
48
+ !types.isProxy(value) &&
49
+ !Array.isArray(value),
50
+ );
51
+ const proto = Object.getPrototypeOf(value);
52
+ need(proto === Object.prototype || proto === null);
53
+ return value as Data;
54
+ }
55
+ function field(value: unknown, key: string): unknown {
56
+ object(value);
57
+ const d = Object.getOwnPropertyDescriptor(value, key);
58
+ need(d && d.enumerable && "value" in d);
59
+ return d.value;
60
+ }
61
+ function closed(
62
+ value: unknown,
63
+ required: readonly string[],
64
+ optional: readonly string[] = [],
65
+ ): Data {
66
+ object(value);
67
+ const keys = Reflect.ownKeys(value as object);
68
+ need(
69
+ required.every((k) => keys.includes(k)) &&
70
+ keys.every(
71
+ (k) => typeof k === "string" && [...required, ...optional].includes(k),
72
+ ),
73
+ );
74
+ const out: Data = Object.create(null);
75
+ for (const key of keys)
76
+ Object.defineProperty(out, key, {
77
+ value: field(value, key as string),
78
+ enumerable: true,
79
+ });
80
+ return out;
81
+ }
82
+ function method(value: unknown, key: string): SourceMethod {
83
+ const fn = field(value, key);
84
+ need(typeof fn === "function" && !types.isProxy(fn));
85
+ return fn as SourceMethod;
86
+ }
87
+ function providerError(failure: ReadFailure) {
88
+ const error = Error("OWNED_OBSERVATION_PROVIDER_REJECTED");
89
+ Object.defineProperty(error, "failure", {
90
+ value: failure,
91
+ enumerable: false,
92
+ writable: false,
93
+ configurable: false,
94
+ });
95
+ return error;
96
+ }
97
+ export function captureOwnedRenewalObservationV2() {
98
+ if (arguments.length !== 0) throw Error("OWNED_OBSERVATION_ARITY");
99
+ let used = false;
100
+ return Object.freeze({
101
+ async invoke() {
102
+ if (arguments.length !== 0 || used) throw Error("OWNED_OBSERVATION_ONCE");
103
+ used = true;
104
+ if (COMPILED_OBSERVATION_ENTRIES.length === 0) {
105
+ return Object.freeze({
106
+ status: "not_dispatched",
107
+ reason: "OWNED_OBSERVATION_SOURCE_UNBOUND",
108
+ operationalAuthority: false,
109
+ });
110
+ }
111
+ // Fixed Source, never an input parameter or selected caller context.
112
+ const OWNER = ORIGINAL_OWNER,
113
+ check = method(OWNER, "check");
114
+ function ownerCheck() {
115
+ const sample: unknown = Reflect.apply(check, OWNER, []);
116
+ checkOwnerResult(sample);
117
+ return sample;
118
+ }
119
+ async function owned<T>(call: () => T | PromiseLike<T>): Promise<T> {
120
+ ownerCheck();
121
+ let value: T;
122
+ try {
123
+ value = await call();
124
+ } catch (error) {
125
+ ownerCheck();
126
+ throw error;
127
+ }
128
+ ownerCheck();
129
+ return value;
130
+ }
131
+ ownerCheck();
132
+ let raw: unknown;
133
+ try {
134
+ raw = loadFixedObservationOperation();
135
+ } catch {
136
+ ownerCheck();
137
+ stop();
138
+ }
139
+ ownerCheck();
140
+ const op = closed(
141
+ raw,
142
+ [
143
+ "owner",
144
+ "originAssociation",
145
+ "originalEntry",
146
+ "observationEntry",
147
+ "record",
148
+ "actualAttachAcknowledgement",
149
+ "readTransport",
150
+ ],
151
+ ["configureAcknowledgement"],
152
+ );
153
+ need(op.owner === OWNER && OWNER === ORIGINAL_OWNER);
154
+ need(op.originAssociation === ORIGINAL_ORIGIN_ASSOCIATION);
155
+ object(op.originAssociation);
156
+ need(
157
+ COMPILED_INITIAL_ENTRIES.includes(op.originalEntry) &&
158
+ COMPILED_OBSERVATION_ENTRIES.includes(op.observationEntry),
159
+ );
160
+ need(field(op.observationEntry, "originalEntry") === op.originalEntry);
161
+ need(
162
+ !Object.prototype.hasOwnProperty.call(op, "configureAcknowledgement"),
163
+ );
164
+ const coversRetained = method(op.originalEntry, "coversRetained");
165
+ const coversObservation = method(
166
+ op.observationEntry,
167
+ "coversObservation",
168
+ );
169
+ closed(op.record, [
170
+ "configuration",
171
+ "request",
172
+ "attachReceipt",
173
+ "originalBundle",
174
+ ]);
175
+ need(
176
+ field(op.record, "attachReceipt") === op.actualAttachAcknowledgement,
177
+ );
178
+ object(op.actualAttachAcknowledgement);
179
+ const delegate = op.readTransport;
180
+ closed(delegate, ["rawRequest"]);
181
+ const send = method(delegate, "rawRequest");
182
+ const captured = captureObservationRecord(op.record),
183
+ record = captured.record;
184
+ ownerCheck();
185
+ let phase = "original-C6";
186
+ let invocation: object | null = null,
187
+ generation: object | null = null,
188
+ tokens: WeakMap<object, StoredReadFailure> | null = null,
189
+ tokenSlot: object | null = null,
190
+ lastRejected: Attempt | null = null;
191
+ let pending: Attempt | null = null;
192
+ let ordinal = 0,
193
+ readerState: string = "unused",
194
+ readState: string = "not_started";
195
+ function consume(token: unknown): ReadFailure | null {
196
+ ownerCheck();
197
+ if (tokens === null || token === null || typeof token !== "object")
198
+ return null;
199
+ const stored = tokens.get(token);
200
+ if (
201
+ !stored ||
202
+ stored.invocation !== invocation ||
203
+ stored.generation !== generation ||
204
+ stored.attempt !== lastRejected ||
205
+ readState !== "actual_rejected" ||
206
+ pending !== null
207
+ )
208
+ return null;
209
+ tokens.delete(token);
210
+ return Object.freeze({
211
+ category: "provider_rejected",
212
+ phase: "read",
213
+ resource: stored.attempt.resource,
214
+ ordinal: stored.attempt.ordinal,
215
+ request: stored.attempt.request,
216
+ diagnostics: stored.diagnostics,
217
+ outcome: "unknown",
218
+ operationalAuthority: false,
219
+ });
220
+ }
221
+ function takeReadFailure() {
222
+ ownerCheck();
223
+ const token = tokenSlot;
224
+ if (token === null || tokens === null) return null;
225
+ const stored = tokens.get(token);
226
+ if (
227
+ !stored ||
228
+ stored.invocation !== invocation ||
229
+ stored.generation !== generation ||
230
+ stored.attempt !== lastRejected ||
231
+ readState !== "actual_rejected" ||
232
+ pending !== null
233
+ )
234
+ return null;
235
+ tokenSlot = null;
236
+ return token;
237
+ }
238
+ async function read(row: ObservationReadRow) {
239
+ ownerCheck();
240
+ need(
241
+ readerState === "running" &&
242
+ pending === null &&
243
+ readState !== "actual_rejected" &&
244
+ ordinal < 44,
245
+ );
246
+ need(
247
+ row.ordinal === ordinal + 1 &&
248
+ row.method === "GET" &&
249
+ row.body === undefined &&
250
+ row.options.apiVersion === "2026-09-30.endive" &&
251
+ row.options.maxNetworkRetries === 0,
252
+ );
253
+ const request = Object.freeze({
254
+ method: "GET",
255
+ path: row.path,
256
+ apiVersion: row.options.apiVersion,
257
+ });
258
+ const attempt: Attempt = {
259
+ invocation,
260
+ generation,
261
+ resource: row.resource,
262
+ ordinal: ++ordinal,
263
+ request,
264
+ promise: null,
265
+ };
266
+ pending = attempt;
267
+ readState = "pending";
268
+ let promise: unknown;
269
+ try {
270
+ promise = Reflect.apply(send, delegate, [
271
+ "GET",
272
+ row.path,
273
+ undefined,
274
+ row.options,
275
+ ]);
276
+ } catch {
277
+ ownerCheck();
278
+ pending = null;
279
+ readerState = "failed";
280
+ stop();
281
+ }
282
+ attempt.promise = promise;
283
+ Object.freeze(attempt);
284
+ let reply: unknown;
285
+ try {
286
+ reply = await promise;
287
+ } catch (error) {
288
+ ownerCheck();
289
+ need(
290
+ pending === attempt &&
291
+ attempt.invocation === invocation &&
292
+ attempt.generation === generation &&
293
+ attempt.promise === promise,
294
+ );
295
+ readState = "actual_rejected";
296
+ readerState = "failed";
297
+ pending = null;
298
+ lastRejected = attempt;
299
+ const diagnostics = safeReadDiagnostics(error),
300
+ token = Object.freeze(Object.create(null));
301
+ need(tokens !== null);
302
+ tokens.set(
303
+ token,
304
+ Object.freeze({ invocation, generation, attempt, diagnostics }),
305
+ );
306
+ tokenSlot = token;
307
+ const forwarded = takeReadFailure();
308
+ need(forwarded === token);
309
+ throw forwarded;
310
+ }
311
+ ownerCheck();
312
+ need(
313
+ pending === attempt &&
314
+ attempt.invocation === invocation &&
315
+ attempt.generation === generation &&
316
+ attempt.promise === promise,
317
+ );
318
+ pending = null;
319
+ readState = "actual_fulfilled";
320
+ const body = captureObservationReply(reply);
321
+ ownerCheck();
322
+ return body;
323
+ }
324
+ try {
325
+ const desired = await owned(() =>
326
+ projectRenewalConfigurationV2(record.configuration),
327
+ );
328
+ ownerCheck();
329
+ if (desired.status !== "projected_configure_request") return desired;
330
+ phase = "proof";
331
+ const receipt = await owned(() =>
332
+ constructRenewalScheduleAttachmentReceiptV2(
333
+ record.configuration.attachReceipt,
334
+ ),
335
+ );
336
+ ownerCheck();
337
+ verifyObservationRecord(captured, desired, receipt);
338
+ ownerCheck();
339
+ const retainedModule = await import("../material/classifiers.js");
340
+ ownerCheck();
341
+ // Fixed internal package code; module exports may be native DATA or SSR accessors.
342
+ const classifyRetained =
343
+ retainedModule.classifyOwnedRetainedInitialAttachment;
344
+ ownerCheck();
345
+ need(
346
+ typeof classifyRetained === "function" &&
347
+ !types.isProxy(classifyRetained),
348
+ );
349
+ const retained = await owned(
350
+ (): ReturnType<
351
+ typeof retainedModule.classifyOwnedRetainedInitialAttachment
352
+ > =>
353
+ Reflect.apply(classifyRetained, retainedModule, [
354
+ {
355
+ attachRequest: record.configuration.attachReceipt.attachRequest,
356
+ originalBundle: record.originalBundle,
357
+ },
358
+ ]),
359
+ );
360
+ ownerCheck();
361
+ need(retained.status === "classified");
362
+ const covered = Reflect.apply(coversRetained, op.originalEntry, [
363
+ retained.material,
364
+ record.originalBundle,
365
+ ]);
366
+ ownerCheck();
367
+ need(covered === true);
368
+ // New child/channel identity is allocated only after all original proof work.
369
+ invocation = Object.freeze({});
370
+ generation = Object.freeze({});
371
+ tokens = new WeakMap();
372
+ need(readerState === "unused" && ordinal === 0 && pending === null);
373
+ readerState = "running";
374
+ const rows = baseReadRows(record),
375
+ base: unknown[] = [];
376
+ for (const row of rows) {
377
+ const body = await owned(() => read(row));
378
+ ownerCheck();
379
+ base.push(body);
380
+ }
381
+ const reads: ObservationReads = {
382
+ schedule: base[0],
383
+ subscription: base[1],
384
+ targetPrice: base[2],
385
+ billingCustomer: base[3],
386
+ coupons: [],
387
+ };
388
+ validateBaseRouting(record, reads);
389
+ const couponIds = observationCouponIds(record, reads.subscription);
390
+ let finalSample = ownerCheck();
391
+ for (const id of couponIds) {
392
+ const body = await owned(() => read(couponReadRow(id, ordinal + 1)));
393
+ ownerCheck();
394
+ validateCoupon(record, id, body);
395
+ finalSample = ownerCheck();
396
+ reads.coupons.push(body);
397
+ }
398
+ need(
399
+ pending === null && ordinal === 4 + couponIds.length && ordinal <= 44,
400
+ );
401
+ const observedAt = Math.floor(finalSample.wallMs / 1000);
402
+ need(Number.isSafeInteger(observedAt) && observedAt >= 0);
403
+ readerState = "closed";
404
+ readState = "closed";
405
+ const input = captureObservationInput({
406
+ configuration: record.configuration,
407
+ reads,
408
+ });
409
+ phase = "observer";
410
+ const observation = await owned(() =>
411
+ inspectRenewalScheduleMaterialV2(input),
412
+ );
413
+ ownerCheck();
414
+ const complete = Reflect.apply(coversObservation, op.observationEntry, [
415
+ record,
416
+ input,
417
+ observation,
418
+ ]);
419
+ ownerCheck();
420
+ need(complete === true);
421
+ const output = admitObservationOutput({
422
+ status: "owned_observation_data",
423
+ observation,
424
+ reads: input.reads,
425
+ observedAt,
426
+ retainedConfigureAcknowledgement: "absent",
427
+ operationalAuthority: false,
428
+ });
429
+ ownerCheck();
430
+ return output;
431
+ } catch (error) {
432
+ ownerCheck();
433
+ if (phase === "original-C6") throw error;
434
+ const failure = consume(error);
435
+ if (failure !== null) {
436
+ const outward = providerError(failure);
437
+ ownerCheck();
438
+ throw outward;
439
+ }
440
+ stop();
441
+ }
442
+ },
443
+ });
444
+ }
@@ -0,0 +1,250 @@
1
+ import { types } from "node:util";
2
+ import { requiredJSONSnapshot } from "../material/requiredJson.js";
3
+ import type { Data, Diagnostics } from "./types.js";
4
+ const stop = (): never => {
5
+ throw Error("OWNED_OBSERVATION_STOP");
6
+ };
7
+ const need: (x: unknown) => asserts x = (x) => {
8
+ if (!x) stop();
9
+ };
10
+ const nativeResponsePrototype = Response.prototype;
11
+ const nativeStatusGetter = Object.getOwnPropertyDescriptor(
12
+ nativeResponsePrototype,
13
+ "status",
14
+ )!.get!;
15
+ const apply = Reflect.apply,
16
+ isProxy = types.isProxy;
17
+ function closed(
18
+ value: unknown,
19
+ required: readonly string[],
20
+ optional: readonly string[] = [],
21
+ ): Data {
22
+ need(
23
+ value !== null &&
24
+ typeof value === "object" &&
25
+ !isProxy(value) &&
26
+ !Array.isArray(value),
27
+ );
28
+ const proto = Object.getPrototypeOf(value);
29
+ need(proto === Object.prototype || proto === null);
30
+ const keys = Reflect.ownKeys(value);
31
+ need(
32
+ required.every((k) => keys.includes(k)) &&
33
+ keys.every(
34
+ (k) => typeof k === "string" && [...required, ...optional].includes(k),
35
+ ),
36
+ );
37
+ for (const key of keys) {
38
+ const d = Object.getOwnPropertyDescriptor(value, key);
39
+ need(d && d.enumerable && "value" in d);
40
+ }
41
+ return value as Data;
42
+ }
43
+ // Proxy-first complete traversal before ordinary privacy copying. Repeated ordinary
44
+ // references are charged per occurrence; only active-path cycles are rejected.
45
+ export function rejectProxyJSON(value: unknown, transportRoot = false) {
46
+ const active = new Set<object>();
47
+ let nodes = 0;
48
+ function walk(x: unknown, depth: number, isRoot: boolean) {
49
+ need(++nodes <= 10000 && depth <= 40);
50
+ need(!isProxy(x));
51
+ if (x === null || typeof x !== "object") return;
52
+ need(!active.has(x));
53
+ active.add(x);
54
+ const array = Array.isArray(x),
55
+ keys = Reflect.ownKeys(x);
56
+ need(keys.length <= 10001);
57
+ for (const key of keys) {
58
+ need(typeof key === "string");
59
+ const d = Object.getOwnPropertyDescriptor(x, key);
60
+ need(d && "value" in d);
61
+ if (isRoot && transportRoot && key === "lastResponse" && !d.enumerable)
62
+ continue;
63
+ if (array && key === "length") continue;
64
+ need(d.enumerable);
65
+ walk(d.value, depth + 1, false);
66
+ }
67
+ active.delete(x);
68
+ }
69
+ walk(value, 0, true);
70
+ }
71
+ function freeze<T>(value: T): T {
72
+ if (value && typeof value === "object") {
73
+ for (const d of Object.values(Object.getOwnPropertyDescriptors(value)))
74
+ if ("value" in d) freeze(d.value);
75
+ Object.freeze(value);
76
+ }
77
+ return value;
78
+ }
79
+ function ordinary<T>(value: T): T {
80
+ rejectProxyJSON(value);
81
+ return freeze(requiredJSONSnapshot(value)) as T;
82
+ }
83
+ export function captureObservationReply(reply: unknown) {
84
+ rejectProxyJSON(reply, true);
85
+ need(reply !== null && typeof reply === "object" && !Array.isArray(reply));
86
+ const proto = Object.getPrototypeOf(reply);
87
+ need(proto === Object.prototype || proto === null);
88
+ const meta = Object.getOwnPropertyDescriptor(reply, "lastResponse");
89
+ need(
90
+ meta &&
91
+ !meta.enumerable &&
92
+ "value" in meta &&
93
+ meta.value !== null &&
94
+ typeof meta.value === "object",
95
+ );
96
+ const metadata = meta.value as object;
97
+ need(!isProxy(metadata));
98
+ const codes: unknown[] = [];
99
+ for (const key of ["status", "statusCode"]) {
100
+ const d = Object.getOwnPropertyDescriptor(metadata, key);
101
+ if (!d) continue;
102
+ need("value" in d);
103
+ if (d.value !== undefined) codes.push(d.value);
104
+ }
105
+ if (Object.getPrototypeOf(metadata) === nativeResponsePrototype)
106
+ codes.push(apply(nativeStatusGetter, metadata, []));
107
+ need(
108
+ codes.length > 0 &&
109
+ codes.every(
110
+ (x) =>
111
+ typeof x === "number" &&
112
+ Number.isInteger(x) &&
113
+ x >= 200 &&
114
+ x < 300 &&
115
+ x === codes[0],
116
+ ),
117
+ );
118
+ const entries: [string, unknown][] = [];
119
+ for (const key of Reflect.ownKeys(reply)) {
120
+ need(typeof key === "string");
121
+ if (key === "lastResponse") continue;
122
+ const d = Object.getOwnPropertyDescriptor(reply, key);
123
+ need(d && d.enumerable && "value" in d);
124
+ entries.push([key, d.value]);
125
+ }
126
+ return ordinary(Object.fromEntries(entries));
127
+ }
128
+ export function captureObservationInput<T>(value: T): T {
129
+ const root = closed(value, ["configuration", "reads"]);
130
+ const reads = closed(root.reads, [
131
+ "schedule",
132
+ "subscription",
133
+ "targetPrice",
134
+ "billingCustomer",
135
+ "coupons",
136
+ ]);
137
+ need(Array.isArray(reads.coupons));
138
+ return ordinary(value);
139
+ }
140
+ export function admitObservationOutput<T>(value: T): T {
141
+ const root = closed(value, [
142
+ "status",
143
+ "observation",
144
+ "reads",
145
+ "observedAt",
146
+ "retainedConfigureAcknowledgement",
147
+ "operationalAuthority",
148
+ ]);
149
+ need(
150
+ root.status === "owned_observation_data" &&
151
+ root.operationalAuthority === false &&
152
+ root.retainedConfigureAcknowledgement === "absent",
153
+ );
154
+ need(
155
+ typeof root.observedAt === "number" &&
156
+ Number.isSafeInteger(root.observedAt) &&
157
+ root.observedAt >= 0,
158
+ );
159
+ const reads = closed(root.reads, [
160
+ "schedule",
161
+ "subscription",
162
+ "targetPrice",
163
+ "billingCustomer",
164
+ "coupons",
165
+ ]);
166
+ need(Array.isArray(reads.coupons));
167
+ const r = closed(
168
+ root.observation,
169
+ [
170
+ "acknowledgementEstablished",
171
+ "authenticationEstablished",
172
+ "providerQualificationRequired",
173
+ "predicate",
174
+ ],
175
+ [
176
+ "reason",
177
+ "observedItemId",
178
+ "nativePeriod",
179
+ "providerStatus",
180
+ "effectiveness",
181
+ ],
182
+ );
183
+ need(
184
+ r.acknowledgementEstablished === false &&
185
+ r.authenticationEstablished === false &&
186
+ r.providerQualificationRequired === true,
187
+ );
188
+ need(
189
+ typeof r.predicate === "string" &&
190
+ [
191
+ "pending_material_match",
192
+ "current_target_material_match",
193
+ "attached_unconfigured_match",
194
+ "terminal_facts_only",
195
+ "unknown",
196
+ "conflict",
197
+ ].includes(r.predicate),
198
+ );
199
+ for (const key of [
200
+ "reason",
201
+ "observedItemId",
202
+ "providerStatus",
203
+ "effectiveness",
204
+ ])
205
+ if (Object.prototype.hasOwnProperty.call(r, key))
206
+ need(typeof r[key] === "string");
207
+ if (Object.prototype.hasOwnProperty.call(r, "nativePeriod")) {
208
+ const period = closed(r.nativePeriod, ["start", "end"]);
209
+ need(
210
+ Number.isSafeInteger(period.start) && Number.isSafeInteger(period.end),
211
+ );
212
+ }
213
+ return ordinary(value);
214
+ }
215
+ // Only bounded own DATA is admitted. Diagnostics never authorize a failure.
216
+ export function safeReadDiagnostics(error: unknown): Diagnostics {
217
+ const out: {
218
+ type?: string;
219
+ code?: string;
220
+ statusCode?: number;
221
+ requestId?: string;
222
+ } = {};
223
+ if (error === null || typeof error !== "object" || isProxy(error))
224
+ return Object.freeze(out);
225
+ for (const key of ["type", "code", "statusCode", "requestId"] as const) {
226
+ const d = Object.getOwnPropertyDescriptor(error, key);
227
+ if (!d || !("value" in d)) continue;
228
+ const value: unknown = d.value;
229
+ if (key === "statusCode") {
230
+ if (
231
+ typeof value === "number" &&
232
+ Number.isInteger(value) &&
233
+ value >= 100 &&
234
+ value <= 599
235
+ )
236
+ out[key] = value;
237
+ } else if (
238
+ typeof value === "string" &&
239
+ value.length >= 1 &&
240
+ value.length <= 255
241
+ ) {
242
+ try {
243
+ out[key] = requiredJSONSnapshot(value) as string;
244
+ } catch {
245
+ /* Unsupported diagnostics are omitted. */
246
+ }
247
+ }
248
+ }
249
+ return Object.freeze(out);
250
+ }