@fantastic.dev/better-stripe 0.94.0 → 0.95.1

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts +6 -0
  4. package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/operationJournal.js +10 -0
  6. package/dist/client/billing/renewalAttach/internal/operationJournal.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +5 -0
  8. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +40 -0
  10. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +13 -0
  12. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -0
  13. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +43 -0
  14. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -0
  15. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts +32 -0
  16. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -0
  17. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +102 -0
  18. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.d.ts +3 -0
  20. package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.d.ts.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.js +59 -0
  22. package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.js.map +1 -0
  23. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.d.ts +11 -0
  24. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.d.ts.map +1 -0
  25. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.js +132 -0
  26. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.js.map +1 -0
  27. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.d.ts +6 -0
  28. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.d.ts.map +1 -0
  29. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.js +16 -0
  30. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.js.map +1 -0
  31. package/dist/client/billing/renewalObservation/evidence-invoice-lines.d.ts +27 -0
  32. package/dist/client/billing/renewalObservation/evidence-invoice-lines.d.ts.map +1 -0
  33. package/dist/client/billing/renewalObservation/evidence-invoice-lines.js +164 -0
  34. package/dist/client/billing/renewalObservation/evidence-invoice-lines.js.map +1 -0
  35. package/dist/client/billing/renewalObservation/evidence-invoice.d.ts +4 -0
  36. package/dist/client/billing/renewalObservation/evidence-invoice.d.ts.map +1 -0
  37. package/dist/client/billing/renewalObservation/evidence-invoice.js +190 -0
  38. package/dist/client/billing/renewalObservation/evidence-invoice.js.map +1 -0
  39. package/dist/client/billing/renewalObservation/evidence-material.d.ts +26 -0
  40. package/dist/client/billing/renewalObservation/evidence-material.d.ts.map +1 -0
  41. package/dist/client/billing/renewalObservation/evidence-material.js +253 -0
  42. package/dist/client/billing/renewalObservation/evidence-material.js.map +1 -0
  43. package/dist/client/billing/renewalObservation/evidence-v1-types.d.ts +156 -0
  44. package/dist/client/billing/renewalObservation/evidence-v1-types.d.ts.map +1 -0
  45. package/dist/client/billing/renewalObservation/evidence-v1-types.js +2 -0
  46. package/dist/client/billing/renewalObservation/evidence-v1-types.js.map +1 -0
  47. package/dist/client/billing/renewalObservation/evidence-v1.d.ts +4 -0
  48. package/dist/client/billing/renewalObservation/evidence-v1.d.ts.map +1 -0
  49. package/dist/client/billing/renewalObservation/evidence-v1.js +263 -0
  50. package/dist/client/billing/renewalObservation/evidence-v1.js.map +1 -0
  51. package/dist/client/billing/renewalObservation/terminal-evidence.d.ts +17 -0
  52. package/dist/client/billing/renewalObservation/terminal-evidence.d.ts.map +1 -0
  53. package/dist/client/billing/renewalObservation/terminal-evidence.js +289 -0
  54. package/dist/client/billing/renewalObservation/terminal-evidence.js.map +1 -0
  55. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
  56. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  57. package/dist/component/balanceFunding/mutations.d.ts +43 -43
  58. package/dist/component/balanceFunding/queries.d.ts +1 -1
  59. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  60. package/dist/component/earnings/triggers.d.ts +16 -16
  61. package/dist/component/payoutRelease/queries.d.ts +2 -2
  62. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  63. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  64. package/docs/renewal-context-reads.md +28 -0
  65. package/docs/renewal-material-observation.md +50 -0
  66. package/package.json +1 -1
  67. package/src/client/billing/renewalAttach/internal/operationJournal.ts +12 -0
  68. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +59 -0
  69. package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +58 -0
  70. package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +158 -0
  71. package/src/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.ts +54 -0
  72. package/src/client/billing/renewalAttach/internal/producer/ownerFactory.ts +136 -0
  73. package/src/client/billing/renewalAttach/internal/producer/producerClock.integration.test.ts +175 -0
  74. package/src/client/billing/renewalAttach/internal/producer/producerOwner.integration.test.ts +449 -0
  75. package/src/client/billing/renewalAttach/internal/producer/stockDelegateFactory.ts +23 -0
  76. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialDeclarations.ts +5 -0
  77. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +142 -0
  78. package/src/client/billing/renewalObservation/evidence-admission.test.ts +219 -0
  79. package/src/client/billing/renewalObservation/evidence-history.test.ts +187 -0
  80. package/src/client/billing/renewalObservation/evidence-invoice-controls.test.ts +293 -0
  81. package/src/client/billing/renewalObservation/evidence-invoice-lines.ts +238 -0
  82. package/src/client/billing/renewalObservation/evidence-invoice.test.ts +177 -0
  83. package/src/client/billing/renewalObservation/evidence-invoice.ts +271 -0
  84. package/src/client/billing/renewalObservation/evidence-material.test.ts +289 -0
  85. package/src/client/billing/renewalObservation/evidence-material.ts +313 -0
  86. package/src/client/billing/renewalObservation/evidence-v1-types.ts +186 -0
  87. package/src/client/billing/renewalObservation/evidence-v1.test.ts +371 -0
  88. package/src/client/billing/renewalObservation/evidence-v1.ts +286 -0
  89. package/src/client/billing/renewalObservation/terminal-evidence.ts +379 -0
