@epistola.app/valtimo-plugin 0.0.1 → 0.2.0
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/package.json +9 -13
- package/ng-package.json +0 -17
- package/src/lib/assets/epistola-logo.ts +0 -4
- package/src/lib/assets/index.ts +0 -1
- package/src/lib/components/check-job-status-configuration/check-job-status-configuration.component.html +0 -51
- package/src/lib/components/check-job-status-configuration/check-job-status-configuration.component.scss +0 -1
- package/src/lib/components/check-job-status-configuration/check-job-status-configuration.component.ts +0 -71
- package/src/lib/components/data-mapping-tree/data-mapping-tree.component.html +0 -23
- package/src/lib/components/data-mapping-tree/data-mapping-tree.component.scss +0 -38
- package/src/lib/components/data-mapping-tree/data-mapping-tree.component.ts +0 -124
- package/src/lib/components/download-document-configuration/download-document-configuration.component.html +0 -29
- package/src/lib/components/download-document-configuration/download-document-configuration.component.scss +0 -1
- package/src/lib/components/download-document-configuration/download-document-configuration.component.ts +0 -71
- package/src/lib/components/epistola-configuration/epistola-configuration.component.html +0 -74
- package/src/lib/components/epistola-configuration/epistola-configuration.component.scss +0 -1
- package/src/lib/components/epistola-configuration/epistola-configuration.component.ts +0 -96
- package/src/lib/components/epistola-download/epistola-download.component.ts +0 -79
- package/src/lib/components/epistola-download/epistola-download.formio.ts +0 -19
- package/src/lib/components/field-tree/field-tree.component.html +0 -192
- package/src/lib/components/field-tree/field-tree.component.scss +0 -255
- package/src/lib/components/field-tree/field-tree.component.ts +0 -321
- package/src/lib/components/generate-document-configuration/generate-document-configuration.component.html +0 -182
- package/src/lib/components/generate-document-configuration/generate-document-configuration.component.scss +0 -150
- package/src/lib/components/generate-document-configuration/generate-document-configuration.component.ts +0 -422
- package/src/lib/epistola.module.ts +0 -50
- package/src/lib/epistola.specification.ts +0 -208
- package/src/lib/models/config.ts +0 -53
- package/src/lib/models/index.ts +0 -2
- package/src/lib/models/template.ts +0 -70
- package/src/lib/services/epistola-plugin.service.ts +0 -82
- package/src/lib/services/index.ts +0 -1
- package/src/public_api.ts +0 -16
- package/tsconfig.lib.json +0 -21
- /package/{dist/fesm2022 → fesm2022}/epistola.app-valtimo-plugin.mjs +0 -0
- /package/{dist/fesm2022 → fesm2022}/epistola.app-valtimo-plugin.mjs.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/lib → lib}/assets/epistola-logo.d.ts +0 -0
- /package/{dist/lib → lib}/assets/index.d.ts +0 -0
- /package/{dist/lib → lib}/components/check-job-status-configuration/check-job-status-configuration.component.d.ts +0 -0
- /package/{dist/lib → lib}/components/data-mapping-tree/data-mapping-tree.component.d.ts +0 -0
- /package/{dist/lib → lib}/components/download-document-configuration/download-document-configuration.component.d.ts +0 -0
- /package/{dist/lib → lib}/components/epistola-configuration/epistola-configuration.component.d.ts +0 -0
- /package/{dist/lib → lib}/components/epistola-download/epistola-download.component.d.ts +0 -0
- /package/{dist/lib → lib}/components/epistola-download/epistola-download.formio.d.ts +0 -0
- /package/{dist/lib → lib}/components/field-tree/field-tree.component.d.ts +0 -0
- /package/{dist/lib → lib}/components/generate-document-configuration/generate-document-configuration.component.d.ts +0 -0
- /package/{dist/lib → lib}/epistola.module.d.ts +0 -0
- /package/{dist/lib → lib}/epistola.specification.d.ts +0 -0
- /package/{dist/lib → lib}/models/config.d.ts +0 -0
- /package/{dist/lib → lib}/models/index.d.ts +0 -0
- /package/{dist/lib → lib}/models/template.d.ts +0 -0
- /package/{dist/lib → lib}/services/epistola-plugin.service.d.ts +0 -0
- /package/{dist/lib → lib}/services/index.d.ts +0 -0
- /package/{dist/public_api.d.ts → public_api.d.ts} +0 -0
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
|
|
2
|
-
import {CommonModule} from '@angular/common';
|
|
3
|
-
import {FormsModule} from '@angular/forms';
|
|
4
|
-
import {
|
|
5
|
-
FunctionConfigurationComponent,
|
|
6
|
-
PluginConfigurationData,
|
|
7
|
-
PluginTranslatePipeModule
|
|
8
|
-
} from '@valtimo/plugin';
|
|
9
|
-
import {FormModule, FormOutput, InputModule, SelectItem, SelectModule} from '@valtimo/components';
|
|
10
|
-
import {CaseManagementParams, ManagementContext} from '@valtimo/shared';
|
|
11
|
-
import {ProcessLinkStateService} from '@valtimo/process-link';
|
|
12
|
-
import {BehaviorSubject, combineLatest, merge, Observable, of, Subject, Subscription} from 'rxjs';
|
|
13
|
-
import {catchError, filter, map, take, takeUntil} from 'rxjs/operators';
|
|
14
|
-
import {GenerateDocumentConfig, TemplateField, VariantInfo} from '../../models';
|
|
15
|
-
import {EpistolaPluginService} from '../../services';
|
|
16
|
-
import {DataMappingTreeComponent} from '../data-mapping-tree/data-mapping-tree.component';
|
|
17
|
-
|
|
18
|
-
export type VariantSelectionMode = 'explicit' | 'attributes';
|
|
19
|
-
|
|
20
|
-
@Component({
|
|
21
|
-
selector: 'epistola-generate-document-configuration',
|
|
22
|
-
templateUrl: './generate-document-configuration.component.html',
|
|
23
|
-
styleUrls: ['./generate-document-configuration.component.scss'],
|
|
24
|
-
standalone: true,
|
|
25
|
-
imports: [
|
|
26
|
-
CommonModule,
|
|
27
|
-
FormsModule,
|
|
28
|
-
PluginTranslatePipeModule,
|
|
29
|
-
FormModule,
|
|
30
|
-
InputModule,
|
|
31
|
-
SelectModule,
|
|
32
|
-
DataMappingTreeComponent
|
|
33
|
-
]
|
|
34
|
-
})
|
|
35
|
-
export class GenerateDocumentConfigurationComponent
|
|
36
|
-
implements FunctionConfigurationComponent, OnInit, OnDestroy
|
|
37
|
-
{
|
|
38
|
-
// Required inputs from FunctionConfigurationComponent
|
|
39
|
-
@Input() save$!: Observable<void>;
|
|
40
|
-
@Input() disabled$!: Observable<boolean>;
|
|
41
|
-
@Input() pluginId!: string;
|
|
42
|
-
@Input() prefillConfiguration$!: Observable<GenerateDocumentConfig>;
|
|
43
|
-
|
|
44
|
-
// Optional inputs from FunctionConfigurationComponent
|
|
45
|
-
@Input() selectedPluginConfigurationData$?: Observable<PluginConfigurationData>;
|
|
46
|
-
@Input() context$?: Observable<[ManagementContext, CaseManagementParams]>;
|
|
47
|
-
|
|
48
|
-
@Output() valid: EventEmitter<boolean> = new EventEmitter<boolean>();
|
|
49
|
-
@Output() configuration: EventEmitter<GenerateDocumentConfig> = new EventEmitter<GenerateDocumentConfig>();
|
|
50
|
-
|
|
51
|
-
// Template options loaded from API
|
|
52
|
-
templateOptions$ = new BehaviorSubject<SelectItem[]>([]);
|
|
53
|
-
templatesLoading$ = new BehaviorSubject<boolean>(false);
|
|
54
|
-
|
|
55
|
-
// Variant options loaded based on selected template
|
|
56
|
-
variantOptions$ = new BehaviorSubject<SelectItem[]>([]);
|
|
57
|
-
variantsLoading$ = new BehaviorSubject<boolean>(false);
|
|
58
|
-
|
|
59
|
-
// Environment options loaded from API
|
|
60
|
-
environmentOptions$ = new BehaviorSubject<SelectItem[]>([]);
|
|
61
|
-
environmentsLoading$ = new BehaviorSubject<boolean>(false);
|
|
62
|
-
|
|
63
|
-
// Template fields for data mapping
|
|
64
|
-
templateFields$ = new BehaviorSubject<TemplateField[]>([]);
|
|
65
|
-
templateFieldsLoading$ = new BehaviorSubject<boolean>(false);
|
|
66
|
-
|
|
67
|
-
// Current data mapping (nested structure mirroring template schema)
|
|
68
|
-
dataMapping$ = new BehaviorSubject<Record<string, any>>({});
|
|
69
|
-
|
|
70
|
-
// Prefill data mapping observable for the tree
|
|
71
|
-
prefillDataMapping$!: Observable<Record<string, any>>;
|
|
72
|
-
|
|
73
|
-
outputFormatOptions: SelectItem[] = [
|
|
74
|
-
{id: 'PDF', text: 'PDF'},
|
|
75
|
-
{id: 'HTML', text: 'HTML'}
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
// Show data mapping builder only when template is selected
|
|
79
|
-
readonly selectedTemplateId$ = new BehaviorSubject<string>('');
|
|
80
|
-
readonly selectedVariantId$ = new BehaviorSubject<string>('');
|
|
81
|
-
|
|
82
|
-
// Variant selection mode: 'explicit' (dropdown) or 'attributes' (key-value pairs)
|
|
83
|
-
variantSelectionMode: VariantSelectionMode = 'explicit';
|
|
84
|
-
|
|
85
|
-
// Variant attributes for attribute-based selection
|
|
86
|
-
variantAttributeEntries: {key: string; value: string}[] = [];
|
|
87
|
-
|
|
88
|
-
// Case definition key from context (for ValuePathSelector)
|
|
89
|
-
caseDefinitionKey: string | null = null;
|
|
90
|
-
|
|
91
|
-
// Discovered process variables
|
|
92
|
-
processVariables: string[] = [];
|
|
93
|
-
|
|
94
|
-
// Required fields status
|
|
95
|
-
requiredFieldsStatus: {mapped: number; total: number} = {mapped: 0, total: 0};
|
|
96
|
-
|
|
97
|
-
private readonly destroy$ = new Subject<void>();
|
|
98
|
-
private saveSubscription!: Subscription;
|
|
99
|
-
private readonly formValue$ = new BehaviorSubject<Partial<GenerateDocumentConfig> | null>(null);
|
|
100
|
-
private readonly valid$ = new BehaviorSubject<boolean>(false);
|
|
101
|
-
private pluginConfigurationId$ = new BehaviorSubject<string>('');
|
|
102
|
-
|
|
103
|
-
constructor(
|
|
104
|
-
private readonly epistolaPluginService: EpistolaPluginService,
|
|
105
|
-
private readonly processLinkStateService: ProcessLinkStateService
|
|
106
|
-
) {}
|
|
107
|
-
|
|
108
|
-
ngOnInit(): void {
|
|
109
|
-
this.initContext();
|
|
110
|
-
this.initPrefillDataMapping();
|
|
111
|
-
this.initPluginConfiguration();
|
|
112
|
-
this.initTemplatesLoading();
|
|
113
|
-
this.initEnvironmentsLoading();
|
|
114
|
-
this.initVariantsLoading();
|
|
115
|
-
this.initTemplateFieldsLoading();
|
|
116
|
-
this.openSaveSubscription();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
ngOnDestroy(): void {
|
|
120
|
-
this.destroy$.next();
|
|
121
|
-
this.destroy$.complete();
|
|
122
|
-
this.saveSubscription?.unsubscribe();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
formValueChange(formOutput: FormOutput): void {
|
|
126
|
-
const formValue = formOutput as unknown as Partial<GenerateDocumentConfig>;
|
|
127
|
-
this.formValue$.next(formValue);
|
|
128
|
-
|
|
129
|
-
// Update selected template if changed (also clears variant selection)
|
|
130
|
-
if (formValue.templateId && formValue.templateId !== this.selectedTemplateId$.getValue()) {
|
|
131
|
-
this.selectedTemplateId$.next(formValue.templateId);
|
|
132
|
-
this.selectedVariantId$.next('');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Update selected variant if changed
|
|
136
|
-
if (formValue.variantId && formValue.variantId !== this.selectedVariantId$.getValue()) {
|
|
137
|
-
this.selectedVariantId$.next(formValue.variantId);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
this.handleValid(formValue);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
onDataMappingChange(mapping: Record<string, any>): void {
|
|
144
|
-
this.dataMapping$.next(mapping);
|
|
145
|
-
// Re-validate when data mapping changes
|
|
146
|
-
const currentFormValue = this.formValue$.getValue();
|
|
147
|
-
if (currentFormValue) {
|
|
148
|
-
this.handleValid(currentFormValue);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
onRequiredFieldsStatusChange(status: {mapped: number; total: number}): void {
|
|
153
|
-
this.requiredFieldsStatus = status;
|
|
154
|
-
// Re-validate when required fields status changes
|
|
155
|
-
const currentFormValue = this.formValue$.getValue();
|
|
156
|
-
if (currentFormValue) {
|
|
157
|
-
this.handleValid(currentFormValue);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
onVariantSelectionModeChange(mode: VariantSelectionMode): void {
|
|
162
|
-
this.variantSelectionMode = mode;
|
|
163
|
-
if (mode === 'attributes' && this.variantAttributeEntries.length === 0) {
|
|
164
|
-
this.variantAttributeEntries = [{key: '', value: ''}];
|
|
165
|
-
}
|
|
166
|
-
// Re-validate
|
|
167
|
-
const currentFormValue = this.formValue$.getValue();
|
|
168
|
-
if (currentFormValue) {
|
|
169
|
-
this.handleValid(currentFormValue);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
addAttributeEntry(): void {
|
|
174
|
-
this.variantAttributeEntries = [...this.variantAttributeEntries, {key: '', value: ''}];
|
|
175
|
-
this.revalidate();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
removeAttributeEntry(index: number): void {
|
|
179
|
-
this.variantAttributeEntries = this.variantAttributeEntries.filter((_, i) => i !== index);
|
|
180
|
-
this.revalidate();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
onAttributeEntryChange(): void {
|
|
184
|
-
this.revalidate();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
private revalidate(): void {
|
|
188
|
-
const currentFormValue = this.formValue$.getValue();
|
|
189
|
-
if (currentFormValue) {
|
|
190
|
-
this.handleValid(currentFormValue);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
private formatAttributes(attributes: Record<string, string>): string {
|
|
195
|
-
const entries = Object.entries(attributes || {});
|
|
196
|
-
if (entries.length === 0) return '';
|
|
197
|
-
return ` (${entries.map(([k, v]) => `${k}=${v}`).join(', ')})`;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private initContext(): void {
|
|
201
|
-
if (this.context$) {
|
|
202
|
-
this.context$.pipe(
|
|
203
|
-
takeUntil(this.destroy$),
|
|
204
|
-
filter(([context]) => context === 'case')
|
|
205
|
-
).subscribe(([, params]) => {
|
|
206
|
-
this.caseDefinitionKey = params.caseDefinitionKey;
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private initPrefillDataMapping(): void {
|
|
212
|
-
if (this.prefillConfiguration$) {
|
|
213
|
-
this.prefillDataMapping$ = this.prefillConfiguration$.pipe(
|
|
214
|
-
map(config => config?.dataMapping || {})
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
// Also set initial selected template, variant mode, and variant
|
|
218
|
-
this.prefillConfiguration$.pipe(
|
|
219
|
-
takeUntil(this.destroy$),
|
|
220
|
-
filter(config => !!config?.templateId)
|
|
221
|
-
).subscribe(config => {
|
|
222
|
-
this.selectedTemplateId$.next(config.templateId);
|
|
223
|
-
if (config.variantAttributes && Object.keys(config.variantAttributes).length > 0) {
|
|
224
|
-
this.variantSelectionMode = 'attributes';
|
|
225
|
-
this.variantAttributeEntries = Object.entries(config.variantAttributes)
|
|
226
|
-
.map(([key, value]) => ({key, value}));
|
|
227
|
-
} else if (config.variantId) {
|
|
228
|
-
this.variantSelectionMode = 'explicit';
|
|
229
|
-
this.selectedVariantId$.next(config.variantId);
|
|
230
|
-
}
|
|
231
|
-
if (config.dataMapping) {
|
|
232
|
-
this.dataMapping$.next(config.dataMapping);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
} else {
|
|
236
|
-
this.prefillDataMapping$ = new BehaviorSubject({}).asObservable();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
private initPluginConfiguration(): void {
|
|
241
|
-
const sources: Observable<string>[] = [];
|
|
242
|
-
|
|
243
|
-
// Create mode: framework emits when user selects a plugin configuration
|
|
244
|
-
if (this.selectedPluginConfigurationData$) {
|
|
245
|
-
sources.push(
|
|
246
|
-
this.selectedPluginConfigurationData$.pipe(
|
|
247
|
-
filter(config => !!config?.configurationId),
|
|
248
|
-
map(config => config.configurationId)
|
|
249
|
-
)
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Edit mode: read pluginConfigurationId from the ProcessLink entity
|
|
254
|
-
// (selectedPluginConfigurationData$ does not emit in edit mode)
|
|
255
|
-
sources.push(
|
|
256
|
-
this.processLinkStateService.selectedProcessLink$.pipe(
|
|
257
|
-
filter(processLink => !!processLink?.pluginConfigurationId),
|
|
258
|
-
map(processLink => processLink.pluginConfigurationId!)
|
|
259
|
-
)
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
merge(...sources).pipe(
|
|
263
|
-
takeUntil(this.destroy$)
|
|
264
|
-
).subscribe(configurationId => {
|
|
265
|
-
this.pluginConfigurationId$.next(configurationId);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
private initTemplatesLoading(): void {
|
|
270
|
-
this.pluginConfigurationId$.pipe(
|
|
271
|
-
takeUntil(this.destroy$),
|
|
272
|
-
filter(id => !!id)
|
|
273
|
-
).subscribe(configurationId => {
|
|
274
|
-
this.templatesLoading$.next(true);
|
|
275
|
-
this.epistolaPluginService.getTemplates(configurationId).pipe(
|
|
276
|
-
takeUntil(this.destroy$),
|
|
277
|
-
catchError(() => of([]))
|
|
278
|
-
).subscribe(templates => {
|
|
279
|
-
const options: SelectItem[] = templates.map(t => ({
|
|
280
|
-
id: t.id,
|
|
281
|
-
text: t.name
|
|
282
|
-
}));
|
|
283
|
-
this.templateOptions$.next(options);
|
|
284
|
-
this.templatesLoading$.next(false);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
private initEnvironmentsLoading(): void {
|
|
290
|
-
this.pluginConfigurationId$.pipe(
|
|
291
|
-
takeUntil(this.destroy$),
|
|
292
|
-
filter(id => !!id)
|
|
293
|
-
).subscribe(configurationId => {
|
|
294
|
-
this.environmentsLoading$.next(true);
|
|
295
|
-
this.epistolaPluginService.getEnvironments(configurationId).pipe(
|
|
296
|
-
takeUntil(this.destroy$),
|
|
297
|
-
catchError(() => of([]))
|
|
298
|
-
).subscribe(environments => {
|
|
299
|
-
const options: SelectItem[] = environments.map(e => ({
|
|
300
|
-
id: e.id,
|
|
301
|
-
text: e.name
|
|
302
|
-
}));
|
|
303
|
-
this.environmentOptions$.next(options);
|
|
304
|
-
this.environmentsLoading$.next(false);
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
private initVariantsLoading(): void {
|
|
310
|
-
combineLatest([
|
|
311
|
-
this.pluginConfigurationId$,
|
|
312
|
-
this.selectedTemplateId$
|
|
313
|
-
]).pipe(
|
|
314
|
-
takeUntil(this.destroy$),
|
|
315
|
-
filter(([configId, templateId]) => !!configId && !!templateId)
|
|
316
|
-
).subscribe(([configurationId, templateId]) => {
|
|
317
|
-
this.variantsLoading$.next(true);
|
|
318
|
-
this.epistolaPluginService.getVariants(configurationId, templateId).pipe(
|
|
319
|
-
takeUntil(this.destroy$),
|
|
320
|
-
catchError(() => of([]))
|
|
321
|
-
).subscribe(variants => {
|
|
322
|
-
const options: SelectItem[] = variants.map(v => ({
|
|
323
|
-
id: v.id,
|
|
324
|
-
text: v.name + this.formatAttributes(v.attributes)
|
|
325
|
-
}));
|
|
326
|
-
this.variantOptions$.next(options);
|
|
327
|
-
this.variantsLoading$.next(false);
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
private initTemplateFieldsLoading(): void {
|
|
333
|
-
combineLatest([
|
|
334
|
-
this.pluginConfigurationId$,
|
|
335
|
-
this.selectedTemplateId$
|
|
336
|
-
]).pipe(
|
|
337
|
-
takeUntil(this.destroy$),
|
|
338
|
-
filter(([configId, templateId]) => !!configId && !!templateId)
|
|
339
|
-
).subscribe(([configurationId, templateId]) => {
|
|
340
|
-
this.templateFieldsLoading$.next(true);
|
|
341
|
-
this.epistolaPluginService.getTemplateDetails(configurationId, templateId).pipe(
|
|
342
|
-
takeUntil(this.destroy$),
|
|
343
|
-
catchError(() => of({fields: []} as any))
|
|
344
|
-
).subscribe(details => {
|
|
345
|
-
this.templateFields$.next(details.fields || []);
|
|
346
|
-
this.templateFieldsLoading$.next(false);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// Also load process variables if we have a case context
|
|
350
|
-
this.loadProcessVariables();
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
private loadProcessVariables(): void {
|
|
355
|
-
// Try to discover process variables (best-effort, may not always have context)
|
|
356
|
-
if (this.caseDefinitionKey) {
|
|
357
|
-
this.epistolaPluginService.getProcessVariables(this.caseDefinitionKey).pipe(
|
|
358
|
-
takeUntil(this.destroy$),
|
|
359
|
-
catchError(() => of([]))
|
|
360
|
-
).subscribe(variables => {
|
|
361
|
-
this.processVariables = variables;
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
private handleValid(formValue: Partial<GenerateDocumentConfig>): void {
|
|
367
|
-
const baseComplete = !!(
|
|
368
|
-
formValue?.templateId &&
|
|
369
|
-
formValue?.outputFormat &&
|
|
370
|
-
formValue?.filename &&
|
|
371
|
-
formValue?.resultProcessVariable
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
// Variant selection: if attribute mode is used, all entries must have both key and value filled.
|
|
375
|
-
// Neither variant nor attributes are required — omitting both uses the template's default variant.
|
|
376
|
-
let variantValid = true;
|
|
377
|
-
if (this.variantSelectionMode === 'attributes' && this.variantAttributeEntries.length > 0) {
|
|
378
|
-
variantValid = this.variantAttributeEntries.every(e => !!e.key && !!e.value);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Check if all required template fields are mapped
|
|
382
|
-
const requiredFieldsMapped = this.requiredFieldsStatus.total === 0 ||
|
|
383
|
-
this.requiredFieldsStatus.mapped === this.requiredFieldsStatus.total;
|
|
384
|
-
|
|
385
|
-
const valid = baseComplete && variantValid && requiredFieldsMapped;
|
|
386
|
-
this.valid$.next(valid);
|
|
387
|
-
this.valid.emit(valid);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
private openSaveSubscription(): void {
|
|
391
|
-
this.saveSubscription = this.save$?.subscribe(() => {
|
|
392
|
-
combineLatest([this.formValue$, this.valid$, this.dataMapping$])
|
|
393
|
-
.pipe(take(1))
|
|
394
|
-
.subscribe(([formValue, valid, dataMapping]) => {
|
|
395
|
-
if (valid && formValue) {
|
|
396
|
-
const config: GenerateDocumentConfig = {
|
|
397
|
-
templateId: formValue.templateId!,
|
|
398
|
-
environmentId: formValue.environmentId || undefined,
|
|
399
|
-
dataMapping: dataMapping,
|
|
400
|
-
outputFormat: formValue.outputFormat as 'PDF' | 'HTML',
|
|
401
|
-
filename: formValue.filename!,
|
|
402
|
-
correlationId: formValue.correlationId || undefined,
|
|
403
|
-
resultProcessVariable: formValue.resultProcessVariable!
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
if (this.variantSelectionMode === 'explicit') {
|
|
407
|
-
config.variantId = formValue.variantId!;
|
|
408
|
-
} else {
|
|
409
|
-
config.variantAttributes = {};
|
|
410
|
-
for (const entry of this.variantAttributeEntries) {
|
|
411
|
-
if (entry.key && entry.value) {
|
|
412
|
-
config.variantAttributes[entry.key] = entry.value;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
this.configuration.emit(config);
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {NgModule} from '@angular/core';
|
|
2
|
-
import {CommonModule} from '@angular/common';
|
|
3
|
-
import {HttpClientModule} from '@angular/common/http';
|
|
4
|
-
import {PluginTranslatePipeModule} from '@valtimo/plugin';
|
|
5
|
-
import {FormModule, InputModule, SelectModule} from '@valtimo/components';
|
|
6
|
-
import {EpistolaConfigurationComponent} from './components/epistola-configuration/epistola-configuration.component';
|
|
7
|
-
import {
|
|
8
|
-
GenerateDocumentConfigurationComponent
|
|
9
|
-
} from './components/generate-document-configuration/generate-document-configuration.component';
|
|
10
|
-
import {
|
|
11
|
-
CheckJobStatusConfigurationComponent
|
|
12
|
-
} from './components/check-job-status-configuration/check-job-status-configuration.component';
|
|
13
|
-
import {
|
|
14
|
-
DownloadDocumentConfigurationComponent
|
|
15
|
-
} from './components/download-document-configuration/download-document-configuration.component';
|
|
16
|
-
import {DataMappingTreeComponent} from './components/data-mapping-tree/data-mapping-tree.component';
|
|
17
|
-
import {FieldTreeComponent} from './components/field-tree/field-tree.component';
|
|
18
|
-
import {EpistolaDownloadComponent} from './components/epistola-download/epistola-download.component';
|
|
19
|
-
import {EpistolaPluginService} from './services';
|
|
20
|
-
|
|
21
|
-
@NgModule({
|
|
22
|
-
imports: [
|
|
23
|
-
CommonModule,
|
|
24
|
-
HttpClientModule,
|
|
25
|
-
PluginTranslatePipeModule,
|
|
26
|
-
FormModule,
|
|
27
|
-
InputModule,
|
|
28
|
-
SelectModule,
|
|
29
|
-
EpistolaConfigurationComponent,
|
|
30
|
-
GenerateDocumentConfigurationComponent,
|
|
31
|
-
CheckJobStatusConfigurationComponent,
|
|
32
|
-
DownloadDocumentConfigurationComponent,
|
|
33
|
-
DataMappingTreeComponent,
|
|
34
|
-
FieldTreeComponent,
|
|
35
|
-
EpistolaDownloadComponent
|
|
36
|
-
],
|
|
37
|
-
exports: [
|
|
38
|
-
EpistolaConfigurationComponent,
|
|
39
|
-
GenerateDocumentConfigurationComponent,
|
|
40
|
-
CheckJobStatusConfigurationComponent,
|
|
41
|
-
DownloadDocumentConfigurationComponent,
|
|
42
|
-
DataMappingTreeComponent,
|
|
43
|
-
FieldTreeComponent,
|
|
44
|
-
EpistolaDownloadComponent
|
|
45
|
-
],
|
|
46
|
-
providers: [
|
|
47
|
-
EpistolaPluginService
|
|
48
|
-
]
|
|
49
|
-
})
|
|
50
|
-
export class EpistolaPluginModule {}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import {PluginSpecification} from '@valtimo/plugin';
|
|
2
|
-
import {EpistolaConfigurationComponent} from './components/epistola-configuration/epistola-configuration.component';
|
|
3
|
-
import {
|
|
4
|
-
GenerateDocumentConfigurationComponent
|
|
5
|
-
} from './components/generate-document-configuration/generate-document-configuration.component';
|
|
6
|
-
import {
|
|
7
|
-
CheckJobStatusConfigurationComponent
|
|
8
|
-
} from './components/check-job-status-configuration/check-job-status-configuration.component';
|
|
9
|
-
import {
|
|
10
|
-
DownloadDocumentConfigurationComponent
|
|
11
|
-
} from './components/download-document-configuration/download-document-configuration.component';
|
|
12
|
-
import {EPISTOLA_PLUGIN_LOGO_BASE64} from './assets';
|
|
13
|
-
|
|
14
|
-
const epistolaPluginSpecification: PluginSpecification = {
|
|
15
|
-
// Must match backend @Plugin(key = "epistola")
|
|
16
|
-
pluginId: 'epistola',
|
|
17
|
-
|
|
18
|
-
// Component for plugin-level configuration (tenantId)
|
|
19
|
-
pluginConfigurationComponent: EpistolaConfigurationComponent,
|
|
20
|
-
|
|
21
|
-
// Plugin logo
|
|
22
|
-
pluginLogoBase64: EPISTOLA_PLUGIN_LOGO_BASE64,
|
|
23
|
-
|
|
24
|
-
// Map action keys to their configuration components
|
|
25
|
-
functionConfigurationComponents: {
|
|
26
|
-
'generate-document': GenerateDocumentConfigurationComponent,
|
|
27
|
-
'check-job-status': CheckJobStatusConfigurationComponent,
|
|
28
|
-
'download-document': DownloadDocumentConfigurationComponent,
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
// Translations
|
|
32
|
-
pluginTranslations: {
|
|
33
|
-
nl: {
|
|
34
|
-
title: 'Epistola Document Suite',
|
|
35
|
-
description: 'Documentgeneratie met Epistola',
|
|
36
|
-
configurationTitle: 'Configuratienaam',
|
|
37
|
-
baseUrl: 'Base URL',
|
|
38
|
-
baseUrlTooltip: 'De basis URL van de Epistola API (bijv. https://api.epistola.app)',
|
|
39
|
-
apiKey: 'API Key',
|
|
40
|
-
apiKeyTooltip: 'De API sleutel voor authenticatie met Epistola',
|
|
41
|
-
tenantId: 'Tenant ID',
|
|
42
|
-
tenantIdTooltip: 'De tenant slug in Epistola (3-63 tekens, alleen kleine letters, cijfers en koppeltekens, bijv. "mijn-tenant")',
|
|
43
|
-
defaultEnvironmentId: 'Standaard Omgeving',
|
|
44
|
-
defaultEnvironmentIdTooltip: 'De standaard omgeving voor documentgeneratie (3-30 tekens, alleen kleine letters, cijfers en koppeltekens, bijv. "productie")',
|
|
45
|
-
templateSyncEnabled: 'Template synchronisatie',
|
|
46
|
-
templateSyncEnabledTooltip: 'Synchroniseer template definities automatisch van het classpath naar Epistola bij het opstarten',
|
|
47
|
-
'generate-document': 'Genereer Document',
|
|
48
|
-
templateId: 'Template',
|
|
49
|
-
templateIdTooltip: 'Selecteer het template dat gebruikt wordt voor documentgeneratie',
|
|
50
|
-
variantId: 'Variant',
|
|
51
|
-
variantIdTooltip: 'Selecteer de template variant',
|
|
52
|
-
variantSelectionMode: 'Variant selectie',
|
|
53
|
-
variantSelectionModeTooltip: 'Kies hoe de variant geselecteerd wordt',
|
|
54
|
-
selectByVariant: 'Selecteer variant',
|
|
55
|
-
selectByAttributes: 'Selecteer op kenmerken',
|
|
56
|
-
variantAttributes: 'Variant kenmerken',
|
|
57
|
-
variantAttributesTooltip: 'Kenmerken voor automatische variant selectie. Waarden kunnen expressies zijn (doc:, pv:, case:).',
|
|
58
|
-
attributeKey: 'Kenmerk',
|
|
59
|
-
attributeValue: 'Waarde',
|
|
60
|
-
addAttribute: 'Kenmerk toevoegen',
|
|
61
|
-
removeAttribute: 'Kenmerk verwijderen',
|
|
62
|
-
environmentId: 'Omgeving',
|
|
63
|
-
environmentIdTooltip: 'Selecteer de doelomgeving (optioneel)',
|
|
64
|
-
correlationId: 'Correlatie ID',
|
|
65
|
-
correlationIdTooltip: 'Een optioneel correlatie ID voor het traceren van dit verzoek',
|
|
66
|
-
dataMapping: 'Data Mapping',
|
|
67
|
-
dataMappingTooltip: 'Koppeling van template velden naar data bronnen (doc:, pv:, case:)',
|
|
68
|
-
outputFormat: 'Uitvoerformaat',
|
|
69
|
-
outputFormatTooltip: 'Het gewenste formaat van het gegenereerde document',
|
|
70
|
-
filename: 'Bestandsnaam',
|
|
71
|
-
filenameTooltip: 'De bestandsnaam voor het gegenereerde document',
|
|
72
|
-
resultProcessVariable: 'Resultaat Procesvariabele',
|
|
73
|
-
resultProcessVariableTooltip: 'De naam van de procesvariabele waarin het request ID wordt opgeslagen',
|
|
74
|
-
pdf: 'PDF',
|
|
75
|
-
html: 'HTML',
|
|
76
|
-
// Data mapping builder translations
|
|
77
|
-
dataMappingTitle: 'Data Mapping',
|
|
78
|
-
dataMappingDescription: 'Koppel template velden aan Valtimo data bronnen',
|
|
79
|
-
templateField: 'Template veld',
|
|
80
|
-
dataSource: 'Data bron',
|
|
81
|
-
addMapping: 'Mapping toevoegen',
|
|
82
|
-
noMappings: 'Nog geen mappings toegevoegd. Klik op "Mapping toevoegen" om te beginnen.',
|
|
83
|
-
documentFields: 'Document velden',
|
|
84
|
-
processVariables: 'Procesvariabelen',
|
|
85
|
-
caseProperties: 'Zaak eigenschappen',
|
|
86
|
-
sourceType: 'Brontype',
|
|
87
|
-
sourceTypeDocument: 'Document veld',
|
|
88
|
-
sourceTypeProcessVariable: 'Procesvariabele',
|
|
89
|
-
sourceTypeManual: 'Handmatig',
|
|
90
|
-
requiredFieldsMissing: 'Niet alle verplichte velden zijn gekoppeld',
|
|
91
|
-
requiredFieldsComplete: 'Alle verplichte velden zijn gekoppeld',
|
|
92
|
-
validationSummary: 'verplichte velden gekoppeld',
|
|
93
|
-
fieldRequired: 'Verplicht',
|
|
94
|
-
fieldOptional: 'Optioneel',
|
|
95
|
-
mapCollectionTo: 'Koppel collectie aan',
|
|
96
|
-
browseMode: 'Bladermodus',
|
|
97
|
-
pvMode: 'Procesvariabele modus',
|
|
98
|
-
pvPlaceholder: 'Naam procesvariabele',
|
|
99
|
-
expressionMode: 'Expressiemodus',
|
|
100
|
-
itemFieldMapping: 'Veldnamen per item koppelen',
|
|
101
|
-
itemFieldMappingTitle: 'Veldkoppeling per item:',
|
|
102
|
-
sourceFieldPlaceholder: 'Bronveldnaam',
|
|
103
|
-
noTemplateFields: 'Geen template velden beschikbaar',
|
|
104
|
-
// Check job status action
|
|
105
|
-
'check-job-status': 'Controleer Taakstatus',
|
|
106
|
-
requestIdVariable: 'Request ID Variabele',
|
|
107
|
-
requestIdVariableTooltip: 'Naam van de procesvariabele met het Epistola request ID',
|
|
108
|
-
statusVariable: 'Status Variabele',
|
|
109
|
-
statusVariableTooltip: 'Naam van de procesvariabele waarin de status wordt opgeslagen',
|
|
110
|
-
documentIdVariable: 'Document ID Variabele',
|
|
111
|
-
documentIdVariableTooltip: 'Naam van de procesvariabele waarin het document ID wordt opgeslagen (bij voltooiing)',
|
|
112
|
-
errorMessageVariable: 'Foutmelding Variabele',
|
|
113
|
-
errorMessageVariableTooltip: 'Naam van de procesvariabele waarin de foutmelding wordt opgeslagen (bij fout)',
|
|
114
|
-
// Download document action
|
|
115
|
-
'download-document': 'Download Document',
|
|
116
|
-
contentVariable: 'Inhoud Variabele',
|
|
117
|
-
contentVariableTooltip: 'Naam van de procesvariabele waarin de documentinhoud (Base64) wordt opgeslagen'
|
|
118
|
-
},
|
|
119
|
-
en: {
|
|
120
|
-
title: 'Epistola Document Suite',
|
|
121
|
-
description: 'Document generation using Epistola',
|
|
122
|
-
configurationTitle: 'Configuration name',
|
|
123
|
-
baseUrl: 'Base URL',
|
|
124
|
-
baseUrlTooltip: 'The base URL of the Epistola API (e.g. https://api.epistola.app)',
|
|
125
|
-
apiKey: 'API Key',
|
|
126
|
-
apiKeyTooltip: 'The API key for authentication with Epistola',
|
|
127
|
-
tenantId: 'Tenant ID',
|
|
128
|
-
tenantIdTooltip: 'The tenant slug in Epistola (3-63 chars, lowercase letters, digits and hyphens only, e.g. "my-tenant")',
|
|
129
|
-
defaultEnvironmentId: 'Default Environment',
|
|
130
|
-
defaultEnvironmentIdTooltip: 'The default environment for document generation (3-30 chars, lowercase letters, digits and hyphens only, e.g. "production")',
|
|
131
|
-
templateSyncEnabled: 'Template sync',
|
|
132
|
-
templateSyncEnabledTooltip: 'Automatically synchronize template definitions from classpath to Epistola on startup',
|
|
133
|
-
'generate-document': 'Generate Document',
|
|
134
|
-
templateId: 'Template',
|
|
135
|
-
templateIdTooltip: 'Select the template to use for document generation',
|
|
136
|
-
variantId: 'Variant',
|
|
137
|
-
variantIdTooltip: 'Select the template variant',
|
|
138
|
-
variantSelectionMode: 'Variant selection',
|
|
139
|
-
variantSelectionModeTooltip: 'Choose how the variant is selected',
|
|
140
|
-
selectByVariant: 'Select variant',
|
|
141
|
-
selectByAttributes: 'Select by attributes',
|
|
142
|
-
variantAttributes: 'Variant attributes',
|
|
143
|
-
variantAttributesTooltip: 'Attributes for automatic variant selection. Values can be expressions (doc:, pv:, case:).',
|
|
144
|
-
attributeKey: 'Attribute',
|
|
145
|
-
attributeValue: 'Value',
|
|
146
|
-
addAttribute: 'Add attribute',
|
|
147
|
-
removeAttribute: 'Remove attribute',
|
|
148
|
-
environmentId: 'Environment',
|
|
149
|
-
environmentIdTooltip: 'Select the target environment (optional)',
|
|
150
|
-
correlationId: 'Correlation ID',
|
|
151
|
-
correlationIdTooltip: 'An optional correlation ID for tracking this request',
|
|
152
|
-
dataMapping: 'Data Mapping',
|
|
153
|
-
dataMappingTooltip: 'Mapping of template fields to data sources (doc:, pv:, case:)',
|
|
154
|
-
outputFormat: 'Output Format',
|
|
155
|
-
outputFormatTooltip: 'The desired format of the generated document',
|
|
156
|
-
filename: 'Filename',
|
|
157
|
-
filenameTooltip: 'The filename for the generated document',
|
|
158
|
-
resultProcessVariable: 'Result Process Variable',
|
|
159
|
-
resultProcessVariableTooltip: 'The name of the process variable to store the request ID in',
|
|
160
|
-
pdf: 'PDF',
|
|
161
|
-
html: 'HTML',
|
|
162
|
-
// Data mapping builder translations
|
|
163
|
-
dataMappingTitle: 'Data Mapping',
|
|
164
|
-
dataMappingDescription: 'Map template fields to Valtimo data sources',
|
|
165
|
-
templateField: 'Template field',
|
|
166
|
-
dataSource: 'Data source',
|
|
167
|
-
addMapping: 'Add mapping',
|
|
168
|
-
noMappings: 'No mappings added yet. Click "Add mapping" to start.',
|
|
169
|
-
documentFields: 'Document fields',
|
|
170
|
-
processVariables: 'Process variables',
|
|
171
|
-
caseProperties: 'Case properties',
|
|
172
|
-
sourceType: 'Source type',
|
|
173
|
-
sourceTypeDocument: 'Document field',
|
|
174
|
-
sourceTypeProcessVariable: 'Process variable',
|
|
175
|
-
sourceTypeManual: 'Manual value',
|
|
176
|
-
requiredFieldsMissing: 'Not all required fields are mapped',
|
|
177
|
-
requiredFieldsComplete: 'All required fields are mapped',
|
|
178
|
-
validationSummary: 'required fields mapped',
|
|
179
|
-
fieldRequired: 'Required',
|
|
180
|
-
fieldOptional: 'Optional',
|
|
181
|
-
mapCollectionTo: 'Map collection to',
|
|
182
|
-
browseMode: 'Browse mode',
|
|
183
|
-
pvMode: 'Process variable mode',
|
|
184
|
-
pvPlaceholder: 'Process variable name',
|
|
185
|
-
expressionMode: 'Expression mode',
|
|
186
|
-
itemFieldMapping: 'Map field names per item',
|
|
187
|
-
itemFieldMappingTitle: 'Item field mapping:',
|
|
188
|
-
sourceFieldPlaceholder: 'Source field name',
|
|
189
|
-
noTemplateFields: 'No template fields available',
|
|
190
|
-
// Check job status action
|
|
191
|
-
'check-job-status': 'Check Job Status',
|
|
192
|
-
requestIdVariable: 'Request ID Variable',
|
|
193
|
-
requestIdVariableTooltip: 'Name of the process variable containing the Epistola request ID',
|
|
194
|
-
statusVariable: 'Status Variable',
|
|
195
|
-
statusVariableTooltip: 'Name of the process variable to store the status in',
|
|
196
|
-
documentIdVariable: 'Document ID Variable',
|
|
197
|
-
documentIdVariableTooltip: 'Name of the process variable to store the document ID in (when completed)',
|
|
198
|
-
errorMessageVariable: 'Error Message Variable',
|
|
199
|
-
errorMessageVariableTooltip: 'Name of the process variable to store the error message in (when failed)',
|
|
200
|
-
// Download document action
|
|
201
|
-
'download-document': 'Download Document',
|
|
202
|
-
contentVariable: 'Content Variable',
|
|
203
|
-
contentVariableTooltip: 'Name of the process variable to store the document content (Base64) in'
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export {epistolaPluginSpecification};
|