@izara_project/izara-core-generate-service-code 1.0.22 → 1.0.24

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 (106) hide show
  1. package/package.json +1 -1
  2. package/src/generateCode/generateFlowSchema/GenerateCodeFlowSchema.js +11 -8
  3. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/data.js +2 -2
  4. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/template.ejs +3 -10
  5. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/data.js +5 -4
  6. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs +5 -14
  7. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/index.js +4 -13
  8. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/mainFunction/data.js +2 -2
  9. package/src/generateCode/generateFlowSchema/event/extTopicComponent/index.js +5 -9
  10. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/data.js +6 -10
  11. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/template.ejs +4 -11
  12. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/data.js +2 -2
  13. package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-in-sqs/data.js +2 -2
  14. package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-out/data.js +4 -3
  15. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/data.js +4 -8
  16. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/template.ejs +12 -21
  17. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/data.js +2 -2
  18. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/index.js +3 -7
  19. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/data.js +11 -9
  20. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/template.ejs +3 -10
  21. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/data.js +2 -2
  22. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/index.js +3 -7
  23. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/functionYaml/data.js +4 -3
  24. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/data.js +3 -3
  25. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/functionYaml/data.js +8 -11
  26. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/handler/data.js +2 -2
  27. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/mainFunction/data.js +2 -2
  28. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/index.js +8 -24
  29. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-in/data.js +2 -2
  30. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-out/data.js +4 -3
  31. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/data.js +14 -12
  32. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs +5 -8
  33. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +30 -0
  34. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +26 -0
  35. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +44 -0
  36. package/src/generateCode/generateFlowSchema/event/s3Component/index.js +23 -55
  37. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/functionYaml/data.js +3 -7
  38. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/handler/data.js +3 -7
  39. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/mainFunction/data.js +3 -7
  40. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/queue/data.js +2 -2
  41. package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/functionYaml/data.js +3 -7
  42. package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/handler/data.js +3 -7
  43. package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/mainFunction/data.js +3 -7
  44. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +3 -7
  45. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/handler/data.js +3 -7
  46. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +3 -7
  47. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/queue/data.js +2 -2
  48. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/functionYaml/data.js +6 -10
  49. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/handler/data.js +3 -7
  50. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -7
  51. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/sqs/data.js +2 -2
  52. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/functionYml/HdrS3/data.js +3 -7
  53. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/handler/handlerS3/data.js +3 -7
  54. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/mainFunction/data.js +3 -7
  55. package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/S3/data.js +4 -4
  56. package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/sns-out/data.js +5 -3
  57. package/src/generateCode/generateFlowSchema/event/s3Component/websocket/dynamoDb/ReservedTableData.js +3 -3
  58. package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/data.js +4 -8
  59. package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +3 -5
  60. package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +7 -2
  61. package/src/generateCode/generateFlowSchema/libs/data.js +3 -7
  62. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/functionYaml/data.js +9 -9
  63. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/handler/data.js +1 -5
  64. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/index.js +6 -18
  65. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/mainFunction/data.js +15 -14
  66. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/functionYaml/data.js +4 -8
  67. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/handler/data.js +15 -15
  68. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/mainFunction/data.js +15 -15
  69. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/index.js +13 -33
  70. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/functionYaml/data.js +4 -8
  71. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/handler/data.js +12 -14
  72. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/mainFunction/data.js +11 -14
  73. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/functionYaml/dsq/data.js +4 -9
  74. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/functionYaml/sqs/data.js +4 -9
  75. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/handler/dsq/data.js +11 -14
  76. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/handler/sqs/data.js +11 -14
  77. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/mainFunction/data.js +15 -15
  78. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheQueue/data.js +2 -3
  79. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +185 -103
  80. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/sns-out/data.js +2 -1
  81. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/delete/sns-out/data.js +2 -1
  82. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/get/sns-out/data.js +2 -1
  83. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/mainFunction/template.ejs +137 -71
  84. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/sns-out/data.js +2 -1
  85. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +1 -1
  86. package/src/generateCode/generateSchema/actionEndpointComponent/yaml/data.js +6 -4
  87. package/src/generateCode/generateSchema/findDataComponent/mainFunction/data.js +1 -1
  88. package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/complete/sns-out/data.js +2 -1
  89. package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/data.js +1 -0
  90. package/src/generateCode/generateSchema/relationshipPerActionComponent/create/complete/sns-out/data.js +2 -1
  91. package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/data.js +1 -0
  92. package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/complete/sns-out/data.js +2 -1
  93. package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/data.js +1 -0
  94. package/src/generateCode/generateSchema/relationshipPerActionComponent/get/complete/sns-out/data.js +2 -1
  95. package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/complete/sns-out/data.js +2 -1
  96. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/data.js +1 -0
  97. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/sns-out/data.js +2 -1
  98. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/complete/sns-out/data.js +2 -1
  99. package/src/generateCode/resourceYamlComponent/sns-out/data.js +2 -1
  100. package/src/generateCode/resourceYamlComponent/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -1
  101. package/src/generateCode/resourceYamlComponent/sns-out/template.ejs +2 -6
  102. package/src/generateCode.js +9 -7
  103. package/src/libs/Consts.js +9 -12
  104. package/src/libs/Utils.js +26 -1
  105. package/src/__TemplateData/flowSchema/event/externalTopic/Process/handler/data.js +0 -64
  106. package/src/__TemplateData/flowSchema/event/externalTopic/sns-out/data.js +0 -75
