@open-mercato/shared 0.10.1-develop.8287.1.7313a0fe67 → 0.10.1-develop.8291.1.6ec3aee41c
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/.turbo/turbo-build.log +1 -1
- package/AGENTS.md +2 -1
- package/dist/lib/currencyPrecision.js +51 -0
- package/dist/lib/currencyPrecision.js.map +7 -0
- package/dist/lib/db/exactDecimalType.js +20 -0
- package/dist/lib/db/exactDecimalType.js.map +7 -0
- package/dist/lib/decimal.js +289 -0
- package/dist/lib/decimal.js.map +7 -0
- package/dist/lib/isoCurrencyMinorUnits.js +313 -0
- package/dist/lib/isoCurrencyMinorUnits.js.map +7 -0
- package/dist/lib/number.js +20 -2
- package/dist/lib/number.js.map +2 -2
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/dist/modules/payment_gateways/types.js.map +2 -2
- package/package.json +4 -2
- package/src/lib/__tests__/currencyPrecision.test.ts +114 -0
- package/src/lib/__tests__/decimal.test.ts +381 -0
- package/src/lib/__tests__/number.test.ts +40 -1
- package/src/lib/currencyPrecision.ts +82 -0
- package/src/lib/db/__tests__/exactDecimalType.test.ts +86 -0
- package/src/lib/db/exactDecimalType.ts +25 -0
- package/src/lib/decimal.ts +427 -0
- package/src/lib/isoCurrencyMinorUnits.ts +315 -0
- package/src/lib/number.ts +32 -2
- package/src/modules/payment_gateways/types.ts +18 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
const ISO_4217_MINOR_UNITS = Object.freeze({
|
|
2
|
+
ADP: null,
|
|
3
|
+
AED: 2,
|
|
4
|
+
AFA: null,
|
|
5
|
+
AFN: 2,
|
|
6
|
+
ALK: null,
|
|
7
|
+
ALL: 2,
|
|
8
|
+
AMD: 2,
|
|
9
|
+
ANG: null,
|
|
10
|
+
AOA: 2,
|
|
11
|
+
AOK: null,
|
|
12
|
+
AON: null,
|
|
13
|
+
AOR: null,
|
|
14
|
+
ARA: null,
|
|
15
|
+
ARP: null,
|
|
16
|
+
ARS: 2,
|
|
17
|
+
ARY: null,
|
|
18
|
+
ATS: null,
|
|
19
|
+
AUD: 2,
|
|
20
|
+
AWG: 2,
|
|
21
|
+
AYM: null,
|
|
22
|
+
AZM: null,
|
|
23
|
+
AZN: 2,
|
|
24
|
+
BAD: null,
|
|
25
|
+
BAM: 2,
|
|
26
|
+
BBD: 2,
|
|
27
|
+
BDT: 2,
|
|
28
|
+
BEC: null,
|
|
29
|
+
BEF: null,
|
|
30
|
+
BEL: null,
|
|
31
|
+
BGJ: null,
|
|
32
|
+
BGK: null,
|
|
33
|
+
BGL: null,
|
|
34
|
+
BGN: null,
|
|
35
|
+
BHD: 3,
|
|
36
|
+
BIF: 0,
|
|
37
|
+
BMD: 2,
|
|
38
|
+
BND: 2,
|
|
39
|
+
BOB: 2,
|
|
40
|
+
BOP: null,
|
|
41
|
+
BOV: 2,
|
|
42
|
+
BRB: null,
|
|
43
|
+
BRC: null,
|
|
44
|
+
BRE: null,
|
|
45
|
+
BRL: 2,
|
|
46
|
+
BRN: null,
|
|
47
|
+
BRR: null,
|
|
48
|
+
BSD: 2,
|
|
49
|
+
BTN: 2,
|
|
50
|
+
BUK: null,
|
|
51
|
+
BWP: 2,
|
|
52
|
+
BYB: null,
|
|
53
|
+
BYN: 2,
|
|
54
|
+
BYR: null,
|
|
55
|
+
BZD: 2,
|
|
56
|
+
CAD: 2,
|
|
57
|
+
CDF: 2,
|
|
58
|
+
CHC: null,
|
|
59
|
+
CHE: 2,
|
|
60
|
+
CHF: 2,
|
|
61
|
+
CHW: 2,
|
|
62
|
+
CLF: 4,
|
|
63
|
+
CLP: 0,
|
|
64
|
+
CNY: 2,
|
|
65
|
+
COP: 2,
|
|
66
|
+
COU: 2,
|
|
67
|
+
CRC: 2,
|
|
68
|
+
CSD: null,
|
|
69
|
+
CSJ: null,
|
|
70
|
+
CSK: null,
|
|
71
|
+
CUC: null,
|
|
72
|
+
CUP: 2,
|
|
73
|
+
CVE: 2,
|
|
74
|
+
CYP: null,
|
|
75
|
+
CZK: 2,
|
|
76
|
+
DDM: null,
|
|
77
|
+
DEM: null,
|
|
78
|
+
DJF: 0,
|
|
79
|
+
DKK: 2,
|
|
80
|
+
DOP: 2,
|
|
81
|
+
DZD: 2,
|
|
82
|
+
ECS: null,
|
|
83
|
+
ECV: null,
|
|
84
|
+
EEK: null,
|
|
85
|
+
EGP: 2,
|
|
86
|
+
ERN: 2,
|
|
87
|
+
ESA: null,
|
|
88
|
+
ESB: null,
|
|
89
|
+
ESP: null,
|
|
90
|
+
ETB: 2,
|
|
91
|
+
EUR: 2,
|
|
92
|
+
FIM: null,
|
|
93
|
+
FJD: 2,
|
|
94
|
+
FKP: 2,
|
|
95
|
+
FRF: null,
|
|
96
|
+
GBP: 2,
|
|
97
|
+
GEK: null,
|
|
98
|
+
GEL: 2,
|
|
99
|
+
GHC: null,
|
|
100
|
+
GHP: null,
|
|
101
|
+
GHS: 2,
|
|
102
|
+
GIP: 2,
|
|
103
|
+
GMD: 2,
|
|
104
|
+
GNE: null,
|
|
105
|
+
GNF: 0,
|
|
106
|
+
GNS: null,
|
|
107
|
+
GQE: null,
|
|
108
|
+
GRD: null,
|
|
109
|
+
GTQ: 2,
|
|
110
|
+
GWE: null,
|
|
111
|
+
GWP: null,
|
|
112
|
+
GYD: 2,
|
|
113
|
+
HKD: 2,
|
|
114
|
+
HNL: 2,
|
|
115
|
+
HRD: null,
|
|
116
|
+
HRK: null,
|
|
117
|
+
HTG: 2,
|
|
118
|
+
HUF: 2,
|
|
119
|
+
IDR: 2,
|
|
120
|
+
IEP: null,
|
|
121
|
+
ILP: null,
|
|
122
|
+
ILR: null,
|
|
123
|
+
ILS: 2,
|
|
124
|
+
INR: 2,
|
|
125
|
+
IQD: 3,
|
|
126
|
+
IRR: 2,
|
|
127
|
+
ISJ: null,
|
|
128
|
+
ISK: 0,
|
|
129
|
+
ITL: null,
|
|
130
|
+
JMD: 2,
|
|
131
|
+
JOD: 3,
|
|
132
|
+
JPY: 0,
|
|
133
|
+
KES: 2,
|
|
134
|
+
KGS: 2,
|
|
135
|
+
KHR: 2,
|
|
136
|
+
KMF: 0,
|
|
137
|
+
KPW: 2,
|
|
138
|
+
KRW: 0,
|
|
139
|
+
KWD: 3,
|
|
140
|
+
KYD: 2,
|
|
141
|
+
KZT: 2,
|
|
142
|
+
LAJ: null,
|
|
143
|
+
LAK: 2,
|
|
144
|
+
LBP: 2,
|
|
145
|
+
LKR: 2,
|
|
146
|
+
LRD: 2,
|
|
147
|
+
LSL: 2,
|
|
148
|
+
LSM: null,
|
|
149
|
+
LTL: null,
|
|
150
|
+
LTT: null,
|
|
151
|
+
LUC: null,
|
|
152
|
+
LUF: null,
|
|
153
|
+
LUL: null,
|
|
154
|
+
LVL: null,
|
|
155
|
+
LVR: null,
|
|
156
|
+
LYD: 3,
|
|
157
|
+
MAD: 2,
|
|
158
|
+
MDL: 2,
|
|
159
|
+
MGA: 2,
|
|
160
|
+
MGF: null,
|
|
161
|
+
MKD: 2,
|
|
162
|
+
MLF: null,
|
|
163
|
+
MMK: 2,
|
|
164
|
+
MNT: 2,
|
|
165
|
+
MOP: 2,
|
|
166
|
+
MRO: null,
|
|
167
|
+
MRU: 2,
|
|
168
|
+
MTL: null,
|
|
169
|
+
MTP: null,
|
|
170
|
+
MUR: 2,
|
|
171
|
+
MVQ: null,
|
|
172
|
+
MVR: 2,
|
|
173
|
+
MWK: 2,
|
|
174
|
+
MXN: 2,
|
|
175
|
+
MXP: null,
|
|
176
|
+
MXV: 2,
|
|
177
|
+
MYR: 2,
|
|
178
|
+
MZE: null,
|
|
179
|
+
MZM: null,
|
|
180
|
+
MZN: 2,
|
|
181
|
+
NAD: 2,
|
|
182
|
+
NGN: 2,
|
|
183
|
+
NIC: null,
|
|
184
|
+
NIO: 2,
|
|
185
|
+
NLG: null,
|
|
186
|
+
NOK: 2,
|
|
187
|
+
NPR: 2,
|
|
188
|
+
NZD: 2,
|
|
189
|
+
OMR: 3,
|
|
190
|
+
PAB: 2,
|
|
191
|
+
PEH: null,
|
|
192
|
+
PEI: null,
|
|
193
|
+
PEN: 2,
|
|
194
|
+
PES: null,
|
|
195
|
+
PGK: 2,
|
|
196
|
+
PHP: 2,
|
|
197
|
+
PKR: 2,
|
|
198
|
+
PLN: 2,
|
|
199
|
+
PLZ: null,
|
|
200
|
+
PTE: null,
|
|
201
|
+
PYG: 0,
|
|
202
|
+
QAR: 2,
|
|
203
|
+
RHD: null,
|
|
204
|
+
ROK: null,
|
|
205
|
+
ROL: null,
|
|
206
|
+
RON: 2,
|
|
207
|
+
RSD: 2,
|
|
208
|
+
RUB: 2,
|
|
209
|
+
RUR: null,
|
|
210
|
+
RWF: 0,
|
|
211
|
+
SAR: 2,
|
|
212
|
+
SBD: 2,
|
|
213
|
+
SCR: 2,
|
|
214
|
+
SDD: null,
|
|
215
|
+
SDG: 2,
|
|
216
|
+
SDP: null,
|
|
217
|
+
SEK: 2,
|
|
218
|
+
SGD: 2,
|
|
219
|
+
SHP: 2,
|
|
220
|
+
SIT: null,
|
|
221
|
+
SKK: null,
|
|
222
|
+
SLE: 2,
|
|
223
|
+
SLL: null,
|
|
224
|
+
SOS: 2,
|
|
225
|
+
SRD: 2,
|
|
226
|
+
SRG: null,
|
|
227
|
+
SSP: 2,
|
|
228
|
+
STD: null,
|
|
229
|
+
STN: 2,
|
|
230
|
+
SUR: null,
|
|
231
|
+
SVC: 2,
|
|
232
|
+
SYP: 2,
|
|
233
|
+
SZL: 2,
|
|
234
|
+
THB: 2,
|
|
235
|
+
TJR: null,
|
|
236
|
+
TJS: 2,
|
|
237
|
+
TMM: null,
|
|
238
|
+
TMT: 2,
|
|
239
|
+
TND: 3,
|
|
240
|
+
TOP: 2,
|
|
241
|
+
TPE: null,
|
|
242
|
+
TRL: null,
|
|
243
|
+
TRY: 2,
|
|
244
|
+
TTD: 2,
|
|
245
|
+
TWD: 2,
|
|
246
|
+
TZS: 2,
|
|
247
|
+
UAH: 2,
|
|
248
|
+
UAK: null,
|
|
249
|
+
UGS: null,
|
|
250
|
+
UGW: null,
|
|
251
|
+
UGX: 0,
|
|
252
|
+
USD: 2,
|
|
253
|
+
USN: 2,
|
|
254
|
+
USS: null,
|
|
255
|
+
UYI: 0,
|
|
256
|
+
UYN: null,
|
|
257
|
+
UYP: null,
|
|
258
|
+
UYU: 2,
|
|
259
|
+
UYW: 4,
|
|
260
|
+
UZS: 2,
|
|
261
|
+
VEB: null,
|
|
262
|
+
VED: 2,
|
|
263
|
+
VEF: null,
|
|
264
|
+
VES: 2,
|
|
265
|
+
VNC: null,
|
|
266
|
+
VND: 0,
|
|
267
|
+
VUV: 0,
|
|
268
|
+
WST: 2,
|
|
269
|
+
XAD: 2,
|
|
270
|
+
XAF: 0,
|
|
271
|
+
XAG: null,
|
|
272
|
+
XAU: null,
|
|
273
|
+
XBA: null,
|
|
274
|
+
XBB: null,
|
|
275
|
+
XBC: null,
|
|
276
|
+
XBD: null,
|
|
277
|
+
XCD: 2,
|
|
278
|
+
XCG: 2,
|
|
279
|
+
XDR: null,
|
|
280
|
+
XEU: null,
|
|
281
|
+
XFO: null,
|
|
282
|
+
XFU: null,
|
|
283
|
+
XOF: 0,
|
|
284
|
+
XPD: null,
|
|
285
|
+
XPF: 0,
|
|
286
|
+
XPT: null,
|
|
287
|
+
XRE: null,
|
|
288
|
+
XSU: null,
|
|
289
|
+
XTS: null,
|
|
290
|
+
XUA: null,
|
|
291
|
+
XXX: null,
|
|
292
|
+
YDD: null,
|
|
293
|
+
YER: 2,
|
|
294
|
+
YUD: null,
|
|
295
|
+
YUM: null,
|
|
296
|
+
YUN: null,
|
|
297
|
+
ZAL: null,
|
|
298
|
+
ZAR: 2,
|
|
299
|
+
ZMK: null,
|
|
300
|
+
ZMW: 2,
|
|
301
|
+
ZRN: null,
|
|
302
|
+
ZRZ: null,
|
|
303
|
+
ZWC: null,
|
|
304
|
+
ZWD: null,
|
|
305
|
+
ZWG: 2,
|
|
306
|
+
ZWL: null,
|
|
307
|
+
ZWN: null,
|
|
308
|
+
ZWR: null
|
|
309
|
+
});
|
|
310
|
+
export {
|
|
311
|
+
ISO_4217_MINOR_UNITS
|
|
312
|
+
};
|
|
313
|
+
//# sourceMappingURL=isoCurrencyMinorUnits.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/isoCurrencyMinorUnits.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * ISO 4217 minor units (decimal places) of every currency code: List One published\n * 2026-09-17 (current codes) and List Three published 2026-01-01 (withdrawn codes).\n * `null` means ISO defines no minor unit: List One marks the code N.A. (XAU, XDR,\n * XXX), or the code is withdrawn and List Three publishes none.\n */\nexport const ISO_4217_MINOR_UNITS: Readonly<Record<string, number | null>> = Object.freeze({\n ADP: null,\n AED: 2,\n AFA: null,\n AFN: 2,\n ALK: null,\n ALL: 2,\n AMD: 2,\n ANG: null,\n AOA: 2,\n AOK: null,\n AON: null,\n AOR: null,\n ARA: null,\n ARP: null,\n ARS: 2,\n ARY: null,\n ATS: null,\n AUD: 2,\n AWG: 2,\n AYM: null,\n AZM: null,\n AZN: 2,\n BAD: null,\n BAM: 2,\n BBD: 2,\n BDT: 2,\n BEC: null,\n BEF: null,\n BEL: null,\n BGJ: null,\n BGK: null,\n BGL: null,\n BGN: null,\n BHD: 3,\n BIF: 0,\n BMD: 2,\n BND: 2,\n BOB: 2,\n BOP: null,\n BOV: 2,\n BRB: null,\n BRC: null,\n BRE: null,\n BRL: 2,\n BRN: null,\n BRR: null,\n BSD: 2,\n BTN: 2,\n BUK: null,\n BWP: 2,\n BYB: null,\n BYN: 2,\n BYR: null,\n BZD: 2,\n CAD: 2,\n CDF: 2,\n CHC: null,\n CHE: 2,\n CHF: 2,\n CHW: 2,\n CLF: 4,\n CLP: 0,\n CNY: 2,\n COP: 2,\n COU: 2,\n CRC: 2,\n CSD: null,\n CSJ: null,\n CSK: null,\n CUC: null,\n CUP: 2,\n CVE: 2,\n CYP: null,\n CZK: 2,\n DDM: null,\n DEM: null,\n DJF: 0,\n DKK: 2,\n DOP: 2,\n DZD: 2,\n ECS: null,\n ECV: null,\n EEK: null,\n EGP: 2,\n ERN: 2,\n ESA: null,\n ESB: null,\n ESP: null,\n ETB: 2,\n EUR: 2,\n FIM: null,\n FJD: 2,\n FKP: 2,\n FRF: null,\n GBP: 2,\n GEK: null,\n GEL: 2,\n GHC: null,\n GHP: null,\n GHS: 2,\n GIP: 2,\n GMD: 2,\n GNE: null,\n GNF: 0,\n GNS: null,\n GQE: null,\n GRD: null,\n GTQ: 2,\n GWE: null,\n GWP: null,\n GYD: 2,\n HKD: 2,\n HNL: 2,\n HRD: null,\n HRK: null,\n HTG: 2,\n HUF: 2,\n IDR: 2,\n IEP: null,\n ILP: null,\n ILR: null,\n ILS: 2,\n INR: 2,\n IQD: 3,\n IRR: 2,\n ISJ: null,\n ISK: 0,\n ITL: null,\n JMD: 2,\n JOD: 3,\n JPY: 0,\n KES: 2,\n KGS: 2,\n KHR: 2,\n KMF: 0,\n KPW: 2,\n KRW: 0,\n KWD: 3,\n KYD: 2,\n KZT: 2,\n LAJ: null,\n LAK: 2,\n LBP: 2,\n LKR: 2,\n LRD: 2,\n LSL: 2,\n LSM: null,\n LTL: null,\n LTT: null,\n LUC: null,\n LUF: null,\n LUL: null,\n LVL: null,\n LVR: null,\n LYD: 3,\n MAD: 2,\n MDL: 2,\n MGA: 2,\n MGF: null,\n MKD: 2,\n MLF: null,\n MMK: 2,\n MNT: 2,\n MOP: 2,\n MRO: null,\n MRU: 2,\n MTL: null,\n MTP: null,\n MUR: 2,\n MVQ: null,\n MVR: 2,\n MWK: 2,\n MXN: 2,\n MXP: null,\n MXV: 2,\n MYR: 2,\n MZE: null,\n MZM: null,\n MZN: 2,\n NAD: 2,\n NGN: 2,\n NIC: null,\n NIO: 2,\n NLG: null,\n NOK: 2,\n NPR: 2,\n NZD: 2,\n OMR: 3,\n PAB: 2,\n PEH: null,\n PEI: null,\n PEN: 2,\n PES: null,\n PGK: 2,\n PHP: 2,\n PKR: 2,\n PLN: 2,\n PLZ: null,\n PTE: null,\n PYG: 0,\n QAR: 2,\n RHD: null,\n ROK: null,\n ROL: null,\n RON: 2,\n RSD: 2,\n RUB: 2,\n RUR: null,\n RWF: 0,\n SAR: 2,\n SBD: 2,\n SCR: 2,\n SDD: null,\n SDG: 2,\n SDP: null,\n SEK: 2,\n SGD: 2,\n SHP: 2,\n SIT: null,\n SKK: null,\n SLE: 2,\n SLL: null,\n SOS: 2,\n SRD: 2,\n SRG: null,\n SSP: 2,\n STD: null,\n STN: 2,\n SUR: null,\n SVC: 2,\n SYP: 2,\n SZL: 2,\n THB: 2,\n TJR: null,\n TJS: 2,\n TMM: null,\n TMT: 2,\n TND: 3,\n TOP: 2,\n TPE: null,\n TRL: null,\n TRY: 2,\n TTD: 2,\n TWD: 2,\n TZS: 2,\n UAH: 2,\n UAK: null,\n UGS: null,\n UGW: null,\n UGX: 0,\n USD: 2,\n USN: 2,\n USS: null,\n UYI: 0,\n UYN: null,\n UYP: null,\n UYU: 2,\n UYW: 4,\n UZS: 2,\n VEB: null,\n VED: 2,\n VEF: null,\n VES: 2,\n VNC: null,\n VND: 0,\n VUV: 0,\n WST: 2,\n XAD: 2,\n XAF: 0,\n XAG: null,\n XAU: null,\n XBA: null,\n XBB: null,\n XBC: null,\n XBD: null,\n XCD: 2,\n XCG: 2,\n XDR: null,\n XEU: null,\n XFO: null,\n XFU: null,\n XOF: 0,\n XPD: null,\n XPF: 0,\n XPT: null,\n XRE: null,\n XSU: null,\n XTS: null,\n XUA: null,\n XXX: null,\n YDD: null,\n YER: 2,\n YUD: null,\n YUM: null,\n YUN: null,\n ZAL: null,\n ZAR: 2,\n ZMK: null,\n ZMW: 2,\n ZRN: null,\n ZRZ: null,\n ZWC: null,\n ZWD: null,\n ZWG: 2,\n ZWL: null,\n ZWN: null,\n ZWR: null,\n})\n"],
|
|
5
|
+
"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A,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACP,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/lib/number.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decimalToString, isDecimalInput } from "./decimal.js";
|
|
1
2
|
const DEFAULT_SEPARATORS = { group: ",", decimal: "." };
|
|
2
3
|
const separatorCache = /* @__PURE__ */ new Map();
|
|
3
4
|
const UNICODE_MINUS_SIGNS = /[−‒–—]/g;
|
|
@@ -32,6 +33,17 @@ function isValidGrouping(integerPart, separator) {
|
|
|
32
33
|
return rest.every((segment) => /^\d{3}$/.test(segment));
|
|
33
34
|
}
|
|
34
35
|
function parseLocaleNumber(input, locale) {
|
|
36
|
+
const normalized = normalizeLocaleNumber(input, locale);
|
|
37
|
+
if (normalized === null) return null;
|
|
38
|
+
const parsed = Number(normalized);
|
|
39
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
40
|
+
}
|
|
41
|
+
function parseLocaleDecimal(input, locale) {
|
|
42
|
+
const normalized = normalizeLocaleNumber(input, locale);
|
|
43
|
+
if (normalized === null || !isDecimalInput(normalized)) return null;
|
|
44
|
+
return decimalToString(normalized);
|
|
45
|
+
}
|
|
46
|
+
function normalizeLocaleNumber(input, locale) {
|
|
35
47
|
if (input == null) return null;
|
|
36
48
|
const trimmed = input.trim();
|
|
37
49
|
if (!trimmed) return null;
|
|
@@ -59,14 +71,18 @@ function parseLocaleNumber(input, locale) {
|
|
|
59
71
|
if (fractionParts.length && fractionParts[0].includes(groupSeparator)) return null;
|
|
60
72
|
const normalized = `${integerPart.split(groupSeparator).join("")}${fractionParts.length ? `.${fractionParts[0]}` : ""}`;
|
|
61
73
|
if (!NORMALIZED_NUMBER.test(normalized)) return null;
|
|
62
|
-
|
|
63
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
74
|
+
return normalized;
|
|
64
75
|
}
|
|
65
76
|
function formatLocaleNumberInput(value, locale) {
|
|
66
77
|
const serialized = String(value);
|
|
67
78
|
const { decimal } = resolveLocaleNumberSeparators(locale);
|
|
68
79
|
return decimal === "." ? serialized : serialized.replace(".", decimal);
|
|
69
80
|
}
|
|
81
|
+
function formatLocaleDecimalInput(value, locale) {
|
|
82
|
+
const serialized = decimalToString(value);
|
|
83
|
+
const { decimal } = resolveLocaleNumberSeparators(locale);
|
|
84
|
+
return decimal === "." ? serialized : serialized.replace(".", decimal);
|
|
85
|
+
}
|
|
70
86
|
function parseNumberWithDefault(raw, fallback, options) {
|
|
71
87
|
if (raw == null) return fallback;
|
|
72
88
|
const trimmed = raw.trim();
|
|
@@ -78,7 +94,9 @@ function parseNumberWithDefault(raw, fallback, options) {
|
|
|
78
94
|
return value;
|
|
79
95
|
}
|
|
80
96
|
export {
|
|
97
|
+
formatLocaleDecimalInput,
|
|
81
98
|
formatLocaleNumberInput,
|
|
99
|
+
parseLocaleDecimal,
|
|
82
100
|
parseLocaleNumber,
|
|
83
101
|
parseNumberWithDefault,
|
|
84
102
|
resolveLocaleNumberSeparators
|
package/dist/lib/number.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/number.ts"],
|
|
4
|
-
"sourcesContent": ["type LocaleNumberSeparators = { group: string; decimal: string }\n\nconst DEFAULT_SEPARATORS: LocaleNumberSeparators = { group: ',', decimal: '.' }\nconst separatorCache = new Map<string, LocaleNumberSeparators>()\n\nconst UNICODE_MINUS_SIGNS = /[\u2212\u2012\u2013\u2014]/g\nconst GROUP_LIKE_CHARACTER = /[\\s'\u2019\u02BC]/\nconst GROUP_LIKE_SEPARATOR_IN_POSITION = /(\\d)[\\s'\u2019\u02BC](?=\\d{3}(?!\\d))/g\nconst NORMALIZED_NUMBER = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i\n\n/**\n * Group and decimal separators the given locale uses, derived from `Intl` rather than\n * assumed, so grouping characters such as the narrow no-break space (`fr-FR`) are covered.\n */\nexport function resolveLocaleNumberSeparators(locale?: string): LocaleNumberSeparators {\n const cacheKey = locale ?? ''\n const cached = separatorCache.get(cacheKey)\n if (cached) return cached\n let resolved = DEFAULT_SEPARATORS\n try {\n const parts = new Intl.NumberFormat(locale, {\n useGrouping: true,\n minimumFractionDigits: 1,\n }).formatToParts(12345.6)\n const group = parts.find((part) => part.type === 'group')?.value ?? DEFAULT_SEPARATORS.group\n const decimal = parts.find((part) => part.type === 'decimal')?.value ?? DEFAULT_SEPARATORS.decimal\n resolved = { group, decimal }\n } catch {\n resolved = DEFAULT_SEPARATORS\n }\n separatorCache.set(cacheKey, resolved)\n return resolved\n}\n\nfunction isValidGrouping(integerPart: string, separator: string): boolean {\n const digits = integerPart.replace(/^[+-]/, '')\n const segments = digits.split(separator)\n if (segments.length < 2) return true\n const [first, ...rest] = segments\n if (!/^\\d{1,3}$/.test(first)) return false\n return rest.every((segment) => /^\\d{3}$/.test(segment))\n}\n\n/**\n * Parses a user-typed number written in the conventions of `locale` \u2014 `110,70` under `pl-PL`,\n * `1 234,56` under `fr-FR`, `1,234.56` under `en-US`. Returns `null` when the input is not a\n * number, never a silent `0`, so callers can tell \"unparseable\" apart from \"zero\".\n *\n * Both `,` and `.` are accepted as the decimal separator whichever way the locale runs, because\n * users type the shape their keyboard offers. A SINGLE `,` or `.` is therefore always the decimal\n * point, in every locale: `1.500` is 1.5 under `de-DE` just as it is under `en-US`. Reading a lone\n * separator as grouping instead would turn `1.500` into 1500 with no visible cue \u2014 a silent 1000\u00D7\n * on a money field, and three- and four-decimal unit prices are ordinary here. Grouping is\n * recognized only where it is unambiguous: at least two separators (`1.234.567`), or a whitespace\n * or apostrophe separator standing in a valid group-of-three position (`1 234,56`, `1\u2019234.5`).\n * Whitespace and apostrophes anywhere else are not absorbed \u2014 `1 2` is rejected rather than read\n * as 12 \u2014 so a mistyped or pasted value surfaces as an error instead of a different number.\n *\n * Use it only on strings a user typed. Values arriving from an API or the database are already\n * numbers and MUST NOT go through it.\n */\nexport function parseLocaleNumber(input: string | null | undefined, locale?: string): number | null {\n if (input == null) return null\n const trimmed = input.trim()\n if (!trimmed) return null\n\n const { group } = resolveLocaleNumberSeparators(locale)\n let candidate = trimmed.replace(UNICODE_MINUS_SIGNS, '-')\n if (group && group !== ',' && group !== '.' && !GROUP_LIKE_CHARACTER.test(group)) {\n candidate = candidate.split(group).join(' ')\n }\n candidate = candidate.replace(GROUP_LIKE_SEPARATOR_IN_POSITION, '$1')\n if (!candidate) return null\n\n const hasComma = candidate.includes(',')\n const hasDot = candidate.includes('.')\n let decimalSeparator: string | null = null\n if (hasComma && hasDot) {\n decimalSeparator = candidate.lastIndexOf(',') > candidate.lastIndexOf('.') ? ',' : '.'\n } else if (hasComma || hasDot) {\n const separator = hasComma ? ',' : '.'\n const segments = candidate.split(separator)\n decimalSeparator = segments.length > 2 ? null : separator\n }\n\n const groupSeparator = decimalSeparator\n ? decimalSeparator === ','\n ? '.'\n : ','\n : hasComma\n ? ','\n : '.'\n const [integerPart, ...fractionParts] = decimalSeparator ? candidate.split(decimalSeparator) : [candidate]\n if (fractionParts.length > 1) return null\n if (!isValidGrouping(integerPart, groupSeparator)) return null\n if (fractionParts.length && fractionParts[0].includes(groupSeparator)) return null\n\n const normalized = `${integerPart.split(groupSeparator).join('')}${fractionParts.length ? `.${fractionParts[0]}` : ''}`\n if (!NORMALIZED_NUMBER.test(normalized)) return null\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { decimalToString, isDecimalInput, type DecimalInput } from './decimal'\n\ntype LocaleNumberSeparators = { group: string; decimal: string }\n\nconst DEFAULT_SEPARATORS: LocaleNumberSeparators = { group: ',', decimal: '.' }\nconst separatorCache = new Map<string, LocaleNumberSeparators>()\n\nconst UNICODE_MINUS_SIGNS = /[\u2212\u2012\u2013\u2014]/g\nconst GROUP_LIKE_CHARACTER = /[\\s'\u2019\u02BC]/\nconst GROUP_LIKE_SEPARATOR_IN_POSITION = /(\\d)[\\s'\u2019\u02BC](?=\\d{3}(?!\\d))/g\nconst NORMALIZED_NUMBER = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i\n\n/**\n * Group and decimal separators the given locale uses, derived from `Intl` rather than\n * assumed, so grouping characters such as the narrow no-break space (`fr-FR`) are covered.\n */\nexport function resolveLocaleNumberSeparators(locale?: string): LocaleNumberSeparators {\n const cacheKey = locale ?? ''\n const cached = separatorCache.get(cacheKey)\n if (cached) return cached\n let resolved = DEFAULT_SEPARATORS\n try {\n const parts = new Intl.NumberFormat(locale, {\n useGrouping: true,\n minimumFractionDigits: 1,\n }).formatToParts(12345.6)\n const group = parts.find((part) => part.type === 'group')?.value ?? DEFAULT_SEPARATORS.group\n const decimal = parts.find((part) => part.type === 'decimal')?.value ?? DEFAULT_SEPARATORS.decimal\n resolved = { group, decimal }\n } catch {\n resolved = DEFAULT_SEPARATORS\n }\n separatorCache.set(cacheKey, resolved)\n return resolved\n}\n\nfunction isValidGrouping(integerPart: string, separator: string): boolean {\n const digits = integerPart.replace(/^[+-]/, '')\n const segments = digits.split(separator)\n if (segments.length < 2) return true\n const [first, ...rest] = segments\n if (!/^\\d{1,3}$/.test(first)) return false\n return rest.every((segment) => /^\\d{3}$/.test(segment))\n}\n\n/**\n * Parses a user-typed number written in the conventions of `locale` \u2014 `110,70` under `pl-PL`,\n * `1 234,56` under `fr-FR`, `1,234.56` under `en-US`. Returns `null` when the input is not a\n * number, never a silent `0`, so callers can tell \"unparseable\" apart from \"zero\".\n *\n * Both `,` and `.` are accepted as the decimal separator whichever way the locale runs, because\n * users type the shape their keyboard offers. A SINGLE `,` or `.` is therefore always the decimal\n * point, in every locale: `1.500` is 1.5 under `de-DE` just as it is under `en-US`. Reading a lone\n * separator as grouping instead would turn `1.500` into 1500 with no visible cue \u2014 a silent 1000\u00D7\n * on a money field, and three- and four-decimal unit prices are ordinary here. Grouping is\n * recognized only where it is unambiguous: at least two separators (`1.234.567`), or a whitespace\n * or apostrophe separator standing in a valid group-of-three position (`1 234,56`, `1\u2019234.5`).\n * Whitespace and apostrophes anywhere else are not absorbed \u2014 `1 2` is rejected rather than read\n * as 12 \u2014 so a mistyped or pasted value surfaces as an error instead of a different number.\n *\n * Use it only on strings a user typed. Values arriving from an API or the database are already\n * numbers and MUST NOT go through it.\n */\nexport function parseLocaleNumber(input: string | null | undefined, locale?: string): number | null {\n const normalized = normalizeLocaleNumber(input, locale)\n if (normalized === null) return null\n const parsed = Number(normalized)\n return Number.isFinite(parsed) ? parsed : null\n}\n\n/**\n * Same parsing rules as `parseLocaleNumber`, but returns the exact decimal string\n * (`1 234,567891234567891` \u2192 `1234.567891234567891`) instead of a lossy JS `number`.\n * Use it for money and FX values a user typed.\n */\nexport function parseLocaleDecimal(input: string | null | undefined, locale?: string): string | null {\n const normalized = normalizeLocaleNumber(input, locale)\n if (normalized === null || !isDecimalInput(normalized)) return null\n return decimalToString(normalized)\n}\n\nfunction normalizeLocaleNumber(input: string | null | undefined, locale?: string): string | null {\n if (input == null) return null\n const trimmed = input.trim()\n if (!trimmed) return null\n\n const { group } = resolveLocaleNumberSeparators(locale)\n let candidate = trimmed.replace(UNICODE_MINUS_SIGNS, '-')\n if (group && group !== ',' && group !== '.' && !GROUP_LIKE_CHARACTER.test(group)) {\n candidate = candidate.split(group).join(' ')\n }\n candidate = candidate.replace(GROUP_LIKE_SEPARATOR_IN_POSITION, '$1')\n if (!candidate) return null\n\n const hasComma = candidate.includes(',')\n const hasDot = candidate.includes('.')\n let decimalSeparator: string | null = null\n if (hasComma && hasDot) {\n decimalSeparator = candidate.lastIndexOf(',') > candidate.lastIndexOf('.') ? ',' : '.'\n } else if (hasComma || hasDot) {\n const separator = hasComma ? ',' : '.'\n const segments = candidate.split(separator)\n decimalSeparator = segments.length > 2 ? null : separator\n }\n\n const groupSeparator = decimalSeparator\n ? decimalSeparator === ','\n ? '.'\n : ','\n : hasComma\n ? ','\n : '.'\n const [integerPart, ...fractionParts] = decimalSeparator ? candidate.split(decimalSeparator) : [candidate]\n if (fractionParts.length > 1) return null\n if (!isValidGrouping(integerPart, groupSeparator)) return null\n if (fractionParts.length && fractionParts[0].includes(groupSeparator)) return null\n\n const normalized = `${integerPart.split(groupSeparator).join('')}${fractionParts.length ? `.${fractionParts[0]}` : ''}`\n if (!NORMALIZED_NUMBER.test(normalized)) return null\n return normalized\n}\n\n/**\n * Renders a number as the text an input field should show under `locale` \u2014 `2,5` under\n * `pl-PL`, `2.5` under `en-US`. Unlike `String()`, which always emits a dot, the result uses\n * the locale's decimal separator, so a value redisplayed after blur or reload matches what the\n * user typed and what the rest of the UI shows. No grouping is applied, and the output always\n * round-trips through `parseLocaleNumber`.\n */\nexport function formatLocaleNumberInput(value: number, locale?: string): string {\n const serialized = String(value)\n const { decimal } = resolveLocaleNumberSeparators(locale)\n return decimal === '.' ? serialized : serialized.replace('.', decimal)\n}\n\n/**\n * Exact counterpart of `formatLocaleNumberInput` for decimal strings: renders every digit\n * (`1234.567891234567891234` \u2192 `1234,567891234567891234` under `pl-PL`) in plain notation,\n * without grouping. The output round-trips through `parseLocaleDecimal`.\n */\nexport function formatLocaleDecimalInput(value: DecimalInput, locale?: string): string {\n const serialized = decimalToString(value)\n const { decimal } = resolveLocaleNumberSeparators(locale)\n return decimal === '.' ? serialized : serialized.replace('.', decimal)\n}\n\nexport function parseNumberWithDefault(\n raw: string | null | undefined,\n fallback: number,\n options?: { min?: number; integer?: boolean },\n): number {\n if (raw == null) return fallback\n const trimmed = raw.trim()\n if (!trimmed) return fallback\n const value = options?.integer ? Number.parseInt(trimmed, 10) : Number(trimmed)\n if (!Number.isFinite(value)) return fallback\n const min = options?.min ?? -Infinity\n if (value < min) return fallback\n return value\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB,sBAAyC;AAInE,MAAM,qBAA6C,EAAE,OAAO,KAAK,SAAS,IAAI;AAC9E,MAAM,iBAAiB,oBAAI,IAAoC;AAE/D,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,mCAAmC;AACzC,MAAM,oBAAoB;AAMnB,SAAS,8BAA8B,QAAyC;AACrF,QAAM,WAAW,UAAU;AAC3B,QAAM,SAAS,eAAe,IAAI,QAAQ;AAC1C,MAAI,OAAQ,QAAO;AACnB,MAAI,WAAW;AACf,MAAI;AACF,UAAM,QAAQ,IAAI,KAAK,aAAa,QAAQ;AAAA,MAC1C,aAAa;AAAA,MACb,uBAAuB;AAAA,IACzB,CAAC,EAAE,cAAc,OAAO;AACxB,UAAM,QAAQ,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,OAAO,GAAG,SAAS,mBAAmB;AACvF,UAAM,UAAU,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,SAAS,GAAG,SAAS,mBAAmB;AAC3F,eAAW,EAAE,OAAO,QAAQ;AAAA,EAC9B,QAAQ;AACN,eAAW;AAAA,EACb;AACA,iBAAe,IAAI,UAAU,QAAQ;AACrC,SAAO;AACT;AAEA,SAAS,gBAAgB,aAAqB,WAA4B;AACxE,QAAM,SAAS,YAAY,QAAQ,SAAS,EAAE;AAC9C,QAAM,WAAW,OAAO,MAAM,SAAS;AACvC,MAAI,SAAS,SAAS,EAAG,QAAO;AAChC,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AACzB,MAAI,CAAC,YAAY,KAAK,KAAK,EAAG,QAAO;AACrC,SAAO,KAAK,MAAM,CAAC,YAAY,UAAU,KAAK,OAAO,CAAC;AACxD;AAoBO,SAAS,kBAAkB,OAAkC,QAAgC;AAClG,QAAM,aAAa,sBAAsB,O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AACrC,MAAI,CAAC,gBAAgB,aAAa,cAAc,EAAG,QAAO;AAC1D,MAAI,cAAc,UAAU,cAAc,CAAC,EAAE,SAAS,cAAc,EAAG,QAAO;AAE9E,QAAM,aAAa,GAAG,YAAY,MAAM,cAAc,EAAE,KAAK,EAAE,CAAC,GAAG,cAAc,SAAS,IAAI,cAAc,CAAC,CAAC,KAAK,EAAE;AACrH,MAAI,CAAC,kBAAkB,KAAK,UAAU,EAAG,QAAO;AAChD,SAAO;AACT;AASO,SAAS,wBAAwB,OAAe,QAAyB;AAC9E,QAAM,aAAa,OAAO,KAAK;AAC/B,QAAM,EAAE,QAAQ,IAAI,8BAA8B,MAAM;AACxD,SAAO,YAAY,MAAM,aAAa,WAAW,QAAQ,KAAK,OAAO;AACvE;AAOO,SAAS,yBAAyB,OAAqB,QAAyB;AACrF,QAAM,aAAa,gBAAgB,KAAK;AACxC,QAAM,EAAE,QAAQ,IAAI,8BAA8B,MAAM;AACxD,SAAO,YAAY,MAAM,aAAa,WAAW,QAAQ,KAAK,OAAO;AACvE;AAEO,SAAS,uBACd,KACA,UACA,SACQ;AACR,MAAI,OAAO,KAAM,QAAO;AACxB,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,SAAS,UAAU,OAAO,SAAS,SAAS,EAAE,IAAI,OAAO,OAAO;AAC9E,MAAI,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACpC,QAAM,MAAM,SAAS,OAAO;AAC5B,MAAI,QAAQ,IAAK,QAAO;AACxB,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/version.js
CHANGED
package/dist/lib/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/version.ts"],
|
|
4
|
-
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.10.1-develop.
|
|
4
|
+
"sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.10.1-develop.8291.1.6ec3aee41c';\nexport const appVersion = APP_VERSION;\n"],
|
|
5
5
|
"mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/payment_gateways/types.ts"],
|
|
4
|
-
"sourcesContent": ["import { DEFAULT_WEBHOOK_BODY_LIMIT_BYTES } from '../../lib/webhooks/body'\n\n// \u2500\u2500 Unified Payment Status \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type UnifiedPaymentStatus =\n | 'pending'\n | 'authorized'\n | 'captured'\n | 'partially_captured'\n | 'refunded'\n | 'partially_refunded'\n | 'cancelled'\n | 'failed'\n | 'expired'\n | 'unknown'\n\n// \u2500\u2500 GatewayAdapter Interface \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface GatewayAdapter {\n readonly providerKey: string\n\n /** Create a payment session / payment intent */\n createSession(input: CreateSessionInput): Promise<CreateSessionResult>\n\n /** Capture an authorized payment */\n capture(input: CaptureInput): Promise<CaptureResult>\n\n /** Refund a captured payment (full or partial) */\n refund(input: RefundInput): Promise<RefundResult>\n\n /** Cancel / void an authorized payment before capture */\n cancel(input: CancelInput): Promise<CancelResult>\n\n /** Get current payment status from provider */\n getStatus(input: GetStatusInput): Promise<GatewayPaymentStatus>\n\n /** Verify and parse an inbound webhook event */\n verifyWebhook(input: VerifyWebhookInput): Promise<WebhookEvent>\n\n /**\n * Map provider status to unified status. The core webhook processor also passes the verified\n * event's type and the verified event itself, so an adapter can tell apart events that share a\n * type or a provider status (for example a partial and a full refund). Both extra arguments are\n * optional. Map an event to `refunded` / `partially_refunded` only when the provider confirms\n * captured funds were refunded: webhook sync treats such a status as proof of capture.\n */\n mapStatus(providerStatus: string, eventType?: string, event?: WebhookEvent): UnifiedPaymentStatus\n}\n\nexport type PaymentGatewayDescriptorFieldType =\n | 'text'\n | 'number'\n | 'select'\n | 'multiselect'\n | 'boolean'\n | 'textarea'\n | 'secret'\n | 'url'\n\nexport interface PaymentGatewayDescriptorField {\n key: string\n label: string\n type: PaymentGatewayDescriptorFieldType\n description?: string\n required?: boolean\n options?: Array<{ value: string; label: string }>\n}\n\nexport type PaymentGatewayRendererType = 'embedded' | 'redirect'\n\nexport interface PaymentGatewayRendererDescriptor {\n key: string\n label: string\n type: PaymentGatewayRendererType\n description?: string\n supportedPaymentTypes?: '*' | string[]\n settingsFields?: PaymentGatewayDescriptorField[]\n}\n\nexport interface PaymentGatewayPresentationRequest {\n mode?: 'auto' | PaymentGatewayRendererType\n rendererKey?: string\n rendererSettings?: Record<string, unknown>\n}\n\n/**\n * Payer details a provider needs to create a payment session. Each value maps to\n * canonical checkout customer fields: `email` \u2192 `email`, `name` \u2192 `firstName` + `lastName`.\n */\nexport type PaymentGatewayPayerField = 'email' | 'name'\n\nexport interface PaymentGatewayDescriptor {\n providerKey: string\n label: string\n /**\n * Payer details the provider cannot create a session without. Hosts that collect\n * payer data (for example checkout links) must collect each one as a required field.\n * Omit when the provider needs no payer data.\n */\n requiresPayerFields?: PaymentGatewayPayerField[]\n sessionConfig?: {\n fields?: PaymentGatewayDescriptorField[]\n supportedCurrencies?: '*' | string[]\n supportedPaymentTypes?: Array<{ value: string; label: string }>\n defaultRendererKey?: string\n renderers?: PaymentGatewayRendererDescriptor[]\n /**\n * @deprecated Use `renderers` and `defaultRendererKey`.\n */\n presentation?: 'embedded' | 'redirect' | 'either'\n /**\n * @deprecated Use `renderers`.\n */\n embeddedRenderers?: string[]\n }\n}\n\nexport interface EmbeddedPaymentGatewayClientSession {\n type: 'embedded'\n rendererKey: string\n payload?: Record<string, unknown>\n settings?: Record<string, unknown>\n}\n\nexport interface RedirectPaymentGatewayClientSession {\n type: 'redirect'\n redirectUrl: string\n target?: 'self' | 'top'\n}\n\nexport type PaymentGatewayClientSession =\n | EmbeddedPaymentGatewayClientSession\n | RedirectPaymentGatewayClientSession\n\n// \u2500\u2500 Order Amount Reconciliation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface PaymentGatewayScope {\n organizationId: string\n tenantId: string\n}\n\nexport interface PaymentOrderTotal {\n orderId: string\n currencyCode: string\n amountDue: number\n}\n\n/**\n * Contract a module that owns orders implements so `payment_gateways` can\n * reconcile a caller-supplied session amount against the authoritative amount\n * due, without depending on that module. Implementations MUST scope the lookup\n * by tenant and organization and MUST return `null` for anything outside the\n * caller's scope, so an out-of-scope order is indistinguishable from a missing\n * one. The `sales` module registers the default implementation under the\n * `paymentOrderTotalResolver` DI name.\n */\nexport interface PaymentOrderTotalResolver {\n resolveOrderTotal(orderId: string, scope: PaymentGatewayScope): Promise<PaymentOrderTotal | null>\n}\n\n// \u2500\u2500 Input / Output Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface CreateSessionInput {\n orderId?: string\n paymentId: string\n /** Stable operation key for provider-native session creation idempotency. */\n idempotencyKey?: string\n tenantId: string\n organizationId: string\n amount: number\n currencyCode: string\n captureMethod?: 'automatic' | 'manual'\n paymentTypes?: string[]\n description?: string\n successUrl?: string\n cancelUrl?: string\n metadata?: Record<string, unknown>\n credentials: Record<string, unknown>\n lineItems?: SessionLineItem[]\n presentation?: PaymentGatewayPresentationRequest\n}\n\nexport interface SessionLineItem {\n name: string\n quantity: number\n unitAmount: number\n currencyCode: string\n}\n\nexport interface CreateSessionResult {\n sessionId: string\n clientSecret?: string\n redirectUrl?: string\n status: UnifiedPaymentStatus\n providerData?: Record<string, unknown>\n clientSession?: PaymentGatewayClientSession\n}\n\nexport interface CaptureInput {\n sessionId: string\n amount?: number\n credentials: Record<string, unknown>\n metadata?: Record<string, unknown>\n idempotencyKey?: string\n}\n\nexport interface CaptureResult {\n status: UnifiedPaymentStatus\n capturedAmount: number\n providerData?: Record<string, unknown>\n}\n\nexport interface RefundInput {\n sessionId: string\n amount?: number\n reason?: string\n credentials: Record<string, unknown>\n metadata?: Record<string, unknown>\n idempotencyKey?: string\n}\n\nexport interface RefundResult {\n refundId: string\n status: UnifiedPaymentStatus\n refundedAmount: number\n providerData?: Record<string, unknown>\n}\n\nexport interface CancelInput {\n sessionId: string\n reason?: string\n credentials: Record<string, unknown>\n idempotencyKey?: string\n}\n\nexport interface CancelResult {\n status: UnifiedPaymentStatus\n providerData?: Record<string, unknown>\n}\n\nexport interface GetStatusInput {\n sessionId: string\n credentials: Record<string, unknown>\n}\n\nexport interface GatewayPaymentStatus {\n status: UnifiedPaymentStatus\n amount: number\n amountReceived: number\n currencyCode: string\n providerData?: Record<string, unknown>\n}\n\nexport interface VerifyWebhookInput {\n rawBody: string | Buffer\n headers: Record<string, string | string[] | undefined>\n credentials: Record<string, unknown>\n /** Platform-resolved payment the webhook is expected to concern, when a locator found one. */\n candidate?: WebhookCandidateSnapshot\n}\n\n/** Raw request material handed to webhook locator hints. */\nexport interface WebhookLocatorContext {\n rawBody: string | Buffer\n headers: Record<string, string | string[] | undefined>\n}\n\nexport interface WebhookCandidateSnapshot {\n transactionId: string\n paymentId: string\n providerSessionId: string | null\n amount: string\n currencyCode: string\n}\n\nexport type WebhookResponseOutcome =\n | 'accepted'\n | 'no_candidate'\n | 'verification_failed'\n | 'verification_unavailable'\n | 'processing_failed'\n | 'payload_too_large'\n | 'rate_limited'\n\nexport interface WebhookHttpResponse {\n status: number\n body: string | Record<string, unknown>\n contentType?: string\n}\n\n/** Thrown by a webhook handler when verification cannot be performed (for example a provider outage). */\nexport class WebhookVerificationUnavailableError extends Error {\n constructor(message = 'Webhook verification is unavailable') {\n super(message)\n this.name = 'WebhookVerificationUnavailableError'\n }\n}\n\nexport interface WebhookEvent {\n eventType: string\n eventId: string\n data: Record<string, unknown>\n idempotencyKey: string\n timestamp: Date\n /** Provider API version the payload was rendered with, when the provider reports one */\n apiVersion?: string\n}\n\n// \u2500\u2500 Webhook Handler \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface WebhookHandlerRegistration {\n handler: (input: VerifyWebhookInput) => Promise<WebhookEvent>\n queue?: string\n readSessionIdHint?: (payload: Record<string, unknown> | null, context?: WebhookLocatorContext) => string | null\n readPaymentIdHint?: (payload: Record<string, unknown> | null, context?: WebhookLocatorContext) => string | null\n maxBodyBytes?: number\n rawBody?: WebhookRawBodyMode\n formatResponse?: (outcome: WebhookResponseOutcome) => WebhookHttpResponse\n}\n\nexport type WebhookRawBodyMode = 'text' | 'bytes'\n\n// \u2500\u2500 Adapter Registry Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface RegisterAdapterOptions {\n version?: string\n}\n\n// \u2500\u2500 Registries \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst ADAPTER_REGISTRY_KEY = '__openMercatoPaymentGatewayAdapters__'\nconst WEBHOOK_REGISTRY_KEY = '__openMercatoPaymentGatewayWebhookHandlers__'\nconst DESCRIPTOR_REGISTRY_KEY = '__openMercatoPaymentGatewayDescriptors__'\n\nfunction getAdapterRegistry(): Map<string, GatewayAdapter> {\n const globalState = globalThis as typeof globalThis & {\n [ADAPTER_REGISTRY_KEY]?: Map<string, GatewayAdapter>\n }\n if (!globalState[ADAPTER_REGISTRY_KEY]) {\n globalState[ADAPTER_REGISTRY_KEY] = new Map<string, GatewayAdapter>()\n }\n return globalState[ADAPTER_REGISTRY_KEY]\n}\n\nfunction getWebhookHandlerRegistry(): Map<string, WebhookHandlerRegistration> {\n const globalState = globalThis as typeof globalThis & {\n [WEBHOOK_REGISTRY_KEY]?: Map<string, WebhookHandlerRegistration>\n }\n if (!globalState[WEBHOOK_REGISTRY_KEY]) {\n globalState[WEBHOOK_REGISTRY_KEY] = new Map<string, WebhookHandlerRegistration>()\n }\n return globalState[WEBHOOK_REGISTRY_KEY]\n}\n\nfunction getDescriptorRegistry(): Map<string, PaymentGatewayDescriptor> {\n const globalState = globalThis as typeof globalThis & {\n [DESCRIPTOR_REGISTRY_KEY]?: Map<string, PaymentGatewayDescriptor>\n }\n if (!globalState[DESCRIPTOR_REGISTRY_KEY]) {\n globalState[DESCRIPTOR_REGISTRY_KEY] = new Map<string, PaymentGatewayDescriptor>()\n }\n return globalState[DESCRIPTOR_REGISTRY_KEY]\n}\n\nfunction adapterKey(providerKey: string, version?: string): string {\n return version ? `${providerKey}:${version}` : providerKey\n}\n\nexport function registerGatewayAdapter(adapter: GatewayAdapter, options?: RegisterAdapterOptions): () => void {\n const adapterRegistry = getAdapterRegistry()\n const key = adapterKey(adapter.providerKey, options?.version)\n adapterRegistry.set(key, adapter)\n if (options?.version) {\n // Also register as default if no default exists\n if (!adapterRegistry.has(adapter.providerKey)) {\n adapterRegistry.set(adapter.providerKey, adapter)\n }\n }\n return () => {\n adapterRegistry.delete(key)\n }\n}\n\nexport function getGatewayAdapter(providerKey: string, version?: string): GatewayAdapter | undefined {\n const adapterRegistry = getAdapterRegistry()\n if (version) {\n return adapterRegistry.get(adapterKey(providerKey, version)) ?? adapterRegistry.get(providerKey)\n }\n return adapterRegistry.get(providerKey)\n}\n\nexport function listGatewayAdapters(): GatewayAdapter[] {\n const adapterRegistry = getAdapterRegistry()\n const seen = new Set<string>()\n const result: GatewayAdapter[] = []\n for (const [key, adapter] of adapterRegistry) {\n if (!key.includes(':') && !seen.has(adapter.providerKey)) {\n seen.add(adapter.providerKey)\n result.push(adapter)\n }\n }\n return result\n}\n\nexport function clearGatewayAdapters(): void {\n getAdapterRegistry().clear()\n}\n\nexport function registerWebhookHandler(\n providerKey: string,\n handler: (input: VerifyWebhookInput) => Promise<WebhookEvent>,\n options?: Omit<WebhookHandlerRegistration, 'handler'>,\n): () => void {\n if (options?.rawBody !== undefined && options.rawBody !== 'text' && options.rawBody !== 'bytes') {\n throw new Error(\"[internal] Payment gateway webhook rawBody must be 'text' or 'bytes'\")\n }\n if (\n options?.maxBodyBytes !== undefined\n && (!Number.isSafeInteger(options.maxBodyBytes)\n || options.maxBodyBytes <= 0\n || options.maxBodyBytes > DEFAULT_WEBHOOK_BODY_LIMIT_BYTES)\n ) {\n throw new Error(\n `[internal] Payment gateway webhook maxBodyBytes must be a positive safe integer no greater than ${DEFAULT_WEBHOOK_BODY_LIMIT_BYTES}`,\n )\n }\n const webhookHandlerRegistry = getWebhookHandlerRegistry()\n webhookHandlerRegistry.set(providerKey, {\n handler,\n queue: options?.queue,\n readSessionIdHint: options?.readSessionIdHint,\n readPaymentIdHint: options?.readPaymentIdHint,\n maxBodyBytes: options?.maxBodyBytes,\n rawBody: options?.rawBody,\n formatResponse: options?.formatResponse,\n })\n return () => {\n webhookHandlerRegistry.delete(providerKey)\n }\n}\n\nexport function getWebhookHandler(providerKey: string): WebhookHandlerRegistration | undefined {\n return getWebhookHandlerRegistry().get(providerKey)\n}\n\nexport function clearWebhookHandlers(): void {\n getWebhookHandlerRegistry().clear()\n}\n\nexport function registerPaymentGatewayDescriptor(descriptor: PaymentGatewayDescriptor): () => void {\n const descriptorRegistry = getDescriptorRegistry()\n descriptorRegistry.set(descriptor.providerKey, descriptor)\n return () => {\n descriptorRegistry.delete(descriptor.providerKey)\n }\n}\n\nexport function getPaymentGatewayDescriptor(providerKey: string): PaymentGatewayDescriptor | undefined {\n return getDescriptorRegistry().get(providerKey)\n}\n\nexport function listPaymentGatewayDescriptors(): PaymentGatewayDescriptor[] {\n return Array.from(getDescriptorRegistry().values()).sort((left, right) => left.label.localeCompare(right.label))\n}\n\nexport function clearPaymentGatewayDescriptors(): void {\n getDescriptorRegistry().clear()\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,wCAAwC;
|
|
4
|
+
"sourcesContent": ["import { DEFAULT_WEBHOOK_BODY_LIMIT_BYTES } from '../../lib/webhooks/body'\n\n// \u2500\u2500 Unified Payment Status \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type UnifiedPaymentStatus =\n | 'pending'\n | 'authorized'\n | 'captured'\n | 'partially_captured'\n | 'refunded'\n | 'partially_refunded'\n | 'cancelled'\n | 'failed'\n | 'expired'\n | 'unknown'\n\n// \u2500\u2500 GatewayAdapter Interface \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface GatewayAdapter {\n readonly providerKey: string\n\n /** Create a payment session / payment intent */\n createSession(input: CreateSessionInput): Promise<CreateSessionResult>\n\n /** Capture an authorized payment */\n capture(input: CaptureInput): Promise<CaptureResult>\n\n /** Refund a captured payment (full or partial) */\n refund(input: RefundInput): Promise<RefundResult>\n\n /** Cancel / void an authorized payment before capture */\n cancel(input: CancelInput): Promise<CancelResult>\n\n /** Get current payment status from provider */\n getStatus(input: GetStatusInput): Promise<GatewayPaymentStatus>\n\n /** Verify and parse an inbound webhook event */\n verifyWebhook(input: VerifyWebhookInput): Promise<WebhookEvent>\n\n /**\n * Map provider status to unified status. The core webhook processor also passes the verified\n * event's type and the verified event itself, so an adapter can tell apart events that share a\n * type or a provider status (for example a partial and a full refund). Both extra arguments are\n * optional. Map an event to `refunded` / `partially_refunded` only when the provider confirms\n * captured funds were refunded: webhook sync treats such a status as proof of capture.\n */\n mapStatus(providerStatus: string, eventType?: string, event?: WebhookEvent): UnifiedPaymentStatus\n}\n\nexport type PaymentGatewayDescriptorFieldType =\n | 'text'\n | 'number'\n | 'select'\n | 'multiselect'\n | 'boolean'\n | 'textarea'\n | 'secret'\n | 'url'\n\nexport interface PaymentGatewayDescriptorField {\n key: string\n label: string\n type: PaymentGatewayDescriptorFieldType\n description?: string\n required?: boolean\n options?: Array<{ value: string; label: string }>\n}\n\nexport type PaymentGatewayRendererType = 'embedded' | 'redirect'\n\nexport interface PaymentGatewayRendererDescriptor {\n key: string\n label: string\n type: PaymentGatewayRendererType\n description?: string\n supportedPaymentTypes?: '*' | string[]\n settingsFields?: PaymentGatewayDescriptorField[]\n}\n\nexport interface PaymentGatewayPresentationRequest {\n mode?: 'auto' | PaymentGatewayRendererType\n rendererKey?: string\n rendererSettings?: Record<string, unknown>\n}\n\n/**\n * Payer details a provider needs to create a payment session. Each value maps to\n * canonical checkout customer fields: `email` \u2192 `email`, `name` \u2192 `firstName` + `lastName`.\n */\nexport type PaymentGatewayPayerField = 'email' | 'name'\n\nexport interface PaymentGatewayDescriptor {\n providerKey: string\n label: string\n /**\n * Payer details the provider cannot create a session without. Hosts that collect\n * payer data (for example checkout links) must collect each one as a required field.\n * Omit when the provider needs no payer data.\n */\n requiresPayerFields?: PaymentGatewayPayerField[]\n sessionConfig?: {\n fields?: PaymentGatewayDescriptorField[]\n supportedCurrencies?: '*' | string[]\n supportedPaymentTypes?: Array<{ value: string; label: string }>\n defaultRendererKey?: string\n renderers?: PaymentGatewayRendererDescriptor[]\n /**\n * @deprecated Use `renderers` and `defaultRendererKey`.\n */\n presentation?: 'embedded' | 'redirect' | 'either'\n /**\n * @deprecated Use `renderers`.\n */\n embeddedRenderers?: string[]\n }\n}\n\nexport interface EmbeddedPaymentGatewayClientSession {\n type: 'embedded'\n rendererKey: string\n payload?: Record<string, unknown>\n settings?: Record<string, unknown>\n}\n\nexport interface RedirectPaymentGatewayClientSession {\n type: 'redirect'\n redirectUrl: string\n target?: 'self' | 'top'\n}\n\nexport type PaymentGatewayClientSession =\n | EmbeddedPaymentGatewayClientSession\n | RedirectPaymentGatewayClientSession\n\n// \u2500\u2500 Order Amount Reconciliation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface PaymentGatewayScope {\n organizationId: string\n tenantId: string\n}\n\nexport interface PaymentOrderTotal {\n orderId: string\n currencyCode: string\n /** Float copy of `amountDueExact`; prefer the exact field. */\n amountDue: number\n amountDueExact?: string\n}\n\n/**\n * Contract a module that owns orders implements so `payment_gateways` can\n * reconcile a caller-supplied session amount against the authoritative amount\n * due, without depending on that module. Implementations MUST scope the lookup\n * by tenant and organization and MUST return `null` for anything outside the\n * caller's scope, so an out-of-scope order is indistinguishable from a missing\n * one. The `sales` module registers the default implementation under the\n * `paymentOrderTotalResolver` DI name.\n */\nexport interface PaymentOrderTotalResolver {\n resolveOrderTotal(orderId: string, scope: PaymentGatewayScope): Promise<PaymentOrderTotal | null>\n}\n\n// \u2500\u2500 Input / Output Types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface CreateSessionInput {\n orderId?: string\n paymentId: string\n /** Stable operation key for provider-native session creation idempotency. */\n idempotencyKey?: string\n tenantId: string\n organizationId: string\n /** Float copy of `amountExact`; prefer the exact field. */\n amount: number\n amountExact?: string\n currencyCode: string\n captureMethod?: 'automatic' | 'manual'\n paymentTypes?: string[]\n description?: string\n successUrl?: string\n cancelUrl?: string\n metadata?: Record<string, unknown>\n credentials: Record<string, unknown>\n lineItems?: SessionLineItem[]\n presentation?: PaymentGatewayPresentationRequest\n}\n\nexport interface SessionLineItem {\n name: string\n quantity: number\n /** Float copy of `unitAmountExact`; prefer the exact field. */\n unitAmount: number\n unitAmountExact?: string\n currencyCode: string\n}\n\nexport interface CreateSessionResult {\n sessionId: string\n clientSecret?: string\n redirectUrl?: string\n status: UnifiedPaymentStatus\n providerData?: Record<string, unknown>\n clientSession?: PaymentGatewayClientSession\n}\n\nexport interface CaptureInput {\n sessionId: string\n /** Float copy of `amountExact`; prefer the exact field. */\n amount?: number\n amountExact?: string\n credentials: Record<string, unknown>\n metadata?: Record<string, unknown>\n idempotencyKey?: string\n}\n\nexport interface CaptureResult {\n status: UnifiedPaymentStatus\n /** Float copy of `capturedAmountExact`; prefer the exact field. */\n capturedAmount: number\n capturedAmountExact?: string\n providerData?: Record<string, unknown>\n}\n\nexport interface RefundInput {\n sessionId: string\n /** Float copy of `amountExact`; prefer the exact field. */\n amount?: number\n amountExact?: string\n reason?: string\n credentials: Record<string, unknown>\n metadata?: Record<string, unknown>\n idempotencyKey?: string\n}\n\nexport interface RefundResult {\n refundId: string\n status: UnifiedPaymentStatus\n /** Float copy of `refundedAmountExact`; prefer the exact field. */\n refundedAmount: number\n refundedAmountExact?: string\n providerData?: Record<string, unknown>\n}\n\nexport interface CancelInput {\n sessionId: string\n reason?: string\n credentials: Record<string, unknown>\n idempotencyKey?: string\n}\n\nexport interface CancelResult {\n status: UnifiedPaymentStatus\n providerData?: Record<string, unknown>\n}\n\nexport interface GetStatusInput {\n sessionId: string\n credentials: Record<string, unknown>\n}\n\nexport interface GatewayPaymentStatus {\n status: UnifiedPaymentStatus\n /** Float copy of `amountExact`; prefer the exact field. */\n amount: number\n amountExact?: string\n /** Float copy of `amountReceivedExact`; prefer the exact field. */\n amountReceived: number\n amountReceivedExact?: string\n currencyCode: string\n providerData?: Record<string, unknown>\n}\n\nexport interface VerifyWebhookInput {\n rawBody: string | Buffer\n headers: Record<string, string | string[] | undefined>\n credentials: Record<string, unknown>\n /** Platform-resolved payment the webhook is expected to concern, when a locator found one. */\n candidate?: WebhookCandidateSnapshot\n}\n\n/** Raw request material handed to webhook locator hints. */\nexport interface WebhookLocatorContext {\n rawBody: string | Buffer\n headers: Record<string, string | string[] | undefined>\n}\n\nexport interface WebhookCandidateSnapshot {\n transactionId: string\n paymentId: string\n providerSessionId: string | null\n amount: string\n currencyCode: string\n}\n\nexport type WebhookResponseOutcome =\n | 'accepted'\n | 'no_candidate'\n | 'verification_failed'\n | 'verification_unavailable'\n | 'processing_failed'\n | 'payload_too_large'\n | 'rate_limited'\n\nexport interface WebhookHttpResponse {\n status: number\n body: string | Record<string, unknown>\n contentType?: string\n}\n\n/** Thrown by a webhook handler when verification cannot be performed (for example a provider outage). */\nexport class WebhookVerificationUnavailableError extends Error {\n constructor(message = 'Webhook verification is unavailable') {\n super(message)\n this.name = 'WebhookVerificationUnavailableError'\n }\n}\n\nexport interface WebhookEvent {\n eventType: string\n eventId: string\n data: Record<string, unknown>\n idempotencyKey: string\n timestamp: Date\n /** Provider API version the payload was rendered with, when the provider reports one */\n apiVersion?: string\n}\n\n// \u2500\u2500 Webhook Handler \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface WebhookHandlerRegistration {\n handler: (input: VerifyWebhookInput) => Promise<WebhookEvent>\n queue?: string\n readSessionIdHint?: (payload: Record<string, unknown> | null, context?: WebhookLocatorContext) => string | null\n readPaymentIdHint?: (payload: Record<string, unknown> | null, context?: WebhookLocatorContext) => string | null\n maxBodyBytes?: number\n rawBody?: WebhookRawBodyMode\n formatResponse?: (outcome: WebhookResponseOutcome) => WebhookHttpResponse\n}\n\nexport type WebhookRawBodyMode = 'text' | 'bytes'\n\n// \u2500\u2500 Adapter Registry Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport interface RegisterAdapterOptions {\n version?: string\n}\n\n// \u2500\u2500 Registries \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst ADAPTER_REGISTRY_KEY = '__openMercatoPaymentGatewayAdapters__'\nconst WEBHOOK_REGISTRY_KEY = '__openMercatoPaymentGatewayWebhookHandlers__'\nconst DESCRIPTOR_REGISTRY_KEY = '__openMercatoPaymentGatewayDescriptors__'\n\nfunction getAdapterRegistry(): Map<string, GatewayAdapter> {\n const globalState = globalThis as typeof globalThis & {\n [ADAPTER_REGISTRY_KEY]?: Map<string, GatewayAdapter>\n }\n if (!globalState[ADAPTER_REGISTRY_KEY]) {\n globalState[ADAPTER_REGISTRY_KEY] = new Map<string, GatewayAdapter>()\n }\n return globalState[ADAPTER_REGISTRY_KEY]\n}\n\nfunction getWebhookHandlerRegistry(): Map<string, WebhookHandlerRegistration> {\n const globalState = globalThis as typeof globalThis & {\n [WEBHOOK_REGISTRY_KEY]?: Map<string, WebhookHandlerRegistration>\n }\n if (!globalState[WEBHOOK_REGISTRY_KEY]) {\n globalState[WEBHOOK_REGISTRY_KEY] = new Map<string, WebhookHandlerRegistration>()\n }\n return globalState[WEBHOOK_REGISTRY_KEY]\n}\n\nfunction getDescriptorRegistry(): Map<string, PaymentGatewayDescriptor> {\n const globalState = globalThis as typeof globalThis & {\n [DESCRIPTOR_REGISTRY_KEY]?: Map<string, PaymentGatewayDescriptor>\n }\n if (!globalState[DESCRIPTOR_REGISTRY_KEY]) {\n globalState[DESCRIPTOR_REGISTRY_KEY] = new Map<string, PaymentGatewayDescriptor>()\n }\n return globalState[DESCRIPTOR_REGISTRY_KEY]\n}\n\nfunction adapterKey(providerKey: string, version?: string): string {\n return version ? `${providerKey}:${version}` : providerKey\n}\n\nexport function registerGatewayAdapter(adapter: GatewayAdapter, options?: RegisterAdapterOptions): () => void {\n const adapterRegistry = getAdapterRegistry()\n const key = adapterKey(adapter.providerKey, options?.version)\n adapterRegistry.set(key, adapter)\n if (options?.version) {\n // Also register as default if no default exists\n if (!adapterRegistry.has(adapter.providerKey)) {\n adapterRegistry.set(adapter.providerKey, adapter)\n }\n }\n return () => {\n adapterRegistry.delete(key)\n }\n}\n\nexport function getGatewayAdapter(providerKey: string, version?: string): GatewayAdapter | undefined {\n const adapterRegistry = getAdapterRegistry()\n if (version) {\n return adapterRegistry.get(adapterKey(providerKey, version)) ?? adapterRegistry.get(providerKey)\n }\n return adapterRegistry.get(providerKey)\n}\n\nexport function listGatewayAdapters(): GatewayAdapter[] {\n const adapterRegistry = getAdapterRegistry()\n const seen = new Set<string>()\n const result: GatewayAdapter[] = []\n for (const [key, adapter] of adapterRegistry) {\n if (!key.includes(':') && !seen.has(adapter.providerKey)) {\n seen.add(adapter.providerKey)\n result.push(adapter)\n }\n }\n return result\n}\n\nexport function clearGatewayAdapters(): void {\n getAdapterRegistry().clear()\n}\n\nexport function registerWebhookHandler(\n providerKey: string,\n handler: (input: VerifyWebhookInput) => Promise<WebhookEvent>,\n options?: Omit<WebhookHandlerRegistration, 'handler'>,\n): () => void {\n if (options?.rawBody !== undefined && options.rawBody !== 'text' && options.rawBody !== 'bytes') {\n throw new Error(\"[internal] Payment gateway webhook rawBody must be 'text' or 'bytes'\")\n }\n if (\n options?.maxBodyBytes !== undefined\n && (!Number.isSafeInteger(options.maxBodyBytes)\n || options.maxBodyBytes <= 0\n || options.maxBodyBytes > DEFAULT_WEBHOOK_BODY_LIMIT_BYTES)\n ) {\n throw new Error(\n `[internal] Payment gateway webhook maxBodyBytes must be a positive safe integer no greater than ${DEFAULT_WEBHOOK_BODY_LIMIT_BYTES}`,\n )\n }\n const webhookHandlerRegistry = getWebhookHandlerRegistry()\n webhookHandlerRegistry.set(providerKey, {\n handler,\n queue: options?.queue,\n readSessionIdHint: options?.readSessionIdHint,\n readPaymentIdHint: options?.readPaymentIdHint,\n maxBodyBytes: options?.maxBodyBytes,\n rawBody: options?.rawBody,\n formatResponse: options?.formatResponse,\n })\n return () => {\n webhookHandlerRegistry.delete(providerKey)\n }\n}\n\nexport function getWebhookHandler(providerKey: string): WebhookHandlerRegistration | undefined {\n return getWebhookHandlerRegistry().get(providerKey)\n}\n\nexport function clearWebhookHandlers(): void {\n getWebhookHandlerRegistry().clear()\n}\n\nexport function registerPaymentGatewayDescriptor(descriptor: PaymentGatewayDescriptor): () => void {\n const descriptorRegistry = getDescriptorRegistry()\n descriptorRegistry.set(descriptor.providerKey, descriptor)\n return () => {\n descriptorRegistry.delete(descriptor.providerKey)\n }\n}\n\nexport function getPaymentGatewayDescriptor(providerKey: string): PaymentGatewayDescriptor | undefined {\n return getDescriptorRegistry().get(providerKey)\n}\n\nexport function listPaymentGatewayDescriptors(): PaymentGatewayDescriptor[] {\n return Array.from(getDescriptorRegistry().values()).sort((left, right) => left.label.localeCompare(right.label))\n}\n\nexport function clearPaymentGatewayDescriptors(): void {\n getDescriptorRegistry().clear()\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wCAAwC;AAqT1C,MAAM,4CAA4C,MAAM;AAAA,EAC7D,YAAY,UAAU,uCAAuC;AAC3D,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAkCA,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B;AAEhC,SAAS,qBAAkD;AACzD,QAAM,cAAc;AAGpB,MAAI,CAAC,YAAY,oBAAoB,GAAG;AACtC,gBAAY,oBAAoB,IAAI,oBAAI,IAA4B;AAAA,EACtE;AACA,SAAO,YAAY,oBAAoB;AACzC;AAEA,SAAS,4BAAqE;AAC5E,QAAM,cAAc;AAGpB,MAAI,CAAC,YAAY,oBAAoB,GAAG;AACtC,gBAAY,oBAAoB,IAAI,oBAAI,IAAwC;AAAA,EAClF;AACA,SAAO,YAAY,oBAAoB;AACzC;AAEA,SAAS,wBAA+D;AACtE,QAAM,cAAc;AAGpB,MAAI,CAAC,YAAY,uBAAuB,GAAG;AACzC,gBAAY,uBAAuB,IAAI,oBAAI,IAAsC;AAAA,EACnF;AACA,SAAO,YAAY,uBAAuB;AAC5C;AAEA,SAAS,WAAW,aAAqB,SAA0B;AACjE,SAAO,UAAU,GAAG,WAAW,IAAI,OAAO,KAAK;AACjD;AAEO,SAAS,uBAAuB,SAAyB,SAA8C;AAC5G,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,MAAM,WAAW,QAAQ,aAAa,SAAS,OAAO;AAC5D,kBAAgB,IAAI,KAAK,OAAO;AAChC,MAAI,SAAS,SAAS;AAEpB,QAAI,CAAC,gBAAgB,IAAI,QAAQ,WAAW,GAAG;AAC7C,sBAAgB,IAAI,QAAQ,aAAa,OAAO;AAAA,IAClD;AAAA,EACF;AACA,SA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AAuB,OAAO,WAAW;AAAA,EAC3C;AACF;AAEO,SAAS,kBAAkB,aAA6D;AAC7F,SAAO,0BAA0B,EAAE,IAAI,WAAW;AACpD;AAEO,SAAS,uBAA6B;AAC3C,4BAA0B,EAAE,MAAM;AACpC;AAEO,SAAS,iCAAiC,YAAkD;AACjG,QAAM,qBAAqB,sBAAsB;AACjD,qBAAmB,IAAI,WAAW,aAAa,UAAU;AACzD,SAAO,MAAM;AACX,uBAAmB,OAAO,WAAW,WAAW;AAAA,EAClD;AACF;AAEO,SAAS,4BAA4B,aAA2D;AACrG,SAAO,sBAAsB,EAAE,IAAI,WAAW;AAChD;AAEO,SAAS,gCAA4D;AAC1E,SAAO,MAAM,KAAK,sBAAsB,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,MAAM,cAAc,MAAM,KAAK,CAAC;AACjH;AAEO,SAAS,iCAAuC;AACrD,wBAAsB,EAAE,MAAM;AAChC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/shared",
|
|
3
|
-
"version": "0.10.1-develop.
|
|
3
|
+
"version": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -130,9 +130,11 @@
|
|
|
130
130
|
"@mikro-orm/core": "^7.1.14",
|
|
131
131
|
"@mikro-orm/decorators": "^7.1.14",
|
|
132
132
|
"@mikro-orm/postgresql": "^7.1.14",
|
|
133
|
-
"@open-mercato/cache": "0.10.1-develop.
|
|
133
|
+
"@open-mercato/cache": "0.10.1-develop.8291.1.6ec3aee41c",
|
|
134
|
+
"@types/big.js": "^7.0.0",
|
|
134
135
|
"@types/html-to-text": "^9.0.4",
|
|
135
136
|
"@types/sanitize-html": "^2.16.1",
|
|
137
|
+
"big.js": "^7.0.1",
|
|
136
138
|
"dotenv": "^17.4.2",
|
|
137
139
|
"gpt-tokenizer": "^3.4.0",
|
|
138
140
|
"html-to-text": "^10.0.0",
|