@asteby/storefront 0.9.0 → 0.11.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/README.md +181 -4
- package/dist/cli.js +665 -0
- package/dist/fiscal-document.cjs +659 -0
- package/dist/fiscal-document.cjs.map +1 -0
- package/dist/fiscal-document.d.cts +215 -0
- package/dist/fiscal-document.d.ts +215 -0
- package/dist/fiscal-document.js +641 -0
- package/dist/fiscal-document.js.map +1 -0
- package/dist/index.cjs +111 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -5
- package/dist/index.d.ts +76 -5
- package/dist/index.js +109 -6
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +1185 -11
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +51 -2
- package/dist/mock.d.ts +51 -2
- package/dist/mock.js +1182 -12
- 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 +243 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +100 -0
- package/dist/node.d.ts +100 -0
- package/dist/node.js +209 -0
- package/dist/node.js.map +1 -0
- package/dist/{types-CSMuPSQA.d.cts → types-C-Ley-Mt.d.cts} +333 -3
- package/dist/{types-iGGZ9EiC.d.ts → types-D7UJxrba.d.ts} +333 -3
- package/package.json +41 -3
|
@@ -318,6 +318,8 @@ type Cart = {
|
|
|
318
318
|
note?: string | null;
|
|
319
319
|
/** Automatic-discount tiers and free-shipping progress (contract 1.2); `null`/absent without the promotions addon. */
|
|
320
320
|
promotions?: CartPromotions | null;
|
|
321
|
+
/** Invoice the buyer asked for (`carts.setInvoice`); `null`/absent when none. */
|
|
322
|
+
invoice?: CartInvoice | null;
|
|
321
323
|
updated_at: string;
|
|
322
324
|
};
|
|
323
325
|
type CartLineInput = {
|
|
@@ -395,20 +397,31 @@ type DeliveryInput = {
|
|
|
395
397
|
rate_id?: string;
|
|
396
398
|
branch_id?: string;
|
|
397
399
|
};
|
|
400
|
+
/**
|
|
401
|
+
* Fiscal data the buyer asks an invoice for. The Spanish aliases are still accepted by the API.
|
|
402
|
+
* `document` is the evidence of where the data came from (never the document itself).
|
|
403
|
+
*/
|
|
398
404
|
type InvoiceRequest = {
|
|
399
405
|
requested?: boolean;
|
|
400
406
|
tax_id?: string;
|
|
401
407
|
legal_name?: string;
|
|
402
408
|
tax_regime?: string;
|
|
403
|
-
/**
|
|
409
|
+
/** Invoice use; the region says which are allowed for `tax_regime`. */
|
|
404
410
|
use?: string;
|
|
405
411
|
postal_code?: string;
|
|
412
|
+
/** Defaults to the market's country. */
|
|
413
|
+
country_code?: string;
|
|
414
|
+
document?: FiscalDocumentEvidence;
|
|
406
415
|
/** Spanish aliases the API also accepts. */
|
|
407
416
|
rfc?: string;
|
|
408
417
|
razon_social?: string;
|
|
409
418
|
regimen?: string;
|
|
410
419
|
uso_cfdi?: string;
|
|
411
420
|
cp?: string;
|
|
421
|
+
/** Alias of `use`. */
|
|
422
|
+
invoice_use?: string;
|
|
423
|
+
/** Also save the data to the buyer's account (needs a session). */
|
|
424
|
+
save?: boolean;
|
|
412
425
|
[key: string]: unknown;
|
|
413
426
|
};
|
|
414
427
|
type CheckoutInput = {
|
|
@@ -472,6 +485,8 @@ type Customer = {
|
|
|
472
485
|
first_name: string | null;
|
|
473
486
|
last_name: string | null;
|
|
474
487
|
default_address_id: string | null;
|
|
488
|
+
/** Saved fiscal data; `null`/absent when none. */
|
|
489
|
+
fiscal?: FiscalIdentity | null;
|
|
475
490
|
created_at: string;
|
|
476
491
|
};
|
|
477
492
|
type CustomerIdentifier = {
|
|
@@ -489,6 +504,65 @@ type CustomerSession = {
|
|
|
489
504
|
expires_at: string;
|
|
490
505
|
customer: Customer;
|
|
491
506
|
};
|
|
507
|
+
/** What the store's buyer accounts support (`GET /storefront/customer/capabilities`). Cache briefly, not forever. */
|
|
508
|
+
type CustomerCapabilities = {
|
|
509
|
+
/** Email + password registration and login are enabled. */
|
|
510
|
+
password: boolean;
|
|
511
|
+
/** Registration needs an emailed code (`customer.verifyRegistration`) before the account exists. */
|
|
512
|
+
email_verification: boolean;
|
|
513
|
+
/** Channels `customer.requestOtp` can deliver the code through. */
|
|
514
|
+
otp_channels: ('email' | 'whatsapp')[];
|
|
515
|
+
/** What invoicing the store offers. Absent on older servers: treat as `available: false`. */
|
|
516
|
+
invoicing?: InvoicingCapabilities;
|
|
517
|
+
/**
|
|
518
|
+
* Why a way of signing in is off. `missing_scope`: the store's token lacks a scope (see `missing_scopes`), so
|
|
519
|
+
* the store is misconfigured; it is not a choice of the merchant. Absent when everything is as configured.
|
|
520
|
+
*/
|
|
521
|
+
unavailable_reason?: 'missing_scope' | (string & {});
|
|
522
|
+
/** Scopes the token lacks (e.g. `customer:write`) when `unavailable_reason` is `missing_scope`. */
|
|
523
|
+
missing_scopes?: string[];
|
|
524
|
+
};
|
|
525
|
+
/** `GET {gateway}/_token`: what the token in use is and what it can do. Needs no scope. */
|
|
526
|
+
type TokenIntrospection = {
|
|
527
|
+
kind: string;
|
|
528
|
+
environment: 'sandbox' | 'production' | (string & {});
|
|
529
|
+
scopes: string[];
|
|
530
|
+
/** Scopes the connection should have but the token lacks. Empty when healthy. */
|
|
531
|
+
missing_scopes: string[];
|
|
532
|
+
connection_id: string | null;
|
|
533
|
+
expires_at: string | null;
|
|
534
|
+
};
|
|
535
|
+
type CustomerRegisterInput = {
|
|
536
|
+
email: string;
|
|
537
|
+
password: string;
|
|
538
|
+
first_name?: string;
|
|
539
|
+
last_name?: string;
|
|
540
|
+
};
|
|
541
|
+
/** `verification_required`: a code was emailed, finish with `customer.verifyRegistration`. `created`: the account is ready and signed in. */
|
|
542
|
+
type CustomerRegisterResult = {
|
|
543
|
+
status: 'verification_required';
|
|
544
|
+
} | {
|
|
545
|
+
status: 'created';
|
|
546
|
+
session: CustomerSession;
|
|
547
|
+
};
|
|
548
|
+
type CustomerVerifyRegistrationInput = {
|
|
549
|
+
email: string;
|
|
550
|
+
code: string;
|
|
551
|
+
};
|
|
552
|
+
type CustomerPasswordLoginInput = {
|
|
553
|
+
email: string;
|
|
554
|
+
password: string;
|
|
555
|
+
};
|
|
556
|
+
/** `current_password` is required by the server when the account already has a password. */
|
|
557
|
+
type CustomerSetPasswordInput = {
|
|
558
|
+
password: string;
|
|
559
|
+
current_password?: string;
|
|
560
|
+
};
|
|
561
|
+
type CustomerResetPasswordInput = {
|
|
562
|
+
email: string;
|
|
563
|
+
code: string;
|
|
564
|
+
password: string;
|
|
565
|
+
};
|
|
492
566
|
type OrderLine = {
|
|
493
567
|
title: string;
|
|
494
568
|
variant_title: string | null;
|
|
@@ -505,6 +579,8 @@ type Order = {
|
|
|
505
579
|
created_at: string;
|
|
506
580
|
total: Money;
|
|
507
581
|
lines: OrderLine[];
|
|
582
|
+
/** Invoice state; absent on older servers. */
|
|
583
|
+
invoice?: InvoiceSummary;
|
|
508
584
|
};
|
|
509
585
|
type ReturnRequestInput = {
|
|
510
586
|
lines: {
|
|
@@ -518,9 +594,12 @@ type ReturnRequest = {
|
|
|
518
594
|
order_id: string;
|
|
519
595
|
status: string;
|
|
520
596
|
};
|
|
597
|
+
/** `200` issued, `202` pending. The 422 / 409 / 503 outcomes arrive as a `StorefrontError`. */
|
|
521
598
|
type InvoiceResult = {
|
|
522
599
|
status: string;
|
|
523
600
|
url?: string | null;
|
|
601
|
+
stage?: InvoiceStage;
|
|
602
|
+
invoice?: InvoiceSummary;
|
|
524
603
|
};
|
|
525
604
|
type Theme = {
|
|
526
605
|
/** Design tokens, e.g. `{ primary: '#0f766e', 'primary-foreground': '#ffffff' }`. */
|
|
@@ -562,7 +641,9 @@ type Article = {
|
|
|
562
641
|
published_at: string;
|
|
563
642
|
seo: SEO;
|
|
564
643
|
};
|
|
565
|
-
type StorefrontErrorCode = 'validation' | 'unauthorized' | 'forbidden' | 'not_found' | 'conflict' | 'insufficient_stock' | 'price_mismatch' | 'invalid_state' | 'rate_limited' | 'not_modified' | 'server_error' | 'network' | 'timeout' | 'aborted' | 'invalid_response'
|
|
644
|
+
type StorefrontErrorCode = 'validation' | 'unauthorized' | 'forbidden' | 'not_found' | 'conflict' | 'insufficient_stock' | 'price_mismatch' | 'invalid_state' | 'rate_limited' | 'not_modified' | 'server_error' | 'network' | 'timeout' | 'aborted' | 'invalid_response'
|
|
645
|
+
/** `403`: the token lacks a scope the route needs. `StorefrontError.requiredScopes` lists them. */
|
|
646
|
+
| 'insufficient_scope' | (string & {});
|
|
566
647
|
/** One affected line of a `409 insufficient_stock`. `line_id` is `null` when the line did not exist yet (add). */
|
|
567
648
|
type InsufficientStockLine = {
|
|
568
649
|
line_id: string | null;
|
|
@@ -580,6 +661,7 @@ type StorefrontErrorBody = {
|
|
|
580
661
|
message: string;
|
|
581
662
|
field?: string;
|
|
582
663
|
details?: unknown;
|
|
664
|
+
required_scopes?: string[];
|
|
583
665
|
};
|
|
584
666
|
};
|
|
585
667
|
type RestockSubscriptionInput = {
|
|
@@ -831,5 +913,253 @@ type PromotionsList = {
|
|
|
831
913
|
nodes: unknown[];
|
|
832
914
|
announcements: PromotionAnnouncement[];
|
|
833
915
|
};
|
|
916
|
+
/** Where an invoice is. `needs_data`: the buyer must fix something. `needs_review`: the store must act. */
|
|
917
|
+
type InvoiceStage = 'not_requested' | 'requested' | 'awaiting_payment' | 'queued' | 'issuing' | 'issued' | 'cancelled' | 'needs_data' | 'retrying' | 'needs_review' | 'window_closed' | (string & {});
|
|
918
|
+
/** What the buyer can do next about an invoice. */
|
|
919
|
+
type InvoiceAction = 'none' | 'request' | 'wait' | 'correct_data' | 'download' | 'contact_store' | (string & {});
|
|
920
|
+
type InvoiceSummary = {
|
|
921
|
+
/** Single-word status (`requested`, `issued`...). Prefer `stage`. */
|
|
922
|
+
status: string;
|
|
923
|
+
stage?: InvoiceStage;
|
|
924
|
+
requested?: boolean;
|
|
925
|
+
/** Machine-readable cause when `stage` is `needs_data` / `needs_review` (e.g. `invoice.tax_regime`). */
|
|
926
|
+
reason_code?: string | null;
|
|
927
|
+
action?: InvoiceAction;
|
|
928
|
+
/** The buyer may ask for it now. */
|
|
929
|
+
can_request?: boolean;
|
|
930
|
+
/** Why `can_request` is `false` (e.g. `awaiting_payment`, `window_closed`, `not_invoiceable`). */
|
|
931
|
+
blocked_reason?: string | null;
|
|
932
|
+
/** Fiscal folio (UUID in Mexico) once issued. */
|
|
933
|
+
folio?: string | null;
|
|
934
|
+
/** Signed, short-lived download links. */
|
|
935
|
+
url?: string | null;
|
|
936
|
+
xml_url?: string | null;
|
|
937
|
+
};
|
|
938
|
+
/** The invoice request of a cart (`Cart.invoice`). The tax id is masked: the full value is never echoed back. */
|
|
939
|
+
type CartInvoice = {
|
|
940
|
+
requested: boolean;
|
|
941
|
+
tax_id_masked?: string | null;
|
|
942
|
+
legal_name?: string | null;
|
|
943
|
+
country_code?: string | null;
|
|
944
|
+
/** `IdentityDocumentSpec.kind` the data was read from, when it was. */
|
|
945
|
+
document_kind?: string | null;
|
|
946
|
+
};
|
|
947
|
+
type InvoicingCapabilities = {
|
|
948
|
+
available: boolean;
|
|
949
|
+
/** Countries (ISO 3166-1 alpha-2) the store can invoice for. */
|
|
950
|
+
countries: string[];
|
|
951
|
+
/** `optional`: the checkout offers "I need an invoice". `off`: invoices can only be requested afterwards. */
|
|
952
|
+
checkout: 'off' | 'optional';
|
|
953
|
+
/** Invoices can be requested after the purchase (`customer.requestInvoice`). */
|
|
954
|
+
post_purchase: boolean;
|
|
955
|
+
/** Days after the purchase in which an invoice can still be requested. */
|
|
956
|
+
window_days?: number;
|
|
957
|
+
/** `IdentityDocumentSpec.kind` values the buyer can upload to prefill the data. */
|
|
958
|
+
identity_documents: string[];
|
|
959
|
+
/** The store can check the data against the tax authority online (informative, never blocks). */
|
|
960
|
+
online_verify: boolean;
|
|
961
|
+
};
|
|
962
|
+
/** One regime or invoice use of the region's fiscal catalog. */
|
|
963
|
+
type RegionFiscalEntry = {
|
|
964
|
+
code: string;
|
|
965
|
+
label: string;
|
|
966
|
+
label_en?: string;
|
|
967
|
+
/** Region-defined (`individual`, `company`...); compare as opaque strings. */
|
|
968
|
+
person_types: string[];
|
|
969
|
+
/** Invoice uses only: the regimes that may use it. Absent: any. */
|
|
970
|
+
allowed_regimes?: string[];
|
|
971
|
+
/** Folded phrases that identify the entry in a document (`catalog_phrases`); without them the label is used. */
|
|
972
|
+
match_phrases?: string[];
|
|
973
|
+
};
|
|
974
|
+
/**
|
|
975
|
+
* A document the buyer can upload to prefill their fiscal data, with the rules to read it. Published by the
|
|
976
|
+
* region in `fiscal_id.documents[]` (texts already in the response locale); the SDK engine knows no country.
|
|
977
|
+
*/
|
|
978
|
+
type IdentityDocumentSpec = {
|
|
979
|
+
/** `<COUNTRY>:<kind>`. */
|
|
980
|
+
kind: string;
|
|
981
|
+
country_code?: string;
|
|
982
|
+
label: string;
|
|
983
|
+
/** Explanation for the buyer; absent when the region has none in the response language. */
|
|
984
|
+
help?: string;
|
|
985
|
+
/** Where the buyer gets the document from the authority. */
|
|
986
|
+
obtain_url?: string;
|
|
987
|
+
/** MIME types the document comes in (the SDK reads PDFs). */
|
|
988
|
+
accept: string[];
|
|
989
|
+
max_bytes: number;
|
|
990
|
+
max_pages?: number;
|
|
991
|
+
/** `rules@1` runs the generic engine on `rules`; `plugin:<id>` runs an extractor from `registerIdentityExtractor`. */
|
|
992
|
+
engine: 'rules@1' | `plugin:${string}` | (string & {});
|
|
993
|
+
/** The `rules@1` rules (the API publishes them as an object; JSON text is accepted too). */
|
|
994
|
+
rules?: IdentityRulesV1 | string | null;
|
|
995
|
+
/** How the server can check the document against the authority (e.g. `qr_validator`). Informative. */
|
|
996
|
+
verify_kind?: string;
|
|
997
|
+
/** Days after `issued_on` in which the document counts as fresh. */
|
|
998
|
+
freshness_days?: number;
|
|
999
|
+
/** Fields the extractor never returns (sensitive data the store has no use for). */
|
|
1000
|
+
discard_fields: string[];
|
|
1001
|
+
};
|
|
1002
|
+
/** Region fiscal identity (`Region.fiscal_id`). */
|
|
1003
|
+
type RegionFiscalId = {
|
|
1004
|
+
/** Name of the tax id (`RFC`, `EIN`...). */
|
|
1005
|
+
kind: string;
|
|
1006
|
+
label: string;
|
|
1007
|
+
/** Regular expression a valid tax id matches. */
|
|
1008
|
+
pattern?: string;
|
|
1009
|
+
/** Generic ids valid without a document (e.g. the national generic public id). */
|
|
1010
|
+
generic_ids: string[];
|
|
1011
|
+
regimes: RegionFiscalEntry[];
|
|
1012
|
+
invoice_uses: RegionFiscalEntry[];
|
|
1013
|
+
/** Documents the buyer can upload; absent on older servers. */
|
|
1014
|
+
documents?: IdentityDocumentSpec[];
|
|
1015
|
+
};
|
|
1016
|
+
type RegionPaymentMethod = {
|
|
1017
|
+
code: string;
|
|
1018
|
+
label: string;
|
|
1019
|
+
description?: string;
|
|
1020
|
+
kind: string;
|
|
1021
|
+
flow: string;
|
|
1022
|
+
providers: string[];
|
|
1023
|
+
installments: {
|
|
1024
|
+
months: number[];
|
|
1025
|
+
min_amount: Money | null;
|
|
1026
|
+
} | null;
|
|
1027
|
+
min_amount: Money | null;
|
|
1028
|
+
max_amount: Money | null;
|
|
1029
|
+
expires_hours?: number;
|
|
1030
|
+
icon?: string;
|
|
1031
|
+
/** Payment forms the invoice may report for this method, comma separated; the first is the default (e.g. `04,28`). */
|
|
1032
|
+
fiscal_payment_form?: string;
|
|
1033
|
+
};
|
|
1034
|
+
/** `GET /storefront/region`: how the market formats, taxes, addresses and invoices. */
|
|
1035
|
+
type Region = {
|
|
1036
|
+
country_code: string;
|
|
1037
|
+
name: string;
|
|
1038
|
+
locale: {
|
|
1039
|
+
default: string;
|
|
1040
|
+
available: string[];
|
|
1041
|
+
current: string;
|
|
1042
|
+
};
|
|
1043
|
+
timezone?: string;
|
|
1044
|
+
currency: Record<string, unknown>;
|
|
1045
|
+
formats?: Record<string, unknown>;
|
|
1046
|
+
tax: Record<string, unknown>;
|
|
1047
|
+
address?: {
|
|
1048
|
+
postal_code?: {
|
|
1049
|
+
pattern: string;
|
|
1050
|
+
example?: string;
|
|
1051
|
+
};
|
|
1052
|
+
[key: string]: unknown;
|
|
1053
|
+
};
|
|
1054
|
+
subdivisions?: Record<string, unknown>[];
|
|
1055
|
+
phone?: Record<string, unknown>;
|
|
1056
|
+
fiscal_id?: RegionFiscalId;
|
|
1057
|
+
payment_methods?: RegionPaymentMethod[];
|
|
1058
|
+
};
|
|
1059
|
+
/** Where the fiscal data came from. `manual`: typed by the buyer. */
|
|
1060
|
+
type FiscalDocumentSource = 'pdf_client' | 'pdf_server' | 'qr' | 'manual';
|
|
1061
|
+
/** What is kept about the document the data was read from. Never the document itself. */
|
|
1062
|
+
type FiscalDocumentEvidence = {
|
|
1063
|
+
/** `IdentityDocumentSpec.kind`. */
|
|
1064
|
+
kind: string;
|
|
1065
|
+
/** The authority's id of the document. */
|
|
1066
|
+
document_id?: string | null;
|
|
1067
|
+
/** ISO date the authority issued it. */
|
|
1068
|
+
issued_on?: string | null;
|
|
1069
|
+
/** SHA-256 of the file, lowercase hex. */
|
|
1070
|
+
sha256?: string | null;
|
|
1071
|
+
/** Engine that read it, e.g. `rules@1`. */
|
|
1072
|
+
extractor?: string;
|
|
1073
|
+
source: FiscalDocumentSource;
|
|
1074
|
+
/** The QR agreed with the text: `true`/`false`, `null` when there was no QR to compare. */
|
|
1075
|
+
qr_match?: boolean | null;
|
|
1076
|
+
};
|
|
1077
|
+
type FiscalVerification = {
|
|
1078
|
+
/** `reviewed` (the buyer confirmed it), `verified`, `mismatch`, `unverified`, `stale`. */
|
|
1079
|
+
status: 'reviewed' | 'verified' | 'mismatch' | 'unverified' | 'stale' | (string & {});
|
|
1080
|
+
checked_at?: string | null;
|
|
1081
|
+
};
|
|
1082
|
+
/** Fiscal data as stored for a buyer. */
|
|
1083
|
+
type FiscalIdentity = {
|
|
1084
|
+
country_code: string;
|
|
1085
|
+
tax_id: string;
|
|
1086
|
+
legal_name: string;
|
|
1087
|
+
tax_regime: string;
|
|
1088
|
+
postal_code: string;
|
|
1089
|
+
invoice_use?: string | null;
|
|
1090
|
+
document?: FiscalDocumentEvidence | null;
|
|
1091
|
+
verification?: FiscalVerification | null;
|
|
1092
|
+
};
|
|
1093
|
+
type FiscalIdentityInput = Omit<FiscalIdentity, 'verification' | 'country_code'> & {
|
|
1094
|
+
country_code?: string;
|
|
1095
|
+
};
|
|
1096
|
+
/** `PATCH /customer`. `fiscal: null` deletes the saved fiscal data (ARCO). */
|
|
1097
|
+
type CustomerUpdateInput = {
|
|
1098
|
+
first_name?: string | null;
|
|
1099
|
+
last_name?: string | null;
|
|
1100
|
+
phone?: string | null;
|
|
1101
|
+
fiscal?: FiscalIdentityInput | null;
|
|
1102
|
+
};
|
|
1103
|
+
/** Post-processing: the value must match `pattern`; `group` of it replaces the value. */
|
|
1104
|
+
type IdentityCapture = {
|
|
1105
|
+
pattern: string;
|
|
1106
|
+
flags?: string;
|
|
1107
|
+
group?: number;
|
|
1108
|
+
};
|
|
1109
|
+
/**
|
|
1110
|
+
* One way to find a field. Only the members of its `strategy` apply:
|
|
1111
|
+
* `regex` (`pattern`, `flags`, `group`), `labeled_lines` (`label`), `concat_labeled` (`labels`, `separator`),
|
|
1112
|
+
* `catalog_phrases` (`catalog`, `start`, `end`), `date` (`pattern` with three groups, `flags`, `order`, `months`),
|
|
1113
|
+
* `qr_param` (`param`, `split`, `parts`, `match`). Any strategy takes `upper` and `capture`.
|
|
1114
|
+
*/
|
|
1115
|
+
type IdentityStrategy = {
|
|
1116
|
+
strategy: 'regex' | 'labeled_lines' | 'concat_labeled' | 'catalog_phrases' | 'date' | 'qr_param';
|
|
1117
|
+
pattern?: string;
|
|
1118
|
+
/** `i`, `s`, `m`. */
|
|
1119
|
+
flags?: string;
|
|
1120
|
+
group?: number;
|
|
1121
|
+
label?: string;
|
|
1122
|
+
labels?: string[];
|
|
1123
|
+
separator?: string;
|
|
1124
|
+
catalog?: string;
|
|
1125
|
+
start?: string;
|
|
1126
|
+
end?: string;
|
|
1127
|
+
/** Permutation of `d`, `m`, `y`: the meaning of the three groups. */
|
|
1128
|
+
order?: string;
|
|
1129
|
+
/** 12 month names, to read a month written in text. */
|
|
1130
|
+
months?: string[];
|
|
1131
|
+
/** `qr_param` fallback for a QR read by a keyboard scanner that garbled the punctuation: a pattern over the raw text whose group `group` is the value. Runs when `param` finds nothing. */
|
|
1132
|
+
scan?: string;
|
|
1133
|
+
param?: string;
|
|
1134
|
+
split?: string;
|
|
1135
|
+
parts?: number;
|
|
1136
|
+
match?: string;
|
|
1137
|
+
upper?: boolean;
|
|
1138
|
+
capture?: IdentityCapture;
|
|
1139
|
+
};
|
|
1140
|
+
type IdentityFieldRule = {
|
|
1141
|
+
/** Output name: `tax_id`, `legal_name`, `postal_code`, `tax_regime`, `document_id`, `issued_on`... */
|
|
1142
|
+
key: string;
|
|
1143
|
+
/** Listed in `missing` when not found. */
|
|
1144
|
+
required?: boolean;
|
|
1145
|
+
/** A list (e.g. every regime the document names). */
|
|
1146
|
+
multiple?: boolean;
|
|
1147
|
+
/** Tried in order; the first non-empty value wins. `qr_param` ones only fill what the text lacks. */
|
|
1148
|
+
strategies: IdentityStrategy[];
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* `rules@1`, as the region publishes it (same semantics as the reference interpreter of the region packs). Text
|
|
1152
|
+
* is normalized (`nbsp`, `collapse_ws`), then each field is resolved. Patterns are in the subset common to Go
|
|
1153
|
+
* (RE2) and JavaScript: no lookaround, backreferences, named groups, inline flags or `\p`.
|
|
1154
|
+
*/
|
|
1155
|
+
type IdentityRulesV1 = {
|
|
1156
|
+
version: 1;
|
|
1157
|
+
normalize?: ('nbsp' | 'collapse_ws')[];
|
|
1158
|
+
/** Captions of the document (regex fragments, case-insensitive, followed by a colon). A labelled value ends at the next caption. */
|
|
1159
|
+
labels?: string[];
|
|
1160
|
+
/** Template of the canonical QR URL, rebuilt from the fields the QR carried (`{field}` placeholders). It survives readers that garble the URL. */
|
|
1161
|
+
qr_canonical?: string;
|
|
1162
|
+
fields: IdentityFieldRule[];
|
|
1163
|
+
};
|
|
834
1164
|
|
|
835
|
-
export type {
|
|
1165
|
+
export type { IdentityRulesV1 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, FiscalVerification as X, IdentityCapture as Y, IdentityDocumentSpec as Z, IdentityFieldRule as _, AddressInput as a, ShippingRate as a$, IdentityStrategy as a0, Image as a1, InsufficientStockDetails as a2, InsufficientStockLine as a3, InvoiceAction as a4, InvoiceRequest as a5, InvoiceResult as a6, InvoiceStage as a7, InvoiceSummary as a8, InvoicingCapabilities as a9, PaymentPoint as aA, PaymentSubmitInput as aB, PaymentVoucher as aC, PickupOption as aD, Product as aE, ProductAttributeValue as aF, ProductCategory as aG, ProductConnection as aH, ProductOption as aI, ProductSort as aJ, ProductVariant as aK, PromotionAnnouncement as aL, PromotionReward as aM, PromotionTier as aN, PromotionsList as aO, RecommendationPlacement as aP, Region as aQ, RegionFiscalEntry as aR, RegionFiscalId as aS, RegionPaymentMethod as aT, RestockSubscriptionInput as aU, RestockSubscriptionResult as aV, ReturnRequest as aW, ReturnRequestInput as aX, SEO as aY, Section as aZ, SelectedOption as a_, Location as aa, LocationContacts as ab, LocationKind as ac, LocationListParams as ad, LocationPickup as ae, Menu as af, MenuItem as ag, Money as ah, MoneyRange as ai, NearestLocation as aj, Order as ak, OrderLine as al, Page as am, PageInfo as an, PaymentAction as ao, PaymentAttemptResult as ap, PaymentAttemptStatus as aq, PaymentClient as ar, PaymentClientCsp as as, PaymentConfig as at, PaymentFlow as au, PaymentMethod as av, PaymentMethods as aw, PaymentNextStep as ax, PaymentOption as ay, PaymentOptionKey as az, Article as b, Shop as b0, ShopBranch as b1, ShopContact as b2, ShopPolicies as b3, StockLevel as b4, StorefrontErrorBody as b5, StorefrontErrorCode as b6, Theme as b7, TokenIntrospection as b8, UnavailableRateProvider as b9, 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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/storefront",
|
|
3
|
-
"version": "0.
|
|
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.",
|
|
3
|
+
"version": "0.11.0",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
@@ -57,6 +57,26 @@
|
|
|
57
57
|
"default": "./dist/mockup.cjs"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
+
"./fiscal-document": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/fiscal-document.d.ts",
|
|
63
|
+
"default": "./dist/fiscal-document.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/fiscal-document.d.cts",
|
|
67
|
+
"default": "./dist/fiscal-document.cjs"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./node": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/node.d.ts",
|
|
73
|
+
"default": "./dist/node.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/node.d.cts",
|
|
77
|
+
"default": "./dist/node.cjs"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
60
80
|
"./package.json": "./package.json"
|
|
61
81
|
},
|
|
62
82
|
"sideEffects": false,
|
|
@@ -64,7 +84,22 @@
|
|
|
64
84
|
"node": ">=20"
|
|
65
85
|
},
|
|
66
86
|
"dependencies": {},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"pdfjs-dist": ">=4.2.67",
|
|
89
|
+
"jsqr": "^1.4.0"
|
|
90
|
+
},
|
|
91
|
+
"peerDependenciesMeta": {
|
|
92
|
+
"pdfjs-dist": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"jsqr": {
|
|
96
|
+
"optional": true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
67
99
|
"devDependencies": {
|
|
100
|
+
"@types/node": "^22.0.0",
|
|
101
|
+
"jsqr": "^1.4.0",
|
|
102
|
+
"pdfjs-dist": "^5.7.284",
|
|
68
103
|
"tsup": "^8.3.5",
|
|
69
104
|
"typescript": "^6.0.0",
|
|
70
105
|
"vitest": "^4.0.0"
|
|
@@ -72,8 +107,11 @@
|
|
|
72
107
|
"publishConfig": {
|
|
73
108
|
"access": "public"
|
|
74
109
|
},
|
|
110
|
+
"bin": {
|
|
111
|
+
"storefront": "./dist/cli.js"
|
|
112
|
+
},
|
|
75
113
|
"scripts": {
|
|
76
|
-
"build": "tsup",
|
|
114
|
+
"build": "rm -rf dist && tsup",
|
|
77
115
|
"dev": "tsup --watch",
|
|
78
116
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
79
117
|
"test": "vitest run",
|