@fantastic.dev/better-stripe 0.87.0 → 0.88.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 (115) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalObservation/active-scheduled.d.ts +6 -0
  4. package/dist/client/billing/renewalObservation/active-scheduled.d.ts.map +1 -0
  5. package/dist/client/billing/renewalObservation/active-scheduled.js +37 -0
  6. package/dist/client/billing/renewalObservation/active-scheduled.js.map +1 -0
  7. package/dist/client/billing/renewalObservation/common.d.ts +47 -0
  8. package/dist/client/billing/renewalObservation/common.d.ts.map +1 -0
  9. package/dist/client/billing/renewalObservation/common.js +39 -0
  10. package/dist/client/billing/renewalObservation/common.js.map +1 -0
  11. package/dist/client/billing/renewalObservation/configured-baseline.d.ts +76 -0
  12. package/dist/client/billing/renewalObservation/configured-baseline.d.ts.map +1 -0
  13. package/dist/client/billing/renewalObservation/configured-baseline.js +26 -0
  14. package/dist/client/billing/renewalObservation/configured-baseline.js.map +1 -0
  15. package/dist/client/billing/renewalObservation/coupon-discount-joins.d.ts +53 -0
  16. package/dist/client/billing/renewalObservation/coupon-discount-joins.d.ts.map +1 -0
  17. package/dist/client/billing/renewalObservation/coupon-discount-joins.js +103 -0
  18. package/dist/client/billing/renewalObservation/coupon-discount-joins.js.map +1 -0
  19. package/dist/client/billing/renewalObservation/invoice-tax-identity.d.ts +52 -0
  20. package/dist/client/billing/renewalObservation/invoice-tax-identity.d.ts.map +1 -0
  21. package/dist/client/billing/renewalObservation/invoice-tax-identity.js +49 -0
  22. package/dist/client/billing/renewalObservation/invoice-tax-identity.js.map +1 -0
  23. package/dist/client/billing/renewalObservation/pending-and-stage.d.ts +76 -0
  24. package/dist/client/billing/renewalObservation/pending-and-stage.d.ts.map +1 -0
  25. package/dist/client/billing/renewalObservation/pending-and-stage.js +36 -0
  26. package/dist/client/billing/renewalObservation/pending-and-stage.js.map +1 -0
  27. package/dist/client/billing/renewalObservation/phase-price-normalization.d.ts +57 -0
  28. package/dist/client/billing/renewalObservation/phase-price-normalization.d.ts.map +1 -0
  29. package/dist/client/billing/renewalObservation/phase-price-normalization.js +70 -0
  30. package/dist/client/billing/renewalObservation/phase-price-normalization.js.map +1 -0
  31. package/dist/client/billing/renewalObservation/planProjection.d.ts +8 -0
  32. package/dist/client/billing/renewalObservation/planProjection.d.ts.map +1 -0
  33. package/dist/client/billing/renewalObservation/planProjection.js +150 -0
  34. package/dist/client/billing/renewalObservation/planProjection.js.map +1 -0
  35. package/dist/client/billing/renewalObservation/reference-catalog.d.ts +37 -0
  36. package/dist/client/billing/renewalObservation/reference-catalog.d.ts.map +1 -0
  37. package/dist/client/billing/renewalObservation/reference-catalog.js +109 -0
  38. package/dist/client/billing/renewalObservation/reference-catalog.js.map +1 -0
  39. package/dist/client/billing/renewalObservation/schedule-templates.d.ts +74 -0
  40. package/dist/client/billing/renewalObservation/schedule-templates.d.ts.map +1 -0
  41. package/dist/client/billing/renewalObservation/schedule-templates.js +72 -0
  42. package/dist/client/billing/renewalObservation/schedule-templates.js.map +1 -0
  43. package/dist/client/billing/renewalObservation/scheduled-context.d.ts +44 -0
  44. package/dist/client/billing/renewalObservation/scheduled-context.d.ts.map +1 -0
  45. package/dist/client/billing/renewalObservation/scheduled-context.js +64 -0
  46. package/dist/client/billing/renewalObservation/scheduled-context.js.map +1 -0
  47. package/dist/client/billing/renewalObservation/scheduled-identity.d.ts +53 -0
  48. package/dist/client/billing/renewalObservation/scheduled-identity.d.ts.map +1 -0
  49. package/dist/client/billing/renewalObservation/scheduled-identity.js +95 -0
  50. package/dist/client/billing/renewalObservation/scheduled-identity.js.map +1 -0
  51. package/dist/client/billing/renewalObservation/scheduled-normalization.d.ts +59 -0
  52. package/dist/client/billing/renewalObservation/scheduled-normalization.d.ts.map +1 -0
  53. package/dist/client/billing/renewalObservation/scheduled-normalization.js +29 -0
  54. package/dist/client/billing/renewalObservation/scheduled-normalization.js.map +1 -0
  55. package/dist/client/billing/renewalObservation/settings-normalization.d.ts +54 -0
  56. package/dist/client/billing/renewalObservation/settings-normalization.d.ts.map +1 -0
  57. package/dist/client/billing/renewalObservation/settings-normalization.js +53 -0
  58. package/dist/client/billing/renewalObservation/settings-normalization.js.map +1 -0
  59. package/dist/client/billing/renewalObservation/stage-runner.d.ts +4 -0
  60. package/dist/client/billing/renewalObservation/stage-runner.d.ts.map +1 -0
  61. package/dist/client/billing/renewalObservation/stage-runner.js +34 -0
  62. package/dist/client/billing/renewalObservation/stage-runner.js.map +1 -0
  63. package/dist/client/billing/renewalObservation/weeklyPending.d.ts +13 -0
  64. package/dist/client/billing/renewalObservation/weeklyPending.d.ts.map +1 -0
  65. package/dist/client/billing/renewalObservation/weeklyPending.js +55 -0
  66. package/dist/client/billing/renewalObservation/weeklyPending.js.map +1 -0
  67. package/dist/client/billing/renewalV2/index.d.ts +383 -0
  68. package/dist/client/billing/renewalV2/index.d.ts.map +1 -1
  69. package/dist/client/billing/renewalV2/index.js +8 -3
  70. package/dist/client/billing/renewalV2/index.js.map +1 -1
  71. package/dist/client/billing/renewalV2/observation.d.ts +19 -0
  72. package/dist/client/billing/renewalV2/observation.d.ts.map +1 -0
  73. package/dist/client/billing/renewalV2/observation.js +95 -0
  74. package/dist/client/billing/renewalV2/observation.js.map +1 -0
  75. package/dist/client/billing/renewalV2/observationInput.d.ts +77 -0
  76. package/dist/client/billing/renewalV2/observationInput.d.ts.map +1 -0
  77. package/dist/client/billing/renewalV2/observationInput.js +140 -0
  78. package/dist/client/billing/renewalV2/observationInput.js.map +1 -0
  79. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  80. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  81. package/dist/client/renewal.d.ts +2 -0
  82. package/dist/client/renewal.d.ts.map +1 -1
  83. package/dist/client/renewal.js +1 -0
  84. package/dist/client/renewal.js.map +1 -1
  85. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  86. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  87. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  88. package/dist/component/earnings/triggers.d.ts +16 -16
  89. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  90. package/docs/client-api.md +26 -0
  91. package/docs/renewal-material-observation.md +124 -0
  92. package/docs/renewal-price-replacements.md +3 -0
  93. package/package.json +1 -1
  94. package/src/client/billing/renewalObservation/active-scheduled.ts +67 -0
  95. package/src/client/billing/renewalObservation/common.ts +83 -0
  96. package/src/client/billing/renewalObservation/configured-baseline.ts +55 -0
  97. package/src/client/billing/renewalObservation/coupon-discount-joins.ts +163 -0
  98. package/src/client/billing/renewalObservation/invoice-tax-identity.ts +65 -0
  99. package/src/client/billing/renewalObservation/pending-and-stage.ts +89 -0
  100. package/src/client/billing/renewalObservation/phase-price-normalization.ts +106 -0
  101. package/src/client/billing/renewalObservation/planProjection.ts +177 -0
  102. package/src/client/billing/renewalObservation/reference-catalog.ts +150 -0
  103. package/src/client/billing/renewalObservation/schedule-templates.ts +118 -0
  104. package/src/client/billing/renewalObservation/scheduled-context.ts +98 -0
  105. package/src/client/billing/renewalObservation/scheduled-identity.ts +175 -0
  106. package/src/client/billing/renewalObservation/scheduled-normalization.ts +49 -0
  107. package/src/client/billing/renewalObservation/settings-normalization.ts +60 -0
  108. package/src/client/billing/renewalObservation/stage-runner.ts +30 -0
  109. package/src/client/billing/renewalObservation/weeklyPending.ts +81 -0
  110. package/src/client/billing/renewalV2/index.ts +14 -6
  111. package/src/client/billing/renewalV2/observation.boundary-review.test.ts +49 -0
  112. package/src/client/billing/renewalV2/observation.test.ts +334 -0
  113. package/src/client/billing/renewalV2/observation.ts +149 -0
  114. package/src/client/billing/renewalV2/observationInput.ts +167 -0
  115. package/src/client/renewal.ts +7 -0
