@izara_project/izara-core-generate-service-code 1.0.73 → 1.0.75

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.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +3 -0
  3. package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +100 -28
  4. package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +2 -0
  5. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +2 -0
  6. package/src/emit/crud/emitCrudApplicationArtifacts.js +2 -2
  7. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +43 -2
  8. package/src/emit/crud/templates/CreateComplete_HdrSqs.ejs +99 -0
  9. package/src/emit/crud/templates/CreateComplete_Main.ejs +188 -0
  10. package/src/emit/crud/templates/DeleteComplete_HdrSqs.ejs +99 -0
  11. package/src/emit/crud/templates/DeleteComplete_Main.ejs +188 -0
  12. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +1 -1
  13. package/src/emit/crud/templates/UpdateComplete_HdrSqs.ejs +99 -0
  14. package/src/emit/crud/templates/UpdateComplete_Main.ejs +188 -0
  15. package/src/emit/custom/customFlows.js +56 -0
  16. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +24 -9
  17. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +1 -1
  18. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +2 -1
  19. package/src/emit/function/functionYamlArtifact.js +8 -3
  20. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +21 -1
  21. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +1 -1
  22. package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +99 -0
  23. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +99 -100
  24. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +5 -14
  25. package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +99 -0
  26. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +98 -99
  27. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +7 -16
  28. package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +99 -0
  29. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +93 -85
  30. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +6 -24
  31. package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +99 -0
  32. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +10 -4
  33. package/src/emit/relationship/templates/GetRelationship_Main.ejs +2 -20
  34. package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +99 -0
  35. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +101 -104
  36. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +6 -15
  37. package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +99 -0
  38. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +92 -110
  39. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +6 -15
  40. package/src/emit/resource/emitResourceArtifacts.js +25 -1
  41. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +3 -0
  42. package/src/emit/shared/templates/FindData_Main.ejs +1 -1
  43. package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +1 -1
  44. package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +2 -1
  45. package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +1 -1
  46. package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +2 -1
  47. package/src/emit/system/emitSystemWebSocketArtifacts.js +54 -2
  48. package/src/emit/system/templates/RegisterComplete_HdrSqs.ejs +64 -0
  49. package/src/emit/system/templates/RegisterComplete_Main.ejs +154 -0
  50. package/src/emit/system/templates/RegisterComplete_Yaml.ejs +17 -0
  51. package/src/emit/system/templates/RegisterWbs_Yaml.ejs +7 -0
  52. package/src/emit/system/templates/Register_HdrWbs.ejs +56 -0
  53. package/src/emit/system/templates/Register_Main.ejs +148 -0
  54. package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +2 -0
  55. package/test/crudApplicationArtifacts.test.js +22 -0
  56. package/test/customFlowApplicationArtifacts.test.js +147 -1
  57. package/test/functionYamlArtifact.test.js +5 -2
  58. package/test/publicApi.test.js +50 -0
  59. package/test/relationshipApplicationArtifacts.test.js +42 -8
  60. package/test/resourceArtifacts.test.js +54 -16
@@ -19,7 +19,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
19
19
 
20
20
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
21
  import snsSharedLib from '@izara_project/izara-core-library-sns';
22
- import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
22
+
23
23
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
24
24
 
25
25
  import { sns } from '@izara_project/izara-core-library-external-request';
@@ -36,16 +36,22 @@ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
36
36
 
