@contrail/flexplm 1.1.35 → 1.1.37
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/lib/entity-processor/base-entity-processor.d.ts +3 -0
- package/lib/entity-processor/base-entity-processor.js +35 -0
- package/lib/util/map-utils.d.ts +1 -1
- package/lib/util/map-utils.js +2 -2
- package/package.json +2 -2
- package/src/entity-processor/base-entity-processor.ts +55 -0
- package/src/util/map-utils.ts +4 -3
|
@@ -31,4 +31,7 @@ export declare abstract class BaseEntityProcessor {
|
|
|
31
31
|
getOutboundEntityUpdates(event: any, flexResponse: any): Promise<any>;
|
|
32
32
|
handleOutgoingDelete(entityType: any, event: any): Promise<void>;
|
|
33
33
|
protected abstract getOutgoingUpsertPayload(entityType: any, event: any): Promise<EntityPayloadType>;
|
|
34
|
+
protected triggerSendEvent(triggerKey: string, event: any): Promise<any>;
|
|
35
|
+
protected sendUpsertToFlexPLM(event: any): Promise<any>;
|
|
36
|
+
protected getEntityUpsertPayload(event: any): Promise<EntityPayloadType>;
|
|
34
37
|
}
|
|
@@ -133,6 +133,8 @@ class BaseEntityProcessor {
|
|
|
133
133
|
return await this.handleOutgoingUpsert(entityType, event);
|
|
134
134
|
case 'delete':
|
|
135
135
|
return await this.handleOutgoingDelete(entityType, event);
|
|
136
|
+
case 'sendUpsertToFlexPLM':
|
|
137
|
+
return await this.sendUpsertToFlexPLM(event);
|
|
136
138
|
default:
|
|
137
139
|
console.log(UNSUPPORTED_TYPE);
|
|
138
140
|
return {
|
|
@@ -171,5 +173,38 @@ class BaseEntityProcessor {
|
|
|
171
173
|
async handleOutgoingDelete(entityType, event) {
|
|
172
174
|
console.warn('delete is not configured', entityType, event.oldData);
|
|
173
175
|
}
|
|
176
|
+
async triggerSendEvent(triggerKey, event) {
|
|
177
|
+
const newEvent = {
|
|
178
|
+
entityName: 'event-workflow-request',
|
|
179
|
+
object: {
|
|
180
|
+
triggerKey,
|
|
181
|
+
event
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const response = await this.entities.create(newEvent);
|
|
185
|
+
return response;
|
|
186
|
+
}
|
|
187
|
+
async sendUpsertToFlexPLM(event) {
|
|
188
|
+
const payload = await this.getEntityUpsertPayload(event);
|
|
189
|
+
if (!payload) {
|
|
190
|
+
const message = 'No payload to send to FlexPLM';
|
|
191
|
+
console.log(message);
|
|
192
|
+
return {
|
|
193
|
+
status: 500,
|
|
194
|
+
data: { message }
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
;
|
|
198
|
+
const flexResponse = await new flexplm_connect_1.FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
199
|
+
const outboundEntityUpdates = await this.getOutboundEntityUpdates(event, flexResponse);
|
|
200
|
+
if (outboundEntityUpdates) {
|
|
201
|
+
flexResponse['outboundEntityUpdates'] = outboundEntityUpdates;
|
|
202
|
+
}
|
|
203
|
+
return flexResponse;
|
|
204
|
+
}
|
|
205
|
+
async getEntityUpsertPayload(event) {
|
|
206
|
+
console.warn('getEntityUpsertPayload is not configured', JSON.stringify(event));
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
174
209
|
}
|
|
175
210
|
exports.BaseEntityProcessor = BaseEntityProcessor;
|
package/lib/util/map-utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MapFileUtil } from '@contrail/transform-data';
|
|
2
2
|
export declare class MapUtil {
|
|
3
|
-
static applyTransformMap(transformMapFile: any, mapFileUtil: any, data: any, mapSectionKey: string, direction: string): Promise<any>;
|
|
3
|
+
static applyTransformMap(transformMapFile: any, mapFileUtil: any, data: any, mapSectionKey: string, direction: string, transformTaskOrderKey?: string): Promise<any>;
|
|
4
4
|
static getMapKey(transformMapFile: any, mapFileUtil: MapFileUtil, data: any, type: string, direction: string): Promise<string>;
|
|
5
5
|
static getFullMapSection(transformMapFile: string, mapFileUtil: MapFileUtil, mapSectionKey: string): Promise<any>;
|
|
6
6
|
}
|
package/lib/util/map-utils.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MapUtil = void 0;
|
|
4
4
|
class MapUtil {
|
|
5
|
-
static async applyTransformMap(transformMapFile, mapFileUtil, data, mapSectionKey, direction) {
|
|
6
|
-
return await mapFileUtil.applyTransformMap(transformMapFile, data, mapSectionKey, direction);
|
|
5
|
+
static async applyTransformMap(transformMapFile, mapFileUtil, data, mapSectionKey, direction, transformTaskOrderKey = 'transformOrder') {
|
|
6
|
+
return await mapFileUtil.applyTransformMap(transformMapFile, data, mapSectionKey, direction, transformTaskOrderKey);
|
|
7
7
|
}
|
|
8
8
|
static async getMapKey(transformMapFile, mapFileUtil, data, type, direction) {
|
|
9
9
|
return await mapFileUtil.getMapKey(transformMapFile, data, type, direction);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/flexplm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.37",
|
|
4
4
|
"description": "Library used for integration with flexplm.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@contrail/app-framework": "^1.2.4",
|
|
42
42
|
"@contrail/sdk": "^1.3.7",
|
|
43
|
-
"@contrail/transform-data": "^1.0.
|
|
43
|
+
"@contrail/transform-data": "^1.0.15",
|
|
44
44
|
"axios": "^1.4.0",
|
|
45
45
|
"p-limit": "^3.1.0"
|
|
46
46
|
}
|
|
@@ -176,6 +176,8 @@ export abstract class BaseEntityProcessor {
|
|
|
176
176
|
return await this.handleOutgoingUpsert(entityType, event);
|
|
177
177
|
case 'delete':
|
|
178
178
|
return await this.handleOutgoingDelete(entityType, event);
|
|
179
|
+
case 'sendUpsertToFlexPLM':
|
|
180
|
+
return await this.sendUpsertToFlexPLM(event);
|
|
179
181
|
default:
|
|
180
182
|
console.log(UNSUPPORTED_TYPE);
|
|
181
183
|
return {
|
|
@@ -223,4 +225,57 @@ export abstract class BaseEntityProcessor {
|
|
|
223
225
|
|
|
224
226
|
// This method must be implemented by derived classes
|
|
225
227
|
protected abstract getOutgoingUpsertPayload(entityType, event): Promise<EntityPayloadType>;
|
|
228
|
+
|
|
229
|
+
/** Create a new event-workflow-request to rerun sending the entity to FlexPLM
|
|
230
|
+
* The event must contain any information needed to ensure it is put in the correct queue for the entity
|
|
231
|
+
*
|
|
232
|
+
* @param triggerKey Ex: event.entityType + '|sendUpsertToFlexPLM'
|
|
233
|
+
* @param event
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
protected async triggerSendEvent(triggerKey: string, event: any) {
|
|
238
|
+
const newEvent = {
|
|
239
|
+
entityName: 'event-workflow-request',
|
|
240
|
+
object: {
|
|
241
|
+
triggerKey,
|
|
242
|
+
event
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const response = await this.entities.create(newEvent);
|
|
246
|
+
|
|
247
|
+
return response;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Sends the current state of the entity to FlexPLM.
|
|
251
|
+
* So any changes made in Vibe between the event being generated and the event being processed are sent to FlexPLM.
|
|
252
|
+
*
|
|
253
|
+
* @param event must contain entityType, id; which are used to query for the entity
|
|
254
|
+
* @returns results of sending the entity to FlexPLM
|
|
255
|
+
*/
|
|
256
|
+
protected async sendUpsertToFlexPLM(event) {
|
|
257
|
+
const payload = await this.getEntityUpsertPayload(event);
|
|
258
|
+
if(!payload){
|
|
259
|
+
const message = 'No payload to send to FlexPLM';
|
|
260
|
+
console.log(message);
|
|
261
|
+
return {
|
|
262
|
+
status: 500,
|
|
263
|
+
data: {message}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
const flexResponse: any = await new FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
267
|
+
|
|
268
|
+
const outboundEntityUpdates = await this.getOutboundEntityUpdates(event, flexResponse);
|
|
269
|
+
if(outboundEntityUpdates){
|
|
270
|
+
flexResponse['outboundEntityUpdates'] = outboundEntityUpdates;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return flexResponse;
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
protected async getEntityUpsertPayload(event: any): Promise<EntityPayloadType> {
|
|
278
|
+
console.warn('getEntityUpsertPayload is not configured', JSON.stringify(event));
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
226
281
|
}
|
package/src/util/map-utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MapFileUtil
|
|
1
|
+
import { MapFileUtil } from '@contrail/transform-data';
|
|
2
2
|
export class MapUtil {
|
|
3
3
|
/** Transforms the data, assumes mapSectionKey has been correctly determined.
|
|
4
4
|
*
|
|
@@ -7,10 +7,11 @@ export class MapUtil {
|
|
|
7
7
|
* @param data
|
|
8
8
|
* @param mapSectionKey key for section of map file
|
|
9
9
|
* @param direction vibe2flex or flex2vibe
|
|
10
|
+
* @param transformTaskOrderKey key for the list of tasks to be processed. default is 'transformOrder'
|
|
10
11
|
* @returns The converted data
|
|
11
12
|
*/
|
|
12
|
-
static async applyTransformMap(transformMapFile, mapFileUtil, data: any, mapSectionKey: string, direction: string) {
|
|
13
|
-
return await mapFileUtil.applyTransformMap(transformMapFile, data, mapSectionKey, direction);
|
|
13
|
+
static async applyTransformMap(transformMapFile, mapFileUtil, data: any, mapSectionKey: string, direction: string, transformTaskOrderKey: string = 'transformOrder'): Promise<any> {
|
|
14
|
+
return await mapFileUtil.applyTransformMap(transformMapFile, data, mapSectionKey, direction, transformTaskOrderKey);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/** Returns the mapKey based on the 'typeConversion' section of the map file.
|