@o3r/components 15.3.0-prerelease.15 → 15.3.0-prerelease.17
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/fesm2022/o3r-components-rules-engine.mjs +321 -334
- package/fesm2022/o3r-components-rules-engine.mjs.map +1 -1
- package/fesm2022/o3r-components.mjs +1495 -1638
- package/fesm2022/o3r-components.mjs.map +1 -1
- package/package.json +12 -12
- package/types/o3r-components-rules-engine.d.ts +60 -66
- package/types/o3r-components-rules-engine.d.ts.map +1 -1
- package/types/o3r-components.d.ts +635 -641
- package/types/o3r-components.d.ts.map +1 -1
|
@@ -1,337 +1,324 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { takeUntilDestroyed } from
|
|
4
|
-
import { Store, select } from
|
|
5
|
-
import { DynamicContentService } from
|
|
6
|
-
import { LoggerService } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import * as i1 from
|
|
10
|
-
import { Actions, createEffect, ofType,
|
|
11
|
-
import { fromApiEffectSwitchMapById } from
|
|
12
|
-
import { RulesEngineRunnerService } from
|
|
13
|
-
import { JSONPath } from
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
],
|
|
315
|
-
providers: [
|
|
316
|
-
PlaceholderRulesEngineActionHandler
|
|
317
|
-
]
|
|
318
|
-
}]
|
|
319
|
-
}] });
|
|
320
|
-
/**
|
|
321
|
-
* Provide placeholder rules engine action handler.
|
|
322
|
-
*/
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injectable, Injector, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
|
|
3
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
4
|
+
import { Store, select } from "@ngrx/store";
|
|
5
|
+
import { DynamicContentService } from "@o3r/dynamic-content";
|
|
6
|
+
import { LoggerService } from "@o3r/logger";
|
|
7
|
+
import { EMPTY, Subject, combineLatest, distinctUntilChanged, firstValueFrom, from, map, of, startWith, switchMap, withLatestFrom } from "rxjs";
|
|
8
|
+
import { PlaceholderRequestStoreModule, PlaceholderTemplateStoreModule, cancelPlaceholderRequest, deletePlaceholderTemplateEntity, failPlaceholderRequestEntity, providePlaceholderRequestStore, providePlaceholderTemplateStore, selectPlaceholderRequestEntities, selectPlaceholderRequestEntityUsage, selectPlaceholderTemplateEntities, setPlaceholderRequestEntityFromUrl, setPlaceholderTemplateEntity, updatePlaceholderRequestEntity } from "@o3r/components";
|
|
9
|
+
import * as i1 from "@ngrx/effects";
|
|
10
|
+
import { Actions, EffectsModule, createEffect, ofType, provideEffects } from "@ngrx/effects";
|
|
11
|
+
import { fromApiEffectSwitchMapById } from "@o3r/core";
|
|
12
|
+
import { RulesEngineRunnerService } from "@o3r/rules-engine";
|
|
13
|
+
import { JSONPath } from "jsonpath-plus";
|
|
14
|
+
import { distinctUntilChanged as distinctUntilChanged$1, map as map$1, switchMap as switchMap$1, take } from "rxjs/operators";
|
|
15
|
+
const RULES_ENGINE_PLACEHOLDER_UPDATE_ACTION_TYPE = "UPDATE_PLACEHOLDER";
|
|
16
|
+
var PlaceholderRulesEngineActionHandler = class PlaceholderRulesEngineActionHandler {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.logger = inject(LoggerService);
|
|
19
|
+
this.injector = inject(Injector);
|
|
20
|
+
this.translationService = import("@o3r/transloco").then((mod) => this.injector.get(mod.LocalizationService, null)).catch(() => null).then((service) => service ?? import("@o3r/localization").then((mod) => this.injector.get(mod.LocalizationService, null) ?? void 0).catch(() => void 0));
|
|
21
|
+
this.placeholdersActions$ = new Subject();
|
|
22
|
+
this.supportingActions = [RULES_ENGINE_PLACEHOLDER_UPDATE_ACTION_TYPE];
|
|
23
|
+
const store = inject(Store);
|
|
24
|
+
const lang$ = from(this.translationService).pipe(switchMap((translationService) => {
|
|
25
|
+
if (!translationService) return of(null);
|
|
26
|
+
const translateService = translationService.getTranslateService();
|
|
27
|
+
return (translateService.onLangChange ? translateService.onLangChange.pipe(map(({ lang }) => lang)) : translateService.langChanges$).pipe(startWith(translationService.getCurrentLanguage()), distinctUntilChanged());
|
|
28
|
+
}));
|
|
29
|
+
combineLatest([lang$, this.placeholdersActions$.pipe(distinctUntilChanged((prev, next) => JSON.stringify(prev) === JSON.stringify(next)))]).pipe(withLatestFrom(combineLatest([store.pipe(select(selectPlaceholderTemplateEntities)), store.pipe(select(selectPlaceholderRequestEntities))])), map(([langAndTemplatesUrls, storedPlaceholdersAndRequests]) => {
|
|
30
|
+
const [lang, placeholderActions] = langAndTemplatesUrls;
|
|
31
|
+
const storedPlaceholders = storedPlaceholdersAndRequests[0] || {};
|
|
32
|
+
const storedPlaceholderRequests = storedPlaceholdersAndRequests[1] || {};
|
|
33
|
+
const placeholderNewRequests = [];
|
|
34
|
+
const usedUrls = {};
|
|
35
|
+
const placeholdersTemplates = placeholderActions.reduce((acc, placeholderAction) => {
|
|
36
|
+
const placeholdersTemplateUrl = {
|
|
37
|
+
rawUrl: placeholderAction.templateUrl,
|
|
38
|
+
priority: placeholderAction.priority
|
|
39
|
+
};
|
|
40
|
+
if (acc[placeholderAction.placeholderId]) acc[placeholderAction.placeholderId].push(placeholdersTemplateUrl);
|
|
41
|
+
else acc[placeholderAction.placeholderId] = [placeholdersTemplateUrl];
|
|
42
|
+
const resolvedUrl = this.resolveUrlWithLang(placeholderAction.templateUrl, lang);
|
|
43
|
+
if (!usedUrls[placeholderAction.templateUrl] && (!storedPlaceholderRequests[placeholderAction.templateUrl] || storedPlaceholderRequests[placeholderAction.templateUrl].resolvedUrl !== resolvedUrl)) placeholderNewRequests.push({
|
|
44
|
+
rawUrl: placeholderAction.templateUrl,
|
|
45
|
+
resolvedUrl: this.resolveUrlWithLang(placeholderAction.templateUrl, lang)
|
|
46
|
+
});
|
|
47
|
+
usedUrls[placeholderAction.templateUrl] = true;
|
|
48
|
+
return acc;
|
|
49
|
+
}, {});
|
|
50
|
+
const placeholderRequestsToDisable = [];
|
|
51
|
+
const placeholderRequestsToEnable = [];
|
|
52
|
+
Object.keys(storedPlaceholderRequests).forEach((storedPlaceholderRequestRawUrl) => {
|
|
53
|
+
const usedFromEngineIteration = usedUrls[storedPlaceholderRequestRawUrl];
|
|
54
|
+
const usedFromStore = storedPlaceholderRequests && storedPlaceholderRequests[storedPlaceholderRequestRawUrl] ? storedPlaceholderRequests[storedPlaceholderRequestRawUrl].used : false;
|
|
55
|
+
if (!usedFromEngineIteration && usedFromStore) placeholderRequestsToDisable.push(storedPlaceholderRequestRawUrl);
|
|
56
|
+
else if (usedFromEngineIteration && !usedFromStore) placeholderRequestsToEnable.push(storedPlaceholderRequestRawUrl);
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
placeholdersTemplatesToBeCleanedUp: Object.keys(storedPlaceholders).filter((placeholderId) => !placeholdersTemplates[placeholderId]),
|
|
60
|
+
placeholderRequestsToDisable,
|
|
61
|
+
placeholderRequestsToEnable,
|
|
62
|
+
placeholdersTemplatesToBeSet: Object.keys(placeholdersTemplates).reduce((changedPlaceholderTemplates, placeholderTemplateId) => {
|
|
63
|
+
if (!storedPlaceholders[placeholderTemplateId] || !(JSON.stringify(storedPlaceholders[placeholderTemplateId].urlsWithPriority) === JSON.stringify(placeholdersTemplates[placeholderTemplateId]))) changedPlaceholderTemplates.push({
|
|
64
|
+
id: placeholderTemplateId,
|
|
65
|
+
urlsWithPriority: placeholdersTemplates[placeholderTemplateId]
|
|
66
|
+
});
|
|
67
|
+
return changedPlaceholderTemplates;
|
|
68
|
+
}, []),
|
|
69
|
+
placeholderNewRequests
|
|
70
|
+
};
|
|
71
|
+
})).pipe(takeUntilDestroyed()).subscribe((placeholdersUpdates) => {
|
|
72
|
+
placeholdersUpdates.placeholdersTemplatesToBeCleanedUp.forEach((placeholderId) => store.dispatch(deletePlaceholderTemplateEntity({ id: placeholderId })));
|
|
73
|
+
placeholdersUpdates.placeholdersTemplatesToBeSet.forEach((placeholdersTemplateToBeSet) => {
|
|
74
|
+
store.dispatch(setPlaceholderTemplateEntity({ entity: placeholdersTemplateToBeSet }));
|
|
75
|
+
});
|
|
76
|
+
placeholdersUpdates.placeholderRequestsToDisable.forEach((placeholderRequestToDisable) => {
|
|
77
|
+
store.dispatch(updatePlaceholderRequestEntity({ entity: {
|
|
78
|
+
id: placeholderRequestToDisable,
|
|
79
|
+
used: false
|
|
80
|
+
} }));
|
|
81
|
+
});
|
|
82
|
+
placeholdersUpdates.placeholderRequestsToEnable.forEach((placeholderRequestToEnable) => {
|
|
83
|
+
store.dispatch(updatePlaceholderRequestEntity({ entity: {
|
|
84
|
+
id: placeholderRequestToEnable,
|
|
85
|
+
used: true
|
|
86
|
+
} }));
|
|
87
|
+
});
|
|
88
|
+
placeholdersUpdates.placeholderNewRequests.forEach((placeholderNewRequest) => {
|
|
89
|
+
store.dispatch(setPlaceholderRequestEntityFromUrl({
|
|
90
|
+
resolvedUrl: placeholderNewRequest.resolvedUrl,
|
|
91
|
+
id: placeholderNewRequest.rawUrl,
|
|
92
|
+
call: this.retrieveTemplate(placeholderNewRequest.resolvedUrl)
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
resolveUrlWithLang(url, language) {
|
|
98
|
+
if (!language && url.includes("[LANGUAGE]")) this.logger.warn(`Missing language when trying to resolve ${url}`);
|
|
99
|
+
return language ? url.replace(/\[LANGUAGE]/g, language) : url;
|
|
100
|
+
}
|
|
101
|
+
async retrieveTemplate(url) {
|
|
102
|
+
const resolvedUrl$ = this.injector.get(DynamicContentService, null, { optional: true })?.getContentPathStream(url) || of(url);
|
|
103
|
+
const fullUrl = await firstValueFrom(resolvedUrl$);
|
|
104
|
+
return fetch(fullUrl).then((response) => response.json());
|
|
105
|
+
}
|
|
106
|
+
executeActions(actions) {
|
|
107
|
+
const templates = actions.map((action) => ({
|
|
108
|
+
placeholderId: action.placeholderId,
|
|
109
|
+
templateUrl: action.value,
|
|
110
|
+
priority: action.priority || 0
|
|
111
|
+
}));
|
|
112
|
+
this.placeholdersActions$.next(templates);
|
|
113
|
+
}
|
|
114
|
+
static {
|
|
115
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
116
|
+
minVersion: "12.0.0",
|
|
117
|
+
version: "22.2.3",
|
|
118
|
+
ngImport: i0,
|
|
119
|
+
type: PlaceholderRulesEngineActionHandler,
|
|
120
|
+
deps: [],
|
|
121
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
static {
|
|
125
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
126
|
+
minVersion: "12.0.0",
|
|
127
|
+
version: "22.2.3",
|
|
128
|
+
ngImport: i0,
|
|
129
|
+
type: PlaceholderRulesEngineActionHandler
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
134
|
+
minVersion: "12.0.0",
|
|
135
|
+
version: "22.2.3",
|
|
136
|
+
ngImport: i0,
|
|
137
|
+
type: PlaceholderRulesEngineActionHandler,
|
|
138
|
+
decorators: [{ type: Injectable }],
|
|
139
|
+
ctorParameters: () => []
|
|
140
|
+
});
|
|
141
|
+
var PlaceholderTemplateResponseEffect = class PlaceholderTemplateResponseEffect {
|
|
142
|
+
constructor() {
|
|
143
|
+
this.actions$ = inject(Actions);
|
|
144
|
+
this.store = inject(Store);
|
|
145
|
+
this.rulesEngineService = inject(RulesEngineRunnerService, { optional: true });
|
|
146
|
+
this.dynamicContentService = inject(DynamicContentService, { optional: true });
|
|
147
|
+
this.injector = inject(Injector);
|
|
148
|
+
this.translationService = import("@o3r/transloco").then((mod) => this.injector.get(mod.LocalizationService, null)).catch(() => null).then((service) => service ?? import("@o3r/localization").then((mod) => this.injector.get(mod.LocalizationService, null) ?? void 0).catch(() => void 0));
|
|
149
|
+
this.setPlaceholderRequestEntityFromUrl$ = createEffect(() => this.actions$.pipe(ofType(setPlaceholderRequestEntityFromUrl), fromApiEffectSwitchMapById((templateResponse, action) => {
|
|
150
|
+
const facts = templateResponse.vars ? Object.entries(templateResponse.vars).filter(([, variable]) => variable.type === "fact") : [];
|
|
151
|
+
const factsStreamsList = this.rulesEngineService ? facts.map(([varName, fact]) => this.rulesEngineService.engine.retrieveOrCreateFactStream(fact.value).pipe(map$1((factValue) => ({
|
|
152
|
+
varName,
|
|
153
|
+
factName: fact.value,
|
|
154
|
+
factValue: fact.path && factValue ? JSONPath({
|
|
155
|
+
wrap: false,
|
|
156
|
+
json: factValue,
|
|
157
|
+
path: fact.path
|
|
158
|
+
}) : factValue
|
|
159
|
+
})), distinctUntilChanged$1((previous, current) => previous.factValue === current.factValue))) : [];
|
|
160
|
+
const factsStreamsList$ = factsStreamsList.length > 0 ? combineLatest(factsStreamsList) : of([]);
|
|
161
|
+
return combineLatest([factsStreamsList$, this.store.select(selectPlaceholderRequestEntityUsage(action.id)).pipe(distinctUntilChanged$1())]).pipe(switchMap$1(([factsUsedInTemplate, placeholderRequestUsage]) => {
|
|
162
|
+
if (!placeholderRequestUsage) return EMPTY;
|
|
163
|
+
return this.getRenderedHTML$(templateResponse.template, templateResponse.vars, factsUsedInTemplate).pipe(map$1(({ renderedTemplate, unknownTypeFound }) => updatePlaceholderRequestEntity({
|
|
164
|
+
entity: {
|
|
165
|
+
...templateResponse,
|
|
166
|
+
resolvedUrl: action.resolvedUrl,
|
|
167
|
+
id: action.id,
|
|
168
|
+
renderedTemplate,
|
|
169
|
+
unknownTypeFound
|
|
170
|
+
},
|
|
171
|
+
requestId: action.requestId
|
|
172
|
+
})));
|
|
173
|
+
}));
|
|
174
|
+
}, (error, action) => of(failPlaceholderRequestEntity({
|
|
175
|
+
ids: [action.id],
|
|
176
|
+
error,
|
|
177
|
+
requestId: action.requestId
|
|
178
|
+
})), (requestIdPayload, action) => cancelPlaceholderRequest({
|
|
179
|
+
...requestIdPayload,
|
|
180
|
+
id: action.id
|
|
181
|
+
}))));
|
|
182
|
+
}
|
|
183
|
+
getRenderedHTML$(template, vars, facts) {
|
|
184
|
+
let unknownTypeFound = false;
|
|
185
|
+
const factMapFromVars = (facts || []).reduce((mapping, fact) => {
|
|
186
|
+
mapping[fact.varName] = fact.factValue;
|
|
187
|
+
return mapping;
|
|
188
|
+
}, {});
|
|
189
|
+
const replacements$ = [];
|
|
190
|
+
if (vars && template) {
|
|
191
|
+
for (const varName in vars) if (Object.prototype.hasOwnProperty.call(vars, varName)) {
|
|
192
|
+
const ejsVar = new RegExp(`<%=\\s*${varName}\\s*%>`, "g");
|
|
193
|
+
switch (vars[varName].type) {
|
|
194
|
+
case "relativeUrl":
|
|
195
|
+
replacements$.push(this.dynamicContentService?.getMediaPathStream(vars[varName].value).pipe(take(1), map$1((value) => ({
|
|
196
|
+
ejsVar,
|
|
197
|
+
value
|
|
198
|
+
}))) || of({
|
|
199
|
+
ejsVar,
|
|
200
|
+
value: vars[varName].value
|
|
201
|
+
}));
|
|
202
|
+
break;
|
|
203
|
+
case "fullUrl":
|
|
204
|
+
template = template.replace(ejsVar, vars[varName].value);
|
|
205
|
+
break;
|
|
206
|
+
case "fact":
|
|
207
|
+
template = template.replace(ejsVar, factMapFromVars[varName] ?? "");
|
|
208
|
+
break;
|
|
209
|
+
case "localisation": {
|
|
210
|
+
const linkedParams = Object.entries(vars[varName].parameters || {}).reduce((acc, [paramKey, paramValue]) => {
|
|
211
|
+
acc[paramKey] = factMapFromVars[paramValue];
|
|
212
|
+
return acc;
|
|
213
|
+
}, {});
|
|
214
|
+
replacements$.push(from(this.translationService).pipe(switchMap$1((translationService) => translationService ? translationService.translate(vars[varName].value, linkedParams).pipe(map$1((value) => value ? {
|
|
215
|
+
ejsVar,
|
|
216
|
+
value
|
|
217
|
+
} : null)) : of(null))));
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
default: unknownTypeFound = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return replacements$.length > 0 && !!template ? combineLatest(replacements$).pipe(map$1((replacements) => ({
|
|
225
|
+
renderedTemplate: replacements.reduce((acc, replacement) => replacement ? acc.replace(replacement.ejsVar, replacement.value) : acc, template),
|
|
226
|
+
unknownTypeFound
|
|
227
|
+
}))) : of({
|
|
228
|
+
renderedTemplate: template,
|
|
229
|
+
unknownTypeFound
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
static {
|
|
233
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
234
|
+
minVersion: "12.0.0",
|
|
235
|
+
version: "22.2.3",
|
|
236
|
+
ngImport: i0,
|
|
237
|
+
type: PlaceholderTemplateResponseEffect,
|
|
238
|
+
deps: [],
|
|
239
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
static {
|
|
243
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
244
|
+
minVersion: "12.0.0",
|
|
245
|
+
version: "22.2.3",
|
|
246
|
+
ngImport: i0,
|
|
247
|
+
type: PlaceholderTemplateResponseEffect
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
252
|
+
minVersion: "12.0.0",
|
|
253
|
+
version: "22.2.3",
|
|
254
|
+
ngImport: i0,
|
|
255
|
+
type: PlaceholderTemplateResponseEffect,
|
|
256
|
+
decorators: [{ type: Injectable }]
|
|
257
|
+
});
|
|
258
|
+
var PlaceholderRulesEngineActionModule = class PlaceholderRulesEngineActionModule {
|
|
259
|
+
static {
|
|
260
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
261
|
+
minVersion: "12.0.0",
|
|
262
|
+
version: "22.2.3",
|
|
263
|
+
ngImport: i0,
|
|
264
|
+
type: PlaceholderRulesEngineActionModule,
|
|
265
|
+
deps: [],
|
|
266
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
static {
|
|
270
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
271
|
+
minVersion: "14.0.0",
|
|
272
|
+
version: "22.2.3",
|
|
273
|
+
ngImport: i0,
|
|
274
|
+
type: PlaceholderRulesEngineActionModule,
|
|
275
|
+
imports: [
|
|
276
|
+
i1.EffectsFeatureModule,
|
|
277
|
+
PlaceholderRequestStoreModule,
|
|
278
|
+
PlaceholderTemplateStoreModule
|
|
279
|
+
]
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
static {
|
|
283
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
284
|
+
minVersion: "12.0.0",
|
|
285
|
+
version: "22.2.3",
|
|
286
|
+
ngImport: i0,
|
|
287
|
+
type: PlaceholderRulesEngineActionModule,
|
|
288
|
+
providers: [PlaceholderRulesEngineActionHandler],
|
|
289
|
+
imports: [
|
|
290
|
+
EffectsModule.forFeature([PlaceholderTemplateResponseEffect]),
|
|
291
|
+
PlaceholderRequestStoreModule,
|
|
292
|
+
PlaceholderTemplateStoreModule
|
|
293
|
+
]
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
298
|
+
minVersion: "12.0.0",
|
|
299
|
+
version: "22.2.3",
|
|
300
|
+
ngImport: i0,
|
|
301
|
+
type: PlaceholderRulesEngineActionModule,
|
|
302
|
+
decorators: [{
|
|
303
|
+
type: NgModule,
|
|
304
|
+
args: [{
|
|
305
|
+
imports: [
|
|
306
|
+
EffectsModule.forFeature([PlaceholderTemplateResponseEffect]),
|
|
307
|
+
PlaceholderRequestStoreModule,
|
|
308
|
+
PlaceholderTemplateStoreModule
|
|
309
|
+
],
|
|
310
|
+
providers: [PlaceholderRulesEngineActionHandler]
|
|
311
|
+
}]
|
|
312
|
+
}]
|
|
313
|
+
});
|
|
323
314
|
function providePlaceholderRulesEngineAction() {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
315
|
+
return makeEnvironmentProviders([
|
|
316
|
+
providePlaceholderRequestStore(),
|
|
317
|
+
providePlaceholderTemplateStore(),
|
|
318
|
+
provideEffects(PlaceholderTemplateResponseEffect),
|
|
319
|
+
PlaceholderRulesEngineActionHandler
|
|
320
|
+
]);
|
|
330
321
|
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Generated bundle index. Do not edit.
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
322
|
export { PlaceholderRulesEngineActionHandler, PlaceholderRulesEngineActionModule, RULES_ENGINE_PLACEHOLDER_UPDATE_ACTION_TYPE, providePlaceholderRulesEngineAction };
|
|
337
|
-
|
|
323
|
+
|
|
324
|
+
//# sourceMappingURL=o3r-components-rules-engine.mjs.map
|