@fantastic.dev/better-stripe 0.91.0 → 0.93.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 (132) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +6 -0
  4. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/configure/actor.js +46 -56
  6. package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts +3 -0
  8. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts.map +1 -0
  9. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js +61 -0
  10. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js.map +1 -0
  11. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -1
  12. package/dist/client/billing/renewalAttach/internal/observation/actor.js +25 -4
  13. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -1
  14. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/observation/capture.js +3 -2
  16. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -1
  17. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts +5 -0
  18. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js +11 -0
  20. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +5 -0
  22. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -1
  23. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -1
  24. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +30 -0
  25. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -0
  26. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +113 -0
  27. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -0
  28. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +562 -0
  29. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  30. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +281 -0
  31. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  32. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +562 -0
  33. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  34. package/dist/client/connect/payoutSyncTestHelpers.d.ts +281 -0
  35. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  36. package/dist/client/index.d.ts +3 -2
  37. package/dist/client/index.d.ts.map +1 -1
  38. package/dist/client/index.js +16 -3
  39. package/dist/client/index.js.map +1 -1
  40. package/dist/component/_generated/api.d.ts +6 -0
  41. package/dist/component/_generated/api.d.ts.map +1 -1
  42. package/dist/component/_generated/api.js.map +1 -1
  43. package/dist/component/_generated/component.d.ts +406 -0
  44. package/dist/component/_generated/component.d.ts.map +1 -1
  45. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  46. package/dist/component/earnings/triggers.d.ts +294 -0
  47. package/dist/component/earnings/triggers.d.ts.map +1 -1
  48. package/dist/component/payoutRelease/queries.d.ts +2 -2
  49. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  50. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  51. package/dist/component/renewalOperations/helpers.d.ts +236 -0
  52. package/dist/component/renewalOperations/helpers.d.ts.map +1 -0
  53. package/dist/component/renewalOperations/helpers.js +457 -0
  54. package/dist/component/renewalOperations/helpers.js.map +1 -0
  55. package/dist/component/renewalOperations/mutations.d.ts +252 -0
  56. package/dist/component/renewalOperations/mutations.d.ts.map +1 -0
  57. package/dist/component/renewalOperations/mutations.js +340 -0
  58. package/dist/component/renewalOperations/mutations.js.map +1 -0
  59. package/dist/component/renewalOperations/queries.d.ts +163 -0
  60. package/dist/component/renewalOperations/queries.d.ts.map +1 -0
  61. package/dist/component/renewalOperations/queries.js +167 -0
  62. package/dist/component/renewalOperations/queries.js.map +1 -0
  63. package/dist/component/renewalOperations/schema.d.ts +1988 -0
  64. package/dist/component/renewalOperations/schema.d.ts.map +1 -0
  65. package/dist/component/renewalOperations/schema.js +227 -0
  66. package/dist/component/renewalOperations/schema.js.map +1 -0
  67. package/dist/component/schema.d.ts +281 -0
  68. package/dist/component/schema.js +5 -0
  69. package/dist/component/schema.js.map +1 -1
  70. package/dist/component/usage/allowance.fixtures.d.ts +281 -0
  71. package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
  72. package/dist/component/usageCredits/accounting.fixtures.d.ts +281 -0
  73. package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
  74. package/dist/shared/renewalOperationJournal.d.ts +43 -0
  75. package/dist/shared/renewalOperationJournal.d.ts.map +1 -0
  76. package/dist/shared/renewalOperationJournal.js +294 -0
  77. package/dist/shared/renewalOperationJournal.js.map +1 -0
  78. package/docs/renewal-context-reads.md +152 -0
  79. package/docs/renewal-material-observation.md +32 -11
  80. package/package.json +1 -1
  81. package/src/client/billing/renewalAttach/internal/configure/actor.ts +63 -52
  82. package/src/client/billing/renewalAttach/internal/configure/ownedContinuation.ts +56 -0
  83. package/src/client/billing/renewalAttach/internal/observation/actor.ts +46 -3
  84. package/src/client/billing/renewalAttach/internal/observation/capture.ts +3 -2
  85. package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -0
  86. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +36 -0
  87. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +48 -0
  88. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +44 -0
  89. package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +34 -0
  90. package/src/client/billing/renewalAttach/internal/observation/types.ts +5 -0
  91. package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +380 -0
  92. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +155 -0
  93. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +5 -1
  94. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +12 -1
  95. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
  96. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +8 -0
  97. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +10 -23
  98. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +115 -0
  99. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +141 -0
  100. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +74 -0
  101. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +79 -0
  102. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +207 -0
  103. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +494 -0
  104. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +452 -0
  105. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +88 -0
  106. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +170 -0
  107. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +99 -0
  108. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +411 -0
  109. package/src/client/index.ts +24 -3
  110. package/src/component/_generated/api.ts +6 -0
  111. package/src/component/_generated/component.ts +450 -0
  112. package/src/component/renewalOperations/acknowledgement.fixtures.ts +552 -0
  113. package/src/component/renewalOperations/acknowledgement.test.ts +573 -0
  114. package/src/component/renewalOperations/acknowledgementReads.test.ts +442 -0
  115. package/src/component/renewalOperations/acknowledgementV2.test.ts +493 -0
  116. package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +373 -0
  117. package/src/component/renewalOperations/basisBinding.test.ts +567 -0
  118. package/src/component/renewalOperations/basisLifecycle.test.ts +569 -0
  119. package/src/component/renewalOperations/boundHistory.test.ts +474 -0
  120. package/src/component/renewalOperations/helpers.ts +592 -0
  121. package/src/component/renewalOperations/historyReads.test.ts +595 -0
  122. package/src/component/renewalOperations/initialBasis.test.ts +578 -0
  123. package/src/component/renewalOperations/journal.test.ts +567 -0
  124. package/src/component/renewalOperations/mutations.ts +456 -0
  125. package/src/component/renewalOperations/payload.test.ts +589 -0
  126. package/src/component/renewalOperations/payloadEncoding.test.ts +592 -0
  127. package/src/component/renewalOperations/queries.ts +204 -0
  128. package/src/component/renewalOperations/schema.ts +268 -0
  129. package/src/component/renewalOperations/timingPolicy.fixtures.ts +193 -0
  130. package/src/component/renewalOperations/timingPolicy.test.ts +523 -0
  131. package/src/component/schema.ts +11 -0
  132. package/src/shared/renewalOperationJournal.ts +333 -0
