@zenky/storefront-api 0.0.34 → 0.0.35

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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 Zenky
3
+ Copyright (c) 2024 Zenky
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.d.ts CHANGED
@@ -372,6 +372,14 @@ export interface NestedCategory extends Category {
372
372
  export interface CategoriesListRequest extends ListRequest {
373
373
  featured?: boolean;
374
374
  }
375
+ export interface ProductsCollection {
376
+ id: string;
377
+ name: string | null;
378
+ description: string | null;
379
+ cover: Media | null;
380
+ }
381
+ export interface CollectionsListRequest extends PaginationRequest, SearchRequest, OrderingRequest {
382
+ }
375
383
  export interface FeatureValue {
376
384
  id: string;
377
385
  alias: string;
@@ -405,157 +413,6 @@ export interface FeaturesGroup {
405
413
  description: string | null;
406
414
  features: Feature[];
407
415
  }
408
- export declare class CategoriesResource extends AbstractResource {
409
- getCategories(storeId: string, request?: CategoriesListRequest): Promise<PaginatedResponse<Category>>;
410
- getCategoriesTree(storeId: string, request?: InclusionRequest): Promise<NestedCategory[]>;
411
- getCategory(storeId: string, categoryId: string, request?: InclusionRequest): Promise<Category>;
412
- getFeaturesGroups(storeId: string, categoryId: string): Promise<FeaturesGroup[]>;
413
- getFeatures(storeId: string, categoryId: string): Promise<Feature[]>;
414
- }
415
- export declare class ZenkyError extends Error {
416
- readonly err: ApiError | null;
417
- constructor(message: string, error: ApiError | null);
418
- }
419
- export declare class ZenkyErrorBuilder {
420
- static build(response: any): Promise<ZenkyError>;
421
- }
422
- export interface Stock {
423
- id: string;
424
- name: string | null;
425
- description: string | null;
426
- address: string | null;
427
- coordinates: GeoLocation | null;
428
- links: Contact[];
429
- phones: Phone[];
430
- schedule: Schedule | null;
431
- }
432
- export interface DeliveryZone {
433
- id: string;
434
- name: string | null;
435
- coordinates: GeoLocation[];
436
- description: string | null;
437
- color: string | null;
438
- min_price: number | null;
439
- free_delivery_price: number | null;
440
- delivery_price: number | null;
441
- delivery_time: string | null;
442
- }
443
- export interface City {
444
- id: string;
445
- is_default: boolean;
446
- name: string | null;
447
- timezone: string;
448
- coordinates: GeoLocation | null;
449
- stocks?: Stock[];
450
- delivery_zones?: DeliveryZone[];
451
- phones?: Phone[];
452
- }
453
- export interface StoreSettings {
454
- country: string;
455
- currency: string;
456
- orders: {
457
- authentication_method: OrderAuthenticationMethod;
458
- use_early_delivery: boolean;
459
- addresses_provider: AddressesProvider;
460
- };
461
- products: {
462
- use_stock_filter: boolean;
463
- };
464
- loyalty: {
465
- enabled: boolean;
466
- bonuses: {
467
- on_demand_balance_enabled: boolean;
468
- pin_enabled: boolean;
469
- };
470
- };
471
- recaptcha: {
472
- actions: RecaptchaAction[];
473
- key: string;
474
- } | null;
475
- websockets: {
476
- app_id: string;
477
- app_key: string;
478
- options: {
479
- host: string;
480
- port: number;
481
- };
482
- } | null;
483
- }
484
- export interface Store {
485
- id: string;
486
- name: string;
487
- domain: string | null;
488
- app_store_url: string | null;
489
- google_play_url: string | null;
490
- logo: Media | null;
491
- square_logo: Media | null;
492
- links: Contact[];
493
- phones: Phone[];
494
- cities: City[];
495
- settings: StoreSettings;
496
- }
497
- export declare class StoreResource extends AbstractResource {
498
- getStore(storeId: string): Promise<Store>;
499
- getStoreByBundleId(bundleId: string): Promise<Store>;
500
- }
501
- export interface ProductsCollection {
502
- id: string;
503
- name: string | null;
504
- description: string | null;
505
- cover: Media | null;
506
- }
507
- export interface CollectionsListRequest extends PaginationRequest, SearchRequest, OrderingRequest {
508
- }
509
- export declare class CollectionsResource extends AbstractResource {
510
- getCollections(storeId: string, request?: CollectionsListRequest): Promise<PaginatedResponse<ProductsCollection>>;
511
- getCollection(storeId: string, id: string): Promise<ProductsCollection>;
512
- }
513
- export interface OfferBanner {
514
- title: string | null;
515
- description: string | null;
516
- image: Media | null;
517
- }
518
- export interface OfferArticle {
519
- title: string | null;
520
- intro: string | null;
521
- body: string | null;
522
- cover: Media | null;
523
- }
524
- export interface Offer {
525
- id: string;
526
- short_id: string;
527
- slug: string | null;
528
- banners: {
529
- desktop: OfferBanner | null;
530
- mobile: OfferBanner | null;
531
- };
532
- article?: OfferArticle | null;
533
- }
534
- export declare class OffersResource extends AbstractResource {
535
- getOffers(storeId: string, request?: ListRequest): Promise<PaginatedResponse<Offer>>;
536
- getOffer(storeId: string, offerId: string, request?: InclusionRequest): Promise<Offer>;
537
- }
538
- export interface Feedback {
539
- id: string;
540
- name: string | null;
541
- email: string | null;
542
- phone: Phone | null;
543
- comment: string | null;
544
- created_at: string;
545
- }
546
- export interface FeedbackRequest extends RecaptchaRequest {
547
- name?: string;
548
- email?: string;
549
- phone?: PhoneRequest;
550
- comment?: string;
551
- }
552
- export interface CallbackRequest extends RecaptchaRequest {
553
- phone: PhoneRequest;
554
- }
555
- export declare class FeedbackResource extends AbstractResource {
556
- createFeedback(storeId: string, request: FeedbackRequest): Promise<Feedback>;
557
- createCallback(storeId: string, request: CallbackRequest): Promise<boolean>;
558
- }
559
416
  export interface Modifier {
560
417
  id: string;
561
418
  sku: string | null;
@@ -710,6 +567,169 @@ export interface ProductVariantPriceCalculationRequest {
710
567
  stock_id?: string;
711
568
  modifiers?: ProductModifiersRequest[];
712
569
  }
570
+ export interface CatalogItem {
571
+ type: "category" | "collection";
572
+ products_count: number;
573
+ category?: Category | null;
574
+ collection?: ProductsCollection | null;
575
+ products: Product[];
576
+ }
577
+ export declare class CatalogResource extends AbstractResource {
578
+ getCatalog(storeId: string): Promise<CatalogItem[]>;
579
+ }
580
+ export declare class CategoriesResource extends AbstractResource {
581
+ getCategories(storeId: string, request?: CategoriesListRequest): Promise<PaginatedResponse<Category>>;
582
+ getCategoriesTree(storeId: string, request?: InclusionRequest): Promise<NestedCategory[]>;
583
+ getCategory(storeId: string, categoryId: string, request?: InclusionRequest): Promise<Category>;
584
+ getFeaturesGroups(storeId: string, categoryId: string): Promise<FeaturesGroup[]>;
585
+ getFeatures(storeId: string, categoryId: string): Promise<Feature[]>;
586
+ }
587
+ export declare class ZenkyError extends Error {
588
+ readonly err: ApiError | null;
589
+ constructor(message: string, error: ApiError | null);
590
+ }
591
+ export declare class ZenkyErrorBuilder {
592
+ static build(response: any): Promise<ZenkyError>;
593
+ }
594
+ export interface Stock {
595
+ id: string;
596
+ name: string | null;
597
+ description: string | null;
598
+ address: string | null;
599
+ coordinates: GeoLocation | null;
600
+ links: Contact[];
601
+ phones: Phone[];
602
+ schedule: Schedule | null;
603
+ }
604
+ export interface DeliveryZone {
605
+ id: string;
606
+ name: string | null;
607
+ coordinates: GeoLocation[];
608
+ description: string | null;
609
+ color: string | null;
610
+ min_price: number | null;
611
+ free_delivery_price: number | null;
612
+ delivery_price: number | null;
613
+ delivery_time: string | null;
614
+ }
615
+ export interface City {
616
+ id: string;
617
+ is_default: boolean;
618
+ name: string | null;
619
+ timezone: string;
620
+ coordinates: GeoLocation | null;
621
+ stocks?: Stock[];
622
+ delivery_zones?: DeliveryZone[];
623
+ phones?: Phone[];
624
+ }
625
+ export interface StoreSettings {
626
+ country: string;
627
+ currency: string;
628
+ orders: {
629
+ authentication_method: OrderAuthenticationMethod;
630
+ use_early_delivery: boolean;
631
+ addresses_provider: AddressesProvider;
632
+ repeats: {
633
+ enabled: boolean;
634
+ };
635
+ checkout_ui: {
636
+ enabled: boolean;
637
+ message: string | null;
638
+ };
639
+ };
640
+ products: {
641
+ use_stock_filter: boolean;
642
+ search: {
643
+ enabled: boolean;
644
+ };
645
+ };
646
+ loyalty: {
647
+ enabled: boolean;
648
+ bonuses: {
649
+ on_demand_balance_enabled: boolean;
650
+ pin_enabled: boolean;
651
+ };
652
+ };
653
+ recaptcha: {
654
+ actions: RecaptchaAction[];
655
+ key: string;
656
+ } | null;
657
+ websockets: {
658
+ app_id: string;
659
+ app_key: string;
660
+ options: {
661
+ host: string;
662
+ port: number;
663
+ };
664
+ } | null;
665
+ }
666
+ export interface Store {
667
+ id: string;
668
+ name: string;
669
+ domain: string | null;
670
+ app_store_url: string | null;
671
+ google_play_url: string | null;
672
+ logo: Media | null;
673
+ square_logo: Media | null;
674
+ links: Contact[];
675
+ phones: Phone[];
676
+ cities: City[];
677
+ settings: StoreSettings;
678
+ }
679
+ export declare class StoreResource extends AbstractResource {
680
+ getStore(storeId: string): Promise<Store>;
681
+ getStoreByBundleId(bundleId: string): Promise<Store>;
682
+ }
683
+ export declare class CollectionsResource extends AbstractResource {
684
+ getCollections(storeId: string, request?: CollectionsListRequest): Promise<PaginatedResponse<ProductsCollection>>;
685
+ getCollection(storeId: string, id: string): Promise<ProductsCollection>;
686
+ }
687
+ export interface OfferBanner {
688
+ title: string | null;
689
+ description: string | null;
690
+ image: Media | null;
691
+ }
692
+ export interface OfferArticle {
693
+ title: string | null;
694
+ intro: string | null;
695
+ body: string | null;
696
+ cover: Media | null;
697
+ }
698
+ export interface Offer {
699
+ id: string;
700
+ short_id: string;
701
+ slug: string | null;
702
+ banners: {
703
+ desktop: OfferBanner | null;
704
+ mobile: OfferBanner | null;
705
+ };
706
+ article?: OfferArticle | null;
707
+ }
708
+ export declare class OffersResource extends AbstractResource {
709
+ getOffers(storeId: string, request?: ListRequest): Promise<PaginatedResponse<Offer>>;
710
+ getOffer(storeId: string, offerId: string, request?: InclusionRequest): Promise<Offer>;
711
+ }
712
+ export interface Feedback {
713
+ id: string;
714
+ name: string | null;
715
+ email: string | null;
716
+ phone: Phone | null;
717
+ comment: string | null;
718
+ created_at: string;
719
+ }
720
+ export interface FeedbackRequest extends RecaptchaRequest {
721
+ name?: string;
722
+ email?: string;
723
+ phone?: PhoneRequest;
724
+ comment?: string;
725
+ }
726
+ export interface CallbackRequest extends RecaptchaRequest {
727
+ phone: PhoneRequest;
728
+ }
729
+ export declare class FeedbackResource extends AbstractResource {
730
+ createFeedback(storeId: string, request: FeedbackRequest): Promise<Feedback>;
731
+ createCallback(storeId: string, request: CallbackRequest): Promise<boolean>;
732
+ }
713
733
  export declare class ProductsResource extends AbstractResource {
714
734
  getProducts(storeId: string, request?: ListProductsRequest): Promise<PaginatedResponse<Product>>;
715
735
  getProduct(storeId: string, productId: string, request?: ViewProductRequest): Promise<Product>;
@@ -1336,6 +1356,7 @@ export declare class ZenkyStorefront {
1336
1356
  readonly store: StoreResource;
1337
1357
  readonly auth: AuthenticationResource;
1338
1358
  readonly customer: CustomersResource;
1359
+ readonly catalog: CatalogResource;
1339
1360
  readonly categories: CategoriesResource;
1340
1361
  readonly products: ProductsResource;
1341
1362
  readonly addresses: AddressesResource;
@@ -43,6 +43,12 @@ class S extends d {
43
43
  }
44
44
  }
45
45
  class q extends d {
46
+ async getCatalog(t) {
47
+ const e = this.getStoreUrl(t, "/catalog");
48
+ return this.getResponse(await this.client.request("GET", e));
49
+ }
50
+ }
51
+ class A extends d {
46
52
  async getCategories(t, e) {
47
53
  const s = this.getStoreUrl(t, "/categories", e);
48
54
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -64,21 +70,21 @@ class q extends d {
64
70
  return this.getResponse(await this.client.request("GET", s));
65
71
  }
66
72
  }
67
- class E extends Error {
73
+ class O extends Error {
68
74
  constructor(e, s) {
69
75
  super(e);
70
76
  l(this, "err");
71
77
  this.err = s;
72
78
  }
73
79
  }
74
- class A {
80
+ class b {
75
81
  static async build(t) {
76
82
  const e = await t.json();
77
83
  switch (t.status) {
78
84
  case 401:
79
- return new E((e == null ? void 0 : e.message) ?? "Unauthenticated.", null);
85
+ return new O((e == null ? void 0 : e.message) ?? "Unauthenticated.", null);
80
86
  default:
81
- return new E(e == null ? void 0 : e.message, (e == null ? void 0 : e.error) || null);
87
+ return new O(e == null ? void 0 : e.message, (e == null ? void 0 : e.error) || null);
82
88
  }
83
89
  }
84
90
  }
@@ -139,10 +145,10 @@ class k {
139
145
  const o = await this.fetchFunction.call(null, `${this.baseUrl}${e}`, a);
140
146
  if (o.ok)
141
147
  return o.status === 204 ? !0 : o.json();
142
- throw await A.build(o);
148
+ throw await b.build(o);
143
149
  }
144
150
  }
145
- class b extends d {
151
+ class _ extends d {
146
152
  async getStore(t) {
147
153
  const e = this.client.getUrl(`/store/${t}`);
148
154
  return this.getResponse(await this.client.request("GET", e));
@@ -152,7 +158,7 @@ class b extends d {
152
158
  return this.getResponse(await this.client.request("GET", e));
153
159
  }
154
160
  }
155
- class _ extends d {
161
+ class T extends d {
156
162
  async getCollections(t, e) {
157
163
  const s = this.getStoreUrl(t, "/collections", e);
158
164
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -162,7 +168,7 @@ class _ extends d {
162
168
  return this.getResponse(await this.client.request("GET", s));
163
169
  }
164
170
  }
165
- class T extends d {
171
+ class C extends d {
166
172
  async getOffers(t, e) {
167
173
  const s = this.getStoreUrl(t, "/offers", e);
168
174
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -172,7 +178,7 @@ class T extends d {
172
178
  return this.getResponse(await this.client.request("GET", n));
173
179
  }
174
180
  }
175
- class C extends d {
181
+ class N extends d {
176
182
  async createFeedback(t, e) {
177
183
  const s = this.getStoreUrl(t, "/feedback", e);
178
184
  return this.getResponse(await this.client.request("POST", s));
@@ -182,7 +188,7 @@ class C extends d {
182
188
  return await this.client.request("POST", s), !0;
183
189
  }
184
190
  }
185
- class N extends d {
191
+ class $ extends d {
186
192
  async getProducts(t, e) {
187
193
  const s = this.getStoreUrl(t, "/products", e);
188
194
  return this.getPaginatedResponse(await this.client.request("GET", s));
@@ -196,7 +202,7 @@ class N extends d {
196
202
  return this.getResponse(await this.client.request("POST", i, n));
197
203
  }
198
204
  }
199
- class $ extends d {
205
+ class G extends d {
200
206
  getOrderUrl(t, e, s, n) {
201
207
  const i = typeof e == "string" ? e : e.id, a = typeof e == "string" ? void 0 : e.token;
202
208
  return this.getStoreUrl(t, `/orders/${i}${s}${a ? "?token=" + a : ""}`, n);
@@ -322,13 +328,13 @@ class $ extends d {
322
328
  );
323
329
  }
324
330
  }
325
- class G extends d {
331
+ class V extends d {
326
332
  async getAddressSuggestions(t, e) {
327
333
  const s = this.getStoreUrl(t, "/suggestions/address");
328
334
  return this.getResponse(await this.client.request("POST", s, e));
329
335
  }
330
336
  }
331
- class V extends d {
337
+ class D extends d {
332
338
  async getProfile(t, e, s) {
333
339
  const n = this.getStoreUrl(t, "/me", e);
334
340
  return this.getResponse(await this.client.request("GET", n, null, s));
@@ -393,17 +399,17 @@ class V extends d {
393
399
  @author Jacob Kelley <jakie8@gmail.com>
394
400
  @license MIT
395
401
  **/
396
- var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
402
+ var p = "application/x-postmate-v1+json", x = 5, I = 0, L = function() {
397
403
  return ++I;
398
- }, u = function() {
404
+ }, c = function() {
399
405
  var t;
400
406
  return g.debug ? (t = console).log.apply(t, arguments) : null;
401
- }, L = function(t) {
407
+ }, M = function(t) {
402
408
  var e = document.createElement("a");
403
409
  e.href = t;
404
410
  var s = e.protocol.length > 4 ? e.protocol : window.location.protocol, n = e.host.length ? e.port === "80" || e.port === "443" ? e.hostname : e.host : window.location.host;
405
411
  return e.origin || s + "//" + n;
406
- }, M = {
412
+ }, z = {
407
413
  handshake: 1,
408
414
  "handshake-reply": 1,
409
415
  call: 1,
@@ -416,27 +422,27 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
416
422
  * @param {String|Boolean} allowedOrigin The whitelisted origin or false to skip origin check
417
423
  * @return {Boolean}
418
424
  */
419
- }, O = function(t, e) {
420
- return !(typeof e == "string" && t.origin !== e || !t.data || typeof t.data == "object" && !("postmate" in t.data) || t.data.type !== p || !M[t.data.postmate]);
421
- }, z = function(t, e) {
425
+ }, E = function(t, e) {
426
+ return !(typeof e == "string" && t.origin !== e || !t.data || typeof t.data == "object" && !("postmate" in t.data) || t.data.type !== p || !z[t.data.postmate]);
427
+ }, j = function(t, e) {
422
428
  var s = typeof t[e] == "function" ? t[e]() : t[e];
423
429
  return g.Promise.resolve(s);
424
- }, j = /* @__PURE__ */ function() {
430
+ }, H = /* @__PURE__ */ function() {
425
431
  function r(e) {
426
432
  var s = this;
427
- this.parent = e.parent, this.frame = e.frame, this.child = e.child, this.childOrigin = e.childOrigin, this.events = {}, process.env.NODE_ENV !== "production" && (u("Parent: Registering API"), u("Parent: Awaiting messages...")), this.listener = function(n) {
428
- if (!O(n, s.childOrigin))
433
+ this.parent = e.parent, this.frame = e.frame, this.child = e.child, this.childOrigin = e.childOrigin, this.events = {}, process.env.NODE_ENV !== "production" && (c("Parent: Registering API"), c("Parent: Awaiting messages...")), this.listener = function(n) {
434
+ if (!E(n, s.childOrigin))
429
435
  return !1;
430
436
  var i = ((n || {}).data || {}).value || {}, a = i.data, o = i.name;
431
- n.data.postmate === "emit" && (process.env.NODE_ENV !== "production" && u("Parent: Received event emission: " + o), o in s.events && s.events[o].call(s, a));
432
- }, this.parent.addEventListener("message", this.listener, !1), process.env.NODE_ENV !== "production" && u("Parent: Awaiting event emissions from Child");
437
+ n.data.postmate === "emit" && (process.env.NODE_ENV !== "production" && c("Parent: Received event emission: " + o), o in s.events && s.events[o].call(s, a));
438
+ }, this.parent.addEventListener("message", this.listener, !1), process.env.NODE_ENV !== "production" && c("Parent: Awaiting event emissions from Child");
433
439
  }
434
440
  var t = r.prototype;
435
441
  return t.get = function(s) {
436
442
  var n = this;
437
443
  return new g.Promise(function(i) {
438
- var a = x(), o = function c(h) {
439
- h.data.uid === a && h.data.postmate === "reply" && (n.parent.removeEventListener("message", c, !1), i(h.data.value));
444
+ var a = L(), o = function u(h) {
445
+ h.data.uid === a && h.data.postmate === "reply" && (n.parent.removeEventListener("message", u, !1), i(h.data.value));
440
446
  };
441
447
  n.parent.addEventListener("message", o, !1), n.child.postMessage({
442
448
  postmate: "request",
@@ -455,20 +461,20 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
455
461
  }, t.on = function(s, n) {
456
462
  this.events[s] = n;
457
463
  }, t.destroy = function() {
458
- process.env.NODE_ENV !== "production" && u("Parent: Destroying Postmate instance"), window.removeEventListener("message", this.listener, !1), this.frame.parentNode.removeChild(this.frame);
464
+ process.env.NODE_ENV !== "production" && c("Parent: Destroying Postmate instance"), window.removeEventListener("message", this.listener, !1), this.frame.parentNode.removeChild(this.frame);
459
465
  }, r;
460
- }(), H = /* @__PURE__ */ function() {
466
+ }(), F = /* @__PURE__ */ function() {
461
467
  function r(e) {
462
468
  var s = this;
463
- this.model = e.model, this.parent = e.parent, this.parentOrigin = e.parentOrigin, this.child = e.child, process.env.NODE_ENV !== "production" && (u("Child: Registering API"), u("Child: Awaiting messages...")), this.child.addEventListener("message", function(n) {
464
- if (O(n, s.parentOrigin)) {
465
- process.env.NODE_ENV !== "production" && u("Child: Received request", n.data);
466
- var i = n.data, a = i.property, o = i.uid, c = i.data;
469
+ this.model = e.model, this.parent = e.parent, this.parentOrigin = e.parentOrigin, this.child = e.child, process.env.NODE_ENV !== "production" && (c("Child: Registering API"), c("Child: Awaiting messages...")), this.child.addEventListener("message", function(n) {
470
+ if (E(n, s.parentOrigin)) {
471
+ process.env.NODE_ENV !== "production" && c("Child: Received request", n.data);
472
+ var i = n.data, a = i.property, o = i.uid, u = i.data;
467
473
  if (n.data.postmate === "call") {
468
- a in s.model && typeof s.model[a] == "function" && s.model[a](c);
474
+ a in s.model && typeof s.model[a] == "function" && s.model[a](u);
469
475
  return;
470
476
  }
471
- z(s.model, a).then(function(h) {
477
+ j(s.model, a).then(function(h) {
472
478
  return n.source.postMessage({
473
479
  property: a,
474
480
  postmate: "reply",
@@ -482,7 +488,7 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
482
488
  }
483
489
  var t = r.prototype;
484
490
  return t.emit = function(s, n) {
485
- process.env.NODE_ENV !== "production" && u('Child: Emitting Event "' + s + '"', n), this.parent.postMessage({
491
+ process.env.NODE_ENV !== "production" && c('Child: Emitting Event "' + s + '"', n), this.parent.postMessage({
486
492
  postmate: "emit",
487
493
  type: p,
488
494
  value: {
@@ -493,29 +499,29 @@ var p = "application/x-postmate-v1+json", D = 5, I = 0, x = function() {
493
499
  }, r;
494
500
  }(), g = /* @__PURE__ */ function() {
495
501
  function r(e) {
496
- var s = e.container, n = s === void 0 ? typeof n < "u" ? n : document.body : s, i = e.model, a = e.url, o = e.name, c = e.classListArray, h = c === void 0 ? [] : c;
502
+ var s = e.container, n = s === void 0 ? typeof n < "u" ? n : document.body : s, i = e.model, a = e.url, o = e.name, u = e.classListArray, h = u === void 0 ? [] : u;
497
503
  return this.parent = window, this.frame = document.createElement("iframe"), this.frame.name = o || "", this.frame.classList.add.apply(this.frame.classList, h), n.appendChild(this.frame), this.child = this.frame.contentWindow || this.frame.contentDocument.parentWindow, this.model = i || {}, this.sendHandshake(a);
498
504
  }
499
505
  var t = r.prototype;
500
506
  return t.sendHandshake = function(s) {
501
- var n = this, i = L(s), a = 0, o;
502
- return new r.Promise(function(c, h) {
507
+ var n = this, i = M(s), a = 0, o;
508
+ return new r.Promise(function(u, h) {
503
509
  var m = function v(y) {
504
- return O(y, i) ? y.data.postmate === "handshake-reply" ? (clearInterval(o), process.env.NODE_ENV !== "production" && u("Parent: Received handshake reply from Child"), n.parent.removeEventListener("message", v, !1), n.childOrigin = y.origin, process.env.NODE_ENV !== "production" && u("Parent: Saving Child origin", n.childOrigin), c(new j(n))) : (process.env.NODE_ENV !== "production" && u("Parent: Invalid handshake reply"), h("Failed handshake")) : !1;
510
+ return E(y, i) ? y.data.postmate === "handshake-reply" ? (clearInterval(o), process.env.NODE_ENV !== "production" && c("Parent: Received handshake reply from Child"), n.parent.removeEventListener("message", v, !1), n.childOrigin = y.origin, process.env.NODE_ENV !== "production" && c("Parent: Saving Child origin", n.childOrigin), u(new H(n))) : (process.env.NODE_ENV !== "production" && c("Parent: Invalid handshake reply"), h("Failed handshake")) : !1;
505
511
  };
506
512
  n.parent.addEventListener("message", m, !1);
507
513
  var f = function() {
508
- a++, process.env.NODE_ENV !== "production" && u("Parent: Sending handshake attempt " + a, {
514
+ a++, process.env.NODE_ENV !== "production" && c("Parent: Sending handshake attempt " + a, {
509
515
  childOrigin: i
510
516
  }), n.child.postMessage({
511
517
  postmate: "handshake",
512
518
  type: p,
513
519
  model: n.model
514
- }, i), a === D && clearInterval(o);
520
+ }, i), a === x && clearInterval(o);
515
521
  }, w = function() {
516
522
  f(), o = setInterval(f, 500);
517
523
  };
518
- n.frame.attachEvent ? n.frame.attachEvent("onload", w) : n.frame.onload = w, process.env.NODE_ENV !== "production" && u("Parent: Loading frame", {
524
+ n.frame.attachEvent ? n.frame.attachEvent("onload", w) : n.frame.onload = w, process.env.NODE_ENV !== "production" && c("Parent: Loading frame", {
519
525
  url: s
520
526
  }), n.frame.src = s;
521
527
  });
@@ -537,17 +543,17 @@ g.Model = /* @__PURE__ */ function() {
537
543
  return t.sendHandshakeReply = function() {
538
544
  var s = this;
539
545
  return new g.Promise(function(n, i) {
540
- var a = function o(c) {
541
- if (c.data.postmate) {
542
- if (c.data.postmate === "handshake") {
543
- process.env.NODE_ENV !== "production" && u("Child: Received handshake from Parent"), s.child.removeEventListener("message", o, !1), process.env.NODE_ENV !== "production" && u("Child: Sending handshake reply to Parent"), c.source.postMessage({
546
+ var a = function o(u) {
547
+ if (u.data.postmate) {
548
+ if (u.data.postmate === "handshake") {
549
+ process.env.NODE_ENV !== "production" && c("Child: Received handshake from Parent"), s.child.removeEventListener("message", o, !1), process.env.NODE_ENV !== "production" && c("Child: Sending handshake reply to Parent"), u.source.postMessage({
544
550
  postmate: "handshake-reply",
545
551
  type: p
546
- }, c.origin), s.parentOrigin = c.origin;
547
- var h = c.data.model;
552
+ }, u.origin), s.parentOrigin = u.origin;
553
+ var h = u.data.model;
548
554
  return h && (Object.keys(h).forEach(function(m) {
549
555
  s.model[m] = h[m];
550
- }), process.env.NODE_ENV !== "production" && u("Child: Inherited and extended model from Parent")), process.env.NODE_ENV !== "production" && u("Child: Saving Parent origin", s.parentOrigin), n(new H(s));
556
+ }), process.env.NODE_ENV !== "production" && c("Child: Inherited and extended model from Parent")), process.env.NODE_ENV !== "production" && c("Child: Saving Parent origin", s.parentOrigin), n(new F(s));
551
557
  }
552
558
  return i("Handshake Reply Failed");
553
559
  }
@@ -556,7 +562,7 @@ g.Model = /* @__PURE__ */ function() {
556
562
  });
557
563
  }, r;
558
564
  }();
559
- class F extends d {
565
+ class W extends d {
560
566
  async checkPhone(t, e) {
561
567
  const s = this.getStoreUrl(t, "/auth/check");
562
568
  return this.getResponse(await this.client.request("POST", s, e));
@@ -607,12 +613,13 @@ class F extends d {
607
613
  };
608
614
  }
609
615
  }
610
- class ke {
616
+ class Ee {
611
617
  constructor(t, e) {
612
618
  l(this, "client");
613
619
  l(this, "store");
614
620
  l(this, "auth");
615
621
  l(this, "customer");
622
+ l(this, "catalog");
616
623
  l(this, "categories");
617
624
  l(this, "products");
618
625
  l(this, "addresses");
@@ -622,51 +629,52 @@ class ke {
622
629
  l(this, "articles");
623
630
  l(this, "feedback");
624
631
  const s = k.build(t, e);
625
- this.store = new b(s), this.auth = new F(s), this.customer = new V(s), this.categories = new q(s), this.products = new N(s), this.addresses = new G(s), this.orders = new $(s), this.collections = new _(s), this.offers = new T(s), this.articles = new S(s), this.feedback = new C(s), this.client = s;
632
+ this.store = new _(s), this.auth = new W(s), this.customer = new D(s), this.catalog = new q(s), this.categories = new A(s), this.products = new $(s), this.addresses = new V(s), this.orders = new G(s), this.collections = new T(s), this.offers = new C(s), this.articles = new S(s), this.feedback = new N(s), this.client = s;
626
633
  }
627
634
  setApiToken(t) {
628
635
  return this.client.setToken(t), this;
629
636
  }
630
637
  }
631
- var W = /* @__PURE__ */ ((r) => (r.Female = "female", r.Male = "male", r.Other = "other", r))(W || {}), Z = /* @__PURE__ */ ((r) => (r.CloudPayments = "cloudpayments", r))(Z || {}), J = /* @__PURE__ */ ((r) => (r.Visa = "visa", r.MasterCard = "master-card", r.MIR = "mir", r.Maestro = "maestro", r.AmericanExpress = "american-express", r.DinersClub = "diners-club", r.Discover = "discover", r.JCB = "jcb", r.UnionPay = "union-pay", r))(J || {}), X = /* @__PURE__ */ ((r) => (r.Select = "select", r.MutipleSelect = "mutiple_select", r.Checkboxes = "checkboxes", r.Radios = "radios", r.Range = "range", r.Text = "text", r))(X || {}), B = /* @__PURE__ */ ((r) => (r.Integer = "integer", r.Float = "float", r))(B || {}), Y = /* @__PURE__ */ ((r) => (r.Increase = "increase", r.Decrease = "decrease", r))(Y || {}), Q = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Confirmed = "confirmed", r.Cancelled = "cancelled", r.Rejected = "rejected", r.Refunded = "refunded", r.PartiallyRefunded = "partially_refunded", r))(Q || {}), K = /* @__PURE__ */ ((r) => (r.Manual = "manual", r.Cashback = "cashback", r.ReferralReward = "referral_reward", r.RecruitReward = "recruit_reward", r.Payment = "payment", r.Cancellation = "cancellation", r.Refund = "refund", r.Adjustment = "adjustment", r.WelcomeBonuses = "welcome_bonuses", r.PromotionReward = "promotion_reward", r.External = "external", r))(K || {}), ee = /* @__PURE__ */ ((r) => (r.Delivery = "delivery", r.Pickup = "pickup", r.OnPremise = "on_premise", r))(ee || {}), te = /* @__PURE__ */ ((r) => (r.Payment = "payment", r.Refund = "refund", r))(te || {}), re = /* @__PURE__ */ ((r) => (r.Cash = "cash", r.CreditCard = "credit-card", r.CloudPayments = "cloudpayments", r.CardToken = "card_token", r.Bonuses = "bonuses", r))(re || {}), se = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Confirmed = "confirmed", r.Cancelled = "cancelled", r.PendingRefund = "pending_refund", r.Refunding = "refunding", r.Refunded = "refunded", r))(se || {}), ne = /* @__PURE__ */ ((r) => (r.Auth = "auth", r.Charge = "charge", r))(ne || {}), ie = /* @__PURE__ */ ((r) => (r.PersonsCount = "persons_count", r.DeliveryTime = "delivery_time", r.DeliveryIntervals = "delivery_intervals", r))(ie || {}), ae = /* @__PURE__ */ ((r) => (r.PriceMismatch = "price_mismatch", r.OutOfStock = "out_of_stock", r.Unavailable = "unavailable", r))(ae || {}), oe = /* @__PURE__ */ ((r) => (r.None = "none", r.Cleanup = "cleanup", r))(oe || {}), le = /* @__PURE__ */ ((r) => (r.Piece = "piece", r.Gram = "gram", r.Kilogram = "kilogram", r.Meter = "meter", r))(le || {}), ue = /* @__PURE__ */ ((r) => (r.Weight = "weight", r.Width = "width", r.Height = "height", r.Length = "length", r))(ue || {}), ce = /* @__PURE__ */ ((r) => (r.Netto = "netto", r.Brutto = "brutto", r))(ce || {}), he = /* @__PURE__ */ ((r) => (r.Color = "color", r))(he || {}), de = /* @__PURE__ */ ((r) => (r.Category = "category", r.Group = "group", r.VariantOption = "variant_option", r.VariantOptionValue = "variant_option_value", r))(de || {}), ge = /* @__PURE__ */ ((r) => (r.Amount = "amount", r.Percentage = "percentage", r))(ge || {}), pe = /* @__PURE__ */ ((r) => (r.Email = "email", r.Website = "website", r.Vk = "vk", r.Facebook = "facebook", r.Instagram = "instagram", r.Twitter = "twitter", r.Ok = "ok", r.Tiktok = "tiktok", r))(pe || {}), me = /* @__PURE__ */ ((r) => (r.Yes = "yes", r.No = "no", r.Both = "both", r))(me || {}), ve = /* @__PURE__ */ ((r) => (r.Disabled = "disabled", r.Preauth = "preauth", r.Confirmation = "confirmation", r))(ve || {}), fe = /* @__PURE__ */ ((r) => (r.Dadata = "dadata", r.Manual = "manual", r))(fe || {}), we = /* @__PURE__ */ ((r) => (r.Registration = "registration", r.ResendRegistrationCode = "resend_registration_code", r.ResetPassword = "reset_password", r.OrderSubmission = "order_submission", r.FeedbackRequest = "feedback_request", r.CallbackRequest = "callback_request", r))(we || {});
638
+ var Z = /* @__PURE__ */ ((r) => (r.Female = "female", r.Male = "male", r.Other = "other", r))(Z || {}), J = /* @__PURE__ */ ((r) => (r.CloudPayments = "cloudpayments", r))(J || {}), X = /* @__PURE__ */ ((r) => (r.Visa = "visa", r.MasterCard = "master-card", r.MIR = "mir", r.Maestro = "maestro", r.AmericanExpress = "american-express", r.DinersClub = "diners-club", r.Discover = "discover", r.JCB = "jcb", r.UnionPay = "union-pay", r))(X || {}), B = /* @__PURE__ */ ((r) => (r.Select = "select", r.MutipleSelect = "mutiple_select", r.Checkboxes = "checkboxes", r.Radios = "radios", r.Range = "range", r.Text = "text", r))(B || {}), Y = /* @__PURE__ */ ((r) => (r.Integer = "integer", r.Float = "float", r))(Y || {}), Q = /* @__PURE__ */ ((r) => (r.Increase = "increase", r.Decrease = "decrease", r))(Q || {}), K = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Confirmed = "confirmed", r.Cancelled = "cancelled", r.Rejected = "rejected", r.Refunded = "refunded", r.PartiallyRefunded = "partially_refunded", r))(K || {}), ee = /* @__PURE__ */ ((r) => (r.Manual = "manual", r.Cashback = "cashback", r.ReferralReward = "referral_reward", r.RecruitReward = "recruit_reward", r.Payment = "payment", r.Cancellation = "cancellation", r.Refund = "refund", r.Adjustment = "adjustment", r.WelcomeBonuses = "welcome_bonuses", r.PromotionReward = "promotion_reward", r.External = "external", r))(ee || {}), te = /* @__PURE__ */ ((r) => (r.Delivery = "delivery", r.Pickup = "pickup", r.OnPremise = "on_premise", r))(te || {}), re = /* @__PURE__ */ ((r) => (r.Payment = "payment", r.Refund = "refund", r))(re || {}), se = /* @__PURE__ */ ((r) => (r.Cash = "cash", r.CreditCard = "credit-card", r.CloudPayments = "cloudpayments", r.CardToken = "card_token", r.Bonuses = "bonuses", r))(se || {}), ne = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Confirmed = "confirmed", r.Cancelled = "cancelled", r.PendingRefund = "pending_refund", r.Refunding = "refunding", r.Refunded = "refunded", r))(ne || {}), ie = /* @__PURE__ */ ((r) => (r.Auth = "auth", r.Charge = "charge", r))(ie || {}), ae = /* @__PURE__ */ ((r) => (r.PersonsCount = "persons_count", r.DeliveryTime = "delivery_time", r.DeliveryIntervals = "delivery_intervals", r))(ae || {}), oe = /* @__PURE__ */ ((r) => (r.PriceMismatch = "price_mismatch", r.OutOfStock = "out_of_stock", r.Unavailable = "unavailable", r))(oe || {}), le = /* @__PURE__ */ ((r) => (r.None = "none", r.Cleanup = "cleanup", r))(le || {}), ce = /* @__PURE__ */ ((r) => (r.Piece = "piece", r.Gram = "gram", r.Kilogram = "kilogram", r.Meter = "meter", r))(ce || {}), ue = /* @__PURE__ */ ((r) => (r.Weight = "weight", r.Width = "width", r.Height = "height", r.Length = "length", r))(ue || {}), he = /* @__PURE__ */ ((r) => (r.Netto = "netto", r.Brutto = "brutto", r))(he || {}), de = /* @__PURE__ */ ((r) => (r.Color = "color", r))(de || {}), ge = /* @__PURE__ */ ((r) => (r.Category = "category", r.Group = "group", r.VariantOption = "variant_option", r.VariantOptionValue = "variant_option_value", r))(ge || {}), pe = /* @__PURE__ */ ((r) => (r.Amount = "amount", r.Percentage = "percentage", r))(pe || {}), me = /* @__PURE__ */ ((r) => (r.Email = "email", r.Website = "website", r.Vk = "vk", r.Facebook = "facebook", r.Instagram = "instagram", r.Twitter = "twitter", r.Ok = "ok", r.Tiktok = "tiktok", r))(me || {}), ve = /* @__PURE__ */ ((r) => (r.Yes = "yes", r.No = "no", r.Both = "both", r))(ve || {}), fe = /* @__PURE__ */ ((r) => (r.Disabled = "disabled", r.Preauth = "preauth", r.Confirmation = "confirmation", r))(fe || {}), we = /* @__PURE__ */ ((r) => (r.Dadata = "dadata", r.Manual = "manual", r))(we || {}), ye = /* @__PURE__ */ ((r) => (r.Registration = "registration", r.ResendRegistrationCode = "resend_registration_code", r.ResetPassword = "reset_password", r.OrderSubmission = "order_submission", r.FeedbackRequest = "feedback_request", r.CallbackRequest = "callback_request", r))(ye || {});
632
639
  export {
633
- Z as AcquiringType,
640
+ J as AcquiringType,
634
641
  U as AddressSuggestionsProvider,
635
- fe as AddressesProvider,
642
+ we as AddressesProvider,
636
643
  S as ArticlesResource,
637
- K as BonusesTransactionReason,
638
- Q as BonusesTransactionStatus,
639
- Y as BonusesTransactionType,
640
- q as CategoriesResource,
641
- ne as CloudpaymentsChargeType,
642
- _ as CollectionsResource,
643
- pe as ContactType,
644
- ee as DeliveryMethod,
644
+ ee as BonusesTransactionReason,
645
+ K as BonusesTransactionStatus,
646
+ Q as BonusesTransactionType,
647
+ q as CatalogResource,
648
+ A as CategoriesResource,
649
+ ie as CloudpaymentsChargeType,
650
+ T as CollectionsResource,
651
+ me as ContactType,
652
+ te as DeliveryMethod,
645
653
  ue as Dimension,
646
- ce as DimensionType,
647
- ge as DiscountType,
648
- B as FeatureRange,
649
- X as FeatureType,
650
- C as FeedbackResource,
651
- W as Gender,
652
- T as OffersResource,
653
- ve as OrderAuthenticationMethod,
654
- oe as OrderCartCheckerResultAction,
655
- ae as OrderCartCheckerResultReason,
656
- ie as OrderOptionKind,
657
- se as OrderPaymentTransactionStatus,
658
- te as OrderPaymentTransactionType,
659
- $ as OrdersResource,
660
- re as PaymentMethod,
661
- J as PaymentSystemType,
662
- de as ProductContextType,
663
- N as ProductsResource,
664
- we as RecaptchaAction,
665
- b as StoreResource,
666
- me as TernaryFilter,
667
- le as UnitType,
668
- he as VariantOptionType,
669
- E as ZenkyError,
670
- A as ZenkyErrorBuilder,
671
- ke as ZenkyStorefront
654
+ he as DimensionType,
655
+ pe as DiscountType,
656
+ Y as FeatureRange,
657
+ B as FeatureType,
658
+ N as FeedbackResource,
659
+ Z as Gender,
660
+ C as OffersResource,
661
+ fe as OrderAuthenticationMethod,
662
+ le as OrderCartCheckerResultAction,
663
+ oe as OrderCartCheckerResultReason,
664
+ ae as OrderOptionKind,
665
+ ne as OrderPaymentTransactionStatus,
666
+ re as OrderPaymentTransactionType,
667
+ G as OrdersResource,
668
+ se as PaymentMethod,
669
+ X as PaymentSystemType,
670
+ ge as ProductContextType,
671
+ $ as ProductsResource,
672
+ ye as RecaptchaAction,
673
+ _ as StoreResource,
674
+ ve as TernaryFilter,
675
+ ce as UnitType,
676
+ de as VariantOptionType,
677
+ O as ZenkyError,
678
+ b as ZenkyErrorBuilder,
679
+ Ee as ZenkyStorefront
672
680
  };
@@ -1,7 +1,7 @@
1
- (function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.zenkyStorefrontApi={}))})(this,function(i){"use strict";var we=Object.defineProperty;var ke=(i,g,h)=>g in i?we(i,g,{enumerable:!0,configurable:!0,writable:!0,value:h}):i[g]=h;var u=(i,g,h)=>(ke(i,typeof g!="symbol"?g+"":g,h),h);var g=(r=>(r.DADATA="dadata",r))(g||{});class h{constructor(t){this.client=t}getStoreUrl(t,e,s={}){return this.client.getStoreUrl(t,e,s)}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const e=t.data,s=t.meta.pagination;return{items:e,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class U extends h{async getArticleCategories(t){const e=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",e))}async getArticleCategory(t,e){const s=this.getStoreUrl(t,`/articles/categories/${e}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,e){const s=this.getStoreUrl(t,"/articles",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,e,s){const n=this.getStoreUrl(t,`/articles/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class S extends h{async getCategories(t,e){const s=this.getStoreUrl(t,"/categories",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,e){const s=this.getStoreUrl(t,"/categories/tree",e);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,e,s){const n=this.getStoreUrl(t,`/categories/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getFeaturesGroups(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features`);return this.getResponse(await this.client.request("GET",s))}}class O extends Error{constructor(e,s){super(e);u(this,"err");this.err=s}}class q{static async build(t){const e=await t.json();switch(t.status){case 401:return new O((e==null?void 0:e.message)??"Unauthenticated.",null);default:return new O(e==null?void 0:e.message,(e==null?void 0:e.error)||null)}}}class R{constructor(t,e,s,n,a,o,l){u(this,"baseUrl");u(this,"baseAuthUrl");u(this,"token");u(this,"client");u(this,"timezone");u(this,"fetchFunction");u(this,"fetchOptions");this.baseUrl=t,this.baseAuthUrl=e,this.token=s,this.client=n,this.timezone=a,this.fetchFunction=typeof o=="function"?o:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,e){return new R((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.baseAuthUrl)||"https://auth.zenky.io/",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",e,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}getBaseAuthUrl(){return this.baseAuthUrl}getStoreUrl(t,e,s={}){return this.getUrl(`/store/${t}${e}`,s)}getUrl(t,e={}){if(!Object.keys(e).length)return t;const s=[];Object.keys(e).forEach(a=>{s.push(`${a}=${e[a]}`)});const n=t.includes("?")?"&":"?";return`${t}${n}${s.join("&")}`}async request(t,e,s,n){const a={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};n?a.Authorization=`Bearer ${n}`:this.token&&(a.Authorization=`Bearer ${this.token}`);const o={method:t,mode:"cors",...this.fetchOptions};s&&(a["Content-Type"]="application/json",o.body=JSON.stringify(s)),o.headers=a;const l=await this.fetchFunction.call(null,`${this.baseUrl}${e}`,o);if(l.ok)return l.status===204?!0:l.json();throw await q.build(l)}}class T extends h{async getStore(t){const e=this.client.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",e))}async getStoreByBundleId(t){const e=this.client.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",e))}}class A extends h{async getCollections(t,e){const s=this.getStoreUrl(t,"/collections",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,e){const s=this.getStoreUrl(t,`/collections/${e}`);return this.getResponse(await this.client.request("GET",s))}}class b extends h{async getOffers(t,e){const s=this.getStoreUrl(t,"/offers",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,e,s){const n=this.getStoreUrl(t,`/offers/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class _ extends h{async createFeedback(t,e){const s=this.getStoreUrl(t,"/feedback",e);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,e){const s=this.getStoreUrl(t,"/callback",e);return await this.client.request("POST",s),!0}}class C extends h{async getProducts(t,e){const s=this.getStoreUrl(t,"/products",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,e,s){const n=this.getStoreUrl(t,`/products/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getProductVariantPrice(t,e,s,n){const a=this.getStoreUrl(t,`/products/${e}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",a,n))}}class N extends h{getOrderUrl(t,e,s,n){const a=typeof e=="string"?e:e.id,o=typeof e=="string"?void 0:e.token;return this.getStoreUrl(t,`/orders/${a}${s}${o?"?token="+o:""}`,n)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,e,s){const n=this.getStoreUrl(t,"/orders",e);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,s))}async createOrder(t,e,s){const n=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",n,e,s))}async getOrder(t,e,s){const n=this.getOrderUrl(t,e,"",s);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderSettings(t,e){const s=this.getOrderUrl(t,e,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async addProductVariantToOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async removeProductVariantFromOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products/remove");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async checkProducts(t,e){const s=this.getOrderUrl(t,e,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e)))}async getOrderCheckoutUrl(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/url");return this.getResponse(await this.client.request("POST",n,{redirect_url:s},this.getApiToken(e))).url}async setOrderCustomer(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/customer");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async setOrderDeliveryMethod(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/delivery");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async setOrderPayments(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async getOrderBonusesPreview(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments/bonuses",{amount:s});return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderTotal(t,e){const s=this.getOrderUrl(t,e,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async checkoutOrder(t,e,s){const n=this.getOrderUrl(t,e,"/checkout");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async confirmOrder(t,e,s){const n=this.getOrderUrl(t,e,"/confirm");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async resendOrderConfirmationCode(t,e){const s=this.getOrderUrl(t,e,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(e)),!0}async getOrderBonusesTransactions(t,e,s){const n=this.getOrderUrl(t,e,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderCashbackTransaction(t,e){const s=this.getOrderUrl(t,e,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async dispatchPromotionsChecker(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e))).dispatched}async getOrderPromotionRewards(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async getCloudpaymentsReceipt(t,e,s){const n=this.getOrderUrl(t,e,`/payments/${s}/receipt`);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}}class oe extends h{async getAddressSuggestions(t,e){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,e))}}class le extends h{async getProfile(t,e,s){const n=this.getStoreUrl(t,"/me",e);return this.getResponse(await this.client.request("GET",n,null,s))}async updateProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",n,e,s))}async removeProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",n,e,s),!0}async getSettings(t,e){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,e))}async updateSettings(t,e,s){const n=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",n,e,s))}async getAddresses(t,e,s){const n=this.getStoreUrl(t,"/me/addresses",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async createAddress(t,e,s){const n=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",n,e,s))}async updateAddress(t,e,s,n){const a=this.getStoreUrl(t,`/me/addresses/${e}`);return this.getResponse(await this.client.request("PUT",a,s,n))}async deleteAddress(t,e,s){const n=this.getStoreUrl(t,`/me/addresses/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getPaymentMethods(t,e,s){const n=this.getStoreUrl(t,"/me/payment-methods",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async deletePaymentMethod(t,e,s){const n=this.getStoreUrl(t,`/me/payment-methods/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getBonusesTransactions(t,e,s){const n=this.getStoreUrl(t,"/me/loyalty/transactions",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async getBonusesBalance(t,e){const s=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",s,null,e))}async revokeToken(t,e){const s=this.getStoreUrl(t,"/me/logout");return await this.client.request("POST",s,null,e),!0}}/**
1
+ (function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.zenkyStorefrontApi={}))})(this,function(i){"use strict";var ke=Object.defineProperty;var Oe=(i,g,u)=>g in i?ke(i,g,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[g]=u;var c=(i,g,u)=>(Oe(i,typeof g!="symbol"?g+"":g,u),u);var g=(r=>(r.DADATA="dadata",r))(g||{});class u{constructor(t){this.client=t}getStoreUrl(t,e,s={}){return this.client.getStoreUrl(t,e,s)}getPaginatedResponse(t){if(!t||!Array.isArray(t.data)||!t.meta||!t.meta.pagination)throw new Error("getPaginatedResponse(): Invalid response.");const e=t.data,s=t.meta.pagination;return{items:e,pagination:s}}getResponse(t){if(!t||!t.data)throw new Error("getResponse(): Invalid response.");return t.data}}class U extends u{async getArticleCategories(t){const e=this.getStoreUrl(t,"/articles/categories");return this.getPaginatedResponse(await this.client.request("GET",e))}async getArticleCategory(t,e){const s=this.getStoreUrl(t,`/articles/categories/${e}`);return this.getResponse(await this.client.request("GET",s))}async getArticles(t,e){const s=this.getStoreUrl(t,"/articles",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getArticle(t,e,s){const n=this.getStoreUrl(t,`/articles/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class S extends u{async getCatalog(t){const e=this.getStoreUrl(t,"/catalog");return this.getResponse(await this.client.request("GET",e))}}class q extends u{async getCategories(t,e){const s=this.getStoreUrl(t,"/categories",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCategoriesTree(t,e){const s=this.getStoreUrl(t,"/categories/tree",e);return this.getResponse(await this.client.request("GET",s))}async getCategory(t,e,s){const n=this.getStoreUrl(t,`/categories/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getFeaturesGroups(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features/groups`);return this.getResponse(await this.client.request("GET",s))}async getFeatures(t,e){const s=this.getStoreUrl(t,`/categories/${e}/features`);return this.getResponse(await this.client.request("GET",s))}}class O extends Error{constructor(e,s){super(e);c(this,"err");this.err=s}}class T{static async build(t){const e=await t.json();switch(t.status){case 401:return new O((e==null?void 0:e.message)??"Unauthenticated.",null);default:return new O(e==null?void 0:e.message,(e==null?void 0:e.error)||null)}}}class R{constructor(t,e,s,n,a,o,l){c(this,"baseUrl");c(this,"baseAuthUrl");c(this,"token");c(this,"client");c(this,"timezone");c(this,"fetchFunction");c(this,"fetchOptions");this.baseUrl=t,this.baseAuthUrl=e,this.token=s,this.client=n,this.timezone=a,this.fetchFunction=typeof o=="function"?o:fetch,this.fetchOptions=typeof l<"u"?l:{}}static build(t,e){return new R((t==null?void 0:t.baseUrl)||"https://storefront.zenky.io/v1",(t==null?void 0:t.baseAuthUrl)||"https://auth.zenky.io/",(t==null?void 0:t.token)||null,(t==null?void 0:t.client)||"web",(t==null?void 0:t.timezone)||"UTC",e,t==null?void 0:t.fetchOptions)}setToken(t){return this.token=t,this}getBaseAuthUrl(){return this.baseAuthUrl}getStoreUrl(t,e,s={}){return this.getUrl(`/store/${t}${e}`,s)}getUrl(t,e={}){if(!Object.keys(e).length)return t;const s=[];Object.keys(e).forEach(a=>{s.push(`${a}=${e[a]}`)});const n=t.includes("?")?"&":"?";return`${t}${n}${s.join("&")}`}async request(t,e,s,n){const a={Accept:"application/json","X-Zenky-Client":this.client,"X-Timezone":this.timezone};n?a.Authorization=`Bearer ${n}`:this.token&&(a.Authorization=`Bearer ${this.token}`);const o={method:t,mode:"cors",...this.fetchOptions};s&&(a["Content-Type"]="application/json",o.body=JSON.stringify(s)),o.headers=a;const l=await this.fetchFunction.call(null,`${this.baseUrl}${e}`,o);if(l.ok)return l.status===204?!0:l.json();throw await T.build(l)}}class A extends u{async getStore(t){const e=this.client.getUrl(`/store/${t}`);return this.getResponse(await this.client.request("GET",e))}async getStoreByBundleId(t){const e=this.client.getUrl(`/store/by-bundle/${t}`);return this.getResponse(await this.client.request("GET",e))}}class b extends u{async getCollections(t,e){const s=this.getStoreUrl(t,"/collections",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getCollection(t,e){const s=this.getStoreUrl(t,`/collections/${e}`);return this.getResponse(await this.client.request("GET",s))}}class _ extends u{async getOffers(t,e){const s=this.getStoreUrl(t,"/offers",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getOffer(t,e,s){const n=this.getStoreUrl(t,`/offers/${e}`,s);return this.getResponse(await this.client.request("GET",n))}}class C extends u{async createFeedback(t,e){const s=this.getStoreUrl(t,"/feedback",e);return this.getResponse(await this.client.request("POST",s))}async createCallback(t,e){const s=this.getStoreUrl(t,"/callback",e);return await this.client.request("POST",s),!0}}class N extends u{async getProducts(t,e){const s=this.getStoreUrl(t,"/products",e);return this.getPaginatedResponse(await this.client.request("GET",s))}async getProduct(t,e,s){const n=this.getStoreUrl(t,`/products/${e}`,s);return this.getResponse(await this.client.request("GET",n))}async getProductVariantPrice(t,e,s,n){const a=this.getStoreUrl(t,`/products/${e}/variants/${s}/price`);return this.getResponse(await this.client.request("POST",a,n))}}class $ extends u{getOrderUrl(t,e,s,n){const a=typeof e=="string"?e:e.id,o=typeof e=="string"?void 0:e.token;return this.getStoreUrl(t,`/orders/${a}${s}${o?"?token="+o:""}`,n)}getApiToken(t){if(!(typeof t=="string"||typeof t.api_token>"u"))return t.api_token}async getOrders(t,e,s){const n=this.getStoreUrl(t,"/orders",e);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,s))}async createOrder(t,e,s){const n=this.getStoreUrl(t,"/orders");return this.getResponse(await this.client.request("POST",n,e,s))}async getOrder(t,e,s){const n=this.getOrderUrl(t,e,"",s);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderSettings(t,e){const s=this.getOrderUrl(t,e,"/settings");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async addProductVariantToOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async removeProductVariantFromOrder(t,e,s){const n=this.getOrderUrl(t,e,"/products/remove");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async checkProducts(t,e){const s=this.getOrderUrl(t,e,"/products/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e)))}async getOrderCheckoutUrl(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/url");return this.getResponse(await this.client.request("POST",n,{redirect_url:s},this.getApiToken(e))).url}async setOrderCustomer(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/customer");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async setOrderDeliveryMethod(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/delivery");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async setOrderPayments(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async getOrderBonusesPreview(t,e,s){const n=this.getOrderUrl(t,e,"/checkout/payments/bonuses",{amount:s});return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderTotal(t,e){const s=this.getOrderUrl(t,e,"/checkout/total");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async checkoutOrder(t,e,s){const n=this.getOrderUrl(t,e,"/checkout");return this.getResponse(await this.client.request("POST",n,s,this.getApiToken(e)))}async confirmOrder(t,e,s){const n=this.getOrderUrl(t,e,"/confirm");return await this.client.request("POST",n,s,this.getApiToken(e)),!0}async resendOrderConfirmationCode(t,e){const s=this.getOrderUrl(t,e,"/confirm/resend");return await this.client.request("POST",s,void 0,this.getApiToken(e)),!0}async getOrderBonusesTransactions(t,e,s){const n=this.getOrderUrl(t,e,"/loyalty/transactions",s);return this.getPaginatedResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}async getOrderCashbackTransaction(t,e){const s=this.getOrderUrl(t,e,"/loyalty/transactions/cashback");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async dispatchPromotionsChecker(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/check");return this.getResponse(await this.client.request("POST",s,void 0,this.getApiToken(e))).dispatched}async getOrderPromotionRewards(t,e){const s=this.getOrderUrl(t,e,"/loyalty/promotions/rewards");return this.getResponse(await this.client.request("GET",s,void 0,this.getApiToken(e)))}async getCloudpaymentsReceipt(t,e,s){const n=this.getOrderUrl(t,e,`/payments/${s}/receipt`);return this.getResponse(await this.client.request("GET",n,void 0,this.getApiToken(e)))}}class le extends u{async getAddressSuggestions(t,e){const s=this.getStoreUrl(t,"/suggestions/address");return this.getResponse(await this.client.request("POST",s,e))}}class ce extends u{async getProfile(t,e,s){const n=this.getStoreUrl(t,"/me",e);return this.getResponse(await this.client.request("GET",n,null,s))}async updateProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return this.getResponse(await this.client.request("PUT",n,e,s))}async removeProfile(t,e,s){const n=this.getStoreUrl(t,"/me");return await this.client.request("DELETE",n,e,s),!0}async getSettings(t,e){const s=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("GET",s,null,e))}async updateSettings(t,e,s){const n=this.getStoreUrl(t,"/me/settings");return this.getResponse(await this.client.request("PUT",n,e,s))}async getAddresses(t,e,s){const n=this.getStoreUrl(t,"/me/addresses",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async createAddress(t,e,s){const n=this.getStoreUrl(t,"/me/addresses");return this.getResponse(await this.client.request("POST",n,e,s))}async updateAddress(t,e,s,n){const a=this.getStoreUrl(t,`/me/addresses/${e}`);return this.getResponse(await this.client.request("PUT",a,s,n))}async deleteAddress(t,e,s){const n=this.getStoreUrl(t,`/me/addresses/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getPaymentMethods(t,e,s){const n=this.getStoreUrl(t,"/me/payment-methods",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async deletePaymentMethod(t,e,s){const n=this.getStoreUrl(t,`/me/payment-methods/${e}`);return await this.client.request("DELETE",n,null,s),!0}async getBonusesTransactions(t,e,s){const n=this.getStoreUrl(t,"/me/loyalty/transactions",e);return this.getPaginatedResponse(await this.client.request("GET",n,null,s))}async getBonusesBalance(t,e){const s=this.getStoreUrl(t,"/me/loyalty/balance");return this.getResponse(await this.client.request("GET",s,null,e))}async revokeToken(t,e){const s=this.getStoreUrl(t,"/me/logout");return await this.client.request("POST",s,null,e),!0}}/**
2
2
  postmate - A powerful, simple, promise-based postMessage library
3
3
  @version v1.5.2
4
4
  @link https://github.com/dollarshaveclub/postmate
5
5
  @author Jacob Kelley <jakie8@gmail.com>
6
6
  @license MIT
7
- **/var f="application/x-postmate-v1+json",ue=5,ce=0,he=function(){return++ce},c=function(){var t;return m.debug?(t=console).log.apply(t,arguments):null},de=function(t){var e=document.createElement("a");e.href=t;var s=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||s+"//"+n},ge={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},E=function(t,e){return!(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==f||!ge[t.data.postmate])},pe=function(t,e){var s=typeof t[e]=="function"?t[e]():t[e];return m.Promise.resolve(s)},me=function(){function r(e){var s=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},process.env.NODE_ENV!=="production"&&(c("Parent: Registering API"),c("Parent: Awaiting messages...")),this.listener=function(n){if(!E(n,s.childOrigin))return!1;var a=((n||{}).data||{}).value||{},o=a.data,l=a.name;n.data.postmate==="emit"&&(process.env.NODE_ENV!=="production"&&c("Parent: Received event emission: "+l),l in s.events&&s.events[l].call(s,o))},this.parent.addEventListener("message",this.listener,!1),process.env.NODE_ENV!=="production"&&c("Parent: Awaiting event emissions from Child")}var t=r.prototype;return t.get=function(s){var n=this;return new m.Promise(function(a){var o=he(),l=function d(p){p.data.uid===o&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(p.data.value))};n.parent.addEventListener("message",l,!1),n.child.postMessage({postmate:"request",type:f,property:s,uid:o},n.childOrigin)})},t.call=function(s,n){this.child.postMessage({postmate:"call",type:f,property:s,data:n},this.childOrigin)},t.on=function(s,n){this.events[s]=n},t.destroy=function(){process.env.NODE_ENV!=="production"&&c("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},r}(),fe=function(){function r(e){var s=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,process.env.NODE_ENV!=="production"&&(c("Child: Registering API"),c("Child: Awaiting messages...")),this.child.addEventListener("message",function(n){if(E(n,s.parentOrigin)){process.env.NODE_ENV!=="production"&&c("Child: Received request",n.data);var a=n.data,o=a.property,l=a.uid,d=a.data;if(n.data.postmate==="call"){o in s.model&&typeof s.model[o]=="function"&&s.model[o](d);return}pe(s.model,o).then(function(p){return n.source.postMessage({property:o,postmate:"reply",type:f,uid:l,value:p},n.origin)})}})}var t=r.prototype;return t.emit=function(s,n){process.env.NODE_ENV!=="production"&&c('Child: Emitting Event "'+s+'"',n),this.parent.postMessage({postmate:"emit",type:f,value:{name:s,data:n}},this.parentOrigin)},r}(),m=function(){function r(e){var s=e.container,n=s===void 0?typeof n<"u"?n:document.body:s,a=e.model,o=e.url,l=e.name,d=e.classListArray,p=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=l||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(o)}var t=r.prototype;return t.sendHandshake=function(s){var n=this,a=de(s),o=0,l;return new r.Promise(function(d,p){var v=function y(P){return E(P,a)?P.data.postmate==="handshake-reply"?(clearInterval(l),process.env.NODE_ENV!=="production"&&c("Parent: Received handshake reply from Child"),n.parent.removeEventListener("message",y,!1),n.childOrigin=P.origin,process.env.NODE_ENV!=="production"&&c("Parent: Saving Child origin",n.childOrigin),d(new me(n))):(process.env.NODE_ENV!=="production"&&c("Parent: Invalid handshake reply"),p("Failed handshake")):!1};n.parent.addEventListener("message",v,!1);var w=function(){o++,process.env.NODE_ENV!=="production"&&c("Parent: Sending handshake attempt "+o,{childOrigin:a}),n.child.postMessage({postmate:"handshake",type:f,model:n.model},a),o===ue&&clearInterval(l)},k=function(){w(),l=setInterval(w,500)};n.frame.attachEvent?n.frame.attachEvent("onload",k):n.frame.onload=k,process.env.NODE_ENV!=="production"&&c("Parent: Loading frame",{url:s}),n.frame.src=s})},r}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),m.Model=function(){function r(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=r.prototype;return t.sendHandshakeReply=function(){var s=this;return new m.Promise(function(n,a){var o=function l(d){if(d.data.postmate){if(d.data.postmate==="handshake"){process.env.NODE_ENV!=="production"&&c("Child: Received handshake from Parent"),s.child.removeEventListener("message",l,!1),process.env.NODE_ENV!=="production"&&c("Child: Sending handshake reply to Parent"),d.source.postMessage({postmate:"handshake-reply",type:f},d.origin),s.parentOrigin=d.origin;var p=d.data.model;return p&&(Object.keys(p).forEach(function(v){s.model[v]=p[v]}),process.env.NODE_ENV!=="production"&&c("Child: Inherited and extended model from Parent")),process.env.NODE_ENV!=="production"&&c("Child: Saving Parent origin",s.parentOrigin),n(new fe(s))}return a("Handshake Reply Failed")}};s.child.addEventListener("message",o,!1)})},r}();class ve extends h{async checkPhone(t,e){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,e))}async register(t,e){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,e))}async confirmRegistration(t,e){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,e))}async resendRegistrationConfirmation(t,e){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,e))}async login(t,e){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,e))}async dispatchPasswordReset(t,e){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,e))}async resetPassword(t,e){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,e))}useAuthenticationModal(t,e,s,n={}){const a=`${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;let o=null,l=null;return{initAuthenticationModal:async()=>new Promise(v=>{const w=typeof e=="string"?document.querySelector(e):e;o=new m({...n,container:w,url:a}),o.then(k=>{l=k,l.on("zenky:auth:token",s),l.on("zenky:auth:resize",y=>{l.frame.style.height=`${y}px`}),v(!0)})}),destroyAuthenticationModal:()=>{l&&l.destroy()}}}}class ye{constructor(t,e){u(this,"client");u(this,"store");u(this,"auth");u(this,"customer");u(this,"categories");u(this,"products");u(this,"addresses");u(this,"orders");u(this,"collections");u(this,"offers");u(this,"articles");u(this,"feedback");const s=R.build(t,e);this.store=new T(s),this.auth=new ve(s),this.customer=new le(s),this.categories=new S(s),this.products=new C(s),this.addresses=new oe(s),this.orders=new N(s),this.collections=new A(s),this.offers=new b(s),this.articles=new U(s),this.feedback=new _(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var $=(r=>(r.Female="female",r.Male="male",r.Other="other",r))($||{}),G=(r=>(r.CloudPayments="cloudpayments",r))(G||{}),D=(r=>(r.Visa="visa",r.MasterCard="master-card",r.MIR="mir",r.Maestro="maestro",r.AmericanExpress="american-express",r.DinersClub="diners-club",r.Discover="discover",r.JCB="jcb",r.UnionPay="union-pay",r))(D||{}),V=(r=>(r.Select="select",r.MutipleSelect="mutiple_select",r.Checkboxes="checkboxes",r.Radios="radios",r.Range="range",r.Text="text",r))(V||{}),I=(r=>(r.Integer="integer",r.Float="float",r))(I||{}),M=(r=>(r.Increase="increase",r.Decrease="decrease",r))(M||{}),L=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.Rejected="rejected",r.Refunded="refunded",r.PartiallyRefunded="partially_refunded",r))(L||{}),z=(r=>(r.Manual="manual",r.Cashback="cashback",r.ReferralReward="referral_reward",r.RecruitReward="recruit_reward",r.Payment="payment",r.Cancellation="cancellation",r.Refund="refund",r.Adjustment="adjustment",r.WelcomeBonuses="welcome_bonuses",r.PromotionReward="promotion_reward",r.External="external",r))(z||{}),j=(r=>(r.Delivery="delivery",r.Pickup="pickup",r.OnPremise="on_premise",r))(j||{}),F=(r=>(r.Payment="payment",r.Refund="refund",r))(F||{}),H=(r=>(r.Cash="cash",r.CreditCard="credit-card",r.CloudPayments="cloudpayments",r.CardToken="card_token",r.Bonuses="bonuses",r))(H||{}),Z=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.PendingRefund="pending_refund",r.Refunding="refunding",r.Refunded="refunded",r))(Z||{}),W=(r=>(r.Auth="auth",r.Charge="charge",r))(W||{}),B=(r=>(r.PersonsCount="persons_count",r.DeliveryTime="delivery_time",r.DeliveryIntervals="delivery_intervals",r))(B||{}),J=(r=>(r.PriceMismatch="price_mismatch",r.OutOfStock="out_of_stock",r.Unavailable="unavailable",r))(J||{}),X=(r=>(r.None="none",r.Cleanup="cleanup",r))(X||{}),Y=(r=>(r.Piece="piece",r.Gram="gram",r.Kilogram="kilogram",r.Meter="meter",r))(Y||{}),K=(r=>(r.Weight="weight",r.Width="width",r.Height="height",r.Length="length",r))(K||{}),Q=(r=>(r.Netto="netto",r.Brutto="brutto",r))(Q||{}),x=(r=>(r.Color="color",r))(x||{}),ee=(r=>(r.Category="category",r.Group="group",r.VariantOption="variant_option",r.VariantOptionValue="variant_option_value",r))(ee||{}),te=(r=>(r.Amount="amount",r.Percentage="percentage",r))(te||{}),re=(r=>(r.Email="email",r.Website="website",r.Vk="vk",r.Facebook="facebook",r.Instagram="instagram",r.Twitter="twitter",r.Ok="ok",r.Tiktok="tiktok",r))(re||{}),se=(r=>(r.Yes="yes",r.No="no",r.Both="both",r))(se||{}),ne=(r=>(r.Disabled="disabled",r.Preauth="preauth",r.Confirmation="confirmation",r))(ne||{}),ie=(r=>(r.Dadata="dadata",r.Manual="manual",r))(ie||{}),ae=(r=>(r.Registration="registration",r.ResendRegistrationCode="resend_registration_code",r.ResetPassword="reset_password",r.OrderSubmission="order_submission",r.FeedbackRequest="feedback_request",r.CallbackRequest="callback_request",r))(ae||{});i.AcquiringType=G,i.AddressSuggestionsProvider=g,i.AddressesProvider=ie,i.ArticlesResource=U,i.BonusesTransactionReason=z,i.BonusesTransactionStatus=L,i.BonusesTransactionType=M,i.CategoriesResource=S,i.CloudpaymentsChargeType=W,i.CollectionsResource=A,i.ContactType=re,i.DeliveryMethod=j,i.Dimension=K,i.DimensionType=Q,i.DiscountType=te,i.FeatureRange=I,i.FeatureType=V,i.FeedbackResource=_,i.Gender=$,i.OffersResource=b,i.OrderAuthenticationMethod=ne,i.OrderCartCheckerResultAction=X,i.OrderCartCheckerResultReason=J,i.OrderOptionKind=B,i.OrderPaymentTransactionStatus=Z,i.OrderPaymentTransactionType=F,i.OrdersResource=N,i.PaymentMethod=H,i.PaymentSystemType=D,i.ProductContextType=ee,i.ProductsResource=C,i.RecaptchaAction=ae,i.StoreResource=T,i.TernaryFilter=se,i.UnitType=Y,i.VariantOptionType=x,i.ZenkyError=O,i.ZenkyErrorBuilder=q,i.ZenkyStorefront=ye,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
7
+ **/var f="application/x-postmate-v1+json",ue=5,he=0,de=function(){return++he},h=function(){var t;return m.debug?(t=console).log.apply(t,arguments):null},ge=function(t){var e=document.createElement("a");e.href=t;var s=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||s+"//"+n},pe={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},E=function(t,e){return!(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==f||!pe[t.data.postmate])},me=function(t,e){var s=typeof t[e]=="function"?t[e]():t[e];return m.Promise.resolve(s)},fe=function(){function r(e){var s=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},process.env.NODE_ENV!=="production"&&(h("Parent: Registering API"),h("Parent: Awaiting messages...")),this.listener=function(n){if(!E(n,s.childOrigin))return!1;var a=((n||{}).data||{}).value||{},o=a.data,l=a.name;n.data.postmate==="emit"&&(process.env.NODE_ENV!=="production"&&h("Parent: Received event emission: "+l),l in s.events&&s.events[l].call(s,o))},this.parent.addEventListener("message",this.listener,!1),process.env.NODE_ENV!=="production"&&h("Parent: Awaiting event emissions from Child")}var t=r.prototype;return t.get=function(s){var n=this;return new m.Promise(function(a){var o=de(),l=function d(p){p.data.uid===o&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(p.data.value))};n.parent.addEventListener("message",l,!1),n.child.postMessage({postmate:"request",type:f,property:s,uid:o},n.childOrigin)})},t.call=function(s,n){this.child.postMessage({postmate:"call",type:f,property:s,data:n},this.childOrigin)},t.on=function(s,n){this.events[s]=n},t.destroy=function(){process.env.NODE_ENV!=="production"&&h("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},r}(),ve=function(){function r(e){var s=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,process.env.NODE_ENV!=="production"&&(h("Child: Registering API"),h("Child: Awaiting messages...")),this.child.addEventListener("message",function(n){if(E(n,s.parentOrigin)){process.env.NODE_ENV!=="production"&&h("Child: Received request",n.data);var a=n.data,o=a.property,l=a.uid,d=a.data;if(n.data.postmate==="call"){o in s.model&&typeof s.model[o]=="function"&&s.model[o](d);return}me(s.model,o).then(function(p){return n.source.postMessage({property:o,postmate:"reply",type:f,uid:l,value:p},n.origin)})}})}var t=r.prototype;return t.emit=function(s,n){process.env.NODE_ENV!=="production"&&h('Child: Emitting Event "'+s+'"',n),this.parent.postMessage({postmate:"emit",type:f,value:{name:s,data:n}},this.parentOrigin)},r}(),m=function(){function r(e){var s=e.container,n=s===void 0?typeof n<"u"?n:document.body:s,a=e.model,o=e.url,l=e.name,d=e.classListArray,p=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=l||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(o)}var t=r.prototype;return t.sendHandshake=function(s){var n=this,a=ge(s),o=0,l;return new r.Promise(function(d,p){var v=function y(P){return E(P,a)?P.data.postmate==="handshake-reply"?(clearInterval(l),process.env.NODE_ENV!=="production"&&h("Parent: Received handshake reply from Child"),n.parent.removeEventListener("message",y,!1),n.childOrigin=P.origin,process.env.NODE_ENV!=="production"&&h("Parent: Saving Child origin",n.childOrigin),d(new fe(n))):(process.env.NODE_ENV!=="production"&&h("Parent: Invalid handshake reply"),p("Failed handshake")):!1};n.parent.addEventListener("message",v,!1);var w=function(){o++,process.env.NODE_ENV!=="production"&&h("Parent: Sending handshake attempt "+o,{childOrigin:a}),n.child.postMessage({postmate:"handshake",type:f,model:n.model},a),o===ue&&clearInterval(l)},k=function(){w(),l=setInterval(w,500)};n.frame.attachEvent?n.frame.attachEvent("onload",k):n.frame.onload=k,process.env.NODE_ENV!=="production"&&h("Parent: Loading frame",{url:s}),n.frame.src=s})},r}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),m.Model=function(){function r(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=r.prototype;return t.sendHandshakeReply=function(){var s=this;return new m.Promise(function(n,a){var o=function l(d){if(d.data.postmate){if(d.data.postmate==="handshake"){process.env.NODE_ENV!=="production"&&h("Child: Received handshake from Parent"),s.child.removeEventListener("message",l,!1),process.env.NODE_ENV!=="production"&&h("Child: Sending handshake reply to Parent"),d.source.postMessage({postmate:"handshake-reply",type:f},d.origin),s.parentOrigin=d.origin;var p=d.data.model;return p&&(Object.keys(p).forEach(function(v){s.model[v]=p[v]}),process.env.NODE_ENV!=="production"&&h("Child: Inherited and extended model from Parent")),process.env.NODE_ENV!=="production"&&h("Child: Saving Parent origin",s.parentOrigin),n(new ve(s))}return a("Handshake Reply Failed")}};s.child.addEventListener("message",o,!1)})},r}();class ye extends u{async checkPhone(t,e){const s=this.getStoreUrl(t,"/auth/check");return this.getResponse(await this.client.request("POST",s,e))}async register(t,e){const s=this.getStoreUrl(t,"/auth/register");return this.getResponse(await this.client.request("POST",s,e))}async confirmRegistration(t,e){const s=this.getStoreUrl(t,"/auth/register/confirm");return this.getResponse(await this.client.request("POST",s,e))}async resendRegistrationConfirmation(t,e){const s=this.getStoreUrl(t,"/auth/register/resend");return this.getResponse(await this.client.request("POST",s,e))}async login(t,e){const s=this.getStoreUrl(t,"/auth/login");return this.getResponse(await this.client.request("POST",s,e))}async dispatchPasswordReset(t,e){const s=this.getStoreUrl(t,"/auth/password/request");return this.getResponse(await this.client.request("POST",s,e))}async resetPassword(t,e){const s=this.getStoreUrl(t,"/auth/password/reset");return this.getResponse(await this.client.request("POST",s,e))}useAuthenticationModal(t,e,s,n={}){const a=`${this.client.getBaseAuthUrl()}/?store_id=${t}&response_type=post_message`;let o=null,l=null;return{initAuthenticationModal:async()=>new Promise(v=>{const w=typeof e=="string"?document.querySelector(e):e;o=new m({...n,container:w,url:a}),o.then(k=>{l=k,l.on("zenky:auth:token",s),l.on("zenky:auth:resize",y=>{l.frame.style.height=`${y}px`}),v(!0)})}),destroyAuthenticationModal:()=>{l&&l.destroy()}}}}class we{constructor(t,e){c(this,"client");c(this,"store");c(this,"auth");c(this,"customer");c(this,"catalog");c(this,"categories");c(this,"products");c(this,"addresses");c(this,"orders");c(this,"collections");c(this,"offers");c(this,"articles");c(this,"feedback");const s=R.build(t,e);this.store=new A(s),this.auth=new ye(s),this.customer=new ce(s),this.catalog=new S(s),this.categories=new q(s),this.products=new N(s),this.addresses=new le(s),this.orders=new $(s),this.collections=new b(s),this.offers=new _(s),this.articles=new U(s),this.feedback=new C(s),this.client=s}setApiToken(t){return this.client.setToken(t),this}}var G=(r=>(r.Female="female",r.Male="male",r.Other="other",r))(G||{}),D=(r=>(r.CloudPayments="cloudpayments",r))(D||{}),V=(r=>(r.Visa="visa",r.MasterCard="master-card",r.MIR="mir",r.Maestro="maestro",r.AmericanExpress="american-express",r.DinersClub="diners-club",r.Discover="discover",r.JCB="jcb",r.UnionPay="union-pay",r))(V||{}),I=(r=>(r.Select="select",r.MutipleSelect="mutiple_select",r.Checkboxes="checkboxes",r.Radios="radios",r.Range="range",r.Text="text",r))(I||{}),M=(r=>(r.Integer="integer",r.Float="float",r))(M||{}),L=(r=>(r.Increase="increase",r.Decrease="decrease",r))(L||{}),z=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.Rejected="rejected",r.Refunded="refunded",r.PartiallyRefunded="partially_refunded",r))(z||{}),j=(r=>(r.Manual="manual",r.Cashback="cashback",r.ReferralReward="referral_reward",r.RecruitReward="recruit_reward",r.Payment="payment",r.Cancellation="cancellation",r.Refund="refund",r.Adjustment="adjustment",r.WelcomeBonuses="welcome_bonuses",r.PromotionReward="promotion_reward",r.External="external",r))(j||{}),F=(r=>(r.Delivery="delivery",r.Pickup="pickup",r.OnPremise="on_premise",r))(F||{}),H=(r=>(r.Payment="payment",r.Refund="refund",r))(H||{}),Z=(r=>(r.Cash="cash",r.CreditCard="credit-card",r.CloudPayments="cloudpayments",r.CardToken="card_token",r.Bonuses="bonuses",r))(Z||{}),W=(r=>(r.Pending="pending",r.Confirmed="confirmed",r.Cancelled="cancelled",r.PendingRefund="pending_refund",r.Refunding="refunding",r.Refunded="refunded",r))(W||{}),B=(r=>(r.Auth="auth",r.Charge="charge",r))(B||{}),J=(r=>(r.PersonsCount="persons_count",r.DeliveryTime="delivery_time",r.DeliveryIntervals="delivery_intervals",r))(J||{}),X=(r=>(r.PriceMismatch="price_mismatch",r.OutOfStock="out_of_stock",r.Unavailable="unavailable",r))(X||{}),Y=(r=>(r.None="none",r.Cleanup="cleanup",r))(Y||{}),K=(r=>(r.Piece="piece",r.Gram="gram",r.Kilogram="kilogram",r.Meter="meter",r))(K||{}),Q=(r=>(r.Weight="weight",r.Width="width",r.Height="height",r.Length="length",r))(Q||{}),x=(r=>(r.Netto="netto",r.Brutto="brutto",r))(x||{}),ee=(r=>(r.Color="color",r))(ee||{}),te=(r=>(r.Category="category",r.Group="group",r.VariantOption="variant_option",r.VariantOptionValue="variant_option_value",r))(te||{}),re=(r=>(r.Amount="amount",r.Percentage="percentage",r))(re||{}),se=(r=>(r.Email="email",r.Website="website",r.Vk="vk",r.Facebook="facebook",r.Instagram="instagram",r.Twitter="twitter",r.Ok="ok",r.Tiktok="tiktok",r))(se||{}),ne=(r=>(r.Yes="yes",r.No="no",r.Both="both",r))(ne||{}),ie=(r=>(r.Disabled="disabled",r.Preauth="preauth",r.Confirmation="confirmation",r))(ie||{}),ae=(r=>(r.Dadata="dadata",r.Manual="manual",r))(ae||{}),oe=(r=>(r.Registration="registration",r.ResendRegistrationCode="resend_registration_code",r.ResetPassword="reset_password",r.OrderSubmission="order_submission",r.FeedbackRequest="feedback_request",r.CallbackRequest="callback_request",r))(oe||{});i.AcquiringType=D,i.AddressSuggestionsProvider=g,i.AddressesProvider=ae,i.ArticlesResource=U,i.BonusesTransactionReason=j,i.BonusesTransactionStatus=z,i.BonusesTransactionType=L,i.CatalogResource=S,i.CategoriesResource=q,i.CloudpaymentsChargeType=B,i.CollectionsResource=b,i.ContactType=se,i.DeliveryMethod=F,i.Dimension=Q,i.DimensionType=x,i.DiscountType=re,i.FeatureRange=M,i.FeatureType=I,i.FeedbackResource=C,i.Gender=G,i.OffersResource=_,i.OrderAuthenticationMethod=ie,i.OrderCartCheckerResultAction=Y,i.OrderCartCheckerResultReason=X,i.OrderOptionKind=J,i.OrderPaymentTransactionStatus=W,i.OrderPaymentTransactionType=H,i.OrdersResource=$,i.PaymentMethod=Z,i.PaymentSystemType=V,i.ProductContextType=te,i.ProductsResource=N,i.RecaptchaAction=oe,i.StoreResource=A,i.TernaryFilter=ne,i.UnitType=K,i.VariantOptionType=ee,i.ZenkyError=O,i.ZenkyErrorBuilder=T,i.ZenkyStorefront=we,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenky/storefront-api",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "Zenky Storefront API SDK",
5
5
  "author": "Timur Zurbaev <hello@zurbaev.ru>",
6
6
  "license": "MIT",
@@ -22,8 +22,6 @@
22
22
  "dev": "vite",
23
23
  "build": "tsc && vite build",
24
24
  "preview": "vite preview",
25
- "test": "vitest",
26
- "coverage": "vitest run --coverage",
27
25
  "types": "dts-bundle-generator --out-file ./dist/index.d.ts ./src/index.ts"
28
26
  },
29
27
  "devDependencies": {
@@ -33,9 +31,7 @@
33
31
  "dts-bundle-generator": "^8.0.1",
34
32
  "typescript": "^5.0.2",
35
33
  "vite": "^4.3.9",
36
- "vite-plugin-dts": "^2.3.0",
37
- "vitest": "^0.32.0",
38
- "vitest-fetch-mock": "^0.2.2"
34
+ "vite-plugin-dts": "^2.3.0"
39
35
  },
40
36
  "dependencies": {
41
37
  "postmate": "^1.5.2"