@izara_project/izara-core-generate-service-code 1.0.90 → 1.0.92

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 (82) hide show
  1. package/package.json +7 -10
  2. package/src/compile/flowValidator.js +6 -0
  3. package/src/compile/loadSchemas.js +177 -69
  4. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +2 -2
  5. package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
  6. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
  7. package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
  8. package/src/emit/crud/templates/CreateAfterHookCallback_Main.ejs +6 -6
  9. package/src/emit/crud/templates/CreateBeforeHookCallback_Main.ejs +3 -3
  10. package/src/emit/crud/templates/CreateComplete_Main.ejs +22 -22
  11. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +18 -18
  12. package/src/emit/crud/templates/CreateLogicalLib.ejs +47 -47
  13. package/src/emit/crud/templates/CreateNodeCallback_Main.ejs +24 -24
  14. package/src/emit/crud/templates/DeleteAfterHookCallback_Main.ejs +5 -5
  15. package/src/emit/crud/templates/DeleteBeforeHookCallback_Main.ejs +3 -3
  16. package/src/emit/crud/templates/DeleteComplete_Main.ejs +23 -23
  17. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +15 -15
  18. package/src/emit/crud/templates/DeleteLogicalLib.ejs +19 -19
  19. package/src/emit/crud/templates/FlowEndpointRbacCallback_Main.ejs +3 -3
  20. package/src/emit/crud/templates/UpdateAfterHookCallback_Main.ejs +5 -5
  21. package/src/emit/crud/templates/UpdateBeforeHookCallback_Main.ejs +3 -3
  22. package/src/emit/crud/templates/UpdateComplete_Main.ejs +22 -22
  23. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +15 -15
  24. package/src/emit/crud/templates/UpdateLogicalLib.ejs +33 -33
  25. package/src/emit/custom/customFlowPaths.js +149 -0
  26. package/src/emit/custom/customFlowS3.js +156 -0
  27. package/src/emit/custom/customFlowSteps.js +385 -0
  28. package/src/emit/custom/customFlowTemplates.js +28 -0
  29. package/src/emit/custom/customFlows.js +48 -19
  30. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
  31. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
  32. package/src/emit/custom/templates/FlowEndpointRbacCallback_Main.ejs +7 -7
  33. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +3 -3
  34. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +3 -3
  35. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +3 -3
  36. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +4 -4
  37. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +26 -6
  38. package/src/emit/rbac/emitRbacApplicationArtifacts.js +40 -13
  39. package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
  40. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
  41. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +13 -7
  42. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -1
  43. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
  44. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
  45. package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +2 -2
  46. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +6 -6
  47. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +17 -17
  48. package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +2 -2
  49. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +6 -6
  50. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +14 -14
  51. package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +2 -2
  52. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +6 -6
  53. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +10 -10
  54. package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +2 -2
  55. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +5 -5
  56. package/src/emit/relationship/templates/GetRelationship_Main.ejs +9 -9
  57. package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +2 -2
  58. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +6 -6
  59. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +15 -15
  60. package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +2 -2
  61. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +6 -6
  62. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +11 -11
  63. package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
  64. package/src/emit/resource/emitResourceArtifacts.js +13 -1251
  65. package/src/emit/resource/generateResourceArtifacts.js +20 -20
  66. package/src/emit/resource/iamResourceArtifacts.js +612 -0
  67. package/src/emit/resource/resourceState.js +564 -0
  68. package/src/emit/resource/resourceTemplate.js +30 -0
  69. package/src/emit/resource/s3ResourceArtifacts.js +14 -0
  70. package/src/emit/resource/sqsResourceArtifacts.js +113 -0
  71. package/src/emit/shared/runSubsystemGeneration.js +55 -0
  72. package/src/emit/shared/templates/FindData_Main.ejs +19 -19
  73. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +3 -3
  74. package/src/emit/shared/templates/ProcessLogical_Main.ejs +15 -15
  75. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  76. package/test/createTargetRoleHandler.test.js +62 -4
  77. package/test/crudApplicationArtifacts.test.js +75 -3
  78. package/test/customFlowApplicationArtifacts.test.js +98 -0
  79. package/test/dynamicCrudFlowSchemas.test.js +2 -2
  80. package/test/dynamicRbacFlowSchemas.test.js +32 -4
  81. package/test/relationshipApplicationArtifacts.test.js +1 -1
  82. package/test/resourceArtifacts.test.js +99 -0
@@ -44,7 +44,7 @@ export default async function <%- functionName %>(
44
44
  returnValue,
45
45
  parentFlowId,
46
46
  status,
47
- errorsFound,
47
+ foundErrors,
48
48
  graphServiceTag
49
49
  } = requestParams;
50
50
 
