@swell/apps-sdk 1.0.150 → 1.0.151

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.
Files changed (39) hide show
  1. package/dist/index.cjs +353 -105
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/index.js +335 -105
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +344 -105
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/src/compatibility/drops/all_products.d.ts +1 -1
  8. package/dist/src/compatibility/drops/articles.d.ts +1 -1
  9. package/dist/src/compatibility/drops/blogs.d.ts +1 -1
  10. package/dist/src/compatibility/drops/collections.d.ts +2 -3
  11. package/dist/src/compatibility/drops/images.d.ts +1 -1
  12. package/dist/src/compatibility/drops/pages.d.ts +2 -3
  13. package/dist/src/compatibility/shopify-objects/collections.d.ts +2 -2
  14. package/dist/src/content.d.ts +3 -3
  15. package/dist/src/liquid/filters/shopify/default_pagination.d.ts +1 -1
  16. package/dist/src/resources/account.d.ts +4 -4
  17. package/dist/src/resources/addresses.d.ts +7 -0
  18. package/dist/src/resources/blog.d.ts +5 -4
  19. package/dist/src/resources/blog_category.d.ts +5 -4
  20. package/dist/src/resources/cart.d.ts +4 -4
  21. package/dist/src/resources/categories.d.ts +7 -0
  22. package/dist/src/resources/category.d.ts +5 -4
  23. package/dist/src/resources/index.d.ts +18 -9
  24. package/dist/src/resources/order.d.ts +5 -4
  25. package/dist/src/resources/orders.d.ts +7 -0
  26. package/dist/src/resources/page.d.ts +5 -4
  27. package/dist/src/resources/predictive_search.d.ts +6 -0
  28. package/dist/src/resources/product.d.ts +5 -19
  29. package/dist/src/resources/product_helpers.d.ts +12 -2
  30. package/dist/src/resources/product_recommendations.d.ts +6 -0
  31. package/dist/src/resources/search.d.ts +6 -0
  32. package/dist/src/resources/subscription.d.ts +7 -0
  33. package/dist/src/resources/subscriptions.d.ts +7 -0
  34. package/dist/src/resources/swell_types.d.ts +66 -9
  35. package/dist/src/resources/variant.d.ts +8 -8
  36. package/dist/src/resources.d.ts +11 -12
  37. package/dist/types/shopify.d.ts +2 -2
  38. package/dist/types/swell.d.ts +3 -1
  39. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -66,21 +66,30 @@ __export(index_exports, {
66
66
  StorefrontResource: () => StorefrontResource,
67
67
  Swell: () => Swell,
68
68
  SwellAccount: () => SwellAccount,
69
+ SwellAddresses: () => SwellAddresses,
69
70
  SwellBackendAPI: () => SwellBackendAPI,
70
71
  SwellBlog: () => SwellBlog,
71
72
  SwellBlogCategory: () => SwellBlogCategory,
72
73
  SwellCart: () => SwellCart,
74
+ SwellCategories: () => SwellCategories,
73
75
  SwellCategory: () => SwellCategory,
74
76
  SwellError: () => SwellError,
75
77
  SwellOrder: () => SwellOrder,
78
+ SwellOrders: () => SwellOrders,
76
79
  SwellPage: () => SwellPage,
80
+ SwellPredictiveSearch: () => SwellPredictiveSearch,
77
81
  SwellProduct: () => SwellProduct,
82
+ SwellProductRecommendations: () => SwellProductRecommendations,
83
+ SwellSearch: () => SwellSearch,
78
84
  SwellStorefrontCollection: () => SwellStorefrontCollection,
79
85
  SwellStorefrontPagination: () => SwellStorefrontPagination,
80
86
  SwellStorefrontRecord: () => SwellStorefrontRecord,
81
87
  SwellStorefrontResource: () => SwellStorefrontResource,
82
88
  SwellStorefrontSingleton: () => SwellStorefrontSingleton,
89
+ SwellSubscription: () => SwellSubscription,
90
+ SwellSubscriptions: () => SwellSubscriptions,
83
91
  SwellTheme: () => SwellTheme3,
92
+ SwellVariant: () => SwellVariant,
84
93
  ThemeColor: () => ThemeColor,
85
94
  ThemeFont: () => ThemeFont,
86
95
  ThemeForm: () => ThemeForm,
@@ -763,18 +772,12 @@ var StorefrontResource = class {
763
772
  }
764
773
  return instance[prop];
765
774
  }
766
- // add additional properties to the loaded result
767
- _transformResult(result) {
768
- return result;
769
- }
770
775
  async _get(..._args) {
771
776
  if (this._getter) {
772
777
  const getter = this._getter.bind(
773
778
  this
774
779
  );
775
780
  return Promise.resolve().then(getter).then((result) => {
776
- return this._transformResult(result);
777
- }).then((result) => {
778
781
  this._result = result ?? null;
779
782
  if (result) {
780
783
  Object.assign(this, result);
@@ -857,7 +860,6 @@ function cloneStorefrontResource(input) {
857
860
  });
858
861
  const clone = new ClonedClass(input._getter);
859
862
  clone._params = input._params;
860
- clone._transformResult = input._transformResult.bind(clone);
861
863
  Object.defineProperty(clone, "_resourceName", {
862
864
  value: resourceName
863
865
  });
@@ -911,7 +913,11 @@ var SwellStorefrontCollection = class _SwellStorefrontCollection extends SwellSt
911
913
  limit = DEFAULT_QUERY_PAGE_LIMIT;
912
914
  name;
913
915
  constructor(swell, collection, query = {}, getter) {
914
- super(swell, collection, getter);
916
+ super(
917
+ swell,
918
+ collection,
919
+ getter
920
+ );
915
921
  this._query = this._initQuery(query);
916
922
  if (!getter) {
917
923
  this._setGetter(this._defaultGetter());
@@ -1087,8 +1093,6 @@ var SwellStorefrontRecord = class extends SwellStorefrontResource {
1087
1093
  getter,
1088
1094
  isResourceCacheble(this._collection)
1089
1095
  ).then((result) => {
1090
- return this._transformResult(result);
1091
- }).then((result) => {
1092
1096
  this._result = result;
1093
1097
  if (result) {
1094
1098
  Object.assign(this, result);
@@ -7845,59 +7849,146 @@ var WorkerCacheProxy = class {
7845
7849
  }
7846
7850
  };
7847
7851
 
7852
+ // src/resources/addresses.ts
7853
+ var SwellAddresses = class extends SwellStorefrontCollection {
7854
+ constructor(swell, query) {
7855
+ const { page, limit: limit2 } = swell.queryParams;
7856
+ super(swell, "accounts:addresses", { page, limit: limit2, ...query }, function() {
7857
+ return this._swell.storefront.account.listAddresses(
7858
+ this._query
7859
+ );
7860
+ });
7861
+ }
7862
+ };
7863
+
7864
+ // src/resources/orders.ts
7865
+ var SwellOrders = class extends SwellStorefrontCollection {
7866
+ constructor(swell, query) {
7867
+ const { page, limit: limit2 } = swell.queryParams;
7868
+ super(swell, "accounts:orders", { page, limit: limit2, ...query }, function() {
7869
+ return this._swell.storefront.account.listOrders(this._query);
7870
+ });
7871
+ }
7872
+ };
7873
+
7874
+ // src/resources/subscriptions.ts
7875
+ var SwellSubscriptions = class extends SwellStorefrontCollection {
7876
+ constructor(swell, query) {
7877
+ const { page, limit: limit2 } = swell.queryParams;
7878
+ super(
7879
+ swell,
7880
+ "accounts:subscriptions",
7881
+ { page, limit: limit2, ...query },
7882
+ function() {
7883
+ return this._swell.storefront.subscriptions.list(
7884
+ this._query
7885
+ );
7886
+ }
7887
+ );
7888
+ }
7889
+ };
7890
+
7848
7891
  // src/resources/account.ts
7849
7892
  var SwellAccount = class extends SwellStorefrontSingleton {
7850
- constructor(swell, getter) {
7851
- super(swell, "account", getter);
7893
+ constructor(swell) {
7894
+ super(swell, "account", async function() {
7895
+ const account = await this._defaultGetter().call(this);
7896
+ if (!account) {
7897
+ return null;
7898
+ }
7899
+ account.addresses = new SwellAddresses(
7900
+ this._swell
7901
+ );
7902
+ account.orders = new SwellOrders(
7903
+ this._swell
7904
+ );
7905
+ account.subscriptions = new SwellSubscriptions(
7906
+ this._swell
7907
+ );
7908
+ return account;
7909
+ });
7852
7910
  return this._getProxy();
7853
7911
  }
7854
7912
  };
7855
7913
 
7856
7914
  // src/resources/blog_category.ts
7857
7915
  var SwellBlogCategory = class extends SwellStorefrontRecord {
7858
- constructor(swell, id, query = {}, getter) {
7859
- super(swell, "content/blog-categories", id, query, getter);
7916
+ constructor(swell, id, query) {
7917
+ super(swell, "content/blog-categories", id, query, async function() {
7918
+ const category = await this._defaultGetter().call(this);
7919
+ if (!category) {
7920
+ return null;
7921
+ }
7922
+ category.blogs = new SwellStorefrontCollection(
7923
+ this._swell,
7924
+ "content/blogs",
7925
+ {
7926
+ category_id: category.id,
7927
+ expand: "author"
7928
+ }
7929
+ );
7930
+ return category;
7931
+ });
7860
7932
  return this._getProxy();
7861
7933
  }
7862
7934
  };
7863
7935
 
7864
7936
  // src/resources/blog.ts
7865
7937
  var SwellBlog = class extends SwellStorefrontRecord {
7866
- constructor(swell, id, query = {}, getter) {
7867
- super(swell, "content/blogs", id, query, getter);
7938
+ constructor(swell, blogId, categoryId, query) {
7939
+ super(swell, "content/blogs", blogId, query, async function() {
7940
+ this._query = { ...this._query, expand: "author" };
7941
+ const blog = await this._defaultGetter().call(this);
7942
+ if (!blog) {
7943
+ return null;
7944
+ }
7945
+ if (categoryId) {
7946
+ blog.category = new SwellStorefrontRecord(
7947
+ this._swell,
7948
+ "content/blog-categories",
7949
+ categoryId
7950
+ );
7951
+ }
7952
+ return blog;
7953
+ });
7868
7954
  return this._getProxy();
7869
7955
  }
7870
7956
  };
7871
7957
 
7872
7958
  // src/resources/cart.ts
7873
7959
  var SwellCart = class extends SwellStorefrontSingleton {
7874
- constructor(swell, getter) {
7875
- super(swell, "cart", getter);
7876
- return this._getProxy();
7877
- }
7878
- };
7879
-
7880
- // src/resources/category.ts
7881
- var SwellCategory = class extends SwellStorefrontRecord {
7882
- constructor(swell, id, query = {}, getter) {
7883
- super(swell, "categories", id, query, getter);
7884
- return this._getProxy();
7885
- }
7886
- };
7887
-
7888
- // src/resources/order.ts
7889
- var SwellOrder = class extends SwellStorefrontRecord {
7890
- constructor(swell, id, query = {}, getter) {
7891
- super(swell, "orders", id, query, getter);
7960
+ constructor(swell) {
7961
+ super(swell, "cart");
7892
7962
  return this._getProxy();
7893
7963
  }
7894
7964
  };
7895
7965
 
7896
- // src/resources/page.ts
7897
- var SwellPage = class extends SwellStorefrontRecord {
7898
- constructor(swell, id, query = {}, getter) {
7899
- super(swell, "content/pages", id, query, getter);
7900
- return this._getProxy();
7966
+ // src/resources/categories.ts
7967
+ var SwellCategories = class extends SwellStorefrontCollection {
7968
+ constructor(swell, query) {
7969
+ super(
7970
+ swell,
7971
+ "categories",
7972
+ {
7973
+ limit: 100,
7974
+ top_id: null,
7975
+ ...query
7976
+ },
7977
+ async function() {
7978
+ const categories = await this._defaultGetter().call(this);
7979
+ if (!categories) {
7980
+ return null;
7981
+ }
7982
+ for (const category of categories.results) {
7983
+ category.products = new SwellStorefrontCollection(
7984
+ this._swell,
7985
+ "products",
7986
+ { category: category.id }
7987
+ );
7988
+ }
7989
+ return categories;
7990
+ }
7991
+ );
7901
7992
  }
7902
7993
  };
7903
7994
 
@@ -8057,6 +8148,143 @@ function getSelectedSubscriptionPurchaseOptionPlan(selectedPurchaseOptionType, s
8057
8148
  }
8058
8149
  return selectedPlan || subscriptionPurchaseOption.plans[0];
8059
8150
  }
8151
+ var SORT_OPTIONS = Object.freeze([
8152
+ { value: "", name: "Featured" },
8153
+ { value: "popularity", name: "Popularity", query: "popularity desc" },
8154
+ { value: "price_asc", name: "Price, low to high", query: "price asc" },
8155
+ { value: "price_desc", name: "Price, high to low", query: "price desc" },
8156
+ { value: "date_asc", name: "Date, old to new", query: "date asc" },
8157
+ { value: "date_desc", name: "Date, new to old", query: "date desc" },
8158
+ { value: "name_asc", name: "Product name, A-Z", query: "name asc" },
8159
+ { value: "name_desc", name: "Product name, Z-A", query: "name desc" }
8160
+ ]);
8161
+ async function getProductFilters(swell, productQuery) {
8162
+ const sortBy = swell.queryParams.sort || "";
8163
+ const filterQuery = productQueryWithFilters(swell, productQuery);
8164
+ return {
8165
+ filter_options: await getProductFiltersByQuery(swell, filterQuery),
8166
+ sort: SORT_OPTIONS.find((option) => option.value === sortBy)?.value,
8167
+ sort_options: [...SORT_OPTIONS]
8168
+ };
8169
+ }
8170
+ async function getProductFiltersByQuery(swell, query = {}) {
8171
+ const filters2 = await swell.get("/products/:filters", {
8172
+ ...query,
8173
+ sort: void 0
8174
+ }) || [];
8175
+ if (!Array.isArray(filters2)) {
8176
+ throw new Error("Product filters must be an array");
8177
+ }
8178
+ for (const filter of filters2) {
8179
+ filter.param_name = `filter_${filter.id}`;
8180
+ if (Array.isArray(filter.options)) {
8181
+ filter.active_options = [];
8182
+ filter.inactive_options = [];
8183
+ for (const option of filter.options) {
8184
+ const queryValue = swell.queryParams[filter.param_name];
8185
+ option.active = Array.isArray(queryValue) ? queryValue.includes(option.value) : queryValue === option.value;
8186
+ const list = option.active ? filter.active_options : filter.inactive_options;
8187
+ list.push(option);
8188
+ }
8189
+ }
8190
+ }
8191
+ return filters2;
8192
+ }
8193
+ function productQueryWithFilters(swell, query) {
8194
+ const filters2 = Object.keys(swell.queryParams).reduce(
8195
+ (acc, key) => {
8196
+ if (key.startsWith("filter_")) {
8197
+ const qkey = key.replace("filter_", "");
8198
+ const value = swell.queryParams[key];
8199
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && (value.gte !== void 0 || value.lte !== void 0)) {
8200
+ acc[qkey] = [value.gte || 0, value.lte || void 0];
8201
+ } else {
8202
+ acc[qkey] = value;
8203
+ }
8204
+ }
8205
+ return acc;
8206
+ },
8207
+ {}
8208
+ );
8209
+ const sortBy = swell.queryParams.sort || "";
8210
+ return {
8211
+ sort: SORT_OPTIONS.find((option) => option.value === sortBy)?.query || void 0,
8212
+ $filters: filters2,
8213
+ ...query
8214
+ };
8215
+ }
8216
+
8217
+ // src/resources/category.ts
8218
+ var SwellCategory = class extends SwellStorefrontRecord {
8219
+ constructor(swell, id, query) {
8220
+ super(swell, "categories", id, query, async function() {
8221
+ let category = await this._defaultGetter().call(this);
8222
+ if (!category && this._id === "all") {
8223
+ category = {
8224
+ name: "Products",
8225
+ id: "all",
8226
+ slug: "all",
8227
+ filter_options: [],
8228
+ sort_options: []
8229
+ };
8230
+ }
8231
+ if (!category) {
8232
+ return null;
8233
+ }
8234
+ const productFilters = await getProductFilters(
8235
+ this._swell,
8236
+ category.id !== "all" ? { category: category.id, $variants: true } : { $variants: true }
8237
+ );
8238
+ Object.assign(category, productFilters);
8239
+ return category;
8240
+ });
8241
+ return this._getProxy();
8242
+ }
8243
+ };
8244
+
8245
+ // src/resources/order.ts
8246
+ var SwellOrder = class extends SwellStorefrontRecord {
8247
+ constructor(swell, id, query) {
8248
+ super(swell, "accounts:orders", id, query, function() {
8249
+ return this._swell.storefront.account.getOrder(this._id);
8250
+ });
8251
+ return this._getProxy();
8252
+ }
8253
+ };
8254
+
8255
+ // src/resources/page.ts
8256
+ var SwellPage = class extends SwellStorefrontRecord {
8257
+ constructor(swell, id, query) {
8258
+ super(swell, "content/pages", id, query);
8259
+ return this._getProxy();
8260
+ }
8261
+ };
8262
+
8263
+ // src/resources/predictive_search.ts
8264
+ var SwellPredictiveSearch = class extends StorefrontResource {
8265
+ constructor(swell, query) {
8266
+ super(async function() {
8267
+ const performed = String(query || "").length > 0;
8268
+ let products;
8269
+ if (performed) {
8270
+ products = new SwellStorefrontCollection(
8271
+ swell,
8272
+ "products",
8273
+ {
8274
+ search: query,
8275
+ limit: 10
8276
+ }
8277
+ );
8278
+ await products.resolve();
8279
+ }
8280
+ return {
8281
+ query,
8282
+ performed,
8283
+ products
8284
+ };
8285
+ });
8286
+ }
8287
+ };
8060
8288
 
8061
8289
  // src/resources/variant.ts
8062
8290
  function transformSwellVariant(params, product, variant) {
@@ -8076,27 +8304,30 @@ function transformSwellVariant(params, product, variant) {
8076
8304
  )
8077
8305
  };
8078
8306
  }
8307
+ var SwellVariant = class extends SwellStorefrontRecord {
8308
+ product;
8309
+ constructor(swell, product, id, query) {
8310
+ super(swell, "products:variants", id, query, async function() {
8311
+ const variant = await this._swell.get(
8312
+ "/products:variants/{id}",
8313
+ { id: this._id }
8314
+ );
8315
+ return variant ?? null;
8316
+ });
8317
+ this.product = product;
8318
+ }
8319
+ };
8079
8320
 
8080
8321
  // src/resources/product.ts
8081
- var SORT_OPTIONS = [
8082
- { value: "", name: "Featured" },
8083
- { value: "popularity", name: "Popularity", query: "popularity desc" },
8084
- { value: "price_asc", name: "Price, low to high", query: "price asc" },
8085
- { value: "price_desc", name: "Price, high to low", query: "price desc" },
8086
- { value: "date_asc", name: "Date, old to new", query: "date asc" },
8087
- { value: "date_desc", name: "Date, new to old", query: "date desc" },
8088
- { value: "name_asc", name: "Product name, A-Z", query: "name asc" },
8089
- { value: "name_desc", name: "Product name, Z-A", query: "name desc" }
8090
- ];
8091
8322
  function transformSwellProduct(params, product) {
8092
8323
  if (!product) {
8093
- return product;
8324
+ return null;
8094
8325
  }
8095
8326
  const newProduct = {
8096
8327
  ...product,
8097
8328
  // add swell properties there
8098
8329
  selected_option_values: getSelectedVariantOptionValues(product, params),
8099
- purchase_options: getPurchaseOptions(product, params)
8330
+ purchase_options: getPurchaseOptions(product, params) ?? void 0
8100
8331
  };
8101
8332
  if (Array.isArray(newProduct.variants?.results)) {
8102
8333
  newProduct.variants = {
@@ -8109,43 +8340,49 @@ function transformSwellProduct(params, product) {
8109
8340
  return newProduct;
8110
8341
  }
8111
8342
  var SwellProduct = class extends SwellStorefrontRecord {
8112
- _params;
8113
- constructor(swell, id, query = {}, getter) {
8114
- super(swell, "products", id, query, getter);
8115
- this._params = swell.queryParams;
8343
+ constructor(swell, id, query) {
8344
+ const params = swell.queryParams;
8345
+ super(swell, "products", id, query, async function() {
8346
+ const result = await this._defaultGetter().call(this);
8347
+ return transformSwellProduct(params, result);
8348
+ });
8116
8349
  return this._getProxy();
8117
8350
  }
8118
- // add swell properties to the resolved object
8119
- _transformResult(result) {
8120
- const res = transformSwellProduct(
8121
- this._params,
8122
- result
8123
- );
8124
- return res;
8351
+ };
8352
+
8353
+ // src/resources/product_recommendations.ts
8354
+ var SwellProductRecommendations = class extends SwellProduct {
8355
+ constructor(swell, id, query) {
8356
+ super(swell, id, { ...query, $recommendations: true });
8357
+ }
8358
+ };
8359
+
8360
+ // src/resources/search.ts
8361
+ var SwellSearch = class extends StorefrontResource {
8362
+ constructor(swell, query) {
8363
+ super(async () => {
8364
+ const performed = String(query || "").length > 0;
8365
+ const productFilters = await getProductFilters(
8366
+ swell,
8367
+ performed ? { search: query } : void 0
8368
+ );
8369
+ return {
8370
+ query,
8371
+ performed,
8372
+ ...productFilters
8373
+ };
8374
+ });
8375
+ }
8376
+ };
8377
+
8378
+ // src/resources/subscription.ts
8379
+ var SwellSubscription = class extends SwellStorefrontRecord {
8380
+ constructor(swell, id, query) {
8381
+ super(swell, "accounts:subscriptions", id, query, function() {
8382
+ return this._swell.storefront.subscriptions.get(this._id, this._query);
8383
+ });
8125
8384
  }
8126
8385
  };
8127
- function productQueryWithFilters(swell, query = {}) {
8128
- const sortBy = swell.queryParams.sort || "";
8129
- const filters2 = Object.entries(swell.queryParams).reduce(
8130
- (acc, [key, value]) => {
8131
- if (key.startsWith("filter_")) {
8132
- const qkey = key.replace("filter_", "");
8133
- if (value?.gte !== void 0 || value?.lte !== void 0) {
8134
- acc[qkey] = [value.gte || 0, value.lte || void 0];
8135
- } else {
8136
- acc[qkey] = value;
8137
- }
8138
- }
8139
- return acc;
8140
- },
8141
- {}
8142
- );
8143
- return {
8144
- sort: SORT_OPTIONS.find((option) => option.value === sortBy)?.query || void 0,
8145
- $filters: filters2,
8146
- ...query
8147
- };
8148
- }
8149
8386
 
8150
8387
  // src/api.ts
8151
8388
  var DEFAULT_API_HOST = "https://api.schema.io";
@@ -15716,11 +15953,9 @@ function getProducts(instance, object, mapper) {
15716
15953
  return this._defaultGetter().call(this);
15717
15954
  }
15718
15955
  );
15719
- return products._cloneWithCompatibilityResult(
15720
- (products2) => {
15721
- return { ...products2, results: products2.results.map(mapper) };
15722
- }
15723
- );
15956
+ return products._cloneWithCompatibilityResult((products2) => {
15957
+ return { ...products2, results: products2.results.map(mapper) };
15958
+ });
15724
15959
  });
15725
15960
  }
15726
15961
  function makeProductsCollectionResolve(instance, object, mapper) {
@@ -15737,19 +15972,24 @@ function makeProductsCollectionResolve(instance, object, mapper) {
15737
15972
 
15738
15973
  // src/compatibility/shopify-objects/collections.ts
15739
15974
  function ShopifyCollections(instance, categories) {
15740
- return new SwellStorefrontCollection(instance.swell, categories._collection, categories._query, async () => {
15741
- const results = (await categories.results)?.map((category) => {
15742
- return ShopifyCollection(instance, category);
15743
- });
15744
- return {
15745
- page: categories.page ?? 1,
15746
- count: categories.count ?? 0,
15747
- results: results ?? [],
15748
- page_count: categories.page_count ?? 0,
15749
- limit: categories.limit,
15750
- pages: categories.pages ?? {}
15751
- };
15752
- });
15975
+ return new SwellStorefrontCollection(
15976
+ instance.swell,
15977
+ categories._collection,
15978
+ categories._query,
15979
+ async () => {
15980
+ const results = (await categories.results)?.map((category) => {
15981
+ return ShopifyCollection(instance, category);
15982
+ });
15983
+ return {
15984
+ page: categories.page ?? 1,
15985
+ count: categories.count ?? 0,
15986
+ results: results ?? [],
15987
+ page_count: categories.page_count ?? 0,
15988
+ limit: categories.limit,
15989
+ pages: categories.pages ?? {}
15990
+ };
15991
+ }
15992
+ );
15753
15993
  }
15754
15994
 
15755
15995
  // src/compatibility/shopify-objects/address.ts
@@ -16936,13 +17176,12 @@ var ImagesDrop = class extends import_liquidjs7.Drop {
16936
17176
  var SwellImage = class extends StorefrontResource {
16937
17177
  constructor(swell, name) {
16938
17178
  super(async () => {
16939
- const files = await swell.get("/:files", {
17179
+ const file = await swell.get("/:files/:last", {
16940
17180
  private: { $ne: true },
16941
17181
  content_type: { $regex: "^image/" },
16942
17182
  filename: name
16943
17183
  });
16944
- const file = files?.results[0] ?? null;
16945
- if (file === null) {
17184
+ if (!file) {
16946
17185
  return null;
16947
17186
  }
16948
17187
  return { file };
@@ -22237,21 +22476,30 @@ function getResourceQuery(slug, query) {
22237
22476
  StorefrontResource,
22238
22477
  Swell,
22239
22478
  SwellAccount,
22479
+ SwellAddresses,
22240
22480
  SwellBackendAPI,
22241
22481
  SwellBlog,
22242
22482
  SwellBlogCategory,
22243
22483
  SwellCart,
22484
+ SwellCategories,
22244
22485
  SwellCategory,
22245
22486
  SwellError,
22246
22487
  SwellOrder,
22488
+ SwellOrders,
22247
22489
  SwellPage,
22490
+ SwellPredictiveSearch,
22248
22491
  SwellProduct,
22492
+ SwellProductRecommendations,
22493
+ SwellSearch,
22249
22494
  SwellStorefrontCollection,
22250
22495
  SwellStorefrontPagination,
22251
22496
  SwellStorefrontRecord,
22252
22497
  SwellStorefrontResource,
22253
22498
  SwellStorefrontSingleton,
22499
+ SwellSubscription,
22500
+ SwellSubscriptions,
22254
22501
  SwellTheme,
22502
+ SwellVariant,
22255
22503
  ThemeColor,
22256
22504
  ThemeFont,
22257
22505
  ThemeForm,