@spiffcommerce/core 32.4.0-beta.10d6c3f0-b67c-57ea-8493-e129d6bd348f → 32.4.0-beta.1b26129a-55da-564d-bf8a-bc8182e21c7f
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.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -65,7 +65,7 @@ class Me extends gn {
|
|
65
65
|
super(`ImplementationError - ${t}`);
|
66
66
|
}
|
67
67
|
}
|
68
|
-
class
|
68
|
+
class T extends Me {
|
69
69
|
constructor(t) {
|
70
70
|
super(`Unhandled Behavior Encountered: ${t}`);
|
71
71
|
}
|
@@ -3544,7 +3544,7 @@ class wi {
|
|
3544
3544
|
async getLocalOrFromServer(t) {
|
3545
3545
|
if (this.cache.has(t)) {
|
3546
3546
|
const r = this.cache.get(t);
|
3547
|
-
if (!r) throw new
|
3547
|
+
if (!r) throw new T("Failed to get asset from cache!");
|
3548
3548
|
return r;
|
3549
3549
|
}
|
3550
3550
|
const a = (async () => (await Be([t]))[0])();
|
@@ -3570,14 +3570,14 @@ class wi {
|
|
3570
3570
|
* Caches an asset if it doesn't already exist.
|
3571
3571
|
*/
|
3572
3572
|
cacheAsset(t) {
|
3573
|
-
if (!t.key) throw new
|
3573
|
+
if (!t.key) throw new T("Asset has no key!");
|
3574
3574
|
this.cache.has(t.key) || this.cache.set(t.key, Promise.resolve(t));
|
3575
3575
|
}
|
3576
3576
|
/**
|
3577
3577
|
* Caches a material if it doesn't already exist.
|
3578
3578
|
*/
|
3579
3579
|
cacheMaterial(t) {
|
3580
|
-
if (!t.id) throw new
|
3580
|
+
if (!t.id) throw new T("Material has no id!");
|
3581
3581
|
this.materialCache.has(t.id) || this.materialCache.set(t.id, Promise.resolve(t));
|
3582
3582
|
}
|
3583
3583
|
/**
|
@@ -3693,7 +3693,7 @@ class wi {
|
|
3693
3693
|
case "mkv":
|
3694
3694
|
return "video/x-matroska";
|
3695
3695
|
default:
|
3696
|
-
throw new
|
3696
|
+
throw new T("Unexpected mimetype: " + e);
|
3697
3697
|
}
|
3698
3698
|
}
|
3699
3699
|
}
|
@@ -8923,7 +8923,7 @@ class Rs {
|
|
8923
8923
|
l.helperData.charactersRemaining = a.data.maxLength - o.length;
|
8924
8924
|
const c = [], d = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
|
8925
8925
|
for (const u of e) {
|
8926
|
-
if (!u.fontData) throw new
|
8926
|
+
if (!u.fontData) throw new T("Failed to resolve font data for text.");
|
8927
8927
|
const [h, m] = Ce(
|
8928
8928
|
u.fontSize,
|
8929
8929
|
u.fontData,
|
@@ -9210,7 +9210,7 @@ class Rs {
|
|
9210
9210
|
paths: a.paths,
|
9211
9211
|
fillSpotColorDefinition: f
|
9212
9212
|
}, y = [], S = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
|
9213
|
-
if (!P.fontData) throw new
|
9213
|
+
if (!P.fontData) throw new T("Failed to resolve font data for text.");
|
9214
9214
|
const [b, F] = Ce(
|
9215
9215
|
P.fontSize,
|
9216
9216
|
P.fontData,
|
@@ -9231,10 +9231,10 @@ class Rs {
|
|
9231
9231
|
y.push(
|
9232
9232
|
this.generateTextChangeCommandsForRegion(b, a, P.id, R)
|
9233
9233
|
);
|
9234
|
-
const
|
9234
|
+
const N = new z(P, m);
|
9235
9235
|
return {
|
9236
9236
|
regionElement: { id: p, region: u },
|
9237
|
-
commands: [
|
9237
|
+
commands: [N, ...y],
|
9238
9238
|
newElement: P,
|
9239
9239
|
fontData: r
|
9240
9240
|
};
|
@@ -9489,7 +9489,7 @@ class qs extends Os {
|
|
9489
9489
|
const b = et("g");
|
9490
9490
|
b.classList.add("module-layer2"), I.appendChild(b), b.setAttribute("fill", "rgb(255,209,0)"), b.setAttribute("transform", "translate(1,-0.1)"), b.innerHTML = o;
|
9491
9491
|
const F = et("g");
|
9492
|
-
return F.classList.add("module-layer3"), I.appendChild(F), F.setAttribute("fill", "white"), F.innerHTML = o, new Ws(I).transform(([
|
9492
|
+
return F.classList.add("module-layer3"), I.appendChild(F), F.setAttribute("fill", "white"), F.innerHTML = o, new Ws(I).transform(([N, Z]) => [N, Z + (c / 2 - N) ** 2 / (c * 6)]), I;
|
9493
9493
|
}, u = et("g");
|
9494
9494
|
u.classList.add("module-root");
|
9495
9495
|
const h = et("defs");
|
@@ -9509,7 +9509,7 @@ class qs extends Os {
|
|
9509
9509
|
async function tr(n) {
|
9510
9510
|
if (n === "Vegemite")
|
9511
9511
|
return new qs();
|
9512
|
-
throw new
|
9512
|
+
throw new T(`Failed to resolve Module, Module ${n} not found`);
|
9513
9513
|
}
|
9514
9514
|
const Hs = [
|
9515
9515
|
"altGlyph",
|
@@ -11326,7 +11326,7 @@ class Go {
|
|
11326
11326
|
const c = l[0];
|
11327
11327
|
if (o.type === E.Model) {
|
11328
11328
|
if (!this.modelContainer)
|
11329
|
-
throw new
|
11329
|
+
throw new T(
|
11330
11330
|
"We should always have a model container when injecting a preview!"
|
11331
11331
|
);
|
11332
11332
|
const d = c.asset?.fileLink;
|
@@ -11351,7 +11351,7 @@ class Go {
|
|
11351
11351
|
}
|
11352
11352
|
o.data.targetMaterials.forEach((u) => {
|
11353
11353
|
if (!this.modelContainer)
|
11354
|
-
throw new
|
11354
|
+
throw new T(
|
11355
11355
|
"We should always have a model container when injecting a preview!"
|
11356
11356
|
);
|
11357
11357
|
this.modelContainer.applyMaterialVariant(u, o.option.id, d);
|
@@ -11422,7 +11422,7 @@ class Go {
|
|
11422
11422
|
serialize() {
|
11423
11423
|
const t = this.getCommandContext().getState();
|
11424
11424
|
if (!t)
|
11425
|
-
throw new
|
11425
|
+
throw new T("Attempted to serialize state before it was initialized.");
|
11426
11426
|
const e = vt(t.transaction), a = this.dehydrateState(e);
|
11427
11427
|
return JSON.stringify(a);
|
11428
11428
|
}
|
@@ -12419,7 +12419,7 @@ class de {
|
|
12419
12419
|
case E.Module:
|
12420
12420
|
return new Zo(t, e, t.getStepTags(e.stepName));
|
12421
12421
|
default:
|
12422
|
-
throw new
|
12422
|
+
throw new T(`Step type ${e.type} not yet supported in Core SDK`);
|
12423
12423
|
}
|
12424
12424
|
}
|
12425
12425
|
}
|
@@ -12636,7 +12636,7 @@ const al = async (n, t) => {
|
|
12636
12636
|
await (async () => {
|
12637
12637
|
if (c !== void 0) return c;
|
12638
12638
|
await n.outstandingRequestsPromise();
|
12639
|
-
const F = (k.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map()).get(r.id),
|
12639
|
+
const F = (k.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map()).get(r.id), N = await v.getShadowGraphqlClient().query({
|
12640
12640
|
query: kn,
|
12641
12641
|
variables: { ids: [r.id] },
|
12642
12642
|
fetchPolicy: "no-cache",
|
@@ -12644,17 +12644,17 @@ const al = async (n, t) => {
|
|
12644
12644
|
context: {
|
12645
12645
|
transactionOwnerId: F
|
12646
12646
|
}
|
12647
|
-
}), Z =
|
12648
|
-
return
|
12649
|
-
|
12647
|
+
}), Z = N.data?.transactions[0].workflowState;
|
12648
|
+
return N.errors ? (N.errors.forEach((tt) => {
|
12649
|
+
N.errors && console.log("Server Error:", tt.message);
|
12650
12650
|
}), null) : Z ?? null;
|
12651
12651
|
})() || (console.warn("State mismatch detected. Uploading known state explicitly"), console.warn("State Object:", JSON.stringify(a())), await n.updateStateWithServerImmediate(a), console.log("Server state is undefined @ Workflow completion"));
|
12652
12652
|
const u = n.getPreviewService(), h = t?.finalizeStepConfig?.lookAtAnimation, m = u && t.showModelOnFinishStep && !!h, p = l && Za(l, t, !0), g = l && Za(l, t, !1), f = async (b) => {
|
12653
12653
|
const F = {};
|
12654
12654
|
let R = 0;
|
12655
12655
|
if (Object.keys(i).length > 0)
|
12656
|
-
for (const
|
12657
|
-
const Z = i[
|
12656
|
+
for (const N of Object.keys(i)) {
|
12657
|
+
const Z = i[N], tt = t.steps.find((rt) => rt.stepName === N);
|
12658
12658
|
for (let rt = 0; rt < Z.selections.length; ++rt) {
|
12659
12659
|
const K = Z.selections[rt];
|
12660
12660
|
if (tt && (!b || tt.option && (tt.option.variants || []).length > 1 && !tt.data.hideSelectionInCart && !tt.data.hideSelectionsInCart)) {
|
@@ -12708,14 +12708,14 @@ const al = async (n, t) => {
|
|
12708
12708
|
};
|
12709
12709
|
if (g) {
|
12710
12710
|
const F = [];
|
12711
|
-
for (const [R,
|
12712
|
-
F.push({ key: R, value:
|
12711
|
+
for (const [R, N] of Object.entries(g))
|
12712
|
+
F.push({ key: R, value: N });
|
12713
12713
|
b.metadata = F;
|
12714
12714
|
}
|
12715
12715
|
if (I) {
|
12716
12716
|
const F = [];
|
12717
|
-
for (const [R,
|
12718
|
-
F.push({ key: R, ids:
|
12717
|
+
for (const [R, N] of Object.entries(y))
|
12718
|
+
F.push({ key: R, ids: N });
|
12719
12719
|
b.selectedVariants = F;
|
12720
12720
|
}
|
12721
12721
|
return b;
|
@@ -12824,7 +12824,7 @@ class ol {
|
|
12824
12824
|
const t = k.get(this.localPersistenceKey);
|
12825
12825
|
return t ? JSON.parse(t) : [];
|
12826
12826
|
}
|
12827
|
-
throw new
|
12827
|
+
throw new T("Unexpected storage method requested");
|
12828
12828
|
}
|
12829
12829
|
/**
|
12830
12830
|
* Search for a transaction that has been saved.
|
@@ -12864,7 +12864,7 @@ class ol {
|
|
12864
12864
|
k.set(this.localPersistenceKey, JSON.stringify(t));
|
12865
12865
|
return;
|
12866
12866
|
}
|
12867
|
-
throw new
|
12867
|
+
throw new T("Unexpected storage method requested");
|
12868
12868
|
}
|
12869
12869
|
}
|
12870
12870
|
const Xe = new ol(), ll = w`
|
@@ -13071,8 +13071,13 @@ class hl {
|
|
13071
13071
|
}
|
13072
13072
|
})).data?.transactionUpdateIntegrationProduct.product;
|
13073
13073
|
if (!a)
|
13074
|
-
throw new
|
13075
|
-
|
13074
|
+
throw new T("Failed to set product. No product returned from server.");
|
13075
|
+
if (!this.bundle)
|
13076
|
+
throw new T("Cannot set product on experience that is not part of a bundle.");
|
13077
|
+
const r = (await this.bundle.getProductCollection().fetchProducts()).find(
|
13078
|
+
(i) => i.getId() === a.id
|
13079
|
+
);
|
13080
|
+
this.product = a, this.currentPriceBreak = this.priceBreakToBeApplied();
|
13076
13081
|
try {
|
13077
13082
|
const i = r?.getDefaultWorkflow();
|
13078
13083
|
if (i) {
|
@@ -13082,7 +13087,6 @@ class hl {
|
|
13082
13087
|
} catch {
|
13083
13088
|
console.log("Setting Product - No default workflow available, must be set manually.");
|
13084
13089
|
}
|
13085
|
-
this.product = a, this.currentPriceBreak = this.priceBreakToBeApplied();
|
13086
13090
|
}
|
13087
13091
|
getWorkflow() {
|
13088
13092
|
return this.workflow;
|
@@ -13316,9 +13320,9 @@ class hl {
|
|
13316
13320
|
}
|
13317
13321
|
async save(t) {
|
13318
13322
|
const e = this.getProduct(), a = this.getWorkflow(), r = this.getCommandContext().getState();
|
13319
|
-
if (!e) throw new
|
13320
|
-
if (!a) throw new
|
13321
|
-
if (!r) throw new
|
13323
|
+
if (!e) throw new T("Product undefined!");
|
13324
|
+
if (!a) throw new T("Workflow undefined!");
|
13325
|
+
if (!r) throw new T("State undefined!");
|
13322
13326
|
const s = {
|
13323
13327
|
title: await (async () => {
|
13324
13328
|
if (t) return t;
|
@@ -13337,11 +13341,11 @@ class hl {
|
|
13337
13341
|
}
|
13338
13342
|
async copy() {
|
13339
13343
|
const t = vt(this.getCommandContext().getState());
|
13340
|
-
if (!t) throw new
|
13344
|
+
if (!t) throw new T("Internal state is undefined! Cannot copy experience!");
|
13341
13345
|
const e = JSON.stringify(t.transaction), a = this.getWorkflow();
|
13342
|
-
if (!a) throw new
|
13346
|
+
if (!a) throw new T("Workflow is undefined! Cannot copy experience!");
|
13343
13347
|
const r = this.getTransaction().integrationProduct?.id;
|
13344
|
-
if (!r) throw new
|
13348
|
+
if (!r) throw new T("Integration product id is undefined!");
|
13345
13349
|
return await this.getClient().getWorkflowExperience({
|
13346
13350
|
type: "integration",
|
13347
13351
|
integrationProductId: r,
|
@@ -13352,9 +13356,9 @@ class hl {
|
|
13352
13356
|
async onDesignFinished(t, e = !0) {
|
13353
13357
|
const a = this.getTransaction(), r = this.getProduct(), i = this.getWorkflow();
|
13354
13358
|
if (!r)
|
13355
|
-
throw new
|
13359
|
+
throw new T("Product undefined! Cannot finish an experience without a product.");
|
13356
13360
|
if (!i)
|
13357
|
-
throw new
|
13361
|
+
throw new T("Workflow undefined! Cannot finish an experience without a workflow.");
|
13358
13362
|
return a.completed ? (await this.graphQlClient().mutate({
|
13359
13363
|
mutation: Ri,
|
13360
13364
|
variables: {
|
@@ -16132,7 +16136,7 @@ class bd {
|
|
16132
16136
|
} catch (a) {
|
16133
16137
|
throw console.error(a), new ht("Critical - Unable to synchronize workflow state with server.");
|
16134
16138
|
}
|
16135
|
-
}, this.options = t, this.options.applicationKey && qr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 32.4.0-beta.
|
16139
|
+
}, this.options = t, this.options.applicationKey && qr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 32.4.0-beta.35245b6b-54e5-5ca9-b645-8fe9cfe2f057"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
|
16136
16140
|
}
|
16137
16141
|
configure(t) {
|
16138
16142
|
gt.setHubUrl(t.hubUrl), gt.setServerUrl(t.serverUrl), gt.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 && jr(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Ut.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);
|
@@ -16609,7 +16613,7 @@ class bd {
|
|
16609
16613
|
return !this.activeIntegration && b[0].integrationProduct?.integration && (this.activeIntegration = Promise.resolve(b[0].integrationProduct.integration)), b.map((F, R) => ({
|
16610
16614
|
transaction: F,
|
16611
16615
|
workflowId: F.workflowId,
|
16612
|
-
readOnly: y.find((
|
16616
|
+
readOnly: y.find((N) => N.option.transactionId === F.id)?.option.readOnly ?? !1,
|
16613
16617
|
index: y[R].index
|
16614
16618
|
}));
|
16615
16619
|
}, i = async (y) => {
|
@@ -16652,7 +16656,7 @@ class bd {
|
|
16652
16656
|
])).flat(), h = [...new Set(u.map((y) => y.workflowId))].filter(
|
16653
16657
|
(y) => y !== void 0
|
16654
16658
|
), m = h.length > 0 ? await lr(h, e) : [], p = new Map(m.map((y) => [y.id, y])), g = k.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map(), f = u.map(async (y) => {
|
16655
|
-
const { transaction: S, workflowId: B, readOnly: b, index: F } = y, R = B ? p.get(B) : void 0,
|
16659
|
+
const { transaction: S, workflowId: B, readOnly: b, index: F } = y, R = B ? p.get(B) : void 0, N = t[F];
|
16656
16660
|
!g.get(S.id) && S.transactionOwnerId && g.set(S.id, S.transactionOwnerId);
|
16657
16661
|
const Z = g.get(S.id) || void 0, tt = new Gl({
|
16658
16662
|
onMutate: () => ({ context: { transactionOwnerId: Z, bundleOwnerId: e?.bundleOwnerId } }),
|
@@ -16660,25 +16664,25 @@ class bd {
|
|
16660
16664
|
}), rt = {
|
16661
16665
|
workflow: R,
|
16662
16666
|
transaction: S,
|
16663
|
-
singleVariantsRenderable:
|
16667
|
+
singleVariantsRenderable: N?.workflowConfiguration?.singleVariantsRenderable,
|
16664
16668
|
stateMutationFunc: b ? async () => {
|
16665
|
-
throw new
|
16669
|
+
throw new T("State mutation is forbidden in read only mode!");
|
16666
16670
|
} : async (K) => this.updateTransactionState({
|
16667
16671
|
...K,
|
16668
16672
|
context: { transactionOwnerId: Z, bundleOwnerId: e?.bundleOwnerId }
|
16669
16673
|
}),
|
16670
16674
|
graphQlClient: () => tt,
|
16671
16675
|
readOnly: b,
|
16672
|
-
isReloadedTransaction:
|
16676
|
+
isReloadedTransaction: N.type === "transaction"
|
16673
16677
|
};
|
16674
|
-
if (
|
16678
|
+
if (N.type === "transaction" && S.workflowState) {
|
16675
16679
|
const K = JSON.parse(S.workflowState);
|
16676
16680
|
await qa(K), rt.reloadedState = K;
|
16677
|
-
} else if (!b &&
|
16678
|
-
const K = JSON.parse(
|
16681
|
+
} else if (!b && N.workflowState) {
|
16682
|
+
const K = JSON.parse(N.workflowState);
|
16679
16683
|
await qa(K), rt.reloadedState = K;
|
16680
16684
|
}
|
16681
|
-
return rt.delayWorkflowStateSync = !0, { experienceOptions: rt, index: F, options:
|
16685
|
+
return rt.delayWorkflowStateSync = !0, { experienceOptions: rt, index: F, options: N };
|
16682
16686
|
}), C = await Promise.all(f);
|
16683
16687
|
k.setMap("transactionOwnerIds", g);
|
16684
16688
|
const I = C.sort((y, S) => y.index - S.index);
|
@@ -16959,7 +16963,7 @@ class Xl {
|
|
16959
16963
|
if (!r || !this.frameData)
|
16960
16964
|
return;
|
16961
16965
|
if (this.frameData.length !== t.length)
|
16962
|
-
throw new
|
16966
|
+
throw new T(
|
16963
16967
|
"Frame data and offsets are not the same length. This is a bug. Please report it."
|
16964
16968
|
);
|
16965
16969
|
if (!this.offsets.some((s, o) => !(t[o].x === s.x && t[o].y === s.y && t[o].zoom === s.zoom)) && !a) {
|
@@ -17003,8 +17007,8 @@ class Xl {
|
|
17003
17007
|
*/
|
17004
17008
|
updateFrameOffsets(t, e, a, r, i) {
|
17005
17009
|
if (!a || a.length === 0 || a.some((o) => !o))
|
17006
|
-
throw new
|
17007
|
-
if (!this.workflowManager) throw new
|
17010
|
+
throw new T("Frame data not set. This is a bug");
|
17011
|
+
if (!this.workflowManager) throw new T("No workflow manager set, cannot update offsets.");
|
17008
17012
|
const s = this.workflowManager.getCommandDispatcher();
|
17009
17013
|
this.targetElements.forEach((o, l) => {
|
17010
17014
|
s(
|
@@ -17908,7 +17912,7 @@ export {
|
|
17908
17912
|
Ko as TextStepHandle,
|
17909
17913
|
xl as Transform,
|
17910
17914
|
Fl as TransformCollection,
|
17911
|
-
|
17915
|
+
T as UnhandledBehaviorError,
|
17912
17916
|
Tr as UnitOfMeasurement,
|
17913
17917
|
hd as UpdateImageSourceCommand,
|
17914
17918
|
it as Variant,
|