@@ -52,7 +52,7 @@ export default async function <%- functionName %>(
52
52
  returnValue: returnValue,
53
53
  parentFlowId: parentFlowId,
54
54
  status: status,
55
- errorsFound: errorsFound,
55
+ foundErrors: foundErrors,
56
56
  graphServiceTag: graphServiceTag,
57
57
  passBackProperties: passBackProperties
58
58
  });
@@ -76,7 +76,7 @@ export default async function <%- functionName %>(
76
76
  _izContext.logger.warn(
77
77
  `No pending step found for awaitingStepId: ${awaitingStepId}`
78
78
  );
79
- return { returnValue, status, errorsFound };
79
+ return { returnValue, status, foundErrors };
80
80
  }
81
81
 
82
82
  const result =
@@ -84,7 +84,7 @@ export default async function <%- functionName %>(
84
84
  _izContext,
85
85
  pending.pendingStepId,
86
86
  awaitingStepId,
87
- errorsFound
87
+ foundErrors
88
88
  );
89
89
  _izContext.logger.debug(
90
90
  '[<%- functionName %>] all awaiting steps result',
@@ -109,7 +109,7 @@ export default async function <%- functionName %>(
109
109
  moveObject: returnValue.requestParams.moveObject,
110
110
  status: status,
111
111
  parentFlowId: parentFlowId || returnValue?.parentFlowId,
112
- errorsFound: errorsFound
112
+ foundErrors: foundErrors
113
113
  };
114
114
 
115
115
  const callingFlowConfig =
@@ -167,7 +167,7 @@ export default async function <%- functionName %>(
167
167
  return {
168
168
  returnValue,
169
169
  status,
170
- errorsFound
170
+ foundErrors
171
171
  };
172
172
  } catch (err) {
173
173
  _izContext.logger.error('error createRelationshipComplete:', err);
@@ -93,7 +93,7 @@ export default async function moveRelationship(
93
93
  } = requestParams;
94
94
 
95
95
  const parentFlowId = identifierUuid();
96
- let errorsFound = [];
96
+ let foundErrors = [];
97
97
 
98
98
  //(<beforeValidateMoveRel>)
99
99
  //(</beforeValidateMoveRel>).
@@ -110,7 +110,7 @@ export default async function moveRelationship(
110
110
  );
111
111
 
112
112
  if (!objectSchema) {
113
- errorsFound.push(
113
+ foundErrors.push(
114
114
  `validateIdentifiers, not found schema of ${objTypeString}`
115
115
  );
116
116
  }
@@ -121,7 +121,7 @@ export default async function moveRelationship(
121
121
  ];
122
122
  for (const identifierName of identifierNames) {
123
123
  if (!identifiersObject.hasOwnProperty(identifierName)) {
124
- errorsFound.push(
124
+ foundErrors.push(
125
125
  `validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
126
126
  );
127
127
  } else {
@@ -129,7 +129,7 @@ export default async function moveRelationship(
129
129
  typeof identifiersObject[identifierName] !== 'string' &&
130
130
  typeof identifiersObject[identifierName] !== 'number'
131
131
  ) {
132
- errorsFound.push(
132
+ foundErrors.push(
133
133
  `validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
134
134
  );
135
135
  }
@@ -163,13 +163,13 @@ export default async function moveRelationship(
163
163
  !relationshipSchema.hasOwnProperty('moveBy') ||
164
164
  relationshipSchema.moveBy === 'none'
165
165
  ) {
166
- errorsFound.push(`relationship: ${relType.relationshipTag} can't move`);
166
+ foundErrors.push(`relationship: ${relType.relationshipTag} can't move`);
167
167
  // ? Legacy Code:
168
168
  /*
169
169
  } else if (relationshipSchema.moveBy === "user") {
170
170
  if (callingFlowConfig) {
171
171
  if (callingFlowConfig.callingFlow !== "ImportDataTestExternalUpdateRelationshipHdrSqs") {
172
- errorsFound.push(`moveBy is user but it's not user process with importData`);
172
+ foundErrors.push(`moveBy is user but it's not user process with importData`);
173
173
  }
174
174
  }
175
175
  }
@@ -177,7 +177,7 @@ export default async function moveRelationship(
177
177
  // ? [Fix]: The legacy logic incorrectly blocked "user" from regular execution and allowed non-user values.
178
178
  // ? It has been corrected to require moveBy === "user" for normal execution.
179
179
  } else if (relationshipSchema.moveBy !== 'user') {
180
- errorsFound.push(
180
+ foundErrors.push(
181
181
  `relationship: ${relType.relationshipTag} moveBy is not user`
182
182
  );
183
183
  }
@@ -199,7 +199,7 @@ export default async function moveRelationship(
199
199
  );
200
200
 
201
201
  if (!links.length) {
202
- errorsFound.push(
202
+ foundErrors.push(
203
203
  `not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`
204
204
  );
205
205
  }
@@ -238,7 +238,7 @@ export default async function moveRelationship(
238
238
  }
239
239
 
240
240
  if (checkCorrectLink == false) {
241
- errorsFound.push(`Wrong Relationship Direction`);
241
+ foundErrors.push(`Wrong Relationship Direction`);
242
242
  }
243
243
 
244
244
  let targetStorageResources = [];
@@ -286,7 +286,7 @@ export default async function moveRelationship(
286
286
  usedStorageResource.graphServerTag
287
287
  );
288
288
  if (!graphServiceTag) {
289
- errorsFound.push(
289
+ foundErrors.push(
290
290
  `storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`
291
291
  );
292
292
  }
@@ -312,23 +312,23 @@ export default async function moveRelationship(
312
312
  );
313
313
 
314
314
  if (!targetStorageResources.length) {
315
- errorsFound.push(`Not found link from relationship schema`);
315
+ foundErrors.push(`Not found link from relationship schema`);
316
316
  }
317
317
 
318
318
  // validate properties exists with schema
319
319
  for (const propKey in relationshipProperties) {
320
320
  if (!relationshipSchema.fieldNames.hasOwnProperty(propKey)) {
321
- errorsFound.push(
321
+ foundErrors.push(
322
322
  `property: ${propKey} not exists in relationshipSchema`
323
323
  );
324
324
  }
325
325
  }
326
326
  } else {
327
- errorsFound.push(`relationshipSchema not exists`);
327
+ foundErrors.push(`relationshipSchema not exists`);
328
328
  }
329
329
 
330
330
  // if found errors will stop processing
331
- if (errorsFound.length) {
331
+ if (foundErrors.length) {
332
332
  let moveRelCompleteMsg = {
333
333
  firstObject,
334
334
  secondObject,
@@ -339,7 +339,7 @@ export default async function moveRelationship(
339
339
  //(<inMoveCompleteMsg>)
340
340
  //(</inMoveCompleteMsg>)
341
341
  status: 'error',
342
- errorsFound: errorsFound,
342
+ foundErrors: foundErrors,
343
343
  parentFlowId: parentFlowId
344
344
  };
345
345
 
@@ -20,7 +20,7 @@ let perRecordsValidatorSchema = {
20
20
  status: {
21
21
  type: 'string'
22
22
  },
23
- errorsFound: {
23
+ foundErrors: {
24
24
  type: 'array'
25
25
  },
26
26
  graphServiceTag: {
@@ -31,7 +31,7 @@ let perRecordsValidatorSchema = {
31
31
  'returnValue',
32
32
  'parentFlowId',
33
33
  'status',
34
- 'errorsFound',
34
+ 'foundErrors',
35
35
  'graphServiceTag'
36
36
  ]
37
37
  //(<validatorSchema>)
@@ -45,7 +45,7 @@ export default async function updateRelationshipComplete(
45
45
  returnValue,
46
46
  parentFlowId,
47
47
  status,
48
- errorsFound,
48
+ foundErrors,
49
49
  graphServiceTag
50
50
  } = requestParams;
51
51
 
@@ -53,7 +53,7 @@ export default async function updateRelationshipComplete(
53
53
  returnValue: returnValue,
54
54
  parentFlowId: parentFlowId,
55
55
  status: status,
56
- errorsFound: errorsFound,
56
+ foundErrors: foundErrors,
57
57
  graphServiceTag: graphServiceTag,
58
58
  passBackProperties: passBackProperties
59
59
  // callingFlowConfig: callingFlowConfig
@@ -78,7 +78,7 @@ export default async function updateRelationshipComplete(
78
78
  _izContext.logger.warn(
79
79
  `No pending step found for awaitingStepId: ${awaitingStepId}`
80
80
  );
81
- return { returnValue, status, errorsFound };
81
+ return { returnValue, status, foundErrors };
82
82
  }
83
83
 
84
84
  const result =
@@ -86,7 +86,7 @@ export default async function updateRelationshipComplete(
86
86
  _izContext,
87
87
  pending.pendingStepId,
88
88
  awaitingStepId,
89
- errorsFound
89
+ foundErrors
90
90
  );
91
91
  _izContext.logger.debug(
92
92
  '[UpdateRelationshipComplete] all awaiting steps result',
@@ -104,7 +104,7 @@ export default async function updateRelationshipComplete(
104
104
  relId: returnValue.requestParams.relId,
105
105
  relType: returnValue.requestParams.relType,
106
106
  status: status,
107
- errorsFound: errorsFound
107
+ foundErrors: foundErrors
108
108
  //(<inUpdateCompleteMsg>)
109
109
  //(</inUpdateCompleteMsg>)
110
110
  };
@@ -158,7 +158,7 @@ export default async function updateRelationshipComplete(
158
158
  return {
159
159
  returnValue,
160
160
  status,
161
- errorsFound
161
+ foundErrors
162
162
  };
163
163
  } catch (err) {
164
164
  _izContext.logger.error('error updateRelationshipComplete:', err);
@@ -88,7 +88,7 @@ export default async function updateRelationship(
88
88
  //(</requestParamUpdateRel>)
89
89
  } = requestParams;
90
90
 
91
- let errorsFound = [];
91
+ let foundErrors = [];
92
92
  const parentFlowId = identifierUuid();
93
93
 
94
94
  //(<beforeValidateUpdateRel>)
@@ -106,7 +106,7 @@ export default async function updateRelationship(
106
106
  );
107
107
 
108
108
  if (!objectSchema) {
109
- errorsFound.push(
109
+ foundErrors.push(
110
110
  `validateIdentifiers, not found schema of ${objTypeString}`
111
111
  );
112
112
  }
@@ -116,7 +116,7 @@ export default async function updateRelationship(
116
116
  schemaIdentifier.fieldName || schemaIdentifier.name;
117
117
 
118
118
  if (!identifiersObject.hasOwnProperty(identifierName)) {
119
- errorsFound.push(
119
+ foundErrors.push(
120
120
  `validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
121
121
  );
122
122
  } else {
@@ -124,7 +124,7 @@ export default async function updateRelationship(
124
124
  typeof identifiersObject[identifierName] !== 'string' &&
125
125
  typeof identifiersObject[identifierName] !== 'number'
126
126
  ) {
127
- errorsFound.push(
127
+ foundErrors.push(
128
128
  `validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
129
129
  );
130
130
  }
@@ -225,7 +225,7 @@ export default async function updateRelationship(
225
225
  usedStorageResource.graphServerTag
226
226
  );
227
227
  if (!graphServiceTag) {
228
- errorsFound.push(
228
+ foundErrors.push(
229
229
  `storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`
230
230
  );
231
231
  }
@@ -252,7 +252,7 @@ export default async function updateRelationship(
252
252
  );
253
253
 
254
254
  if (!targetStorageResources.length) {
255
- errorsFound.push(`Not found link from relationship schema`);
255
+ foundErrors.push(`Not found link from relationship schema`);
256
256
  }
257
257
 
258
258
  // validate canUpdate properties relationship
@@ -269,21 +269,21 @@ export default async function updateRelationship(
269
269
  callingFlowConfig.callingFlow !==
270
270
  'ImportDataTestExternalUpdateRelationshipHdrSqs'
271
271
  ) {
272
- errorsFound.push(
272
+ foundErrors.push(
273
273
  `property:${propKey} can update user but it's not user process with importData`
274
274
  );
275
275
  }
276
276
  }
277
277
  }
278
278
  } else {
279
- errorsFound.push(
279
+ foundErrors.push(
280
280
  `property:${propKey} not exists in relationshipSchema`
281
281
  );
282
282
  }
283
283
  }
284
284
 
285
285
  // if found errors will stop processing
286
- if (errorsFound.length) {
286
+ if (foundErrors.length) {
287
287
  let updateCompleteMsg = {
288
288
  firstObject: firstObject,
289
289
  secondObject: secondObject,
@@ -291,7 +291,7 @@ export default async function updateRelationship(
291
291
  relType: relType,
292
292
  relationshipDirection,
293
293
  status: 'error',
294
- errorsFound: errorsFound,
294
+ foundErrors: foundErrors,
295
295
  parentFlowId: parentFlowId
296
296
  //(<inUpdateCompleteMsgUpdateRel>)
297
297
  //(</inUpdateCompleteMsgUpdateRel>)
@@ -524,7 +524,7 @@ export default async function updateRelationship(
524
524
  relId: relId,
525
525
  relType: relType,
526
526
  relationshipDirection,
527
- errorsFound
527
+ foundErrors
528
528
  };
529
529
  }
530
530
  } catch (err) {
@@ -0,0 +1,18 @@
1
+ import { indentYaml, renderResourceTemplate } from './resourceTemplate.js';
2
+
3
+ export async function renderDynamo(state) {
4
+ const [system, ...tables] = await Promise.all([
5
+ renderResourceTemplate('SystemDynamoDB_Yaml.ejs', {
6
+ hasS3: state.s3FlowTags.length > 0,
7
+ hasRbac: state.selfRbac
8
+ }),
9
+ ...state.tables.map((table) =>
10
+ renderResourceTemplate('DynamoDBTable_Yaml.ejs', table)
11
+ )
12
+ ]);
13
+ const indentedTables = tables.map((t) => indentYaml(t, 2)).join('\n');
14
+ if (indentedTables) {
15
+ return `${system}\n${indentedTables}`;
16
+ }
17
+ return `${system}`;
18
+ }