37
37
  export default async function updateRelationshipComplete(
38
38
  _izContext,
39
- returnValue,
40
- status,
41
- errorsFound,
42
- graphServiceTag,
39
+ requestParams,
43
40
  passBackProperties = {}
44
41
  // callingFlowConfig = {}
45
42
  ) {
46
43
  try {
44
+ const {
45
+ returnValue,
46
+ parentFlowId,
47
+ status,
48
+ errorsFound,
49
+ graphServiceTag
50
+ } = requestParams;
51
+
47
52
  _izContext.logger.debug('Function:updateRelationshipComplete', {
48
53
  returnValue: returnValue,
54
+ parentFlowId: parentFlowId,
49
55
  status: status,
50
56
  errorsFound: errorsFound,
51
57
  graphServiceTag: graphServiceTag,
@@ -53,120 +59,96 @@ export default async function updateRelationshipComplete(
53
59
  // callingFlowConfig: callingFlowConfig
54
60
  });
55
61
 
56
- let linkTypeId;
57
- // start create awaitingStepId
58
- if (
59
- returnValue.requestParams.hasOwnProperty('secondObject') &&
60
- Object.values(returnValue.requestParams.secondObject.objType).length > 0
61
- ) {
62
- linkTypeId = createLinkTypeId(
62
+ const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
63
+ parentFlowId || returnValue?.parentFlowId, // hash id
64
+ PREFIX.updateRel // prefix, use constant further
65
+ );
66
+
67
+ const pending =
68
+ await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(
63
69
  _izContext,
64
- returnValue.requestParams.firstObject.objType,
65
- returnValue.requestParams.secondObject.objType,
66
- returnValue.requestParams.relType,
67
- returnValue.requestParams.relationshipDirection
70
+ awaitingStepId
68
71
  );
69
- } else {
70
- linkTypeId = hash({
71
- firstObject: returnValue.requestParams.firstObject.objType,
72
- relType: returnValue.requestParams.relType
73
- });
74
- }
72
+ _izContext.logger.debug('[UpdateRelationshipComplete] awaiting step', {
73
+ awaitingStepId,
74
+ pending
75
+ });
75
76
 
76
- let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
77
- hash({
78
- linkTypeId,
79
- relId: returnValue.requestParams.relId,
80
- relationshipProperties:
81
- returnValue.requestParams.relationshipProperties,
82
- graphServiceTag: graphServiceTag
83
- }), // hash id
84
- PREFIX.updateRel // prefix, use constant further
85
- );
77
+ if (!pending) {
78
+ _izContext.logger.warn(
79
+ `No pending step found for awaitingStepId: ${awaitingStepId}`
80
+ );
81
+ return { returnValue, status, errorsFound };
82
+ }
86
83
 
87
- let updateRelPendingObjects = await dynamodbSharedLib.query(
88
- _izContext,
89
- await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
84
+ const result =
85
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
86
+ _izContext,
87
+ pending.pendingStepId,
88
+ awaitingStepId,
89
+ errorsFound
90
+ );
91
+ _izContext.logger.debug(
92
+ '[UpdateRelationshipComplete] all awaiting steps result',
90
93
  {
91
- awaitingStepId: awaitingStepId
94
+ isComplete: result.isComplete,
95
+ awaitingStepId,
96
+ pendingStepId: pending.pendingStepId
92
97
  }
93
98
  );
94
- _izContext.logger.debug(
95
- 'record of updateRelPendingObjects ::',
96
- updateRelPendingObjects
97
- );
98
99
 
99
- await Promise.all(
100
- updateRelPendingObjects.Items.map(async ({ pendingStepId }) => {
101
- if (
102
- await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
103
- _izContext,
104
- pendingStepId, // task waiting
105
- awaitingStepId,
106
- errorsFound
107
- )
108
- ) {
109
- _izContext.logger.debug('finished all awaitingStep');
110
-
111
- let updateCompleteMsg = {
112
- relId: returnValue.requestParams.relId,
113
- relType: returnValue.requestParams.relType,
114
- status: status,
115
- errorsFound: errorsFound
116
- //(<inUpdateCompleteMsg>)
117
- //(</inUpdateCompleteMsg>)
118
- };
119
-
120
- updateCompleteMsg =
121
- callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
122
- passBackProperties,
123
- updateCompleteMsg
124
- );
125
- _izContext.logger.debug(
126
- 'After addCallingFlowToSnsResponseMessageObject',
127
- updateCompleteMsg
128
- );
129
-
130
- let messageAttributes =
131
- callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
132
- passBackProperties,
133
- {}
134
- );
135
- _izContext.logger.debug(
136
- 'After addCallingFlowToSnsResponseMessageAttributes',
137
- updateCompleteMsg
138
- );
139
-
140
- let sendMessageToOutUpdateRelationshipComplete = {
141
- Message: JSON.stringify(updateCompleteMsg),
142
- MessageAttributes: sns.createStringMessageAttributes(
143
- _izContext,
144
- messageAttributes
145
- ),
146
- TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
147
- _izContext,
148
- TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete
149
- )
150
- };
151
- _izContext.logger.debug(
152
- 'Send message to OutUpdateRelationshipComplete :::>',
153
- sendMessageToOutUpdateRelationshipComplete
154
- );
155
- await sns.publishAsync(
156
- _izContext,
157
- sendMessageToOutUpdateRelationshipComplete
158
- );
159
- } // check pendingStepId finished
160
-
161
- // remove awaitingMultipleStep after finished
162
- await asyncFlowSharedLib.removeAwaitingMultipleStep(
163
- _izContext,
164
- awaitingStepId,
165
- pendingStepId,
166
- errorsFound
100
+ if (result.isComplete) {
101
+ _izContext.logger.debug('finished all awaitingStep');
102
+
103
+ let updateCompleteMsg = {
104
+ relId: returnValue.requestParams.relId,
105
+ relType: returnValue.requestParams.relType,
106
+ status: status,
107
+ errorsFound: errorsFound
108
+ //(<inUpdateCompleteMsg>)
109
+ //(</inUpdateCompleteMsg>)
110
+ };
111
+
112
+ updateCompleteMsg =
113
+ callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
114
+ passBackProperties,
115
+ updateCompleteMsg
167
116
  );
168
- }) // end per pendingStep
169
- );
117
+ _izContext.logger.debug(
118
+ 'After addCallingFlowToSnsResponseMessageObject',
119
+ updateCompleteMsg
120
+ );
121
+
122
+ let messageAttributes =
123
+ callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
124
+ passBackProperties,
125
+ {}
126
+ );
127
+ _izContext.logger.debug(
128
+ 'After addCallingFlowToSnsResponseMessageAttributes',
129
+ updateCompleteMsg
130
+ );
131
+
132
+ let sendMessageToOutUpdateRelationshipComplete = {
133
+ Message: JSON.stringify(updateCompleteMsg),
134
+ MessageAttributes: sns.createStringMessageAttributes(
135
+ _izContext,
136
+ messageAttributes
137
+ ),
138
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
139
+ _izContext,
140
+ TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete
141
+ )
142
+ };
143
+ _izContext.logger.debug(
144
+ 'Send message to OutUpdateRelationshipComplete :::>',
145
+ sendMessageToOutUpdateRelationshipComplete
146
+ );
147
+ await sns.publishAsync(
148
+ _izContext,
149
+ sendMessageToOutUpdateRelationshipComplete
150
+ );
151
+ } // check isComplete finished
170
152
 
