@izara_project/izara-market-library-service-schemas 1.0.34 → 1.0.35

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 (74) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +5 -5
  4. package/src/MainLibs/src/Consts.js +43 -10
  5. package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
  6. package/src/reStructure/GenerateCode.js +1 -0
  7. package/src/reStructure/SchemaConfig.js +1 -0
  8. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
  9. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -0
  11. package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +28 -44
  12. package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
  13. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTree/data.js +134 -0
  14. package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/data.js +172 -0
  15. package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
  16. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
  17. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
  18. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
  19. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
  20. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
  21. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +96 -0
  22. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
  23. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
  24. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
  25. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +138 -0
  26. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
  27. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
  28. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
  29. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
  30. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +133 -0
  31. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
  32. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +12 -0
  33. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
  34. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +19 -2
  35. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
  36. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
  37. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +142 -0
  38. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
  39. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
  40. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +89 -0
  41. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
  42. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +120 -0
  43. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
  44. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
  45. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
  46. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
  47. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
  48. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +3 -6
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +7 -9
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +2 -2
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +2 -2
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +8 -43
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +1 -1
  55. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -2
  56. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +1 -0
  57. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +7 -1
  58. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +18 -7
  59. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +3 -1
  60. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +7 -1
  61. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +52 -13
  62. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +2 -0
  63. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -6
  64. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -29
  65. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +67 -6
  66. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +20 -0
  67. package/src/reStructure/TemplateData/propertyNodeSchema/generateTemplateData.js +66 -0
  68. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +151 -0
  69. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs +16 -0
  70. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data.js +179 -0
  71. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +7 -0
  72. package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
  73. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
  74. /package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/request.json +0 -0
@@ -22,6 +22,8 @@ const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/C
22
22
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
23
  const templatePath = path.join(__dirname, "template.ejs");
24
24
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
25
+ const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
26
+ const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
25
27
 
