@swell/apps-sdk 1.0.156 → 1.0.157

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/index.cjs CHANGED
@@ -30,7 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AccountAddressesResource: () => AccountAddressesResource,
34
+ AccountOrderResource: () => AccountOrderResource,
35
+ AccountOrdersResource: () => AccountOrdersResource,
36
+ AccountResource: () => AccountResource,
37
+ AccountSubscriptionResource: () => AccountSubscriptionResource,
38
+ AccountSubscriptionsResource: () => AccountSubscriptionsResource,
39
+ BlogCategoryResource: () => BlogCategoryResource,
40
+ BlogResource: () => BlogResource,
33
41
  CURRENCY_COUNTRIES: () => CURRENCY_COUNTRIES,
42
+ CartResource: () => CartResource,
43
+ CategoriesResource: () => CategoriesResource,
44
+ CategoryResource: () => CategoryResource,
34
45
  DEFAULT_QUERY_PAGE_LIMIT: () => DEFAULT_QUERY_PAGE_LIMIT,
35
46
  DeferredShopifyResource: () => DeferredShopifyResource,
36
47
  FILE_DATA_INCLUDE_QUERY: () => FILE_DATA_INCLUDE_QUERY,
@@ -42,7 +53,11 @@ __export(index_exports, {
42
53
  MockRecordSingleton: () => MockRecordSingleton,
43
54
  PageError: () => PageError,
44
55
  PageNotFound: () => PageNotFound,
56
+ PageResource: () => PageResource,
57
+ PredictiveSearchResource: () => PredictiveSearchResource,
58
+ ProductResource: () => ProductResource,
45
59
  SECTION_GROUP_CONTENT: () => SECTION_GROUP_CONTENT,
60
+ SearchResource: () => SearchResource,
46
61
  ShopifyArticle: () => ShopifyArticle,
47
62
  ShopifyBlog: () => ShopifyBlog,
48
63
  ShopifyCart: () => ShopifyCart,
@@ -65,35 +80,19 @@ __export(index_exports, {
65
80
  ShopifyVariant: () => ShopifyVariant,
66
81
  StorefrontResource: () => StorefrontResource,
67
82
  Swell: () => Swell,
68
- SwellAccount: () => SwellAccount,
69
- SwellAddresses: () => SwellAddresses,
70
83
  SwellBackendAPI: () => SwellBackendAPI,
71
- SwellBlog: () => SwellBlog,
72
- SwellBlogCategory: () => SwellBlogCategory,
73
- SwellCart: () => SwellCart,
74
- SwellCategories: () => SwellCategories,
75
- SwellCategory: () => SwellCategory,
76
84
  SwellError: () => SwellError,
77
- SwellOrder: () => SwellOrder,
78
- SwellOrders: () => SwellOrders,
79
- SwellPage: () => SwellPage,
80
- SwellPredictiveSearch: () => SwellPredictiveSearch,
81
- SwellProduct: () => SwellProduct,
82
- SwellProductRecommendations: () => SwellProductRecommendations,
83
- SwellSearch: () => SwellSearch,
84
85
  SwellStorefrontCollection: () => SwellStorefrontCollection,
85
86
  SwellStorefrontPagination: () => SwellStorefrontPagination,
86
87
  SwellStorefrontRecord: () => SwellStorefrontRecord,
87
88
  SwellStorefrontResource: () => SwellStorefrontResource,
88
89
  SwellStorefrontSingleton: () => SwellStorefrontSingleton,
89
- SwellSubscription: () => SwellSubscription,
90
- SwellSubscriptions: () => SwellSubscriptions,
91
90
  SwellTheme: () => SwellTheme3,
92
- SwellVariant: () => SwellVariant,
93
91
  ThemeColor: () => ThemeColor,
94
92
  ThemeFont: () => ThemeFont,
95
93
  ThemeForm: () => ThemeForm,
96
94
  ThemeFormErrors: () => ThemeFormErrors,
95
+ VariantResource: () => VariantResource,
97
96
  WorkerHtmlCache: () => WorkerHtmlCache,
98
97
  adaptShopifyFontData: () => adaptShopifyFontData,
99
98
  adaptShopifyFormData: () => adaptShopifyFormData,
@@ -8308,28 +8307,6 @@ var SwellAccount = class extends SwellStorefrontSingleton {
8308
8307
  }
8309
8308
  };
8310
8309
 
8311
- // src/resources/blog_category.ts
8312
- var SwellBlogCategory = class extends SwellStorefrontRecord {
8313
- constructor(swell, id, query) {
8314
- super(swell, "content/blog-categories", id, query, async function() {
8315
- const category = await this._defaultGetter().call(this);
8316
- if (!category) {
8317
- return null;
8318
- }
8319
- category.blogs = new SwellStorefrontCollection(
8320
- this._swell,
8321
- "content/blogs",
8322
- {
8323
- category_id: category.id,
8324
- expand: "author"
8325
- }
8326
- );
8327
- return category;
8328
- });
8329
- return this._getProxy();
8330
- }
8331
- };
8332
-
8333
8310
  // src/resources/blog.ts
8334
8311
  var SwellBlog = class extends SwellStorefrontRecord {
8335
8312
  constructor(swell, blogId, categoryId, query) {
@@ -8352,6 +8329,28 @@ var SwellBlog = class extends SwellStorefrontRecord {
8352
8329
  }
8353
8330
  };
8354
8331
 
8332
+ // src/resources/blog_category.ts
8333
+ var SwellBlogCategory = class extends SwellStorefrontRecord {
8334
+ constructor(swell, id, query) {
8335
+ super(swell, "content/blog-categories", id, query, async function() {
8336
+ const category = await this._defaultGetter().call(this);
8337
+ if (!category) {
8338
+ return null;
8339
+ }
8340
+ category.blogs = new SwellStorefrontCollection(
8341
+ this._swell,
8342
+ "content/blogs",
8343
+ {
8344
+ category_id: category.id,
8345
+ expand: "author"
8346
+ }
8347
+ );
8348
+ return category;
8349
+ });
8350
+ return this._getProxy();
8351
+ }
8352
+ };
8353
+
8355
8354
  // src/resources/cart.ts
8356
8355
  var SwellCart = class extends SwellStorefrontSingleton {
8357
8356
  constructor(swell) {
@@ -8360,35 +8359,6 @@ var SwellCart = class extends SwellStorefrontSingleton {
8360
8359
  }
8361
8360
  };
8362
8361
 
8363
- // src/resources/categories.ts
8364
- var SwellCategories = class extends SwellStorefrontCollection {
8365
- constructor(swell, query) {
8366
- super(
8367
- swell,
8368
- "categories",
8369
- {
8370
- limit: 100,
8371
- top_id: null,
8372
- ...query
8373
- },
8374
- async function() {
8375
- const categories = await this._defaultGetter().call(this);
8376
- if (!categories) {
8377
- return null;
8378
- }
8379
- for (const category of categories.results) {
8380
- category.products = new SwellStorefrontCollection(
8381
- this._swell,
8382
- "products",
8383
- { category: category.id }
8384
- );
8385
- }
8386
- return categories;
8387
- }
8388
- );
8389
- }
8390
- };
8391
-
8392
8362
  // src/resources/product_helpers.ts
8393
8363
  function isGiftcard(product) {
8394
8364
  return product.type === "giftcard";
@@ -8639,6 +8609,35 @@ var SwellCategory = class extends SwellStorefrontRecord {
8639
8609
  }
8640
8610
  };
8641
8611
 
8612
+ // src/resources/categories.ts
8613
+ var SwellCategories = class extends SwellStorefrontCollection {
8614
+ constructor(swell, query) {
8615
+ super(
8616
+ swell,
8617
+ "categories",
8618
+ {
8619
+ limit: 100,
8620
+ top_id: null,
8621
+ ...query
8622
+ },
8623
+ async function() {
8624
+ const categories = await this._defaultGetter().call(this);
8625
+ if (!categories) {
8626
+ return null;
8627
+ }
8628
+ for (const category of categories.results) {
8629
+ category.products = new SwellStorefrontCollection(
8630
+ this._swell,
8631
+ "products",
8632
+ { category: category.id }
8633
+ );
8634
+ }
8635
+ return categories;
8636
+ }
8637
+ );
8638
+ }
8639
+ };
8640
+
8642
8641
  // src/resources/order.ts
8643
8642
  var SwellOrder = class extends SwellStorefrontRecord {
8644
8643
  constructor(swell, id, query) {
@@ -8747,13 +8746,6 @@ var SwellProduct = class extends SwellStorefrontRecord {
8747
8746
  }
8748
8747
  };
8749
8748
 
8750
- // src/resources/product_recommendations.ts
8751
- var SwellProductRecommendations = class extends SwellProduct {
8752
- constructor(swell, id, query) {
8753
- super(swell, id, { ...query, $recommendations: true });
8754
- }
8755
- };
8756
-
8757
8749
  // src/resources/search.ts
8758
8750
  var SwellSearch = class extends StorefrontResource {
8759
8751
  constructor(swell, query) {
@@ -8781,6 +8773,40 @@ var SwellSubscription = class extends SwellStorefrontRecord {
8781
8773
  }
8782
8774
  };
8783
8775
 
8776
+ // src/resources/index.ts
8777
+ var AccountResource = class extends SwellAccount {
8778
+ };
8779
+ var AccountAddressesResource = class extends SwellAddresses {
8780
+ };
8781
+ var BlogResource = class extends SwellBlog {
8782
+ };
8783
+ var BlogCategoryResource = class extends SwellBlogCategory {
8784
+ };
8785
+ var CartResource = class extends SwellCart {
8786
+ };
8787
+ var CategoryResource = class extends SwellCategory {
8788
+ };
8789
+ var CategoriesResource = class extends SwellCategories {
8790
+ };
8791
+ var AccountOrderResource = class extends SwellOrder {
8792
+ };
8793
+ var AccountOrdersResource = class extends SwellOrders {
8794
+ };
8795
+ var PageResource = class extends SwellPage {
8796
+ };
8797
+ var PredictiveSearchResource = class extends SwellPredictiveSearch {
8798
+ };
8799
+ var ProductResource = class extends SwellProduct {
8800
+ };
8801
+ var SearchResource = class extends SwellSearch {
8802
+ };
8803
+ var AccountSubscriptionResource = class extends SwellSubscription {
8804
+ };
8805
+ var AccountSubscriptionsResource = class extends SwellSubscriptions {
8806
+ };
8807
+ var VariantResource = class extends SwellVariant {
8808
+ };
8809
+
8784
8810
  // src/api.ts
8785
8811
  var DEFAULT_API_HOST = "https://api.schema.io";
8786
8812
  var resourceCaches = /* @__PURE__ */ new Map();
@@ -21293,8 +21319,8 @@ var SwellTheme3 = class {
21293
21319
  return result ?? defaultValue();
21294
21320
  }
21295
21321
  async fetchCart() {
21296
- const CartResource = this.resources?.singletons?.cart;
21297
- const cart = CartResource ? new CartResource(this.swell) : new SwellStorefrontSingleton(this.swell, "cart");
21322
+ const CartResource2 = this.resources?.singletons?.cart;
21323
+ const cart = CartResource2 ? new CartResource2(this.swell) : new SwellStorefrontSingleton(this.swell, "cart");
21298
21324
  cart._isEmpty = function() {
21299
21325
  return !this._result?.items?.length;
21300
21326
  };
@@ -21306,8 +21332,8 @@ var SwellTheme3 = class {
21306
21332
  return cart;
21307
21333
  }
21308
21334
  async fetchAccount() {
21309
- const AccountResource = this.resources?.singletons?.account;
21310
- const account = AccountResource ? new AccountResource(this.swell) : new SwellStorefrontSingleton(this.swell, "account");
21335
+ const AccountResource2 = this.resources?.singletons?.account;
21336
+ const account = AccountResource2 ? new AccountResource2(this.swell) : new SwellStorefrontSingleton(this.swell, "account");
21311
21337
  await account.id;
21312
21338
  if (!account?.id) {
21313
21339
  return null;
@@ -22897,7 +22923,18 @@ function getResourceQuery(slug, query) {
22897
22923
  }
22898
22924
  // Annotate the CommonJS export names for ESM import in node:
22899
22925
  0 && (module.exports = {
22926
+ AccountAddressesResource,
22927
+ AccountOrderResource,
22928
+ AccountOrdersResource,
22929
+ AccountResource,
22930
+ AccountSubscriptionResource,
22931
+ AccountSubscriptionsResource,
22932
+ BlogCategoryResource,
22933
+ BlogResource,
22900
22934
  CURRENCY_COUNTRIES,
22935
+ CartResource,
22936
+ CategoriesResource,
22937
+ CategoryResource,
22901
22938
  DEFAULT_QUERY_PAGE_LIMIT,
22902
22939
  DeferredShopifyResource,
22903
22940
  FILE_DATA_INCLUDE_QUERY,
@@ -22909,7 +22946,11 @@ function getResourceQuery(slug, query) {
22909
22946
  MockRecordSingleton,
22910
22947
  PageError,
22911
22948
  PageNotFound,
22949
+ PageResource,
22950
+ PredictiveSearchResource,
22951
+ ProductResource,
22912
22952
  SECTION_GROUP_CONTENT,
22953
+ SearchResource,
22913
22954
  ShopifyArticle,
22914
22955
  ShopifyBlog,
22915
22956
  ShopifyCart,
@@ -22932,35 +22973,19 @@ function getResourceQuery(slug, query) {
22932
22973
  ShopifyVariant,
22933
22974
  StorefrontResource,
22934
22975
  Swell,
22935
- SwellAccount,
22936
- SwellAddresses,
22937
22976
  SwellBackendAPI,
22938
- SwellBlog,
22939
- SwellBlogCategory,
22940
- SwellCart,
22941
- SwellCategories,
22942
- SwellCategory,
22943
22977
  SwellError,
22944
- SwellOrder,
22945
- SwellOrders,
22946
- SwellPage,
22947
- SwellPredictiveSearch,
22948
- SwellProduct,
22949
- SwellProductRecommendations,
22950
- SwellSearch,
22951
22978
  SwellStorefrontCollection,
22952
22979
  SwellStorefrontPagination,
22953
22980
  SwellStorefrontRecord,
22954
22981
  SwellStorefrontResource,
22955
22982
  SwellStorefrontSingleton,
22956
- SwellSubscription,
22957
- SwellSubscriptions,
22958
22983
  SwellTheme,
22959
- SwellVariant,
22960
22984
  ThemeColor,
22961
22985
  ThemeFont,
22962
22986
  ThemeForm,
22963
22987
  ThemeFormErrors,
22988
+ VariantResource,
22964
22989
  WorkerHtmlCache,
22965
22990
  adaptShopifyFontData,
22966
22991
  adaptShopifyFormData,