@@ -68,7 +68,7 @@ const HTTP_METHOD = {
68
68
  * Generates yaml source params for a given action and handler
69
69
  * @param {Object} _izContext - Context object with logger
70
70
  * @param {Array} allObjSchemas - All object schemas
71
- * @param {string} srcPath - Source path
71
+ * @param {string} appPath - Source path
72
72
  * @param {string} action - Action name (create/update/get/delete)
73
73
  * @param {string} handler - Handler type (hdrApi/hdrSqs/hdrDsq/hdrInv)
74
74
  * @param {string|null} functionNameConfig - Override for yaml key (null = derive from action+handler)
@@ -78,7 +78,7 @@ const HTTP_METHOD = {
78
78
  async function data(
79
79
  _izContext,
80
80
  allObjSchemas,
81
- srcPath,
81
+ appPath,
82
82
  action,
83
83
  handler,
84
84
  handlerSuffix = '',
@@ -187,7 +187,9 @@ async function data(
187
187
  }
188
188
 
189
189
  // ── Service config ────────────────────────────────────────────────────────
190
- const configPath = path.join(srcPath, '../config/serverless.config.yml');
190
+ const configPath = path.join(appPath, '../config/serverless.config.yml');
191
+
192
+ // console.debug('###### configPath:', configPath);
191
193
  const ownServiceTag = yaml.parse(fs.readFileSync(configPath, 'utf8'))
192
194
  .main_config.iz_serviceTag;
193
195
 
@@ -294,7 +296,7 @@ async function data(
294
296
  }))
295
297
  },
296
298
  setting: {
297
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
299
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
298
300
  saveFileName: SAVE_FILE_NAME.functionPerActionYaml,
299
301
  fileExtension: '.yml',
300
302
  isAppend: true
@@ -74,7 +74,7 @@ async function data(_izContext, appPath, getObjectTypes) {
74
74
  objectType,
75
75
  schemaPath
76
76
  );
77
- // console.log('objectSchemaRecord: ', objectSchemaRecord);
77
+ // console.log('#### objectSchemaRecord: ', objectSchemaRecord);
78
78
 
79
79
  let objectSchema = objectSchemaRecord.records[0];
80
80
  // console.log(("objectSchema: ", objectSchema)
@@ -56,7 +56,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
56
56
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
57
57
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
58
58
  fileExtension: '.yml',
59
- isAppend: true
59
+ isAppend: true,
60
+ fromFile: 'relationShip/changeComplete/sns-out/data.js'
60
61
  }
61
62
  };
62
63
  }
