@amboras-dev/money 0.0.0-stage → 0.1.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/README.md +393 -2
- package/dist/ai.cjs +185 -0
- package/dist/ai.d.cts +97 -0
- package/dist/ai.d.ts +97 -0
- package/dist/ai.js +175 -0
- package/dist/allocate-CdnhvAda.js +199 -0
- package/dist/allocate-D7tm_t_o.cjs +222 -0
- package/dist/amount-D7dj76nH.js +200 -0
- package/dist/amount-DHtvZSSm.cjs +241 -0
- package/dist/arithmetic-Bq-8mSal.cjs +233 -0
- package/dist/arithmetic-C-Q_aI49.js +132 -0
- package/dist/billing.cjs +184 -0
- package/dist/billing.d.cts +81 -0
- package/dist/billing.d.ts +81 -0
- package/dist/billing.js +175 -0
- package/dist/commerce.cjs +536 -0
- package/dist/commerce.d.cts +293 -0
- package/dist/commerce.d.ts +293 -0
- package/dist/commerce.js +516 -0
- package/dist/format-BdB7LEIp.js +90 -0
- package/dist/format-BnA1aLJk.cjs +113 -0
- package/dist/fx.cjs +407 -0
- package/dist/fx.d.cts +157 -0
- package/dist/fx.d.ts +157 -0
- package/dist/fx.js +374 -0
- package/dist/index.cjs +349 -0
- package/dist/index.d.cts +288 -0
- package/dist/index.d.ts +288 -0
- package/dist/index.js +276 -0
- package/dist/input.cjs +163 -0
- package/dist/input.d.cts +203 -0
- package/dist/input.d.ts +203 -0
- package/dist/input.js +153 -0
- package/dist/iso-minor--gQWI1f2.cjs +65 -0
- package/dist/iso-minor-CtaiIifs.js +48 -0
- package/dist/medusa-CmxCni-G.js +101 -0
- package/dist/medusa-DuQ3-KoD.d.cts +78 -0
- package/dist/medusa-OJ2TJOxt.cjs +154 -0
- package/dist/medusa-RwqxaDGq.d.ts +78 -0
- package/dist/money-CIgELekG.js +3571 -0
- package/dist/money-CbhsT0fB.d.cts +232 -0
- package/dist/money-CbhsT0fB.d.ts +232 -0
- package/dist/money-D5-vlv0h.cjs +3960 -0
- package/dist/number-text-BpvN6NAo.cjs +145 -0
- package/dist/number-text-C82oh6JB.js +134 -0
- package/dist/own-D7544D3k.js +4 -0
- package/dist/own-oP9DXFWv.cjs +9 -0
- package/dist/percent-CKVI_c-m.js +20 -0
- package/dist/percent-Dt8vNIAW.cjs +43 -0
- package/dist/rate-CmeTGNex.d.ts +63 -0
- package/dist/rate-DGPfB_jc.cjs +217 -0
- package/dist/rate-lLPViBuM.js +152 -0
- package/dist/rate-toyS3EMf.d.cts +63 -0
- package/dist/reporting-5xby-Zas.d.ts +31 -0
- package/dist/reporting-DEM97DhQ.d.cts +31 -0
- package/dist/retail-BsvpNv1F.js +69 -0
- package/dist/retail-BwcFJcVN.d.ts +31 -0
- package/dist/retail-DTk2XAMM.cjs +86 -0
- package/dist/retail-Mqd-sPMF.d.cts +31 -0
- package/dist/rounding-CVAPEfq_.js +50 -0
- package/dist/rounding-oZ832yTD.cjs +79 -0
- package/dist/sql.cjs +290 -0
- package/dist/sql.d.cts +147 -0
- package/dist/sql.d.ts +147 -0
- package/dist/sql.js +271 -0
- package/dist/testing.cjs +28518 -0
- package/dist/testing.d.cts +97 -0
- package/dist/testing.d.ts +97 -0
- package/dist/testing.js +28510 -0
- package/dist/wire-CI3Sm1iC.js +1675 -0
- package/dist/wire-Cd4Q1Jmm.d.ts +269 -0
- package/dist/wire-DQZ6fA3c.cjs +1872 -0
- package/dist/wire-hWuixv3w.d.cts +269 -0
- package/dist/wire.cjs +35 -0
- package/dist/wire.d.cts +2 -0
- package/dist/wire.d.ts +2 -0
- package/dist/wire.js +2 -0
- package/package.json +158 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { L as DecimalText, a as StoredAmount, i as ReadStoredOptions, r as Money } from "./money-CbhsT0fB.js";
|
|
2
|
+
//#region src/medusa.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* `row['raw_' + key]` when it is not null/undefined (a failure to read it is final: no
|
|
5
|
+
* fallback to the lossy plain key), else `row[key]`, read like `readStored`.
|
|
6
|
+
*/
|
|
7
|
+
declare function readStoredField(row: unknown, key: string, currency: string, options: ReadStoredOptions & {
|
|
8
|
+
mode: 'lenient';
|
|
9
|
+
}): Money | null;
|
|
10
|
+
declare function readStoredField(row: unknown, key: string, currency: string, options?: ReadStoredOptions & {
|
|
11
|
+
mode?: 'strict';
|
|
12
|
+
}): Money;
|
|
13
|
+
declare function readStoredField(row: unknown, key: string, currency: string, options?: ReadStoredOptions): Money | null;
|
|
14
|
+
interface ReadStoredDecimalOptions {
|
|
15
|
+
/** `'strict'` (default) throws `amount_invalid`; `'lenient'` returns null. Never 0. */
|
|
16
|
+
mode?: 'strict' | 'lenient';
|
|
17
|
+
/** Allow negative values. Default true. */
|
|
18
|
+
signed?: boolean;
|
|
19
|
+
/** Names the input field in errors. */
|
|
20
|
+
field?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Like `readStored` but keeps fractions (Medusa fractional totals, ledger literals) and needs
|
|
24
|
+
* no currency: the canonical DecimalText (`{ value: '107.81750000000000000000' }` gives
|
|
25
|
+
* `'107.8175'`). Same shape precedence.
|
|
26
|
+
*/
|
|
27
|
+
declare function readStoredDecimal(raw: unknown, options: ReadStoredDecimalOptions & {
|
|
28
|
+
mode: 'lenient';
|
|
29
|
+
}): DecimalText | null;
|
|
30
|
+
declare function readStoredDecimal(raw: unknown, options?: ReadStoredDecimalOptions & {
|
|
31
|
+
mode?: 'strict';
|
|
32
|
+
}): DecimalText;
|
|
33
|
+
declare function readStoredDecimal(raw: unknown, options?: ReadStoredDecimalOptions): DecimalText | null;
|
|
34
|
+
/**
|
|
35
|
+
* A variant's `calculated_price` (a number, or an object read through
|
|
36
|
+
* `raw_calculated_amount` / `calculated_amount`) as Money in
|
|
37
|
+
* `firstCurrency(calculated_price.currency_code, fallbackCurrency)`. Null on anything
|
|
38
|
+
* missing or unreadable.
|
|
39
|
+
*/
|
|
40
|
+
declare function readCalculatedPrice(variant: unknown, fallbackCurrency?: string): Money | null;
|
|
41
|
+
/** Medusa's raw amount column shape. */
|
|
42
|
+
interface MedusaRaw {
|
|
43
|
+
readonly value: string;
|
|
44
|
+
readonly precision: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `{ value, precision }` for a Medusa raw column: `value` is plain decimal text, never an
|
|
48
|
+
* exponent (`1e21` gives `'1000000000000000000000'`). NaN and Infinity throw `amount_invalid`.
|
|
49
|
+
*/
|
|
50
|
+
declare function toMedusaRaw(value: Money | DecimalText | number | bigint, precision?: number): MedusaRaw;
|
|
51
|
+
/** A Money for a Medusa amount input: `'0'` for zero (Medusa drops numeric 0 on order-edit updates), else the number. */
|
|
52
|
+
declare function toMedusaAmountInput(m: Money): number | string;
|
|
53
|
+
/** A per-currency setting: upper-case currency code to stored amount. Build one with `moneyByCurrency`. */
|
|
54
|
+
type MoneyByCurrency = {
|
|
55
|
+
readonly [code: string]: StoredAmount;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Validates an object of `code -> stored amount` (keys through `currencyCode`, values
|
|
59
|
+
* non-negative safe integers), upper-cases the keys and freezes it. A key given twice in
|
|
60
|
+
* different cases throws `currency_invalid`.
|
|
61
|
+
*/
|
|
62
|
+
declare function moneyByCurrency(input: unknown): MoneyByCurrency;
|
|
63
|
+
/** A Medusa price row, or anything shaped like one. */
|
|
64
|
+
interface PriceLike {
|
|
65
|
+
readonly amount: unknown;
|
|
66
|
+
readonly currency_code: string;
|
|
67
|
+
readonly price_list_id?: string | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The amount for `currency` from a MoneyByCurrency or a Medusa price list (base prices only:
|
|
71
|
+
* rows with a `price_list_id` are skipped). Exact currency match, any case; the amount is read
|
|
72
|
+
* strictly. Null when there is none.
|
|
73
|
+
*/
|
|
74
|
+
declare function moneyFor(source: MoneyByCurrency | readonly PriceLike[], currency: string): Money | null;
|
|
75
|
+
/** Whether unknown Medusa input holds an amount above zero. `''`, null and garbage are false, never a throw. */
|
|
76
|
+
declare function isPositiveAmount(raw: unknown): boolean;
|
|
77
|
+
//#endregion
|
|
78
|
+
export { isPositiveAmount as a, readCalculatedPrice as c, toMedusaAmountInput as d, toMedusaRaw as f, ReadStoredDecimalOptions as i, readStoredDecimal as l, MoneyByCurrency as n, moneyByCurrency as o, PriceLike as r, moneyFor as s, MedusaRaw as t, readStoredField as u };
|