@happyvertical/smrt-commerce 0.40.70 → 0.41.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.
- package/AGENTS.md +9 -2
- package/README.md +8 -8
- package/dist/chunks/money-WSMvSgWq.js +8 -0
- package/dist/chunks/money-WSMvSgWq.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +297 -115
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +613 -387
- package/dist/migrations/moneyMinorUnits.d.ts +86 -0
- package/dist/migrations/moneyMinorUnits.d.ts.map +1 -0
- package/dist/models/Contract.d.ts +19 -9
- package/dist/models/Contract.d.ts.map +1 -1
- package/dist/models/ContractLineItem.d.ts +21 -7
- package/dist/models/ContractLineItem.d.ts.map +1 -1
- package/dist/models/Customer.d.ts +7 -1
- package/dist/models/Customer.d.ts.map +1 -1
- package/dist/models/Invoice.d.ts +43 -37
- package/dist/models/Invoice.d.ts.map +1 -1
- package/dist/models/InvoiceLineItem.d.ts +34 -10
- package/dist/models/InvoiceLineItem.d.ts.map +1 -1
- package/dist/models/Payment.d.ts +31 -11
- package/dist/models/Payment.d.ts.map +1 -1
- package/dist/models/PaymentAllocation.d.ts +9 -2
- package/dist/models/PaymentAllocation.d.ts.map +1 -1
- package/dist/models/PaymentIntent.d.ts +7 -2
- package/dist/models/PaymentIntent.d.ts.map +1 -1
- package/dist/models/Payout.d.ts +15 -10
- package/dist/models/Payout.d.ts.map +1 -1
- package/dist/models/Vendor.d.ts +3 -1
- package/dist/models/Vendor.d.ts.map +1 -1
- package/dist/money.d.ts +27 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +155 -93
- package/package.json +8 -7
|
@@ -51,10 +51,10 @@ export declare class PaymentIntent extends SmrtObject {
|
|
|
51
51
|
*/
|
|
52
52
|
paymentOptions: PaymentOption[];
|
|
53
53
|
/**
|
|
54
|
-
* USD price locked at quote time
|
|
54
|
+
* USD price locked at quote time, in **integer minor units** (US cents).
|
|
55
55
|
* Independent of any specific option's native-currency amount;
|
|
56
56
|
* `usdPriceLocked` is the canonical "what this costs in USD"
|
|
57
|
-
* number used downstream for reporting, tax, and drift accounting.
|
|
57
|
+
* number used downstream for reporting, tax, and drift accounting (#2401).
|
|
58
58
|
*/
|
|
59
59
|
usdPriceLocked: number;
|
|
60
60
|
/**
|
|
@@ -327,6 +327,11 @@ export declare class PaymentIntent extends SmrtObject {
|
|
|
327
327
|
* Drops entries that don't carry the required `backendId` /
|
|
328
328
|
* `currency` / `payTo` / `nativeAmount` quartet so downstream
|
|
329
329
|
* routing code can rely on the invariant.
|
|
330
|
+
*
|
|
331
|
+
* `nativeAmount` must be a whole number of minor units (#2401): the
|
|
332
|
+
* reconciliation in {@link reconcilePaymentWithOption} compares it to
|
|
333
|
+
* `Payment.nativeAmount` with `!==`, so a fractional major-unit option could
|
|
334
|
+
* never match the payment that arrives and would silently strand the intent.
|
|
330
335
|
*/
|
|
331
336
|
private static normalizePaymentOptions;
|
|
332
337
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentIntent.d.ts","sourceRoot":"","sources":["../../src/models/PaymentIntent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EACL,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"PaymentIntent.d.ts","sourceRoot":"","sources":["../../src/models/PaymentIntent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EACL,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,KAAK,aAAa,EAEnB,MAAM,mBAAmB,C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S1B;AAED,eAAe,aAAa,CAAC"}
|
package/dist/models/Payout.d.ts
CHANGED
|
@@ -21,20 +21,24 @@ export declare class Payout extends SmrtObject {
|
|
|
21
21
|
*/
|
|
22
22
|
vendorId: string;
|
|
23
23
|
/**
|
|
24
|
-
* Total funds moved, in the originating payment's native currency
|
|
25
|
-
*
|
|
26
|
-
* `Payment.nativeAmount`
|
|
24
|
+
* Total funds moved, in the originating payment's native currency, as
|
|
25
|
+
* **integer minor units** (cents, satoshis) — the same convention as
|
|
26
|
+
* `Payment.amount` / `Payment.nativeAmount` (#2401).
|
|
27
27
|
*/
|
|
28
28
|
grossAmount: number;
|
|
29
29
|
/**
|
|
30
|
-
* Operator's take from `grossAmount
|
|
31
|
-
* `grossAmount - supplierNet` at save time — the model enforces
|
|
30
|
+
* Operator's take from `grossAmount`, in integer minor units. Must equal
|
|
31
|
+
* `grossAmount - supplierNet` **exactly** at save time — the model enforces
|
|
32
32
|
* the invariant via `validateAmounts()`.
|
|
33
33
|
*/
|
|
34
34
|
operatorFee: number;
|
|
35
35
|
/**
|
|
36
|
-
* Net funds the supplier receives. Must equal
|
|
37
|
-
* `grossAmount - operatorFee` at save time.
|
|
36
|
+
* Net funds the supplier receives, in integer minor units. Must equal
|
|
37
|
+
* `grossAmount - operatorFee` exactly at save time.
|
|
38
|
+
*
|
|
39
|
+
* Converts with the other two: the invariant is a subtraction over all
|
|
40
|
+
* three, so a decimal member would reintroduce the fuzz the tolerance used
|
|
41
|
+
* to hide (#2401).
|
|
38
42
|
*/
|
|
39
43
|
supplierNet: number;
|
|
40
44
|
/**
|
|
@@ -126,9 +130,10 @@ export declare class Payout extends SmrtObject {
|
|
|
126
130
|
*/
|
|
127
131
|
resetFromFailed(): void;
|
|
128
132
|
/**
|
|
129
|
-
* Throws if the gross/fee/net invariant doesn't hold.
|
|
130
|
-
*
|
|
131
|
-
*
|
|
133
|
+
* Throws if the gross/fee/net invariant doesn't hold.
|
|
134
|
+
*
|
|
135
|
+
* Exact: all three are integer minor units, so `supplierNet` must equal
|
|
136
|
+
* `grossAmount - operatorFee` on the nose (#2401).
|
|
132
137
|
*/
|
|
133
138
|
validateAmounts(): void;
|
|
134
139
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Payout.d.ts","sourceRoot":"","sources":["../../src/models/Payout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAc,UAAU,EAAQ,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"Payout.d.ts","sourceRoot":"","sources":["../../src/models/Payout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAc,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAGxE,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAuCrE,qBAuBa,MAAO,SAAQ,UAAU;IACpC;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;OAIG;IAEH,QAAQ,EAAE,MAAM,CAAM;IAEtB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAK;IAExB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAK;IAExB;;;;;;;OAOG;IACH,WAAW,EAAE,MAAM,CAAK;IAExB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAM;IAEtB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAM;IAE1B;;;;;OAKG;IACH,MAAM,EAAE,YAAY,CAAwB;IAE5C;;OAEG;IACH,MAAM,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE3B;;OAEG;IACH,WAAW,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEhC;;OAEG;IACH,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE7B;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAM;IAE3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,aAAkB;IA2BvC;;;OAGG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAa1C,SAAS,IAAI,OAAO;IAIpB,MAAM,IAAI,OAAO;IAIjB,WAAW,IAAI,OAAO;IAItB,QAAQ,IAAI,OAAO;IAInB;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAcpC;;;;;;OAMG;IACH,aAAa,IAAI,IAAI;IAUrB;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAchC;;;;;;OAMG;IACH,eAAe,IAAI,IAAI;IAevB;;;;;OAKG;IACH,eAAe,IAAI,IAAI;IA4BvB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCpC;;;;;;;;;OASG;YACW,kBAAkB;IAchC;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;;;;;;;;;;;;OAaG;YACW,2BAA2B;IAoCzC,OAAO,CAAC,MAAM,CAAC,UAAU;CAS1B;AAED,eAAe,MAAM,CAAC"}
|
package/dist/models/Vendor.d.ts
CHANGED
|
@@ -32,7 +32,9 @@ export declare class Vendor extends SmrtObject {
|
|
|
32
32
|
*/
|
|
33
33
|
leadTimeDays: number;
|
|
34
34
|
/**
|
|
35
|
-
* Minimum order amount required
|
|
35
|
+
* Minimum order amount required, in **integer minor units** (cents,
|
|
36
|
+
* satoshis). Compared against `Contract.totalAmount`, which is also minor
|
|
37
|
+
* units (#2401).
|
|
36
38
|
*/
|
|
37
39
|
minimumOrderAmount: number;
|
|
38
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vendor.d.ts","sourceRoot":"","sources":["../../src/models/Vendor.ts"],"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;;;;;;;;OAQG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ1C;;;;OAIG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOpC;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;;;;;;OAUG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;;;OAOG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOtD;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAQ7D;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU1C;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;CAqBxC;AAED,eAAe,MAAM,CAAC"}
|
package/dist/money.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Money is exact: integer minor units, checked at the model boundary (#2401).
|
|
3
|
+
*
|
|
4
|
+
* Every money column in this package is INTEGER minor units — cents,
|
|
5
|
+
* satoshis — so `$19.99` is `1999`. Before #2401 the models carried
|
|
6
|
+
* `EPSILON = 0.01` tolerances on every comparison, because the values really
|
|
7
|
+
* were floats and `0.1 * 3` really is `0.30000000000000004`. With exact
|
|
8
|
+
* integers those tolerances are not merely unnecessary, they are wrong: a
|
|
9
|
+
* one-cent discrepancy is a one-cent discrepancy, not rounding fuzz.
|
|
10
|
+
*
|
|
11
|
+
* Dropping the tolerances is only safe if the values are *actually* integers,
|
|
12
|
+
* which is what this guard establishes. A fractional major-unit write (`19.99`
|
|
13
|
+
* into a cents column) is the bug the whole convention exists to prevent;
|
|
14
|
+
* PostgreSQL catches it with a `22P02` and SQLite's type affinity does not
|
|
15
|
+
* catch it at all, so the model catches it first, on every engine and every
|
|
16
|
+
* write surface.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Throw unless every named value is a finite integer.
|
|
20
|
+
*
|
|
21
|
+
* @param context - Model name for the error message, e.g. `Invoice`.
|
|
22
|
+
* @param label - Row identifier used in the error, e.g. an invoice number.
|
|
23
|
+
* @param entries - `[fieldName, value]` pairs to check.
|
|
24
|
+
* @throws When any value is non-finite or has a fractional part.
|
|
25
|
+
*/
|
|
26
|
+
export declare function assertIntegerMinorUnits(context: string, label: string, entries: ReadonlyArray<readonly [string, number]>): void;
|
|
27
|
+
//# sourceMappingURL=money.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAChD,IAAI,CAUN"}
|