@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.
Files changed (78) hide show
  1. package/README.md +393 -2
  2. package/dist/ai.cjs +185 -0
  3. package/dist/ai.d.cts +97 -0
  4. package/dist/ai.d.ts +97 -0
  5. package/dist/ai.js +175 -0
  6. package/dist/allocate-CdnhvAda.js +199 -0
  7. package/dist/allocate-D7tm_t_o.cjs +222 -0
  8. package/dist/amount-D7dj76nH.js +200 -0
  9. package/dist/amount-DHtvZSSm.cjs +241 -0
  10. package/dist/arithmetic-Bq-8mSal.cjs +233 -0
  11. package/dist/arithmetic-C-Q_aI49.js +132 -0
  12. package/dist/billing.cjs +184 -0
  13. package/dist/billing.d.cts +81 -0
  14. package/dist/billing.d.ts +81 -0
  15. package/dist/billing.js +175 -0
  16. package/dist/commerce.cjs +536 -0
  17. package/dist/commerce.d.cts +293 -0
  18. package/dist/commerce.d.ts +293 -0
  19. package/dist/commerce.js +516 -0
  20. package/dist/format-BdB7LEIp.js +90 -0
  21. package/dist/format-BnA1aLJk.cjs +113 -0
  22. package/dist/fx.cjs +407 -0
  23. package/dist/fx.d.cts +157 -0
  24. package/dist/fx.d.ts +157 -0
  25. package/dist/fx.js +374 -0
  26. package/dist/index.cjs +349 -0
  27. package/dist/index.d.cts +288 -0
  28. package/dist/index.d.ts +288 -0
  29. package/dist/index.js +276 -0
  30. package/dist/input.cjs +163 -0
  31. package/dist/input.d.cts +203 -0
  32. package/dist/input.d.ts +203 -0
  33. package/dist/input.js +153 -0
  34. package/dist/iso-minor--gQWI1f2.cjs +65 -0
  35. package/dist/iso-minor-CtaiIifs.js +48 -0
  36. package/dist/medusa-CmxCni-G.js +101 -0
  37. package/dist/medusa-DuQ3-KoD.d.cts +78 -0
  38. package/dist/medusa-OJ2TJOxt.cjs +154 -0
  39. package/dist/medusa-RwqxaDGq.d.ts +78 -0
  40. package/dist/money-CIgELekG.js +3571 -0
  41. package/dist/money-CbhsT0fB.d.cts +232 -0
  42. package/dist/money-CbhsT0fB.d.ts +232 -0
  43. package/dist/money-D5-vlv0h.cjs +3960 -0
  44. package/dist/number-text-BpvN6NAo.cjs +145 -0
  45. package/dist/number-text-C82oh6JB.js +134 -0
  46. package/dist/own-D7544D3k.js +4 -0
  47. package/dist/own-oP9DXFWv.cjs +9 -0
  48. package/dist/percent-CKVI_c-m.js +20 -0
  49. package/dist/percent-Dt8vNIAW.cjs +43 -0
  50. package/dist/rate-CmeTGNex.d.ts +63 -0
  51. package/dist/rate-DGPfB_jc.cjs +217 -0
  52. package/dist/rate-lLPViBuM.js +152 -0
  53. package/dist/rate-toyS3EMf.d.cts +63 -0
  54. package/dist/reporting-5xby-Zas.d.ts +31 -0
  55. package/dist/reporting-DEM97DhQ.d.cts +31 -0
  56. package/dist/retail-BsvpNv1F.js +69 -0
  57. package/dist/retail-BwcFJcVN.d.ts +31 -0
  58. package/dist/retail-DTk2XAMM.cjs +86 -0
  59. package/dist/retail-Mqd-sPMF.d.cts +31 -0
  60. package/dist/rounding-CVAPEfq_.js +50 -0
  61. package/dist/rounding-oZ832yTD.cjs +79 -0
  62. package/dist/sql.cjs +290 -0
  63. package/dist/sql.d.cts +147 -0
  64. package/dist/sql.d.ts +147 -0
  65. package/dist/sql.js +271 -0
  66. package/dist/testing.cjs +28518 -0
  67. package/dist/testing.d.cts +97 -0
  68. package/dist/testing.d.ts +97 -0
  69. package/dist/testing.js +28510 -0
  70. package/dist/wire-CI3Sm1iC.js +1675 -0
  71. package/dist/wire-Cd4Q1Jmm.d.ts +269 -0
  72. package/dist/wire-DQZ6fA3c.cjs +1872 -0
  73. package/dist/wire-hWuixv3w.d.cts +269 -0
  74. package/dist/wire.cjs +35 -0
  75. package/dist/wire.d.cts +2 -0
  76. package/dist/wire.d.ts +2 -0
  77. package/dist/wire.js +2 -0
  78. 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 };