@genesislcap/pbc-reporting-ui 14.396.4 → 14.397.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/dist/dts/new/main/edit-config/datasource-config/datasource-config-item.d.ts +6 -2
- package/dist/dts/new/main/edit-config/datasource-config/datasource-config-item.d.ts.map +1 -1
- package/dist/dts/new/main/edit-config/datasource-config/datasource-config-item.styles.d.ts.map +1 -1
- package/dist/dts/new/main/edit-config/datasource-config/datasource-config-item.template.d.ts.map +1 -1
- package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.helpers.d.ts.map +1 -1
- package/dist/dts/new/main/edit-config/datasource-config/datasources-config-container.template.d.ts.map +1 -1
- package/dist/dts/new/main/edit-config/shared/datasource-data-base-component.helpers.ts.d.ts.map +1 -1
- package/dist/dts/new/store/slices/datasources-config.d.ts +19 -6
- package/dist/dts/new/store/slices/datasources-config.d.ts.map +1 -1
- package/dist/dts/new/store/slices/types.d.ts +19 -2
- package/dist/dts/new/store/slices/types.d.ts.map +1 -1
- package/dist/dts/new/store/store.d.ts +126 -35
- package/dist/dts/new/store/store.d.ts.map +1 -1
- package/dist/dts/new/types/misc.d.ts +4 -2
- package/dist/dts/new/types/misc.d.ts.map +1 -1
- package/dist/dts/new/utils/alias-generator.d.ts +8 -0
- package/dist/dts/new/utils/alias-generator.d.ts.map +1 -0
- package/dist/dts/new/utils/alias-generator.test.d.ts +2 -0
- package/dist/dts/new/utils/alias-generator.test.d.ts.map +1 -0
- package/dist/dts/new/utils/index.d.ts +1 -0
- package/dist/dts/new/utils/index.d.ts.map +1 -1
- package/dist/dts/new/utils/tooltip.d.ts +3 -0
- package/dist/dts/new/utils/tooltip.d.ts.map +1 -1
- package/dist/dts/new/utils/transformers.d.ts +1 -1
- package/dist/dts/new/utils/transformers.d.ts.map +1 -1
- package/dist/esm/new/main/edit-config/col-filters/col-filters-grid.helpers.test.js +39 -7
- package/dist/esm/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.js +32 -4
- package/dist/esm/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.js +10 -2
- package/dist/esm/new/main/edit-config/datasource-config/datasource-config-item.js +100 -10
- package/dist/esm/new/main/edit-config/datasource-config/datasource-config-item.styles.js +6 -0
- package/dist/esm/new/main/edit-config/datasource-config/datasource-config-item.template.js +38 -3
- package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.helpers.js +11 -7
- package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.js +29 -22
- package/dist/esm/new/main/edit-config/datasource-config/datasources-config-container.template.js +3 -0
- package/dist/esm/new/main/edit-config/shared/datasource-data-base-component.helpers.ts.js +16 -8
- package/dist/esm/new/main/edit-config/shared/datasource-data-base-component.test.js +13 -2
- package/dist/esm/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.template.js +1 -1
- package/dist/esm/new/store/slices/datasources-config.js +41 -5
- package/dist/esm/new/store/slices/types.js +1 -0
- package/dist/esm/new/utils/alias-generator.js +16 -0
- package/dist/esm/new/utils/alias-generator.test.js +36 -0
- package/dist/esm/new/utils/index.js +1 -0
- package/dist/esm/new/utils/tooltip.js +16 -0
- package/dist/esm/new/utils/transformers.js +20 -6
- package/dist/esm/new/utils/transformers.test.js +61 -11
- package/dist/esm/new/utils/validators.test.js +35 -21
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -22
- package/src/new/main/edit-config/col-filters/col-filters-grid.helpers.test.ts +39 -7
- package/src/new/main/edit-config/col-rename-alias/col-rename-alias-grid.helpers.test.ts +32 -4
- package/src/new/main/edit-config/data-transforms-derived-fields/data-transforms.helpers.test.ts +10 -2
- package/src/new/main/edit-config/datasource-config/datasource-config-item.styles.ts +6 -0
- package/src/new/main/edit-config/datasource-config/datasource-config-item.template.ts +62 -3
- package/src/new/main/edit-config/datasource-config/datasource-config-item.ts +107 -8
- package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.test.ts +32 -23
- package/src/new/main/edit-config/datasource-config/datasources-config-container.helpers.ts +18 -10
- package/src/new/main/edit-config/datasource-config/datasources-config-container.template.ts +6 -0
- package/src/new/main/edit-config/shared/datasource-data-base-component.helpers.ts.ts +21 -11
- package/src/new/main/edit-config/shared/datasource-data-base-component.test.ts +14 -2
- package/src/new/main/edit-config/tabbed-datasource-container/tabbed-datasource-container.template.ts +1 -1
- package/src/new/store/slices/datasources-config.ts +58 -7
- package/src/new/store/slices/types.ts +22 -4
- package/src/new/types/misc.ts +9 -2
- package/src/new/utils/alias-generator.test.ts +44 -0
- package/src/new/utils/alias-generator.ts +18 -0
- package/src/new/utils/index.ts +1 -0
- package/src/new/utils/tooltip.ts +19 -0
- package/src/new/utils/transformers.test.ts +73 -11
- package/src/new/utils/transformers.ts +30 -6
- package/src/new/utils/validators.test.ts +35 -21
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { assert, suite } from '@genesislcap/foundation-testing';
|
|
2
|
+
import { generateUniqueAlias } from './alias-generator';
|
|
3
|
+
|
|
4
|
+
const GenerateUniqueAlias = suite('generateUniqueAlias');
|
|
5
|
+
|
|
6
|
+
GenerateUniqueAlias('returns the base alias if it does not exist', () => {
|
|
7
|
+
const existingAliases = new Set(['other']);
|
|
8
|
+
const alias = generateUniqueAlias('test', existingAliases);
|
|
9
|
+
assert.equal(alias, 'test');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
GenerateUniqueAlias('increments the alias if it already exists', () => {
|
|
13
|
+
const existingAliases = new Set(['test']);
|
|
14
|
+
const alias = generateUniqueAlias('test', existingAliases);
|
|
15
|
+
assert.equal(alias, 'test_1');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
GenerateUniqueAlias('increments the alias until it is unique', () => {
|
|
19
|
+
const existingAliases = new Set(['test', 'test_1']);
|
|
20
|
+
const alias = generateUniqueAlias('test', existingAliases);
|
|
21
|
+
assert.equal(alias, 'test_2');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
GenerateUniqueAlias('handles case-insensitivity when checking for existing aliases', () => {
|
|
25
|
+
const existingAliases = new Set(['Test']);
|
|
26
|
+
const alias = generateUniqueAlias('test', existingAliases);
|
|
27
|
+
assert.equal(alias, 'test_1');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
GenerateUniqueAlias('handles case-insensitivity for new alias generation', () => {
|
|
31
|
+
const existingAliases = new Set(['test']);
|
|
32
|
+
const alias = generateUniqueAlias('Test', existingAliases);
|
|
33
|
+
// Since input baseAlias is 'Test', it tries 'Test'. 'Test' matches 'test' case-insensitively.
|
|
34
|
+
// Next attempt 'Test_1'.
|
|
35
|
+
assert.equal(alias, 'Test_1');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
GenerateUniqueAlias('handles mixed case existing aliases', () => {
|
|
39
|
+
const existingAliases = new Set(['TeSt', 'tEsT_1']);
|
|
40
|
+
const alias = generateUniqueAlias('test', existingAliases);
|
|
41
|
+
assert.equal(alias, 'test_2');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
GenerateUniqueAlias.run();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique alias by appending a counter if the base alias already exists in the set.
|
|
3
|
+
* @param baseAlias The desired alias name (usually the resource name).
|
|
4
|
+
* @param existingAliases A Set of currently used aliases to check against.
|
|
5
|
+
* @returns A unique alias string.
|
|
6
|
+
*/
|
|
7
|
+
export function generateUniqueAlias(baseAlias: string, existingAliases: Set<string>): string {
|
|
8
|
+
const existingAliasesLower = new Set(
|
|
9
|
+
Array.from(existingAliases).map((alias) => alias.toLowerCase()),
|
|
10
|
+
);
|
|
11
|
+
let uniqueAlias = baseAlias;
|
|
12
|
+
let counter = 1;
|
|
13
|
+
while (existingAliasesLower.has(uniqueAlias.toLowerCase())) {
|
|
14
|
+
uniqueAlias = `${baseAlias}_${counter}`;
|
|
15
|
+
counter += 1;
|
|
16
|
+
}
|
|
17
|
+
return uniqueAlias;
|
|
18
|
+
}
|
package/src/new/utils/index.ts
CHANGED
package/src/new/utils/tooltip.ts
CHANGED
|
@@ -52,6 +52,11 @@ export namespace TOOLTIP {
|
|
|
52
52
|
</ul>
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
|
+
export const DATASOURCES_DATASOURCE = `
|
|
56
|
+
<h3>Datasource</h3>
|
|
57
|
+
<p>This is the name of the server resource that data will be pulled from to generate the report.</p>
|
|
58
|
+
`;
|
|
59
|
+
|
|
55
60
|
export const DATASOURCES_NAME = `
|
|
56
61
|
<h3>Datasource name</h3>
|
|
57
62
|
<p>Allows you to set a name for the datasource which must correspond with your template data references where the report is configured to use a template file.</p>
|
|
@@ -63,6 +68,20 @@ export namespace TOOLTIP {
|
|
|
63
68
|
<p>Configures the method by which the server constructs the report configuration. Currently only TABLE is supported, which means the entire datasource is loaded into memory when generating the report using this report configuration.</p>
|
|
64
69
|
`;
|
|
65
70
|
|
|
71
|
+
export const DATASOURCES_GROUPING_STRATEGY = `
|
|
72
|
+
<h3>Grouping Strategy</h3>
|
|
73
|
+
<p>Select "None" to disable grouping strategies, or select the strategy you'd like to use.</p>
|
|
74
|
+
<ul>
|
|
75
|
+
<li><strong>Multi-sheet</strong>: Group data for <code>JXLS</code> template Multi-sheet functionality, to split different groups across multiple excel worksheets.</li>
|
|
76
|
+
<li><strong>Lookup-table</strong>: Create a lookup table of key value pairs in the template data, where the group key field is the map key.</li>
|
|
77
|
+
</ul>
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
export const DATASOURCES_GROUPING_KEY = `
|
|
81
|
+
<h3>Grouping Key</h3>
|
|
82
|
+
<p>Select the field for this datasource you want to operate the grouping strategy on.</p>
|
|
83
|
+
`;
|
|
84
|
+
|
|
66
85
|
export const DELIVERY_TIMEZONE = `
|
|
67
86
|
<h3>Timezone</h3>
|
|
68
87
|
<p>Select the timezone to be used for this schedule.</p>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { assert, sinon, suite } from '@genesislcap/foundation-testing';
|
|
2
2
|
import type { Genesis } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
buildDatasourceName,
|
|
5
|
+
transformFromServerPayload,
|
|
6
|
+
transformToServerPayload,
|
|
7
|
+
} from './transformers';
|
|
4
8
|
|
|
5
9
|
const TransformFromServerPayload = suite('transformFromServerPayload');
|
|
6
10
|
|
|
@@ -39,7 +43,7 @@ TransformFromServerPayload('cleans up orphaned fields from INCLUDE_COLUMNS', asy
|
|
|
39
43
|
|
|
40
44
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
41
45
|
|
|
42
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
46
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
43
47
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
44
48
|
|
|
45
49
|
assert.equal(cleanedConfig.INCLUDE_COLUMNS?.length, 2);
|
|
@@ -83,7 +87,7 @@ TransformFromServerPayload('cleans up orphaned fields from COLUMN_RENAMES', asyn
|
|
|
83
87
|
|
|
84
88
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
85
89
|
|
|
86
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
90
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
87
91
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
88
92
|
|
|
89
93
|
assert.equal(Object.keys(cleanedConfig.COLUMN_RENAMES || {}).length, 2);
|
|
@@ -127,7 +131,7 @@ TransformFromServerPayload('cleans up orphaned fields from COLUMN_FORMATS', asyn
|
|
|
127
131
|
|
|
128
132
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
129
133
|
|
|
130
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
134
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
131
135
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
132
136
|
|
|
133
137
|
assert.equal(Object.keys(cleanedConfig.COLUMN_FORMATS || {}).length, 2);
|
|
@@ -171,7 +175,7 @@ TransformFromServerPayload('cleans up orphaned fields from COLUMN_TRANSFORMS', a
|
|
|
171
175
|
|
|
172
176
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
173
177
|
|
|
174
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
178
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
175
179
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
176
180
|
|
|
177
181
|
assert.equal(Object.keys(cleanedConfig.COLUMN_TRANSFORMS || {}).length, 2);
|
|
@@ -209,7 +213,7 @@ TransformFromServerPayload('handles schema fetch failure gracefully', async () =
|
|
|
209
213
|
|
|
210
214
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
211
215
|
|
|
212
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
216
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
213
217
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
214
218
|
|
|
215
219
|
// Should keep original config when schema fetch fails
|
|
@@ -266,8 +270,8 @@ TransformFromServerPayload('handles multiple datasources independently', async (
|
|
|
266
270
|
|
|
267
271
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
268
272
|
|
|
269
|
-
const counterpartyKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
270
|
-
const tradeKey = buildDatasourceName('TRADE', 'REQ_REP');
|
|
273
|
+
const counterpartyKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
274
|
+
const tradeKey = buildDatasourceName('TRADE', 'TRADE', 'REQ_REP');
|
|
271
275
|
|
|
272
276
|
assert.equal(
|
|
273
277
|
result.datasourceConfig[counterpartyKey].TRANSFORMER_CONFIGURATION.INCLUDE_COLUMNS?.length,
|
|
@@ -318,7 +322,7 @@ TransformFromServerPayload('handles empty transformer configuration', async () =
|
|
|
318
322
|
|
|
319
323
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
320
324
|
|
|
321
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
325
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
322
326
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
323
327
|
|
|
324
328
|
assert.equal(JSON.stringify(cleanedConfig), JSON.stringify({}));
|
|
@@ -350,7 +354,7 @@ TransformFromServerPayload('handles missing schema properties', async () => {
|
|
|
350
354
|
|
|
351
355
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
352
356
|
|
|
353
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
357
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
354
358
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
355
359
|
|
|
356
360
|
// All fields should be removed when schema has no properties
|
|
@@ -460,7 +464,7 @@ TransformFromServerPayload('handles all transformer config types together', asyn
|
|
|
460
464
|
|
|
461
465
|
const result = await transformFromServerPayload(payload, mockGetSchema);
|
|
462
466
|
|
|
463
|
-
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'REQ_REP');
|
|
467
|
+
const datasourceKey = buildDatasourceName('COUNTERPARTY', 'COUNTERPARTY', 'REQ_REP');
|
|
464
468
|
const cleanedConfig = result.datasourceConfig[datasourceKey].TRANSFORMER_CONFIGURATION;
|
|
465
469
|
|
|
466
470
|
// INCLUDE_COLUMNS should only have valid fields
|
|
@@ -485,3 +489,61 @@ TransformFromServerPayload('handles all transformer config types together', asyn
|
|
|
485
489
|
});
|
|
486
490
|
|
|
487
491
|
TransformFromServerPayload.run();
|
|
492
|
+
|
|
493
|
+
const TransformToServerPayload = suite('transformToServerPayload');
|
|
494
|
+
|
|
495
|
+
TransformToServerPayload('omits grouping fields when strategy is NONE', () => {
|
|
496
|
+
const state: any = {
|
|
497
|
+
baseConfig: {
|
|
498
|
+
DESTINATION_IDS: [],
|
|
499
|
+
OUTPUT_DIRECTORY: '/reports',
|
|
500
|
+
},
|
|
501
|
+
datasourceConfig: {
|
|
502
|
+
REQ_REP_COUNTERPARTY_COUNTERPARTY: {
|
|
503
|
+
KEY: 'COUNTERPARTY',
|
|
504
|
+
INPUT_TYPE: 'REQ_REP',
|
|
505
|
+
NAME: 'COUNTERPARTY',
|
|
506
|
+
OUTPUT_TYPE: 'TABLE',
|
|
507
|
+
TRANSFORMER_CONFIGURATION: {},
|
|
508
|
+
GROUPING_STRATEGY: 'NONE',
|
|
509
|
+
GROUP_KEY: null,
|
|
510
|
+
},
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const result = transformToServerPayload(state);
|
|
515
|
+
const ds = result.DATA_SOURCES[0];
|
|
516
|
+
|
|
517
|
+
assert.equal(ds.KEY, 'COUNTERPARTY');
|
|
518
|
+
assert.ok(!('GROUPING_STRATEGY' in ds));
|
|
519
|
+
assert.ok(!('GROUP_KEY' in ds));
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
TransformToServerPayload('includes grouping fields when strategy is not NONE', () => {
|
|
523
|
+
const state: any = {
|
|
524
|
+
baseConfig: {
|
|
525
|
+
DESTINATION_IDS: [],
|
|
526
|
+
OUTPUT_DIRECTORY: '/reports',
|
|
527
|
+
},
|
|
528
|
+
datasourceConfig: {
|
|
529
|
+
REQ_REP_COUNTERPARTY_COUNTERPARTY: {
|
|
530
|
+
KEY: 'COUNTERPARTY',
|
|
531
|
+
INPUT_TYPE: 'REQ_REP',
|
|
532
|
+
NAME: 'COUNTERPARTY',
|
|
533
|
+
OUTPUT_TYPE: 'TABLE',
|
|
534
|
+
TRANSFORMER_CONFIGURATION: {},
|
|
535
|
+
GROUPING_STRATEGY: 'MULTI_SHEET',
|
|
536
|
+
GROUP_KEY: 'some_key',
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
const result = transformToServerPayload(state);
|
|
542
|
+
const ds = result.DATA_SOURCES[0] as any;
|
|
543
|
+
|
|
544
|
+
assert.equal(ds.KEY, 'COUNTERPARTY');
|
|
545
|
+
assert.equal(ds.GROUPING_STRATEGY, 'MULTI_SHEET');
|
|
546
|
+
assert.equal(ds.GROUP_KEY, 'some_key');
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
TransformToServerPayload.run();
|
|
@@ -18,7 +18,14 @@ export function transformToServerPayload(state: ReportingConfig): Genesis.Server
|
|
|
18
18
|
DOCUMENT_TEMPLATE_ID: restBaseConfig.DOCUMENT_TEMPLATE_ID
|
|
19
19
|
? restBaseConfig.DOCUMENT_TEMPLATE_ID
|
|
20
20
|
: null,
|
|
21
|
-
DATA_SOURCES: Object.values(datasourceConfig)
|
|
21
|
+
DATA_SOURCES: Object.values(datasourceConfig).map((ds) => {
|
|
22
|
+
// For NONE case we just don't send it to the server to be backwards compatible
|
|
23
|
+
if (ds.GROUPING_STRATEGY === 'NONE') {
|
|
24
|
+
const { GROUPING_STRATEGY, GROUP_KEY, ...rest } = ds;
|
|
25
|
+
return rest;
|
|
26
|
+
}
|
|
27
|
+
return ds;
|
|
28
|
+
}),
|
|
22
29
|
};
|
|
23
30
|
}
|
|
24
31
|
|
|
@@ -85,10 +92,18 @@ export async function transformFromServerPayload(
|
|
|
85
92
|
|
|
86
93
|
const cleanedDatasources = await Promise.all(
|
|
87
94
|
DATA_SOURCES.map(
|
|
88
|
-
async ({
|
|
95
|
+
async ({
|
|
96
|
+
KEY,
|
|
97
|
+
INPUT_TYPE,
|
|
98
|
+
NAME: DS_NAME,
|
|
99
|
+
OUTPUT_TYPE,
|
|
100
|
+
TRANSFORMER_CONFIGURATION,
|
|
101
|
+
...rest
|
|
102
|
+
}) => {
|
|
89
103
|
try {
|
|
90
|
-
const schema = await getSchema(
|
|
104
|
+
const schema = await getSchema(DS_NAME);
|
|
91
105
|
const validFields = new Set(Object.keys(schema.properties || {}));
|
|
106
|
+
const { GROUPING_STRATEGY, GROUP_KEY } = rest as any;
|
|
92
107
|
|
|
93
108
|
const cleanedConfig = cleanupTransformerConfig(
|
|
94
109
|
TRANSFORMER_CONFIGURATION || {},
|
|
@@ -101,16 +116,21 @@ export async function transformFromServerPayload(
|
|
|
101
116
|
NAME: DS_NAME,
|
|
102
117
|
OUTPUT_TYPE,
|
|
103
118
|
TRANSFORMER_CONFIGURATION: cleanedConfig,
|
|
119
|
+
GROUPING_STRATEGY: GROUPING_STRATEGY || 'NONE',
|
|
120
|
+
GROUP_KEY: GROUP_KEY || null,
|
|
104
121
|
};
|
|
105
122
|
} catch (error) {
|
|
106
123
|
// If schema fetch fails, log warning but keep original config
|
|
107
124
|
console.warn(`Failed to fetch schema for ${KEY}, skipping cleanup:`, error);
|
|
125
|
+
const { GROUPING_STRATEGY, GROUP_KEY } = rest as any;
|
|
108
126
|
return {
|
|
109
127
|
KEY,
|
|
110
128
|
INPUT_TYPE,
|
|
111
129
|
NAME: DS_NAME,
|
|
112
130
|
OUTPUT_TYPE,
|
|
113
131
|
TRANSFORMER_CONFIGURATION: TRANSFORMER_CONFIGURATION || {},
|
|
132
|
+
GROUPING_STRATEGY: GROUPING_STRATEGY || 'NONE',
|
|
133
|
+
GROUP_KEY: GROUP_KEY || null,
|
|
114
134
|
};
|
|
115
135
|
}
|
|
116
136
|
},
|
|
@@ -122,7 +142,7 @@ export async function transformFromServerPayload(
|
|
|
122
142
|
datasourceConfig: cleanedDatasources.reduce(
|
|
123
143
|
(acum, ds) => ({
|
|
124
144
|
...acum,
|
|
125
|
-
[buildDatasourceName(ds.NAME, ds.INPUT_TYPE)]: ds,
|
|
145
|
+
[buildDatasourceName(ds.KEY, ds.NAME, ds.INPUT_TYPE)]: ds,
|
|
126
146
|
}),
|
|
127
147
|
{},
|
|
128
148
|
),
|
|
@@ -145,6 +165,10 @@ export function datasourceInputFromDisplay(
|
|
|
145
165
|
else throw new Error(`datasourceInputFromDisplay - Uncaught case ${display}`);
|
|
146
166
|
}
|
|
147
167
|
|
|
148
|
-
export function buildDatasourceName(
|
|
149
|
-
|
|
168
|
+
export function buildDatasourceName(
|
|
169
|
+
alias: string,
|
|
170
|
+
resourceName: string,
|
|
171
|
+
type: DatasourceInputTypes,
|
|
172
|
+
): DatasourceName {
|
|
173
|
+
return `${type}_${resourceName}_${alias}`;
|
|
150
174
|
}
|
|
@@ -29,12 +29,14 @@ ValidateDatasourceConfig('returns ok when single datasource configured', () => {
|
|
|
29
29
|
OUTPUT_FORMAT: 'CSV',
|
|
30
30
|
},
|
|
31
31
|
datasourceConfig: {
|
|
32
|
-
|
|
33
|
-
KEY: '
|
|
34
|
-
NAME: '
|
|
32
|
+
REQ_REP_testSource_testAlias: {
|
|
33
|
+
KEY: 'testAlias',
|
|
34
|
+
NAME: 'testSource',
|
|
35
35
|
INPUT_TYPE: 'REQ_REP',
|
|
36
36
|
OUTPUT_TYPE: 'TABLE',
|
|
37
37
|
TRANSFORMER_CONFIGURATION: {},
|
|
38
|
+
GROUPING_STRATEGY: 'NONE',
|
|
39
|
+
GROUP_KEY: null,
|
|
38
40
|
},
|
|
39
41
|
},
|
|
40
42
|
};
|
|
@@ -53,19 +55,23 @@ ValidateDatasourceConfig('returns ok when multiple datasources and PDF format',
|
|
|
53
55
|
DOCUMENT_TEMPLATE_ID: 'template1',
|
|
54
56
|
},
|
|
55
57
|
datasourceConfig: {
|
|
56
|
-
|
|
57
|
-
KEY: '
|
|
58
|
-
NAME: '
|
|
58
|
+
REQ_REP_source1_alias1: {
|
|
59
|
+
KEY: 'alias1',
|
|
60
|
+
NAME: 'source1',
|
|
59
61
|
INPUT_TYPE: 'REQ_REP',
|
|
60
62
|
OUTPUT_TYPE: 'TABLE',
|
|
61
63
|
TRANSFORMER_CONFIGURATION: {},
|
|
64
|
+
GROUPING_STRATEGY: 'NONE',
|
|
65
|
+
GROUP_KEY: null,
|
|
62
66
|
},
|
|
63
|
-
|
|
64
|
-
KEY: '
|
|
65
|
-
NAME: '
|
|
67
|
+
REQ_REP_source2_alias2: {
|
|
68
|
+
KEY: 'alias2',
|
|
69
|
+
NAME: 'source2',
|
|
66
70
|
INPUT_TYPE: 'REQ_REP',
|
|
67
71
|
OUTPUT_TYPE: 'TABLE',
|
|
68
72
|
TRANSFORMER_CONFIGURATION: {},
|
|
73
|
+
GROUPING_STRATEGY: 'NONE',
|
|
74
|
+
GROUP_KEY: null,
|
|
69
75
|
},
|
|
70
76
|
},
|
|
71
77
|
};
|
|
@@ -86,19 +92,23 @@ ValidateDatasourceConfig(
|
|
|
86
92
|
DOCUMENT_TEMPLATE_ID: 'template1',
|
|
87
93
|
},
|
|
88
94
|
datasourceConfig: {
|
|
89
|
-
|
|
90
|
-
KEY: '
|
|
91
|
-
NAME: '
|
|
95
|
+
REQ_REP_source1_alias1: {
|
|
96
|
+
KEY: 'alias1',
|
|
97
|
+
NAME: 'source1',
|
|
92
98
|
INPUT_TYPE: 'REQ_REP',
|
|
93
99
|
OUTPUT_TYPE: 'TABLE',
|
|
94
100
|
TRANSFORMER_CONFIGURATION: {},
|
|
101
|
+
GROUPING_STRATEGY: 'NONE',
|
|
102
|
+
GROUP_KEY: null,
|
|
95
103
|
},
|
|
96
|
-
|
|
97
|
-
KEY: '
|
|
98
|
-
NAME: '
|
|
104
|
+
REQ_REP_source2_alias2: {
|
|
105
|
+
KEY: 'alias2',
|
|
106
|
+
NAME: 'source2',
|
|
99
107
|
INPUT_TYPE: 'REQ_REP',
|
|
100
108
|
OUTPUT_TYPE: 'TABLE',
|
|
101
109
|
TRANSFORMER_CONFIGURATION: {},
|
|
110
|
+
GROUPING_STRATEGY: 'NONE',
|
|
111
|
+
GROUP_KEY: null,
|
|
102
112
|
},
|
|
103
113
|
},
|
|
104
114
|
};
|
|
@@ -120,19 +130,23 @@ ValidateDatasourceConfig(
|
|
|
120
130
|
DOCUMENT_TEMPLATE_ID: undefined,
|
|
121
131
|
},
|
|
122
132
|
datasourceConfig: {
|
|
123
|
-
|
|
124
|
-
KEY: '
|
|
125
|
-
NAME: '
|
|
133
|
+
REQ_REP_source1_alias1: {
|
|
134
|
+
KEY: 'alias1',
|
|
135
|
+
NAME: 'source1',
|
|
126
136
|
INPUT_TYPE: 'REQ_REP',
|
|
127
137
|
OUTPUT_TYPE: 'TABLE',
|
|
128
138
|
TRANSFORMER_CONFIGURATION: {},
|
|
139
|
+
GROUPING_STRATEGY: 'NONE',
|
|
140
|
+
GROUP_KEY: null,
|
|
129
141
|
},
|
|
130
|
-
|
|
131
|
-
KEY: '
|
|
132
|
-
NAME: '
|
|
142
|
+
REQ_REP_source2_alias2: {
|
|
143
|
+
KEY: 'alias2',
|
|
144
|
+
NAME: 'source2',
|
|
133
145
|
INPUT_TYPE: 'REQ_REP',
|
|
134
146
|
OUTPUT_TYPE: 'TABLE',
|
|
135
147
|
TRANSFORMER_CONFIGURATION: {},
|
|
148
|
+
GROUPING_STRATEGY: 'NONE',
|
|
149
|
+
GROUP_KEY: null,
|
|
136
150
|
},
|
|
137
151
|
},
|
|
138
152
|
};
|