@vritti/api-sdk 0.2.5 → 0.2.7
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/dist/decimal.cjs +37 -0
- package/dist/decimal.cjs.map +1 -0
- package/dist/decimal.d.cts +4 -0
- package/dist/decimal.d.ts +4 -0
- package/dist/decimal.js +6 -0
- package/dist/decimal.js.map +1 -0
- package/dist/drizzle-orm.d.cts +0 -1
- package/dist/drizzle-orm.d.ts +0 -1
- package/dist/index.cjs +5191 -3996
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +515 -346
- package/dist/index.d.ts +515 -346
- package/dist/index.js +5688 -4502
- package/dist/index.js.map +1 -1
- package/dist/lodash.cjs +37 -0
- package/dist/lodash.cjs.map +1 -0
- package/dist/lodash.d.cts +1 -0
- package/dist/lodash.d.ts +1 -0
- package/dist/lodash.js +6 -0
- package/dist/lodash.js.map +1 -0
- package/dist/money.cjs +346 -0
- package/dist/money.cjs.map +1 -0
- package/dist/money.d.cts +222 -0
- package/dist/money.d.ts +222 -0
- package/dist/money.js +318 -0
- package/dist/money.js.map +1 -0
- package/dist/xlsx.cjs.map +1 -1
- package/dist/xlsx.js.map +1 -1
- package/package.json +47 -6
package/dist/money.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import * as dinero_js_bigint from 'dinero.js/bigint';
|
|
2
|
+
export * from 'dinero.js/bigint';
|
|
3
|
+
|
|
4
|
+
declare const SUPPORTED_CURRENCIES: {
|
|
5
|
+
readonly AED: dinero_js_bigint.DineroCurrency<bigint>;
|
|
6
|
+
readonly AFN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
7
|
+
readonly ALL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
8
|
+
readonly AMD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
9
|
+
readonly ANG: {
|
|
10
|
+
readonly code: "ANG";
|
|
11
|
+
readonly base: 10n;
|
|
12
|
+
readonly exponent: 2n;
|
|
13
|
+
};
|
|
14
|
+
readonly AOA: dinero_js_bigint.DineroCurrency<bigint>;
|
|
15
|
+
readonly ARS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
16
|
+
readonly AUD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
17
|
+
readonly AWG: dinero_js_bigint.DineroCurrency<bigint>;
|
|
18
|
+
readonly AZN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
19
|
+
readonly BAM: dinero_js_bigint.DineroCurrency<bigint>;
|
|
20
|
+
readonly BBD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
21
|
+
readonly BDT: dinero_js_bigint.DineroCurrency<bigint>;
|
|
22
|
+
readonly BGN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
23
|
+
readonly BHD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
24
|
+
readonly BIF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
25
|
+
readonly BMD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
26
|
+
readonly BND: dinero_js_bigint.DineroCurrency<bigint>;
|
|
27
|
+
readonly BOB: dinero_js_bigint.DineroCurrency<bigint>;
|
|
28
|
+
readonly BOV: dinero_js_bigint.DineroCurrency<bigint>;
|
|
29
|
+
readonly BRL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
30
|
+
readonly BSD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
31
|
+
readonly BTN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
32
|
+
readonly BWP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
33
|
+
readonly BYN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
34
|
+
readonly BZD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
35
|
+
readonly CAD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
36
|
+
readonly CDF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
37
|
+
readonly CHE: dinero_js_bigint.DineroCurrency<bigint>;
|
|
38
|
+
readonly CHF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
39
|
+
readonly CHW: dinero_js_bigint.DineroCurrency<bigint>;
|
|
40
|
+
readonly CLF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
41
|
+
readonly CLP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
42
|
+
readonly CNY: dinero_js_bigint.DineroCurrency<bigint>;
|
|
43
|
+
readonly COP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
44
|
+
readonly COU: dinero_js_bigint.DineroCurrency<bigint>;
|
|
45
|
+
readonly CRC: dinero_js_bigint.DineroCurrency<bigint>;
|
|
46
|
+
readonly CUP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
47
|
+
readonly CVE: dinero_js_bigint.DineroCurrency<bigint>;
|
|
48
|
+
readonly CZK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
49
|
+
readonly DJF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
50
|
+
readonly DKK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
51
|
+
readonly DOP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
52
|
+
readonly DZD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
53
|
+
readonly EGP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
54
|
+
readonly ERN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
55
|
+
readonly ETB: dinero_js_bigint.DineroCurrency<bigint>;
|
|
56
|
+
readonly EUR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
57
|
+
readonly FJD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
58
|
+
readonly FKP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
59
|
+
readonly GBP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
60
|
+
readonly GEL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
61
|
+
readonly GHS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
62
|
+
readonly GIP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
63
|
+
readonly GMD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
64
|
+
readonly GNF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
65
|
+
readonly GTQ: dinero_js_bigint.DineroCurrency<bigint>;
|
|
66
|
+
readonly GYD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
67
|
+
readonly HKD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
68
|
+
readonly HNL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
69
|
+
readonly HRK: {
|
|
70
|
+
readonly code: "HRK";
|
|
71
|
+
readonly base: 10n;
|
|
72
|
+
readonly exponent: 2n;
|
|
73
|
+
};
|
|
74
|
+
readonly HTG: dinero_js_bigint.DineroCurrency<bigint>;
|
|
75
|
+
readonly HUF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
76
|
+
readonly IDR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
77
|
+
readonly ILS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
78
|
+
readonly INR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
79
|
+
readonly IQD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
80
|
+
readonly IRR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
81
|
+
readonly ISK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
82
|
+
readonly JMD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
83
|
+
readonly JOD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
84
|
+
readonly JPY: dinero_js_bigint.DineroCurrency<bigint>;
|
|
85
|
+
readonly KES: dinero_js_bigint.DineroCurrency<bigint>;
|
|
86
|
+
readonly KGS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
87
|
+
readonly KHR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
88
|
+
readonly KMF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
89
|
+
readonly KPW: dinero_js_bigint.DineroCurrency<bigint>;
|
|
90
|
+
readonly KRW: dinero_js_bigint.DineroCurrency<bigint>;
|
|
91
|
+
readonly KWD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
92
|
+
readonly KYD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
93
|
+
readonly KZT: dinero_js_bigint.DineroCurrency<bigint>;
|
|
94
|
+
readonly LAK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
95
|
+
readonly LBP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
96
|
+
readonly LKR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
97
|
+
readonly LRD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
98
|
+
readonly LSL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
99
|
+
readonly LYD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
100
|
+
readonly MAD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
101
|
+
readonly MDL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
102
|
+
readonly MGA: dinero_js_bigint.DineroCurrency<bigint>;
|
|
103
|
+
readonly MKD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
104
|
+
readonly MMK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
105
|
+
readonly MNT: dinero_js_bigint.DineroCurrency<bigint>;
|
|
106
|
+
readonly MOP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
107
|
+
readonly MRU: dinero_js_bigint.DineroCurrency<bigint>;
|
|
108
|
+
readonly MUR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
109
|
+
readonly MVR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
110
|
+
readonly MWK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
111
|
+
readonly MXN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
112
|
+
readonly MXV: dinero_js_bigint.DineroCurrency<bigint>;
|
|
113
|
+
readonly MYR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
114
|
+
readonly MZN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
115
|
+
readonly NAD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
116
|
+
readonly NGN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
117
|
+
readonly NIO: dinero_js_bigint.DineroCurrency<bigint>;
|
|
118
|
+
readonly NOK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
119
|
+
readonly NPR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
120
|
+
readonly NZD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
121
|
+
readonly OMR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
122
|
+
readonly PAB: dinero_js_bigint.DineroCurrency<bigint>;
|
|
123
|
+
readonly PEN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
124
|
+
readonly PGK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
125
|
+
readonly PHP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
126
|
+
readonly PKR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
127
|
+
readonly PLN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
128
|
+
readonly PYG: dinero_js_bigint.DineroCurrency<bigint>;
|
|
129
|
+
readonly QAR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
130
|
+
readonly RON: dinero_js_bigint.DineroCurrency<bigint>;
|
|
131
|
+
readonly RSD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
132
|
+
readonly RUB: dinero_js_bigint.DineroCurrency<bigint>;
|
|
133
|
+
readonly RWF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
134
|
+
readonly SAR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
135
|
+
readonly SBD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
136
|
+
readonly SCR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
137
|
+
readonly SDG: dinero_js_bigint.DineroCurrency<bigint>;
|
|
138
|
+
readonly SEK: dinero_js_bigint.DineroCurrency<bigint>;
|
|
139
|
+
readonly SGD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
140
|
+
readonly SHP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
141
|
+
readonly SLE: dinero_js_bigint.DineroCurrency<bigint>;
|
|
142
|
+
readonly SOS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
143
|
+
readonly SRD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
144
|
+
readonly SSP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
145
|
+
readonly STN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
146
|
+
readonly SVC: dinero_js_bigint.DineroCurrency<bigint>;
|
|
147
|
+
readonly SYP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
148
|
+
readonly SZL: dinero_js_bigint.DineroCurrency<bigint>;
|
|
149
|
+
readonly THB: dinero_js_bigint.DineroCurrency<bigint>;
|
|
150
|
+
readonly TJS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
151
|
+
readonly TMT: dinero_js_bigint.DineroCurrency<bigint>;
|
|
152
|
+
readonly TND: dinero_js_bigint.DineroCurrency<bigint>;
|
|
153
|
+
readonly TOP: dinero_js_bigint.DineroCurrency<bigint>;
|
|
154
|
+
readonly TRY: dinero_js_bigint.DineroCurrency<bigint>;
|
|
155
|
+
readonly TTD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
156
|
+
readonly TWD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
157
|
+
readonly TZS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
158
|
+
readonly UAH: dinero_js_bigint.DineroCurrency<bigint>;
|
|
159
|
+
readonly UGX: dinero_js_bigint.DineroCurrency<bigint>;
|
|
160
|
+
readonly USD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
161
|
+
readonly USN: dinero_js_bigint.DineroCurrency<bigint>;
|
|
162
|
+
readonly UYI: dinero_js_bigint.DineroCurrency<bigint>;
|
|
163
|
+
readonly UYU: dinero_js_bigint.DineroCurrency<bigint>;
|
|
164
|
+
readonly UYW: dinero_js_bigint.DineroCurrency<bigint>;
|
|
165
|
+
readonly UZS: dinero_js_bigint.DineroCurrency<bigint>;
|
|
166
|
+
readonly VED: dinero_js_bigint.DineroCurrency<bigint>;
|
|
167
|
+
readonly VES: dinero_js_bigint.DineroCurrency<bigint>;
|
|
168
|
+
readonly VND: dinero_js_bigint.DineroCurrency<bigint>;
|
|
169
|
+
readonly VUV: dinero_js_bigint.DineroCurrency<bigint>;
|
|
170
|
+
readonly WST: dinero_js_bigint.DineroCurrency<bigint>;
|
|
171
|
+
readonly XAD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
172
|
+
readonly XAF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
173
|
+
readonly XAG: {
|
|
174
|
+
readonly code: "XAG";
|
|
175
|
+
readonly base: 10n;
|
|
176
|
+
readonly exponent: 0n;
|
|
177
|
+
};
|
|
178
|
+
readonly XAU: {
|
|
179
|
+
readonly code: "XAU";
|
|
180
|
+
readonly base: 10n;
|
|
181
|
+
readonly exponent: 0n;
|
|
182
|
+
};
|
|
183
|
+
readonly XCD: dinero_js_bigint.DineroCurrency<bigint>;
|
|
184
|
+
readonly XCG: dinero_js_bigint.DineroCurrency<bigint>;
|
|
185
|
+
readonly XDR: {
|
|
186
|
+
readonly code: "XDR";
|
|
187
|
+
readonly base: 10n;
|
|
188
|
+
readonly exponent: 0n;
|
|
189
|
+
};
|
|
190
|
+
readonly XOF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
191
|
+
readonly XPD: {
|
|
192
|
+
readonly code: "XPD";
|
|
193
|
+
readonly base: 10n;
|
|
194
|
+
readonly exponent: 0n;
|
|
195
|
+
};
|
|
196
|
+
readonly XPF: dinero_js_bigint.DineroCurrency<bigint>;
|
|
197
|
+
readonly XPT: {
|
|
198
|
+
readonly code: "XPT";
|
|
199
|
+
readonly base: 10n;
|
|
200
|
+
readonly exponent: 0n;
|
|
201
|
+
};
|
|
202
|
+
readonly YER: dinero_js_bigint.DineroCurrency<bigint>;
|
|
203
|
+
readonly ZAR: dinero_js_bigint.DineroCurrency<bigint>;
|
|
204
|
+
readonly ZMW: dinero_js_bigint.DineroCurrency<bigint>;
|
|
205
|
+
readonly ZWG: dinero_js_bigint.DineroCurrency<bigint>;
|
|
206
|
+
readonly ZWL: {
|
|
207
|
+
readonly code: "ZWL";
|
|
208
|
+
readonly base: 10n;
|
|
209
|
+
readonly exponent: 2n;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
type CurrencyCode = keyof typeof SUPPORTED_CURRENCIES;
|
|
213
|
+
type Currency = (typeof SUPPORTED_CURRENCIES)[CurrencyCode];
|
|
214
|
+
type MinorToMajorTransform<TOutput> = (props: {
|
|
215
|
+
value: string;
|
|
216
|
+
currency: Currency;
|
|
217
|
+
}) => TOutput;
|
|
218
|
+
declare function resolveCurrency(currencyCode: CurrencyCode): Currency;
|
|
219
|
+
declare function minorToMajor<TOutput = string>(minor: bigint, currencyCode: CurrencyCode, transform?: MinorToMajorTransform<TOutput>): string | TOutput;
|
|
220
|
+
declare function majorToMinor(major: string, currencyCode: CurrencyCode, field?: string): bigint;
|
|
221
|
+
|
|
222
|
+
export { type Currency, type CurrencyCode, type MinorToMajorTransform, SUPPORTED_CURRENCIES, majorToMinor, minorToMajor, resolveCurrency };
|
package/dist/money.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/money.ts
|
|
5
|
+
import { dinero, toDecimal } from "dinero.js/bigint";
|
|
6
|
+
import { AED, AFN, ALL, AMD, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BOV, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHE, CHF, CHW, CLF, CLP, CNY, COP, COU, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MXV, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USN, UYI, UYU, UYW, UZS, VED, VES, VND, VUV, WST, XAD, XAF, XCD, XCG, XOF, XPF, YER, ZAR, ZMW, ZWG } from "dinero.js/bigint/currencies";
|
|
7
|
+
|
|
8
|
+
// src/exceptions/validation.exception.ts
|
|
9
|
+
import { HttpStatus } from "@nestjs/common";
|
|
10
|
+
|
|
11
|
+
// src/exceptions/base-field.exception.ts
|
|
12
|
+
import { HttpException } from "@nestjs/common";
|
|
13
|
+
var HttpProblemException = class extends HttpException {
|
|
14
|
+
static {
|
|
15
|
+
__name(this, "HttpProblemException");
|
|
16
|
+
}
|
|
17
|
+
constructor(detailOrOptions, httpStatus) {
|
|
18
|
+
const options = typeof detailOrOptions === "string" ? {
|
|
19
|
+
detail: detailOrOptions
|
|
20
|
+
} : detailOrOptions;
|
|
21
|
+
super({
|
|
22
|
+
type: options.type ?? "about:blank",
|
|
23
|
+
label: options.label,
|
|
24
|
+
detail: options.detail,
|
|
25
|
+
errors: options.errors ?? []
|
|
26
|
+
}, httpStatus);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/exceptions/validation.exception.ts
|
|
31
|
+
var ValidationException = class extends HttpProblemException {
|
|
32
|
+
static {
|
|
33
|
+
__name(this, "ValidationException");
|
|
34
|
+
}
|
|
35
|
+
constructor(detailOrOptions) {
|
|
36
|
+
super(detailOrOptions ?? "Validation Failed", HttpStatus.UNPROCESSABLE_ENTITY);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/money.ts
|
|
41
|
+
export * from "dinero.js/bigint";
|
|
42
|
+
var ANG = {
|
|
43
|
+
code: "ANG",
|
|
44
|
+
base: 10n,
|
|
45
|
+
exponent: 2n
|
|
46
|
+
};
|
|
47
|
+
var HRK = {
|
|
48
|
+
code: "HRK",
|
|
49
|
+
base: 10n,
|
|
50
|
+
exponent: 2n
|
|
51
|
+
};
|
|
52
|
+
var XAG = {
|
|
53
|
+
code: "XAG",
|
|
54
|
+
base: 10n,
|
|
55
|
+
exponent: 0n
|
|
56
|
+
};
|
|
57
|
+
var XAU = {
|
|
58
|
+
code: "XAU",
|
|
59
|
+
base: 10n,
|
|
60
|
+
exponent: 0n
|
|
61
|
+
};
|
|
62
|
+
var XDR = {
|
|
63
|
+
code: "XDR",
|
|
64
|
+
base: 10n,
|
|
65
|
+
exponent: 0n
|
|
66
|
+
};
|
|
67
|
+
var XPD = {
|
|
68
|
+
code: "XPD",
|
|
69
|
+
base: 10n,
|
|
70
|
+
exponent: 0n
|
|
71
|
+
};
|
|
72
|
+
var XPT = {
|
|
73
|
+
code: "XPT",
|
|
74
|
+
base: 10n,
|
|
75
|
+
exponent: 0n
|
|
76
|
+
};
|
|
77
|
+
var ZWL = {
|
|
78
|
+
code: "ZWL",
|
|
79
|
+
base: 10n,
|
|
80
|
+
exponent: 2n
|
|
81
|
+
};
|
|
82
|
+
var SUPPORTED_CURRENCIES = {
|
|
83
|
+
AED,
|
|
84
|
+
AFN,
|
|
85
|
+
ALL,
|
|
86
|
+
AMD,
|
|
87
|
+
ANG,
|
|
88
|
+
AOA,
|
|
89
|
+
ARS,
|
|
90
|
+
AUD,
|
|
91
|
+
AWG,
|
|
92
|
+
AZN,
|
|
93
|
+
BAM,
|
|
94
|
+
BBD,
|
|
95
|
+
BDT,
|
|
96
|
+
BGN,
|
|
97
|
+
BHD,
|
|
98
|
+
BIF,
|
|
99
|
+
BMD,
|
|
100
|
+
BND,
|
|
101
|
+
BOB,
|
|
102
|
+
BOV,
|
|
103
|
+
BRL,
|
|
104
|
+
BSD,
|
|
105
|
+
BTN,
|
|
106
|
+
BWP,
|
|
107
|
+
BYN,
|
|
108
|
+
BZD,
|
|
109
|
+
CAD,
|
|
110
|
+
CDF,
|
|
111
|
+
CHE,
|
|
112
|
+
CHF,
|
|
113
|
+
CHW,
|
|
114
|
+
CLF,
|
|
115
|
+
CLP,
|
|
116
|
+
CNY,
|
|
117
|
+
COP,
|
|
118
|
+
COU,
|
|
119
|
+
CRC,
|
|
120
|
+
CUP,
|
|
121
|
+
CVE,
|
|
122
|
+
CZK,
|
|
123
|
+
DJF,
|
|
124
|
+
DKK,
|
|
125
|
+
DOP,
|
|
126
|
+
DZD,
|
|
127
|
+
EGP,
|
|
128
|
+
ERN,
|
|
129
|
+
ETB,
|
|
130
|
+
EUR,
|
|
131
|
+
FJD,
|
|
132
|
+
FKP,
|
|
133
|
+
GBP,
|
|
134
|
+
GEL,
|
|
135
|
+
GHS,
|
|
136
|
+
GIP,
|
|
137
|
+
GMD,
|
|
138
|
+
GNF,
|
|
139
|
+
GTQ,
|
|
140
|
+
GYD,
|
|
141
|
+
HKD,
|
|
142
|
+
HNL,
|
|
143
|
+
HRK,
|
|
144
|
+
HTG,
|
|
145
|
+
HUF,
|
|
146
|
+
IDR,
|
|
147
|
+
ILS,
|
|
148
|
+
INR,
|
|
149
|
+
IQD,
|
|
150
|
+
IRR,
|
|
151
|
+
ISK,
|
|
152
|
+
JMD,
|
|
153
|
+
JOD,
|
|
154
|
+
JPY,
|
|
155
|
+
KES,
|
|
156
|
+
KGS,
|
|
157
|
+
KHR,
|
|
158
|
+
KMF,
|
|
159
|
+
KPW,
|
|
160
|
+
KRW,
|
|
161
|
+
KWD,
|
|
162
|
+
KYD,
|
|
163
|
+
KZT,
|
|
164
|
+
LAK,
|
|
165
|
+
LBP,
|
|
166
|
+
LKR,
|
|
167
|
+
LRD,
|
|
168
|
+
LSL,
|
|
169
|
+
LYD,
|
|
170
|
+
MAD,
|
|
171
|
+
MDL,
|
|
172
|
+
MGA,
|
|
173
|
+
MKD,
|
|
174
|
+
MMK,
|
|
175
|
+
MNT,
|
|
176
|
+
MOP,
|
|
177
|
+
MRU,
|
|
178
|
+
MUR,
|
|
179
|
+
MVR,
|
|
180
|
+
MWK,
|
|
181
|
+
MXN,
|
|
182
|
+
MXV,
|
|
183
|
+
MYR,
|
|
184
|
+
MZN,
|
|
185
|
+
NAD,
|
|
186
|
+
NGN,
|
|
187
|
+
NIO,
|
|
188
|
+
NOK,
|
|
189
|
+
NPR,
|
|
190
|
+
NZD,
|
|
191
|
+
OMR,
|
|
192
|
+
PAB,
|
|
193
|
+
PEN,
|
|
194
|
+
PGK,
|
|
195
|
+
PHP,
|
|
196
|
+
PKR,
|
|
197
|
+
PLN,
|
|
198
|
+
PYG,
|
|
199
|
+
QAR,
|
|
200
|
+
RON,
|
|
201
|
+
RSD,
|
|
202
|
+
RUB,
|
|
203
|
+
RWF,
|
|
204
|
+
SAR,
|
|
205
|
+
SBD,
|
|
206
|
+
SCR,
|
|
207
|
+
SDG,
|
|
208
|
+
SEK,
|
|
209
|
+
SGD,
|
|
210
|
+
SHP,
|
|
211
|
+
SLE,
|
|
212
|
+
SOS,
|
|
213
|
+
SRD,
|
|
214
|
+
SSP,
|
|
215
|
+
STN,
|
|
216
|
+
SVC,
|
|
217
|
+
SYP,
|
|
218
|
+
SZL,
|
|
219
|
+
THB,
|
|
220
|
+
TJS,
|
|
221
|
+
TMT,
|
|
222
|
+
TND,
|
|
223
|
+
TOP,
|
|
224
|
+
TRY,
|
|
225
|
+
TTD,
|
|
226
|
+
TWD,
|
|
227
|
+
TZS,
|
|
228
|
+
UAH,
|
|
229
|
+
UGX,
|
|
230
|
+
USD,
|
|
231
|
+
USN,
|
|
232
|
+
UYI,
|
|
233
|
+
UYU,
|
|
234
|
+
UYW,
|
|
235
|
+
UZS,
|
|
236
|
+
VED,
|
|
237
|
+
VES,
|
|
238
|
+
VND,
|
|
239
|
+
VUV,
|
|
240
|
+
WST,
|
|
241
|
+
XAD,
|
|
242
|
+
XAF,
|
|
243
|
+
XAG,
|
|
244
|
+
XAU,
|
|
245
|
+
XCD,
|
|
246
|
+
XCG,
|
|
247
|
+
XDR,
|
|
248
|
+
XOF,
|
|
249
|
+
XPD,
|
|
250
|
+
XPF,
|
|
251
|
+
XPT,
|
|
252
|
+
YER,
|
|
253
|
+
ZAR,
|
|
254
|
+
ZMW,
|
|
255
|
+
ZWG,
|
|
256
|
+
ZWL
|
|
257
|
+
};
|
|
258
|
+
function resolveCurrency(currencyCode) {
|
|
259
|
+
return SUPPORTED_CURRENCIES[currencyCode];
|
|
260
|
+
}
|
|
261
|
+
__name(resolveCurrency, "resolveCurrency");
|
|
262
|
+
function minorToMajor(minor, currencyCode, transform) {
|
|
263
|
+
const currency = resolveCurrency(currencyCode);
|
|
264
|
+
const amount = dinero({
|
|
265
|
+
amount: minor,
|
|
266
|
+
currency
|
|
267
|
+
});
|
|
268
|
+
if (!transform) {
|
|
269
|
+
return toDecimal(amount);
|
|
270
|
+
}
|
|
271
|
+
return toDecimal(amount, ({ value, currency: resolvedCurrency }) => transform({
|
|
272
|
+
value,
|
|
273
|
+
currency: resolvedCurrency
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
__name(minorToMajor, "minorToMajor");
|
|
277
|
+
function majorToMinor(major, currencyCode, field = "amount") {
|
|
278
|
+
const { exponent } = resolveCurrency(currencyCode);
|
|
279
|
+
const scale = typeof exponent === "bigint" ? Number(exponent) : exponent;
|
|
280
|
+
const trimmed = major.trim();
|
|
281
|
+
if (!/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
282
|
+
throw new ValidationException({
|
|
283
|
+
detail: `Invalid amount: "${major}".`,
|
|
284
|
+
errors: [
|
|
285
|
+
{
|
|
286
|
+
field,
|
|
287
|
+
message: "Enter a valid number."
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const isNegative = trimmed.startsWith("-");
|
|
293
|
+
const unsignedValue = isNegative ? trimmed.slice(1) : trimmed;
|
|
294
|
+
const [wholePart, fractionalPart = ""] = unsignedValue.split(".");
|
|
295
|
+
if (fractionalPart.length > scale) {
|
|
296
|
+
throw new ValidationException({
|
|
297
|
+
detail: `Too many decimal places for ${currencyCode}. Maximum allowed is ${scale}.`,
|
|
298
|
+
errors: [
|
|
299
|
+
{
|
|
300
|
+
field,
|
|
301
|
+
message: `${currencyCode} allows up to ${scale} decimal place${scale === 1 ? "" : "s"}.`
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const paddedFraction = fractionalPart.padEnd(scale, "0");
|
|
307
|
+
const normalizedDigits = `${wholePart}${paddedFraction}`.replace(/^0+(?=\d)/, "");
|
|
308
|
+
const minor = BigInt(normalizedDigits || "0");
|
|
309
|
+
return isNegative ? -minor : minor;
|
|
310
|
+
}
|
|
311
|
+
__name(majorToMinor, "majorToMinor");
|
|
312
|
+
export {
|
|
313
|
+
SUPPORTED_CURRENCIES,
|
|
314
|
+
majorToMinor,
|
|
315
|
+
minorToMajor,
|
|
316
|
+
resolveCurrency
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=money.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/money.ts","../src/exceptions/validation.exception.ts","../src/exceptions/base-field.exception.ts"],"sourcesContent":["import { dinero, toDecimal } from 'dinero.js/bigint';\nimport {\n AED,\n AFN,\n ALL,\n AMD,\n AOA,\n ARS,\n AUD,\n AWG,\n AZN,\n BAM,\n BBD,\n BDT,\n BGN,\n BHD,\n BIF,\n BMD,\n BND,\n BOB,\n BOV,\n BRL,\n BSD,\n BTN,\n BWP,\n BYN,\n BZD,\n CAD,\n CDF,\n CHE,\n CHF,\n CHW,\n CLF,\n CLP,\n CNY,\n COP,\n COU,\n CRC,\n CUP,\n CVE,\n CZK,\n DJF,\n DKK,\n DOP,\n DZD,\n EGP,\n ERN,\n ETB,\n EUR,\n FJD,\n FKP,\n GBP,\n GEL,\n GHS,\n GIP,\n GMD,\n GNF,\n GTQ,\n GYD,\n HKD,\n HNL,\n HTG,\n HUF,\n IDR,\n ILS,\n INR,\n IQD,\n IRR,\n ISK,\n JMD,\n JOD,\n JPY,\n KES,\n KGS,\n KHR,\n KMF,\n KPW,\n KRW,\n KWD,\n KYD,\n KZT,\n LAK,\n LBP,\n LKR,\n LRD,\n LSL,\n LYD,\n MAD,\n MDL,\n MGA,\n MKD,\n MMK,\n MNT,\n MOP,\n MRU,\n MUR,\n MVR,\n MWK,\n MXN,\n MXV,\n MYR,\n MZN,\n NAD,\n NGN,\n NIO,\n NOK,\n NPR,\n NZD,\n OMR,\n PAB,\n PEN,\n PGK,\n PHP,\n PKR,\n PLN,\n PYG,\n QAR,\n RON,\n RSD,\n RUB,\n RWF,\n SAR,\n SBD,\n SCR,\n SDG,\n SEK,\n SGD,\n SHP,\n SLE,\n SOS,\n SRD,\n SSP,\n STN,\n SVC,\n SYP,\n SZL,\n THB,\n TJS,\n TMT,\n TND,\n TOP,\n TRY,\n TTD,\n TWD,\n TZS,\n UAH,\n UGX,\n USD,\n USN,\n UYI,\n UYU,\n UYW,\n UZS,\n VED,\n VES,\n VND,\n VUV,\n WST,\n XAD,\n XAF,\n XCD,\n XCG,\n XOF,\n XPF,\n YER,\n ZAR,\n ZMW,\n ZWG,\n} from 'dinero.js/bigint/currencies';\nimport { ValidationException } from './exceptions/validation.exception';\n\nexport * from 'dinero.js/bigint';\n\nconst ANG = { code: 'ANG', base: 10n, exponent: 2n } as const;\nconst HRK = { code: 'HRK', base: 10n, exponent: 2n } as const;\nconst XAG = { code: 'XAG', base: 10n, exponent: 0n } as const;\nconst XAU = { code: 'XAU', base: 10n, exponent: 0n } as const;\nconst XDR = { code: 'XDR', base: 10n, exponent: 0n } as const;\nconst XPD = { code: 'XPD', base: 10n, exponent: 0n } as const;\nconst XPT = { code: 'XPT', base: 10n, exponent: 0n } as const;\nconst ZWL = { code: 'ZWL', base: 10n, exponent: 2n } as const;\n\nexport const SUPPORTED_CURRENCIES = {\n AED,\n AFN,\n ALL,\n AMD,\n ANG,\n AOA,\n ARS,\n AUD,\n AWG,\n AZN,\n BAM,\n BBD,\n BDT,\n BGN,\n BHD,\n BIF,\n BMD,\n BND,\n BOB,\n BOV,\n BRL,\n BSD,\n BTN,\n BWP,\n BYN,\n BZD,\n CAD,\n CDF,\n CHE,\n CHF,\n CHW,\n CLF,\n CLP,\n CNY,\n COP,\n COU,\n CRC,\n CUP,\n CVE,\n CZK,\n DJF,\n DKK,\n DOP,\n DZD,\n EGP,\n ERN,\n ETB,\n EUR,\n FJD,\n FKP,\n GBP,\n GEL,\n GHS,\n GIP,\n GMD,\n GNF,\n GTQ,\n GYD,\n HKD,\n HNL,\n HRK,\n HTG,\n HUF,\n IDR,\n ILS,\n INR,\n IQD,\n IRR,\n ISK,\n JMD,\n JOD,\n JPY,\n KES,\n KGS,\n KHR,\n KMF,\n KPW,\n KRW,\n KWD,\n KYD,\n KZT,\n LAK,\n LBP,\n LKR,\n LRD,\n LSL,\n LYD,\n MAD,\n MDL,\n MGA,\n MKD,\n MMK,\n MNT,\n MOP,\n MRU,\n MUR,\n MVR,\n MWK,\n MXN,\n MXV,\n MYR,\n MZN,\n NAD,\n NGN,\n NIO,\n NOK,\n NPR,\n NZD,\n OMR,\n PAB,\n PEN,\n PGK,\n PHP,\n PKR,\n PLN,\n PYG,\n QAR,\n RON,\n RSD,\n RUB,\n RWF,\n SAR,\n SBD,\n SCR,\n SDG,\n SEK,\n SGD,\n SHP,\n SLE,\n SOS,\n SRD,\n SSP,\n STN,\n SVC,\n SYP,\n SZL,\n THB,\n TJS,\n TMT,\n TND,\n TOP,\n TRY,\n TTD,\n TWD,\n TZS,\n UAH,\n UGX,\n USD,\n USN,\n UYI,\n UYU,\n UYW,\n UZS,\n VED,\n VES,\n VND,\n VUV,\n WST,\n XAD,\n XAF,\n XAG,\n XAU,\n XCD,\n XCG,\n XDR,\n XOF,\n XPD,\n XPF,\n XPT,\n YER,\n ZAR,\n ZMW,\n ZWG,\n ZWL,\n} as const;\n\nexport type CurrencyCode = keyof typeof SUPPORTED_CURRENCIES;\nexport type Currency = (typeof SUPPORTED_CURRENCIES)[CurrencyCode];\n\nexport type MinorToMajorTransform<TOutput> = (props: { value: string; currency: Currency }) => TOutput;\n\nexport function resolveCurrency(currencyCode: CurrencyCode): Currency {\n return SUPPORTED_CURRENCIES[currencyCode];\n}\n\nexport function minorToMajor<TOutput = string>(\n minor: bigint,\n currencyCode: CurrencyCode,\n transform?: MinorToMajorTransform<TOutput>,\n): string | TOutput {\n const currency = resolveCurrency(currencyCode);\n const amount = dinero({ amount: minor, currency });\n\n if (!transform) {\n return toDecimal(amount);\n }\n\n return toDecimal(amount, ({ value, currency: resolvedCurrency }) => transform({ value, currency: resolvedCurrency }));\n}\n\n// Throws ValidationException (HTTP 422) instead of generic Error so the\n// NestJS error filter maps it to a field-level response automatically.\n// Callers pass `field` so the validation error binds to the right form field.\nexport function majorToMinor(major: string, currencyCode: CurrencyCode, field = 'amount'): bigint {\n const { exponent } = resolveCurrency(currencyCode);\n const scale = typeof exponent === 'bigint' ? Number(exponent) : exponent;\n const trimmed = major.trim();\n\n if (!/^-?\\d+(\\.\\d+)?$/.test(trimmed)) {\n throw new ValidationException({\n detail: `Invalid amount: \"${major}\".`,\n errors: [{ field, message: 'Enter a valid number.' }],\n });\n }\n\n const isNegative = trimmed.startsWith('-');\n const unsignedValue = isNegative ? trimmed.slice(1) : trimmed;\n const [wholePart, fractionalPart = ''] = unsignedValue.split('.');\n\n if (fractionalPart.length > scale) {\n throw new ValidationException({\n detail: `Too many decimal places for ${currencyCode}. Maximum allowed is ${scale}.`,\n errors: [{ field, message: `${currencyCode} allows up to ${scale} decimal place${scale === 1 ? '' : 's'}.` }],\n });\n }\n\n const paddedFraction = fractionalPart.padEnd(scale, '0');\n const normalizedDigits = `${wholePart}${paddedFraction}`.replace(/^0+(?=\\d)/, '');\n const minor = BigInt(normalizedDigits || '0');\n\n return isNegative ? -minor : minor;\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class ValidationException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Validation Failed', HttpStatus.UNPROCESSABLE_ENTITY);\n }\n}\n","import { HttpException, HttpStatus } from '@nestjs/common';\nimport type { FieldError } from '../types/error-response.types';\n\n// Re-export FieldError for backwards compatibility\nexport type { FieldError } from '../types/error-response.types';\n\nexport interface ProblemOptions {\n type?: string;\n label?: string;\n detail?: string;\n errors?: FieldError[];\n}\n\nexport abstract class HttpProblemException extends HttpException {\n constructor(detailOrOptions: string | ProblemOptions, httpStatus: HttpStatus) {\n const options = typeof detailOrOptions === 'string' ? { detail: detailOrOptions } : detailOrOptions;\n\n super(\n {\n type: options.type ?? 'about:blank',\n label: options.label,\n detail: options.detail,\n errors: options.errors ?? [],\n },\n httpStatus,\n );\n }\n}\n"],"mappings":";;;;AAAA,SAASA,QAAQC,iBAAiB;AAClC,SACEC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,KACAC,WACK;;;ACxKP,SAASC,kBAAkB;;;ACA3B,SAASC,qBAAiC;AAanC,IAAeC,uBAAf,cAA4CC,cAAAA;EAbnD,OAamDA;;;EACjD,YAAYC,iBAA0CC,YAAwB;AAC5E,UAAMC,UAAU,OAAOF,oBAAoB,WAAW;MAAEG,QAAQH;IAAg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","names":["dinero","toDecimal","AED","AFN","ALL","AMD","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BOV","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHE","CHF","CHW","CLF","CLP","CNY","COP","COU","CRC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HTG","HUF","IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MXV","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLE","SOS","SRD","SSP","STN","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","USN","UYI","UYU","UYW","UZS","VED","VES","VND","VUV","WST","XAD","XAF","XCD","XCG","XOF","XPF","YER","ZAR","ZMW","ZWG","HttpStatus","HttpException","HttpProblemException","HttpException","detailOrOptions","httpStatus","options","detail","type","label","errors","ValidationException","HttpProblemException","detailOrOptions","HttpStatus","UNPROCESSABLE_ENTITY","ANG","code","base","exponent","HRK","XAG","XAU","XDR","XPD","XPT","ZWL","SUPPORTED_CURRENCIES","AED","AFN","ALL","AMD","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BOV","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHE","CHF","CHW","CLF","CLP","CNY","COP","COU","CRC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HTG","HUF","IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MXV","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLE","SOS","SRD","SSP","STN","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","USN","UYI","UYU","UYW","UZS","VED","VES","VND","VUV","WST","XAD","XAF","XCD","XCG","XOF","XPF","YER","ZAR","ZMW","ZWG","resolveCurrency","currencyCode","minorToMajor","minor","transform","currency","amount","dinero","toDecimal","value","resolvedCurrency","majorToMinor","major","field","scale","Number","trimmed","trim","test","ValidationException","detail","errors","message","isNegative","startsWith","unsignedValue","slice","wholePart","fractionalPart","split","length","paddedFraction","padEnd","normalizedDigits","replace","BigInt"]}
|
package/dist/xlsx.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/xlsx.ts","../src/utils/export.utils.ts"],"sourcesContent":["export { type ExportFormat,
|
|
1
|
+
{"version":3,"sources":["../src/xlsx.ts","../src/utils/export.utils.ts"],"sourcesContent":["export { buildExportBuffer, type ExportFormat, getExportExt, getExportMimeType } from './utils/export.utils';\n","import { type BookType, utils, write } from 'xlsx';\n\nexport type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';\n\nconst FORMAT_CONFIG: Record<\n ExportFormat,\n { bookType: BookType; mimeType: string; ext: string; opts?: Record<string, unknown> }\n> = {\n xlsx: {\n bookType: 'xlsx',\n mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ext: 'xlsx',\n },\n xls: { bookType: 'biff8', mimeType: 'application/vnd.ms-excel', ext: 'xls' },\n csv: { bookType: 'csv', mimeType: 'text/csv', ext: 'csv' },\n tsv: { bookType: 'csv', mimeType: 'text/tab-separated-values', ext: 'tsv', opts: { FS: '\\t' } },\n ods: { bookType: 'ods', mimeType: 'application/vnd.oasis.opendocument.spreadsheet', ext: 'ods' },\n};\n\n// Converts an array of row objects into a spreadsheet buffer in the given format\nexport function buildExportBuffer(rows: Record<string, unknown>[], format: ExportFormat = 'xlsx'): Buffer {\n const config = FORMAT_CONFIG[format];\n const ws = utils.json_to_sheet(rows);\n const wb = utils.book_new();\n utils.book_append_sheet(wb, ws, 'Sheet1');\n return write(wb, { type: 'buffer', bookType: config.bookType, ...config.opts }) as Buffer;\n}\n\nexport function getExportMimeType(format: ExportFormat): string {\n return FORMAT_CONFIG[format].mimeType;\n}\n\nexport function getExportExt(format: ExportFormat): string {\n return FORMAT_CONFIG[format].ext;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAA,kBAA4C;AAI5C,IAAMA,gBAGF;EACFC,MAAM;IACJC,UAAU;IACVC,UAAU;IACVC,KAAK;EACP;EACAC,KAAK;IAAEH,UAAU;IAASC,UAAU;IAA4BC,KAAK;EAAM;EAC3EE,KAAK;IAAEJ,UAAU;IAAOC,UAAU;IAAYC,KAAK;EAAM;EACzDG,KAAK;IAAEL,UAAU;IAAOC,UAAU;IAA6BC,KAAK;IAAOI,MAAM;MAAEC,IAAI;IAAK;EAAE;EAC9FC,KAAK;IAAER,UAAU;IAAOC,UAAU;IAAkDC,KAAK;EAAM;AACjG;AAGO,SAASO,kBAAkBC,MAAiCC,SAAuB,QAAM;AAC9F,QAAMC,SAASd,cAAca,MAAAA;AAC7B,QAAME,KAAKC,kBAAMC,cAAcL,IAAAA;AAC/B,QAAMM,KAAKF,kBAAMG,SAAQ;AACzBH,oBAAMI,kBAAkBF,IAAIH,IAAI,QAAA;AAChC,aAAOM,mBAAMH,IAAI;IAAEI,MAAM;IAAUpB,UAAUY,OAAOZ;IAAU,GAAGY,OAAON;EAAK,CAAA;AAC/E;AANgBG;AAQT,SAASY,kBAAkBV,QAAoB;AACpD,SAAOb,cAAca,MAAAA,EAAQV;AAC/B;AAFgBoB;AAIT,SAASC,aAAaX,QAAoB;AAC/C,SAAOb,cAAca,MAAAA,EAAQT;AAC/B;AAFgBoB;","names":["FORMAT_CONFIG","xlsx","bookType","mimeType","ext","xls","csv","tsv","opts","FS","ods","buildExportBuffer","rows","format","config","ws","utils","json_to_sheet","wb","book_new","book_append_sheet","write","type","getExportMimeType","getExportExt"]}
|
package/dist/xlsx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/export.utils.ts"],"sourcesContent":["import { type BookType, utils, write } from 'xlsx';\n\nexport type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';\n\nconst FORMAT_CONFIG: Record
|
|
1
|
+
{"version":3,"sources":["../src/utils/export.utils.ts"],"sourcesContent":["import { type BookType, utils, write } from 'xlsx';\n\nexport type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';\n\nconst FORMAT_CONFIG: Record<\n ExportFormat,\n { bookType: BookType; mimeType: string; ext: string; opts?: Record<string, unknown> }\n> = {\n xlsx: {\n bookType: 'xlsx',\n mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n ext: 'xlsx',\n },\n xls: { bookType: 'biff8', mimeType: 'application/vnd.ms-excel', ext: 'xls' },\n csv: { bookType: 'csv', mimeType: 'text/csv', ext: 'csv' },\n tsv: { bookType: 'csv', mimeType: 'text/tab-separated-values', ext: 'tsv', opts: { FS: '\\t' } },\n ods: { bookType: 'ods', mimeType: 'application/vnd.oasis.opendocument.spreadsheet', ext: 'ods' },\n};\n\n// Converts an array of row objects into a spreadsheet buffer in the given format\nexport function buildExportBuffer(rows: Record<string, unknown>[], format: ExportFormat = 'xlsx'): Buffer {\n const config = FORMAT_CONFIG[format];\n const ws = utils.json_to_sheet(rows);\n const wb = utils.book_new();\n utils.book_append_sheet(wb, ws, 'Sheet1');\n return write(wb, { type: 'buffer', bookType: config.bookType, ...config.opts }) as Buffer;\n}\n\nexport function getExportMimeType(format: ExportFormat): string {\n return FORMAT_CONFIG[format].mimeType;\n}\n\nexport function getExportExt(format: ExportFormat): string {\n return FORMAT_CONFIG[format].ext;\n}\n"],"mappings":";;;;AAAA,SAAwBA,OAAOC,aAAa;AAI5C,IAAMC,gBAGF;EACFC,MAAM;IACJC,UAAU;IACVC,UAAU;IACVC,KAAK;EACP;EACAC,KAAK;IAAEH,UAAU;IAASC,UAAU;IAA4BC,KAAK;EAAM;EAC3EE,KAAK;IAAEJ,UAAU;IAAOC,UAAU;IAAYC,KAAK;EAAM;EACzDG,KAAK;IAAEL,UAAU;IAAOC,UAAU;IAA6BC,KAAK;IAAOI,MAAM;MAAEC,IAAI;IAAK;EAAE;EAC9FC,KAAK;IAAER,UAAU;IAAOC,UAAU;IAAkDC,KAAK;EAAM;AACjG;AAGO,SAASO,kBAAkBC,MAAiCC,SAAuB,QAAM;AAC9F,QAAMC,SAASd,cAAca,MAAAA;AAC7B,QAAME,KAAKC,MAAMC,cAAcL,IAAAA;AAC/B,QAAMM,KAAKF,MAAMG,SAAQ;AACzBH,QAAMI,kBAAkBF,IAAIH,IAAI,QAAA;AAChC,SAAOM,MAAMH,IAAI;IAAEI,MAAM;IAAUpB,UAAUY,OAAOZ;IAAU,GAAGY,OAAON;EAAK,CAAA;AAC/E;AANgBG;AAQT,SAASY,kBAAkBV,QAAoB;AACpD,SAAOb,cAAca,MAAAA,EAAQV;AAC/B;AAFgBoB;AAIT,SAASC,aAAaX,QAAoB;AAC/C,SAAOb,cAAca,MAAAA,EAAQT;AAC/B;AAFgBoB;","names":["utils","write","FORMAT_CONFIG","xlsx","bookType","mimeType","ext","xls","csv","tsv","opts","FS","ods","buildExportBuffer","rows","format","config","ws","utils","json_to_sheet","wb","book_new","book_append_sheet","write","type","getExportMimeType","getExportExt"]}
|