@contrail/flexplm 1.1.13 → 1.1.15
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/.github/pull_request_template.md +30 -0
- package/.github/workflows/flexplm-lib.yml +27 -0
- package/lib/flexplm-utils.spec.d.ts +1 -0
- package/lib/flexplm-utils.spec.js +26 -0
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -0
- package/lib/publish/base-process-publish-assortment.spec.js +1053 -0
- package/lib/util/config-defaults.spec.d.ts +1 -0
- package/lib/util/config-defaults.spec.js +264 -0
- package/lib/util/data-converter.d.ts +4 -0
- package/lib/util/data-converter.js +88 -1
- package/lib/util/data-converter.spec.d.ts +1 -0
- package/lib/util/data-converter.spec.js +591 -0
- package/lib/util/map-utils.d.ts +2 -2
- package/lib/util/map-utils.js +5 -28
- package/lib/util/map-utils.spec.d.ts +1 -0
- package/lib/util/map-utils.spec.js +89 -0
- package/lib/util/thumbnail-util.spec.d.ts +1 -0
- package/lib/util/thumbnail-util.spec.js +132 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +21 -0
- package/lib/util/type-conversion-utils.d.ts +7 -0
- package/lib/util/type-conversion-utils.js +88 -4
- package/lib/util/type-conversion-utils.spec.d.ts +1 -0
- package/lib/util/type-conversion-utils.spec.js +547 -0
- package/lib/util/type-defaults.d.ts +5 -0
- package/lib/util/type-defaults.js +66 -0
- package/lib/util/type-defaults.spec.d.ts +1 -0
- package/lib/util/type-defaults.spec.js +460 -0
- package/lib/util/type-utils.spec.d.ts +1 -0
- package/lib/util/type-utils.spec.js +190 -0
- package/package.json +2 -2
- package/publish.bat +5 -0
- package/publish.sh +5 -0
- package/src/entity-processor/base-entity-processor.ts +183 -0
- package/src/flexplm-request.ts +28 -0
- package/src/flexplm-utils.spec.ts +27 -0
- package/src/flexplm-utils.ts +29 -0
- package/src/index.ts +20 -0
- package/src/interfaces/interfaces.ts +120 -0
- package/src/interfaces/item-family-changes.ts +67 -0
- package/src/interfaces/publish-change-data.ts +43 -0
- package/src/publish/base-process-publish-assortment-callback.ts +23 -0
- package/src/publish/base-process-publish-assortment.spec.ts +1239 -0
- package/src/publish/base-process-publish-assortment.ts +1024 -0
- package/src/publish/mockData.ts +4561 -0
- package/src/transform/identifier-conversion.ts +226 -0
- package/src/util/config-defaults.spec.ts +315 -0
- package/src/util/config-defaults.ts +79 -0
- package/src/util/data-converter-spec-mockData.ts +231 -0
- package/src/util/data-converter.spec.ts +872 -0
- package/src/util/data-converter.ts +507 -0
- package/src/util/federation.ts +172 -0
- package/src/util/flexplm-connect.ts +169 -0
- package/src/util/logger-config.ts +20 -0
- package/src/util/map-util-spec-mockData.ts +231 -0
- package/src/util/map-utils.spec.ts +103 -0
- package/src/util/map-utils.ts +40 -0
- package/src/util/mockData.ts +98 -0
- package/src/util/thumbnail-util.spec.ts +152 -0
- package/src/util/thumbnail-util.ts +128 -0
- package/src/util/type-conversion-utils-spec-mockData.ts +238 -0
- package/src/util/type-conversion-utils.spec.ts +601 -0
- package/src/util/type-conversion-utils.ts +345 -0
- package/src/util/type-defaults.spec.ts +592 -0
- package/src/util/type-defaults.ts +261 -0
- package/src/util/type-utils.spec.ts +227 -0
- package/src/util/type-utils.ts +124 -0
- package/tsconfig.json +27 -0
- package/tslint.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_defaults_1 = require("./config-defaults");
|
|
4
|
+
let entityObject = {};
|
|
5
|
+
jest.mock('@contrail/sdk', () => {
|
|
6
|
+
return {
|
|
7
|
+
Entities: class {
|
|
8
|
+
get() {
|
|
9
|
+
return entityObject;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
let fetchJson = {};
|
|
15
|
+
global.fetch = jest.fn().mockImplementation(() => {
|
|
16
|
+
return Promise.resolve({
|
|
17
|
+
json: () => Promise.resolve(fetchJson)
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('all tests', () => {
|
|
21
|
+
describe('setConfigDefaults - required values', () => {
|
|
22
|
+
it('missing apiHost', async () => {
|
|
23
|
+
const config = {
|
|
24
|
+
userName: 'vibeiq',
|
|
25
|
+
password: 'vibeiq',
|
|
26
|
+
plmEnviornment: 'SB'
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
expect(e.message).toEqual(config_defaults_1.ConfigDefaults.NEED_CONFIG_VALUES);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
it('missing userName', async () => {
|
|
36
|
+
const config = {
|
|
37
|
+
apiHost: 'http://test.com',
|
|
38
|
+
password: 'vibeiq',
|
|
39
|
+
plmEnviornment: 'SB'
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
expect(e.message).toEqual(config_defaults_1.ConfigDefaults.NEED_CONFIG_VALUES);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
it('missing password', async () => {
|
|
49
|
+
const config = {
|
|
50
|
+
apiHost: 'http://test.com',
|
|
51
|
+
userName: 'vibeiq',
|
|
52
|
+
plmEnviornment: 'SB'
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
expect(e.message).toEqual(config_defaults_1.ConfigDefaults.NEED_CONFIG_VALUES);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
it('missing plmEnviornment', async () => {
|
|
62
|
+
const config = {
|
|
63
|
+
apiHost: 'http://test.com',
|
|
64
|
+
userName: 'vibeiq',
|
|
65
|
+
password: 'vibeiq',
|
|
66
|
+
};
|
|
67
|
+
try {
|
|
68
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(config);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
expect(e.message).toEqual(config_defaults_1.ConfigDefaults.NEED_CONFIG_VALUES);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('userName & password as functions', () => {
|
|
76
|
+
const config = {
|
|
77
|
+
apiHost: 'http://test.com',
|
|
78
|
+
userName: 'vibeiq',
|
|
79
|
+
password: 'vibeiq',
|
|
80
|
+
plmEnviornment: 'SB'
|
|
81
|
+
};
|
|
82
|
+
it('userName as function', async () => {
|
|
83
|
+
const startConfig = Object.assign({}, config, { userName: 'newName' });
|
|
84
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
85
|
+
expect(fcConfig.userName()).toEqual('newName');
|
|
86
|
+
});
|
|
87
|
+
it('password as function', async () => {
|
|
88
|
+
const startConfig = Object.assign({}, config, { password: 'strange' });
|
|
89
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
90
|
+
expect(fcConfig.password()).toEqual('strange');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe('setConfigDefaults-setting defaults', () => {
|
|
94
|
+
const config = {
|
|
95
|
+
apiHost: 'http://test.com',
|
|
96
|
+
userName: 'vibeiq',
|
|
97
|
+
password: 'vibeiq',
|
|
98
|
+
plmEnviornment: 'SB'
|
|
99
|
+
};
|
|
100
|
+
it('urlContext-get default', async () => {
|
|
101
|
+
const startConfig = Object.assign({}, config);
|
|
102
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
103
|
+
expect(fcConfig.urlContext).toEqual('/Windchill');
|
|
104
|
+
});
|
|
105
|
+
it('urlContext-set value', async () => {
|
|
106
|
+
const startConfig = Object.assign({}, config);
|
|
107
|
+
startConfig['urlContext'] = '/FlexPLM';
|
|
108
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
109
|
+
expect(fcConfig.urlContext).toEqual('/FlexPLM');
|
|
110
|
+
});
|
|
111
|
+
it('sendMode-ASYNC_PUBLISH_SEASON-get default', async () => {
|
|
112
|
+
const startConfig = Object.assign({}, config);
|
|
113
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
114
|
+
expect(fcConfig['sendMode']['ASYNC_PUBLISH_SEASON']).toEqual('vibeiqfile');
|
|
115
|
+
});
|
|
116
|
+
it('sendMode-ASYNC_PUBLISH_SEASON-set value', async () => {
|
|
117
|
+
const startConfig = Object.assign({}, config);
|
|
118
|
+
startConfig['sendMode'] = { ASYNC_PUBLISH_SEASON: 'vibeiqfile-dontsendtoflexplm' };
|
|
119
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
120
|
+
expect(fcConfig['sendMode']['ASYNC_PUBLISH_SEASON']).toEqual('vibeiqfile-dontsendtoflexplm');
|
|
121
|
+
});
|
|
122
|
+
it('sendMode-NO_DEFAULT-get default', async () => {
|
|
123
|
+
const startConfig = Object.assign({}, config);
|
|
124
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
125
|
+
expect(fcConfig['sendMode']['NO_DEFAULT']).toBeUndefined();
|
|
126
|
+
});
|
|
127
|
+
it('sendMode-NO_DEFAULT-set value', async () => {
|
|
128
|
+
const startConfig = Object.assign({}, config);
|
|
129
|
+
startConfig['sendMode'] = { NO_DEFAULT: 'vibeiqfile-dontsendtoflexplm' };
|
|
130
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
131
|
+
expect(fcConfig['sendMode']['NO_DEFAULT']).toEqual('vibeiqfile-dontsendtoflexplm');
|
|
132
|
+
});
|
|
133
|
+
it('itemPreDevelopmentLifecycleStages-get default', async () => {
|
|
134
|
+
const startConfig = Object.assign({}, config);
|
|
135
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
136
|
+
expect(fcConfig['itemPreDevelopmentLifecycleStages']).toEqual(['concept']);
|
|
137
|
+
});
|
|
138
|
+
it('itemPreDevelopmentLifecycleStages-set value', async () => {
|
|
139
|
+
const startConfig = Object.assign({}, config);
|
|
140
|
+
const concept = 'concept';
|
|
141
|
+
const development = 'development';
|
|
142
|
+
startConfig['itemPreDevelopmentLifecycleStages'] = concept + ',' + development;
|
|
143
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
144
|
+
const itemPreDevelopmentLifecycleStages = fcConfig['itemPreDevelopmentLifecycleStages'];
|
|
145
|
+
expect(itemPreDevelopmentLifecycleStages instanceof Array).toBeTruthy();
|
|
146
|
+
expect(itemPreDevelopmentLifecycleStages.length).toBe(2);
|
|
147
|
+
expect(itemPreDevelopmentLifecycleStages.includes(concept));
|
|
148
|
+
expect(itemPreDevelopmentLifecycleStages.includes(development));
|
|
149
|
+
});
|
|
150
|
+
it('itemPreDevelopmentLifecycleStages-set value with space', async () => {
|
|
151
|
+
const startConfig = Object.assign({}, config);
|
|
152
|
+
const concept = 'concept';
|
|
153
|
+
const development = 'development';
|
|
154
|
+
startConfig['itemPreDevelopmentLifecycleStages'] = concept + ', ' + development;
|
|
155
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
156
|
+
const itemPreDevelopmentLifecycleStages = fcConfig['itemPreDevelopmentLifecycleStages'];
|
|
157
|
+
expect(itemPreDevelopmentLifecycleStages instanceof Array).toBeTruthy();
|
|
158
|
+
expect(itemPreDevelopmentLifecycleStages.length).toBe(2);
|
|
159
|
+
expect(itemPreDevelopmentLifecycleStages.includes(concept));
|
|
160
|
+
expect(itemPreDevelopmentLifecycleStages.includes(development));
|
|
161
|
+
});
|
|
162
|
+
it('identifierAtts-LCSProduct-get default', async () => {
|
|
163
|
+
const startConfig = Object.assign({}, config);
|
|
164
|
+
const objectClass = 'LCSProduct';
|
|
165
|
+
const expectedAtts = ['name'];
|
|
166
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
167
|
+
const identifierAtts = fcConfig.identifierAtts[objectClass];
|
|
168
|
+
expect(identifierAtts instanceof Array).toBeTruthy();
|
|
169
|
+
expect(identifierAtts.length).toBe(expectedAtts.length);
|
|
170
|
+
for (const att of expectedAtts) {
|
|
171
|
+
expect(identifierAtts.includes(att));
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
it('identifierAtts-LCSProduct-set value', async () => {
|
|
175
|
+
const startConfig = Object.assign({}, config);
|
|
176
|
+
const objectClass = 'LCSProduct';
|
|
177
|
+
const expectedAtts = ['val1', 'val2'];
|
|
178
|
+
startConfig['identifierAtts'] = {};
|
|
179
|
+
startConfig['identifierAtts'][objectClass] = expectedAtts;
|
|
180
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
181
|
+
const identifierAtts = fcConfig.identifierAtts[objectClass];
|
|
182
|
+
expect(identifierAtts instanceof Array).toBeTruthy();
|
|
183
|
+
expect(identifierAtts.length).toBe(expectedAtts.length);
|
|
184
|
+
for (const att of expectedAtts) {
|
|
185
|
+
expect(identifierAtts.includes(att));
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
it('identifierAtts-LCSSeason-get default', async () => {
|
|
189
|
+
const startConfig = Object.assign({}, config);
|
|
190
|
+
const objectClass = 'LCSSeason';
|
|
191
|
+
const expectedAtts = ['flexPLMSeasonName'];
|
|
192
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
193
|
+
const identifierAtts = fcConfig.identifierAtts[objectClass];
|
|
194
|
+
expect(identifierAtts instanceof Array).toBeTruthy();
|
|
195
|
+
expect(identifierAtts.length).toBe(expectedAtts.length);
|
|
196
|
+
for (const att of expectedAtts) {
|
|
197
|
+
expect(identifierAtts.includes(att));
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
it('identifierAtts-LCSSeason-set value', async () => {
|
|
201
|
+
const startConfig = Object.assign({}, config);
|
|
202
|
+
const objectClass = 'LCSSeason';
|
|
203
|
+
const expectedAtts = ['val1', 'val2'];
|
|
204
|
+
startConfig['identifierAtts'] = {};
|
|
205
|
+
startConfig['identifierAtts'][objectClass] = expectedAtts;
|
|
206
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
207
|
+
const identifierAtts = fcConfig.identifierAtts[objectClass];
|
|
208
|
+
expect(identifierAtts instanceof Array).toBeTruthy();
|
|
209
|
+
expect(identifierAtts.length).toBe(expectedAtts.length);
|
|
210
|
+
for (const att of expectedAtts) {
|
|
211
|
+
expect(identifierAtts.includes(att));
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
it('identifierAtts-LCSSKU-get default', async () => {
|
|
215
|
+
const startConfig = Object.assign({}, config);
|
|
216
|
+
const objectClass = 'LCSSKU';
|
|
217
|
+
const expectedAtts = ['optionName'];
|
|
218
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
219
|
+
const identifierAtts = fcConfig.identifierAtts[objectClass];
|
|
220
|
+
expect(identifierAtts instanceof Array).toBeTruthy();
|
|
221
|
+
expect(identifierAtts.length).toBe(expectedAtts.length);
|
|
222
|
+
for (const att of expectedAtts) {
|
|
223
|
+
expect(identifierAtts.includes(att));
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
it('identifierAtts-LCSSKU-set value', async () => {
|
|
227
|
+
const startConfig = Object.assign({}, config);
|
|
228
|
+
const objectClass = 'LCSSKU';
|
|
229
|
+
const expectedAtts = ['val1', 'val2'];
|
|
230
|
+
startConfig['identifierAtts'] = {};
|
|
231
|
+
startConfig['identifierAtts'][objectClass] = expectedAtts;
|
|
232
|
+
const fcConfig = await config_defaults_1.ConfigDefaults.setConfigDefaults(startConfig);
|
|
233
|
+
const identifierAtts = fcConfig.identifierAtts[objectClass];
|
|
234
|
+
expect(identifierAtts instanceof Array).toBeTruthy();
|
|
235
|
+
expect(identifierAtts.length).toBe(expectedAtts.length);
|
|
236
|
+
for (const att of expectedAtts) {
|
|
237
|
+
expect(identifierAtts.includes(att));
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
describe('getConfigFile', () => {
|
|
242
|
+
it('response has test var', async () => {
|
|
243
|
+
fetchJson = { testVar: true };
|
|
244
|
+
entityObject = { downloadUrl: 'http://sss.com' };
|
|
245
|
+
const config = await config_defaults_1.ConfigDefaults.getConfigFile('id-1');
|
|
246
|
+
expect(config).toBeDefined();
|
|
247
|
+
expect(config['testVar']).toBeTruthy();
|
|
248
|
+
});
|
|
249
|
+
it('undefined file object', async () => {
|
|
250
|
+
fetchJson = { testVar: true };
|
|
251
|
+
entityObject = undefined;
|
|
252
|
+
const config = await config_defaults_1.ConfigDefaults.getConfigFile('id-1');
|
|
253
|
+
expect(config).toBeDefined();
|
|
254
|
+
expect(Object.keys(config).length).toEqual(0);
|
|
255
|
+
});
|
|
256
|
+
it('response no downloadUrl', async () => {
|
|
257
|
+
fetchJson = { testVar: true };
|
|
258
|
+
entityObject = {};
|
|
259
|
+
const config = await config_defaults_1.ConfigDefaults.getConfigFile('id-1');
|
|
260
|
+
expect(config).toBeDefined();
|
|
261
|
+
expect(Object.keys(config).length).toEqual(0);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
});
|
|
@@ -7,6 +7,7 @@ export declare class DataConverter {
|
|
|
7
7
|
private transformMapFile;
|
|
8
8
|
private useDisplayForEnumerationMatching;
|
|
9
9
|
private objRefCache;
|
|
10
|
+
private userRefCache;
|
|
10
11
|
constructor(config: FCConfig, mapFileUtil: MapFileUtil);
|
|
11
12
|
getFlexPLMObjectDataFromEvent(event: any, dataToSkip: string[]): Promise<{}>;
|
|
12
13
|
getFlexPLMObjectData(newData: any, dataToSkip: string[], inflateObjRef: boolean): Promise<{}>;
|
|
@@ -19,4 +20,7 @@ export declare class DataConverter {
|
|
|
19
20
|
getEntityValue(prop: any, data: any): Promise<any>;
|
|
20
21
|
setEnumerationKeys(prop: any, nd: any, matchByDisplay: any): any;
|
|
21
22
|
getPersistableChanges(entity: object, changes: object): object;
|
|
23
|
+
setUserListValue(prop: any, nd: any): Promise<any>;
|
|
24
|
+
processGroupMemberCheck(prop: any, userEmail: any): Promise<void>;
|
|
25
|
+
getUserListValue(prop: any, newData: any): Promise<any>;
|
|
22
26
|
}
|
|
@@ -13,6 +13,7 @@ class DataConverter {
|
|
|
13
13
|
this.mapFileUtil = mapFileUtil;
|
|
14
14
|
this.useDisplayForEnumerationMatching = false;
|
|
15
15
|
this.objRefCache = {};
|
|
16
|
+
this.userRefCache = {};
|
|
16
17
|
this.typeUtils = new type_utils_1.TypeUtils();
|
|
17
18
|
this.transformMapFile = this.config['transformMapFile'];
|
|
18
19
|
this.useDisplayForEnumerationMatching = this.config['dataConverter']
|
|
@@ -88,6 +89,9 @@ class DataConverter {
|
|
|
88
89
|
else if ('json' === propertyType) {
|
|
89
90
|
value = nd;
|
|
90
91
|
}
|
|
92
|
+
else if ('userList' === propertyType) {
|
|
93
|
+
value = await this.getUserListValue(prop, newData);
|
|
94
|
+
}
|
|
91
95
|
return value;
|
|
92
96
|
}
|
|
93
97
|
getEnumerationValue(prop, nd) {
|
|
@@ -194,8 +198,13 @@ class DataConverter {
|
|
|
194
198
|
const dataKeys = Object.getOwnPropertyNames(data);
|
|
195
199
|
typeProps = typeProps.filter(prop => dataKeys.includes(prop['slug']));
|
|
196
200
|
for (const prop of typeProps) {
|
|
201
|
+
const propertyType = prop['propertyType'];
|
|
197
202
|
const slug = prop['slug'];
|
|
198
|
-
|
|
203
|
+
let keyName = slug;
|
|
204
|
+
if (propertyType === 'userList') {
|
|
205
|
+
keyName = slug + 'Id';
|
|
206
|
+
}
|
|
207
|
+
entity[keyName] = await this.getEntityValue(prop, data);
|
|
199
208
|
}
|
|
200
209
|
return entity;
|
|
201
210
|
}
|
|
@@ -260,6 +269,9 @@ class DataConverter {
|
|
|
260
269
|
}
|
|
261
270
|
else if ('json' === propertyType) {
|
|
262
271
|
}
|
|
272
|
+
else if ('userList' === propertyType) {
|
|
273
|
+
value = await this.setUserListValue(prop, nd);
|
|
274
|
+
}
|
|
263
275
|
return value;
|
|
264
276
|
}
|
|
265
277
|
setEnumerationKeys(prop, nd, matchByDisplay) {
|
|
@@ -309,5 +321,80 @@ class DataConverter {
|
|
|
309
321
|
}
|
|
310
322
|
return diffValues;
|
|
311
323
|
}
|
|
324
|
+
async setUserListValue(prop, nd) {
|
|
325
|
+
if (!nd?.email) {
|
|
326
|
+
return "";
|
|
327
|
+
}
|
|
328
|
+
if (this.userRefCache[nd.email]) {
|
|
329
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
330
|
+
console.debug('user cache hit: ' + nd.email);
|
|
331
|
+
}
|
|
332
|
+
await this.processGroupMemberCheck(prop, nd.email);
|
|
333
|
+
return this.userRefCache[nd.email];
|
|
334
|
+
}
|
|
335
|
+
const entities = await new sdk_1.Entities().get({
|
|
336
|
+
entityName: 'user-org',
|
|
337
|
+
take: 1000
|
|
338
|
+
});
|
|
339
|
+
const result = entities.find(element => element['userEmail'] === nd.email);
|
|
340
|
+
const value = (result) ? result.id : undefined;
|
|
341
|
+
if (value) {
|
|
342
|
+
this.userRefCache[nd.email] = value;
|
|
343
|
+
await this.processGroupMemberCheck(prop, nd.email);
|
|
344
|
+
}
|
|
345
|
+
return value;
|
|
346
|
+
}
|
|
347
|
+
async processGroupMemberCheck(prop, userEmail) {
|
|
348
|
+
let arrUserList = [];
|
|
349
|
+
if (this.userRefCache[prop.typePropertyUserListId]) {
|
|
350
|
+
arrUserList = this.userRefCache[prop.typePropertyUserListId];
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
const userListResult = await new sdk_1.Entities().get({
|
|
354
|
+
entityName: 'user-list',
|
|
355
|
+
id: prop.typePropertyUserListId
|
|
356
|
+
});
|
|
357
|
+
if (userListResult && Object.keys(userListResult).length) {
|
|
358
|
+
arrUserList = userListResult.userList;
|
|
359
|
+
this.userRefCache[prop.typePropertyUserListId] = arrUserList;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (arrUserList.length) {
|
|
363
|
+
const result = arrUserList.find(element => element['display'] === userEmail);
|
|
364
|
+
if (!result) {
|
|
365
|
+
console.warn(`The passed in user ${userEmail} in property slug ${prop.slug} should be a member of the group associated with the property 'typePropertyUserListId'`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async getUserListValue(prop, newData) {
|
|
370
|
+
const slug = prop['slug'];
|
|
371
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
372
|
+
console.debug('getUserListValue-prop: ' + slug);
|
|
373
|
+
}
|
|
374
|
+
const entityId = newData[slug + 'Id'];
|
|
375
|
+
if (!entityId) {
|
|
376
|
+
return {};
|
|
377
|
+
}
|
|
378
|
+
if (this.userRefCache[entityId]) {
|
|
379
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
380
|
+
console.debug('user cache hit: ' + entityId);
|
|
381
|
+
}
|
|
382
|
+
return this.userRefCache[entityId];
|
|
383
|
+
}
|
|
384
|
+
const entities = await new sdk_1.Entities().get({
|
|
385
|
+
entityName: 'user-org',
|
|
386
|
+
id: entityId
|
|
387
|
+
});
|
|
388
|
+
const value = (entities) ? {
|
|
389
|
+
email: entities.userEmail,
|
|
390
|
+
firstName: entities.first,
|
|
391
|
+
lastName: entities.last,
|
|
392
|
+
isSsoUser: entities.isSsoUser,
|
|
393
|
+
} : undefined;
|
|
394
|
+
if (value) {
|
|
395
|
+
this.userRefCache[entityId] = value;
|
|
396
|
+
}
|
|
397
|
+
return value;
|
|
398
|
+
}
|
|
312
399
|
}
|
|
313
400
|
exports.DataConverter = DataConverter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|