@blob-solutions/vcr-am-sdk 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/LICENSE +15 -0
- package/README.md +226 -21
- package/lib/index.cjs +471 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +453 -30
- package/lib/index.d.ts +453 -30
- package/lib/index.global.js +64 -12
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +446 -1
- package/lib/index.js.map +1 -1
- package/package.json +60 -26
package/lib/index.d.cts
CHANGED
|
@@ -1,8 +1,298 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type RequestOptions = {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
/** Override per-request timeout in ms. `null` disables the timeout. */
|
|
6
|
+
timeoutMs?: number | null;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
declare const registerSaleResponseSchema: z.ZodObject<{
|
|
10
|
+
urlId: z.ZodString;
|
|
11
|
+
saleId: z.ZodNumber;
|
|
12
|
+
crn: z.ZodString;
|
|
13
|
+
srcReceiptId: z.ZodNumber;
|
|
14
|
+
fiscal: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
declare const registerSaleRefundResponseSchema: z.ZodObject<{
|
|
17
|
+
urlId: z.ZodString;
|
|
18
|
+
saleRefundId: z.ZodNumber;
|
|
19
|
+
crn: z.ZodNullable<z.ZodString>;
|
|
20
|
+
receiptId: z.ZodNumber;
|
|
21
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
declare const registerPrepaymentResponseSchema: z.ZodObject<{
|
|
24
|
+
urlId: z.ZodString;
|
|
25
|
+
prepaymentId: z.ZodNumber;
|
|
26
|
+
crn: z.ZodNullable<z.ZodString>;
|
|
27
|
+
receiptId: z.ZodNumber;
|
|
28
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
declare const registerPrepaymentRefundResponseSchema: z.ZodObject<{
|
|
31
|
+
urlId: z.ZodString;
|
|
32
|
+
prepaymentRefundId: z.ZodNumber;
|
|
33
|
+
crn: z.ZodNullable<z.ZodString>;
|
|
34
|
+
receiptId: z.ZodNumber;
|
|
35
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
declare const createOfferResponseSchema: z.ZodObject<{
|
|
38
|
+
offerId: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
declare const createCashierResponseSchema: z.ZodObject<{
|
|
41
|
+
id: z.ZodNumber;
|
|
42
|
+
deskId: z.ZodString;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
declare const createDepartmentResponseSchema: z.ZodObject<{
|
|
45
|
+
message: z.ZodString;
|
|
46
|
+
department: z.ZodNumber;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
declare const cashierListItemSchema: z.ZodObject<{
|
|
49
|
+
deskId: z.ZodString;
|
|
50
|
+
internalId: z.ZodNumber;
|
|
51
|
+
name: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
52
|
+
language: z.ZodEnum<{
|
|
53
|
+
hy: "hy";
|
|
54
|
+
ru: "ru";
|
|
55
|
+
en: "en";
|
|
56
|
+
multi: "multi";
|
|
57
|
+
}>;
|
|
58
|
+
content: z.ZodString;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
declare const cashierListResponseSchema: z.ZodArray<z.ZodObject<{
|
|
62
|
+
deskId: z.ZodString;
|
|
63
|
+
internalId: z.ZodNumber;
|
|
64
|
+
name: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
65
|
+
language: z.ZodEnum<{
|
|
66
|
+
hy: "hy";
|
|
67
|
+
ru: "ru";
|
|
68
|
+
en: "en";
|
|
69
|
+
multi: "multi";
|
|
70
|
+
}>;
|
|
71
|
+
content: z.ZodString;
|
|
72
|
+
}, z.core.$strip>>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
declare const classifierSearchItemSchema: z.ZodObject<{
|
|
75
|
+
code: z.ZodString;
|
|
76
|
+
title: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
declare const classifierSearchResponseSchema: z.ZodArray<z.ZodObject<{
|
|
79
|
+
code: z.ZodString;
|
|
80
|
+
title: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
declare const saleDetailResponseSchema: z.ZodObject<{
|
|
83
|
+
id: z.ZodNumber;
|
|
84
|
+
createdAt: z.ZodString;
|
|
85
|
+
buyerTin: z.ZodNullable<z.ZodString>;
|
|
86
|
+
cashAmount: z.ZodNumber;
|
|
87
|
+
nonCashAmount: z.ZodNumber;
|
|
88
|
+
prepaymentAmount: z.ZodNumber;
|
|
89
|
+
compensationAmount: z.ZodNumber;
|
|
90
|
+
receipt: z.ZodNullable<z.ZodObject<{
|
|
91
|
+
srcId: z.ZodNumber;
|
|
92
|
+
time: z.ZodString;
|
|
93
|
+
tin: z.ZodString;
|
|
94
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
95
|
+
sn: z.ZodString;
|
|
96
|
+
address: z.ZodNullable<z.ZodString>;
|
|
97
|
+
total: z.ZodNumber;
|
|
98
|
+
taxpayer: z.ZodString;
|
|
99
|
+
change: z.ZodNumber;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
refunds: z.ZodArray<z.ZodObject<{
|
|
102
|
+
nonCashAmount: z.ZodNumber;
|
|
103
|
+
cashAmount: z.ZodNumber;
|
|
104
|
+
receipt: z.ZodNullable<z.ZodObject<{
|
|
105
|
+
srcId: z.ZodNumber;
|
|
106
|
+
time: z.ZodString;
|
|
107
|
+
tin: z.ZodString;
|
|
108
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
109
|
+
sn: z.ZodString;
|
|
110
|
+
address: z.ZodNullable<z.ZodString>;
|
|
111
|
+
total: z.ZodNumber;
|
|
112
|
+
taxpayer: z.ZodString;
|
|
113
|
+
change: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>>;
|
|
115
|
+
items: z.ZodArray<z.ZodObject<{
|
|
116
|
+
quantity: z.ZodNumber;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
cashier: z.ZodObject<{
|
|
120
|
+
internalId: z.ZodNumber;
|
|
121
|
+
deskId: z.ZodString;
|
|
122
|
+
name: z.ZodArray<z.ZodObject<{
|
|
123
|
+
id: z.ZodNumber;
|
|
124
|
+
language: z.ZodEnum<{
|
|
125
|
+
hy: "hy";
|
|
126
|
+
ru: "ru";
|
|
127
|
+
en: "en";
|
|
128
|
+
multi: "multi";
|
|
129
|
+
}>;
|
|
130
|
+
content: z.ZodString;
|
|
131
|
+
}, z.core.$strip>>;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
items: z.ZodArray<z.ZodObject<{
|
|
134
|
+
srcId: z.ZodNumber;
|
|
135
|
+
quantity: z.ZodNumber;
|
|
136
|
+
price: z.ZodNumber;
|
|
137
|
+
unit: z.ZodEnum<{
|
|
138
|
+
pc: "pc";
|
|
139
|
+
unit: "unit";
|
|
140
|
+
set: "set";
|
|
141
|
+
box: "box";
|
|
142
|
+
pack: "pack";
|
|
143
|
+
case: "case";
|
|
144
|
+
hr: "hr";
|
|
145
|
+
sess: "sess";
|
|
146
|
+
proj: "proj";
|
|
147
|
+
sub: "sub";
|
|
148
|
+
kg: "kg";
|
|
149
|
+
l: "l";
|
|
150
|
+
m: "m";
|
|
151
|
+
g: "g";
|
|
152
|
+
ml: "ml";
|
|
153
|
+
cm: "cm";
|
|
154
|
+
bottle: "bottle";
|
|
155
|
+
can: "can";
|
|
156
|
+
jar: "jar";
|
|
157
|
+
bag: "bag";
|
|
158
|
+
m2: "m2";
|
|
159
|
+
dozen: "dozen";
|
|
160
|
+
pair: "pair";
|
|
161
|
+
mm: "mm";
|
|
162
|
+
roll: "roll";
|
|
163
|
+
tube: "tube";
|
|
164
|
+
km: "km";
|
|
165
|
+
ton: "ton";
|
|
166
|
+
m3: "m3";
|
|
167
|
+
pallet: "pallet";
|
|
168
|
+
other: "other";
|
|
169
|
+
}>;
|
|
170
|
+
discount: z.ZodNullable<z.ZodNumber>;
|
|
171
|
+
discountType: z.ZodNullable<z.ZodEnum<{
|
|
172
|
+
percent: "percent";
|
|
173
|
+
price: "price";
|
|
174
|
+
total: "total";
|
|
175
|
+
}>>;
|
|
176
|
+
additionalDiscount: z.ZodNullable<z.ZodNumber>;
|
|
177
|
+
additionalDiscountType: z.ZodNullable<z.ZodEnum<{
|
|
178
|
+
percent: "percent";
|
|
179
|
+
total: "total";
|
|
180
|
+
}>>;
|
|
181
|
+
department: z.ZodObject<{
|
|
182
|
+
internalId: z.ZodNumber;
|
|
183
|
+
taxRegime: z.ZodEnum<{
|
|
184
|
+
vat: "vat";
|
|
185
|
+
vat_exempt: "vat_exempt";
|
|
186
|
+
turnover_tax: "turnover_tax";
|
|
187
|
+
micro_enterprise: "micro_enterprise";
|
|
188
|
+
}>;
|
|
189
|
+
title: z.ZodArray<z.ZodObject<{
|
|
190
|
+
id: z.ZodNumber;
|
|
191
|
+
language: z.ZodEnum<{
|
|
192
|
+
hy: "hy";
|
|
193
|
+
ru: "ru";
|
|
194
|
+
en: "en";
|
|
195
|
+
multi: "multi";
|
|
196
|
+
}>;
|
|
197
|
+
content: z.ZodString;
|
|
198
|
+
}, z.core.$strip>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
offer: z.ZodObject<{
|
|
201
|
+
type: z.ZodEnum<{
|
|
202
|
+
product: "product";
|
|
203
|
+
service: "service";
|
|
204
|
+
}>;
|
|
205
|
+
classifierCode: z.ZodString;
|
|
206
|
+
title: z.ZodArray<z.ZodObject<{
|
|
207
|
+
id: z.ZodNumber;
|
|
208
|
+
language: z.ZodEnum<{
|
|
209
|
+
hy: "hy";
|
|
210
|
+
ru: "ru";
|
|
211
|
+
en: "en";
|
|
212
|
+
multi: "multi";
|
|
213
|
+
}>;
|
|
214
|
+
content: z.ZodString;
|
|
215
|
+
}, z.core.$strip>>;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
declare const prepaymentDetailResponseSchema: z.ZodObject<{
|
|
220
|
+
id: z.ZodNumber;
|
|
221
|
+
createdAt: z.ZodString;
|
|
222
|
+
buyerTin: z.ZodNullable<z.ZodString>;
|
|
223
|
+
cashAmount: z.ZodNumber;
|
|
224
|
+
nonCashAmount: z.ZodNumber;
|
|
225
|
+
receipt: z.ZodNullable<z.ZodObject<{
|
|
226
|
+
srcId: z.ZodNumber;
|
|
227
|
+
time: z.ZodString;
|
|
228
|
+
tin: z.ZodString;
|
|
229
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
230
|
+
sn: z.ZodString;
|
|
231
|
+
address: z.ZodNullable<z.ZodString>;
|
|
232
|
+
total: z.ZodNumber;
|
|
233
|
+
taxpayer: z.ZodString;
|
|
234
|
+
change: z.ZodNumber;
|
|
235
|
+
}, z.core.$strip>>;
|
|
236
|
+
refund: z.ZodNullable<z.ZodObject<{
|
|
237
|
+
nonCashAmount: z.ZodNumber;
|
|
238
|
+
cashAmount: z.ZodNumber;
|
|
239
|
+
receipt: z.ZodNullable<z.ZodObject<{
|
|
240
|
+
srcId: z.ZodNumber;
|
|
241
|
+
time: z.ZodString;
|
|
242
|
+
tin: z.ZodString;
|
|
243
|
+
fiscal: z.ZodNullable<z.ZodString>;
|
|
244
|
+
sn: z.ZodString;
|
|
245
|
+
address: z.ZodNullable<z.ZodString>;
|
|
246
|
+
total: z.ZodNumber;
|
|
247
|
+
taxpayer: z.ZodString;
|
|
248
|
+
change: z.ZodNumber;
|
|
249
|
+
}, z.core.$strip>>;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
cashier: z.ZodObject<{
|
|
252
|
+
internalId: z.ZodNumber;
|
|
253
|
+
deskId: z.ZodString;
|
|
254
|
+
name: z.ZodArray<z.ZodObject<{
|
|
255
|
+
id: z.ZodNumber;
|
|
256
|
+
language: z.ZodEnum<{
|
|
257
|
+
hy: "hy";
|
|
258
|
+
ru: "ru";
|
|
259
|
+
en: "en";
|
|
260
|
+
multi: "multi";
|
|
261
|
+
}>;
|
|
262
|
+
content: z.ZodString;
|
|
263
|
+
}, z.core.$strip>>;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
}, z.core.$strip>;
|
|
266
|
+
type RegisterSaleResponse = z.infer<typeof registerSaleResponseSchema>;
|
|
267
|
+
type RegisterSaleRefundResponse = z.infer<typeof registerSaleRefundResponseSchema>;
|
|
268
|
+
type RegisterPrepaymentResponse = z.infer<typeof registerPrepaymentResponseSchema>;
|
|
269
|
+
type RegisterPrepaymentRefundResponse = z.infer<typeof registerPrepaymentRefundResponseSchema>;
|
|
270
|
+
type CreateOfferResponse = z.infer<typeof createOfferResponseSchema>;
|
|
271
|
+
type CreateCashierResponse = z.infer<typeof createCashierResponseSchema>;
|
|
272
|
+
type CreateDepartmentResponse = z.infer<typeof createDepartmentResponseSchema>;
|
|
273
|
+
type CashierListItem = z.infer<typeof cashierListItemSchema>;
|
|
274
|
+
type ClassifierSearchItem = z.infer<typeof classifierSearchItemSchema>;
|
|
275
|
+
type SaleDetail = z.infer<typeof saleDetailResponseSchema>;
|
|
276
|
+
type PrepaymentDetail = z.infer<typeof prepaymentDetailResponseSchema>;
|
|
2
277
|
|
|
3
278
|
declare const unitsKeys: readonly ["pc", "unit", "set", "box", "pack", "case", "hr", "sess", "proj", "sub", "kg", "l", "m", "g", "ml", "cm", "bottle", "can", "jar", "bag", "m2", "dozen", "pair", "mm", "roll", "tube", "km", "ton", "m3", "pallet", "other"];
|
|
4
279
|
declare const AVAILABLE_LANGUAGES: readonly ["hy", "ru", "en"];
|
|
280
|
+
declare const REFUND_REASONS: readonly ["customer_request", "defective_goods", "wrong_goods", "cashier_error", "duplicate_receipt", "other"];
|
|
281
|
+
declare const TAX_REGIMES: readonly ["vat", "vat_exempt", "turnover_tax", "micro_enterprise"];
|
|
282
|
+
declare const DEFAULT_API_URL = "https://vcr.am/api/v1";
|
|
283
|
+
declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
5
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Object where at least one of the listed keys must be present.
|
|
287
|
+
* Inlined here to avoid pulling type-fest into runtime dependents.
|
|
288
|
+
*/
|
|
289
|
+
type RequireAtLeastOne<T, K extends keyof T = keyof T> = Omit<T, K> & {
|
|
290
|
+
[P in K]-?: Required<Pick<T, P>> & Partial<Pick<T, Exclude<K, P>>>;
|
|
291
|
+
}[K];
|
|
292
|
+
type Unit = (typeof unitsKeys)[number];
|
|
293
|
+
type Language = (typeof AVAILABLE_LANGUAGES)[number];
|
|
294
|
+
type RefundReason = (typeof REFUND_REASONS)[number];
|
|
295
|
+
type TaxRegime = (typeof TAX_REGIMES)[number];
|
|
6
296
|
type CashierInternalId = {
|
|
7
297
|
id: number;
|
|
8
298
|
};
|
|
@@ -10,8 +300,6 @@ type CashierDeskId = {
|
|
|
10
300
|
deskId: string;
|
|
11
301
|
};
|
|
12
302
|
type CashierId = CashierInternalId | CashierDeskId;
|
|
13
|
-
type Unit = (typeof unitsKeys)[number];
|
|
14
|
-
type Language = (typeof AVAILABLE_LANGUAGES)[number];
|
|
15
303
|
type PercentDiscount = {
|
|
16
304
|
type: "percent";
|
|
17
305
|
value: string;
|
|
@@ -26,30 +314,25 @@ type AbsoluteAdditionalDiscount = {
|
|
|
26
314
|
};
|
|
27
315
|
type BaseDiscount = PercentDiscount | AbsoluteDiscount;
|
|
28
316
|
type AdditionalDiscount = PercentDiscount | AbsoluteAdditionalDiscount;
|
|
29
|
-
type
|
|
317
|
+
type Discounts = {
|
|
30
318
|
base?: BaseDiscount;
|
|
31
319
|
additional?: AdditionalDiscount;
|
|
32
320
|
};
|
|
33
|
-
type BaseDiscounts = {
|
|
34
|
-
base: BaseDiscount;
|
|
35
|
-
};
|
|
36
|
-
type BaseAndAdditionalDiscounts = {
|
|
37
|
-
base: BaseDiscount;
|
|
38
|
-
additional: AdditionalDiscount;
|
|
39
|
-
};
|
|
40
321
|
type ExistingOffer = {
|
|
41
322
|
externalId: string;
|
|
42
323
|
};
|
|
43
|
-
type
|
|
324
|
+
type LocalizedOfferTitle = {
|
|
44
325
|
type: "localized";
|
|
45
326
|
content: Partial<Record<Language, string>> & {
|
|
46
327
|
hy: string;
|
|
47
328
|
};
|
|
48
329
|
localizationStrategy: "translation" | "transliteration";
|
|
49
|
-
}
|
|
330
|
+
};
|
|
331
|
+
type UniversalOfferTitle = {
|
|
50
332
|
type: "universal";
|
|
51
333
|
content: string;
|
|
52
334
|
};
|
|
335
|
+
type OfferTitle = LocalizedOfferTitle | UniversalOfferTitle;
|
|
53
336
|
type DepartmentInput = {
|
|
54
337
|
id: number;
|
|
55
338
|
};
|
|
@@ -68,11 +351,11 @@ type SaleItem = {
|
|
|
68
351
|
quantity: string;
|
|
69
352
|
price: string;
|
|
70
353
|
unit: Unit;
|
|
71
|
-
discounts?:
|
|
354
|
+
discounts?: Discounts;
|
|
72
355
|
totalAmountTolerance?: string;
|
|
73
356
|
};
|
|
74
357
|
type SaleAmount = RequireAtLeastOne<{
|
|
75
|
-
|
|
358
|
+
prepayment?: string;
|
|
76
359
|
compensation?: string;
|
|
77
360
|
nonCash?: string;
|
|
78
361
|
cash?: string;
|
|
@@ -91,27 +374,167 @@ type LegalEntityBuyer = {
|
|
|
91
374
|
receipt?: SendReceiptToBuyer;
|
|
92
375
|
};
|
|
93
376
|
type Buyer = IndividualBuyer | LegalEntityBuyer;
|
|
94
|
-
type
|
|
377
|
+
type RegisterSaleInput = {
|
|
95
378
|
cashier: CashierId;
|
|
96
379
|
items: SaleItem[];
|
|
97
380
|
amount: SaleAmount;
|
|
98
381
|
buyer: Buyer;
|
|
99
382
|
};
|
|
383
|
+
/** @deprecated Use {@link RegisterSaleInput} instead. Will be removed in 1.0. */
|
|
384
|
+
type SaleData = RegisterSaleInput;
|
|
385
|
+
type ClassifierType = "product" | "service";
|
|
386
|
+
type SearchClassifierInput = {
|
|
387
|
+
query: string;
|
|
388
|
+
type: ClassifierType;
|
|
389
|
+
language: Language;
|
|
390
|
+
};
|
|
391
|
+
type RefundItemInput = {
|
|
392
|
+
srcId: number;
|
|
393
|
+
quantity: string;
|
|
394
|
+
emarks?: string[];
|
|
395
|
+
};
|
|
396
|
+
type RefundAmount = RequireAtLeastOne<{
|
|
397
|
+
cash?: string;
|
|
398
|
+
nonCash?: string;
|
|
399
|
+
}>;
|
|
400
|
+
type RegisterSaleRefundInput = {
|
|
401
|
+
cashier: CashierId;
|
|
402
|
+
saleId: number;
|
|
403
|
+
receipt?: SendReceiptToBuyer;
|
|
404
|
+
reason?: RefundReason;
|
|
405
|
+
reasonNote?: string;
|
|
406
|
+
refundAmounts?: RefundAmount;
|
|
407
|
+
items?: RefundItemInput[];
|
|
408
|
+
};
|
|
409
|
+
type PrepaymentAmount = RequireAtLeastOne<{
|
|
410
|
+
cash?: string;
|
|
411
|
+
nonCash?: string;
|
|
412
|
+
}>;
|
|
413
|
+
type RegisterPrepaymentInput = {
|
|
414
|
+
cashier: CashierId;
|
|
415
|
+
amount: PrepaymentAmount;
|
|
416
|
+
buyer: Buyer;
|
|
417
|
+
};
|
|
418
|
+
type RegisterPrepaymentRefundInput = {
|
|
419
|
+
cashier: CashierId;
|
|
420
|
+
prepaymentId: number;
|
|
421
|
+
receipt?: SendReceiptToBuyer;
|
|
422
|
+
reason?: RefundReason;
|
|
423
|
+
reasonNote?: string;
|
|
424
|
+
};
|
|
425
|
+
type LocalizedName = Partial<Record<Language, string>> & {
|
|
426
|
+
hy: string;
|
|
427
|
+
};
|
|
428
|
+
type CreateCashierInput = {
|
|
429
|
+
name: {
|
|
430
|
+
value: LocalizedName;
|
|
431
|
+
localizationStrategy: "translation" | "transliteration";
|
|
432
|
+
};
|
|
433
|
+
/** 4–8 digit numeric PIN. */
|
|
434
|
+
password: string;
|
|
435
|
+
};
|
|
436
|
+
type CreateDepartmentInput = {
|
|
437
|
+
externalId?: string;
|
|
438
|
+
taxRegime: TaxRegime;
|
|
439
|
+
};
|
|
440
|
+
type CreateOfferInputProduct = {
|
|
441
|
+
type: "product";
|
|
442
|
+
classifierCode: string;
|
|
443
|
+
title: {
|
|
444
|
+
value: LocalizedName;
|
|
445
|
+
localizationStrategy: "translation" | "transliteration";
|
|
446
|
+
};
|
|
447
|
+
defaultMeasureUnit: Unit;
|
|
448
|
+
defaultDepartment: DepartmentInput;
|
|
449
|
+
externalId?: string;
|
|
450
|
+
};
|
|
451
|
+
type CreateOfferInputService = Omit<CreateOfferInputProduct, "type"> & {
|
|
452
|
+
type: "service";
|
|
453
|
+
};
|
|
454
|
+
type CreateOfferInput = CreateOfferInputProduct | CreateOfferInputService;
|
|
100
455
|
|
|
456
|
+
type VCRClientOptions = {
|
|
457
|
+
/** Base URL for the VCR API. Defaults to https://vcr.am/api/v1. */
|
|
458
|
+
baseUrl?: string;
|
|
459
|
+
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
460
|
+
fetch?: typeof fetch;
|
|
461
|
+
/** Default request timeout in ms. Pass `null` to disable. Default 30s. */
|
|
462
|
+
timeoutMs?: number | null;
|
|
463
|
+
};
|
|
101
464
|
declare class VCRClient {
|
|
102
|
-
private
|
|
103
|
-
constructor(apiKey: string);
|
|
104
|
-
registerSale(data:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
465
|
+
#private;
|
|
466
|
+
constructor(apiKey: string, options?: VCRClientOptions);
|
|
467
|
+
registerSale(data: RegisterSaleInput, options?: RequestOptions): Promise<RegisterSaleResponse>;
|
|
468
|
+
getSale(saleId: number, options?: RequestOptions): Promise<SaleDetail>;
|
|
469
|
+
registerSaleRefund(data: RegisterSaleRefundInput, options?: RequestOptions): Promise<RegisterSaleRefundResponse>;
|
|
470
|
+
registerPrepayment(data: RegisterPrepaymentInput, options?: RequestOptions): Promise<RegisterPrepaymentResponse>;
|
|
471
|
+
getPrepayment(prepaymentId: number, options?: RequestOptions): Promise<PrepaymentDetail>;
|
|
472
|
+
registerPrepaymentRefund(data: RegisterPrepaymentRefundInput, options?: RequestOptions): Promise<RegisterPrepaymentRefundResponse>;
|
|
473
|
+
listCashiers(options?: RequestOptions): Promise<CashierListItem[]>;
|
|
474
|
+
createCashier(data: CreateCashierInput, options?: RequestOptions): Promise<CreateCashierResponse>;
|
|
475
|
+
createOffer(data: CreateOfferInput, options?: RequestOptions): Promise<CreateOfferResponse>;
|
|
476
|
+
createDepartment(data: CreateDepartmentInput, options?: RequestOptions): Promise<CreateDepartmentResponse>;
|
|
477
|
+
searchClassifier(input: SearchClassifierInput, options?: RequestOptions): Promise<ClassifierSearchItem[]>;
|
|
478
|
+
/**
|
|
479
|
+
* @deprecated Use {@link searchClassifier} with an options object. Will be
|
|
480
|
+
* removed in 1.0. The new signature accepts `{ query, type, language }` so
|
|
481
|
+
* future params can be added without breaking the call site.
|
|
482
|
+
*/
|
|
483
|
+
searchClassifierCategory(query: string, type: ClassifierType, language: Language, options?: RequestOptions): Promise<ClassifierSearchItem[]>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
type ApiErrorIssue = {
|
|
487
|
+
path: Array<string | number>;
|
|
488
|
+
message: string;
|
|
489
|
+
code: string;
|
|
490
|
+
};
|
|
491
|
+
type ApiErrorBody = {
|
|
492
|
+
error: string;
|
|
493
|
+
issues?: Array<ApiErrorIssue>;
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* Base class for every error thrown by the SDK.
|
|
497
|
+
* Catch this if you want a single catch-all.
|
|
498
|
+
*/
|
|
499
|
+
declare abstract class VCRError extends Error {
|
|
500
|
+
abstract readonly kind: string;
|
|
501
|
+
constructor(message: string, options?: {
|
|
502
|
+
cause?: unknown;
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Server returned a non-2xx response with a parseable JSON error body.
|
|
507
|
+
* Mirrors the unified `{ error, issues? }` envelope from /api/v1.
|
|
508
|
+
*/
|
|
509
|
+
declare class VCRApiError extends VCRError {
|
|
510
|
+
readonly status: number;
|
|
511
|
+
readonly body: ApiErrorBody;
|
|
512
|
+
readonly url: string;
|
|
513
|
+
readonly kind: "api";
|
|
514
|
+
constructor(status: number, body: ApiErrorBody, url: string);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Server returned a non-2xx response that did not match the error envelope,
|
|
518
|
+
* or a 2xx response whose body did not match the expected schema.
|
|
519
|
+
*/
|
|
520
|
+
declare class VCRValidationError extends VCRError {
|
|
521
|
+
readonly status: number;
|
|
522
|
+
readonly url: string;
|
|
523
|
+
readonly issues: z.ZodIssue[];
|
|
524
|
+
readonly raw: unknown;
|
|
525
|
+
readonly kind: "validation";
|
|
526
|
+
constructor(message: string, status: number, url: string, issues: z.ZodIssue[], raw: unknown);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Network-level failure: DNS, connection refused, timeout, abort.
|
|
530
|
+
* The request never produced a parseable HTTP response.
|
|
531
|
+
*/
|
|
532
|
+
declare class VCRNetworkError extends VCRError {
|
|
533
|
+
readonly url: string;
|
|
534
|
+
readonly kind: "network";
|
|
535
|
+
constructor(message: string, url: string, options: {
|
|
536
|
+
cause: unknown;
|
|
537
|
+
});
|
|
115
538
|
}
|
|
116
539
|
|
|
117
|
-
export { AVAILABLE_LANGUAGES, type Language, type SaleData, type SaleItem, type Unit, VCRClient, unitsKeys };
|
|
540
|
+
export { AVAILABLE_LANGUAGES, type ApiErrorBody, type ApiErrorIssue, type Buyer, type CashierId, type CashierListItem, type ClassifierSearchItem, type ClassifierType, type CreateCashierInput, type CreateCashierResponse, type CreateDepartmentInput, type CreateDepartmentResponse, type CreateOfferInput, type CreateOfferInputProduct, type CreateOfferInputService, type CreateOfferResponse, DEFAULT_API_URL, DEFAULT_TIMEOUT_MS, type DepartmentInput, type Discounts, type Language, type LocalizedName, type NewOffer, type Offer, type OfferTitle, type PrepaymentAmount, type PrepaymentDetail, REFUND_REASONS, type RefundAmount, type RefundItemInput, type RefundReason, type RegisterPrepaymentInput, type RegisterPrepaymentRefundInput, type RegisterPrepaymentRefundResponse, type RegisterPrepaymentResponse, type RegisterSaleInput, type RegisterSaleRefundInput, type RegisterSaleRefundResponse, type RegisterSaleResponse, type RequestOptions, type SaleAmount, type SaleData, type SaleDetail, type SaleItem, type SearchClassifierInput, type SendReceiptToBuyer, TAX_REGIMES, type TaxRegime, type Unit, VCRApiError, VCRClient, type VCRClientOptions, VCRError, VCRNetworkError, VCRValidationError, cashierListItemSchema, cashierListResponseSchema, classifierSearchItemSchema, classifierSearchResponseSchema, createCashierResponseSchema, createDepartmentResponseSchema, createOfferResponseSchema, prepaymentDetailResponseSchema, registerPrepaymentRefundResponseSchema, registerPrepaymentResponseSchema, registerSaleRefundResponseSchema, registerSaleResponseSchema, saleDetailResponseSchema, unitsKeys };
|