@@ -0,0 +1,132 @@
1
+ import { readInitialLineage } from "./lineageAuthority.js";
2
+ import { types } from "node:util";
3
+ const owners = new WeakMap();
4
+ function stop() {
5
+ throw Error("INITIAL_OWNER_STOP");
6
+ }
7
+ /** One canonical, independently retired Owner per original private lineage. */
8
+ export function ownerForInitialLineage(token) {
9
+ const existing = owners.get(token);
10
+ if (existing)
11
+ return existing;
12
+ const lineage = readInitialLineage(token);
13
+ const { basis, policy } = lineage;
14
+ let closed = false;
15
+ let checking = false;
16
+ let last = null;
17
+ const listeners = new Set();
18
+ let timer;
19
+ function retire() {
20
+ if (closed)
21
+ return;
22
+ closed = true;
23
+ if (timer !== undefined)
24
+ clearTimeout(timer);
25
+ const active = [...listeners];
26
+ listeners.clear();
27
+ for (const listener of active) {
28
+ if (!listener.active)
29
+ continue;
30
+ listener.active = false;
31
+ try {
32
+ Reflect.apply(listener.fn, undefined, []);
33
+ }
34
+ catch {
35
+ /* Retirement cannot be reversed by a waiter. */
36
+ }
37
+ }
38
+ }
39
+ function check() {
40
+ if (closed || checking) {
41
+ retire();
42
+ stop();
43
+ }
44
+ checking = true;
45
+ try {
46
+ if (readInitialLineage(token) !== lineage)
47
+ stop();
48
+ const wallMs = lineage.wall();
49
+ const ns = lineage.monotonic();
50
+ const nowSeconds = Math.floor(wallMs / 1000);
51
+ if (!Number.isSafeInteger(wallMs) ||
52
+ wallMs < basis.startWallMs ||
53
+ wallMs >= basis.workEndWallMs ||
54
+ wallMs >= basis.endWallMs ||
55
+ ns < lineage.initialHighNs ||
56
+ ns >= basis.workEndNs ||
57
+ ns >= basis.endNs ||
58
+ (last && (wallMs < last.wallMs || ns < last.ns)) ||
59
+ nowSeconds < policy.firstDispatchedAt ||
60
+ nowSeconds - policy.firstDispatchedAt >= 86400 ||
61
+ nowSeconds < policy.periodStart ||
62
+ nowSeconds >= policy.periodEnd ||
63
+ closed)
64
+ stop();
65
+ last = Object.freeze({ wallMs, ns, nowSeconds, retired: false });
66
+ return last;
67
+ }
68
+ catch {
69
+ retire();
70
+ return stop();
71
+ }
72
+ finally {
73
+ checking = false;
74
+ }
75
+ }
76
+ const owner = Object.freeze({
77
+ get basis() {
78
+ if (closed)
79
+ stop();
80
+ return basis;
81
+ },
82
+ check,
83
+ sample: check,
84
+ retire,
85
+ subscribe(listener) {
86
+ if (typeof listener !== "function" || types.isProxy(listener)) {
87
+ retire();
88
+ stop();
89
+ }
90
+ if (closed) {
91
+ try {
92
+ listener();
93
+ }
94
+ catch {
95
+ /* Already retired. */
96
+ }
97
+ return () => { };
98
+ }
99
+ const record = { fn: listener, active: true };
100
+ listeners.add(record);
101
+ return () => {
102
+ record.active = false;
103
+ listeners.delete(record);
104
+ };
105
+ },
106
+ });
107
+ owners.set(token, owner);
108
+ function schedule() {
109
+ const sample = check();
110
+ const monotonicMs = Number((basis.workEndNs - sample.ns + 999999n) / 1000000n);
111
+ // Bound each timer chunk, retaining both original absolute cutoffs.
112
+ timer = setTimeout(() => {
113
+ try {
114
+ schedule();
115
+ }
116
+ catch {
117
+ retire();
118
+ }
119
+ }, Math.min(2147483647, basis.workEndWallMs - sample.wallMs, monotonicMs));
120
+ timer.unref?.();
121
+ }
122
+ try {
123
+ schedule();
124
+ check();
125
+ return owner;
126
+ }
127
+ catch (error) {
128
+ retire();
129
+ throw error;
130
+ }
131
+ }
132
+ //# sourceMappingURL=ownerFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownerFactory.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/producer/ownerFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAWlC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAwB,CAAC;AACnD,SAAS,IAAI;IACX,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACpC,CAAC;AACD,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,IAAI,GAAoC,IAAI,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuC,CAAC;IACjE,IAAI,KAAgD,CAAC;IACrD,SAAS,MAAM;QACb,IAAI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,KAAK,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;QAC9B,SAAS,CAAC,KAAK,EAAE,CAAC;QAClB,KAAK,MAAM,QA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,CAAC;KACF,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACzB,SAAS,QAAQ;QACf,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,MAAM,CACxB,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,QAAQ,CACnD,CAAC;QACF,oEAAoE;QACpE,KAAK,GAAG,UAAU,CAChB,GAAG,EAAE;YACH,IAAI,CAAC;gBACH,QAAQ,EAAE,CAAC;YACb,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CACvE,CAAC;QACF,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAClB,CAAC;IACD,IAAI,CAAC;QACH,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,CAAC;QACR,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC;QACT,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type Stripe from "stripe";
2
+ /** Fixed selected client and original receiver; no replacement-client parameter. */
3
+ export declare function stockDelegateForInitialLineage(token: object): Readonly<{
4
+ rawRequest: Stripe["rawRequest"];
5
+ }>;
6
+ //# sourceMappingURL=stockDelegateFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stockDelegateFactory.d.ts","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/producer/stockDelegateFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAKjC,oFAAoF;AACpF,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;IACtE,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;CAClC,CAAC,CAcD"}
@@ -0,0 +1,16 @@
1
+ import { readInitialLineage } from "./lineageAuthority.js";
2
+ import { ownerForInitialLineage } from "./ownerFactory.js";
3
+ import { ownedAwaitForInitialLineage } from "./ownedAwaitFactory.js";
4
+ /** Fixed selected client and original receiver; no replacement-client parameter. */
5
+ export function stockDelegateForInitialLineage(token) {
6
+ const lineage = readInitialLineage(token);
7
+ const owner = ownerForInitialLineage(token);
8
+ const owned = ownedAwaitForInitialLineage(token);
9
+ return Object.freeze({
10
+ rawRequest(...args) {
11
+ owner.check();
12
+ return owned(() => Reflect.apply(lineage.method, lineage.client, args));
13
+ },
14
+ });
15
+ }
16
+ //# sourceMappingURL=stockDelegateFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stockDelegateFactory.js","sourceRoot":"","sources":["../../../../../../src/client/billing/renewalAttach/internal/producer/stockDelegateFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,oFAAoF;AACpF,MAAM,UAAU,8BAA8B,CAAC,KAAa;IAG1D,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,UAAU,CACR,GAAG,IAAsC;YAEzC,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,OAAO,KAAK,CAAC,GAAG,EAAE,CAChB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAChB,CAAC;QACxC,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { InvoiceLineMatchV1, Reason, Period } from "./evidence-v1-types.js";
2
+ import { type O } from "./common.js";
3
+ export declare class InvoiceEvidenceStopV1 extends Error {
4
+ readonly reason: Reason;
5
+ readonly predicate: "unknown" | "conflict";
6
+ constructor(reason: Reason, predicate?: "unknown" | "conflict");
7
+ }
8
+ export declare function invoiceRecordV1(value: unknown): O;
9
+ /** Expanded references need their complete separately correlated counterpart. */
10
+ export declare function invoiceReferenceV1(raw: unknown, expected: string, kind: string, known?: O): string;
11
+ export declare function sameInvoiceDecimalV1(left: unknown, right: unknown): boolean;
12
+ type LineContext = {
13
+ invoiceId: string;
14
+ invoiceStatus: InvoiceLineMatchV1["invoiceStatus"];
15
+ subscriptionId: string;
16
+ subscription: O;
17
+ itemId: string;
18
+ period: Period;
19
+ price: O;
20
+ productId: string;
21
+ quantity: number;
22
+ livemode: boolean;
23
+ };
24
+ /** Complete bounded page DATA only, never cursor/request or provider provenance. */
25
+ export declare function inspectInvoiceLinesV1(raw: unknown, context: LineContext): InvoiceLineMatchV1;
26
+ export {};
27
+ //# sourceMappingURL=evidence-invoice-lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-invoice-lines.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/evidence-invoice-lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAS,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,qBAAsB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU;IAF5C,YACW,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAS,GAAG,UAAsB,EAGvD;CACF;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAIjD;AACD,iFAAiF;AACjF,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,CAAC,GACR,MAAM,CA2BR;AAWD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAQ3E;AACD,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,CAAC,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAkHF,oFAAoF;AACpF,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,WAAW,GACnB,kBAAkB,CAmCpB"}
@@ -0,0 +1,164 @@
1
+ import { equal } from "./common.js";
2
+ export class InvoiceEvidenceStopV1 extends Error {
3
+ reason;
4
+ predicate;
5
+ constructor(reason, predicate = "unknown") {
6
+ super(reason);
7
+ this.reason = reason;
8
+ this.predicate = predicate;
9
+ }
10
+ }
11
+ export function invoiceRecordV1(value) {
12
+ if (!value || typeof value !== "object" || Array.isArray(value))
13
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
14
+ return value;
15
+ }
16
+ /** Expanded references need their complete separately correlated counterpart. */
17
+ export function invoiceReferenceV1(raw, expected, kind, known) {
18
+ if (raw === null || raw === undefined)
19
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
20
+ if (typeof raw === "string") {
21
+ if (raw !== expected)
22
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
23
+ return raw;
24
+ }
25
+ const expanded = invoiceRecordV1(raw);
26
+ if (expanded.id !== expected ||
27
+ expanded.object !== kind ||
28
+ expanded.deleted === true)
29
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
30
+ for (const field of ["livemode", "customer_account"])
31
+ if (Object.prototype.hasOwnProperty.call(expanded, field) &&
32
+ (!known || expanded[field] !== known[field]))
33
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
34
+ const minimal = Object.keys(expanded).every((key) => ["id", "object", "deleted", "livemode", "customer_account"].includes(key));
35
+ if (!minimal && (!known || !equal(expanded, known)))
36
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
37
+ return expected;
38
+ }
39
+ function decimal(raw) {
40
+ if (typeof raw !== "string" || !/^\d+(?:\.\d{1,12})?$/.test(raw))
41
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
42
+ const [integer, fraction = ""] = raw.split(".");
43
+ return {
44
+ coefficient: BigInt(integer + fraction),
45
+ scale: fraction.length,
46
+ raw,
47
+ };
48
+ }
49
+ export function sameInvoiceDecimalV1(left, right) {
50
+ const a = decimal(left), b = decimal(right), scale = Math.max(a.scale, b.scale);
51
+ return (a.coefficient * 10n ** BigInt(scale - a.scale) ===
52
+ b.coefficient * 10n ** BigInt(scale - b.scale));
53
+ }
54
+ function material(condition) {
55
+ if (!condition)
56
+ throw new InvoiceEvidenceStopV1("invoice_material_mismatch", "conflict");
57
+ }
58
+ function oneLine(raw, context) {
59
+ const line = invoiceRecordV1(raw);
60
+ if (line.object !== "line_item" ||
61
+ typeof line.id !== "string" ||
62
+ !/^il_[A-Za-z0-9_]+$/.test(line.id))
63
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
64
+ invoiceReferenceV1(line.invoice, context.invoiceId, "invoice");
65
+ if (typeof line.livemode !== "boolean" || typeof line.currency !== "string")
66
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
67
+ if (line.livemode !== context.livemode)
68
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
69
+ material(line.currency === context.price.currency);
70
+ const parent = invoiceRecordV1(line.parent);
71
+ if (parent.type === "invoice_item_details") {
72
+ invoiceRecordV1(parent.invoice_item_details);
73
+ if (parent.subscription_item_details !== null)
74
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
75
+ return null;
76
+ }
77
+ if (parent.type !== "subscription_item_details")
78
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
79
+ const details = invoiceRecordV1(parent.subscription_item_details);
80
+ invoiceReferenceV1(details.subscription, context.subscriptionId, "subscription", context.subscription);
81
+ invoiceReferenceV1(details.subscription_item, context.itemId, "subscription_item");
82
+ if (details.proration !== false)
83
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
84
+ if (line.subscription !== null && line.subscription !== undefined)
85
+ invoiceReferenceV1(line.subscription, context.subscriptionId, "subscription", context.subscription);
86
+ const pricing = invoiceRecordV1(line.pricing);
87
+ if (pricing.type === null || pricing.type === undefined)
88
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
89
+ if (pricing.type !== "price_details")
90
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
91
+ const price = invoiceRecordV1(pricing.price_details);
92
+ if (typeof price.price !== "string" || typeof price.product !== "string")
93
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
94
+ material(price.price === context.price.id && price.product === context.productId);
95
+ const period = invoiceRecordV1(line.period);
96
+ if (typeof period.start !== "number" ||
97
+ typeof period.end !== "number" ||
98
+ !Number.isSafeInteger(period.start) ||
99
+ !Number.isSafeInteger(period.end))
100
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
101
+ material(period.start === context.period.start && period.end === context.period.end);
102
+ if (line.quantity_decimal === null ||
103
+ line.quantity_decimal === undefined ||
104
+ pricing.unit_amount_decimal === null ||
105
+ pricing.unit_amount_decimal === undefined)
106
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
107
+ const quantity = decimal(line.quantity_decimal);
108
+ material(sameInvoiceDecimalV1(quantity.raw, String(context.quantity)));
109
+ material(sameInvoiceDecimalV1(pricing.unit_amount_decimal, context.price.unit_amount_decimal));
110
+ if (line.quantity !== null && line.quantity !== undefined) {
111
+ if (typeof line.quantity !== "number" ||
112
+ !Number.isSafeInteger(line.quantity) ||
113
+ line.quantity < 0)
114
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
115
+ material(BigInt(line.quantity) ===
116
+ quantity.coefficient / 10n ** BigInt(quantity.scale));
117
+ }
118
+ return {
119
+ invoiceId: context.invoiceId,
120
+ lineId: line.id,
121
+ subscriptionItemId: context.itemId,
122
+ nativePeriod: { start: context.period.start, end: context.period.end },
123
+ priceId: price.price,
124
+ productId: price.product,
125
+ currency: String(line.currency),
126
+ quantityDecimal: quantity.raw,
127
+ unitAmountDecimal: decimal(pricing.unit_amount_decimal).raw,
128
+ invoiceStatus: context.invoiceStatus,
129
+ };
130
+ }
131
+ /** Complete bounded page DATA only, never cursor/request or provider provenance. */
132
+ export function inspectInvoiceLinesV1(raw, context) {
133
+ if (!Array.isArray(raw) || raw.length < 1 || raw.length > 2)
134
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
135
+ const seen = new Set(), candidates = [];
136
+ for (let index = 0; index < raw.length; index++) {
137
+ const page = invoiceRecordV1(raw[index]);
138
+ if (page.object !== "list" ||
139
+ typeof page.has_more !== "boolean" ||
140
+ !Array.isArray(page.data))
141
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
142
+ if (typeof page.url !== "string")
143
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
144
+ if (page.url !== `/v1/invoices/${context.invoiceId}/lines`)
145
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
146
+ if (page.data.length > 100 ||
147
+ (page.data.length === 0 && (raw.length > 1 || page.has_more)) ||
148
+ page.has_more !== index < raw.length - 1)
149
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
150
+ for (const row of page.data) {
151
+ const line = invoiceRecordV1(row);
152
+ if (typeof line.id !== "string" || seen.has(line.id))
153
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
154
+ seen.add(line.id);
155
+ const candidate = oneLine(line, context);
156
+ if (candidate)
157
+ candidates.push(candidate);
158
+ }
159
+ }
160
+ if (candidates.length !== 1)
161
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
162
+ return candidates[0];
163
+ }
164
+ //# sourceMappingURL=evidence-invoice-lines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-invoice-lines.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/evidence-invoice-lines.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAU,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAEnC,MAAM;IACN,SAAS;IAFpB,YACW,MAAc,EACd,SAAS,GAA2B,SAAS;QAEtD,KAAK,CAAC,MAAM,CAAC,CAAC;sBAHL,MAAM;yBACN,SAAS;IAGpB,CAAC;CACF;AACD,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7D,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;IAC9D,OAAO,KAAU,CAAC;AACpB,CAAC;AACD,iFAAiF;AACjF,MAAM,UAAU,kBAAkB,CAChC,GAAY,EACZ,QAAgB,EAChB,IAAY,EACZ,KAAS;IAET,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QACnC,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;IAC9D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAA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AAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG;YACtB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7D,IAAI,CAAC,QAAQ,KAAK,KAAK,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC;YAExC,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;QAC9D,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClD,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;YAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClB,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,IAAI,SAAS;gBAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QACzB,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;IAC9D,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { InvoiceEvidenceV1 } from "./evidence-v1-types.js";
2
+ /** Exact paired Endive billing facts only. No payment or exclusive-cause proof. */
3
+ export declare function inspectInvoiceEvidenceV1(input: unknown): Promise<InvoiceEvidenceV1>;
4
+ //# sourceMappingURL=evidence-invoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-invoice.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/evidence-invoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAsEhC,mFAAmF;AACnF,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,iBAAiB,CAAC,CAkM5B"}
@@ -0,0 +1,190 @@
1
+ import { reconstructConfigurationV2, } from "../renewalV2/index.js";
2
+ import { object, array, get, equal } from "./common.js";
3
+ import { inspectInvoiceLinesV1, invoiceRecordV1, invoiceReferenceV1, InvoiceEvidenceStopV1, } from "./evidence-invoice-lines.js";
4
+ function incomplete() {
5
+ throw new InvoiceEvidenceStopV1("incomplete_invoice_lines");
6
+ }
7
+ function relation(value) {
8
+ if (!value)
9
+ throw new InvoiceEvidenceStopV1("invoice_relation_mismatch", "conflict");
10
+ }
11
+ function material(value) {
12
+ if (!value)
13
+ throw new InvoiceEvidenceStopV1("invoice_material_mismatch", "conflict");
14
+ }
15
+ function closed(value, keys) {
16
+ const data = invoiceRecordV1(value), actual = Object.keys(data);
17
+ if (actual.length !== keys.length ||
18
+ keys.some((key) => !actual.includes(key)))
19
+ incomplete();
20
+ return data;
21
+ }
22
+ function invoiceId(value) {
23
+ const id = typeof value === "string"
24
+ ? value
25
+ : value === null || value === undefined
26
+ ? null
27
+ : invoiceRecordV1(value).id;
28
+ if (typeof id !== "string" || !/^in_[A-Za-z0-9_]+$/.test(id))
29
+ incomplete();
30
+ return id;
31
+ }
32
+ function status(value) {
33
+ if (value === null ||
34
+ value === "draft" ||
35
+ value === "open" ||
36
+ value === "paid" ||
37
+ value === "uncollectible" ||
38
+ value === "void")
39
+ return value;
40
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
41
+ }
42
+ function period(value, startKey, endKey) {
43
+ const start = value[startKey], end = value[endKey];
44
+ if (typeof start !== "number" ||
45
+ typeof end !== "number" ||
46
+ !Number.isSafeInteger(start) ||
47
+ !Number.isSafeInteger(end) ||
48
+ start < 0 ||
49
+ end <= start)
50
+ incomplete();
51
+ return { start, end };
52
+ }
53
+ /** Exact paired Endive billing facts only. No payment or exclusive-cause proof. */
54
+ export async function inspectInvoiceEvidenceV1(input) {
55
+ try {
56
+ const raw = invoiceRecordV1(input);
57
+ const inventory = closed(raw.invoiceContext, ["original", "current"]);
58
+ const reconstruction = await reconstructConfigurationV2(raw.configuration);
59
+ if (!reconstruction.material)
60
+ incomplete();
61
+ const { material: owned } = reconstruction;
62
+ const expected = owned.prepared.expected;
63
+ const originalSub = get(object(owned.prepared.providerSnapshot), "subscription");
64
+ const originalItem = object(array(get(originalSub, "items").data)[0]);
65
+ const originalPrice = get(originalItem, "price"), targetPrice = object(owned.args.targetPrice);
66
+ const knownCustomer = object(owned.args.billingCustomer), customerId = knownCustomer.id;
67
+ if (typeof customerId !== "string")
68
+ incomplete();
69
+ const reads = closed(raw.reads, [
70
+ "schedule",
71
+ "subscription",
72
+ "targetPrice",
73
+ "billingCustomer",
74
+ "coupons",
75
+ ]);
76
+ const sub = invoiceRecordV1(reads.subscription), schedule = invoiceRecordV1(reads.schedule);
77
+ const customer = invoiceRecordV1(reads.billingCustomer);
78
+ relation(sub.object === "subscription" &&
79
+ sub.id === expected.subscriptionId &&
80
+ sub.customer_account === expected.customerAccountId &&
81
+ sub.livemode === expected.livemode);
82
+ relation(schedule.object === "subscription_schedule" &&
83
+ schedule.id === owned.receipt.scheduleId &&
84
+ schedule.customer_account === expected.customerAccountId &&
85
+ schedule.livemode === expected.livemode);
86
+ relation(customer.object === "customer" &&
87
+ customer.id === customerId &&
88
+ customer.customer_account === expected.customerAccountId &&
89
+ customer.livemode === expected.livemode);
90
+ invoiceReferenceV1(sub.customer, customerId, "customer", customer);
91
+ invoiceReferenceV1(schedule.customer, customerId, "customer", customer);
92
+ invoiceReferenceV1(sub.schedule, owned.receipt.scheduleId, "subscription_schedule", schedule);
93
+ invoiceReferenceV1(schedule.subscription, expected.subscriptionId, "subscription", sub);
94
+ if (schedule.status !== "active")
95
+ throw new InvoiceEvidenceStopV1("unsupported_profile");
96
+ const items = invoiceRecordV1(sub.items);
97
+ if (items.has_more !== false ||
98
+ !Array.isArray(items.data) ||
99
+ items.data.length !== 1)
100
+ incomplete();
101
+ const item = invoiceRecordV1(items.data[0]);
102
+ const observedItemId = item.id;
103
+ if (item.object !== "subscription_item" ||
104
+ typeof observedItemId !== "string" ||
105
+ !/^si_[A-Za-z0-9_]+$/.test(observedItemId))
106
+ incomplete();
107
+ invoiceReferenceV1(item.subscription, expected.subscriptionId, "subscription", sub);
108
+ invoiceReferenceV1(item.price, expected.targetPriceId, "price", targetPrice);
109
+ material(equal(reads.targetPrice, targetPrice));
110
+ material(item.quantity === owned.prepared.quantity);
111
+ const native = period(item, "current_period_start", "current_period_end");
112
+ const phase = closed(schedule.current_phase, ["start_date", "end_date"]);
113
+ const active = period(phase, "start_date", "end_date");
114
+ material(active.start === expected.periodEnd && equal(active, native));
115
+ const phases = array(schedule.phases);
116
+ if (phases.length !== 2)
117
+ incomplete();
118
+ const targetPhase = invoiceRecordV1(phases[1]);
119
+ material(targetPhase.start_date === native.start &&
120
+ targetPhase.end_date === native.end);
121
+ const originalNative = {
122
+ start: expected.periodStart,
123
+ end: expected.periodEnd,
124
+ };
125
+ const originalInvoiceId = invoiceId(originalSub.latest_invoice), currentInvoiceId = invoiceId(sub.latest_invoice);
126
+ const examine = (role) => {
127
+ const row = closed(inventory[role], ["invoice", "linePages"]);
128
+ const invoice = invoiceRecordV1(row.invoice);
129
+ const id = role === "original" ? originalInvoiceId : currentInvoiceId;
130
+ if (invoice.object !== "invoice" || typeof invoice.id !== "string")
131
+ incomplete();
132
+ if (typeof invoice.customer_account !== "string" ||
133
+ typeof invoice.livemode !== "boolean")
134
+ incomplete();
135
+ relation(invoice.id === id &&
136
+ invoice.customer_account === expected.customerAccountId &&
137
+ invoice.livemode === expected.livemode);
138
+ invoiceReferenceV1(invoice.customer, customerId, "customer", role === "original" ? knownCustomer : customer);
139
+ invoiceReferenceV1(role === "original" ? originalSub.latest_invoice : sub.latest_invoice, id, "invoice", invoice);
140
+ const parent = invoiceRecordV1(invoice.parent);
141
+ if (parent.type !== "subscription_details")
142
+ incomplete();
143
+ const details = invoiceRecordV1(parent.subscription_details);
144
+ invoiceReferenceV1(details.subscription, expected.subscriptionId, "subscription", role === "original" ? originalSub : sub);
145
+ if (role === "original"
146
+ ? invoice.billing_reason !== "subscription_create" &&
147
+ invoice.billing_reason !== "subscription_cycle"
148
+ : invoice.billing_reason !== "subscription_cycle")
149
+ throw new InvoiceEvidenceStopV1("unsupported_invoice_reason");
150
+ const price = role === "original" ? originalPrice : targetPrice;
151
+ if (typeof invoice.currency !== "string")
152
+ incomplete();
153
+ material(invoice.currency === price.currency);
154
+ if (invoice.status === undefined)
155
+ incomplete();
156
+ return inspectInvoiceLinesV1(row.linePages, {
157
+ invoiceId: id,
158
+ invoiceStatus: status(invoice.status),
159
+ subscriptionId: expected.subscriptionId,
160
+ subscription: role === "original" ? originalSub : sub,
161
+ itemId: role === "original" ? expected.itemId : observedItemId,
162
+ period: role === "original" ? originalNative : native,
163
+ price,
164
+ productId: role === "original"
165
+ ? expected.currentProductId
166
+ : expected.targetProductId,
167
+ quantity: owned.prepared.quantity,
168
+ livemode: expected.livemode,
169
+ });
170
+ };
171
+ const original = examine("original"), current = examine("current");
172
+ return {
173
+ predicate: "invoice_lines_correlated",
174
+ original,
175
+ current,
176
+ reason: null,
177
+ };
178
+ }
179
+ catch (error) {
180
+ return {
181
+ predicate: error instanceof InvoiceEvidenceStopV1 ? error.predicate : "unknown",
182
+ original: null,
183
+ current: null,
184
+ reason: error instanceof InvoiceEvidenceStopV1
185
+ ? error.reason
186
+ : "incomplete_invoice_lines",
187
+ };
188
+ }
189
+ }
190
+ //# sourceMappingURL=evidence-invoice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-invoice.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/evidence-invoice.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,0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AI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc;gBAC9D,MAAM,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM;gBACrD,KAAK;gBACL,SAAS,EACP,IAAI,KAAK,UAAU;oBACjB,CAAC,CAAC,QAAQ,CAAC,gBAAgB;oBAC3B,CAAC,CAAC,QAAQ,CAAC,eAAe;gBAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ;gBACjC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC5B,CAAC,CAAC;QACL,CAAC,CAAC;QACF,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,EAClC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO;YACL,SAAS,EAAE,0BAA0B;YACrC,QAAQ;YACR,OAAO;YACP,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,SAAS,EACP,KAAK,YAAY,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YACtE,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EACJ,KAAK,YAAY,qBAAqB;gBACpC,CAAC,CAAC,KAAK,CAAC,MAAM;gBACd,CAAC,CAAC,0BAA0B;SACjC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { CurrentMaterialV1, HistoricalMaterialV1, Reason } from "./evidence-v1-types.js";
2
+ import { type ProjectRenewalConfigurationV2Options, type ConstructRenewalConfigurationReceiptV2Options } from "../renewalV2/index.js";
3
+ import { type InspectRenewalScheduleMaterialV2Options } from "../renewalV2/observation.js";
4
+ import { createContext } from "./scheduled-context.js";
5
+ /** Unsigned configuration consistency, never an acknowledgement capability. */
6
+ export type ConfiguredEvidenceV1 = {
7
+ predicate: "absent";
8
+ } | {
9
+ predicate: "qualified";
10
+ snapshot: Record<string, unknown>;
11
+ targetEnd: number;
12
+ } | {
13
+ predicate: "unknown" | "conflict";
14
+ reason: Reason;
15
+ };
16
+ /** A request-bound C9 hash alone does not validate response material or duration. */
17
+ export declare function inspectConfiguredEvidenceV1(input: {
18
+ configuration: ProjectRenewalConfigurationV2Options;
19
+ configureReceipt: ConstructRenewalConfigurationReceiptV2Options | null;
20
+ owned: Parameters<typeof createContext>[0];
21
+ }): Promise<ConfiguredEvidenceV1>;
22
+ /** Map the unchanged maintained full current-material comparison into this DTO. */
23
+ export declare function inspectCurrentMaterialEvidenceV1(input: InspectRenewalScheduleMaterialV2Options, invoiceContext?: unknown): Promise<CurrentMaterialV1>;
24
+ /** Complete unsigned snapshot consistency, never proof of an actual past time. */
25
+ export declare function inspectHistoricalMaterialEvidenceV1(input: unknown): Promise<HistoricalMaterialV1>;
26
+ //# sourceMappingURL=evidence-material.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-material.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/evidence-material.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,oCAAoC,EACzC,KAAK,6CAA6C,EACnD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,uCAAuC,EAC7C,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,+EAA+E;AAC/E,MAAM,MAAM,oBAAoB,GAC5B;IAAE,SAAS,EAAE,QAAQ,CAAA;CAAE,GACvB;IACE,SAAS,EAAE,WAAW,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,qFAAqF;AACrF,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,aAAa,EAAE,oCAAoC,CAAC;IACpD,gBAAgB,EAAE,6CAA6C,GAAG,IAAI,CAAC;IACvE,KAAK,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5C,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmFhC;AAED,mFAAmF;AACnF,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,uCAAuC,EAC9C,cAAc,GAAE,OAAc,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CA4F5B;AAED,kFAAkF;AAClF,wBAAsB,mCAAmC,CACvD,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,oBAAoB,CAAC,CAwF/B"}