@fantastic.dev/better-stripe 0.109.1 → 0.110.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 (52) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts +41 -0
  4. package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +40 -3
  6. package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +10 -1
  8. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +162 -57
  10. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.d.ts +14 -0
  12. package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.d.ts.map +1 -0
  13. package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.js +109 -0
  14. package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.js.map +1 -0
  15. package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.d.ts +20 -0
  16. package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.d.ts.map +1 -0
  17. package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.js +176 -0
  18. package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.js.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -1
  20. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +1 -1
  21. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -1
  22. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -1
  23. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +24 -0
  24. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -1
  25. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +1 -0
  26. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -1
  27. package/dist/client/billing/renewalObservation/evidence-invoice.d.ts.map +1 -1
  28. package/dist/client/billing/renewalObservation/evidence-invoice.js +3 -0
  29. package/dist/client/billing/renewalObservation/evidence-invoice.js.map +1 -1
  30. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  31. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
  32. package/dist/component/balanceFunding/mutations.d.ts +43 -43
  33. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  34. package/dist/component/balanceFunding/queries.d.ts +1 -1
  35. package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
  36. package/docs/renewal-invoice-reads.md +85 -0
  37. package/package.json +1 -1
  38. package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +69 -3
  39. package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +189 -59
  40. package/src/client/billing/renewalAttach/internal/observation/invoiceActor.integration.test.ts +142 -0
  41. package/src/client/billing/renewalAttach/internal/observation/invoiceActorControls.integration.test.ts +495 -0
  42. package/src/client/billing/renewalAttach/internal/observation/invoiceAuthorization.ts +145 -0
  43. package/src/client/billing/renewalAttach/internal/observation/invoicePlan.ts +284 -0
  44. package/src/client/billing/renewalAttach/internal/observation/profile.ts +1 -1
  45. package/src/client/billing/renewalAttach/internal/observation/types.ts +7 -1
  46. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +30 -0
  47. package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +74 -62
  48. package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +158 -0
  49. package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +11 -1
  50. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +4 -0
  51. package/src/client/billing/renewalObservation/evidence-invoice-identity.test.ts +13 -0
  52. package/src/client/billing/renewalObservation/evidence-invoice.ts +8 -0
@@ -32,6 +32,7 @@ const controls = vi.hoisted(() => ({
32
32
  selectors: 0,
33
33
  history: [] as unknown[],
34
34
  observation: [] as unknown[],
35
+ invoices: [] as unknown[],
35
36
  onSelect: null as null | ((client: object) => void),
36
37
  }));
37
38
  vi.mock("../operations/sourceOperations.js", () => {
@@ -46,6 +47,7 @@ vi.mock("../operations/sourceOperations.js", () => {
46
47
  COMPILED_CONFIGURE_WRITE_ENTRIES: controls.write,
47
48
  COMPILED_OBSERVATION_HISTORY_ENTRIES: controls.history,
48
49
  COMPILED_FRESH_OBSERVATION_ENTRIES: controls.observation,
50
+ COMPILED_INVOICE_OBSERVATION_ENTRIES: controls.invoices,
49
51
  loadConfigureWriteTransportSource: poison,
50
52
  loadConfigureReplayTransportSource: poison,
51
53
  loadFixedConfigureWriteOperation: poison,
@@ -112,6 +114,7 @@ beforeEach(() => {
112
114
  controls.selectors = 0;
113
115
  controls.history.splice(0);
114
116
  controls.observation.splice(0);
117
+ controls.invoices.splice(0);
115
118
  controls.onSelect = null;
116
119
  controls.entries.splice(0, controls.entries.length, {
117
120
  coversRetained: () => true,
@@ -181,7 +184,10 @@ async function setup(
181
184
  if (completion.mode === "replay" && completion.posts === 1)
182
185
  throw Error("CONTROLLED_LOST_RESPONSE");
183
186
  }
184
- const body = method === "POST" ? baseline.schedule : routes.get(path);
187
+ const body =
188
+ method === "POST"
189
+ ? baseline.schedule
190
+ : (routes.get(path + parsed.search) ?? routes.get(path));
185
191
  assert(body);
186
192
  assert(
187
193
  method === "GET" ||
@@ -404,6 +410,9 @@ export async function configureAdmissionFixture(
404
410
  hostQuery?: NonNullable<
405
411
  Parameters<typeof initialOperations>[2]
406
412
  >["hostQuery"];
413
+ hostInvoiceQuery?: NonNullable<
414
+ Parameters<typeof initialOperations>[2]
415
+ >["hostQuery"];
407
416
  count?: number;
408
417
  keys?: readonly string[];
409
418
  afterBind?: (reply: unknown) => Promise<void>;
@@ -434,6 +443,7 @@ export async function configureAdmissionFixture(
434
443
  keys: options.keys,
435
444
  identity: options.identity,
436
445
  hostQuery: options.hostQuery,
446
+ hostInvoiceQuery: options.hostInvoiceQuery,
437
447
  source: captureRetainedInput(baseline.original),
438
448
  afterBind: options.afterBind,
439
449
  afterQuery: options.afterQuery,
@@ -41,6 +41,7 @@ export async function initialOperations(
41
41
  options: {
42
42
  identity?: { subject: string; issuer: string; tokenIdentifier: string };
43
43
  hostQuery?: ReturnType<typeof queryGeneric>;
44
+ hostInvoiceQuery?: ReturnType<typeof queryGeneric>;
44
45
  epochMs?: number;
45
46
  workEndWallMs?: number;
46
47
  endWallMs?: number;
@@ -180,6 +181,9 @@ export async function initialOperations(
180
181
  let secondaryId = 0;
181
182
  const host = {
182
183
  ...(options.hostQuery ? { authorize: options.hostQuery } : {}),
184
+ ...(options.hostInvoiceQuery
185
+ ? { authorizeInvoices: options.hostInvoiceQuery }
186
+ : {}),
183
187
  secondary: actionGeneric({
184
188
  args: { id: v.string() },
185
189
  handler: async (ctx, args): Promise<null> => {
@@ -46,3 +46,16 @@ it.each(["string", "minimal-expanded", "full-expanded"] as const)(
46
46
  expect(f.h.input).toEqual(before);
47
47
  },
48
48
  );
49
+
50
+ it("distinct invoices cannot reuse one line ID for incompatible period inventories", async () => {
51
+ const f = invoiceRecipe("subscription_cycle", "open");
52
+ await prerequisites(f.h);
53
+ set(f.currentLine, "id", f.originalLine.id);
54
+ const result = await inspectRenewalEvidenceV1(f.h.input);
55
+ expect(result.invoiceEvidence).toEqual({
56
+ predicate: "conflict",
57
+ original: null,
58
+ current: null,
59
+ reason: "invoice_relation_mismatch",
60
+ });
61
+ });
@@ -251,6 +251,14 @@ export async function inspectInvoiceEvidenceV1(
251
251
  };
252
252
  const original = examine("original"),
253
253
  current = examine("current");
254
+ const lineIds = (role: "original" | "current") =>
255
+ array(invoiceRecordV1(inventory[role]).linePages).flatMap((page) =>
256
+ array(invoiceRecordV1(page).data).map(
257
+ (line) => invoiceRecordV1(line).id,
258
+ ),
259
+ );
260
+ const originalIds = new Set(lineIds("original"));
261
+ relation(lineIds("current").every((id) => !originalIds.has(id)));
254
262
  return {
255
263
  predicate: "invoice_lines_correlated",
256
264
  original,