@@ -33,6 +33,7 @@ const {
33
33
  SHORT_FUNCTION_NAME,
34
34
  SOURCE_GENERATE_IAM_ROLE,
35
35
  SQS_RESOURCE,
36
+ DYNAMO_RESOURCE,
36
37
  HANDLER
37
38
  } = consts;
38
39
 
@@ -55,7 +55,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
55
55
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
56
56
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
57
57
  fileExtension: '.yml',
58
- isAppend: true
58
+ isAppend: true,
59
+ fromFile: 'relationShip/createComplete/sns-out/data.js'
59
60
  }
60
61
  };
61
62
  }
@@ -33,6 +33,7 @@ const {
33
33
  SHORT_FUNCTION_NAME,
34
34
  SOURCE_GENERATE_IAM_ROLE,
35
35
  SQS_RESOURCE,
36
+ DYNAMO_RESOURCE,
36
37
  HANDLER
37
38
  } = consts;
38
39
 
@@ -57,7 +57,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
57
57
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
58
58
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
59
59
  fileExtension: '.yml',
60
- isAppend: true
60
+ isAppend: true,
61
+ fromFile: 'relationShip/deleteComplete/sns-out/data.js'
61
62
  }
62
63
  };
63
64
  }
@@ -33,6 +33,7 @@ const {
33
33
  SHORT_FUNCTION_NAME,
34
34
  SOURCE_GENERATE_IAM_ROLE,
35
35
  SQS_RESOURCE,
36
+ DYNAMO_RESOURCE,
36
37
  HANDLER
37
38
  } = consts;
38
39
 
@@ -58,7 +58,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
58
58
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
59
59
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
60
60
  fileExtension: '.yml',
61
- isAppend: true
61
+ isAppend: true,
62
+ fromFile: 'relationShip/getComplete/sns-out/data.js'
62
63
  }
63
64
  };
64
65
  }
@@ -57,7 +57,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
57
57
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
58
58
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
59
59
  fileExtension: '.yml',
60
- isAppend: true
60
+ isAppend: true,
61
+ fromFile: 'relationShip/moveComplete/sns-out/data.js'
61
62
  }
62
63
  };
63
64
  }
@@ -33,6 +33,7 @@ const {
33
33
  SHORT_FUNCTION_NAME,
34
34
  SOURCE_GENERATE_IAM_ROLE,
35
35
  SQS_RESOURCE,
36
+ DYNAMO_RESOURCE,
36
37
  HANDLER
37
38
  } = consts;
38
39
 
@@ -60,7 +60,8 @@ function createParamsForCreateSource(_izContext, srcPath) {
60
60
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
61
61
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
62
62
  fileExtension: '.yml',
63
- isAppend: true
63
+ isAppend: true,
64
+ fromFile: 'relationShip/update/sns-out/data.js'
64
65
  }
65
66
  };
66
67
  }
@@ -49,7 +49,8 @@ function createParamsForCreateSource(_izContext, appPath) {
49
49
  savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
50
50
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
51
51
  fileExtension: '.yml',
52
- isAppend: true
52
+ isAppend: true,
53
+ fromFile: 'relationShip/updateComplete/sns-out/data.js'
53
54
  }
54
55
  }
55
56
  ];
@@ -69,7 +69,8 @@ function createSourceSnsOut(_izContext, srcPath) {
69
69
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
70
70
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
71
71
  fileExtension: '.yml',
72
- isAppend: true
72
+ isAppend: true,
73
+ fromFile: 'resourceYaml/sns-out/data.js'
73
74
  }
74
75
  });
75
76
  }
@@ -55,7 +55,8 @@ function createDataForDefaultSnsOut(_izContext, srcPath) {
55
55
  savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
56
56
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
57
57
  fileExtension: '.yml',
58
- isAppend: true
58
+ isAppend: true,
59
+ fromFile: 'resourceYaml/sns-out/defaultSnsOut.js'
59
60
  }
60
61
  });
61
62
  }
@@ -1,10 +1,6 @@
1
1
  ##--------- [Create Topic Out]
2
- Out<%- firstLetterUpperCase(queueName) %>:
2
+ Out<%- queueName %>:
3
3
  Type: AWS::SNS::Topic
