@asteby/storefront 0.10.0 → 0.11.1

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/mock.js CHANGED
@@ -1,6 +1,949 @@
1
1
  import { resolveAvailability } from './chunk-HBSB7XS2.js';
2
2
  import { isValidPoint, rankByDistance } from './chunk-45R47HYO.js';
3
3
 
4
+ // src/mock/region-mx.seed.ts
5
+ var SEED_MX_CSF = {
6
+ "kind": "MX:csf",
7
+ "country_code": "MX",
8
+ "label": "Constancia de situaci\xF3n fiscal",
9
+ "help": "Es el PDF que te da el SAT con tu RFC, tu nombre o raz\xF3n social, tu r\xE9gimen y tu c\xF3digo postal fiscal. Lo leemos en tu dispositivo para llenar tus datos de facturaci\xF3n.",
10
+ "obtain_url": "https://www.sat.gob.mx/portal/public/tramites/constancia-de-situacion-fiscal",
11
+ "accept": [
12
+ "application/pdf"
13
+ ],
14
+ "max_bytes": 5242880,
15
+ "max_pages": 6,
16
+ "engine": "rules@1",
17
+ "rules": {
18
+ "version": 1,
19
+ "normalize": [
20
+ "nbsp",
21
+ "collapse_ws"
22
+ ],
23
+ "labels": [
24
+ "RFC",
25
+ "CURP",
26
+ "Nombre \\(s\\)",
27
+ "Nombre",
28
+ "Primer Apellido",
29
+ "Segundo Apellido",
30
+ "Denominaci[\xF3o]n\\s*/\\s*Raz[\xF3o]n Social",
31
+ "R[\xE9e]gimen de capital",
32
+ "Nombre Comercial",
33
+ "Fecha (?:de )?inicio de operaciones",
34
+ "Fecha de constituci[\xF3o]n",
35
+ "Estatus en el padr[\xF3o]n",
36
+ "Fecha de [\xFAu]ltimo cambio de estado",
37
+ "Datos del domicilio registrado",
38
+ "C[\xF3o]digo Postal",
39
+ "Tipo de Vialidad",
40
+ "Nombre de Vialidad",
41
+ "N[\xFAu]mero Exterior",
42
+ "N[\xFAu]mero Interior",
43
+ "Nombre de la Colonia",
44
+ "Nombre de la Localidad",
45
+ "Nombre del Municipio o Demarcaci[\xF3o]n Territorial",
46
+ "Nombre de la Entidad Federativa",
47
+ "Entre Calle",
48
+ "Y Calle",
49
+ "Actividades Econ[\xF3o]micas",
50
+ "Reg[\xEDi]menes",
51
+ "Obligaciones",
52
+ "Correo Electr[\xF3o]nico"
53
+ ],
54
+ "qr_canonical": "https://siat.sat.gob.mx/app/qr/faces/pages/mobile/validadorqr.jsf?D1=10&D2=1&D3={document_id}_{tax_id}",
55
+ "fields": [
56
+ {
57
+ "key": "tax_id",
58
+ "required": true,
59
+ "strategies": [
60
+ {
61
+ "strategy": "labeled_lines",
62
+ "label": "RFC",
63
+ "upper": true,
64
+ "capture": {
65
+ "pattern": "(?:^|[^A-Z0-9\xD1&])([A-Z\xD1&]{3,4}[0-9]{6}[A-Z0-9]{3})(?:[^A-Z0-9\xD1&]|$)",
66
+ "flags": "i",
67
+ "group": 1
68
+ }
69
+ },
70
+ {
71
+ "strategy": "regex",
72
+ "pattern": "(?:^|[^A-Z0-9\xD1&])([A-Z\xD1&]{3,4}[0-9]{6}[A-Z0-9]{3})(?:[^A-Z0-9\xD1&]|$)",
73
+ "flags": "i",
74
+ "group": 1,
75
+ "upper": true
76
+ },
77
+ {
78
+ "strategy": "qr_param",
79
+ "param": "D3",
80
+ "split": "_",
81
+ "parts": 2,
82
+ "match": "^[A-Z\xD1&]{3,4}[0-9]{6}[A-Z0-9]{3}$"
83
+ },
84
+ {
85
+ "strategy": "qr_param",
86
+ "scan": "(?:D3)?([0-9]{11})[^A-Z0-9\xD1&]{0,3}([A-Z\xD1&]{3,4}[0-9]{6}[A-Z0-9]{3})(?:[^A-Z0-9]|$)",
87
+ "flags": "i",
88
+ "group": 2
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "key": "legal_name",
94
+ "required": true,
95
+ "strategies": [
96
+ {
97
+ "strategy": "labeled_lines",
98
+ "label": "Denominaci[\xF3o]n\\s*/\\s*Raz[\xF3o]n Social"
99
+ },
100
+ {
101
+ "strategy": "concat_labeled",
102
+ "labels": [
103
+ "Nombre \\(s\\)",
104
+ "Primer Apellido",
105
+ "Segundo Apellido"
106
+ ],
107
+ "separator": " "
108
+ }
109
+ ]
110
+ },
111
+ {
112
+ "key": "postal_code",
113
+ "required": true,
114
+ "strategies": [
115
+ {
116
+ "strategy": "labeled_lines",
117
+ "label": "C[\xF3o]digo Postal",
118
+ "capture": {
119
+ "pattern": "\\b([0-9]{5})\\b",
120
+ "group": 1
121
+ }
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ "key": "tax_regime",
127
+ "required": true,
128
+ "multiple": true,
129
+ "strategies": [
130
+ {
131
+ "strategy": "catalog_phrases",
132
+ "catalog": "fiscal_regime",
133
+ "start": "Reg[\xEDi]menes\\s*:?",
134
+ "end": "Obligaciones\\s*:"
135
+ }
136
+ ]
137
+ },
138
+ {
139
+ "key": "document_id",
140
+ "strategies": [
141
+ {
142
+ "strategy": "regex",
143
+ "pattern": "id\\s*CIF\\s*:?\\s*([0-9]{6,})",
144
+ "flags": "i",
145
+ "group": 1
146
+ },
147
+ {
148
+ "strategy": "qr_param",
149
+ "param": "D3",
150
+ "split": "_",
151
+ "parts": 2,
152
+ "match": "^[0-9]+$"
153
+ },
154
+ {
155
+ "strategy": "qr_param",
156
+ "scan": "(?:D3)?([0-9]{11})[^A-Z0-9\xD1&]{0,3}([A-Z\xD1&]{3,4}[0-9]{6}[A-Z0-9]{3})(?:[^A-Z0-9]|$)",
157
+ "flags": "i",
158
+ "group": 1
159
+ }
160
+ ]
161
+ },
162
+ {
163
+ "key": "issued_on",
164
+ "strategies": [
165
+ {
166
+ "strategy": "date",
167
+ "order": "dmy",
168
+ "pattern": "Fecha\\s+de\\s+Emisi[\xF3o]n\\s*:?[^0-9]*?([0-9]{1,2})\\s+DE\\s+([A-Za-z\xC1\xC9\xCD\xD3\xDA\xD1\xE1\xE9\xED\xF3\xFA\xF1]+)\\s+DE\\s+([0-9]{4})",
169
+ "flags": "i",
170
+ "months": [
171
+ "enero",
172
+ "febrero",
173
+ "marzo",
174
+ "abril",
175
+ "mayo",
176
+ "junio",
177
+ "julio",
178
+ "agosto",
179
+ "septiembre",
180
+ "octubre",
181
+ "noviembre",
182
+ "diciembre"
183
+ ]
184
+ }
185
+ ]
186
+ }
187
+ ]
188
+ },
189
+ "verify_kind": "qr_validator",
190
+ "freshness_days": 90,
191
+ "discard_fields": [
192
+ "curp",
193
+ "street",
194
+ "exterior_number",
195
+ "neighborhood",
196
+ "activities"
197
+ ]
198
+ };
199
+ var SEED_MX_REGIMES = [
200
+ {
201
+ "code": "601",
202
+ "label": "General de Ley Personas Morales",
203
+ "person_types": [
204
+ "company"
205
+ ],
206
+ "match_phrases": [
207
+ "general de ley personas morales"
208
+ ]
209
+ },
210
+ {
211
+ "code": "603",
212
+ "label": "Personas Morales con Fines no Lucrativos",
213
+ "person_types": [
214
+ "company"
215
+ ],
216
+ "match_phrases": [
217
+ "fines no lucrativos"
218
+ ]
219
+ },
220
+ {
221
+ "code": "605",
222
+ "label": "Sueldos y Salarios e Ingresos Asimilados a Salarios",
223
+ "person_types": [
224
+ "individual"
225
+ ],
226
+ "match_phrases": [
227
+ "sueldos y salarios"
228
+ ]
229
+ },
230
+ {
231
+ "code": "606",
232
+ "label": "Arrendamiento",
233
+ "person_types": [
234
+ "individual"
235
+ ],
236
+ "match_phrases": [
237
+ "arrendamiento"
238
+ ]
239
+ },
240
+ {
241
+ "code": "607",
242
+ "label": "R\xE9gimen de Enajenaci\xF3n o Adquisici\xF3n de Bienes",
243
+ "person_types": [
244
+ "individual"
245
+ ],
246
+ "match_phrases": [
247
+ "enajenacion o adquisicion de bienes"
248
+ ]
249
+ },
250
+ {
251
+ "code": "608",
252
+ "label": "Dem\xE1s ingresos",
253
+ "person_types": [
254
+ "individual"
255
+ ],
256
+ "match_phrases": [
257
+ "demas ingresos"
258
+ ]
259
+ },
260
+ {
261
+ "code": "610",
262
+ "label": "Residentes en el Extranjero sin Establecimiento Permanente en M\xE9xico",
263
+ "person_types": [
264
+ "individual",
265
+ "company"
266
+ ],
267
+ "match_phrases": [
268
+ "residentes en el extranjero"
269
+ ]
270
+ },
271
+ {
272
+ "code": "611",
273
+ "label": "Ingresos por Dividendos (socios y accionistas)",
274
+ "person_types": [
275
+ "individual"
276
+ ],
277
+ "match_phrases": [
278
+ "dividendos"
279
+ ]
280
+ },
281
+ {
282
+ "code": "612",
283
+ "label": "Personas F\xEDsicas con Actividades Empresariales y Profesionales",
284
+ "person_types": [
285
+ "individual"
286
+ ],
287
+ "match_phrases": [
288
+ "actividades empresariales y profesionales"
289
+ ]
290
+ },
291
+ {
292
+ "code": "614",
293
+ "label": "Ingresos por intereses",
294
+ "person_types": [
295
+ "individual"
296
+ ],
297
+ "match_phrases": [
298
+ "ingresos por intereses"
299
+ ]
300
+ },
301
+ {
302
+ "code": "615",
303
+ "label": "R\xE9gimen de los ingresos por obtenci\xF3n de premios",
304
+ "person_types": [
305
+ "individual"
306
+ ],
307
+ "match_phrases": [
308
+ "premios"
309
+ ]
310
+ },
311
+ {
312
+ "code": "616",
313
+ "label": "Sin obligaciones fiscales",
314
+ "person_types": [
315
+ "individual"
316
+ ],
317
+ "match_phrases": [
318
+ "sin obligaciones fiscales"
319
+ ]
320
+ },
321
+ {
322
+ "code": "620",
323
+ "label": "Sociedades Cooperativas de Producci\xF3n que optan por diferir sus ingresos",
324
+ "person_types": [
325
+ "company"
326
+ ],
327
+ "match_phrases": [
328
+ "sociedades cooperativas de produccion"
329
+ ]
330
+ },
331
+ {
332
+ "code": "621",
333
+ "label": "Incorporaci\xF3n Fiscal",
334
+ "person_types": [
335
+ "individual"
336
+ ],
337
+ "match_phrases": [
338
+ "incorporacion fiscal"
339
+ ]
340
+ },
341
+ {
342
+ "code": "622",
343
+ "label": "Actividades Agr\xEDcolas, Ganaderas, Silv\xEDcolas y Pesqueras",
344
+ "person_types": [
345
+ "company"
346
+ ],
347
+ "match_phrases": [
348
+ "actividades agricolas"
349
+ ]
350
+ },
351
+ {
352
+ "code": "623",
353
+ "label": "Opcional para Grupos de Sociedades",
354
+ "person_types": [
355
+ "company"
356
+ ],
357
+ "match_phrases": [
358
+ "opcional para grupos de sociedades"
359
+ ]
360
+ },
361
+ {
362
+ "code": "624",
363
+ "label": "Coordinados",
364
+ "person_types": [
365
+ "company"
366
+ ],
367
+ "match_phrases": [
368
+ "coordinados"
369
+ ]
370
+ },
371
+ {
372
+ "code": "625",
373
+ "label": "R\xE9gimen de las Actividades Empresariales con ingresos a trav\xE9s de Plataformas Tecnol\xF3gicas",
374
+ "person_types": [
375
+ "individual"
376
+ ],
377
+ "match_phrases": [
378
+ "plataformas tecnologicas"
379
+ ]
380
+ },
381
+ {
382
+ "code": "626",
383
+ "label": "R\xE9gimen Simplificado de Confianza",
384
+ "person_types": [
385
+ "individual",
386
+ "company"
387
+ ],
388
+ "match_phrases": [
389
+ "simplificado de confianza"
390
+ ]
391
+ }
392
+ ];
393
+ var SEED_MX_INVOICE_USES = [
394
+ {
395
+ "code": "G01",
396
+ "label": "Adquisici\xF3n de mercanc\xEDas",
397
+ "person_types": [
398
+ "individual",
399
+ "company"
400
+ ],
401
+ "allowed_regimes": [
402
+ "601",
403
+ "603",
404
+ "606",
405
+ "612",
406
+ "620",
407
+ "621",
408
+ "622",
409
+ "623",
410
+ "624",
411
+ "625",
412
+ "626"
413
+ ]
414
+ },
415
+ {
416
+ "code": "G03",
417
+ "label": "Gastos en general",
418
+ "person_types": [
419
+ "individual",
420
+ "company"
421
+ ],
422
+ "allowed_regimes": [
423
+ "601",
424
+ "603",
425
+ "606",
426
+ "612",
427
+ "620",
428
+ "621",
429
+ "622",
430
+ "623",
431
+ "624",
432
+ "625",
433
+ "626"
434
+ ]
435
+ },
436
+ {
437
+ "code": "I01",
438
+ "label": "Construcciones",
439
+ "person_types": [
440
+ "individual",
441
+ "company"
442
+ ],
443
+ "allowed_regimes": [
444
+ "601",
445
+ "603",
446
+ "606",
447
+ "612",
448
+ "620",
449
+ "621",
450
+ "622",
451
+ "623",
452
+ "624",
453
+ "625",
454
+ "626"
455
+ ]
456
+ },
457
+ {
458
+ "code": "I02",
459
+ "label": "Mobiliario y equipo de oficina por inversiones",
460
+ "person_types": [
461
+ "individual",
462
+ "company"
463
+ ],
464
+ "allowed_regimes": [
465
+ "601",
466
+ "603",
467
+ "606",
468
+ "612",
469
+ "620",
470
+ "621",
471
+ "622",
472
+ "623",
473
+ "624",
474
+ "625",
475
+ "626"
476
+ ]
477
+ },
478
+ {
479
+ "code": "I03",
480
+ "label": "Equipo de transporte",
481
+ "person_types": [
482
+ "individual",
483
+ "company"
484
+ ],
485
+ "allowed_regimes": [
486
+ "601",
487
+ "603",
488
+ "606",
489
+ "612",
490
+ "620",
491
+ "621",
492
+ "622",
493
+ "623",
494
+ "624",
495
+ "625",
496
+ "626"
497
+ ]
498
+ },
499
+ {
500
+ "code": "I04",
501
+ "label": "Equipo de c\xF3mputo y accesorios",
502
+ "person_types": [
503
+ "individual",
504
+ "company"
505
+ ],
506
+ "allowed_regimes": [
507
+ "601",
508
+ "603",
509
+ "606",
510
+ "612",
511
+ "620",
512
+ "621",
513
+ "622",
514
+ "623",
515
+ "624",
516
+ "625",
517
+ "626"
518
+ ]
519
+ },
520
+ {
521
+ "code": "I05",
522
+ "label": "Dados, troqueles, moldes, matrices y herramental",
523
+ "person_types": [
524
+ "individual",
525
+ "company"
526
+ ],
527
+ "allowed_regimes": [
528
+ "601",
529
+ "603",
530
+ "606",
531
+ "612",
532
+ "620",
533
+ "621",
534
+ "622",
535
+ "623",
536
+ "624",
537
+ "625",
538
+ "626"
539
+ ]
540
+ },
541
+ {
542
+ "code": "I06",
543
+ "label": "Comunicaciones telef\xF3nicas",
544
+ "person_types": [
545
+ "individual",
546
+ "company"
547
+ ],
548
+ "allowed_regimes": [
549
+ "601",
550
+ "603",
551
+ "606",
552
+ "612",
553
+ "620",
554
+ "621",
555
+ "622",
556
+ "623",
557
+ "624",
558
+ "625",
559
+ "626"
560
+ ]
561
+ },
562
+ {
563
+ "code": "I07",
564
+ "label": "Comunicaciones satelitales",
565
+ "person_types": [
566
+ "individual",
567
+ "company"
568
+ ],
569
+ "allowed_regimes": [
570
+ "601",
571
+ "603",
572
+ "606",
573
+ "612",
574
+ "620",
575
+ "621",
576
+ "622",
577
+ "623",
578
+ "624",
579
+ "625",
580
+ "626"
581
+ ]
582
+ },
583
+ {
584
+ "code": "I08",
585
+ "label": "Otra maquinaria y equipo",
586
+ "person_types": [
587
+ "individual",
588
+ "company"
589
+ ],
590
+ "allowed_regimes": [
591
+ "601",
592
+ "603",
593
+ "606",
594
+ "612",
595
+ "620",
596
+ "621",
597
+ "622",
598
+ "623",
599
+ "624",
600
+ "625",
601
+ "626"
602
+ ]
603
+ },
604
+ {
605
+ "code": "D01",
606
+ "label": "Honorarios m\xE9dicos, dentales y gastos hospitalarios",
607
+ "person_types": [
608
+ "individual"
609
+ ],
610
+ "allowed_regimes": [
611
+ "605",
612
+ "606",
613
+ "607",
614
+ "608",
615
+ "611",
616
+ "612",
617
+ "614",
618
+ "615",
619
+ "625"
620
+ ]
621
+ },
622
+ {
623
+ "code": "D02",
624
+ "label": "Gastos m\xE9dicos por incapacidad o discapacidad",
625
+ "person_types": [
626
+ "individual"
627
+ ],
628
+ "allowed_regimes": [
629
+ "605",
630
+ "606",
631
+ "607",
632
+ "608",
633
+ "611",
634
+ "612",
635
+ "614",
636
+ "615",
637
+ "625"
638
+ ]
639
+ },
640
+ {
641
+ "code": "D03",
642
+ "label": "Gastos funerales",
643
+ "person_types": [
644
+ "individual"
645
+ ],
646
+ "allowed_regimes": [
647
+ "605",
648
+ "606",
649
+ "607",
650
+ "608",
651
+ "611",
652
+ "612",
653
+ "614",
654
+ "615",
655
+ "625"
656
+ ]
657
+ },
658
+ {
659
+ "code": "D04",
660
+ "label": "Donativos",
661
+ "person_types": [
662
+ "individual"
663
+ ],
664
+ "allowed_regimes": [
665
+ "605",
666
+ "606",
667
+ "607",
668
+ "608",
669
+ "611",
670
+ "612",
671
+ "614",
672
+ "615",
673
+ "625"
674
+ ]
675
+ },
676
+ {
677
+ "code": "D05",
678
+ "label": "Intereses reales efectivamente pagados por cr\xE9ditos hipotecarios (casa habitaci\xF3n)",
679
+ "person_types": [
680
+ "individual"
681
+ ],
682
+ "allowed_regimes": [
683
+ "605",
684
+ "606",
685
+ "607",
686
+ "608",
687
+ "611",
688
+ "612",
689
+ "614",
690
+ "615",
691
+ "625"
692
+ ]
693
+ },
694
+ {
695
+ "code": "D06",
696
+ "label": "Aportaciones voluntarias al SAR",
697
+ "person_types": [
698
+ "individual"
699
+ ],
700
+ "allowed_regimes": [
701
+ "605",
702
+ "606",
703
+ "607",
704
+ "608",
705
+ "611",
706
+ "612",
707
+ "614",
708
+ "615",
709
+ "625"
710
+ ]
711
+ },
712
+ {
713
+ "code": "D07",
714
+ "label": "Primas por seguros de gastos m\xE9dicos",
715
+ "person_types": [
716
+ "individual"
717
+ ],
718
+ "allowed_regimes": [
719
+ "605",
720
+ "606",
721
+ "607",
722
+ "608",
723
+ "611",
724
+ "612",
725
+ "614",
726
+ "615",
727
+ "625"
728
+ ]
729
+ },
730
+ {
731
+ "code": "D08",
732
+ "label": "Gastos de transportaci\xF3n escolar obligatoria",
733
+ "person_types": [
734
+ "individual"
735
+ ],
736
+ "allowed_regimes": [
737
+ "605",
738
+ "606",
739
+ "607",
740
+ "608",
741
+ "611",
742
+ "612",
743
+ "614",
744
+ "615",
745
+ "625"
746
+ ]
747
+ },
748
+ {
749
+ "code": "D09",
750
+ "label": "Dep\xF3sitos en cuentas para el ahorro, primas que tengan como base planes de pensiones",
751
+ "person_types": [
752
+ "individual"
753
+ ],
754
+ "allowed_regimes": [
755
+ "605",
756
+ "606",
757
+ "607",
758
+ "608",
759
+ "611",
760
+ "612",
761
+ "614",
762
+ "615",
763
+ "625"
764
+ ]
765
+ },
766
+ {
767
+ "code": "D10",
768
+ "label": "Pagos por servicios educativos (colegiaturas)",
769
+ "person_types": [
770
+ "individual"
771
+ ],
772
+ "allowed_regimes": [
773
+ "605",
774
+ "606",
775
+ "607",
776
+ "608",
777
+ "611",
778
+ "612",
779
+ "614",
780
+ "615",
781
+ "625"
782
+ ]
783
+ },
784
+ {
785
+ "code": "S01",
786
+ "label": "Sin efectos fiscales",
787
+ "person_types": [
788
+ "individual",
789
+ "company"
790
+ ],
791
+ "allowed_regimes": [
792
+ "601",
793
+ "603",
794
+ "605",
795
+ "606",
796
+ "607",
797
+ "608",
798
+ "610",
799
+ "611",
800
+ "612",
801
+ "614",
802
+ "615",
803
+ "616",
804
+ "620",
805
+ "621",
806
+ "622",
807
+ "623",
808
+ "624",
809
+ "625",
810
+ "626"
811
+ ]
812
+ }
813
+ ];
814
+ var SEED_MX_PAYMENT_METHODS = [
815
+ {
816
+ "code": "card",
817
+ "label": "Tarjeta de cr\xE9dito o d\xE9bito",
818
+ "description": "Visa, Mastercard y American Express. Pago seguro procesado por tu pasarela.",
819
+ "kind": "card",
820
+ "flow": "inline",
821
+ "providers": [
822
+ "mercadopago",
823
+ "stripe"
824
+ ],
825
+ "installments": null,
826
+ "min_amount": null,
827
+ "max_amount": null,
828
+ "icon": "CreditCard",
829
+ "fiscal_payment_form": "04,28"
830
+ },
831
+ {
832
+ "code": "mercadopago",
833
+ "label": "Mercado Pago",
834
+ "description": "Paga con tu cuenta de Mercado Pago: saldo, tarjetas guardadas o meses.",
835
+ "kind": "wallet",
836
+ "flow": "redirect",
837
+ "providers": [
838
+ "mercadopago"
839
+ ],
840
+ "installments": null,
841
+ "min_amount": null,
842
+ "max_amount": null,
843
+ "icon": "Wallet",
844
+ "fiscal_payment_form": "06,04,28"
845
+ },
846
+ {
847
+ "code": "oxxo",
848
+ "label": "Efectivo en OXXO",
849
+ "description": "Recibe una referencia y paga en cualquier tienda OXXO. Confirmamos tu pedido cuando se acredita el pago.",
850
+ "kind": "cash_voucher",
851
+ "flow": "voucher",
852
+ "providers": [
853
+ "mercadopago",
854
+ "stripe"
855
+ ],
856
+ "installments": null,
857
+ "min_amount": null,
858
+ "max_amount": null,
859
+ "expires_hours": 72,
860
+ "icon": "Store",
861
+ "fiscal_payment_form": "01"
862
+ },
863
+ {
864
+ "code": "spei",
865
+ "label": "Transferencia SPEI",
866
+ "description": "Paga desde la app de tu banco con una CLABE \xFAnica para tu pedido; se confirma en minutos.",
867
+ "kind": "bank_transfer",
868
+ "flow": "instructions",
869
+ "providers": [
870
+ "mercadopago",
871
+ "stripe"
872
+ ],
873
+ "installments": null,
874
+ "min_amount": null,
875
+ "max_amount": null,
876
+ "expires_hours": 24,
877
+ "icon": "Landmark",
878
+ "fiscal_payment_form": "03"
879
+ }
880
+ ];
881
+ var SEED_MX_FISCAL_ID_PATTERN = "^[A-Z\xD1&]{3,4}[0-9]{2}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[A-Z0-9]{2}[0-9A]$";
882
+ var SEED_MX_GENERIC_IDS = ["XAXX010101000", "XEXX010101000"];
883
+
884
+ // src/mock/region.ts
885
+ var MOCK_IDENTITY_DOCUMENT_MX_CSF = SEED_MX_CSF;
886
+ var MOCK_CSF_RULES = SEED_MX_CSF.rules;
887
+ var MOCK_FISCAL_ID_MX = {
888
+ kind: "mx_rfc",
889
+ label: "RFC",
890
+ pattern: SEED_MX_FISCAL_ID_PATTERN,
891
+ generic_ids: SEED_MX_GENERIC_IDS,
892
+ regimes: SEED_MX_REGIMES,
893
+ invoice_uses: SEED_MX_INVOICE_USES,
894
+ documents: [SEED_MX_CSF]
895
+ };
896
+ var MOCK_REGION_MX = {
897
+ country_code: "MX",
898
+ name: "M\xE9xico",
899
+ locale: { default: "es-MX", available: ["es-MX", "en-US"], current: "es-MX" },
900
+ timezone: "America/Mexico_City",
901
+ currency: { code: "MXN", symbol: "$", symbol_position: "before", minor_units: 2 },
902
+ formats: { date: "dd/MM/yyyy", measurement: "metric" },
903
+ tax: { prices_include_tax: true, label: "IVA", price_label: "IVA incluido", show_breakdown: true, default_category: "standard", categories: ["standard"] },
904
+ address: { postal_code: { pattern: "^[0-9]{5}$", example: "06600" } },
905
+ fiscal_id: MOCK_FISCAL_ID_MX,
906
+ payment_methods: SEED_MX_PAYMENT_METHODS
907
+ };
908
+ function mockPersonType(taxId) {
909
+ if (taxId.length === 13) return "individual";
910
+ if (taxId.length === 12) return "company";
911
+ return null;
912
+ }
913
+ function validateInvoiceRequest(region, input, prefix = "invoice") {
914
+ const text = (...v) => v.map((x) => typeof x === "string" ? x.trim() : "").find(Boolean) ?? "";
915
+ const fid = region?.fiscal_id;
916
+ const taxId = text(input.tax_id, input.rfc).toUpperCase();
917
+ const name = text(input.legal_name, input.razon_social);
918
+ const regime = text(input.tax_regime, input.regimen);
919
+ const use = text(input.use, input.uso_cfdi, input.invoice_use);
920
+ const postal = text(input.postal_code, input.cp);
921
+ const bad = (field, message) => ({ field: `${prefix}.${field}`, message });
922
+ if (!taxId) return bad("tax_id", "The tax id is required");
923
+ if (fid?.pattern && !fid.generic_ids.includes(taxId) && !new RegExp(fid.pattern).test(taxId)) return bad("tax_id", `Not a valid ${fid.kind}`);
924
+ if (!name) return bad("legal_name", "The legal name is required");
925
+ if (!regime) return bad("tax_regime", "The tax regime is required");
926
+ const entry = fid?.regimes.find((r) => r.code === regime);
927
+ if (fid && !entry) return bad("tax_regime", `Unknown tax regime ${regime}`);
928
+ const person = fid?.generic_ids.includes(taxId) ? null : mockPersonType(taxId);
929
+ if (entry && person && entry.person_types.length > 0 && !entry.person_types.includes(person)) {
930
+ return bad("tax_regime", `The regime ${regime} does not apply to this ${fid.kind}`);
931
+ }
932
+ const postalPattern = region?.address?.postal_code?.pattern;
933
+ if (!postal || postalPattern && !new RegExp(postalPattern).test(postal)) return bad("postal_code", "Not a valid postal code");
934
+ if (!use) return bad("use", "The invoice use is required");
935
+ const useEntry = fid?.invoice_uses.find((u) => u.code === use);
936
+ if (fid && !useEntry) return bad("use", `Unknown invoice use ${use}`);
937
+ if (useEntry?.allowed_regimes && useEntry.allowed_regimes.length > 0 && !useEntry.allowed_regimes.includes(regime)) {
938
+ return bad("use", `The regime ${regime} does not admit the use ${use}`);
939
+ }
940
+ return null;
941
+ }
942
+ function maskTaxId(taxId) {
943
+ const v = taxId.trim();
944
+ return v.length <= 4 ? "*".repeat(v.length) : `${v.slice(0, 2)}${"*".repeat(v.length - 5)}${v.slice(-3)}`;
945
+ }
946
+
4
947
  // src/mock/seed.ts
5
948
  var MOCK_IMAGE_URL = (seed, width = 800, height = 800) => `https://picsum.photos/seed/${encodeURIComponent(seed)}/${width}/${height}`;
6
949
  var MOCK_CURRENCY = "MXN";
@@ -339,17 +1282,19 @@ function buildCustomers() {
339
1282
 
340
1283
  // src/mock/index.ts
341
1284
  var HttpError = class extends Error {
342
- constructor(status, code, message, field, details) {
1285
+ constructor(status, code, message, field, details, requiredScopes) {
343
1286
  super(message);
344
1287
  this.status = status;
345
1288
  this.code = code;
346
1289
  this.field = field;
347
1290
  this.details = details;
1291
+ this.requiredScopes = requiredScopes;
348
1292
  }
349
1293
  status;
350
1294
  code;
351
1295
  field;
352
1296
  details;
1297
+ requiredScopes;
353
1298
  };
354
1299
  var PUBLIC_CACHE = "public, max-age=60, stale-while-revalidate=600";
355
1300
  var PRIVATE_CACHE = "private, no-store";
@@ -399,8 +1344,24 @@ function createMockStorefront(options = {}) {
399
1344
  password: true,
400
1345
  email_verification: true,
401
1346
  otp_channels: ["email"],
1347
+ invoicing: {
1348
+ available: true,
1349
+ countries: ["MX"],
1350
+ checkout: "optional",
1351
+ post_purchase: true,
1352
+ window_days: 30,
1353
+ identity_documents: ["MX:csf"],
1354
+ online_verify: false
1355
+ },
402
1356
  ...options.customerCapabilities
403
1357
  };
1358
+ const missingScopes = options.missingScopes ?? [];
1359
+ if (missingScopes.includes("customer:write")) {
1360
+ capabilities.password = false;
1361
+ capabilities.unavailable_reason = "missing_scope";
1362
+ capabilities.missing_scopes = ["customer:write"];
1363
+ }
1364
+ const region = options.region === void 0 ? MOCK_REGION_MX : options.region;
404
1365
  const maxLoginAttempts = options.maxLoginAttempts ?? 5;
405
1366
  const MIN_PASSWORD = 10;
406
1367
  const MAX_PASSWORD = 128;
@@ -444,6 +1405,7 @@ function createMockStorefront(options = {}) {
444
1405
  checkouts: /* @__PURE__ */ new Map(),
445
1406
  payments: /* @__PURE__ */ new Map(),
446
1407
  restock: /* @__PURE__ */ new Set(),
1408
+ invoices: /* @__PURE__ */ new Map(),
447
1409
  seq: 0
448
1410
  };
449
1411
  }
@@ -706,9 +1668,39 @@ function createMockStorefront(options = {}) {
706
1668
  tax_included: true
707
1669
  },
708
1670
  note: cart.note,
1671
+ invoice: cart.invoice ? cartInvoiceOf(cart.invoice) : null,
709
1672
  updated_at: cart.updated_at
710
1673
  };
711
1674
  }
1675
+ function cartInvoiceOf(inv) {
1676
+ const taxId = typeof inv.tax_id === "string" ? inv.tax_id : typeof inv.rfc === "string" ? inv.rfc : "";
1677
+ const name = typeof inv.legal_name === "string" ? inv.legal_name : typeof inv.razon_social === "string" ? inv.razon_social : null;
1678
+ return {
1679
+ requested: true,
1680
+ tax_id_masked: taxId ? maskTaxId(taxId) : null,
1681
+ legal_name: name,
1682
+ country_code: inv.country_code ?? region?.country_code ?? null,
1683
+ document_kind: inv.document?.kind ?? null
1684
+ };
1685
+ }
1686
+ function parseInvoice(raw, prefix = "invoice") {
1687
+ if (raw === null || raw === void 0) return null;
1688
+ if (typeof raw !== "object" || Array.isArray(raw)) throw new HttpError(400, "validation", "invoice must be an object", prefix);
1689
+ const inv = raw;
1690
+ if (inv.requested === false) return null;
1691
+ const problem = validateInvoiceRequest(region, inv, prefix);
1692
+ if (problem) throw new HttpError(422, "invalid_state", problem.message, problem.field);
1693
+ return inv;
1694
+ }
1695
+ const orderInvoice = (order) => {
1696
+ const entry = state.invoices.get(order.id);
1697
+ const paid = order.status !== "pending_payment";
1698
+ if (entry) {
1699
+ const stage = entry.stage === "awaiting_payment" && paid ? "queued" : entry.stage;
1700
+ return { stage, requested: true, status: stage === "issued" ? "issued" : "requested", action: stage === "awaiting_payment" ? "wait" : "none", can_request: false, url: null, xml_url: null };
1701
+ }
1702
+ return paid ? { status: "not_requested", stage: "not_requested", requested: false, action: "request", can_request: true, blocked_reason: null } : { status: "not_requested", stage: "not_requested", requested: false, action: "none", can_request: false, blocked_reason: "awaiting_payment" };
1703
+ };
712
1704
  function requireCustomer(headers) {
713
1705
  const token = headers.get("x-customer-token");
714
1706
  const id = token ? state.sessions.get(token) : void 0;
@@ -781,6 +1773,10 @@ function createMockStorefront(options = {}) {
781
1773
  return value;
782
1774
  };
783
1775
  route("GET", "/shop", "catalog:read", () => ({ body: state.shop, cache: "public" }));
1776
+ route("GET", "/region", "catalog:read", () => {
1777
+ if (!region) throw new HttpError(404, "not_found", "No region configured");
1778
+ return { body: region, cache: "public" };
1779
+ });
784
1780
  route("GET", "/products", "catalog:read", ({ search }) => ({ body: listProducts(search), cache: "public" }));
785
1781
  route("GET", "/products/:handle", "catalog:read", ({ params }) => ({
786
1782
  body: requireNode(state.products.find((p) => p.handle === params[0]), `Product ${params[0]}`),
@@ -837,6 +1833,8 @@ function createMockStorefront(options = {}) {
837
1833
  shipping_address: null,
838
1834
  delivery: { method: null, rate_id: null, branch_id: null },
839
1835
  note: null,
1836
+ invoice: null,
1837
+ checkedOut: false,
840
1838
  updated_at: now()
841
1839
  };
842
1840
  if (body.lines !== void 0) addLines(cart, validateLines(body.lines));
@@ -933,6 +1931,13 @@ function createMockStorefront(options = {}) {
933
1931
  cart.updated_at = now();
934
1932
  return { body: renderCart(cart), cache: "private" };
935
1933
  });
1934
+ route("PUT", "/carts/:id/invoice", "cart:write", ({ params, body }) => {
1935
+ const cart = getCartRecord(params[0]);
1936
+ if (cart.checkedOut) throw new HttpError(409, "already_checked_out", "The cart is already an order");
1937
+ cart.invoice = parseInvoice(body);
1938
+ cart.updated_at = now();
1939
+ return { body: renderCart(cart), cache: "private" };
1940
+ });
936
1941
  route("PUT", "/carts/:id/note", "cart:write", ({ params, body }) => {
937
1942
  const cart = getCartRecord(params[0]);
938
1943
  const raw = body.note;
@@ -983,6 +1988,7 @@ function createMockStorefront(options = {}) {
983
1988
  }
984
1989
  if (typeof body.payment_method !== "string" || !body.payment_method) throw new HttpError(400, "validation", "payment_method is required", "payment_method");
985
1990
  if (typeof body.return_url !== "string" || !body.return_url) throw new HttpError(400, "validation", "return_url is required", "return_url");
1991
+ const invoice = body.invoice !== void 0 ? parseInvoice(body.invoice) : record.invoice;
986
1992
  checkStock(record.lines.map((l, i) => ({ variant: findVariant(l.variant_id).variant, quantity: l.quantity, lineId: l.id, field: `lines[${i}].quantity` })));
987
1993
  for (const l of record.lines) {
988
1994
  const v = findVariant(l.variant_id).variant;
@@ -1027,6 +2033,8 @@ function createMockStorefront(options = {}) {
1027
2033
  }
1028
2034
  };
1029
2035
  state.checkouts.set(checkoutId, result);
2036
+ record.checkedOut = true;
2037
+ if (invoice) state.invoices.set(orderId, { stage: "awaiting_payment", request: invoice });
1030
2038
  if (key) state.idempotency.set(`${params[0]}:${key}`, { status: 201, body: result });
1031
2039
  return { status: 201, body: result, cache: "private" };
1032
2040
  });
@@ -1120,6 +2128,8 @@ function createMockStorefront(options = {}) {
1120
2128
  } else {
1121
2129
  payment = { provider: "mock", status: "paid" };
1122
2130
  found.checkout.status = "paid";
2131
+ const order = state.orders.find((o) => o.id === found.checkout.external_order_id);
2132
+ if (order) order.status = "paid";
1123
2133
  }
1124
2134
  payment.outcome = payment.status === "paid" ? "approved" : payment.status === "failed" ? "rejected" : payment.action?.type === "challenge" ? "challenge" : "pending";
1125
2135
  const result = { attempt: { n: st.attempts }, payment, checkout: found.checkout, attempts_left: attemptsLeft };
@@ -1239,8 +2249,38 @@ function createMockStorefront(options = {}) {
1239
2249
  state.loginFailures.delete(email);
1240
2250
  return { status: 204 };
1241
2251
  });
1242
- route("GET", "/customer", "customer:read", ({ headers }) => ({ body: requireCustomer(headers), cache: "private" }));
1243
- const stripOrder = ({ customer_id: _c, ...o }) => o;
2252
+ const publicCustomer = (c) => {
2253
+ if (!c.fiscal?.document) return c;
2254
+ const { sha256: _sha, ...document } = c.fiscal.document;
2255
+ return { ...c, fiscal: { ...c.fiscal, document } };
2256
+ };
2257
+ route("GET", "/customer", "customer:read", ({ headers }) => ({ body: publicCustomer(requireCustomer(headers)), cache: "private" }));
2258
+ route("PATCH", "/customer", "customer:write", ({ headers, body }) => {
2259
+ const c = requireCustomer(headers);
2260
+ const text = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
2261
+ if ("first_name" in body) c.first_name = text(body.first_name);
2262
+ if ("last_name" in body) c.last_name = text(body.last_name);
2263
+ if ("phone" in body) c.phone = text(body.phone);
2264
+ if ("fiscal" in body) {
2265
+ if (body.fiscal === null) c.fiscal = null;
2266
+ else {
2267
+ const fiscal = parseInvoice({ ...body.fiscal, requested: true }, "fiscal");
2268
+ const fid = {
2269
+ country_code: String(fiscal.country_code ?? region?.country_code ?? ""),
2270
+ tax_id: String(fiscal.tax_id ?? fiscal.rfc).toUpperCase(),
2271
+ legal_name: String(fiscal.legal_name ?? fiscal.razon_social),
2272
+ tax_regime: String(fiscal.tax_regime ?? fiscal.regimen),
2273
+ postal_code: String(fiscal.postal_code ?? fiscal.cp),
2274
+ invoice_use: String(fiscal.use ?? fiscal.uso_cfdi ?? fiscal.invoice_use ?? "") || null,
2275
+ document: fiscal.document ?? null,
2276
+ verification: { status: "reviewed", checked_at: now() }
2277
+ };
2278
+ c.fiscal = fid;
2279
+ }
2280
+ }
2281
+ return { body: publicCustomer(c), cache: "private" };
2282
+ });
2283
+ const stripOrder = ({ customer_id: _c, ...o }) => ({ ...o, invoice: orderInvoice(o) });
1244
2284
  route("GET", "/customer/orders", "orders:read", ({ headers, search }) => {
1245
2285
  const c = requireCustomer(headers);
1246
2286
  const orders = state.orders.filter((o) => o.customer_id === c.id).sort((a, b) => b.created_at.localeCompare(a.created_at)).map(stripOrder);
@@ -1256,9 +2296,16 @@ function createMockStorefront(options = {}) {
1256
2296
  if (!Array.isArray(body.lines) || body.lines.length === 0) throw new HttpError(400, "validation", "lines are required", "lines");
1257
2297
  return { status: 201, body: { id: nextId("ret"), order_id: order.id, status: "requested" }, cache: "private" };
1258
2298
  });
1259
- route("POST", "/customer/orders/:id/invoice", "customer:write", ({ headers, params }) => {
1260
- findOrder(headers, params[0]);
1261
- return { status: 202, body: { status: "requested", url: null }, cache: "private" };
2299
+ route("POST", "/customer/orders/:id/invoice", "customer:write", ({ headers, params, body }) => {
2300
+ const order = findOrder(headers, params[0]);
2301
+ const existing = state.invoices.get(order.id);
2302
+ if (existing && existing.stage !== "awaiting_payment") {
2303
+ return { status: existing.stage === "issued" ? 200 : 202, body: { status: existing.stage === "issued" ? "issued" : "requested", url: null, stage: existing.stage, invoice: orderInvoice(order) }, cache: "private" };
2304
+ }
2305
+ const request = parseInvoice({ ...body, requested: true }, "invoice");
2306
+ if (order.status === "pending_payment") throw new HttpError(409, "awaiting_payment", "The order is not paid yet");
2307
+ state.invoices.set(order.id, { stage: "queued", request });
2308
+ return { status: 202, body: { status: "requested", url: null, stage: "queued", invoice: orderInvoice(order) }, cache: "private" };
1262
2309
  });
1263
2310
  route("GET", "/customer/addresses", "customer:read", ({ headers }) => {
1264
2311
  const c = requireCustomer(headers);
@@ -1313,9 +2360,11 @@ function createMockStorefront(options = {}) {
1313
2360
  }));
1314
2361
  function scopesFor(token) {
1315
2362
  if (!token) return null;
1316
- if (token.startsWith("pk_")) return /* @__PURE__ */ new Set(["catalog:read", "content:read", "cart:write"]);
1317
- if (token.startsWith("sk_")) return /* @__PURE__ */ new Set(["catalog:read", "content:read", "cart:write", "checkout:write", "customer:read", "customer:write", "orders:read"]);
1318
- return null;
2363
+ let all;
2364
+ if (token.startsWith("pk_")) all = ["catalog:read", "content:read", "cart:write"];
2365
+ else if (token.startsWith("sk_")) all = ["catalog:read", "content:read", "cart:write", "checkout:write", "customer:read", "customer:write", "orders:read"];
2366
+ else return null;
2367
+ return new Set(all.filter((sc) => !missingScopes.includes(sc)));
1319
2368
  }
1320
2369
  function json(status, body, headers = {}) {
1321
2370
  return new Response(status === 204 || body === void 0 ? null : JSON.stringify(body), {
@@ -1326,12 +2375,18 @@ function createMockStorefront(options = {}) {
1326
2375
  function errorResponse(err) {
1327
2376
  return json(
1328
2377
  err.status,
1329
- { error: { code: err.code, message: err.message, ...err.field ? { field: err.field } : {}, ...err.details !== void 0 ? { details: err.details } : {} } },
2378
+ { error: { code: err.code, message: err.message, ...err.field ? { field: err.field } : {}, ...err.details !== void 0 ? { details: err.details } : {}, ...err.requiredScopes ? { required_scopes: err.requiredScopes } : {} } },
1330
2379
  { "Cache-Control": PRIVATE_CACHE }
1331
2380
  );
1332
2381
  }
1333
2382
  async function handle(request) {
1334
2383
  const url = new URL(request.url);
2384
+ if (/\/_token\/?$/.test(url.pathname)) {
2385
+ const tok = request.headers.get("authorization")?.match(/^Bearer\s+(.+)$/i)?.[1] ?? null;
2386
+ const granted = scopesFor(tok);
2387
+ if (!tok || !granted) return errorResponse(new HttpError(401, "unauthorized", "Missing or invalid storefront token"));
2388
+ return json(200, { success: true, data: { kind: tok.startsWith("pk_") ? "publishable" : "secret", environment: "sandbox", scopes: [...granted], missing_scopes: missingScopes, connection_id: "conn_mock", expires_at: null } }, { "Cache-Control": PRIVATE_CACHE });
2389
+ }
1335
2390
  const idx = url.pathname.indexOf("/storefront/");
1336
2391
  if (idx < 0) return errorResponse(new HttpError(404, "not_found", `No route for ${url.pathname}`));
1337
2392
  const path = url.pathname.slice(idx + "/storefront".length).replace(/\/+$/, "") || "/";
@@ -1344,7 +2399,9 @@ function createMockStorefront(options = {}) {
1344
2399
  const token = auth?.match(/^Bearer\s+(.+)$/i)?.[1] ?? null;
1345
2400
  const scopes = scopesFor(token);
1346
2401
  if (!scopes) return errorResponse(new HttpError(401, "unauthorized", "Missing or invalid storefront token"));
1347
- if (enforceScopes && !scopes.has(r.scope)) return errorResponse(new HttpError(403, "forbidden", `Token lacks scope ${r.scope}`));
2402
+ if ((enforceScopes || missingScopes.length > 0) && !scopes.has(r.scope)) {
2403
+ return errorResponse(new HttpError(403, "insufficient_scope", `Token lacks scope ${r.scope}`, void 0, void 0, [r.scope]));
2404
+ }
1348
2405
  let body = {};
1349
2406
  if (method !== "GET" && method !== "DELETE") {
1350
2407
  const text = await request.text();
@@ -1399,6 +2456,6 @@ function createMockStorefront(options = {}) {
1399
2456
  };
1400
2457
  }
1401
2458
 
1402
- export { MOCK_CURRENCY, MOCK_CUSTOMER_EMAIL, MOCK_IMAGE_URL, MOCK_POSTAL_CENTROIDS, createMockStorefront };
2459
+ export { MOCK_CSF_RULES, MOCK_CURRENCY, MOCK_CUSTOMER_EMAIL, MOCK_FISCAL_ID_MX, MOCK_IDENTITY_DOCUMENT_MX_CSF, MOCK_IMAGE_URL, MOCK_POSTAL_CENTROIDS, MOCK_REGION_MX, createMockStorefront };
1403
2460
  //# sourceMappingURL=mock.js.map
1404
2461
  //# sourceMappingURL=mock.js.map