@spiffcommerce/core 37.0.0 → 37.0.1
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +60 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -14760,31 +14760,33 @@ class An {
|
|
|
14760
14760
|
this.onGlobalPropertiesChanged.bind(this),
|
|
14761
14761
|
o
|
|
14762
14762
|
), this.globalPropertyHandleService = new Nl(this), this.setPreviewService(a), this.initializationPromise = (async () => {
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
query
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14787
|
-
|
|
14763
|
+
if (!o?.readonly) {
|
|
14764
|
+
const c = this.bundleStateManager.getState();
|
|
14765
|
+
if (c.integrationProductIds && c.integrationProductIds.length > 0) {
|
|
14766
|
+
const d = await S.getShadowGraphqlClient().query({
|
|
14767
|
+
query: Wn,
|
|
14768
|
+
variables: {
|
|
14769
|
+
ids: c.integrationProductIds
|
|
14770
|
+
},
|
|
14771
|
+
errorPolicy: "all",
|
|
14772
|
+
fetchPolicy: "no-cache"
|
|
14773
|
+
});
|
|
14774
|
+
if (d.errors)
|
|
14775
|
+
throw new Error(`Failed to fetch integration products for Bundle ${e.id}`);
|
|
14776
|
+
const A = d.data.integrationProducts?.filter((h) => !!h.product?.id && c.integrationProductIds.includes(h.id)).map((h) => h.product.id);
|
|
14777
|
+
c.integrationProductIds = [], c.productIds = Array.from(/* @__PURE__ */ new Set([...c.productIds || [], ...A || []]));
|
|
14778
|
+
const u = JSON.stringify(c);
|
|
14779
|
+
this.bundleStateManager.setState(u), await S.getShadowGraphqlClient().mutate({
|
|
14780
|
+
mutation: de,
|
|
14781
|
+
variables: {
|
|
14782
|
+
id: this.id,
|
|
14783
|
+
bundleStateData: u
|
|
14784
|
+
},
|
|
14785
|
+
context: {
|
|
14786
|
+
bundleOwnerId: r
|
|
14787
|
+
}
|
|
14788
|
+
});
|
|
14789
|
+
}
|
|
14788
14790
|
}
|
|
14789
14791
|
return Promise.all([
|
|
14790
14792
|
this.loadExistingWorkflowExperiences(
|
|
@@ -14797,27 +14799,27 @@ class An {
|
|
|
14797
14799
|
),
|
|
14798
14800
|
this.globalPropertyStateManager.getInitializationPromise()
|
|
14799
14801
|
]).then(
|
|
14800
|
-
() => new Promise((
|
|
14802
|
+
() => new Promise((c, d) => {
|
|
14801
14803
|
if (o?.readonly) {
|
|
14802
|
-
|
|
14804
|
+
c([]);
|
|
14803
14805
|
return;
|
|
14804
14806
|
}
|
|
14805
14807
|
console.log("Setting default global variants.");
|
|
14806
|
-
const
|
|
14807
|
-
|
|
14808
|
-
const
|
|
14809
|
-
if (
|
|
14810
|
-
const
|
|
14811
|
-
if (!
|
|
14808
|
+
const A = this.globalPropertyStateManager.getGlobalPropertyState();
|
|
14809
|
+
A ? this.globalPropertyHandleService.getHandles().then((u) => {
|
|
14810
|
+
const h = u.map(async (g) => {
|
|
14811
|
+
if (g.getType() === z.ColorOption || g.getType() === z.Option) {
|
|
14812
|
+
const p = g;
|
|
14813
|
+
if (!A.aspects.find((f) => f.name === p.getName()))
|
|
14812
14814
|
try {
|
|
14813
|
-
return await
|
|
14814
|
-
} catch (
|
|
14815
|
-
console.error(`Failed to initialize default global variant - ${
|
|
14815
|
+
return await p.initDefaultVariant();
|
|
14816
|
+
} catch (f) {
|
|
14817
|
+
console.error(`Failed to initialize default global variant - ${f}`);
|
|
14816
14818
|
}
|
|
14817
14819
|
}
|
|
14818
14820
|
});
|
|
14819
|
-
Promise.all(
|
|
14820
|
-
}) : (console.log("Attempted to set global default variant before state was initialized."),
|
|
14821
|
+
Promise.all(h).then(c).catch(d);
|
|
14822
|
+
}) : (console.log("Attempted to set global default variant before state was initialized."), c([]));
|
|
14821
14823
|
})
|
|
14822
14824
|
);
|
|
14823
14825
|
})(), this.initializationPromise.catch((c) => {
|
|
@@ -15428,29 +15430,31 @@ class An {
|
|
|
15428
15430
|
async loadExistingWorkflowExperiences(t, e, a) {
|
|
15429
15431
|
if (t.length === 0) return;
|
|
15430
15432
|
const i = await this.client.getWorkflowExperiences(
|
|
15431
|
-
t.map((
|
|
15433
|
+
t.map((r) => ({
|
|
15432
15434
|
type: "transaction",
|
|
15433
|
-
transactionId:
|
|
15435
|
+
transactionId: r
|
|
15434
15436
|
})),
|
|
15435
15437
|
e,
|
|
15436
15438
|
void 0,
|
|
15437
15439
|
a
|
|
15438
15440
|
);
|
|
15439
|
-
if (i.forEach((
|
|
15440
|
-
for (const
|
|
15441
|
-
await this.injectExperienceIntoPreviewService(
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15441
|
+
if (i.forEach((r) => r.setBundle(this)), i.forEach((r) => r.checkForPriceBreakChanges()), this.workflowExperiences = i, this.previewService)
|
|
15442
|
+
for (const r of i)
|
|
15443
|
+
await this.injectExperienceIntoPreviewService(r);
|
|
15444
|
+
if (!this.globalPropertyStateManager.getBundleOptions()?.readonly) {
|
|
15445
|
+
const r = this.getProductIds() || [], o = this.getProductCollection();
|
|
15446
|
+
if (o && r.length > 0) {
|
|
15447
|
+
await o.fetchProducts();
|
|
15448
|
+
const s = o.getProducts(), l = [], c = [];
|
|
15449
|
+
for (const A of r)
|
|
15450
|
+
if (!s.find((h) => h.getId() === A)) {
|
|
15451
|
+
for (const h of i)
|
|
15452
|
+
h.getProduct()?.id === A && c.push(h);
|
|
15453
|
+
l.push(A);
|
|
15454
|
+
}
|
|
15455
|
+
const d = [];
|
|
15456
|
+
l.length > 0 && d.push(this.removeProductIds(l)), c.length > 0 && d.push(Promise.all(c.map((A) => A.clearProduct()))), d.length > 0 && await Promise.all(d);
|
|
15457
|
+
}
|
|
15454
15458
|
}
|
|
15455
15459
|
}
|
|
15456
15460
|
async updateBundle() {
|
|
@@ -16107,7 +16111,7 @@ class qd {
|
|
|
16107
16111
|
} catch (a) {
|
|
16108
16112
|
throw console.error(a), new pt("Critical - Unable to synchronize workflow state with server.");
|
|
16109
16113
|
}
|
|
16110
|
-
}, this.options = t, this.options.applicationKey && cr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 37.0.
|
|
16114
|
+
}, this.options = t, this.options.applicationKey && cr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 37.0.1"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
|
|
16111
16115
|
}
|
|
16112
16116
|
configure(t) {
|
|
16113
16117
|
Ct.setHubUrl(t.hubUrl), Ct.setServerUrl(t.serverUrl), Ct.setServicesApiUrl(t.servicesApiUrl), this.marketplaceThemeInstallId = t.marketplaceThemeInstallId, this.marketplaceThemeInstallConfigurationId = t.marketplaceThemeInstallConfigurationId, this.userPoolClientId = t.userPoolClientId, this.userPoolRegion = t.userPoolRegion, this.spiffRegion = t.spiffRegion, t.bearerAuthenticationToken && Ar(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Lt.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);
|