@fantastic.dev/better-stripe 0.104.0 → 0.106.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 (70) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts +23 -0
  4. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js +28 -0
  6. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +300 -0
  8. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/configure/transport.js +44 -2
  10. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.d.ts +19 -0
  12. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.d.ts.map +1 -0
  13. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.js +11 -0
  14. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.js.map +1 -0
  15. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.d.ts +56 -0
  16. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.d.ts.map +1 -0
  17. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.js +79 -0
  18. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.js.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.d.ts +47 -0
  20. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.d.ts.map +1 -1
  21. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.js +79 -0
  22. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.js.map +1 -1
  23. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts +25 -0
  24. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts.map +1 -1
  25. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js +62 -0
  26. package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js.map +1 -1
  27. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts +14 -0
  28. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts.map +1 -1
  29. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js +17 -0
  30. package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js.map +1 -1
  31. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.d.ts +5 -0
  32. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.d.ts.map +1 -0
  33. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.js +259 -0
  34. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.js.map +1 -0
  35. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.d.ts +7 -0
  36. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.d.ts.map +1 -0
  37. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.js +209 -0
  38. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.js.map +1 -0
  39. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.d.ts +61 -0
  40. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.d.ts.map +1 -0
  41. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js +73 -0
  42. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js.map +1 -0
  43. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  44. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  45. package/dist/component/balanceFunding/mutations.d.ts +27 -27
  46. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  47. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  48. package/dist/component/earnings/triggers.d.ts +16 -16
  49. package/dist/component/payoutRelease/queries.d.ts +2 -2
  50. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  51. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  52. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  53. package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
  54. package/docs/renewal-context-reads.md +99 -4
  55. package/package.json +1 -1
  56. package/src/client/billing/renewalAttach/internal/c10/configureEvents.ts +37 -0
  57. package/src/client/billing/renewalAttach/internal/configure/transport.ts +64 -2
  58. package/src/client/billing/renewalAttach/internal/producer/configureAcknowledgement.ts +11 -0
  59. package/src/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.ts +121 -0
  60. package/src/client/billing/renewalAttach/internal/producer/configureFrontier.ts +155 -0
  61. package/src/client/billing/renewalAttach/internal/producer/configureJournalData.ts +84 -0
  62. package/src/client/billing/renewalAttach/internal/producer/configureJournalWork.ts +16 -0
  63. package/src/client/billing/renewalAttach/internal/producer/configureRecovery.ts +361 -0
  64. package/src/client/billing/renewalAttach/internal/producer/configureWrite.ts +288 -0
  65. package/src/client/billing/renewalAttach/internal/producer/configureWriteFactory.ts +88 -0
  66. package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecovery.integration.test.ts +99 -0
  67. package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecoveryControls.integration.test.ts +420 -0
  68. package/src/client/billing/renewalAttach/internal/producer/producerConfigureWrite.integration.test.ts +158 -0
  69. package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +537 -0
  70. package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +85 -2
@@ -1,8 +1,9 @@
1
1
  import assert from "node:assert/strict";
2
- import { afterEach, beforeEach, vi } from "vitest";
2
+ import { afterEach, beforeEach, describe, it, vi } from "vitest";
3
3
  import { initialOperations } from "./producerInitialOperation.js";
4
4
  import { makeConfigureReadNativeBaseline } from "./configureReadNativeBaseline.js";
5
5
  import { captureRetainedInput } from "../material/capture.js";
6
+ import { captureAdmittedConfigurePreflight } from "../producer/configurePreflight.js";
6
7
  import { captureInitialInvocationCore } from "../producer/invocationProducer.js";
7
8
  import { createClassActionOperationJournal } from "../operationJournal.js";
8
9
  import { components } from "../../../../../../example/convex/_generated/api.js";
@@ -23,6 +24,10 @@ const controls = vi.hoisted(() => ({
23
24
  originalEntry: unknown;
24
25
  coversPreflight(...args: unknown[]): boolean;
25
26
  }[],
27
+ write: [] as {
28
+ originalEntry: unknown;
29
+ coversConfigure(...args: unknown[]): boolean;
30
+ }[],
26
31
  legacy: 0,
27
32
  selectors: 0,
28
33
  }));
