@amboras-dev/money 0.2.0 → 0.4.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 +22 -11
  2. package/dist/ai.cjs +12 -13
  3. package/dist/ai.d.cts +5 -9
  4. package/dist/ai.d.ts +5 -9
  5. package/dist/ai.js +12 -13
  6. package/dist/{allocate-CZRg4TOP.cjs → allocate-AusholrC.cjs} +3 -4
  7. package/dist/{allocate-X7_jAtOj.js → allocate-BBRfdaSC.js} +3 -4
  8. package/dist/{amount-BV0O-aN8.cjs → amount-Bzxw9aD4.cjs} +32 -14
  9. package/dist/{amount-BoYBMgK9.js → amount-off8IMBJ.js} +32 -14
  10. package/dist/{arithmetic-BhNwisjb.js → arithmetic-C97-YafD.js} +4 -5
  11. package/dist/{arithmetic-DjT4Kzgt.cjs → arithmetic-D8A6IeZ0.cjs} +4 -5
  12. package/dist/billing.cjs +5 -8
  13. package/dist/billing.d.cts +1 -9
  14. package/dist/billing.d.ts +1 -9
  15. package/dist/billing.js +5 -8
  16. package/dist/commerce.cjs +15 -23
  17. package/dist/commerce.d.cts +2 -16
  18. package/dist/commerce.d.ts +2 -16
  19. package/dist/commerce.js +15 -23
  20. package/dist/{format-DLhno7eX.cjs → format-92fzvTXY.cjs} +9 -9
  21. package/dist/{format-BdPnijvn.js → format-BJC513u4.js} +9 -9
  22. package/dist/fx.cjs +12 -18
  23. package/dist/fx.d.cts +5 -15
  24. package/dist/fx.d.ts +5 -15
  25. package/dist/fx.js +12 -18
  26. package/dist/index.cjs +10 -12
  27. package/dist/index.d.cts +17 -23
  28. package/dist/index.d.ts +17 -23
  29. package/dist/index.js +10 -12
  30. package/dist/input.cjs +7 -10
  31. package/dist/input.d.cts +16 -22
  32. package/dist/input.d.ts +16 -22
  33. package/dist/input.js +7 -10
  34. package/dist/{iso-minor-wSwJN57T.cjs → iso-minor-DyNjT9A1.cjs} +2 -3
  35. package/dist/{iso-minor-CqkWDxHS.js → iso-minor-odkY-e6I.js} +2 -3
  36. package/dist/{medusa-lRY9xlsf.cjs → medusa-CzVK0bth.cjs} +3 -4
  37. package/dist/{medusa-DBXJXXvF.d.ts → medusa-DofdvIgQ.d.cts} +1 -3
  38. package/dist/{medusa-4K8N1pUc.d.cts → medusa-DrbYmD2Y.d.ts} +1 -3
  39. package/dist/{medusa-DqJY1qpj.js → medusa-pKGlImn9.js} +3 -4
  40. package/dist/{money-B-3aFjNJ.d.cts → money-BkMeYDEW.d.cts} +0 -6
  41. package/dist/{money-B-3aFjNJ.d.ts → money-BkMeYDEW.d.ts} +0 -6
  42. package/dist/{money-WhnGiI00.js → money-BxbAw7BP.js} +7 -15
  43. package/dist/{money-B3wH_Z4S.cjs → money-DWBjuuEK.cjs} +7 -15
  44. package/dist/{number-text-DE-q4jO5.js → number-text-Bj-gZXiF.js} +3 -4
  45. package/dist/{number-text-BWu67jUq.cjs → number-text-CWuVwrlg.cjs} +3 -4
  46. package/dist/{own-oP9DXFWv.cjs → own-C5imDkyB.cjs} +1 -2
  47. package/dist/{own-D7544D3k.js → own-DHxqIYqL.js} +1 -2
  48. package/dist/{percent-D1VB9xXG.js → percent-CB3Ixjc_.js} +2 -3
  49. package/dist/{percent-C0InC2t2.cjs → percent-DABHiSBs.cjs} +2 -3
  50. package/dist/{rate-DBPiYgT1.d.ts → rate-BvvZUdSu.d.ts} +1 -3
  51. package/dist/{rate-tqK8ijG0.d.cts → rate-CEakW3ia.d.cts} +1 -3
  52. package/dist/{rate-CVeMii4a.cjs → rate-CEjWTATc.cjs} +3 -4
  53. package/dist/{rate-DicStBue.js → rate-D6S2_wgZ.js} +3 -4
  54. package/dist/{reporting-tpGJbqYp.d.ts → reporting-DFNyDBdi.d.cts} +2 -4
  55. package/dist/{reporting-CG-ai2sM.d.cts → reporting-jIBILvnr.d.ts} +2 -4
  56. package/dist/{retail-DRUTTQoJ.d.ts → retail-B04CjW3b.d.ts} +1 -3
  57. package/dist/{retail-Cml8YSKg.cjs → retail-CYGPU4ea.cjs} +4 -5
  58. package/dist/{retail-C_BPLvMj.d.cts → retail-CmEyJQOH.d.cts} +1 -3
  59. package/dist/{retail-1mu888J1.js → retail-DXgs11ov.js} +4 -5
  60. package/dist/{rounding-DHBtNCHG.cjs → rounding-4QKTRbMQ.cjs} +2 -3
  61. package/dist/{rounding-g9rvye0k.js → rounding-CA1PVP3b.js} +2 -3
  62. package/dist/sql.cjs +9 -15
  63. package/dist/sql.d.cts +2 -12
  64. package/dist/sql.d.ts +2 -12
  65. package/dist/sql.js +9 -15
  66. package/dist/testing.cjs +39198 -12
  67. package/dist/testing.d.cts +20 -13
  68. package/dist/testing.d.ts +20 -13
  69. package/dist/testing.js +39198 -13
  70. package/dist/{wire-sW0yzqth.js → wire-B4QU8O3W.js} +350 -93
  71. package/dist/{wire-CaUN9Vf_.d.ts → wire-CVNicirK.d.ts} +165 -46
  72. package/dist/{wire-xjYXv4go.d.cts → wire-CtNJmWVP.d.cts} +165 -46
  73. package/dist/{wire-Bhuut8cW.cjs → wire-u2tmHY0Y.cjs} +403 -92
  74. package/dist/wire.cjs +10 -1
  75. package/dist/wire.d.cts +2 -2
  76. package/dist/wire.d.ts +2 -2
  77. package/dist/wire.js +1 -2
  78. package/package.json +4 -3
