@swell/apps-sdk 1.0.153 → 1.0.154
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 +22 -9
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +22 -9
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +22 -9
- package/dist/index.mjs.map +2 -2
- package/dist/src/resources.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -860,18 +860,31 @@ var StorefrontResource = class {
|
|
|
860
860
|
return this._compatibilityProps[prop];
|
|
861
861
|
}
|
|
862
862
|
};
|
|
863
|
+
var RESOURCE_CLONE_PROPS = Object.freeze([
|
|
864
|
+
"_defaultGetter",
|
|
865
|
+
"_getResourceObject",
|
|
866
|
+
"_collection",
|
|
867
|
+
"_swell",
|
|
868
|
+
"_query",
|
|
869
|
+
"_params",
|
|
870
|
+
"_id",
|
|
871
|
+
"_resourceName"
|
|
872
|
+
]);
|
|
863
873
|
function cloneStorefrontResource(input) {
|
|
864
|
-
const resourceName = input._resourceName;
|
|
874
|
+
const resourceName = input._resourceName || input.constructor?.name;
|
|
865
875
|
const ClonedClass = class extends StorefrontResource {
|
|
866
876
|
};
|
|
867
877
|
Object.defineProperty(ClonedClass, "name", {
|
|
868
878
|
value: resourceName
|
|
869
879
|
});
|
|
870
880
|
const clone = new ClonedClass(input._getter);
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
881
|
+
for (const key of RESOURCE_CLONE_PROPS) {
|
|
882
|
+
if (input[key] !== void 0) {
|
|
883
|
+
Object.defineProperty(clone, key, {
|
|
884
|
+
value: input[key]
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
}
|
|
875
888
|
return clone;
|
|
876
889
|
}
|
|
877
890
|
var SwellStorefrontResource = class extends StorefrontResource {
|
|
@@ -890,7 +903,7 @@ var SwellStorefrontResource = class extends StorefrontResource {
|
|
|
890
903
|
_getProxy() {
|
|
891
904
|
return super._getProxy();
|
|
892
905
|
}
|
|
893
|
-
|
|
906
|
+
_getResourceObject() {
|
|
894
907
|
const { _swell, _collection } = this;
|
|
895
908
|
this._resource = (_swell?.storefront)[_collection];
|
|
896
909
|
if (_swell && _collection.startsWith("content/")) {
|
|
@@ -947,7 +960,7 @@ var SwellStorefrontCollection = class _SwellStorefrontCollection extends SwellSt
|
|
|
947
960
|
return properQuery;
|
|
948
961
|
}
|
|
949
962
|
_defaultGetter() {
|
|
950
|
-
const resource = this.
|
|
963
|
+
const resource = this._getResourceObject();
|
|
951
964
|
async function defaultGetter() {
|
|
952
965
|
return resource.list(this._query);
|
|
953
966
|
}
|
|
@@ -1074,7 +1087,7 @@ var SwellStorefrontRecord = class extends SwellStorefrontResource {
|
|
|
1074
1087
|
return super._getProxy();
|
|
1075
1088
|
}
|
|
1076
1089
|
_defaultGetter() {
|
|
1077
|
-
const resource = this.
|
|
1090
|
+
const resource = this._getResourceObject();
|
|
1078
1091
|
async function defaultGetter() {
|
|
1079
1092
|
return resource.get(this._id, this._query);
|
|
1080
1093
|
}
|
|
@@ -1133,7 +1146,7 @@ var SwellStorefrontSingleton = class extends SwellStorefrontResource {
|
|
|
1133
1146
|
_collection,
|
|
1134
1147
|
_swell: { storefrontContext }
|
|
1135
1148
|
} = this;
|
|
1136
|
-
const resource = this.
|
|
1149
|
+
const resource = this._getResourceObject();
|
|
1137
1150
|
async function defaultGetter() {
|
|
1138
1151
|
if (storefrontContext[_collection] !== void 0) {
|
|
1139
1152
|
return storefrontContext[_collection];
|