@@ -35,6 +40,11 @@ vi.mock("../operations/sourceOperations.js", () => {
35
40
  COMPILED_INITIAL_ENTRIES: controls.entries,
36
41
  COMPILED_RECOVERY_ENTRIES: controls.recovery,
37
42
  COMPILED_PREFLIGHT_ENTRIES: controls.preflight,
43
+ COMPILED_CONFIGURE_WRITE_ENTRIES: controls.write,
44
+ loadConfigureWriteTransportSource: poison,
45
+ loadConfigureReplayTransportSource: poison,
46
+ loadFixedConfigureWriteOperation: poison,
47
+ loadFixedConfigureReplayOperation: poison,
38
48
  loadOwnedConfigureOperation: poison,
39
49
  loadConfigureOwnedReadTransportSource: poison,
40
50
  ORIGINAL_ORIGIN_ASSOCIATION: null,
@@ -77,6 +87,7 @@ const canonical = (value: unknown) => JSON.stringify(renewalSnapshot(value));
77
87
  beforeEach(() => {
78
88
  controls.legacy = 0;
79
89
  controls.preflight.splice(0);
90
+ controls.write.splice(0);
80
91
  controls.selectors = 0;
81
92
  controls.entries.splice(0, controls.entries.length, {
82
93
  coversRetained: () => true,
@@ -113,6 +124,8 @@ async function setup(
113
124
  path: string;
114
125
  query: string;
115
126
  hasBody: boolean;
127
+ idempotencyKey: string | null;
128
+ apiVersion: string | null;
116
129
  }[] = [];
117
130
  const routes = new Map<string, unknown>([
118
131
  ["/v1/subscriptions/sub_original", source.originalBundle.wireSubscription],
@@ -132,6 +145,8 @@ async function setup(
132
145
  path,
133
146
  query: parsed.search,
134
147
  hasBody: init?.body !== undefined,
148
+ idempotencyKey: new Headers(init?.headers).get("idempotency-key"),
149
+ apiVersion: new Headers(init?.headers).get("stripe-version"),
135
150
  });
136
151
  await hooks.beforeFetch?.(path, method);
137
152
  if (method === "POST") {
@@ -143,7 +158,9 @@ async function setup(
143
158
  assert(body);
144
159
  assert(
145
160
  method === "GET" ||
146
- (method === "POST" && path === "/v1/subscription_schedules"),
161
+ (method === "POST" &&
162
+ (path === "/v1/subscription_schedules" ||
163
+ path === "/v1/subscription_schedules/" + baseline.schedule.id)),
147
164
  );
148
165
  return new Response(JSON.stringify(body), {
149
166
  status: 200,
@@ -362,6 +379,7 @@ export async function configureAdmissionFixture(
362
379
  ) => Promise<void>;
363
380
  afterAppend?: () => Promise<void>;
364
381
  beforeAppend?: () => Promise<void>;
382
+ afterRetain?: () => Promise<void>;
365
383
  beforeFetch?: (path: string, method: string) => Promise<void>;
366
384
  } = {},
367
385
  ) {
@@ -383,6 +401,7 @@ export async function configureAdmissionFixture(
383
401
  afterBind: options.afterBind,
384
402
  afterQuery: options.afterQuery,
385
403
  beforeAppend: options.beforeAppend,
404
+ afterRetain: options.afterRetain,
386
405
  afterAppend: async () => {
387
406
  completion.appends++;
388
407
  if (completion.mode === "resume" && completion.appends === 2)
@@ -398,3 +417,67 @@ export async function configureAdmissionFixture(
398
417
  },
399
418
  );
400
419
  }
420
+
421
+ /** Stage real Action prerequisites separately while joining every test continuation. */
422
+ export function configureAdmissionCase<T>(
423
+ name: string,
424
+ prepare: (h: Awaited<ReturnType<typeof setup>>) => Promise<T>,
425
+ verify: (h: Awaited<ReturnType<typeof setup>>, state: T) => Promise<void>,
426
+ options: Parameters<typeof configureAdmissionFixture>[1] = {},
427
+ ) {
428
+ describe(name, () => {
429
+ let pending: Promise<void>,
430
+ start!: () => void,
431
+ run = false;
432
+ beforeEach(async () => {
433
+ run = false;
434
+ let ready!: () => void, failed!: (error: unknown) => void;
435
+ const prepared = new Promise<void>((resolve, reject) => {
436
+ ready = resolve;
437
+ failed = reject;
438
+ });
439
+ const entered = new Promise<void>((resolve) => {
440
+ start = resolve;
441
+ });
442
+ pending = configureAdmissionFixture(async (h) => {
443
+ const state = await prepare(h);
444
+ ready();
445
+ await entered;
446
+ if (run) await verify(h, state);
447
+ }, options);
448
+ void pending.catch(failed);
449
+ await prepared;
450
+ });
451
+ afterEach(async () => {
452
+ start?.();
453
+ await pending?.catch(() => {});
454
+ });
455
+ it(name, async () => {
456
+ run = true;
457
+ start();
458
+ await pending;
459
+ });
460
+ });
461
+ }
462
+
463
+ /** Actual initial ACK, child admission and completed readonly preflight prerequisites. */
464
+ export async function prepareAdmittedConfigure(
465
+ h: Awaited<ReturnType<typeof setup>>,
466
+ ) {
467
+ await h.complete();
468
+ const child = await h.child();
469
+ const token = await h.core.admitConfigure(child.fresh.call, child.journal);
470
+ const current = h.configureReads(child);
471
+ if (controls.preflight.length === 0)
472
+ controls.preflight.push({
473
+ originalEntry: controls.entries[0],
474
+ coversPreflight: () => true,
475
+ });
476
+ if (controls.write.length === 0)
477
+ controls.write.push({
478
+ originalEntry: controls.entries[0],
479
+ coversConfigure: () => true,
480
+ });
481
+ await captureAdmittedConfigurePreflight(token).invoke();
482
+ return { child, token, current };
483
+ }