171
153
  return {
172
154
  returnValue,
@@ -338,15 +338,6 @@ export default async function updateRelationship(
338
338
  return updateCompleteMsg;
339
339
  }
340
340
 
341
- // before create awaitingStepId per graph storageResource
342
- const linkTypeId = createLinkTypeId(
343
- _izContext,
344
- firstObject.objType,
345
- secondObject.objType,
346
- relType,
347
- relationshipDirection
348
- );
349
-
350
341
  let usedGraphServiceTag = []; // collect used graph serviceName, use to check duplicate graph serviceName across graph serverTag
351
342
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
352
343
  let awaitingStepIds = [];
@@ -360,12 +351,12 @@ export default async function updateRelationship(
360
351
  targetGraphStorageResources.push(targetStorageResource);
361
352
 
362
353
  // awaitingStepId per graphServiceTag
363
- awaitingStepIds.push(
364
- asyncFlowSharedLib.createAwaitingStepId(
354
+ awaitingStepIds.push({
355
+ awaitingStepId: asyncFlowSharedLib.createAwaitingStepId(
365
356
  parentFlowId, // hash id
366
357
  PREFIX.updateRel // prefix, use constant further
367
358
  )
368
- );
359
+ });
369
360
  } else if (
370
361
  storageResource.storageType === consts.STORAGE_TYPES.dynamoDB
371
362
  ) {
@@ -411,12 +402,12 @@ export default async function updateRelationship(
411
402
  // save awaiting
412
403
  await asyncFlowSharedLib.createAwaitingMultipleSteps(
413
404
  _izContext,
414
- awaitingStepIds, // awaitingStepIds
415
405
  asyncFlowSharedLib.createPendingStepId(
416
- // pendingStepId
417
406
  _izContext.uniqueRequestId, // hash id
418
407
  PREFIX.updateRel // prefix, use constant further
419
- )
408
+ ),
409
+ awaitingStepIds,
410
+ {}
420
411
  );
421
412
 
422
413
  // prepare message body
@@ -5,6 +5,7 @@ import {
5
5
  customFlowRoleName,
6
6
  flowDsqSteps,
7
7
  flowExtTopicSteps,
8
+ generatedDsqFlows,
8
9
  generatedOwnTopicFlows,
9
10
  supportedCustomFlows
10
11
  } from '../custom/customFlows.js';
@@ -74,6 +75,12 @@ const SQS_CONSUMER_ACTIONS = [
74
75
  'sqs:GetQueueAttributes',
75
76
  'sqs:ReceiveMessage'
76
77
  ];
78
+ const SQS_DLQ_ACTIONS = [
79
+ 'sqs:DeleteMessage',
80
+ 'sqs:GetQueueAttributes',
81
+ 'sqs:ReceiveMessage',
82
+ 'sqs:SendMessage'
83
+ ];
77
84
 
78
85
  export async function emitResourceArtifacts({
79
86
  objects,
@@ -219,6 +226,9 @@ function createResourceState({ objects, relationships, flows }) {
219
226
  ...generatedOwnTopicFlows(flows).map((flow) =>
220
227
  customFlowRoleName(flow.flowTag)
221
228
  ),
229
+ ...generatedDsqFlows(flows).map((flow) =>
230
+ customFlowRoleName(flow.flowTag)
231
+ ),
222
232
  ...flowExtTopicSteps(flows).map(({ flow }) =>
223
233
  customFlowRoleName(flow.flowTag)
224
234
  ),
@@ -255,7 +265,8 @@ function createResourceState({ objects, relationships, flows }) {
255
265
  const relationshipTableNames = [...collectTables(relationships).keys()];
256
266
  const tableMap = new Map([
257
267
  ...collectTables(objects),
258
- ...collectTables(relationships)
268
+ ...collectTables(relationships),
269
+ ...collectTables(flows)
259
270
  ]);
260
271
  const externalDynamoTables = objects.flatMap(
261
272
  (object) => object.externalDynamoResources ?? []
@@ -496,6 +507,11 @@ function roleStatements(state, roleName) {
496
507
  SQS_CONSUMER_ACTIONS,
497
508
  queueArns(roleQueueNames(state, roleName))
498
509
  );
510
+ addStatement(
511
+ statements,
512
+ SQS_DLQ_ACTIONS,
513
+ queueArns(roleDlqQueueNames(state, roleName))
514
+ );
499
515
  addStatement(
500
516
  statements,
501
517
  ['sns:Publish'],
@@ -648,6 +664,14 @@ function roleQueueNames(state, roleName) {
648
664
  return queueList;
649
665
  }
650
666
 
667
+ function roleDlqQueueNames(state, roleName) {
668
+ const queues = roleQueueNames(state, roleName);
669
+ if (!Array.isArray(queues) || queues.length === 0) {
670
+ return [];
671
+ }
672
+ return queues.map((q) => (q.endsWith('DLQ') ? q : `${q}DLQ`));
673
+ }
674
+
651
675
  function roleTopicNames(state, roleName) {
652
676
  if (roleName === 'ProcFindDataRole') return [];
653
677
  if (roleName === 'FlowObjectsRole')
@@ -18,3 +18,6 @@
18
18
  - AttributeName: '<%- sk %>'
19
19
  KeyType: 'RANGE'
20
20
  <% } %>
21
+ #<#<%- tableName %>TableSetting#>
22
+ #<#/<%- tableName %>TableSetting#>
23
+
@@ -94,7 +94,7 @@ export default async function findData(
94
94
  fieldName,
95
95
  objType,
96
96
  identifiers,
97
- null,
97
+ "",
98
98
  overWriteCache,
99
99
  callingFlow,
100
100
  'error'
@@ -13,7 +13,7 @@ const validatorSchema = {
13
13
  type: 'object',
14
14
  properties: {
15
15
  <%_ startConfig.properties.forEach((prop, index) => { _%>
16
- <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: { type: '<%- prop.type || 'string' %>' }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
16
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: { type: '<%- prop.type || 'string' %>'<% if (typeof prop.default !== 'undefined') { %>, default: <%- typeof prop.default === 'string' ? `'${prop.default.replace(/'/g, "\\'")}'` : JSON.stringify(prop.default) %><% } %> }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
17
17
  <%_ }) _%>
18
18
  },
19
19
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
@@ -31,7 +31,8 @@ let perRecordsValidatorSchema = {
31
31
  properties: {
32
32
  <%_ startConfig.properties.forEach((prop, index) => { _%>
33
33
  <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
34
- type: '<%- prop.type || 'string' %>'
34
+ type: '<%- prop.type || 'string' %>'<% if (typeof prop.default !== 'undefined') { %>,
35
+ default: <%- typeof prop.default === 'string' ? `'${prop.default.replace(/'/g, "\\'")}'` : JSON.stringify(prop.default) %><% } %>
35
36
  }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
36
37
  <%_ }) _%>
37
38
  },
@@ -10,7 +10,7 @@ const validatorSchema = {
10
10
  type: 'object',
11
11
  properties: {
12
12
  <%_ startConfig.properties.forEach((prop, index) => { _%>
13
- <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: { type: '<%- prop.type || 'string' %>' }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
13
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: { type: '<%- prop.type || 'string' %>'<% if (typeof prop.default !== 'undefined') { %>, default: <%- typeof prop.default === 'string' ? `'${prop.default.replace(/'/g, "\\'")}'` : JSON.stringify(prop.default) %><% } %> }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
14
14
  <%_ }) _%>
15
15
  },
16
16
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
@@ -31,7 +31,8 @@ let perRecordsValidatorSchema = {
31
31
  properties: {
32
32
  <%_ startConfig.properties.forEach((prop, index) => { _%>
33
33
  <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
34
- type: '<%- prop.type || 'string' %>'
34
+ type: '<%- prop.type || 'string' %>'<% if (typeof prop.default !== 'undefined') { %>,
35
+ default: <%- typeof prop.default === 'string' ? `'${prop.default.replace(/'/g, "\\'")}'` : JSON.stringify(prop.default) %><% } %>
35
36
  }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
36
37
  <%_ }) _%>
37
38
  },
@@ -3,6 +3,8 @@ import ejsLib from 'ejs';
3
3
 
4
4
  const TEMPLATE_URL = new URL('./templates/', import.meta.url);
5
5
  const SOURCE = 'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source';
6
+ const REGISTER_SOURCE =
7
+ 'app/src/generatedCode/SystemFlowSchemas/Register/source';
6
8
 
7
9
  async function _renderSystemTemplate(templateName, data = {}) {
8
10
  const templatePath = new URL(templateName, TEMPLATE_URL);
@@ -27,12 +29,32 @@ export async function emitSystemWebSocketArtifacts(
27
29
  const webSocketCompleteHdrSqsContent = await _renderSystemTemplate(
28
30
  'WebSocketComplete_HdrSqs.ejs'
29
31
  );
32
+ const registerMainContent = await _renderSystemTemplate('Register_Main.ejs');
33
+ const registerHdrWbsContent = await _renderSystemTemplate(
34
+ 'Register_HdrWbs.ejs'
35
+ );
36
+ const registerCompleteMainContent = await _renderSystemTemplate(
37
+ 'RegisterComplete_Main.ejs'
38
+ );
39
+ const registerCompleteHdrSqsContent = await _renderSystemTemplate(
40
+ 'RegisterComplete_HdrSqs.ejs',
41
+ { queueName: 'RegisterComplete' }
42
+ );
43
+ const registerCompleteHdrDsqContent = await _renderSystemTemplate(
44
+ 'RegisterComplete_HdrSqs.ejs',
45
+ { queueName: 'RegisterCompleteDLQ' }
46
+ );
47
+
30
48
  const webSocketConnectYaml = await _renderSystemTemplate(
31
49
  'WebSocketConnect_Yaml.ejs'
32
50
  );
33
51
  const webSocketCompleteYaml = await _renderSystemTemplate(
34
52
  'WebSocketComplete_Yaml.ejs'
35
53
  );
54
+ const registerWbsYaml = await _renderSystemTemplate('RegisterWbs_Yaml.ejs');
55
+ const registerCompleteYaml = await _renderSystemTemplate(
56
+ 'RegisterComplete_Yaml.ejs'
57
+ );
36
58
 
37
59
  return {
38
60
  artifacts: [
@@ -47,9 +69,34 @@ export async function emitSystemWebSocketArtifacts(
47
69
  {
48
70
  path: `${SOURCE}/WebSocketComplete_HdrSqs.js`,
49
71
  content: webSocketCompleteHdrSqsContent
72
+ },
73
+ {
74
+ path: `${REGISTER_SOURCE}/Register_Main.js`,
75
+ content: registerMainContent
76
+ },
77
+ {
78
+ path: `${REGISTER_SOURCE}/Register_HdrWbs.js`,
79
+ content: registerHdrWbsContent
80
+ },
81
+ {
82
+ path: `${REGISTER_SOURCE}/RegisterComplete_Main.js`,
83
+ content: registerCompleteMainContent
84
+ },
85
+ {
86
+ path: `${REGISTER_SOURCE}/RegisterComplete_HdrSqs.js`,
87
+ content: registerCompleteHdrSqsContent
88
+ },
89
+ {
90
+ path: `${REGISTER_SOURCE}/RegisterComplete_HdrDsq.js`,
91
+ content: registerCompleteHdrDsqContent
50
92
  }
51
93
  ],
52
- functions: [webSocketConnectYaml, webSocketCompleteYaml]
94
+ functions: [
95
+ webSocketConnectYaml,
96
+ webSocketCompleteYaml,
97
+ registerWbsYaml,
98
+ registerCompleteYaml
99
+ ]
53
100
  };
54
101
  }
55
102
 
@@ -57,7 +104,12 @@ export function systemWebSocketManagedPaths() {
57
104
  return [
58
105
  `${SOURCE}/WebSocketConnect.js`,
59
106
  `${SOURCE}/WebSocketComplete_Main.js`,
60
- `${SOURCE}/WebSocketComplete_HdrSqs.js`
107
+ `${SOURCE}/WebSocketComplete_HdrSqs.js`,
108
+ `${REGISTER_SOURCE}/Register_Main.js`,
109
+ `${REGISTER_SOURCE}/Register_HdrWbs.js`,
110
+ `${REGISTER_SOURCE}/RegisterComplete_Main.js`,
111
+ `${REGISTER_SOURCE}/RegisterComplete_HdrSqs.js`,
112
+ `${REGISTER_SOURCE}/RegisterComplete_HdrDsq.js`
61
113
  ];
62
114
  }
63
115
 
@@ -0,0 +1,64 @@
1
+ import { middlewareHandler } from '@izara_project/izara-middleware';
2
+ import Logger from '@izara_project/izara-core-library-logger';
3
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
4
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
5
+ import registerCompleteMain from './RegisterComplete_Main.js';
6
+
7
+ middlewareHandler.setValidatorSchema(
8
+ recordHandlerSharedLib.baseValidatorSchema()
9
+ );
10
+ let perRecordsValidatorSchema = {};
11
+
12
+ export const main = middlewareHandler.wrap(async (event, context) => {
13
+ try {
14
+ let recordPromises = [];
15
+
16
+ await Promise.all(
17
+ event.Records.map(async (record) => {
18
+ let passOnProperties = [];
19
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
20
+
21
+ await recordHandlerSharedLib.validateRecord(
22
+ record,
23
+ '<%= queueName %>',
24
+ perRecordsValidatorSchema
25
+ );
26
+
27
+ passOnProperties.push(record.body.TopicArn);
28
+ passOnProperties.push(record.body.Message);
29
+ passOnProperties.push(
30
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(
31
+ record.body.Message
32
+ )
33
+ );
34
+ record._izContext.logger.debug(
35
+ 'passOnProperties in handler',
36
+ passOnProperties
37
+ );
38
+
39
+ let recordPromise = recordHandlerSharedLib.recordHandler(
40
+ record,
41
+ registerCompleteMain,
42
+ '<%= queueName %>',
43
+ passOnProperties
44
+ );
45
+ record._izContext.logger.debug('after recordPromise in handler');
46
+ recordPromises.push(recordPromise);
47
+ })
48
+ );
49
+
50
+ Logger.debug('before Promise.all(recordPromises) in handler');
51
+ try {
52
+ await Promise.all(recordPromises);
53
+ return event.Records;
54
+ } catch {
55
+ Logger.debug(
56
+ 'Promise.all(recordPromises) in handler threw error (at least one record did not resolve)'
57
+ );
58
+ }
59
+ Logger.debug('after Promise.all(recordPromises) in handler');
60
+ } catch (err) {
61
+ Logger.error('Unhandled Error, RegisterComplete: ', err);
62
+ throw err;
63
+ }
64
+ });