@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.js
CHANGED
|
@@ -740,18 +740,31 @@
|
|
|
740
740
|
return this._compatibilityProps[prop];
|
|
741
741
|
}
|
|
742
742
|
};
|
|
743
|
+
var RESOURCE_CLONE_PROPS = Object.freeze([
|
|
744
|
+
"_defaultGetter",
|
|
745
|
+
"_getResourceObject",
|
|
746
|
+
"_collection",
|
|
747
|
+
"_swell",
|
|
748
|
+
"_query",
|
|
749
|
+
"_params",
|
|
750
|
+
"_id",
|
|
751
|
+
"_resourceName"
|
|
752
|
+
]);
|
|
743
753
|
function cloneStorefrontResource(input) {
|
|
744
|
-
const resourceName = input._resourceName;
|
|
754
|
+
const resourceName = input._resourceName || input.constructor?.name;
|
|
745
755
|
const ClonedClass = class extends StorefrontResource {
|
|
746
756
|
};
|
|
747
757
|
Object.defineProperty(ClonedClass, "name", {
|
|
748
758
|
value: resourceName
|
|
749
759
|
});
|
|
750
760
|
const clone = new ClonedClass(input._getter);
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
761
|
+
for (const key of RESOURCE_CLONE_PROPS) {
|
|
762
|
+
if (input[key] !== void 0) {
|
|
763
|
+
Object.defineProperty(clone, key, {
|
|
764
|
+
value: input[key]
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
}
|
|
755
768
|
return clone;
|
|
756
769
|
}
|
|
757
770
|
var SwellStorefrontResource = class extends StorefrontResource {
|
|
@@ -770,7 +783,7 @@
|
|
|
770
783
|
_getProxy() {
|
|
771
784
|
return super._getProxy();
|
|
772
785
|
}
|
|
773
|
-
|
|
786
|
+
_getResourceObject() {
|
|
774
787
|
const { _swell, _collection } = this;
|
|
775
788
|
this._resource = (_swell?.storefront)[_collection];
|
|
776
789
|
if (_swell && _collection.startsWith("content/")) {
|
|
@@ -827,7 +840,7 @@
|
|
|
827
840
|
return properQuery;
|
|
828
841
|
}
|
|
829
842
|
_defaultGetter() {
|
|
830
|
-
const resource = this.
|
|
843
|
+
const resource = this._getResourceObject();
|
|
831
844
|
async function defaultGetter() {
|
|
832
845
|
return resource.list(this._query);
|
|
833
846
|
}
|
|
@@ -954,7 +967,7 @@
|
|
|
954
967
|
return super._getProxy();
|
|
955
968
|
}
|
|
956
969
|
_defaultGetter() {
|
|
957
|
-
const resource = this.
|
|
970
|
+
const resource = this._getResourceObject();
|
|
958
971
|
async function defaultGetter() {
|
|
959
972
|
return resource.get(this._id, this._query);
|
|
960
973
|
}
|
|
@@ -1013,7 +1026,7 @@
|
|
|
1013
1026
|
_collection,
|
|
1014
1027
|
_swell: { storefrontContext }
|
|
1015
1028
|
} = this;
|
|
1016
|
-
const resource = this.
|
|
1029
|
+
const resource = this._getResourceObject();
|
|
1017
1030
|
async function defaultGetter() {
|
|
1018
1031
|
if (storefrontContext[_collection] !== void 0) {
|
|
1019
1032
|
return storefrontContext[_collection];
|