@blob-solutions/vcr-am-sdk 0.15.0 → 0.17.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 +47 -0
- package/README.md +64 -1
- package/lib/index.cjs +20 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +77 -1
- package/lib/index.d.ts +77 -1
- package/lib/index.global.js +7 -7
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +20 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,20 @@ type RequestOptions = {
|
|
|
4
4
|
signal?: AbortSignal;
|
|
5
5
|
/** Override per-request timeout in ms. `null` disables the timeout. */
|
|
6
6
|
timeoutMs?: number | null;
|
|
7
|
+
/**
|
|
8
|
+
* Opt-in replay protection for the document-creating endpoints
|
|
9
|
+
* (`registerSale`, `registerSaleRefund`, `registerPrepayment`,
|
|
10
|
+
* `registerPrepaymentRefund`). Retrying a request that carries the same key
|
|
11
|
+
* returns the original response instead of registering a second document.
|
|
12
|
+
*
|
|
13
|
+
* Strongly recommended. Without it, retrying after a 502 produces a
|
|
14
|
+
* duplicate fiscal receipt, which can only be undone by issuing a refund.
|
|
15
|
+
*
|
|
16
|
+
* The SDK deliberately does not generate this for you: the value must stay
|
|
17
|
+
* **stable across your retries**, so it has to come from something you own —
|
|
18
|
+
* typically your order id (`order-4821`) — not from a fresh UUID per call.
|
|
19
|
+
*/
|
|
20
|
+
idempotencyKey?: string;
|
|
7
21
|
};
|
|
8
22
|
|
|
9
23
|
declare const registerSaleResponseSchema: z.ZodObject<{
|
|
@@ -191,10 +205,38 @@ declare const offerListResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
191
205
|
archivedAt: z.ZodNullable<z.ZodString>;
|
|
192
206
|
createdAt: z.ZodString;
|
|
193
207
|
}, z.core.$strip>>;
|
|
208
|
+
/**
|
|
209
|
+
* Where a document stands with the tax authority, derived from its submission
|
|
210
|
+
* log. This is the field to poll after a 502 that carried a `pending` handle.
|
|
211
|
+
*
|
|
212
|
+
* - `accepted` — SRC registered it. Terminal and final; a fiscal receipt exists.
|
|
213
|
+
* - `rejected` — SRC refused the document itself. Terminal: resending the same
|
|
214
|
+
* payload gets the same refusal, so something has to change.
|
|
215
|
+
* - `pending` — no answer from SRC yet. VCR owns the retry; do NOT resend.
|
|
216
|
+
* - `needs_decision` — the automatic retry window (24h) closed without an
|
|
217
|
+
* answer. Still not resendable blind — check the document before acting.
|
|
218
|
+
*
|
|
219
|
+
* A plain enum rather than a boolean because "not accepted" spans three very
|
|
220
|
+
* different situations, and the one that matters most (`pending`) is the one
|
|
221
|
+
* that looks like failure but must not be treated as one.
|
|
222
|
+
*/
|
|
223
|
+
declare const srcStatusSchema: z.ZodEnum<{
|
|
224
|
+
pending: "pending";
|
|
225
|
+
accepted: "accepted";
|
|
226
|
+
rejected: "rejected";
|
|
227
|
+
needs_decision: "needs_decision";
|
|
228
|
+
}>;
|
|
194
229
|
declare const saleDetailResponseSchema: z.ZodObject<{
|
|
195
230
|
id: z.ZodNumber;
|
|
196
231
|
createdAt: z.ZodString;
|
|
232
|
+
srcStatus: z.ZodEnum<{
|
|
233
|
+
pending: "pending";
|
|
234
|
+
accepted: "accepted";
|
|
235
|
+
rejected: "rejected";
|
|
236
|
+
needs_decision: "needs_decision";
|
|
237
|
+
}>;
|
|
197
238
|
buyerTin: z.ZodNullable<z.ZodString>;
|
|
239
|
+
comment: z.ZodNullable<z.ZodString>;
|
|
198
240
|
cashAmount: z.ZodNumber;
|
|
199
241
|
nonCashAmount: z.ZodNumber;
|
|
200
242
|
prepaymentAmount: z.ZodNumber;
|
|
@@ -336,6 +378,12 @@ declare const prepaymentStateSchema: z.ZodEnum<{
|
|
|
336
378
|
declare const prepaymentDetailResponseSchema: z.ZodObject<{
|
|
337
379
|
id: z.ZodNumber;
|
|
338
380
|
createdAt: z.ZodString;
|
|
381
|
+
srcStatus: z.ZodEnum<{
|
|
382
|
+
pending: "pending";
|
|
383
|
+
accepted: "accepted";
|
|
384
|
+
rejected: "rejected";
|
|
385
|
+
needs_decision: "needs_decision";
|
|
386
|
+
}>;
|
|
339
387
|
buyerTin: z.ZodNullable<z.ZodString>;
|
|
340
388
|
cashAmount: z.ZodNumber;
|
|
341
389
|
nonCashAmount: z.ZodNumber;
|
|
@@ -436,6 +484,7 @@ type CashierListItem = z.infer<typeof cashierListItemSchema>;
|
|
|
436
484
|
type ClassifierSearchItem = z.infer<typeof classifierSearchItemSchema>;
|
|
437
485
|
type Whoami = z.infer<typeof whoamiResponseSchema>;
|
|
438
486
|
type OfferListItem = z.infer<typeof offerListItemSchema>;
|
|
487
|
+
type SrcStatus = z.infer<typeof srcStatusSchema>;
|
|
439
488
|
type SaleDetail = z.infer<typeof saleDetailResponseSchema>;
|
|
440
489
|
type PrepaymentDetail = z.infer<typeof prepaymentDetailResponseSchema>;
|
|
441
490
|
type PrepaymentListItem = z.infer<typeof prepaymentListItemSchema>;
|
|
@@ -633,6 +682,13 @@ type RegisterSaleInput = {
|
|
|
633
682
|
cashier: CashierId;
|
|
634
683
|
items: SaleItem[];
|
|
635
684
|
buyer: Buyer;
|
|
685
|
+
/**
|
|
686
|
+
* Optional merchant-internal note, e.g. an external payment reference. Max
|
|
687
|
+
* 500 characters; control characters are stripped and surrounding whitespace
|
|
688
|
+
* trimmed server-side. It is purely internal: never printed on the buyer's
|
|
689
|
+
* receipt and never sent to the tax authority (SRC).
|
|
690
|
+
*/
|
|
691
|
+
comment?: string;
|
|
636
692
|
} & SalePayment;
|
|
637
693
|
/** @deprecated Use {@link RegisterSaleInput} instead. Will be removed in 1.0. */
|
|
638
694
|
type SaleData = RegisterSaleInput;
|
|
@@ -857,6 +913,21 @@ type ApiErrorIssue = {
|
|
|
857
913
|
message: string;
|
|
858
914
|
code: string;
|
|
859
915
|
};
|
|
916
|
+
/**
|
|
917
|
+
* A document VCR persisted and queued for automatic resubmission to SRC.
|
|
918
|
+
*
|
|
919
|
+
* Present on a 502 when SRC was merely unreachable. It means the request was
|
|
920
|
+
* NOT lost: VCR owns the work and a background sweep usually completes it
|
|
921
|
+
* within minutes. Poll `statusUrl` to find out; do NOT resend the request,
|
|
922
|
+
* which would produce a second fiscal receipt.
|
|
923
|
+
*/
|
|
924
|
+
type PendingResource = {
|
|
925
|
+
/** Which collection `id` belongs to, e.g. `"sale"` or `"prepayment"`. */
|
|
926
|
+
type: string;
|
|
927
|
+
id: number;
|
|
928
|
+
/** Path to poll for the outcome, e.g. `/api/v1/sales/5122`. */
|
|
929
|
+
statusUrl: string;
|
|
930
|
+
};
|
|
860
931
|
type ApiErrorBody = {
|
|
861
932
|
error: string;
|
|
862
933
|
issues?: Array<ApiErrorIssue>;
|
|
@@ -866,6 +937,11 @@ type ApiErrorBody = {
|
|
|
866
937
|
* and Sentry event can be located.
|
|
867
938
|
*/
|
|
868
939
|
requestId?: string;
|
|
940
|
+
/**
|
|
941
|
+
* Set when the request was persisted despite the error. Its absence on an
|
|
942
|
+
* error means nothing was created.
|
|
943
|
+
*/
|
|
944
|
+
pending?: PendingResource;
|
|
869
945
|
};
|
|
870
946
|
/**
|
|
871
947
|
* Base class for every error thrown by the SDK.
|
|
@@ -912,4 +988,4 @@ declare class VCRNetworkError extends VCRError {
|
|
|
912
988
|
});
|
|
913
989
|
}
|
|
914
990
|
|
|
915
|
-
export { AVAILABLE_LANGUAGES, type ApiErrorBody, type ApiErrorIssue, type AutoSettle, 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, type CreateOfferTitle, type CustomerPrepaymentBalance, DEFAULT_API_URL, DEFAULT_TIMEOUT_MS, type DepartmentInput, type DepartmentListItem, type Discounts, type ExchangeRate, type Language, type LegacyOfferTitle, type ListOffersFilter, type ListPrepaymentsFilter, type LocalizedName, type NewOffer, type Offer, type OfferListItem, type OfferTitle, type PrepaymentAmount, type PrepaymentDetail, type PrepaymentListItem, type PrepaymentState, 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 SalePayment, type SearchClassifierInput, type SendReceiptToBuyer, TAX_REGIMES, type TaxRegime, type Unit, type UpdateOfferInput, VCRApiError, VCRClient, type VCRClientOptions, VCRError, VCRNetworkError, VCRValidationError, type Whoami, cashierListItemSchema, cashierListResponseSchema, classifierSearchItemSchema, classifierSearchResponseSchema, createCashierResponseSchema, createDepartmentResponseSchema, createOfferResponseSchema, customerPrepaymentBalanceResponseSchema, departmentListItemSchema, departmentListResponseSchema, exchangeRateResponseSchema, offerListItemSchema, offerListResponseSchema, prepaymentDetailResponseSchema, prepaymentListItemSchema, prepaymentListResponseSchema, prepaymentStateSchema, registerPrepaymentRefundResponseSchema, registerPrepaymentResponseSchema, registerSaleRefundResponseSchema, registerSaleResponseSchema, saleDetailResponseSchema, unitsKeys, whoamiResponseSchema };
|
|
991
|
+
export { AVAILABLE_LANGUAGES, type ApiErrorBody, type ApiErrorIssue, type AutoSettle, 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, type CreateOfferTitle, type CustomerPrepaymentBalance, DEFAULT_API_URL, DEFAULT_TIMEOUT_MS, type DepartmentInput, type DepartmentListItem, type Discounts, type ExchangeRate, type Language, type LegacyOfferTitle, type ListOffersFilter, type ListPrepaymentsFilter, type LocalizedName, type NewOffer, type Offer, type OfferListItem, type OfferTitle, type PendingResource, type PrepaymentAmount, type PrepaymentDetail, type PrepaymentListItem, type PrepaymentState, 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 SalePayment, type SearchClassifierInput, type SendReceiptToBuyer, type SrcStatus, TAX_REGIMES, type TaxRegime, type Unit, type UpdateOfferInput, VCRApiError, VCRClient, type VCRClientOptions, VCRError, VCRNetworkError, VCRValidationError, type Whoami, cashierListItemSchema, cashierListResponseSchema, classifierSearchItemSchema, classifierSearchResponseSchema, createCashierResponseSchema, createDepartmentResponseSchema, createOfferResponseSchema, customerPrepaymentBalanceResponseSchema, departmentListItemSchema, departmentListResponseSchema, exchangeRateResponseSchema, offerListItemSchema, offerListResponseSchema, prepaymentDetailResponseSchema, prepaymentListItemSchema, prepaymentListResponseSchema, prepaymentStateSchema, registerPrepaymentRefundResponseSchema, registerPrepaymentResponseSchema, registerSaleRefundResponseSchema, registerSaleResponseSchema, saleDetailResponseSchema, srcStatusSchema, unitsKeys, whoamiResponseSchema };
|