4
4
  Properties:
5
5
  DisplayName: "SNS Message out"
6
- TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>_Out
7
-
8
- <%_ function firstLetterUpperCase(text) {
9
- return text.charAt(0).toUpperCase() + text.slice(1)
10
- } _%>
6
+ TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- queueName %>_Out
@@ -64,6 +64,7 @@ async function generateCodeWithTemplate(
64
64
  try {
65
65
  const startTime = Date.now();
66
66
  const appPath = path.join(rootServicePath, '/app');
67
+ const schemasPath = path.join(appPath, '/src/schemas');
67
68
  console.info(
68
69
  `[INFO] [generateCode] STATUS=START | path=${rootServicePath}`
69
70
  );
@@ -73,15 +74,12 @@ async function generateCodeWithTemplate(
73
74
  const fetchStartTime = Date.now();
74
75
  const [allLocalFlowSchemas, allObjSchemas, allLocalRelationshipSchemas] =
75
76
  await Promise.all([
76
- getObjectSchema.getAllLocalFlowSchemas(_izContext, rootServicePath),
77
+ getObjectSchema.getAllLocalFlowSchemas(_izContext, schemasPath),
77
78
  getObjectSchema.getAllLocalObjectSchemasWithHierarchy(
78
79
  _izContext,
79
- rootServicePath
80
+ schemasPath
80
81
  ),
81
- getObjectSchema.getAllLocalRelationshipSchema(
82
- _izContext,
83
- rootServicePath
84
- )
82
+ getObjectSchema.getAllLocalRelationshipSchema(_izContext, schemasPath)
85
83
  ]);
86
84
 
87
85
  const fetchDuration = Date.now() - fetchStartTime;
@@ -145,6 +143,7 @@ async function generateCodeWithTemplate(
145
143
  appPath,
146
144
  allCreateSource
147
145
  );
146
+
148
147
  allCreateSource.push(...createSourceRole);
149
148
  const roleStr = `items=${allCreateSource.length} roles=${createSourceRole.length}`;
150
149
  console.info(
@@ -156,6 +155,7 @@ async function generateCodeWithTemplate(
156
155
  console.info('[INFO] [generateCode] STATUS=VALIDATING| source items...');
157
156
  for (const item of allCreateSource) {
158
157
  if (!item?.templatePath || !item?.templateData || !item?.setting) {
158
+ console.debug('###### error item:', item);
159
159
  throw new Error(
160
160
  `[generateCode] invalid source item: ${JSON.stringify(item)}`
161
161
  );
@@ -163,6 +163,8 @@ async function generateCodeWithTemplate(
163
163
  const { templatePath, templateData, setting } = item;
164
164
  setting.checkCreateSourcePass = true;
165
165
 
166
+ // console.debug('####### item:', item);
167
+
166
168
  const [status, errors] = await createSource(
167
169
  readFileSync(templatePath, 'utf8'),
168
170
  templateData,
@@ -170,7 +172,7 @@ async function generateCodeWithTemplate(
170
172
  );
171
173
  if (!status) {
172
174
  console.error('[generateCode] validation failed:', errors);
173
- _izContext.logger.error('[generateCode] validation failed:', errors);
175
+ console.debug('###### item:', item);
174
176
  throw new Error(errors);
175
177
  }
176
178
 
@@ -86,16 +86,12 @@ const SOURCE_PATH = {
86
86
  '/src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/',
87
87
  resourceLocationGeneratedCodeHookFunction:
88
88
  'src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/',
89
- generatedAttributeTree: '/src/schemas/generatedCode/attributeTree/',
90
- generatedPropertyValue: '/src/schemas/generatedCode/propertyValue/',
91
- generatedRefRelationshipAttribute:
92
- '/src/schemas/generatedCode/refRelationshipAttribute/',
93
89
  endpointPerService: '/src/generatedCode/ActionEndpoint/source/',
94
90
  resourceLocationHandlerEndpointPerService:
95
91
  'src/generatedCode/ActionEndpoint/source/',
96
92
  createRecordComplete: '/src/generatedCode/CreateRecordComplete/',
97
93
  resourceLocationCreateRecordComplete:
98
- 'src/generatedCode/CreateRerordComplete/'
94
+ 'src/generatedCode/CreateRecordComplete/'
99
95
  };
100
96
 
101
97
  const SQS_RESOURCE = {
@@ -141,20 +137,21 @@ const SAVE_FILE_NAME = {
141
137
  snsOutYaml: 'generated-sns-out',
142
138
  functionRelationshipYaml: 'relationship-per-action',
143
139
  functionPerActionYaml: 'per-action-function',
140
+ processLogicalYaml: 'process-logical',
141
+ flowSchemaYaml: 'flow-schema',
142
+ roleNameConfigYaml: 'role-name-config',
143
+ sharedResourceYaml: 'generate-shared-resource',
144
+ authorizerYaml: 'authorizer',
145
+ findData: 'find-data',
146
+
144
147
  externalLambdaRole: 'generatedLambdaRoleServiceConfig',
145
148
  snsSubscription: 'generatedSnsServiceConfig',
146
149
  translateId: 'TranslateIdsRequest',
147
- findData: 'find-data',
148
- processLogicalYaml: 'process-logical',
149
- flowSchemaYaml: 'flow-schema',
150
150
  S3Bucket: 'generated-s3-bucket',
151
- sharedResourceYaml: 'generate-shared-resource',
152
151
  objectRelationship: 'ObjectRelationships',
153
152
  refObjectRelationship: 'RefObjectRelationships',
154
153
  objectSchema: 'ObjectFieldSchema',
155
- roleNameConfigYaml: 'role-name-config',
156
- roleNameConfig: 'RoleNameConfig',
157
- authorizerYaml: 'authorizer'
154
+ roleNameConfig: 'RoleNameConfig'
158
155
  };
159
156
 
160
157
  const FUNCTION_NAME = {
package/src/libs/Utils.js CHANGED
@@ -18,8 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  import yaml from 'yaml';
19
19
  import fs from 'fs';
20
20
  import path from 'path';
21
+
21
22
  import { objectHash as hash } from '@izara_project/izara-shared-core';
22
23
 
24
+ import consts from '#libs/Consts.js';
25
+ const { SOURCE_PATH } = consts;
26
+
23
27
  function firstLetterUpperCase(text) {
24
28
  return text.charAt(0).toUpperCase() + text.slice(1);
25
29
  }
@@ -128,6 +132,26 @@ function deleteFile(filePath) {
128
132
  }
129
133
  }
130
134
 
135
+ const savePath = {
136
+ resourceYamlFlowSchemaFlowTag: function (appPath, flowTag) {
137
+ return path.join(
138
+ appPath,
139
+ SOURCE_PATH.flowSchema,
140
+ firstLetterUpperCase(flowTag),
141
+ 'MainHandler/',
142
+ 'source/'
143
+ );
144
+ },
145
+ flowSchemaFlowTag: function (flowTag) {
146
+ return path.join(
147
+ SOURCE_PATH.flowSchema,
148
+ firstLetterUpperCase(flowTag),
149
+ 'MainHandler/',
150
+ 'source/'
151
+ );
152
+ }
153
+ };
154
+
131
155
  export default {
132
156
  firstLetterUpperCase,
133
157
  firstLetterLowerCase,
@@ -135,5 +159,6 @@ export default {
135
159
  getLocalConfig,
136
160
  checkValidTableYaml,
137
161
  deleteFileInDir,
138
- deleteFile
162
+ deleteFile,
163
+ savePath
139
164
  };
@@ -1,64 +0,0 @@
1
- /*
2
- Copyright (C) 2020 Sven Mason <http://izara.io>
3
-
4
- This program is free software: you can redistribute it and/or modify
5
- it under the terms of the GNU Affero General Public License as
6
- published by the Free Software Foundation, either version 3 of the
7
- License, or (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU Affero General Public License for more details.
13
-
14
- You should have received a copy of the GNU Affero General Public License
15
- along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
-
18
- import path from 'path';
19
- import { fileURLToPath } from 'url';
20
- const __filename = fileURLToPath(import.meta.url);
21
- const __dirname = path.dirname(__filename);
22
-
23
- import consts from '../../../../../../libs/Consts.js';
24
- import utils from '../../../../../../libs/Utils.js';
25
-
26
- const { SOURCE_PATH, HANDLER } = consts;
27
- const { firstLetterUpperCase: upperCase } = utils;
28
-
29
- const templatePath = path.join(__dirname, 'template.ejs');
30
- /**
31
- * receive objectSchema
32
- * create data for WebScoket handler template
33
- *
34
- * @param {Object} objectSchema
35
- * @return {{templatePath, templateData,setting}}
36
- */
37
-
38
- function createSourceParams(_izContext, flowSchema, srcPath) {
39
- let functionName = 'Process' + upperCase(flowSchema.flowTag);
40
- let handlerType = upperCase(HANDLER.hdrSqs);
41
- let queueName = 'Process' + upperCase(flowSchema.flowTag) + handlerType;
42
-
43
- return {
44
- templatePath: templatePath,
45
- templateData: {
46
- functionName,
47
- handlerType,
48
- queueName
49
- },
50
- setting: {
51
- savePath: path.join(
52
- srcPath,
53
- SOURCE_PATH.flowSchema,
54
- upperCase(flowSchema.flowTag),
55
- 'source/'
56
- ),
57
- saveFileName: `${functionName}_${handlerType}`,
58
- fileExtension: '.js',
59
- isAppend: false
60
- }
61
- };
62
- }
63
-
64
- export default createSourceParams;
@@ -1,75 +0,0 @@
1
- /*
2
- Copyright (C) 2020 Sven Mason <http://izara.io>
3
-
4
- This program is free software: you can redistribute it and/or modify
5
- it under the terms of the GNU Affero General Public License as
6
- published by the Free Software Foundation, either version 3 of the
7
- License, or (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU Affero General Public License for more details.
13
-
14
- You should have received a copy of the GNU Affero General Public License
15
- along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
-
18
- import path from 'path';
19
- import { fileURLToPath } from 'url';
20
- const __filename = fileURLToPath(import.meta.url);
21
- const __dirname = path.dirname(__filename);
22
-
23
- import consts from '../../../../../libs/Consts.js';
24
- import utils from '../../../../../libs/Utils.js';
25
-
26
- const { SOURCE_PATH, SAVE_FILE_NAME } = consts;
27
- const { firstLetterUpperCase: upperCase } = utils;
28
-
29
- const templatePath = path.join(
30
- __dirname,
31
- '../../../../resourceYaml/sns-out/template.ejs'
32
- );
33
-
34
- /**
35
- * create data for dynamoDbYaml tempalte from objectSchema
36
- * return array of dynamoDb data
37
- * because one objectSchema can create multiple dynamoDb table
38
- *
39
- * @param {Object} _izContext
40
- * @param {String} saveFilePath
41
- * @returns {Object[]} - data of multiple dynamoDb template
42
- */
43
-
44
- function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
45
- let resultsForCreateDefaultSnsInSqs = [];
46
- let flowSteps = Object.keys(flowSchema.flowSteps);
47
- const setting = {
48
- initialData: 'Resources:\n',
49
- savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
50
- saveFileName: SAVE_FILE_NAME.snsOutYaml,
51
- fileExtension: '.yml',
52
- isAppend: true
53
- };
54
-
55
- let topicOut = `${upperCase(flowSchema.flowTag)}`;
56
-
57
- const generatedSnsTopicInForFlowSchema = [];
58
- if (flowSteps.includes('Out')) {
59
- generatedSnsTopicInForFlowSchema.push({
60
- queueName: upperCase(topicOut)
61
- });
62
- }
63
-
64
- for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
65
- resultsForCreateDefaultSnsInSqs.push({
66
- templatePath: templatePath,
67
- templateData: defaultSnsInSqsData,
68
- setting: setting
69
- });
70
- }
71
-
72
- return resultsForCreateDefaultSnsInSqs;
73
- }
74
-
75
- export default createDataForDefaultSnsInSqs;