@@ -1,14 +1,11 @@
1
- import { R as DecimalText, b as FractionDigits, i as Money, x as StorageScale, z as RoundingMode } from "./money-B-3aFjNJ.cjs";
2
- import { Y as PspId } from "./wire-xjYXv4go.cjs";
3
- //#region src/testing/check-wire-digits.d.ts
1
+ import { R as DecimalText, b as FractionDigits, i as Money, x as StorageScale, z as RoundingMode } from "./money-BkMeYDEW.cjs";
2
+ import { mt as PspId } from "./wire-CtNJmWVP.cjs";
4
3
  /**
5
4
  * Mismatch messages (empty when consistent) between `psp`'s encoder and `documented(code)`, the
6
5
  * decimal count the PSP's documentation gives for each currency it takes (undefined: the
7
6
  * documentation does not list it). Gated PSPs are probed under the iso-minor-v2 convention.
8
7
  */
9
8
  export declare function checkWireDigits(psp: PspId, documented: (code: string) => FractionDigits | undefined): string[];
10
- //#endregion
11
- //#region src/testing/fixtures.d.ts
12
9
  /** One currency of a class, with the facts a test should assert about it. */
13
10
  interface CurrencyCase {
14
11
  readonly code: string;
@@ -46,8 +43,6 @@ export declare const ROUNDING_VECTORS: readonly RoundingVector[];
46
43
  export declare function normalizeIntlSpaces(s: string): string;
47
44
  /** A sample amount for previews and email samples: `fromMajor(major, currency, { precision: 'round' })` (KWD 12.5 is 12500 stored). */
48
45
  export declare function sampleMoney(currency: string, major: number | string): Money;
49
- //#endregion
50
- //#region src/testing/golden-destinations.d.ts
51
46
  /** `destinationAmount(dest, money(stored, currency), { as })`: `expected` null means it returns undefined; `error` means it throws that code. */
52
47
  interface DestinationAmountVector {
53
48
  readonly dest: string;
@@ -72,8 +67,6 @@ export declare const DESTINATION_GOLDEN_VECTORS: {
72
67
  readonly feedPrice: readonly DestinationTextVector[];
73
68
  readonly googleMicros: readonly DestinationTextVector[];
74
69
  };
75
- //#endregion
76
- //#region src/testing/golden-psp.d.ts
77
70
  type GoldenPspId = 'stripe' | 'adyen' | 'razorpay' | 'paystack' | 'momo' | 'vnpay' | 'paypal' | 'mollie' | 'airwallex' | 'iyzico' | 'authorize-net' | 'payoo';
78
71
  /**
79
72
  * One encode as Medusa does it today: `wire` for a sent amount, or `error` and `wire: null` for a refusal: the
@@ -93,8 +86,6 @@ interface GoldenVector {
93
86
  }
94
87
  /** Wire bytes for every PSP x presented currency x storage amount (18900 vectors). */
95
88
  export declare const PSP_GOLDEN_VECTORS: readonly GoldenVector[];
96
- //#endregion
97
- //#region src/testing/golden-psp-fractional.d.ts
98
89
  /**
99
90
  * Where the package departs on purpose from what the codec does with a fractional amount:
100
91
  * `'sub-unit'` a positive amount whose wire is 0 is refused (`error` contains `SUB_UNIT_REFUSAL`);
@@ -121,5 +112,21 @@ interface FractionalGoldenVector {
121
112
  }
122
113
  /** Fractional storage amounts for every PSP x presented currency (10500 vectors). */
123
114
  export declare const PSP_FRACTIONAL_GOLDEN_VECTORS: readonly FractionalGoldenVector[];
124
- //#endregion
125
- export type { CurrencyCase, DestinationAmountVector, DestinationTextVector, FractionalGoldenVector, FractionalPolicy, GoldenPspId, GoldenVector, MedusaAmountShape, RoundingVector };
115
+ /**
116
+ * One amount as Medusa's pre-0.2.0 float codec spelled it, for a PSP it encoded in floating point
117
+ * (`(stored / storageScale).toFixed(digits)` on a double): `wire` is what the adapter sent (a number
118
+ * for Airwallex and Payoo), `iso` its `legacyIsoMajorString` (the same at the display digits). At an
119
+ * exact tie the double can sit below it, so USD `'1072.5'` is `'10.72'` where encodeWire sends
120
+ * `'10.73'`; `sameWireAmount(..., { acceptLegacyFloatRounding: true })` accepts these spellings.
121
+ */
122
+ interface LegacyFloatGoldenVector {
123
+ readonly psp: GoldenPspId;
124
+ readonly currency: string;
125
+ /** The storage amount as decimal text (`'1072.5'`). */
126
+ readonly stored: string;
127
+ readonly wire: number | string;
128
+ readonly iso: string;
129
+ }
130
+ /** Medusa's float spellings for every float PSP x presented currency x amount (7589 vectors). */
131
+ export declare const PSP_LEGACY_FLOAT_GOLDEN_VECTORS: readonly LegacyFloatGoldenVector[];
132
+ export type { CurrencyCase, DestinationAmountVector, DestinationTextVector, FractionalGoldenVector, FractionalPolicy, GoldenPspId, GoldenVector, LegacyFloatGoldenVector, MedusaAmountShape, RoundingVector };
package/dist/testing.d.ts CHANGED
@@ -1,14 +1,11 @@
1
- import { R as DecimalText, b as FractionDigits, i as Money, x as StorageScale, z as RoundingMode } from "./money-B-3aFjNJ.js";
2
- import { Y as PspId } from "./wire-CaUN9Vf_.js";
3
- //#region src/testing/check-wire-digits.d.ts
1
+ import { R as DecimalText, b as FractionDigits, i as Money, x as StorageScale, z as RoundingMode } from "./money-BkMeYDEW.js";
2
+ import { mt as PspId } from "./wire-CVNicirK.js";
4
3
  /**
5
4
  * Mismatch messages (empty when consistent) between `psp`'s encoder and `documented(code)`, the
6
5
  * decimal count the PSP's documentation gives for each currency it takes (undefined: the
7
6
  * documentation does not list it). Gated PSPs are probed under the iso-minor-v2 convention.
8
7
  */
9
8
  export declare function checkWireDigits(psp: PspId, documented: (code: string) => FractionDigits | undefined): string[];
10
- //#endregion
11
- //#region src/testing/fixtures.d.ts
12
9
  /** One currency of a class, with the facts a test should assert about it. */
13
10
  interface CurrencyCase {
14
11
  readonly code: string;
@@ -46,8 +43,6 @@ export declare const ROUNDING_VECTORS: readonly RoundingVector[];
46
43
  export declare function normalizeIntlSpaces(s: string): string;
47
44
  /** A sample amount for previews and email samples: `fromMajor(major, currency, { precision: 'round' })` (KWD 12.5 is 12500 stored). */
48
45
  export declare function sampleMoney(currency: string, major: number | string): Money;
49
- //#endregion
50
- //#region src/testing/golden-destinations.d.ts
51
46
  /** `destinationAmount(dest, money(stored, currency), { as })`: `expected` null means it returns undefined; `error` means it throws that code. */
52
47
  interface DestinationAmountVector {
53
48
  readonly dest: string;
@@ -72,8 +67,6 @@ export declare const DESTINATION_GOLDEN_VECTORS: {
72
67
  readonly feedPrice: readonly DestinationTextVector[];
73
68
  readonly googleMicros: readonly DestinationTextVector[];
74
69
  };
75
- //#endregion
76
- //#region src/testing/golden-psp.d.ts
77
70
  type GoldenPspId = 'stripe' | 'adyen' | 'razorpay' | 'paystack' | 'momo' | 'vnpay' | 'paypal' | 'mollie' | 'airwallex' | 'iyzico' | 'authorize-net' | 'payoo';
78
71
  /**
79
72
  * One encode as Medusa does it today: `wire` for a sent amount, or `error` and `wire: null` for a refusal: the
@@ -93,8 +86,6 @@ interface GoldenVector {
93
86
  }
94
87
  /** Wire bytes for every PSP x presented currency x storage amount (18900 vectors). */
95
88
  export declare const PSP_GOLDEN_VECTORS: readonly GoldenVector[];
96
- //#endregion
97
- //#region src/testing/golden-psp-fractional.d.ts
98
89
  /**
99
90
  * Where the package departs on purpose from what the codec does with a fractional amount:
100
91
  * `'sub-unit'` a positive amount whose wire is 0 is refused (`error` contains `SUB_UNIT_REFUSAL`);
@@ -121,5 +112,21 @@ interface FractionalGoldenVector {
121
112
  }
122
113
  /** Fractional storage amounts for every PSP x presented currency (10500 vectors). */
123
114
  export declare const PSP_FRACTIONAL_GOLDEN_VECTORS: readonly FractionalGoldenVector[];
124
- //#endregion
125
- export type { CurrencyCase, DestinationAmountVector, DestinationTextVector, FractionalGoldenVector, FractionalPolicy, GoldenPspId, GoldenVector, MedusaAmountShape, RoundingVector };
115
+ /**
116
+ * One amount as Medusa's pre-0.2.0 float codec spelled it, for a PSP it encoded in floating point
117
+ * (`(stored / storageScale).toFixed(digits)` on a double): `wire` is what the adapter sent (a number
118
+ * for Airwallex and Payoo), `iso` its `legacyIsoMajorString` (the same at the display digits). At an
119
+ * exact tie the double can sit below it, so USD `'1072.5'` is `'10.72'` where encodeWire sends
120
+ * `'10.73'`; `sameWireAmount(..., { acceptLegacyFloatRounding: true })` accepts these spellings.
121
+ */
122
+ interface LegacyFloatGoldenVector {
123
+ readonly psp: GoldenPspId;
124
+ readonly currency: string;
125
+ /** The storage amount as decimal text (`'1072.5'`). */
126
+ readonly stored: string;
127
+ readonly wire: number | string;
128
+ readonly iso: string;
129
+ }
130
+ /** Medusa's float spellings for every float PSP x presented currency x amount (7589 vectors). */
131
+ export declare const PSP_LEGACY_FLOAT_GOLDEN_VECTORS: readonly LegacyFloatGoldenVector[];
132
+ export type { CurrencyCase, DestinationAmountVector, DestinationTextVector, FractionalGoldenVector, FractionalPolicy, GoldenPspId, GoldenVector, LegacyFloatGoldenVector, MedusaAmountShape, RoundingVector };