@veloceapps/sdk 8.0.0-135 → 8.0.0-137
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/core/modules/configuration/services/configuration-state.service.d.ts +3 -1
- package/core/services/flow-info.service.d.ts +1 -0
- package/core/services/flow-state.service.d.ts +1 -0
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +29 -13
- package/esm2020/core/services/flow-info.service.mjs +4 -1
- package/esm2020/core/services/flow-state.service.mjs +16 -10
- package/esm2020/src/pages/product/product.component.mjs +2 -2
- package/esm2020/src/services/flow-router.service.mjs +3 -3
- package/esm2020/src/services/flow.service.mjs +7 -6
- package/fesm2015/veloceapps-sdk-core.mjs +50 -24
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +9 -8
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +45 -20
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +9 -8
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/services/flow.service.d.ts +1 -1
|
@@ -203,6 +203,9 @@ class FlowInfoService {
|
|
|
203
203
|
get isLegacy() {
|
|
204
204
|
return !!this.flow && this.flow?.properties.stateful == null;
|
|
205
205
|
}
|
|
206
|
+
get isStateful() {
|
|
207
|
+
return !!this.flow?.properties.stateful;
|
|
208
|
+
}
|
|
206
209
|
constructor(flowsApiService, templatesApiService, customizationService) {
|
|
207
210
|
this.flowsApiService = flowsApiService;
|
|
208
211
|
this.templatesApiService = templatesApiService;
|
|
@@ -803,6 +806,7 @@ class FlowStateService {
|
|
|
803
806
|
this.toastService = toastService;
|
|
804
807
|
this.customizationService = customizationService;
|
|
805
808
|
this.NOT_INITIALIZED = Symbol();
|
|
809
|
+
this.executedFunctions = {};
|
|
806
810
|
this._hasStatefulUnsavedChanges = false;
|
|
807
811
|
this.stateId$ = new BehaviorSubject(null);
|
|
808
812
|
this.processors = {};
|
|
@@ -1160,27 +1164,32 @@ class FlowStateService {
|
|
|
1160
1164
|
return forkJoin(owners$).pipe(map$1(noop));
|
|
1161
1165
|
}
|
|
1162
1166
|
executeActionScript(request, executable) {
|
|
1163
|
-
const
|
|
1164
|
-
if (!script) {
|
|
1167
|
+
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
|
1168
|
+
if (!configurationProcessor?.script) {
|
|
1165
1169
|
const scope = this.getScopeByOwnerId(executable.ownerId);
|
|
1166
1170
|
const scopeText = scope ? ` in ${scope}` : '';
|
|
1167
1171
|
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
|
1168
1172
|
}
|
|
1169
|
-
return this.executeProcessorScript(request,
|
|
1173
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
|
1170
1174
|
}
|
|
1171
1175
|
executeSelectorScript(request, executable) {
|
|
1172
|
-
const
|
|
1173
|
-
if (!script) {
|
|
1176
|
+
const configurationProcessor = this.processors[executable.ownerId]?.[executable.apiName];
|
|
1177
|
+
if (!configurationProcessor?.script) {
|
|
1174
1178
|
const scope = this.getScopeByOwnerId(executable.ownerId);
|
|
1175
1179
|
const scopeText = scope ? ` in ${scope}` : '';
|
|
1176
1180
|
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
|
1177
1181
|
}
|
|
1178
|
-
return this.executeProcessorScript(request,
|
|
1182
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
|
1179
1183
|
}
|
|
1180
|
-
executeProcessorScript(request,
|
|
1181
|
-
|
|
1184
|
+
executeProcessorScript(request, configurationProcessor, inputData) {
|
|
1185
|
+
let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
|
|
1186
|
+
if (!functionToExecute) {
|
|
1187
|
+
functionToExecute = new Function(`${configurationProcessor.script}\nreturn transform;`)();
|
|
1188
|
+
this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
|
|
1189
|
+
}
|
|
1190
|
+
return functionToExecute({
|
|
1182
1191
|
request,
|
|
1183
|
-
inputData
|
|
1192
|
+
inputData,
|
|
1184
1193
|
});
|
|
1185
1194
|
}
|
|
1186
1195
|
generateRequestId(scope, selectorName, inputData) {
|
|
@@ -2162,10 +2171,12 @@ class ConfigurationStateService {
|
|
|
2162
2171
|
this.flowStateApiService = flowStateApiService;
|
|
2163
2172
|
this.quoteApiService = quoteApiService;
|
|
2164
2173
|
this.NOT_INITIALIZED = Symbol();
|
|
2174
|
+
this.executedFunctions = {};
|
|
2165
2175
|
this.stateId = null;
|
|
2166
2176
|
this.ownerId = '';
|
|
2167
2177
|
this.subscriptions = {};
|
|
2168
2178
|
this.isInitialized$ = new BehaviorSubject(false);
|
|
2179
|
+
this.canceledConfiguration$ = new Subject();
|
|
2169
2180
|
}
|
|
2170
2181
|
init$() {
|
|
2171
2182
|
let request$;
|
|
@@ -2175,7 +2186,10 @@ class ConfigurationStateService {
|
|
|
2175
2186
|
else {
|
|
2176
2187
|
request$ = this.initStateless$();
|
|
2177
2188
|
}
|
|
2178
|
-
return request$.pipe(finalize(() =>
|
|
2189
|
+
return request$.pipe(finalize(() => {
|
|
2190
|
+
this.isInitialized$.next(true);
|
|
2191
|
+
this.canceledConfiguration$ = new Subject();
|
|
2192
|
+
}));
|
|
2179
2193
|
}
|
|
2180
2194
|
cleanup() {
|
|
2181
2195
|
this.stateId = null;
|
|
@@ -2244,10 +2258,13 @@ class ConfigurationStateService {
|
|
|
2244
2258
|
}
|
|
2245
2259
|
}
|
|
2246
2260
|
return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
|
|
2261
|
+
if (!this.subscriptions[requestId]) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2247
2264
|
if (!this.subscriptions[requestId].data$.observed) {
|
|
2248
2265
|
delete this.subscriptions[requestId];
|
|
2249
2266
|
}
|
|
2250
|
-
}));
|
|
2267
|
+
}), takeUntil(this.canceledConfiguration$));
|
|
2251
2268
|
}
|
|
2252
2269
|
saveConfiguration(quoteId, flow) {
|
|
2253
2270
|
if (this.isStatefulConfiguration) {
|
|
@@ -2290,6 +2307,9 @@ class ConfigurationStateService {
|
|
|
2290
2307
|
if (!this.isInitialized$.value) {
|
|
2291
2308
|
return of(undefined);
|
|
2292
2309
|
}
|
|
2310
|
+
this.canceledConfiguration$.next();
|
|
2311
|
+
this.canceledConfiguration$.complete();
|
|
2312
|
+
this.subscriptions = {};
|
|
2293
2313
|
this.isInitialized$.next(false);
|
|
2294
2314
|
if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
|
|
2295
2315
|
return of(undefined);
|
|
@@ -2373,24 +2393,29 @@ class ConfigurationStateService {
|
|
|
2373
2393
|
}
|
|
2374
2394
|
executeActionScript(request, processor) {
|
|
2375
2395
|
const { actions } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
|
|
2376
|
-
const
|
|
2377
|
-
if (!script) {
|
|
2396
|
+
const configurationProcessor = actions?.find(action => action.apiName === processor.apiName);
|
|
2397
|
+
if (!configurationProcessor?.script) {
|
|
2378
2398
|
return request;
|
|
2379
2399
|
}
|
|
2380
|
-
return this.executeProcessorScript(request,
|
|
2400
|
+
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
|
2381
2401
|
}
|
|
2382
2402
|
executeSelectorScript(request, processor) {
|
|
2383
2403
|
const { selectors } = this.configurationRuntimeService.runtimeContext?.uiDefinitionContainer ?? {};
|
|
2384
|
-
const
|
|
2385
|
-
if (!script) {
|
|
2404
|
+
const configurationProcessor = selectors?.find(selector => selector.apiName === processor.apiName);
|
|
2405
|
+
if (!configurationProcessor?.script) {
|
|
2386
2406
|
return null;
|
|
2387
2407
|
}
|
|
2388
|
-
return this.executeProcessorScript(request,
|
|
2408
|
+
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
|
2389
2409
|
}
|
|
2390
|
-
executeProcessorScript(request,
|
|
2391
|
-
|
|
2410
|
+
executeProcessorScript(request, configurationProcessor, inputData) {
|
|
2411
|
+
let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
|
|
2412
|
+
if (!functionToExecute) {
|
|
2413
|
+
functionToExecute = new Function(`${configurationProcessor.script}\nreturn transform;`)();
|
|
2414
|
+
this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
|
|
2415
|
+
}
|
|
2416
|
+
return functionToExecute({
|
|
2392
2417
|
request,
|
|
2393
|
-
inputData
|
|
2418
|
+
inputData,
|
|
2394
2419
|
});
|
|
2395
2420
|
}
|
|
2396
2421
|
}
|