@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.mjs
CHANGED
|
@@ -713,18 +713,31 @@ var StorefrontResource = class {
|
|
|
713
713
|
return this._compatibilityProps[prop];
|
|
714
714
|
}
|
|
715
715
|
};
|
|
716
|
+
var RESOURCE_CLONE_PROPS = Object.freeze([
|
|
717
|
+
"_defaultGetter",
|
|
718
|
+
"_getResourceObject",
|
|
719
|
+
"_collection",
|
|
720
|
+
"_swell",
|
|
721
|
+
"_query",
|
|
722
|
+
"_params",
|
|
723
|
+
"_id",
|
|
724
|
+
"_resourceName"
|
|
725
|
+
]);
|
|
716
726
|
function cloneStorefrontResource(input) {
|
|
717
|
-
const resourceName = input._resourceName;
|
|
727
|
+
const resourceName = input._resourceName || input.constructor?.name;
|
|
718
728
|
const ClonedClass = class extends StorefrontResource {
|
|
719
729
|
};
|
|
720
730
|
Object.defineProperty(ClonedClass, "name", {
|
|
721
731
|
value: resourceName
|
|
722
732
|
});
|
|
723
733
|
const clone = new ClonedClass(input._getter);
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
734
|
+
for (const key of RESOURCE_CLONE_PROPS) {
|
|
735
|
+
if (input[key] !== void 0) {
|
|
736
|
+
Object.defineProperty(clone, key, {
|
|
737
|
+
value: input[key]
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
}
|
|
728
741
|
return clone;
|
|
729
742
|
}
|
|
730
743
|
var SwellStorefrontResource = class extends StorefrontResource {
|
|
@@ -743,7 +756,7 @@ var SwellStorefrontResource = class extends StorefrontResource {
|
|
|
743
756
|
_getProxy() {
|
|
744
757
|
return super._getProxy();
|
|
745
758
|
}
|
|
746
|
-
|
|
759
|
+
_getResourceObject() {
|
|
747
760
|
const { _swell, _collection } = this;
|
|
748
761
|
this._resource = (_swell?.storefront)[_collection];
|
|
749
762
|
if (_swell && _collection.startsWith("content/")) {
|
|
@@ -800,7 +813,7 @@ var SwellStorefrontCollection = class _SwellStorefrontCollection extends SwellSt
|
|
|
800
813
|
return properQuery;
|
|
801
814
|
}
|
|
802
815
|
_defaultGetter() {
|
|
803
|
-
const resource = this.
|
|
816
|
+
const resource = this._getResourceObject();
|
|
804
817
|
async function defaultGetter() {
|
|
805
818
|
return resource.list(this._query);
|
|
806
819
|
}
|
|
@@ -927,7 +940,7 @@ var SwellStorefrontRecord = class extends SwellStorefrontResource {
|
|
|
927
940
|
return super._getProxy();
|
|
928
941
|
}
|
|
929
942
|
_defaultGetter() {
|
|
930
|
-
const resource = this.
|
|
943
|
+
const resource = this._getResourceObject();
|
|
931
944
|
async function defaultGetter() {
|
|
932
945
|
return resource.get(this._id, this._query);
|
|
933
946
|
}
|
|
@@ -986,7 +999,7 @@ var SwellStorefrontSingleton = class extends SwellStorefrontResource {
|
|
|
986
999
|
_collection,
|
|
987
1000
|
_swell: { storefrontContext }
|
|
988
1001
|
} = this;
|
|
989
|
-
const resource = this.
|
|
1002
|
+
const resource = this._getResourceObject();
|
|
990
1003
|
async function defaultGetter() {
|
|
991
1004
|
if (storefrontContext[_collection] !== void 0) {
|
|
992
1005
|
return storefrontContext[_collection];
|