@asteby/storefront 0.15.0 → 0.16.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/dist/cli.js +13 -1
- package/dist/fiscal-document.cjs +72 -8
- package/dist/fiscal-document.cjs.map +1 -1
- package/dist/fiscal-document.d.cts +34 -4
- package/dist/fiscal-document.d.ts +34 -4
- package/dist/fiscal-document.js +71 -9
- package/dist/fiscal-document.js.map +1 -1
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +121 -1
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +3 -1
- package/dist/mock.d.ts +3 -1
- package/dist/mock.js +121 -1
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/{types-CuamKhDe.d.ts → types-DFK20t_g.d.ts} +46 -1
- package/dist/{types-cwXbVCwe.d.cts → types-TQPpYbac.d.cts} +46 -1
- package/package.json +1 -1
package/dist/mockup.d.cts
CHANGED
package/dist/mockup.d.ts
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -47,7 +47,7 @@ function maskToken(token) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// src/node.ts
|
|
50
|
-
var SDK_VERSION = true ? "0.
|
|
50
|
+
var SDK_VERSION = true ? "0.16.0" : "dev";
|
|
51
51
|
function createFileTokenSource(file, options = {}) {
|
|
52
52
|
const ttl = options.ttlMs ?? 3e4;
|
|
53
53
|
const now = options.now ?? Date.now;
|
package/dist/node.js
CHANGED
|
@@ -11,7 +11,7 @@ function maskToken(token) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// src/node.ts
|
|
14
|
-
var SDK_VERSION = true ? "0.
|
|
14
|
+
var SDK_VERSION = true ? "0.16.0" : "dev";
|
|
15
15
|
function createFileTokenSource(file, options = {}) {
|
|
16
16
|
const ttl = options.ttlMs ?? 3e4;
|
|
17
17
|
const now = options.now ?? Date.now;
|
|
@@ -426,6 +426,8 @@ type InvoiceRequest = {
|
|
|
426
426
|
invoice_use?: string;
|
|
427
427
|
/** Also save the data to the buyer's account (needs a session). */
|
|
428
428
|
save?: boolean;
|
|
429
|
+
/** Saved fiscal profile the data comes from (contract 1.9; needs a session; `404` when it is not the buyer's). */
|
|
430
|
+
profile_id?: string;
|
|
429
431
|
[key: string]: unknown;
|
|
430
432
|
};
|
|
431
433
|
type CheckoutInput = {
|
|
@@ -525,6 +527,10 @@ type CustomerCapabilities = {
|
|
|
525
527
|
unavailable_reason?: 'missing_scope' | (string & {});
|
|
526
528
|
/** Scopes the token lacks (e.g. `customer:write`) when `unavailable_reason` is `missing_scope`. */
|
|
527
529
|
missing_scopes?: string[];
|
|
530
|
+
/** Saved fiscal profiles (contract 1.9). Absent on older servers: the section does not exist. */
|
|
531
|
+
fiscal_profiles?: {
|
|
532
|
+
max: number;
|
|
533
|
+
};
|
|
528
534
|
};
|
|
529
535
|
/** `GET {gateway}/_token`: what the token in use is and what it can do. Needs no scope. */
|
|
530
536
|
type TokenIntrospection = {
|
|
@@ -1196,6 +1202,11 @@ type RegionFiscalEntry = {
|
|
|
1196
1202
|
allowed_regimes?: string[];
|
|
1197
1203
|
/** Folded phrases that identify the entry in a document (`catalog_phrases`); without them the label is used. */
|
|
1198
1204
|
match_phrases?: string[];
|
|
1205
|
+
/**
|
|
1206
|
+
* Invoice uses only (contract 1.9): the regimes this use is SUGGESTED for. Region data, never a rule: the buyer can
|
|
1207
|
+
* change it and `allowed_regimes` still validates.
|
|
1208
|
+
*/
|
|
1209
|
+
suggested_for_regimes?: string[];
|
|
1199
1210
|
};
|
|
1200
1211
|
/**
|
|
1201
1212
|
* A document the buyer can upload to prefill their fiscal data, with the rules to read it. Published by the
|
|
@@ -1212,6 +1223,11 @@ type IdentityDocumentSpec = {
|
|
|
1212
1223
|
obtain_url?: string;
|
|
1213
1224
|
/** MIME types the document comes in (the SDK reads PDFs). */
|
|
1214
1225
|
accept: string[];
|
|
1226
|
+
/**
|
|
1227
|
+
* What can be read from a PHOTO of the document (contract 1.9): `qr_only` (the QR: tax id and document id) or
|
|
1228
|
+
* `full`. Absent or `none`: files only.
|
|
1229
|
+
*/
|
|
1230
|
+
image_mode?: 'none' | 'qr_only' | 'full';
|
|
1215
1231
|
max_bytes: number;
|
|
1216
1232
|
max_pages?: number;
|
|
1217
1233
|
/** `rules@1` runs the generic engine on `rules`; `plugin:<id>` runs an extractor from `registerIdentityExtractor`. */
|
|
@@ -1238,6 +1254,15 @@ type RegionFiscalId = {
|
|
|
1238
1254
|
invoice_uses: RegionFiscalEntry[];
|
|
1239
1255
|
/** Documents the buyer can upload; absent on older servers. */
|
|
1240
1256
|
documents?: IdentityDocumentSpec[];
|
|
1257
|
+
/**
|
|
1258
|
+
* Person type -> pattern its tax ids follow (contract 1.9), so the SDK tells the type from DATA instead of a function
|
|
1259
|
+
* each store injects. Absent: not derived. See `personTypeFromPatterns` (`@asteby/storefront-react/fiscal`).
|
|
1260
|
+
*/
|
|
1261
|
+
person_patterns?: Record<string, string>;
|
|
1262
|
+
/** Name of the pack's optional check algorithm (a warning at most, never a block). */
|
|
1263
|
+
checksum?: string | null;
|
|
1264
|
+
/** The invoice use the organization prefers by default; it wins over `suggested_for_regimes`. */
|
|
1265
|
+
default_invoice_use?: string | null;
|
|
1241
1266
|
};
|
|
1242
1267
|
type RegionPaymentMethod = {
|
|
1243
1268
|
code: string;
|
|
@@ -1328,6 +1353,26 @@ type FiscalIdentity = {
|
|
|
1328
1353
|
type FiscalIdentityInput = Omit<FiscalIdentity, 'verification' | 'country_code'> & {
|
|
1329
1354
|
country_code?: string;
|
|
1330
1355
|
};
|
|
1356
|
+
/**
|
|
1357
|
+
* A saved fiscal profile of the buyer (contract 1.9; up to `capabilities.fiscal_profiles.max`, one is the default).
|
|
1358
|
+
* Personal data: show the tax id masked in lists (`maskTaxId`), never log it.
|
|
1359
|
+
*/
|
|
1360
|
+
type FiscalProfile = FiscalIdentity & {
|
|
1361
|
+
id: string;
|
|
1362
|
+
/** Name the buyer gave it ("Personal", "My company"). */
|
|
1363
|
+
label: string;
|
|
1364
|
+
/** Derived by the server from the region's data; `null` when the region defines none. */
|
|
1365
|
+
person_type?: string | null;
|
|
1366
|
+
is_default: boolean;
|
|
1367
|
+
last_used_at?: string | null;
|
|
1368
|
+
created_at: string;
|
|
1369
|
+
updated_at: string;
|
|
1370
|
+
};
|
|
1371
|
+
/** Create or edit a profile. The server derives `person_type` and sets `verification`; the client cannot. */
|
|
1372
|
+
type FiscalProfileInput = Partial<FiscalIdentityInput> & {
|
|
1373
|
+
label?: string;
|
|
1374
|
+
is_default?: boolean;
|
|
1375
|
+
};
|
|
1331
1376
|
/** `PATCH /customer`. `fiscal: null` deletes the saved fiscal data (ARCO). */
|
|
1332
1377
|
type CustomerUpdateInput = {
|
|
1333
1378
|
first_name?: string | null;
|
|
@@ -1397,4 +1442,4 @@ type IdentityRulesV1 = {
|
|
|
1397
1442
|
fields: IdentityFieldRule[];
|
|
1398
1443
|
};
|
|
1399
1444
|
|
|
1400
|
-
export type {
|
|
1445
|
+
export type { IdentityCapture as $, Address as A, CustomerCapabilities as B, Cart as C, CustomerIdentifier as D, CustomerPasswordLoginInput as E, CustomerRegisterInput as F, CustomerRegisterResult as G, CustomerResetPasswordInput as H, CustomerSession as I, CustomerSessionInput as J, CustomerSetPasswordInput as K, CustomerUpdateInput as L, CustomerVerifyRegistrationInput as M, DeclineCode as N, DeliveryInput as O, DeliveryMethod as P, DeliveryOptions as Q, Facet as R, FacetValue as S, FiscalDocumentEvidence as T, FiscalDocumentSource as U, FiscalIdentity as V, FiscalIdentityInput as W, FiscalProfile as X, FiscalProfileInput as Y, FiscalVerification as Z, GeoHint as _, AddressInput as a, ProductOption as a$, IdentityDocumentSpec as a0, IdentityFieldRule as a1, IdentityRulesV1 as a2, IdentityStrategy as a3, Image as a4, InsufficientStockDetails as a5, InsufficientStockLine as a6, InvoiceAction as a7, InvoiceDoc as a8, InvoiceFile as a9, OrderStepKey as aA, OrderStepState as aB, Page as aC, PageInfo as aD, PaymentAction as aE, PaymentAttemptResult as aF, PaymentAttemptStatus as aG, PaymentClient as aH, PaymentClientCsp as aI, PaymentConfig as aJ, PaymentFlow as aK, PaymentInfo as aL, PaymentMethod as aM, PaymentMethods as aN, PaymentNextStep as aO, PaymentOption as aP, PaymentOptionKey as aQ, PaymentPoint as aR, PaymentSubmitInput as aS, PaymentVoucher as aT, PendingPayment as aU, PendingPaymentVoucher as aV, PickupOption as aW, Product as aX, ProductAttributeValue as aY, ProductCategory as aZ, ProductConnection as a_, InvoiceFileKind as aa, InvoiceRequest as ab, InvoiceResult as ac, InvoiceStage as ad, InvoiceSummary as ae, InvoicingCapabilities as af, Location as ag, LocationContacts as ah, LocationKind as ai, LocationListParams as aj, LocationPickup as ak, Menu as al, MenuItem as am, Money as an, MoneyRange as ao, NearestLocation as ap, NextAction as aq, NextActionKind as ar, Order as as, OrderLine as at, OrderPickup as au, OrderProblem as av, OrderProgress as aw, OrderProgressStep as ax, OrderSection as ay, OrderStage as az, Article as b, ProductSort as b0, ProductVariant as b1, PromotionAnnouncement as b2, PromotionReward as b3, PromotionTier as b4, PromotionsList as b5, RecommendationPlacement as b6, Refund as b7, Region as b8, RegionFiscalEntry as b9, UnavailableRateProvider as bA, RegionFiscalId as ba, RegionPaymentMethod as bb, RegionPostalCode as bc, RestockSubscriptionInput as bd, RestockSubscriptionResult as be, ReturnRequest as bf, ReturnRequestInput as bg, SEO as bh, Section as bi, SelectedOption as bj, Shipment as bk, ShipmentEvent as bl, ShipmentKind as bm, ShipmentMap as bn, ShipmentStatus as bo, ShipmentsSummary as bp, ShippingRate as bq, Shop as br, ShopBranch as bs, ShopContact as bt, ShopPolicies as bu, StockLevel as bv, StorefrontErrorBody as bw, StorefrontErrorCode as bx, Theme as by, TokenIntrospection as bz, Availability as c, AvailabilityStatus as d, CartBuyer as e, CartBuyerInput as f, CartCost as g, CartDelivery as h, CartDiscountCode as i, CartDiscountLine as j, CartInvoice as k, CartLine as l, CartLineInput as m, CartLineMerchandise as n, CartLineProblem as o, CartLineUpdateInput as p, CartPromotions as q, CartRecommendation as r, CartRecommendations as s, CheckoutInfo as t, CheckoutInput as u, CheckoutPayment as v, CheckoutResult as w, Collection as x, Connection as y, Customer as z };
|
|
@@ -426,6 +426,8 @@ type InvoiceRequest = {
|
|
|
426
426
|
invoice_use?: string;
|
|
427
427
|
/** Also save the data to the buyer's account (needs a session). */
|
|
428
428
|
save?: boolean;
|
|
429
|
+
/** Saved fiscal profile the data comes from (contract 1.9; needs a session; `404` when it is not the buyer's). */
|
|
430
|
+
profile_id?: string;
|
|
429
431
|
[key: string]: unknown;
|
|
430
432
|
};
|
|
431
433
|
type CheckoutInput = {
|
|
@@ -525,6 +527,10 @@ type CustomerCapabilities = {
|
|
|
525
527
|
unavailable_reason?: 'missing_scope' | (string & {});
|
|
526
528
|
/** Scopes the token lacks (e.g. `customer:write`) when `unavailable_reason` is `missing_scope`. */
|
|
527
529
|
missing_scopes?: string[];
|
|
530
|
+
/** Saved fiscal profiles (contract 1.9). Absent on older servers: the section does not exist. */
|
|
531
|
+
fiscal_profiles?: {
|
|
532
|
+
max: number;
|
|
533
|
+
};
|
|
528
534
|
};
|
|
529
535
|
/** `GET {gateway}/_token`: what the token in use is and what it can do. Needs no scope. */
|
|
530
536
|
type TokenIntrospection = {
|
|
@@ -1196,6 +1202,11 @@ type RegionFiscalEntry = {
|
|
|
1196
1202
|
allowed_regimes?: string[];
|
|
1197
1203
|
/** Folded phrases that identify the entry in a document (`catalog_phrases`); without them the label is used. */
|
|
1198
1204
|
match_phrases?: string[];
|
|
1205
|
+
/**
|
|
1206
|
+
* Invoice uses only (contract 1.9): the regimes this use is SUGGESTED for. Region data, never a rule: the buyer can
|
|
1207
|
+
* change it and `allowed_regimes` still validates.
|
|
1208
|
+
*/
|
|
1209
|
+
suggested_for_regimes?: string[];
|
|
1199
1210
|
};
|
|
1200
1211
|
/**
|
|
1201
1212
|
* A document the buyer can upload to prefill their fiscal data, with the rules to read it. Published by the
|
|
@@ -1212,6 +1223,11 @@ type IdentityDocumentSpec = {
|
|
|
1212
1223
|
obtain_url?: string;
|
|
1213
1224
|
/** MIME types the document comes in (the SDK reads PDFs). */
|
|
1214
1225
|
accept: string[];
|
|
1226
|
+
/**
|
|
1227
|
+
* What can be read from a PHOTO of the document (contract 1.9): `qr_only` (the QR: tax id and document id) or
|
|
1228
|
+
* `full`. Absent or `none`: files only.
|
|
1229
|
+
*/
|
|
1230
|
+
image_mode?: 'none' | 'qr_only' | 'full';
|
|
1215
1231
|
max_bytes: number;
|
|
1216
1232
|
max_pages?: number;
|
|
1217
1233
|
/** `rules@1` runs the generic engine on `rules`; `plugin:<id>` runs an extractor from `registerIdentityExtractor`. */
|
|
@@ -1238,6 +1254,15 @@ type RegionFiscalId = {
|
|
|
1238
1254
|
invoice_uses: RegionFiscalEntry[];
|
|
1239
1255
|
/** Documents the buyer can upload; absent on older servers. */
|
|
1240
1256
|
documents?: IdentityDocumentSpec[];
|
|
1257
|
+
/**
|
|
1258
|
+
* Person type -> pattern its tax ids follow (contract 1.9), so the SDK tells the type from DATA instead of a function
|
|
1259
|
+
* each store injects. Absent: not derived. See `personTypeFromPatterns` (`@asteby/storefront-react/fiscal`).
|
|
1260
|
+
*/
|
|
1261
|
+
person_patterns?: Record<string, string>;
|
|
1262
|
+
/** Name of the pack's optional check algorithm (a warning at most, never a block). */
|
|
1263
|
+
checksum?: string | null;
|
|
1264
|
+
/** The invoice use the organization prefers by default; it wins over `suggested_for_regimes`. */
|
|
1265
|
+
default_invoice_use?: string | null;
|
|
1241
1266
|
};
|
|
1242
1267
|
type RegionPaymentMethod = {
|
|
1243
1268
|
code: string;
|
|
@@ -1328,6 +1353,26 @@ type FiscalIdentity = {
|
|
|
1328
1353
|
type FiscalIdentityInput = Omit<FiscalIdentity, 'verification' | 'country_code'> & {
|
|
1329
1354
|
country_code?: string;
|
|
1330
1355
|
};
|
|
1356
|
+
/**
|
|
1357
|
+
* A saved fiscal profile of the buyer (contract 1.9; up to `capabilities.fiscal_profiles.max`, one is the default).
|
|
1358
|
+
* Personal data: show the tax id masked in lists (`maskTaxId`), never log it.
|
|
1359
|
+
*/
|
|
1360
|
+
type FiscalProfile = FiscalIdentity & {
|
|
1361
|
+
id: string;
|
|
1362
|
+
/** Name the buyer gave it ("Personal", "My company"). */
|
|
1363
|
+
label: string;
|
|
1364
|
+
/** Derived by the server from the region's data; `null` when the region defines none. */
|
|
1365
|
+
person_type?: string | null;
|
|
1366
|
+
is_default: boolean;
|
|
1367
|
+
last_used_at?: string | null;
|
|
1368
|
+
created_at: string;
|
|
1369
|
+
updated_at: string;
|
|
1370
|
+
};
|
|
1371
|
+
/** Create or edit a profile. The server derives `person_type` and sets `verification`; the client cannot. */
|
|
1372
|
+
type FiscalProfileInput = Partial<FiscalIdentityInput> & {
|
|
1373
|
+
label?: string;
|
|
1374
|
+
is_default?: boolean;
|
|
1375
|
+
};
|
|
1331
1376
|
/** `PATCH /customer`. `fiscal: null` deletes the saved fiscal data (ARCO). */
|
|
1332
1377
|
type CustomerUpdateInput = {
|
|
1333
1378
|
first_name?: string | null;
|
|
@@ -1397,4 +1442,4 @@ type IdentityRulesV1 = {
|
|
|
1397
1442
|
fields: IdentityFieldRule[];
|
|
1398
1443
|
};
|
|
1399
1444
|
|
|
1400
|
-
export type {
|
|
1445
|
+
export type { IdentityCapture as $, Address as A, CustomerCapabilities as B, Cart as C, CustomerIdentifier as D, CustomerPasswordLoginInput as E, CustomerRegisterInput as F, CustomerRegisterResult as G, CustomerResetPasswordInput as H, CustomerSession as I, CustomerSessionInput as J, CustomerSetPasswordInput as K, CustomerUpdateInput as L, CustomerVerifyRegistrationInput as M, DeclineCode as N, DeliveryInput as O, DeliveryMethod as P, DeliveryOptions as Q, Facet as R, FacetValue as S, FiscalDocumentEvidence as T, FiscalDocumentSource as U, FiscalIdentity as V, FiscalIdentityInput as W, FiscalProfile as X, FiscalProfileInput as Y, FiscalVerification as Z, GeoHint as _, AddressInput as a, ProductOption as a$, IdentityDocumentSpec as a0, IdentityFieldRule as a1, IdentityRulesV1 as a2, IdentityStrategy as a3, Image as a4, InsufficientStockDetails as a5, InsufficientStockLine as a6, InvoiceAction as a7, InvoiceDoc as a8, InvoiceFile as a9, OrderStepKey as aA, OrderStepState as aB, Page as aC, PageInfo as aD, PaymentAction as aE, PaymentAttemptResult as aF, PaymentAttemptStatus as aG, PaymentClient as aH, PaymentClientCsp as aI, PaymentConfig as aJ, PaymentFlow as aK, PaymentInfo as aL, PaymentMethod as aM, PaymentMethods as aN, PaymentNextStep as aO, PaymentOption as aP, PaymentOptionKey as aQ, PaymentPoint as aR, PaymentSubmitInput as aS, PaymentVoucher as aT, PendingPayment as aU, PendingPaymentVoucher as aV, PickupOption as aW, Product as aX, ProductAttributeValue as aY, ProductCategory as aZ, ProductConnection as a_, InvoiceFileKind as aa, InvoiceRequest as ab, InvoiceResult as ac, InvoiceStage as ad, InvoiceSummary as ae, InvoicingCapabilities as af, Location as ag, LocationContacts as ah, LocationKind as ai, LocationListParams as aj, LocationPickup as ak, Menu as al, MenuItem as am, Money as an, MoneyRange as ao, NearestLocation as ap, NextAction as aq, NextActionKind as ar, Order as as, OrderLine as at, OrderPickup as au, OrderProblem as av, OrderProgress as aw, OrderProgressStep as ax, OrderSection as ay, OrderStage as az, Article as b, ProductSort as b0, ProductVariant as b1, PromotionAnnouncement as b2, PromotionReward as b3, PromotionTier as b4, PromotionsList as b5, RecommendationPlacement as b6, Refund as b7, Region as b8, RegionFiscalEntry as b9, UnavailableRateProvider as bA, RegionFiscalId as ba, RegionPaymentMethod as bb, RegionPostalCode as bc, RestockSubscriptionInput as bd, RestockSubscriptionResult as be, ReturnRequest as bf, ReturnRequestInput as bg, SEO as bh, Section as bi, SelectedOption as bj, Shipment as bk, ShipmentEvent as bl, ShipmentKind as bm, ShipmentMap as bn, ShipmentStatus as bo, ShipmentsSummary as bp, ShippingRate as bq, Shop as br, ShopBranch as bs, ShopContact as bt, ShopPolicies as bu, StockLevel as bv, StorefrontErrorBody as bw, StorefrontErrorCode as bx, Theme as by, TokenIntrospection as bz, Availability as c, AvailabilityStatus as d, CartBuyer as e, CartBuyerInput as f, CartCost as g, CartDelivery as h, CartDiscountCode as i, CartDiscountLine as j, CartInvoice as k, CartLine as l, CartLineInput as m, CartLineMerchandise as n, CartLineProblem as o, CartLineUpdateInput as p, CartPromotions as q, CartRecommendation as r, CartRecommendations as s, CheckoutInfo as t, CheckoutInput as u, CheckoutPayment as v, CheckoutResult as w, Collection as x, Connection as y, Customer as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Typed client for the Storefront API v1 (catalog, cart, checkout, customer, content) using only global fetch — Node 20+, edge runtimes and browsers — plus an in-memory mock of the whole contract and, in `@asteby/storefront/fiscal-document`, a country-agnostic engine that reads a buyer's fiscal document (PDF) in the browser or Node.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|