@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.
- package/dist/index.cjs +353 -105
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +335 -105
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +344 -105
- package/dist/index.mjs.map +4 -4
- package/dist/src/compatibility/drops/all_products.d.ts +1 -1
- package/dist/src/compatibility/drops/articles.d.ts +1 -1
- package/dist/src/compatibility/drops/blogs.d.ts +1 -1
- package/dist/src/compatibility/drops/collections.d.ts +2 -3
- package/dist/src/compatibility/drops/images.d.ts +1 -1
- package/dist/src/compatibility/drops/pages.d.ts +2 -3
- package/dist/src/compatibility/shopify-objects/collections.d.ts +2 -2
- package/dist/src/content.d.ts +3 -3
- package/dist/src/liquid/filters/shopify/default_pagination.d.ts +1 -1
- package/dist/src/resources/account.d.ts +4 -4
- package/dist/src/resources/addresses.d.ts +7 -0
- package/dist/src/resources/blog.d.ts +5 -4
- package/dist/src/resources/blog_category.d.ts +5 -4
- package/dist/src/resources/cart.d.ts +4 -4
- package/dist/src/resources/categories.d.ts +7 -0
- package/dist/src/resources/category.d.ts +5 -4
- package/dist/src/resources/index.d.ts +18 -9
- package/dist/src/resources/order.d.ts +5 -4
- package/dist/src/resources/orders.d.ts +7 -0
- package/dist/src/resources/page.d.ts +5 -4
- package/dist/src/resources/predictive_search.d.ts +6 -0
- package/dist/src/resources/product.d.ts +5 -19
- package/dist/src/resources/product_helpers.d.ts +12 -2
- package/dist/src/resources/product_recommendations.d.ts +6 -0
- package/dist/src/resources/search.d.ts +6 -0
- package/dist/src/resources/subscription.d.ts +7 -0
- package/dist/src/resources/subscriptions.d.ts +7 -0
- package/dist/src/resources/swell_types.d.ts +66 -9
- package/dist/src/resources/variant.d.ts +8 -8
- package/dist/src/resources.d.ts +11 -12
- package/dist/types/shopify.d.ts +2 -2
- package/dist/types/swell.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -626,18 +626,12 @@ var StorefrontResource = class {
|
|
|
626
626
|
}
|
|
627
627
|
return instance[prop];
|
|
628
628
|
}
|
|
629
|
-
// add additional properties to the loaded result
|
|
630
|
-
_transformResult(result) {
|
|
631
|
-
return result;
|
|
632
|
-
}
|
|
633
629
|
async _get(..._args) {
|
|
634
630
|
if (this._getter) {
|
|
635
631
|
const getter = this._getter.bind(
|
|
636
632
|
this
|
|
637
633
|
);
|
|
638
634
|
return Promise.resolve().then(getter).then((result) => {
|
|
639
|
-
return this._transformResult(result);
|
|
640
|
-
}).then((result) => {
|
|
641
635
|
this._result = result ?? null;
|
|
642
636
|
if (result) {
|
|
643
637
|
Object.assign(this, result);
|
|
@@ -720,7 +714,6 @@ function cloneStorefrontResource(input) {
|
|
|
720
714
|
});
|
|
721
715
|
const clone = new ClonedClass(input._getter);
|
|
722
716
|
clone._params = input._params;
|
|
723
|
-
clone._transformResult = input._transformResult.bind(clone);
|
|
724
717
|
Object.defineProperty(clone, "_resourceName", {
|
|
725
718
|
value: resourceName
|
|
726
719
|
});
|
|
@@ -774,7 +767,11 @@ var SwellStorefrontCollection = class _SwellStorefrontCollection extends SwellSt
|
|
|
774
767
|
limit = DEFAULT_QUERY_PAGE_LIMIT;
|
|
775
768
|
name;
|
|
776
769
|
constructor(swell, collection, query = {}, getter) {
|
|
777
|
-
super(
|
|
770
|
+
super(
|
|
771
|
+
swell,
|
|
772
|
+
collection,
|
|
773
|
+
getter
|
|
774
|
+
);
|
|
778
775
|
this._query = this._initQuery(query);
|
|
779
776
|
if (!getter) {
|
|
780
777
|
this._setGetter(this._defaultGetter());
|
|
@@ -950,8 +947,6 @@ var SwellStorefrontRecord = class extends SwellStorefrontResource {
|
|
|
950
947
|
getter,
|
|
951
948
|
isResourceCacheble(this._collection)
|
|
952
949
|
).then((result) => {
|
|
953
|
-
return this._transformResult(result);
|
|
954
|
-
}).then((result) => {
|
|
955
950
|
this._result = result;
|
|
956
951
|
if (result) {
|
|
957
952
|
Object.assign(this, result);
|
|
@@ -7708,59 +7703,146 @@ var WorkerCacheProxy = class {
|
|
|
7708
7703
|
}
|
|
7709
7704
|
};
|
|
7710
7705
|
|
|
7706
|
+
// src/resources/addresses.ts
|
|
7707
|
+
var SwellAddresses = class extends SwellStorefrontCollection {
|
|
7708
|
+
constructor(swell, query) {
|
|
7709
|
+
const { page, limit: limit2 } = swell.queryParams;
|
|
7710
|
+
super(swell, "accounts:addresses", { page, limit: limit2, ...query }, function() {
|
|
7711
|
+
return this._swell.storefront.account.listAddresses(
|
|
7712
|
+
this._query
|
|
7713
|
+
);
|
|
7714
|
+
});
|
|
7715
|
+
}
|
|
7716
|
+
};
|
|
7717
|
+
|
|
7718
|
+
// src/resources/orders.ts
|
|
7719
|
+
var SwellOrders = class extends SwellStorefrontCollection {
|
|
7720
|
+
constructor(swell, query) {
|
|
7721
|
+
const { page, limit: limit2 } = swell.queryParams;
|
|
7722
|
+
super(swell, "accounts:orders", { page, limit: limit2, ...query }, function() {
|
|
7723
|
+
return this._swell.storefront.account.listOrders(this._query);
|
|
7724
|
+
});
|
|
7725
|
+
}
|
|
7726
|
+
};
|
|
7727
|
+
|
|
7728
|
+
// src/resources/subscriptions.ts
|
|
7729
|
+
var SwellSubscriptions = class extends SwellStorefrontCollection {
|
|
7730
|
+
constructor(swell, query) {
|
|
7731
|
+
const { page, limit: limit2 } = swell.queryParams;
|
|
7732
|
+
super(
|
|
7733
|
+
swell,
|
|
7734
|
+
"accounts:subscriptions",
|
|
7735
|
+
{ page, limit: limit2, ...query },
|
|
7736
|
+
function() {
|
|
7737
|
+
return this._swell.storefront.subscriptions.list(
|
|
7738
|
+
this._query
|
|
7739
|
+
);
|
|
7740
|
+
}
|
|
7741
|
+
);
|
|
7742
|
+
}
|
|
7743
|
+
};
|
|
7744
|
+
|
|
7711
7745
|
// src/resources/account.ts
|
|
7712
7746
|
var SwellAccount = class extends SwellStorefrontSingleton {
|
|
7713
|
-
constructor(swell
|
|
7714
|
-
super(swell, "account",
|
|
7747
|
+
constructor(swell) {
|
|
7748
|
+
super(swell, "account", async function() {
|
|
7749
|
+
const account = await this._defaultGetter().call(this);
|
|
7750
|
+
if (!account) {
|
|
7751
|
+
return null;
|
|
7752
|
+
}
|
|
7753
|
+
account.addresses = new SwellAddresses(
|
|
7754
|
+
this._swell
|
|
7755
|
+
);
|
|
7756
|
+
account.orders = new SwellOrders(
|
|
7757
|
+
this._swell
|
|
7758
|
+
);
|
|
7759
|
+
account.subscriptions = new SwellSubscriptions(
|
|
7760
|
+
this._swell
|
|
7761
|
+
);
|
|
7762
|
+
return account;
|
|
7763
|
+
});
|
|
7715
7764
|
return this._getProxy();
|
|
7716
7765
|
}
|
|
7717
7766
|
};
|
|
7718
7767
|
|
|
7719
7768
|
// src/resources/blog_category.ts
|
|
7720
7769
|
var SwellBlogCategory = class extends SwellStorefrontRecord {
|
|
7721
|
-
constructor(swell, id, query
|
|
7722
|
-
super(swell, "content/blog-categories", id, query,
|
|
7770
|
+
constructor(swell, id, query) {
|
|
7771
|
+
super(swell, "content/blog-categories", id, query, async function() {
|
|
7772
|
+
const category = await this._defaultGetter().call(this);
|
|
7773
|
+
if (!category) {
|
|
7774
|
+
return null;
|
|
7775
|
+
}
|
|
7776
|
+
category.blogs = new SwellStorefrontCollection(
|
|
7777
|
+
this._swell,
|
|
7778
|
+
"content/blogs",
|
|
7779
|
+
{
|
|
7780
|
+
category_id: category.id,
|
|
7781
|
+
expand: "author"
|
|
7782
|
+
}
|
|
7783
|
+
);
|
|
7784
|
+
return category;
|
|
7785
|
+
});
|
|
7723
7786
|
return this._getProxy();
|
|
7724
7787
|
}
|
|
7725
7788
|
};
|
|
7726
7789
|
|
|
7727
7790
|
// src/resources/blog.ts
|
|
7728
7791
|
var SwellBlog = class extends SwellStorefrontRecord {
|
|
7729
|
-
constructor(swell,
|
|
7730
|
-
super(swell, "content/blogs",
|
|
7792
|
+
constructor(swell, blogId, categoryId, query) {
|
|
7793
|
+
super(swell, "content/blogs", blogId, query, async function() {
|
|
7794
|
+
this._query = { ...this._query, expand: "author" };
|
|
7795
|
+
const blog = await this._defaultGetter().call(this);
|
|
7796
|
+
if (!blog) {
|
|
7797
|
+
return null;
|
|
7798
|
+
}
|
|
7799
|
+
if (categoryId) {
|
|
7800
|
+
blog.category = new SwellStorefrontRecord(
|
|
7801
|
+
this._swell,
|
|
7802
|
+
"content/blog-categories",
|
|
7803
|
+
categoryId
|
|
7804
|
+
);
|
|
7805
|
+
}
|
|
7806
|
+
return blog;
|
|
7807
|
+
});
|
|
7731
7808
|
return this._getProxy();
|
|
7732
7809
|
}
|
|
7733
7810
|
};
|
|
7734
7811
|
|
|
7735
7812
|
// src/resources/cart.ts
|
|
7736
7813
|
var SwellCart = class extends SwellStorefrontSingleton {
|
|
7737
|
-
constructor(swell
|
|
7738
|
-
super(swell, "cart"
|
|
7739
|
-
return this._getProxy();
|
|
7740
|
-
}
|
|
7741
|
-
};
|
|
7742
|
-
|
|
7743
|
-
// src/resources/category.ts
|
|
7744
|
-
var SwellCategory = class extends SwellStorefrontRecord {
|
|
7745
|
-
constructor(swell, id, query = {}, getter) {
|
|
7746
|
-
super(swell, "categories", id, query, getter);
|
|
7747
|
-
return this._getProxy();
|
|
7748
|
-
}
|
|
7749
|
-
};
|
|
7750
|
-
|
|
7751
|
-
// src/resources/order.ts
|
|
7752
|
-
var SwellOrder = class extends SwellStorefrontRecord {
|
|
7753
|
-
constructor(swell, id, query = {}, getter) {
|
|
7754
|
-
super(swell, "orders", id, query, getter);
|
|
7814
|
+
constructor(swell) {
|
|
7815
|
+
super(swell, "cart");
|
|
7755
7816
|
return this._getProxy();
|
|
7756
7817
|
}
|
|
7757
7818
|
};
|
|
7758
7819
|
|
|
7759
|
-
// src/resources/
|
|
7760
|
-
var
|
|
7761
|
-
constructor(swell,
|
|
7762
|
-
super(
|
|
7763
|
-
|
|
7820
|
+
// src/resources/categories.ts
|
|
7821
|
+
var SwellCategories = class extends SwellStorefrontCollection {
|
|
7822
|
+
constructor(swell, query) {
|
|
7823
|
+
super(
|
|
7824
|
+
swell,
|
|
7825
|
+
"categories",
|
|
7826
|
+
{
|
|
7827
|
+
limit: 100,
|
|
7828
|
+
top_id: null,
|
|
7829
|
+
...query
|
|
7830
|
+
},
|
|
7831
|
+
async function() {
|
|
7832
|
+
const categories = await this._defaultGetter().call(this);
|
|
7833
|
+
if (!categories) {
|
|
7834
|
+
return null;
|
|
7835
|
+
}
|
|
7836
|
+
for (const category of categories.results) {
|
|
7837
|
+
category.products = new SwellStorefrontCollection(
|
|
7838
|
+
this._swell,
|
|
7839
|
+
"products",
|
|
7840
|
+
{ category: category.id }
|
|
7841
|
+
);
|
|
7842
|
+
}
|
|
7843
|
+
return categories;
|
|
7844
|
+
}
|
|
7845
|
+
);
|
|
7764
7846
|
}
|
|
7765
7847
|
};
|
|
7766
7848
|
|
|
@@ -7920,6 +8002,143 @@ function getSelectedSubscriptionPurchaseOptionPlan(selectedPurchaseOptionType, s
|
|
|
7920
8002
|
}
|
|
7921
8003
|
return selectedPlan || subscriptionPurchaseOption.plans[0];
|
|
7922
8004
|
}
|
|
8005
|
+
var SORT_OPTIONS = Object.freeze([
|
|
8006
|
+
{ value: "", name: "Featured" },
|
|
8007
|
+
{ value: "popularity", name: "Popularity", query: "popularity desc" },
|
|
8008
|
+
{ value: "price_asc", name: "Price, low to high", query: "price asc" },
|
|
8009
|
+
{ value: "price_desc", name: "Price, high to low", query: "price desc" },
|
|
8010
|
+
{ value: "date_asc", name: "Date, old to new", query: "date asc" },
|
|
8011
|
+
{ value: "date_desc", name: "Date, new to old", query: "date desc" },
|
|
8012
|
+
{ value: "name_asc", name: "Product name, A-Z", query: "name asc" },
|
|
8013
|
+
{ value: "name_desc", name: "Product name, Z-A", query: "name desc" }
|
|
8014
|
+
]);
|
|
8015
|
+
async function getProductFilters(swell, productQuery) {
|
|
8016
|
+
const sortBy = swell.queryParams.sort || "";
|
|
8017
|
+
const filterQuery = productQueryWithFilters(swell, productQuery);
|
|
8018
|
+
return {
|
|
8019
|
+
filter_options: await getProductFiltersByQuery(swell, filterQuery),
|
|
8020
|
+
sort: SORT_OPTIONS.find((option) => option.value === sortBy)?.value,
|
|
8021
|
+
sort_options: [...SORT_OPTIONS]
|
|
8022
|
+
};
|
|
8023
|
+
}
|
|
8024
|
+
async function getProductFiltersByQuery(swell, query = {}) {
|
|
8025
|
+
const filters2 = await swell.get("/products/:filters", {
|
|
8026
|
+
...query,
|
|
8027
|
+
sort: void 0
|
|
8028
|
+
}) || [];
|
|
8029
|
+
if (!Array.isArray(filters2)) {
|
|
8030
|
+
throw new Error("Product filters must be an array");
|
|
8031
|
+
}
|
|
8032
|
+
for (const filter of filters2) {
|
|
8033
|
+
filter.param_name = `filter_${filter.id}`;
|
|
8034
|
+
if (Array.isArray(filter.options)) {
|
|
8035
|
+
filter.active_options = [];
|
|
8036
|
+
filter.inactive_options = [];
|
|
8037
|
+
for (const option of filter.options) {
|
|
8038
|
+
const queryValue = swell.queryParams[filter.param_name];
|
|
8039
|
+
option.active = Array.isArray(queryValue) ? queryValue.includes(option.value) : queryValue === option.value;
|
|
8040
|
+
const list = option.active ? filter.active_options : filter.inactive_options;
|
|
8041
|
+
list.push(option);
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8045
|
+
return filters2;
|
|
8046
|
+
}
|
|
8047
|
+
function productQueryWithFilters(swell, query) {
|
|
8048
|
+
const filters2 = Object.keys(swell.queryParams).reduce(
|
|
8049
|
+
(acc, key) => {
|
|
8050
|
+
if (key.startsWith("filter_")) {
|
|
8051
|
+
const qkey = key.replace("filter_", "");
|
|
8052
|
+
const value = swell.queryParams[key];
|
|
8053
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && (value.gte !== void 0 || value.lte !== void 0)) {
|
|
8054
|
+
acc[qkey] = [value.gte || 0, value.lte || void 0];
|
|
8055
|
+
} else {
|
|
8056
|
+
acc[qkey] = value;
|
|
8057
|
+
}
|
|
8058
|
+
}
|
|
8059
|
+
return acc;
|
|
8060
|
+
},
|
|
8061
|
+
{}
|
|
8062
|
+
);
|
|
8063
|
+
const sortBy = swell.queryParams.sort || "";
|
|
8064
|
+
return {
|
|
8065
|
+
sort: SORT_OPTIONS.find((option) => option.value === sortBy)?.query || void 0,
|
|
8066
|
+
$filters: filters2,
|
|
8067
|
+
...query
|
|
8068
|
+
};
|
|
8069
|
+
}
|
|
8070
|
+
|
|
8071
|
+
// src/resources/category.ts
|
|
8072
|
+
var SwellCategory = class extends SwellStorefrontRecord {
|
|
8073
|
+
constructor(swell, id, query) {
|
|
8074
|
+
super(swell, "categories", id, query, async function() {
|
|
8075
|
+
let category = await this._defaultGetter().call(this);
|
|
8076
|
+
if (!category && this._id === "all") {
|
|
8077
|
+
category = {
|
|
8078
|
+
name: "Products",
|
|
8079
|
+
id: "all",
|
|
8080
|
+
slug: "all",
|
|
8081
|
+
filter_options: [],
|
|
8082
|
+
sort_options: []
|
|
8083
|
+
};
|
|
8084
|
+
}
|
|
8085
|
+
if (!category) {
|
|
8086
|
+
return null;
|
|
8087
|
+
}
|
|
8088
|
+
const productFilters = await getProductFilters(
|
|
8089
|
+
this._swell,
|
|
8090
|
+
category.id !== "all" ? { category: category.id, $variants: true } : { $variants: true }
|
|
8091
|
+
);
|
|
8092
|
+
Object.assign(category, productFilters);
|
|
8093
|
+
return category;
|
|
8094
|
+
});
|
|
8095
|
+
return this._getProxy();
|
|
8096
|
+
}
|
|
8097
|
+
};
|
|
8098
|
+
|
|
8099
|
+
// src/resources/order.ts
|
|
8100
|
+
var SwellOrder = class extends SwellStorefrontRecord {
|
|
8101
|
+
constructor(swell, id, query) {
|
|
8102
|
+
super(swell, "accounts:orders", id, query, function() {
|
|
8103
|
+
return this._swell.storefront.account.getOrder(this._id);
|
|
8104
|
+
});
|
|
8105
|
+
return this._getProxy();
|
|
8106
|
+
}
|
|
8107
|
+
};
|
|
8108
|
+
|
|
8109
|
+
// src/resources/page.ts
|
|
8110
|
+
var SwellPage = class extends SwellStorefrontRecord {
|
|
8111
|
+
constructor(swell, id, query) {
|
|
8112
|
+
super(swell, "content/pages", id, query);
|
|
8113
|
+
return this._getProxy();
|
|
8114
|
+
}
|
|
8115
|
+
};
|
|
8116
|
+
|
|
8117
|
+
// src/resources/predictive_search.ts
|
|
8118
|
+
var SwellPredictiveSearch = class extends StorefrontResource {
|
|
8119
|
+
constructor(swell, query) {
|
|
8120
|
+
super(async function() {
|
|
8121
|
+
const performed = String(query || "").length > 0;
|
|
8122
|
+
let products;
|
|
8123
|
+
if (performed) {
|
|
8124
|
+
products = new SwellStorefrontCollection(
|
|
8125
|
+
swell,
|
|
8126
|
+
"products",
|
|
8127
|
+
{
|
|
8128
|
+
search: query,
|
|
8129
|
+
limit: 10
|
|
8130
|
+
}
|
|
8131
|
+
);
|
|
8132
|
+
await products.resolve();
|
|
8133
|
+
}
|
|
8134
|
+
return {
|
|
8135
|
+
query,
|
|
8136
|
+
performed,
|
|
8137
|
+
products
|
|
8138
|
+
};
|
|
8139
|
+
});
|
|
8140
|
+
}
|
|
8141
|
+
};
|
|
7923
8142
|
|
|
7924
8143
|
// src/resources/variant.ts
|
|
7925
8144
|
function transformSwellVariant(params, product, variant) {
|
|
@@ -7939,27 +8158,30 @@ function transformSwellVariant(params, product, variant) {
|
|
|
7939
8158
|
)
|
|
7940
8159
|
};
|
|
7941
8160
|
}
|
|
8161
|
+
var SwellVariant = class extends SwellStorefrontRecord {
|
|
8162
|
+
product;
|
|
8163
|
+
constructor(swell, product, id, query) {
|
|
8164
|
+
super(swell, "products:variants", id, query, async function() {
|
|
8165
|
+
const variant = await this._swell.get(
|
|
8166
|
+
"/products:variants/{id}",
|
|
8167
|
+
{ id: this._id }
|
|
8168
|
+
);
|
|
8169
|
+
return variant ?? null;
|
|
8170
|
+
});
|
|
8171
|
+
this.product = product;
|
|
8172
|
+
}
|
|
8173
|
+
};
|
|
7942
8174
|
|
|
7943
8175
|
// src/resources/product.ts
|
|
7944
|
-
var SORT_OPTIONS = [
|
|
7945
|
-
{ value: "", name: "Featured" },
|
|
7946
|
-
{ value: "popularity", name: "Popularity", query: "popularity desc" },
|
|
7947
|
-
{ value: "price_asc", name: "Price, low to high", query: "price asc" },
|
|
7948
|
-
{ value: "price_desc", name: "Price, high to low", query: "price desc" },
|
|
7949
|
-
{ value: "date_asc", name: "Date, old to new", query: "date asc" },
|
|
7950
|
-
{ value: "date_desc", name: "Date, new to old", query: "date desc" },
|
|
7951
|
-
{ value: "name_asc", name: "Product name, A-Z", query: "name asc" },
|
|
7952
|
-
{ value: "name_desc", name: "Product name, Z-A", query: "name desc" }
|
|
7953
|
-
];
|
|
7954
8176
|
function transformSwellProduct(params, product) {
|
|
7955
8177
|
if (!product) {
|
|
7956
|
-
return
|
|
8178
|
+
return null;
|
|
7957
8179
|
}
|
|
7958
8180
|
const newProduct = {
|
|
7959
8181
|
...product,
|
|
7960
8182
|
// add swell properties there
|
|
7961
8183
|
selected_option_values: getSelectedVariantOptionValues(product, params),
|
|
7962
|
-
purchase_options: getPurchaseOptions(product, params)
|
|
8184
|
+
purchase_options: getPurchaseOptions(product, params) ?? void 0
|
|
7963
8185
|
};
|
|
7964
8186
|
if (Array.isArray(newProduct.variants?.results)) {
|
|
7965
8187
|
newProduct.variants = {
|
|
@@ -7972,43 +8194,49 @@ function transformSwellProduct(params, product) {
|
|
|
7972
8194
|
return newProduct;
|
|
7973
8195
|
}
|
|
7974
8196
|
var SwellProduct = class extends SwellStorefrontRecord {
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
super(swell, "products", id, query,
|
|
7978
|
-
|
|
8197
|
+
constructor(swell, id, query) {
|
|
8198
|
+
const params = swell.queryParams;
|
|
8199
|
+
super(swell, "products", id, query, async function() {
|
|
8200
|
+
const result = await this._defaultGetter().call(this);
|
|
8201
|
+
return transformSwellProduct(params, result);
|
|
8202
|
+
});
|
|
7979
8203
|
return this._getProxy();
|
|
7980
8204
|
}
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
);
|
|
7987
|
-
|
|
8205
|
+
};
|
|
8206
|
+
|
|
8207
|
+
// src/resources/product_recommendations.ts
|
|
8208
|
+
var SwellProductRecommendations = class extends SwellProduct {
|
|
8209
|
+
constructor(swell, id, query) {
|
|
8210
|
+
super(swell, id, { ...query, $recommendations: true });
|
|
8211
|
+
}
|
|
8212
|
+
};
|
|
8213
|
+
|
|
8214
|
+
// src/resources/search.ts
|
|
8215
|
+
var SwellSearch = class extends StorefrontResource {
|
|
8216
|
+
constructor(swell, query) {
|
|
8217
|
+
super(async () => {
|
|
8218
|
+
const performed = String(query || "").length > 0;
|
|
8219
|
+
const productFilters = await getProductFilters(
|
|
8220
|
+
swell,
|
|
8221
|
+
performed ? { search: query } : void 0
|
|
8222
|
+
);
|
|
8223
|
+
return {
|
|
8224
|
+
query,
|
|
8225
|
+
performed,
|
|
8226
|
+
...productFilters
|
|
8227
|
+
};
|
|
8228
|
+
});
|
|
8229
|
+
}
|
|
8230
|
+
};
|
|
8231
|
+
|
|
8232
|
+
// src/resources/subscription.ts
|
|
8233
|
+
var SwellSubscription = class extends SwellStorefrontRecord {
|
|
8234
|
+
constructor(swell, id, query) {
|
|
8235
|
+
super(swell, "accounts:subscriptions", id, query, function() {
|
|
8236
|
+
return this._swell.storefront.subscriptions.get(this._id, this._query);
|
|
8237
|
+
});
|
|
7988
8238
|
}
|
|
7989
8239
|
};
|
|
7990
|
-
function productQueryWithFilters(swell, query = {}) {
|
|
7991
|
-
const sortBy = swell.queryParams.sort || "";
|
|
7992
|
-
const filters2 = Object.entries(swell.queryParams).reduce(
|
|
7993
|
-
(acc, [key, value]) => {
|
|
7994
|
-
if (key.startsWith("filter_")) {
|
|
7995
|
-
const qkey = key.replace("filter_", "");
|
|
7996
|
-
if (value?.gte !== void 0 || value?.lte !== void 0) {
|
|
7997
|
-
acc[qkey] = [value.gte || 0, value.lte || void 0];
|
|
7998
|
-
} else {
|
|
7999
|
-
acc[qkey] = value;
|
|
8000
|
-
}
|
|
8001
|
-
}
|
|
8002
|
-
return acc;
|
|
8003
|
-
},
|
|
8004
|
-
{}
|
|
8005
|
-
);
|
|
8006
|
-
return {
|
|
8007
|
-
sort: SORT_OPTIONS.find((option) => option.value === sortBy)?.query || void 0,
|
|
8008
|
-
$filters: filters2,
|
|
8009
|
-
...query
|
|
8010
|
-
};
|
|
8011
|
-
}
|
|
8012
8240
|
|
|
8013
8241
|
// src/api.ts
|
|
8014
8242
|
var DEFAULT_API_HOST = "https://api.schema.io";
|
|
@@ -15579,11 +15807,9 @@ function getProducts(instance, object, mapper) {
|
|
|
15579
15807
|
return this._defaultGetter().call(this);
|
|
15580
15808
|
}
|
|
15581
15809
|
);
|
|
15582
|
-
return products._cloneWithCompatibilityResult(
|
|
15583
|
-
(
|
|
15584
|
-
|
|
15585
|
-
}
|
|
15586
|
-
);
|
|
15810
|
+
return products._cloneWithCompatibilityResult((products2) => {
|
|
15811
|
+
return { ...products2, results: products2.results.map(mapper) };
|
|
15812
|
+
});
|
|
15587
15813
|
});
|
|
15588
15814
|
}
|
|
15589
15815
|
function makeProductsCollectionResolve(instance, object, mapper) {
|
|
@@ -15600,19 +15826,24 @@ function makeProductsCollectionResolve(instance, object, mapper) {
|
|
|
15600
15826
|
|
|
15601
15827
|
// src/compatibility/shopify-objects/collections.ts
|
|
15602
15828
|
function ShopifyCollections(instance, categories) {
|
|
15603
|
-
return new SwellStorefrontCollection(
|
|
15604
|
-
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15615
|
-
|
|
15829
|
+
return new SwellStorefrontCollection(
|
|
15830
|
+
instance.swell,
|
|
15831
|
+
categories._collection,
|
|
15832
|
+
categories._query,
|
|
15833
|
+
async () => {
|
|
15834
|
+
const results = (await categories.results)?.map((category) => {
|
|
15835
|
+
return ShopifyCollection(instance, category);
|
|
15836
|
+
});
|
|
15837
|
+
return {
|
|
15838
|
+
page: categories.page ?? 1,
|
|
15839
|
+
count: categories.count ?? 0,
|
|
15840
|
+
results: results ?? [],
|
|
15841
|
+
page_count: categories.page_count ?? 0,
|
|
15842
|
+
limit: categories.limit,
|
|
15843
|
+
pages: categories.pages ?? {}
|
|
15844
|
+
};
|
|
15845
|
+
}
|
|
15846
|
+
);
|
|
15616
15847
|
}
|
|
15617
15848
|
|
|
15618
15849
|
// src/compatibility/shopify-objects/address.ts
|
|
@@ -16799,13 +17030,12 @@ var ImagesDrop = class extends Drop7 {
|
|
|
16799
17030
|
var SwellImage = class extends StorefrontResource {
|
|
16800
17031
|
constructor(swell, name) {
|
|
16801
17032
|
super(async () => {
|
|
16802
|
-
const
|
|
17033
|
+
const file = await swell.get("/:files/:last", {
|
|
16803
17034
|
private: { $ne: true },
|
|
16804
17035
|
content_type: { $regex: "^image/" },
|
|
16805
17036
|
filename: name
|
|
16806
17037
|
});
|
|
16807
|
-
|
|
16808
|
-
if (file === null) {
|
|
17038
|
+
if (!file) {
|
|
16809
17039
|
return null;
|
|
16810
17040
|
}
|
|
16811
17041
|
return { file };
|
|
@@ -22107,21 +22337,30 @@ export {
|
|
|
22107
22337
|
StorefrontResource,
|
|
22108
22338
|
Swell,
|
|
22109
22339
|
SwellAccount,
|
|
22340
|
+
SwellAddresses,
|
|
22110
22341
|
SwellBackendAPI,
|
|
22111
22342
|
SwellBlog,
|
|
22112
22343
|
SwellBlogCategory,
|
|
22113
22344
|
SwellCart,
|
|
22345
|
+
SwellCategories,
|
|
22114
22346
|
SwellCategory,
|
|
22115
22347
|
SwellError,
|
|
22116
22348
|
SwellOrder,
|
|
22349
|
+
SwellOrders,
|
|
22117
22350
|
SwellPage,
|
|
22351
|
+
SwellPredictiveSearch,
|
|
22118
22352
|
SwellProduct,
|
|
22353
|
+
SwellProductRecommendations,
|
|
22354
|
+
SwellSearch,
|
|
22119
22355
|
SwellStorefrontCollection,
|
|
22120
22356
|
SwellStorefrontPagination,
|
|
22121
22357
|
SwellStorefrontRecord,
|
|
22122
22358
|
SwellStorefrontResource,
|
|
22123
22359
|
SwellStorefrontSingleton,
|
|
22360
|
+
SwellSubscription,
|
|
22361
|
+
SwellSubscriptions,
|
|
22124
22362
|
SwellTheme3 as SwellTheme,
|
|
22363
|
+
SwellVariant,
|
|
22125
22364
|
ThemeColor,
|
|
22126
22365
|
ThemeFont,
|
|
22127
22366
|
ThemeForm,
|