@@ -0,0 +1,99 @@
1
+ import type { declarePreflightCase } from "./configurePreflightControls.js";
2
+ type Baseline = ReturnType<typeof declarePreflightCase>;
3
+ export type ConfiguredHistoryWriterMode =
4
+ | "configured-history"
5
+ | "configured-history-onephase"
6
+ | "configured-history-drift";
7
+ export const CONFIGURED_TARGET_SECONDS = 2419200;
8
+
9
+ /** Exact full native Plan mapping from the accepted baseline helper; DATA only. */
10
+ function targetPlan(p: Baseline["baselineBundle"]["wireTargetPrice"]) {
11
+ return {
12
+ id: p.id,
13
+ object: "plan",
14
+ active: p.active,
15
+ amount: p.unit_amount,
16
+ amount_decimal: p.unit_amount_decimal,
17
+ billing_scheme: "per_unit",
18
+ created: p.created,
19
+ currency: p.currency,
20
+ interval: p.recurring.interval,
21
+ interval_count: p.recurring.interval_count,
22
+ livemode: p.livemode,
23
+ metadata: p.metadata,
24
+ meter: p.recurring.meter,
25
+ nickname: p.nickname,
26
+ product: p.product,
27
+ tiers_mode: null,
28
+ transform_usage: null,
29
+ trial_period_days: p.recurring.trial_period_days,
30
+ usage_type: "licensed",
31
+ };
32
+ }
33
+ /** Fixed complete reply recipe precedes all Source/Owner/C1/C2 construction. */
34
+ export function configuredHistoryResponse(
35
+ baseline: Baseline,
36
+ mode: ConfiguredHistoryWriterMode,
37
+ ) {
38
+ const response = structuredClone(baseline.schedule);
39
+ const original = response.phases[0]!;
40
+ const target = {
41
+ ...structuredClone(original),
42
+ start_date: baseline.original.attachRequest.preparation.expected.periodEnd,
43
+ end_date:
44
+ baseline.original.attachRequest.preparation.expected.periodEnd +
45
+ CONFIGURED_TARGET_SECONDS,
46
+ proration_behavior: "none",
47
+ billing_cycle_anchor: "automatic",
48
+ items: original.items.map((item) => ({
49
+ ...structuredClone(item),
50
+ price: "price_target",
51
+ plan: "price_target",
52
+ })),
53
+ metadata:
54
+ mode === "configured-history-drift"
55
+ ? { ...original.metadata, declared: "TEST_HISTORY_PHASE_DRIFT" }
56
+ : structuredClone(original.metadata),
57
+ };
58
+ return {
59
+ ...response,
60
+ phases:
61
+ mode === "configured-history-onephase" ? [original] : [original, target],
62
+ };
63
+ }
64
+ export function configuredHistoryLiveReads(
65
+ baseline: Baseline,
66
+ active: boolean,
67
+ ) {
68
+ // The independently declared live Schedule is always the clean complete history.
69
+ const schedule = configuredHistoryResponse(baseline, "configured-history");
70
+ const subscription = structuredClone(
71
+ baseline.baselineBundle.wireSubscription,
72
+ );
73
+ const targetPrice = structuredClone(baseline.baselineBundle.wireTargetPrice);
74
+ if (active) {
75
+ const target = schedule.phases[1]!;
76
+ schedule.current_phase = {
77
+ start_date: target.start_date,
78
+ end_date: target.end_date,
79
+ };
80
+ const item = subscription.items.data[0]!;
81
+ item.id = "si_successor";
82
+ item.price = structuredClone(targetPrice);
83
+ item.plan = targetPlan(targetPrice);
84
+ item.current_period_start = target.start_date;
85
+ item.current_period_end = target.end_date;
86
+ for (const discount of item.discounts) discount.subscription_item = item.id;
87
+ }
88
+ return {
89
+ schedule,
90
+ subscription,
91
+ targetPrice,
92
+ billingCustomer: structuredClone(
93
+ baseline.baselineBundle.wireBillingCustomer,
94
+ ),
95
+ coupons: baseline.baselineBundle.couponReads.map((row) =>
96
+ structuredClone(row.wireCoupon),
97
+ ),
98
+ };
99
+ }
@@ -0,0 +1,411 @@
1
+ import assert from "node:assert/strict";
2
+ import { vi } from "vitest";
3
+ import * as actualPublicAPI from "../../../renewalV2/index.js";
4
+ import * as publicObserver from "../../../renewalV2/observation.js";
5
+ import {
6
+ declareConfiguredHistoryCase,
7
+ type ConfiguredHistoryCase,
8
+ } from "./observationConfiguredHistoryDeclarations.js";
9
+ import { configureWriteFixture } from "./configureWriteOperation.js";
10
+ import { assertConfigureACK, ackSlots } from "./configureWriteAssertions.js";
11
+ import { assertFit } from "./configurePreflightAssertions.js";
12
+ import { data, deepFreeze } from "./configurePreflightControls.js";
13
+
14
+ /** New closed TEST chain; actual writer/publication and original Owner/client retained. */
15
+ export async function configuredHistoryFixture(
16
+ controlCase: ConfiguredHistoryCase,
17
+ ) {
18
+ const declaration = declareConfiguredHistoryCase(controlCase);
19
+ const writer = await configureWriteFixture(declaration.writerMode);
20
+ let finalReadSample: ReturnType<typeof writer.OWNER.check> | null = null;
21
+ const pending: Promise<unknown>[] = [];
22
+ const calls: { method: string; path: string }[] = [];
23
+ const promises: Promise<unknown>[] = [];
24
+ const counters = {
25
+ source: 0,
26
+ target: 0,
27
+ coverage: 0,
28
+ observer: 0,
29
+ C6: 0,
30
+ C3: 0,
31
+ C9: 0,
32
+ lookup: 0,
33
+ };
34
+ const clean = async () => {
35
+ try {
36
+ await Promise.all(pending);
37
+ } finally {
38
+ vi.doUnmock("../configure/actor.js");
39
+ vi.doUnmock("../../../renewalV2/observation.js");
40
+ await writer.cleanup();
41
+ }
42
+ };
43
+ try {
44
+ assert.deepEqual(
45
+ writer.write,
46
+ declaration.writer,
47
+ "PREDECLARED_WRITER_RECIPE_PARITY",
48
+ );
49
+ const basis = writer.OWNER.basis;
50
+ const writerACK: unknown = await writer.captureWriter().invoke();
51
+ assertConfigureACK(writer, writerACK);
52
+ const expectedSlots = 19;
53
+ const expectedDefaultsPresent = expectedSlots === 19;
54
+ assert.equal(ackSlots(writer).length, expectedSlots);
55
+ const ack = data(writerACK);
56
+ assert.equal(
57
+ Object.prototype.hasOwnProperty.call(
58
+ data(ack.receipt),
59
+ "defaultSettingsBinding",
60
+ ),
61
+ expectedDefaultsPresent,
62
+ );
63
+ const rawReceipt = data(ack.rawReceipt);
64
+ assert.equal(
65
+ Object.prototype.hasOwnProperty.call(
66
+ data(rawReceipt.providerSnapshot),
67
+ "default_settings",
68
+ ),
69
+ expectedDefaultsPresent,
70
+ );
71
+ if (expectedDefaultsPresent) {
72
+ const defaults = data(rawReceipt.providerSnapshot).default_settings;
73
+ assert.deepEqual(defaults, declaration.writer.response.default_settings);
74
+ assert(defaults !== null && typeof defaults === "object");
75
+ const defaultBinding = data(ack.receipt).defaultSettingsBinding;
76
+ assert.equal(
77
+ defaultBinding,
78
+ writer.expectedReceipt.defaultSettingsBinding,
79
+ );
80
+ assert(typeof defaultBinding === "string");
81
+ assert.match(
82
+ defaultBinding,
83
+ /^renewal-configured-defaults:v2:sha256:[0-9a-f]{64}$/,
84
+ );
85
+ }
86
+ assert.deepEqual(rawReceipt, writer.rawReceipt);
87
+ const phases = data(rawReceipt.providerSnapshot).phases;
88
+ assert(Array.isArray(phases));
89
+ assert.equal(phases.length, declaration.historyPhaseCount);
90
+ const actualOperation = writer.fixedAOperation();
91
+ assert.equal(actualOperation.owner, writer.OWNER);
92
+ assert.equal(
93
+ actualOperation.actualAttachAcknowledgement,
94
+ writer.acknowledgement,
95
+ );
96
+ const originalEntry = actualOperation.originalEntry;
97
+ const origin = actualOperation.originAssociation;
98
+ const source = await import("../operations/sourceOperations.js");
99
+ assert.equal(source.ORIGINAL_ORIGIN_ASSOCIATION, origin);
100
+ assert(source.COMPILED_INITIAL_ENTRIES.includes(originalEntry));
101
+ const writerBefore = Object.freeze({
102
+ records: writer.writeState.records.length,
103
+ posts: writer.writeState.calls.filter((row) => row.method === "POST")
104
+ .length,
105
+ c9: writer.writeState.explicitC9,
106
+ });
107
+ assert.deepEqual(writerBefore, { records: 3, posts: 1, c9: 1 });
108
+ const setupBefore = Object.freeze({
109
+ records: writer.state.records.length,
110
+ posts: writer.state.calls.filter((row) => row.method === "POST").length,
111
+ });
112
+ assert.deepEqual(setupBefore, { records: 3, posts: 1 });
113
+ const input = deepFreeze({
114
+ configuration: writer.expectedRecord.configuration,
115
+ reads: declaration.reads,
116
+ configureReceipt: rawReceipt,
117
+ });
118
+ const direct: unknown = await Reflect.apply(
119
+ publicObserver.inspectRenewalScheduleMaterialV2,
120
+ publicObserver,
121
+ [input],
122
+ );
123
+ assert.deepEqual(
124
+ direct,
125
+ declaration.expectedObservation,
126
+ "CONFIGURED_HISTORY_PURE_RESULT_PREREQUISITE",
127
+ );
128
+ if (controlCase === "H01-pending") {
129
+ const withoutReceipt: unknown = await Reflect.apply(
130
+ publicObserver.inspectRenewalScheduleMaterialV2,
131
+ publicObserver,
132
+ [
133
+ {
134
+ configuration: writer.expectedRecord.configuration,
135
+ reads: declaration.reads,
136
+ },
137
+ ],
138
+ );
139
+ writer.OWNER.check();
140
+ assert.deepEqual(
141
+ withoutReceipt,
142
+ declaration.expectedWithoutReceipt,
143
+ "MONTHLY_HISTORY_CAUSAL_PREREQUISITE",
144
+ );
145
+ assert.notDeepEqual(withoutReceipt, direct);
146
+ }
147
+ const expectedOutput = deepFreeze({
148
+ status: "owned_observation_data",
149
+ observation: direct,
150
+ reads: declaration.reads,
151
+ observedAt: declaration.observedAt,
152
+ retainedConfigureAcknowledgement: "present",
153
+ operationalAuthority: false,
154
+ });
155
+ const prerequisites = {
156
+ record: assertFit(writer.expectedRecord),
157
+ actualACK: assertFit(writerACK),
158
+ rawReceipt: assertFit(rawReceipt),
159
+ publicInput: assertFit(input),
160
+ publicResult: assertFit(direct),
161
+ expectedOutput: assertFit(expectedOutput),
162
+ };
163
+ assert.equal(writer.OWNER.basis, basis);
164
+ vi.stubGlobal("fetch", async (value: unknown, init: RequestInit) => {
165
+ const row = declaration.rows[calls.length];
166
+ assert(row, "UNDECLARED_OPTIONAL_ACK_READ");
167
+ const url = new URL(String(value));
168
+ assert.equal(url.origin, "https://api.stripe.com");
169
+ assert.equal(url.pathname + url.search, row.path);
170
+ assert.equal(init.method, "GET");
171
+ assert.equal(init.body, undefined);
172
+ assert.equal(init.redirect, "error");
173
+ const headers = new Headers(init.headers);
174
+ assert.equal(
175
+ headers.get("stripe-version"),
176
+ declaration.writer.baseline.apiVersion,
177
+ );
178
+ assert.equal(headers.get("stripe-account"), null);
179
+ calls.push({ method: "GET", path: row.path });
180
+ return new Response(JSON.stringify(row.body), {
181
+ status: 200,
182
+ headers: {
183
+ "content-type": "application/json",
184
+ "request-id": "req_SYNTHETIC_OPTIONAL_ACK",
185
+ },
186
+ });
187
+ });
188
+ const readTransport = Object.freeze({
189
+ rawRequest(...args: unknown[]) {
190
+ writer.OWNER.check();
191
+ const row = declaration.rows[promises.length];
192
+ assert(row);
193
+ assert.deepEqual(args, ["GET", row.path, undefined, row.options]);
194
+ const promise = writer.readFixedA(...args);
195
+ promises.push(promise);
196
+ pending.push(
197
+ promise.then(
198
+ () => {
199
+ const sample = writer.OWNER.check();
200
+ if (row.ordinal === declaration.rows.length)
201
+ finalReadSample = sample;
202
+ },
203
+ () => {},
204
+ ),
205
+ );
206
+ return promise;
207
+ },
208
+ });
209
+ const observationEntry = Object.freeze({
210
+ originalEntry,
211
+ coversObservation(
212
+ record: unknown,
213
+ actualInput: unknown,
214
+ result: unknown,
215
+ ) {
216
+ counters.coverage++;
217
+ assert.deepEqual(record, writer.expectedRecord);
218
+ assert.deepEqual(actualInput, input);
219
+ assert.deepEqual(result, direct);
220
+ return true;
221
+ },
222
+ });
223
+ const operation = Object.freeze({
224
+ owner: writer.OWNER,
225
+ originAssociation: origin,
226
+ originalEntry,
227
+ observationEntry,
228
+ record: writer.expectedRecord,
229
+ actualAttachAcknowledgement: writer.acknowledgement,
230
+ readTransport,
231
+ configureAcknowledgement: writerACK,
232
+ configureOperation: actualOperation,
233
+ });
234
+ const sourceOperation = operation;
235
+ const actualWriterActor = await import("../configure/actor.js");
236
+ const actualLookup = actualWriterActor.readOwnedConfigureAcknowledgement;
237
+ assert.equal(typeof actualLookup, "function");
238
+ vi.doMock("../configure/actor.js", () => ({
239
+ ...actualWriterActor,
240
+ readOwnedConfigureAcknowledgement(
241
+ this: unknown,
242
+ ...args: Parameters<typeof actualLookup>
243
+ ) {
244
+ counters.lookup++;
245
+ return Reflect.apply(actualLookup, this, args) as ReturnType<
246
+ typeof actualLookup
247
+ >;
248
+ },
249
+ }));
250
+ vi.doMock("../operations/sourceOperations.js", () => ({
251
+ ...source,
252
+ COMPILED_OBSERVATION_ENTRIES: Object.freeze([observationEntry]),
253
+ loadFixedObservationOperation() {
254
+ assert.equal(arguments.length, 0);
255
+ counters.source++;
256
+ return sourceOperation;
257
+ },
258
+ }));
259
+ const keep = <T>(promise: Promise<T>) => {
260
+ pending.push(
261
+ promise.then(
262
+ () => {},
263
+ () => {},
264
+ ),
265
+ );
266
+ return promise;
267
+ };
268
+ vi.doMock("../../../renewalV2/index.js", () => ({
269
+ ...actualPublicAPI,
270
+ projectRenewalConfigurationV2(
271
+ ...args: Parameters<
272
+ typeof actualPublicAPI.projectRenewalConfigurationV2
273
+ >
274
+ ) {
275
+ counters.C6++;
276
+ return keep(
277
+ Reflect.apply(
278
+ actualPublicAPI.projectRenewalConfigurationV2,
279
+ actualPublicAPI,
280
+ args,
281
+ ) as ReturnType<typeof actualPublicAPI.projectRenewalConfigurationV2>,
282
+ );
283
+ },
284
+ constructRenewalScheduleAttachmentReceiptV2(
285
+ ...args: Parameters<
286
+ typeof actualPublicAPI.constructRenewalScheduleAttachmentReceiptV2
287
+ >
288
+ ) {
289
+ counters.C3++;
290
+ return keep(
291
+ Reflect.apply(
292
+ actualPublicAPI.constructRenewalScheduleAttachmentReceiptV2,
293
+ actualPublicAPI,
294
+ args,
295
+ ) as ReturnType<
296
+ typeof actualPublicAPI.constructRenewalScheduleAttachmentReceiptV2
297
+ >,
298
+ );
299
+ },
300
+ constructRenewalConfigurationReceiptV2(
301
+ ...args: Parameters<
302
+ typeof actualPublicAPI.constructRenewalConfigurationReceiptV2
303
+ >
304
+ ) {
305
+ counters.C9++;
306
+ return keep(
307
+ Reflect.apply(
308
+ actualPublicAPI.constructRenewalConfigurationReceiptV2,
309
+ actualPublicAPI,
310
+ args,
311
+ ) as ReturnType<
312
+ typeof actualPublicAPI.constructRenewalConfigurationReceiptV2
313
+ >,
314
+ );
315
+ },
316
+ }));
317
+ vi.doMock("../../../renewalV2/observation.js", () => ({
318
+ ...publicObserver,
319
+ inspectRenewalScheduleMaterialV2(
320
+ ...args: Parameters<
321
+ typeof publicObserver.inspectRenewalScheduleMaterialV2
322
+ >
323
+ ) {
324
+ counters.observer++;
325
+ const promise = Reflect.apply(
326
+ publicObserver.inspectRenewalScheduleMaterialV2,
327
+ publicObserver,
328
+ args,
329
+ ) as ReturnType<typeof publicObserver.inspectRenewalScheduleMaterialV2>;
330
+ pending.push(
331
+ promise.then(
332
+ () => {},
333
+ () => {},
334
+ ),
335
+ );
336
+ return promise;
337
+ },
338
+ }));
339
+ const actor = await import("../observation/actor.js");
340
+ writer.OWNER.check();
341
+ assert.deepEqual(counters, {
342
+ source: 0,
343
+ target: 0,
344
+ coverage: 0,
345
+ observer: 0,
346
+ C6: 0,
347
+ C3: 0,
348
+ C9: 0,
349
+ lookup: 0,
350
+ });
351
+ assert.equal(calls.length, 0);
352
+ console.log(
353
+ JSON.stringify({
354
+ kind: "CONFIGURED_HISTORY_ACTUAL_PREREQUISITES",
355
+ actualInitialACK: true,
356
+ actualWriterACK: true,
357
+ actualConfigureOperationPointer: true,
358
+ sameOriginalOwnerENTRYAndOrigin: true,
359
+ controlCase,
360
+ generatedSlots: expectedSlots,
361
+ originalClientAndPromisePath: true,
362
+ writerBefore,
363
+ setupBefore,
364
+ observationHTTP: 0,
365
+ directUnmodifiedObserver: direct,
366
+ prerequisites,
367
+ operationalAuthority: false,
368
+ }),
369
+ );
370
+ return {
371
+ declaration,
372
+ writer,
373
+ writerACK,
374
+ operation,
375
+ sourceOperation,
376
+ basis,
377
+ input,
378
+ expectedOutput,
379
+ finalSample: () => finalReadSample,
380
+ writerBefore,
381
+ setupBefore,
382
+ calls,
383
+ promises,
384
+ counters,
385
+ capture() {
386
+ const handle = actor.captureOwnedRenewalObservationV2();
387
+ return Object.freeze({
388
+ invoke() {
389
+ counters.target++;
390
+ const promise = Reflect.apply(
391
+ handle.invoke,
392
+ handle,
393
+ [],
394
+ ) as ReturnType<typeof handle.invoke>;
395
+ pending.push(
396
+ promise.then(
397
+ () => {},
398
+ () => {},
399
+ ),
400
+ );
401
+ return promise;
402
+ },
403
+ });
404
+ },
405
+ cleanup: clean,
406
+ };
407
+ } catch (error) {
408
+ await clean();
409
+ throw error;
410
+ }
411
+ }
@@ -68,7 +68,13 @@ import type { CreateCheckoutSessionOptions } from "./billing/checkoutOptions.js"
68
68
  export type { CreateCheckoutSessionOptions } from "./billing/checkoutOptions.js";