26
28
  /**
27
29
  * receive objectSchema
@@ -40,7 +42,11 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
40
42
  let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopicEndpoint)
41
43
  return {
42
44
  templatePath: templatePath,
43
- templateData: {},
45
+ templateData: {
46
+ statusType: flowSchema.statusType,
47
+ statusFieldTemplate,
48
+ storedCacheTemplate,
49
+ },
44
50
  setting: {
45
51
  savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),
46
52
  saveFileName: `${functionName}_Main`,
@@ -23,12 +23,14 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
23
23
 
24
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
25
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
+ const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
26
27
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
28
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
29
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
30
 
30
31
  const externalRequest = require('@izara_project/izara-core-library-external-request');
31
32
  const sns = externalRequest.sns
33
+ const sqs = externalRequest.sqs
32
34
  const { postToConnection } = require("../../../../libs/source/GenerateCodeLibs");
33
35
  const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
36
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
@@ -66,31 +68,68 @@ module.exports.FlowSchemaOwnTopicEndpoint = async (
66
68
  //(<endpointHookMainFunction>)
67
69
  //(</endpointHookMainFunction>)
68
70
 
71
+ <% if (statusType === "statusField") { %>
72
+ <%- include(statusFieldTemplate) %>
73
+ <% } else if (statusType === "storedCache") { %>
74
+ <%- include(storedCacheTemplate) %>
69
75
  let messageObject = {
70
- //(<messageObject>)
71
- //(</messageObject>)
72
- };
76
+ requestParams:requestParams
77
+ }
73
78
 
74
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
75
- sendMessageToTranslateIdIterFromAHdrDsq,
79
+ //(<beforeSendMessage>)
80
+ //(</beforeSendMessage>)
81
+ // create callingFlow
82
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
83
+ messageObject,
76
84
  callingFlowSharedLib.addParentCallingFlowConfig(
77
- callingFlow,
85
+ callingFlowConfig,
78
86
  callingFlowSharedLib.createCallingFlowConfig(
79
87
  await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
80
88
  )
81
89
  )
82
90
  )
83
91
 
84
- let sendMessageToFlowSchemaOutEndpointComplete = {
85
- MessageBody: JSON.stringify(messageObject),
86
- QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointHdrSqs")
92
+ let sendMessageToEndpointComplete = {
93
+ Message:JSON.stringify(messageObject),
94
+ QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointCompleteHdrSqs")
95
+ }
96
+ _izContext.logger.debug("sendMessageToEndpointComplete", sendMessageToEndpointComplete)
97
+ await sqs.sendMessage(_izContext, sendMessageToEndpointComplete)
98
+
99
+ <% } else if (statusType === "none") { %>
100
+ let messageObject = {
101
+ requestParams:requestParams
102
+ }
103
+ // create callingFlow
104
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
105
+ messageObject,
106
+ callingFlowSharedLib.addParentCallingFlowConfig(
107
+ callingFlowConfig,
108
+ callingFlowSharedLib.createCallingFlowConfig(
109
+ await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
110
+ )
111
+ )
112
+ )
113
+
114
+ let sendMessageToEndpointComplete = {
115
+ Message:JSON.stringify(messageObject),
116
+ QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointCompleteHdrSqs")
117
+ }
118
+ _izContext.logger.debug("sendMessageToEndpointComplete", sendMessageToEndpointComplete)
119
+ await sqs.sendMessage(_izContext, sendMessageToEndpointComplete)
120
+
121
+ <% } %>
122
+
123
+ let sendMessageToEndpointComplete = {
124
+ Message:JSON.stringify(messageObject),
125
+ QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "FlowSchemaOwnTopicEndpointCompleteHdrSqs")
87
126
  }
88
- _izContext.logger.debug("before sendMessageToFlowSchemaOutEndpointComplete::",sendMessageToFlowSchemaOutEndpointComplete),
89
- await sqs.sendMessage(_izContext, sendMessageToFlowSchemaOutEndpointComplete);
127
+ _izContext.logger.debug("sendMessageToEndpointComplete", sendMessageToEndpointComplete)
128
+ await sqs.sendMessage(_izContext, sendMessageToEndpointComplete)
90
129
 
91
130
  return {
92
- //(<returnParams>)
93
- //(</returnParams>)
131
+ //(<endpointReturn>)
132
+ //(</endpointReturn>)
94
133
  }
95
134
  } catch (err) {
96
135
  _izContext.logger.error('error WebSocketInvoke: ', err)
@@ -9,6 +9,8 @@
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
11
  - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
+ - body: {"MessageAttributes":{"_izContext":{"Value":["x-correlation-connectionId"]}}} # functionName of callingFlow
13
+ - body: {"MessageAttributes":{"_izContext":{"Value":[{"exists":true}]}}}
12
14
  role: <%- roleName %>Role
13
15
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
16
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -33,8 +33,7 @@ const {
33
33
  SOURCE_GENERATE_IAM_ROLE
34
34
  } = require('../../../../../../MainLibs/src/Consts');
35
35
  const templatePath = path.join(__dirname, "template.ejs");
36
- const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
37
- const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
36
+
38
37
 
39
38
  /**
40
39
  * receive objectSchema
@@ -52,14 +51,10 @@ function data(_izContext, flowSchema, srcPath) {
52
51
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
53
52
  let functionName = upperCase(FUNCTION_NAME.flowSchemaOwnTopic)
54
53
  let topicArn = Object.keys(flowSchema.flowSteps)[0];
55
- let statusType = flowSchema.statusType
56
54
  return {
57
55
  templatePath: templatePath,
58
56
  templateData: {
59
57
  topicArn,
60
- statusType,
61
- statusFieldTemplate,
62
- storedCacheTemplate,
63
58
  flowTag: flowSchema.flowTag,
64
59
  },
65
60
  setting: {
@@ -34,9 +34,7 @@ const utils = require('@izara_project/izara-market-library-service-schemas/src/M
34
34
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
35
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
36
36
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
37
- <% if (statusType === "statusField") { %>
38
- const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
39
- <% } %>
37
+
40
38
  /**
41
39
  *
42
40
  *
@@ -77,31 +75,6 @@ module.exports.flowSchemaOwnTopic = async (
77
75
  throw new NoRetryError(`flowTag not found ${requestParams.action}`)
78
76
  }
79
77
 
80
- <% if (statusType === "statusField") { %>
81
- <%- include(statusFieldTemplate) %>
82
- <% } else if (statusType === "storedCache") { %>
83
- <%- include(storedCacheTemplate) %>
84
- let messageObject = {
85
- requestParams:requestParams
86
- }
87
- // create callingFlow
88
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
89
- messageObject,
90
- callingFlowSharedLib.addParentCallingFlowConfig(
91
- callingFlowConfig,
92
- callingFlowSharedLib.createCallingFlowConfig(
93
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.flowSchemaOwnTopicComplete), {}
94
- )
95
- )
96
- )
97
-
98
- let sendMessageToCreateEndpoint = {
99
- Message: JSON.stringify(messageObject),
100
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- topicArn %>")
101
- }
102
- _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
103
- await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
104
- <% } else if (statusType === "none") { %>
105
78
  let messageObject = {
106
79
  requestParams:requestParams
107
80
  }
@@ -122,7 +95,6 @@ module.exports.flowSchemaOwnTopic = async (
122
95
  }
123
96
  _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
124
97
  await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
125
- <% } %>
126
98
 
127
99
  } catch (err) {
128
100
  _izContext.logger.error('error WebSocketInvoke: ', err)
@@ -70,7 +70,7 @@ const createConfirmAfterUploadS3Handler = require('./components/upload/confirmRe
70
70
  const createConfirmAfterUploadS3MainFunction = require('./components/upload/confirmReserved/mainFunction/data');
71
71
  const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
72
72
 
73
- // ** External Topic ** //
73
+ // flowSchema ExternalTopic components //
74
74
  const createExternalWebsocketFunctionYaml = require('./externalTopic/websocket/functionYaml/data');
75
75
  const createExternalWebsocketHandler = require('./externalTopic/websocket/handler/data');
76
76
  const createExternalWebsocketMainFunction = require('./externalTopic/websocket/mainFunction/data');
@@ -102,13 +102,26 @@ const createFlowSchemaOwnTopicEndpointCompleteMainFunction = require('./flowSche
102
102
 
103
103
  const createFlowSchemaOwnTopicQueue = require('./flowSchemaOwnTopic/sns-in/data');
104
104
  const createFlowSchemaOwnTopicSnsOut = require('./flowSchemaOwnTopic/sns-out/data');
105
- // ** EventBridge **
105
+ // flowSchema EventBridge components //
106
106
  const createFlowSchemaEventBridgeFunctionYaml = require('./eventBridge/functionYaml/data');
107
107
  const createFlowSchemaEventBridgeHandler = require('./eventBridge/handler/inv/data');
108
108
  const createFlowSchemaEventBridgeMainFunction = require('./eventBridge/mainFunction/data');
109
109
 
110
- const createFlowSchemaDynamoDb = require('./dynamoDb/data')
111
-
110
+ const createFlowSchemaDynamoDb = require('./dynamoDb/data');
111
+ // create record status Field Complete
112
+ const createCreateObjectCompleteFuntionYaml = require('./CreateRecordComplete/functionYaml/data');
113
+ const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
114
+ const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
115
+ const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
116
+
117
+ const createFlowSchemaRegisterHandlerComplete = require('./createRecordByStatusType/complete/handler/data');
118
+ const createFlowSchemaRegisterMainCompleteFunc = require('./createRecordByStatusType/complete/mainFunction/data');
119
+ const createFlowSchemaRegisterHandlerWbsFunc = require('./createRecordByStatusType/wbs/handler/data');
120
+ const createFlowSchemaRegisterMainWbsFunc = require('./createRecordByStatusType/wbs/mainFunction/data');
121
+ const createFlowSchemaRegisterMainCompleteFuncYaml = require('./createRecordByStatusType/complete/functionYaml/data');
122
+ const createFlowSchemaRegisterMainWbsFuncYaml = require('./createRecordByStatusType/wbs/functionYaml/data');
123
+ const createFlowSchemaRegisterSubscribeOutAll = require('./createRecordByStatusType/subscriptionOutAll/data');
124
+ const createFlowSchemaRegisterSnsInSqs = require('./createRecordByStatusType/sns-in/data');
112
125
 
113
126
  /**
114
127
  * Generates code with templates for different actions
@@ -134,12 +147,18 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
134
147
  createSourceParams.push(
135
148
  ...webSocketResource,
136
149
  ...webSocketGenerateCodeLibs
137
-
138
150
  )
139
151
  }
140
152
 
153
+ // get flowsteps out form all local object schemas
154
+
155
+
141
156
  for (const flowSchema of allLocalFlowSchemas.records) {
142
157
  console.log("flowSchema in Generate TemplateData", flowSchema);
158
+
159
+ if (flowSchema.statusType === "none" || flowSchema.handlerObj === "multi") {
160
+ continue;
161
+ }
143
162
  for (const event of flowSchema.event) {
144
163
  if (event.includes("s3")) {
145
164
  const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
@@ -312,10 +331,52 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
312
331
 
313
332
  if (flowSchema.statusType === "storedCache") {
314
333
  const flowSchemaDynamoDb = createFlowSchemaDynamoDb(_izContext, flowSchema, saveFilePath)
334
+ console.log("generated code storedCache flowSchema")
315
335
  createSourceParams.push(...flowSchemaDynamoDb);
316
- }
336
+ } else if (flowSchema.statusType === "statusField") {
337
+ // wait
338
+
339
+
340
+ // if (flowSchema.statusType === "statusField") {
341
+ // const createRecordCompleteFunctionYaml = createCreateObjectCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
342
+ // const createRecordCompleteHandler = createCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
343
+ // const createRecordCompleteMainFunction = createCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath);
344
+ // const createRecordCompleteQueue = createCreateObjectCompleteQueue(_izContext, flowSchema, saveFilePath);
345
+
346
+ // const recordCompleteResources = [
347
+ // ...createRecordCompleteFunctionYaml,
348
+ // ...createRecordCompleteHandler,
349
+ // ...createRecordCompleteMainFunction,
350
+ // ...createRecordCompleteQueue
351
+ // ];
352
+ // console.log("generated Code createRecordComplete")
353
+ // createSourceParams.push(...recordCompleteResources);
354
+ // }
355
+ }
317
356
  }
318
357
  }
358
+ console.log("flowSchema Register");
359
+ const flowSchemaRegisterHandlerComplete = createFlowSchemaRegisterHandlerComplete(_izContext, saveFilePath);
360
+ const flowSchemaRegisterMainComplete = createFlowSchemaRegisterMainCompleteFunc(_izContext, saveFilePath);
361
+ const flowSchemaRegisterHandlerWbs = createFlowSchemaRegisterHandlerWbsFunc(_izContext, saveFilePath);
362
+ const flowSchemaRegisterMainWbs = createFlowSchemaRegisterMainWbsFunc(_izContext, saveFilePath);
363
+ const flowSchemaRegisterFunctionYamlComplete = createFlowSchemaRegisterMainCompleteFuncYaml(_izContext, saveFilePath);
364
+ const flowSchemaRegisterFunctionYamlWbs = createFlowSchemaRegisterMainWbsFuncYaml(_izContext, saveFilePath);
365
+ const flowSchemaRegisterSubscribeOutAll = createFlowSchemaRegisterSubscribeOutAll(_izContext, allLocalFlowSchemas, saveFilePath);
366
+ const flowSchemaRegisterSnsInSqs = createFlowSchemaRegisterSnsInSqs(_izContext, saveFilePath);
367
+
368
+ const flowSchemaRegisters = [
369
+ ...flowSchemaRegisterHandlerComplete,
370
+ ...flowSchemaRegisterMainComplete,
371
+ ...flowSchemaRegisterHandlerWbs,
372
+ ...flowSchemaRegisterMainWbs,
373
+ ...flowSchemaRegisterFunctionYamlComplete,
374
+ ...flowSchemaRegisterFunctionYamlWbs,
375
+ ...flowSchemaRegisterSnsInSqs,
376
+ ...flowSchemaRegisterSubscribeOutAll,
377
+ ];
378
+ createSourceParams.push(...flowSchemaRegisters);
379
+
319
380
  return createSourceParams;
320
381
  } catch (error) {
321
382
  _izContext.logger.error('Error generating code with template flowSchema:', error);
@@ -126,6 +126,14 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
126
126
  handlerType: [],
127
127
  resources: {}
128
128
  },
129
+ [SOURCE_GENERATE_IAM_ROLE.CreateRecordComplete]: {
130
+ handlerType: [],
131
+ resources: {}
132
+ },
133
+ [SOURCE_GENERATE_IAM_ROLE.RegisterRole]: {
134
+ handlerType: [],
135
+ resources: {}
136
+ },
129
137
  Other: []
130
138
  };
131
139
  const objectTypeList = [];
@@ -237,6 +245,18 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
237
245
  templateData.additionalResourcePermission,
238
246
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.EventBridge].resources
239
247
  )
248
+ } else if (templateData?.roleName?.includes(SOURCE_GENERATE_IAM_ROLE.CreateRecordComplete)) {
249
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.CreateRecordComplete].handlerType.push(templateData);
250
+ processResourcePermissions(
251
+ templateData.additionalResourcePermission,
252
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.CreateRecordComplete].resources
253
+ )
254
+ } else if (templateData.roleName.includes(SOURCE_GENERATE_IAM_ROLE.RegisterRole)) {
255
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.RegisterRole].handlerType.push(templateData);
256
+ processResourcePermissions(
257
+ templateData.additionalResourcePermission,
258
+ groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.RegisterRole].resources
259
+ )
240
260
  }
241
261
  else {
242
262
  // Handle other items
@@ -0,0 +1,66 @@
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
+ 'use strict';
19
+
20
+ // Import required modules
21
+ console.log("generate main PropertySchema");
22
+ const { join } = require('path');
23
+
24
+
25
+ const modules = {
26
+ objectPropertyNodeSchema: require('@izara_project/izara-market-library-service-schemas/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data'),
27
+ relationshipPropertyNodeSchema: require('@izara_project/izara-market-library-service-schemas/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data')
28
+ };
29
+ /**
30
+ * Generates code with templates for different actions
31
+ * @param {Object} _izContext - Context object
32
+ * @param {string} objSchemaPath - Path to the schema
33
+ * @returns {Array} Array of generated code parameters
34
+ */
35
+ async function generateCodeWithTemplate(_izContext, objSchemaPath, settings) {
36
+ try {
37
+ let allCreateSource = [];
38
+ const srcPath = join(objSchemaPath, '../');
39
+
40
+ if (settings.generateName === "propertyNode") {
41
+ let objSchemaPropertyNode = await modules.objectPropertyNodeSchema(
42
+ _izContext,
43
+ settings,
44
+ srcPath
45
+ );
46
+ allCreateSource.push(...objSchemaPropertyNode);
47
+
48
+ let relationshipSchemaPropertyNode = await modules.relationshipPropertyNodeSchema(
49
+ _izContext,
50
+ settings,
51
+ srcPath
52
+ );
53
+ allCreateSource.push(relationshipSchemaPropertyNode);
54
+
55
+ } else {
56
+ throw Error(`Generate propertyNode schema Invalid generateName:${settings.generateName} `);
57
+ }
58
+
59
+ return allCreateSource;
60
+ } catch (error) {
61
+ _izContext.logger.error('Error generating code with template propertyNode schema:', error);
62
+ return [];
63
+ }
64
+ }
65
+
66
+ module.exports = generateCodeWithTemplate;
@@ -0,0 +1,151 @@
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
+ 'use strict';
19
+
20
+ console.log("=== property node schema ===");
21
+
22
+ const path = require('path');
23
+ const fs = require('fs');
24
+ const {
25
+ SOURCE_PATH,
26
+ ADD_ON_DATA_STRUCTURE_TYPE,
27
+ ATTRIBUTE_TAG,
28
+ fieldNameSetting,
29
+ FIELD_NAME_TPYE,
30
+ PROPERTYNODE_TAG,
31
+ SAVE_FILE_NAME
32
+ } = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
33
+
34
+ const templatePath = path.join(__dirname, "./templateObjectPropertyNodeSchema.ejs");
35
+
36
+ const modules = {
37
+ validateAddOnDataStructure: require('../../../libs/ValidateAddOnDataStructure')
38
+ };
39
+ const yaml = require("yaml")
40
+ const objectschemaLocalByPath = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
41
+ const Consts = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts')
42
+ // const objectSchemasBySrc = srcPath
43
+ async function data(_izContext, settings, srcPath) {
44
+
45
+ const configPath = path.join(srcPath, '../../config/serverless.config.yml');
46
+ const serverlessConfig = fs.readFileSync(configPath, 'utf8');
47
+ const config = yaml.parse(serverlessConfig);
48
+ const serviceTag = config.main_config.iz_serviceTag;
49
+ const objectSchemaPath = path.join(srcPath, "schemas")
50
+ // /home/dogsrcute/Programming mint/BackEnd-Service/workspace_by_work/attributee/empty-education/app/src/
51
+
52
+ let allObjectSchemas = await objectschemaLocalByPath.getAllLocalObjectSchemas(
53
+ _izContext,
54
+ objectSchemaPath
55
+ );
56
+ _izContext.logger.debug("allObjectSchemas =>>", allObjectSchemas);
57
+
58
+ if (allObjectSchemas.records.length == 0) {
59
+ throw Error(`Invalid objType:${objTypeString(objType)}, cannot generate attribute tree schema cause objectSchema is not exists`)
60
+ };
61
+
62
+
63
+ let propertyNodeObjectSchemas = [];
64
+ let createSources = [];
65
+
66
+ for (const objectSchema of allObjectSchemas.records) {
67
+
68
+ let objectType = objectSchema.objectType;
69
+
70
+ // validate only addOnndataStructure is type propertyNode.
71
+
72
+ if (!objectSchema.hasOwnProperty("addOnDataStructure") || !Array.isArray(objectSchema.addOnDataStructure) || !objectSchema.addOnDataStructure.length) {
73
+ console.log(`Not have data in addOnDataStructure in objectType:${objectType} ,continute nextObjectSchema`);
74
+ continue;
75
+ };
76
+
77
+ for (let eachAddOnDataStructure of objectSchema.addOnDataStructure) {
78
+
79
+ if (eachAddOnDataStructure.type !== Consts.ADD_ON_DATA_STRUCTURE_TYPE.propertyNode) {
80
+ console.log("continute, not type propertyNode next addOnDataStructure")
81
+ continue
82
+ };
83
+
84
+ const storageResources = objectSchema.storageResources; // storageResource from main objectType
85
+ const storageResourceTag = Object.keys(storageResources); // storage ResourceTag from main objectType
86
+ const compositeKeyDeliminator = objectSchema.compositeKeyDeliminator;
87
+
88
+ propertyNodeObjectSchemas.push(
89
+ { // {subject}property
90
+ objectType: objectType + PROPERTYNODE_TAG.property,
91
+ fieldNames: {
92
+ [objectType + PROPERTYNODE_TAG.property + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName),
93
+ },
94
+ identifiers: [
95
+ {
96
+ type: "identifier",
97
+ fieldName: objectType + PROPERTYNODE_TAG.property + "Id"
98
+ }
99
+ ]
100
+ },
101
+ { // {subject}propertyLabel
102
+ objectType: objectType + PROPERTYNODE_TAG.propertyLabel,
103
+ fieldNames: {
104
+ [objectType + PROPERTYNODE_TAG.propertyLabel + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName),
105
+ },
106
+ identifiers: [
107
+ {
108
+ type: "identifier",
109
+ fieldName: objectType + PROPERTYNODE_TAG.propertyLabel + "Id"
110
+ }
111
+ ]
112
+ }
113
+ );
114
+
115
+ for (let propertyNodeObjectSchema of propertyNodeObjectSchemas) {
116
+ Object.assign(propertyNodeObjectSchema, {
117
+ storageResources: storageResources, // add storageResources
118
+ compositeKeyDeliminator: compositeKeyDeliminator
119
+ })
120
+ for (let attributeTreeFieldName of Object.values(propertyNodeObjectSchema.fieldNames)) {
121
+ Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTag }) // add storageResourceTags for each fieldName
122
+ }
123
+ };
124
+ for (const propertyNodeObjectSchema of propertyNodeObjectSchemas) {
125
+ createSources.push({
126
+ templatePath: templatePath,
127
+ templateData: {
128
+ fieldNames: JSON.stringify(propertyNodeObjectSchema.fieldNames, null, 2),
129
+ identifiers: JSON.stringify(propertyNodeObjectSchema.identifiers, null, 2),
130
+ objectType: propertyNodeObjectSchema.objectType,
131
+ storageResources: JSON.stringify(propertyNodeObjectSchema.storageResources, null, 2),
132
+ compositeKeyDeliminator: propertyNodeObjectSchema.compositeKeyDeliminator
133
+ },
134
+ setting: {
135
+ savePath: path.join(srcPath, SOURCE_PATH.generatedPropertyNode, propertyNodeObjectSchema.objectType + "/"),
136
+ hookPath: path.join(srcPath, "schemaHook", "propertyNode", propertyNodeObjectSchema.objectType, "/"),
137
+ saveFileName: SAVE_FILE_NAME.objectSchema,
138
+ fileExtension: ".js",
139
+ isAppend: false
140
+ }
141
+ })
142
+ };
143
+
144
+
145
+ };//End loop addOn
146
+ }; //End loop objectSchema
147
+
148
+ return createSources;
149
+ }
150
+
151
+ module.exports = data
@@ -0,0 +1,16 @@
1
+ const izara = require("@izara_project/izara-middleware");
2
+ let { pattern } = izara.validatorSchema.stringNotEmpty(); // should not be empty string
3
+
4
+ module.exports = [
5
+ {
6
+ objectType: "<%- objectType %>",
7
+ addOnDataStructure: [ // optional, add for additional setting to objectType
8
+ //(<addOnDataStructure<%- objectType %>>)
9
+ //(</addOnDataStructure<%- objectType %>>)
10
+ ],
11
+ canDelete: true,
12
+ storageResources: <%- storageResources %>,
13
+ fieldNames: <%- fieldNames %>,
14
+ identifiers: <%- identifiers %>
15
+ }
16
+ ]