@blob-solutions/vcr-am-sdk 0.16.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 +30 -0
- package/README.md +62 -1
- package/lib/index.cjs +19 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +69 -1
- package/lib/index.d.ts +69 -1
- package/lib/index.global.js +7 -7
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +19 -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,9 +205,36 @@ 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>;
|
|
198
239
|
comment: z.ZodNullable<z.ZodString>;
|
|
199
240
|
cashAmount: z.ZodNumber;
|
|
@@ -337,6 +378,12 @@ declare const prepaymentStateSchema: z.ZodEnum<{
|
|
|
337
378
|
declare const prepaymentDetailResponseSchema: z.ZodObject<{
|
|
338
379
|
id: z.ZodNumber;
|
|
339
380
|
createdAt: z.ZodString;
|
|
381
|
+
srcStatus: z.ZodEnum<{
|
|
382
|
+
pending: "pending";
|
|
383
|
+
accepted: "accepted";
|
|
384
|
+
rejected: "rejected";
|
|
385
|
+
needs_decision: "needs_decision";
|
|
386
|
+
}>;
|
|
340
387
|
buyerTin: z.ZodNullable<z.ZodString>;
|
|
341
388
|
cashAmount: z.ZodNumber;
|
|
342
389
|
nonCashAmount: z.ZodNumber;
|
|
@@ -437,6 +484,7 @@ type CashierListItem = z.infer<typeof cashierListItemSchema>;
|
|
|
437
484
|
type ClassifierSearchItem = z.infer<typeof classifierSearchItemSchema>;
|
|
438
485
|
type Whoami = z.infer<typeof whoamiResponseSchema>;
|
|
439
486
|
type OfferListItem = z.infer<typeof offerListItemSchema>;
|
|
487
|
+
type SrcStatus = z.infer<typeof srcStatusSchema>;
|
|
440
488
|
type SaleDetail = z.infer<typeof saleDetailResponseSchema>;
|
|
441
489
|
type PrepaymentDetail = z.infer<typeof prepaymentDetailResponseSchema>;
|
|
442
490
|
type PrepaymentListItem = z.infer<typeof prepaymentListItemSchema>;
|
|
@@ -865,6 +913,21 @@ type ApiErrorIssue = {
|
|
|
865
913
|
message: string;
|
|
866
914
|
code: string;
|
|
867
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
|
+
};
|
|
868
931
|
type ApiErrorBody = {
|
|
869
932
|
error: string;
|
|
870
933
|
issues?: Array<ApiErrorIssue>;
|
|
@@ -874,6 +937,11 @@ type ApiErrorBody = {
|
|
|
874
937
|
* and Sentry event can be located.
|
|
875
938
|
*/
|
|
876
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;
|
|
877
945
|
};
|
|
878
946
|
/**
|
|
879
947
|
* Base class for every error thrown by the SDK.
|
|
@@ -920,4 +988,4 @@ declare class VCRNetworkError extends VCRError {
|
|
|
920
988
|
});
|
|
921
989
|
}
|
|
922
990
|
|
|
923
|
-
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 };
|