69
69
  import * as intentsImpl from "./billing/intents.js";
70
70
  export type * from "./billing/intents.js";
71
- import { RenewalContextClient } from "./renewalContextClient.js";
71
+ import {
72
+ ClassOwnedActionRoot,
73
+ CLASS_ROOT_CONSTRUCTION_PERMIT,
74
+ finishClassRoot,
75
+ beginClassAction,
76
+ type ClassActionInput,
77
+ } from "./billing/renewalAttach/internal/producer/classOwnedActionRoot.js";
72
78
  export type {
73
79
  CreateBillingPortalConfigurationOptions,
74
80
  RetrieveBillingPortalConfigurationOptions,
@@ -276,7 +282,7 @@ export type BetterStripeComponent = ComponentApi;
276
282
 
277
283
  // BETTER STRIPE CLIENT
278
284
 
279
- export class BetterStripe extends RenewalContextClient {
285
+ export class BetterStripe extends ClassOwnedActionRoot {
280
286
  get usage() {
281
287
  return new UsageLedgerClient(this.component);
282
288
  }
@@ -288,7 +294,7 @@ export class BetterStripe extends RenewalContextClient {
288
294
  private _statementDescriptorSuffix?: string;
289
295
 
290
296
  constructor(component: BetterStripeComponent, options?: BetterStripeOptions) {
291
- super(component);
297
+ super(component, CLASS_ROOT_CONSTRUCTION_PERMIT);
292
298
  this.stripeApiVersion = resolveStripeApiVersion(options?.stripeApiVersion);
293
299
  this._apiKey = options?.STRIPE_SECRET_KEY;
294
300
  this._triggers = options?.triggers;
@@ -304,6 +310,21 @@ export class BetterStripe extends RenewalContextClient {
304
310
  options.statementDescriptorSuffix,
305
311
  );
306
312
  }
313
+ finishClassRoot(this, {
314
+ prototype: BetterStripe.prototype,
315
+ select: this.#selectRenewalClient,
316
+ enter: this.#enterRenewalAction,
317
+ });
318
+ }
319
+
320
+ #selectRenewalClient(): Stripe {
321
+ return getStripeClient(this._apiKey!, this.stripeApiVersion, {
322
+ singleAttempt: true,
323
+ });
324
+ }
325
+
326
+ #enterRenewalAction(input: ClassActionInput) {
327
+ return beginClassAction(this, input);
307
328
  }
308
329
 
309
330
  /**
@@ -164,6 +164,9 @@ import type * as refundSync_mutations from "../refundSync/mutations.js";
164
164
  import type * as refundSync_queries from "../refundSync/queries.js";
165
165
  import type * as refundSync_routing from "../refundSync/routing.js";
166
166
  import type * as refundSync_validators from "../refundSync/validators.js";
167
+ import type * as renewalOperations_helpers from "../renewalOperations/helpers.js";
168
+ import type * as renewalOperations_mutations from "../renewalOperations/mutations.js";
169
+ import type * as renewalOperations_queries from "../renewalOperations/queries.js";
167
170
  import type * as reversalObservations_capture from "../reversalObservations/capture.js";
168
171
  import type * as reversalObservations_indexSlice from "../reversalObservations/indexSlice.js";
169
172
  import type * as reversalObservations_integrity from "../reversalObservations/integrity.js";
@@ -383,6 +386,9 @@ const fullApi: ApiFromModules<{
383
386
  "refundSync/queries": typeof refundSync_queries;
384
387
  "refundSync/routing": typeof refundSync_routing;
385
388
  "refundSync/validators": typeof refundSync_validators;
389
+ "renewalOperations/helpers": typeof renewalOperations_helpers;
390
+ "renewalOperations/mutations": typeof renewalOperations_mutations;
391
+ "renewalOperations/queries": typeof renewalOperations_queries;
386
392
  "reversalObservations/capture": typeof reversalObservations_capture;
387
393
  "reversalObservations/indexSlice": typeof reversalObservations_indexSlice;
388
394
  "reversalObservations/integrity": typeof reversalObservations_integrity;