@@ -0,0 +1,74 @@
1
+ import { type ObserverCandidateResult } from "./common.js";
2
+ import type { normalize } from "./scheduled-normalization.js";
3
+ export declare function templates(state: ReturnType<typeof normalize>): {
4
+ state?: undefined;
5
+ kind: "result";
6
+ result: ObserverCandidateResult;
7
+ } | {
8
+ result?: undefined;
9
+ kind: "continue";
10
+ state: {
11
+ input: import("./common.js").O;
12
+ rawReads: unknown;
13
+ base: {
14
+ readonly candidateOnly: true;
15
+ readonly providerQualification: "required";
16
+ readonly configureAcknowledged: false;
17
+ readonly configureDispatchOutcome: "unknown";
18
+ readonly providerCallsRequested: false;
19
+ };
20
+ purpose: import("./common.js").Purpose;
21
+ evidence: import("./common.js").Evidence | undefined;
22
+ projection: import("./common.js").O;
23
+ request: import("./common.js").O;
24
+ prepared: import("./common.js").O;
25
+ expected: import("./common.js").O;
26
+ receipt: import("./common.js").O;
27
+ original: import("./common.js").O;
28
+ originalSub: import("./common.js").O;
29
+ originalItem: import("./common.js").O;
30
+ originalSchedule: import("./common.js").O;
31
+ expectedPrice: import("./common.js").O;
32
+ reads: import("./common.js").O;
33
+ schedule: import("./common.js").O;
34
+ sub: import("./common.js").O;
35
+ target: import("./common.js").O;
36
+ customer: import("./common.js").O;
37
+ context: {
38
+ customerAccountId: string;
39
+ livemode: boolean;
40
+ };
41
+ desired: import("./common.js").O;
42
+ ref: (v: unknown, prefix: string, kind: string) => string;
43
+ customerId: string;
44
+ items: import("./common.js").O;
45
+ actualItem: import("./common.js").O;
46
+ current: import("./common.js").O;
47
+ phases: unknown[];
48
+ originalPhase: import("./common.js").O;
49
+ currentOriginal: boolean;
50
+ activeTarget: boolean;
51
+ coupon: (v: unknown) => import("./common.js").O;
52
+ actualItemDiscounts: import("./common.js").O[];
53
+ actualSubDiscounts: import("./common.js").O[];
54
+ originalItemDiscounts: import("./common.js").O[];
55
+ originalSubDiscounts: import("./common.js").O[];
56
+ currentRedemptions: Map<string, import("./common.js").O>;
57
+ invoiceTaxId: (value: unknown) => string;
58
+ retainedPMs: import("./common.js").O[];
59
+ settings: (v: import("./common.js").O) => import("./common.js").O;
60
+ phaseDiscounts: (v: unknown) => import("./common.js").O[];
61
+ priceRef: (v: unknown, known: import("./common.js").O, kind?: string) => string;
62
+ normalizePhase: (v: import("./common.js").O, known: import("./common.js").O) => import("./common.js").O;
63
+ normalizeSchedule: (v: import("./common.js").O) => import("./common.js").O;
64
+ normalizeSub: (v: import("./common.js").O, stage: "original" | "target", knownPrice: import("./common.js").O) => import("./common.js").O;
65
+ sourceWithAssociation: import("./common.js").O;
66
+ attachedTemplate: import("./common.js").O;
67
+ candidateSchedule: import("./common.js").O;
68
+ targetPhase: import("./common.js").O;
69
+ targetTemplate: import("./common.js").O;
70
+ completeTemplate: import("./common.js").O;
71
+ comparableSchedule: import("./common.js").O;
72
+ };
73
+ };
74
+ //# sourceMappingURL=schedule-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule-templates.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/schedule-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC;;UA8CjD,QAAQ;YAKT,uBAAuB;;;UA2CxB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnB"}
@@ -0,0 +1,72 @@
1
+ import { object, array, need, clone, get, equal, timestamp, } from "./common.js";
2
+ export function templates(state) {
3
+ const { rawReads, base, expected, receipt, originalSub, originalItem, originalSchedule, schedule, sub, target, desired, current, phases, originalPhase, currentOriginal, normalizePhase, normalizeSchedule, normalizeSub, } = state;
4
+ // BEGIN original 788-850
5
+ const sourceWithAssociation = clone(originalSub);
6
+ sourceWithAssociation.schedule = receipt.scheduleId;
7
+ const attachedTemplate = normalizeSchedule(originalSchedule);
8
+ attachedTemplate.phases = [
9
+ normalizePhase(originalPhase, get(originalItem, "price")),
10
+ ];
11
+ const candidateSchedule = normalizeSchedule(schedule);
12
+ if (phases.length === 1 && currentOriginal) {
13
+ candidateSchedule.phases = [
14
+ normalizePhase(object(phases[0]), get(originalItem, "price")),
15
+ ];
16
+ need(equal(candidateSchedule, attachedTemplate) &&
17
+ equal(normalizeSub(sub, "original", get(originalItem, "price")), normalizeSub(sourceWithAssociation, "original", get(originalItem, "price"))), "unconfigured_material_drift");
18
+ return {
19
+ kind: "result",
20
+ result: {
21
+ ...base,
22
+ predicate: "attached_unconfigured_match",
23
+ rawReads,
24
+ },
25
+ };
26
+ }
27
+ need(phases.length === 2, "raw_phase_history_unavailable", "unknown");
28
+ const targetPhase = object(phases[1]);
29
+ need(targetPhase.start_date === expected.periodEnd &&
30
+ typeof targetPhase.end_date === "number" &&
31
+ targetPhase.end_date > Number(expected.periodEnd), "target_phase_boundary_mismatch");
32
+ const targetTemplate = clone(originalPhase);
33
+ targetTemplate.start_date = expected.periodEnd;
34
+ targetTemplate.end_date = targetPhase.end_date;
35
+ targetTemplate.proration_behavior = "none";
36
+ targetTemplate.billing_cycle_anchor = object(array(get(desired, "payload").phases)[1]).billing_cycle_anchor;
37
+ const targetTemplateItem = object(array(targetTemplate.items)[0]);
38
+ targetTemplateItem.price = expected.targetPriceId;
39
+ if (targetTemplateItem.plan !== undefined)
40
+ targetTemplateItem.plan = expected.targetPriceId;
41
+ targetTemplate.items = [targetTemplateItem];
42
+ const completeTemplate = clone(attachedTemplate);
43
+ completeTemplate.phases = [
44
+ normalizePhase(originalPhase, get(originalItem, "price")),
45
+ normalizePhase(targetTemplate, target),
46
+ ];
47
+ completeTemplate.current_phase = clone(current);
48
+ candidateSchedule.phases = [
49
+ normalizePhase(object(phases[0]), get(originalItem, "price")),
50
+ normalizePhase(targetPhase, target),
51
+ ];
52
+ need(equal(candidateSchedule, completeTemplate), "full_phase_or_default_read_drift");
53
+ // Separate comparison view. This is NOT a provider read or rewritten ACK.
54
+ const comparableSchedule = clone(candidateSchedule);
55
+ comparableSchedule.current_phase = "NAMED_STAGE_PROGRESS_ONLY";
56
+ timestamp.parse(targetPhase.end_date);
57
+ // END original 788-850
58
+ return {
59
+ kind: "continue",
60
+ state: {
61
+ ...state,
62
+ sourceWithAssociation,
63
+ attachedTemplate,
64
+ candidateSchedule,
65
+ targetPhase,
66
+ targetTemplate,
67
+ completeTemplate,
68
+ comparableSchedule,
69
+ },
70
+ };
71
+ }
72
+ //# sourceMappingURL=schedule-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule-templates.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/schedule-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,KAAK,EACL,SAAS,GAEV,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,SAAS,CAAC,KAAmC;IAC3D,MAAM,EACJ,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,GAAG,EACH,MAAM,EACN,OAAO,EACP,OAAO,EACP,MAAM,EACN,aAAa,EACb,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,GACb,GAAG,KAAK,CAAC;IACV,yBAAyB;IACzB,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IACjD,qBAAqB,CAAC,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IACpD,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC7D,gBAAgB,CAAC,MAAM,GAAG;QACxB,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;KAC1D,CAAC;IACF,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,eAAe,EAAE,CAAC;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,gBAAgB;YAChB,iBAAiB;YACjB,WAAW;YACX,cAAc;YACd,gBAAgB;YAChB,kBAAkB;SACnB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { type O } from "./common.js";
2
+ import type { Purpose, Evidence } from "./common.js";
3
+ type Owned = {
4
+ args: O;
5
+ prepared: unknown;
6
+ receipt: unknown;
7
+ request: unknown;
8
+ };
9
+ /** Fixed internal V2 entry, called only after the public raw reconstruction succeeds. */
10
+ export declare function createContext(owned: Owned, material: unknown, purpose: Purpose, evidence?: Evidence): {
11
+ input: O;
12
+ rawReads: unknown;
13
+ base: {
14
+ readonly candidateOnly: true;
15
+ readonly providerQualification: "required";
16
+ readonly configureAcknowledged: false;
17
+ readonly configureDispatchOutcome: "unknown";
18
+ readonly providerCallsRequested: false;
19
+ };
20
+ purpose: Purpose;
21
+ evidence: Evidence | undefined;
22
+ projection: O;
23
+ request: O;
24
+ prepared: O;
25
+ expected: O;
26
+ receipt: O;
27
+ original: O;
28
+ originalSub: O;
29
+ originalItem: O;
30
+ originalSchedule: O;
31
+ expectedPrice: O;
32
+ reads: O;
33
+ schedule: O;
34
+ sub: O;
35
+ target: O;
36
+ customer: O;
37
+ context: {
38
+ customerAccountId: string;
39
+ livemode: boolean;
40
+ };
41
+ desired: O;
42
+ };
43
+ export {};
44
+ //# sourceMappingURL=scheduled-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-context.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/scheduled-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAChF,yFAAyF;AACzF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,QAAQ;;;;;wCAIM,UAAU;;2CAEP,SAAS;;;;;;;;;;;;;;;;;;;;;;kBAuDJ,OAAO;;;EA4BzC"}
@@ -0,0 +1,64 @@
1
+ import { object, array, need, get } from "./common.js";
2
+ /** Fixed internal V2 entry, called only after the public raw reconstruction succeeds. */
3
+ export function createContext(owned, material, purpose, evidence) {
4
+ const base = {
5
+ candidateOnly: true,
6
+ providerQualification: "required",
7
+ configureAcknowledged: false,
8
+ configureDispatchOutcome: "unknown",
9
+ providerCallsRequested: false,
10
+ };
11
+ const projection = { ...owned.args, prepared: owned.prepared };
12
+ const request = object(owned.request), rawReads = material;
13
+ const input = {
14
+ retainedProjectionInput: projection,
15
+ desiredRequest: request,
16
+ reads: material,
17
+ };
18
+ const desired = object(request), prepared = get(projection, "prepared"), expected = get(prepared, "expected"), receipt = object(owned.receipt);
19
+ const original = get(prepared, "providerSnapshot"), originalSub = get(original, "subscription"), originalItem = object(array(get(originalSub, "items").data)[0]);
20
+ const originalSchedule = get(receipt, "providerSnapshot"), expectedPrice = get(original, "targetPrice");
21
+ need(Object.prototype.hasOwnProperty.call(originalSub, "latest_invoice") &&
22
+ Object.prototype.hasOwnProperty.call(object(object(material).subscription), "latest_invoice"), "missing_latest_invoice", "unknown");
23
+ need(Object.keys(object(material)).every((k) => [
24
+ "schedule",
25
+ "subscription",
26
+ "targetPrice",
27
+ "billingCustomer",
28
+ "coupons",
29
+ ].includes(k)), "unsupported_read_bundle", "unknown");
30
+ const reads = object(material), schedule = get(reads, "schedule"), sub = get(reads, "subscription"), target = get(reads, "targetPrice"), customer = get(reads, "billingCustomer");
31
+ // New public bare-wire boundary: do not let the inherited terminal matcher coerce values.
32
+ need(typeof schedule.status === "string", "invalid_schedule_status", "unknown");
33
+ const context = {
34
+ customerAccountId: String(expected.customerAccountId),
35
+ livemode: expected.livemode,
36
+ };
37
+ // Only immutable retained templates or the separately correlated Customer GET
38
+ // can justify discarding expansion structure in a comparison view.
39
+ return {
40
+ input,
41
+ rawReads,
42
+ base,
43
+ purpose,
44
+ evidence,
45
+ projection,
46
+ request,
47
+ prepared,
48
+ expected,
49
+ receipt,
50
+ original,
51
+ originalSub,
52
+ originalItem,
53
+ originalSchedule,
54
+ expectedPrice,
55
+ reads,
56
+ schedule,
57
+ sub,
58
+ target,
59
+ customer,
60
+ context,
61
+ desired,
62
+ };
63
+ }
64
+ //# sourceMappingURL=scheduled-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-context.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/scheduled-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAU,MAAM,aAAa,CAAC;AAG/D,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAC3B,KAAY,EACZ,QAAiB,EACjB,OAAgB,EAChB,QAAmB;IAEnB,MAAM,IAAI,GAAG;QACX,aAAa,EAAE,IAAI;QACnB,qBAAqB,EAAE,UAAU;QACjC,qBAAqB,EAAE,KAAK;QAC5B,wBAAwB,EAAE,SAAS;QACnC,sBAAsB,EAAE,KAAK;KACrB,CAAC;IACX,MAAM,UAAU,GAAM,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAClE,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EACnC,QAAQ,GAAG,QAAQ,CAAC;IACtB,MAAM,KAAK,GAAM;QACf,uBAAuB,EAAE,UAAU;QACnC,cAAc,EAAE,OAAO;QACvB,KAAK,EAAE,QAAQ;KAChB,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,EAC7B,QAAQ,G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,KAAK,EAAE,aAAa,CAAC,EAClC,QAAQ,GAAG,GAAG,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IAC3C,0FAA0F;IAC1F,IAAI,CACF,OAAO,QAAQ,CAAC,MAAM,KAAK,QAAQ,EACnC,yBAAyB,EACzB,SAAS,CACV,CAAC;IACF,MAAM,OAAO,GAAG;QACd,iBAAiB,EAAE,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QACrD,QAAQ,EAAE,QAAQ,CAAC,QAAmB;KACvC,CAAC;IACF,8EAA8E;IAC9E,mEAAmE;IACnE,OAAO;QACL,KAAK;QACL,QAAQ;QACR,IAAI;QACJ,OAAO;QACP,QAAQ;QACR,UAAU;QACV,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,gBAAgB;QAChB,aAAa;QACb,KAAK;QACL,QAAQ;QACR,GAAG;QACH,MAAM;QACN,QAAQ;QACR,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type ObserverCandidateResult } from "./common.js";
2
+ import type { references } from "./reference-catalog.js";
3
+ export declare function identities(state: ReturnType<typeof references>): {
4
+ kind: "result";
5
+ result: ObserverCandidateResult;
6
+ state?: undefined;
7
+ } | {
8
+ result?: undefined;
9
+ kind: "continue";
10
+ state: {
11
+ input: import("./common.js").O;
12
+ rawReads: unknown;
13
+ base: {
14
+ readonly candidateOnly: true;
15
+ readonly providerQualification: "required";
16
+ readonly configureAcknowledged: false;
17
+ readonly configureDispatchOutcome: "unknown";
18
+ readonly providerCallsRequested: false;
19
+ };
20
+ purpose: import("./common.js").Purpose;
21
+ evidence: import("./common.js").Evidence | undefined;
22
+ projection: import("./common.js").O;
23
+ request: import("./common.js").O;
24
+ prepared: import("./common.js").O;
25
+ expected: import("./common.js").O;
26
+ receipt: import("./common.js").O;
27
+ original: import("./common.js").O;
28
+ originalSub: import("./common.js").O;
29
+ originalItem: import("./common.js").O;
30
+ originalSchedule: import("./common.js").O;
31
+ expectedPrice: import("./common.js").O;
32
+ reads: import("./common.js").O;
33
+ schedule: import("./common.js").O;
34
+ sub: import("./common.js").O;
35
+ target: import("./common.js").O;
36
+ customer: import("./common.js").O;
37
+ context: {
38
+ customerAccountId: string;
39
+ livemode: boolean;
40
+ };
41
+ desired: import("./common.js").O;
42
+ ref: (v: unknown, prefix: string, kind: string) => string;
43
+ customerId: string;
44
+ items: import("./common.js").O;
45
+ actualItem: import("./common.js").O;
46
+ current: import("./common.js").O;
47
+ phases: unknown[];
48
+ originalPhase: import("./common.js").O;
49
+ currentOriginal: boolean;
50
+ activeTarget: boolean;
51
+ };
52
+ };
53
+ //# sourceMappingURL=scheduled-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-identity.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/scheduled-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC;UA+FnD,QAAQ;YAOT,uBAAuB;;;;UA+CxB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAanB"}
@@ -0,0 +1,95 @@
1
+ import { Stop, object, array, need, get, equal, timestamp, planMatchesPrice, } from "./common.js";
2
+ export function identities(state) {
3
+ const { input, rawReads, base, projection, expected, receipt, originalSub, originalItem, originalSchedule, expectedPrice, schedule, sub, target, customer, context, ref, } = state;
4
+ // BEGIN original 280-415
5
+ need(planMatchesPrice(originalItem.plan, originalItem.price, context), "unproven_original_plan_price_mapping", "unknown");
6
+ const customerId = ref(originalSub.customer, "cus", "customer");
7
+ need(schedule.id === receipt.scheduleId &&
8
+ schedule.object === "subscription_schedule" &&
9
+ schedule.customer_account === expected.customerAccountId &&
10
+ schedule.livemode === expected.livemode &&
11
+ ref(schedule.customer, "cus", "customer") === customerId, "owned_schedule_identity_mismatch");
12
+ need(sub.id === expected.subscriptionId &&
13
+ sub.object === "subscription" &&
14
+ sub.customer_account === expected.customerAccountId &&
15
+ sub.livemode === expected.livemode &&
16
+ ref(sub.customer, "cus", "customer") === customerId, "original_subscription_identity_mismatch");
17
+ need(customer.id === customerId &&
18
+ customer.object === "customer" &&
19
+ customer.customer_account === expected.customerAccountId &&
20
+ customer.livemode === expected.livemode, "billing_customer_identity_mismatch");
21
+ for (const value of [schedule.customer, sub.customer])
22
+ if (typeof value !== "string") {
23
+ const expanded = object(value);
24
+ if (!Object.keys(expanded).every((k) => ["id", "object", "deleted", "livemode", "customer_account"].includes(k)))
25
+ need(equal(expanded, customer), "expanded_customer_read_drift");
26
+ }
27
+ for (const [expanded, correlated, kind] of [
28
+ [sub.schedule, schedule, "subscription_schedule"],
29
+ [schedule.subscription, sub, "subscription"],
30
+ ])
31
+ if (expanded !== null && typeof expanded !== "string") {
32
+ const full = object(expanded);
33
+ if (!Object.keys(full).every((k) => ["id", "object", "deleted", "livemode", "customer_account"].includes(k)))
34
+ need(equal(full, correlated), "expanded_" + kind + "_read_drift");
35
+ }
36
+ if (input.configureAcknowledgement !== undefined)
37
+ throw new Stop("configure_ack_contract_unavailable", "unknown");
38
+ if (["canceled", "released", "completed", "not_started"].includes(String(schedule.status))) {
39
+ if (schedule.subscription !== null)
40
+ need(ref(schedule.subscription, "sub", "subscription") ===
41
+ expected.subscriptionId, "terminal_original_relation_mismatch");
42
+ if (schedule.released_subscription !== null)
43
+ need(schedule.released_subscription === expected.subscriptionId, "terminal_released_relation_mismatch");
44
+ return {
45
+ kind: "result",
46
+ result: {
47
+ ...base,
48
+ predicate: "terminal_facts_only",
49
+ providerStatus: schedule.status,
50
+ effectiveness: "unknown",
51
+ rawReads,
52
+ },
53
+ };
54
+ }
55
+ need(schedule.status === "active", "unsupported_schedule_status", "unknown");
56
+ need(ref(schedule.subscription, "sub", "subscription") ===
57
+ expected.subscriptionId &&
58
+ ref(sub.schedule, "sub_sched", "subscription_schedule") ===
59
+ receipt.scheduleId, "active_owned_association_mismatch");
60
+ need(equal(target, expectedPrice), "target_full_read_drift");
61
+ need(equal(customer, projection.billingCustomer), "billing_customer_full_read_drift");
62
+ const items = get(sub, "items");
63
+ need(items.has_more === false && array(items.data).length === 1, "incomplete_or_ambiguous_current_items", "unknown");
64
+ const actualItem = object(array(items.data)[0]);
65
+ need(typeof actualItem.id === "string" &&
66
+ /^si_[A-Za-z0-9_]+$/.test(actualItem.id) &&
67
+ actualItem.subscription === expected.subscriptionId, "target_item_identity_mismatch");
68
+ const current = get(schedule, "current_phase");
69
+ need(Object.keys(current).length === 2 &&
70
+ Object.prototype.hasOwnProperty.call(current, "start_date") &&
71
+ Object.prototype.hasOwnProperty.call(current, "end_date"), "unqualified_current_phase_shape", "unknown");
72
+ timestamp.parse(current.start_date);
73
+ timestamp.parse(current.end_date);
74
+ const phases = array(schedule.phases);
75
+ const originalPhase = object(array(originalSchedule.phases)[0]);
76
+ const currentOriginal = current.start_date === expected.periodStart &&
77
+ current.end_date === expected.periodEnd;
78
+ const activeTarget = current.start_date === expected.periodEnd;
79
+ // END original 280-415
80
+ return {
81
+ kind: "continue",
82
+ state: {
83
+ ...state,
84
+ customerId,
85
+ items,
86
+ actualItem,
87
+ current,
88
+ phases,
89
+ originalPhase,
90
+ currentOriginal,
91
+ activeTarget,
92
+ },
93
+ };
94
+ }
95
+ //# sourceMappingURL=scheduled-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-identity.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/scheduled-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,IAAI,EACJ,GAAG,EACH,KAAK,EACL,SAAS,EACT,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AAErB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AQ,CAAC,WAAW;QAC3C,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,SAAS,CAAC;IAC1C,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,SAAS,CAAC;IAC/D,uBAAuB;IACvB,OAAO;QACL,IAAI,EAAE,UAAmB;QACzB,KAAK,EAAE;YACL,GAAG,KAAK;YACR,UAAU;YACV,KAAK;YACL,UAAU;YACV,OAAO;YACP,MAAM;YACN,aAAa;YACb,eAAe;YACf,YAAY;SACb;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { type O } from "./common.js";
2
+ import type { phasesStage } from "./phase-price-normalization.js";
3
+ export declare function normalize(state: ReturnType<typeof phasesStage>): {
4
+ input: O;
5
+ rawReads: unknown;
6
+ base: {
7
+ readonly candidateOnly: true;
8
+ readonly providerQualification: "required";
9
+ readonly configureAcknowledged: false;
10
+ readonly configureDispatchOutcome: "unknown";
11
+ readonly providerCallsRequested: false;
12
+ };
13
+ purpose: import("./common.js").Purpose;
14
+ evidence: import("./common.js").Evidence | undefined;
15
+ projection: O;
16
+ request: O;
17
+ prepared: O;
18
+ expected: O;
19
+ receipt: O;
20
+ original: O;
21
+ originalSub: O;
22
+ originalItem: O;
23
+ originalSchedule: O;
24
+ expectedPrice: O;
25
+ reads: O;
26
+ schedule: O;
27
+ sub: O;
28
+ target: O;
29
+ customer: O;
30
+ context: {
31
+ customerAccountId: string;
32
+ livemode: boolean;
33
+ };
34
+ desired: O;
35
+ ref: (v: unknown, prefix: string, kind: string) => string;
36
+ customerId: string;
37
+ items: O;
38
+ actualItem: O;
39
+ current: O;
40
+ phases: unknown[];
41
+ originalPhase: O;
42
+ currentOriginal: boolean;
43
+ activeTarget: boolean;
44
+ coupon: (v: unknown) => O;
45
+ actualItemDiscounts: O[];
46
+ actualSubDiscounts: O[];
47
+ originalItemDiscounts: O[];
48
+ originalSubDiscounts: O[];
49
+ currentRedemptions: Map<string, O>;
50
+ invoiceTaxId: (value: unknown) => string;
51
+ retainedPMs: O[];
52
+ settings: (v: O) => O;
53
+ phaseDiscounts: (v: unknown) => O[];
54
+ priceRef: (v: unknown, known: O, kind?: string) => string;
55
+ normalizePhase: (v: O, known: O) => O;
56
+ normalizeSchedule: (v: O) => O;
57
+ normalizeSub: (v: O, stage: "original" | "target", knownPrice: O) => O;
58
+ };
59
+ //# sourceMappingURL=scheduled-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-normalization.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/scheduled-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,CAAC,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAW/B,CAAC;sBAON,CAAC,SAAS,UAAU,GAAG,QAAQ,cAAc,CAAC;EAoBxE"}
@@ -0,0 +1,29 @@
1
+ import { object, array, need, clone, get, planMatchesPrice, } from "./common.js";
2
+ export function normalize(state) {
3
+ const { context, ref, actualItemDiscounts, actualSubDiscounts, originalItemDiscounts, originalSubDiscounts, settings, } = state;
4
+ // BEGIN original 759-787
5
+ const normalizeSchedule = (v) => {
6
+ const s = clone(v);
7
+ s.customer = ref(s.customer, "cus", "customer");
8
+ s.subscription = ref(s.subscription, "sub", "subscription");
9
+ s.default_settings = settings(get(s, "default_settings"));
10
+ return s;
11
+ };
12
+ const normalizeSub = (v, stage, knownPrice) => {
13
+ const s = settings(v);
14
+ s.customer = ref(s.customer, "cus", "customer");
15
+ s.schedule = ref(s.schedule, "sub_sched", "subscription_schedule");
16
+ const i = clone(object(array(get(s, "items").data)[0]));
17
+ need(planMatchesPrice(i.plan, knownPrice, context), "unproven_native_plan_price_mapping", "unknown");
18
+ i.plan = knownPrice.id;
19
+ i.discounts =
20
+ stage === "target" ? actualItemDiscounts : originalItemDiscounts;
21
+ s.discounts =
22
+ stage === "target" ? actualSubDiscounts : originalSubDiscounts;
23
+ get(s, "items").data = [i];
24
+ return s;
25
+ };
26
+ // END original 759-787
27
+ return { ...state, normalizeSchedule, normalizeSub };
28
+ }
29
+ //# sourceMappingURL=scheduled-normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduled-normalization.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/scheduled-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,SAAS,CAAC,KAAqC;IAC7D,MAAM,EACJ,OAAO,EACP,GAAG,EACH,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,GACT,GAAG,KAAK,CAAC;IACV,yBAAyB;IACzB,MAAM,iBAAiB,GAAG,CAAC,CAAI,EAAE,EAAE;QACjC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QAChD,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QAC5D,CAAC,CAAC,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,MAAM,YAAY,GAAG,CAAC,CAAI,EAAE,KAA4B,EAAE,UAAa,EAAE,EAAE;QACzE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QAChD,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;QACnE,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,IAAI,CACF,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAC7C,oCAAoC,EACpC,SAAS,CACV,CAAC;QACF,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC;QACvB,CAAC,CAAC,SAAS;YACT,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,qBAAqB,CAAC;QACnE,CAAC,CAAC,SAAS;YACT,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,oBAAoB,CAAC;QACjE,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,uBAAuB;IACvB,OAAO,EAAE,GAAG,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { type O } from "./common.js";
2
+ import type { taxes } from "./invoice-tax-identity.js";
3
+ export declare function settingsStage(state: ReturnType<typeof taxes>): {
4
+ input: O;
5
+ rawReads: unknown;
6
+ base: {
7
+ readonly candidateOnly: true;
8
+ readonly providerQualification: "required";
9
+ readonly configureAcknowledged: false;
10
+ readonly configureDispatchOutcome: "unknown";
11
+ readonly providerCallsRequested: false;
12
+ };
13
+ purpose: import("./common.js").Purpose;
14
+ evidence: import("./common.js").Evidence | undefined;
15
+ projection: O;
16
+ request: O;
17
+ prepared: O;
18
+ expected: O;
19
+ receipt: O;
20
+ original: O;
21
+ originalSub: O;
22
+ originalItem: O;
23
+ originalSchedule: O;
24
+ expectedPrice: O;
25
+ reads: O;
26
+ schedule: O;
27
+ sub: O;
28
+ target: O;
29
+ customer: O;
30
+ context: {
31
+ customerAccountId: string;
32
+ livemode: boolean;
33
+ };
34
+ desired: O;
35
+ ref: (v: unknown, prefix: string, kind: string) => string;
36
+ customerId: string;
37
+ items: O;
38
+ actualItem: O;
39
+ current: O;
40
+ phases: unknown[];
41
+ originalPhase: O;
42
+ currentOriginal: boolean;
43
+ activeTarget: boolean;
44
+ coupon: (v: unknown) => O;
45
+ actualItemDiscounts: O[];
46
+ actualSubDiscounts: O[];
47
+ originalItemDiscounts: O[];
48
+ originalSubDiscounts: O[];
49
+ currentRedemptions: Map<string, O>;
50
+ invoiceTaxId: (value: unknown) => string;
51
+ retainedPMs: O[];
52
+ settings: (v: O) => O;
53
+ };
54
+ //# sourceMappingURL=settings-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-normalization.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/settings-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAGtC,CAAC;EAsDvB"}