@izara_project/izara-market-library-service-schemas 1.0.39 → 1.0.41

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 (66) hide show
  1. package/package.json +1 -1
  2. package/src/MainLibs/src/Consts.js +2 -2
  3. package/src/TemplateManager/src/libs/Consts.js +2 -1
  4. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +2 -2
  5. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +0 -1
  6. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +0 -1
  7. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +0 -1
  8. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/template.ejs +0 -1
  9. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -1
  11. package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/template.ejs +0 -1
  12. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +1 -14
  13. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +82 -0
  14. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +9 -8
  15. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -2
  16. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +9 -4
  17. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +11 -10
  18. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +90 -49
  19. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +0 -1
  20. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/data.js +1 -1
  22. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +0 -1
  23. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +2 -2
  24. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +5 -4
  25. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +1 -1
  26. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +2 -1
  27. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +21 -16
  28. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +2 -1
  29. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/template.ejs +0 -1
  30. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +28 -23
  31. package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +2 -1
  33. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +4 -1
  34. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +23 -21
  35. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/functionYaml/data.js +13 -7
  36. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/functionYaml/template.ejs +1 -2
  37. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/handler/data.js +6 -6
  38. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/mainFunction/data.js +5 -5
  39. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +4 -4
  40. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -0
  41. package/src/reStructure/TemplateData/perActionComplete/create/yaml/template.ejs +0 -1
  42. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/template.ejs +0 -1
  43. package/src/reStructure/TemplateData/perActionComplete/get/yaml/template.ejs +0 -1
  44. package/src/reStructure/TemplateData/perActionComplete/update/yaml/template.ejs +0 -1
  45. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +1 -0
  46. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +14 -14
  47. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +27 -17
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +2 -1
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +3 -1
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -0
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +4 -0
  52. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/template.ejs +0 -1
  53. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +5 -1
  54. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +5 -2
  55. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +5 -1
  56. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +5 -1
  57. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/template.ejs +0 -1
  58. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +5 -2
  59. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +0 -1
  60. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +5 -1
  61. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/template.ejs +0 -1
  62. package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +1 -2
  63. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +4 -3
  64. package/src/reStructure/libs/ValidateAddOnDataStructure.js +0 -1
  65. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/handler/template.ejs +0 -0
  66. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/webSocketComplete → webSocketComplete}/mainFunction/template.ejs +0 -0
@@ -75,6 +75,7 @@ const createExternalSqsFunctionYaml = require('./externalTopic/functionYaml/data
75
75
  const createExternalSqsHandler = require('./externalTopic/handler/data');
76
76
  const createExternalSqsMainFunction = require('./externalTopic/mainFunction/data');
77
77
  const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
78
+ const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
78
79
 
79
80
  // flowSchema OwnTopic component
80
81
  const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data');
@@ -82,9 +83,9 @@ const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchema
82
83
  const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
83
84
 
84
85
  // flowSchema OwnTopicComplete component
85
- const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./flowSchemaOwnTopic/webSocketComplete/functionYaml/data");
86
- const createFlowSchemaOwnTopicCompleteHandler = require("./flowSchemaOwnTopic/webSocketComplete/handler/data");
87
- const createFlowSchemaOwnTopicCompleteMainFunction = require("./flowSchemaOwnTopic/webSocketComplete/mainFunction/data");
86
+ const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./webSocketComplete/functionYaml/data");
87
+ const createFlowSchemaOwnTopicCompleteHandler = require("./webSocketComplete/handler/data");
88
+ const createFlowSchemaOwnTopicCompleteMainFunction = require("./webSocketComplete/mainFunction/data");
88
89
 
89
90
  // flowSchema OwnTopicEndpoint component
90
91
  const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
@@ -144,10 +145,17 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
144
145
  const webSocketConnectYaml = createWebSocketConnectYaml(_izContext, saveFilePath);
145
146
  const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
146
147
 
148
+ // flowSchema OwnTopic Complete component
149
+ const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, allLocalFlowSchemas, saveFilePath);
150
+ const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, saveFilePath);
151
+ const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, saveFilePath);
152
+ const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
153
+
147
154
  const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
148
155
  if (allLocalFlowSchemas.records.length) {
149
156
  createSourceParams.push(
150
157
  ...webSocketResource,
158
+ ...flowSchemaOwnTopicCompleteComponent
151
159
  )
152
160
  }
153
161
 
@@ -258,13 +266,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
258
266
  const externalSqsHandler = await createExternalSqsHandler(_izContext, flowSchema, saveFilePath);
259
267
  const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
260
268
  const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
261
-
269
+ const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
262
270
  // Group related resources for better organization
263
271
  const externalTopic = [
264
272
  ...externalSqsFunctionYaml,
265
273
  ...externalSqsHandler,
266
274
  ...externalSqsMainFunction,
267
- ...externalTopicSnsInSqs
275
+ ...externalTopicSnsInSqs,
276
+ ...externalTopicSnsOut
268
277
  ];
269
278
 
270
279
  createSourceParams.push(...externalTopic)
@@ -276,11 +285,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
276
285
  const flowSchemaOwnTopicHandler = createFlowSchemaOwnTopicHandler(_izContext, flowSchema, saveFilePath);
277
286
  const flowSchemaOwnTopicMainFunction = await createFlowSchemaOwnTopicMainFunction(_izContext, flowSchema, saveFilePath);
278
287
  const flowSchemaOwnTopicComponent = [...flowSchemaOwnTopicFunctionYaml, ...flowSchemaOwnTopicHandler, ...flowSchemaOwnTopicMainFunction]
279
- // flowSchema OwnTopic Complete component
280
- const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, saveFilePath);
281
- const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, flowSchema, saveFilePath);
282
- const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, flowSchema, saveFilePath);
283
- const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
288
+
284
289
  // flowSchemaOwnTopic Endpoint
285
290
  const flowSchemaOwnTopicEndpointFuntionYaml = await createFlowSchemaOwnTopicEndpointFuntionYaml(_izContext, flowSchema, saveFilePath);
286
291
  const flowSchemaOwnTopicEndpointHandler = createFlowSchemaOwnTopicEndpointHandler(_izContext, flowSchema, saveFilePath);
@@ -288,10 +293,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
288
293
  const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFuntionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
289
294
 
290
295
  // flowSchemaOwnTopic EndpointComplete
291
- // const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
292
- // const flowSchemaOwnTopicEndpointCompleteHandler = createFlowSchemaOwnTopicEndpointCompleteHandler(_izContext, flowSchema, saveFilePath);
293
- // const flowSchemaOwnTopicEndpointCompleteMainFunction = createFlowSchemaOwnTopicEndpointCompleteMainFunction(_izContext, flowSchema, saveFilePath);
294
- // const flowSchemaOwnTopicEndpointCompleteComponent = [...flowSchemaOwnTopicEndpointCompleteFuntionYaml, ...flowSchemaOwnTopicEndpointCompleteHandler, ...flowSchemaOwnTopicEndpointCompleteMainFunction];
296
+ const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
297
+ const flowSchemaOwnTopicEndpointCompleteHandler = createFlowSchemaOwnTopicEndpointCompleteHandler(_izContext, flowSchema, saveFilePath);
298
+ const flowSchemaOwnTopicEndpointCompleteMainFunction = createFlowSchemaOwnTopicEndpointCompleteMainFunction(_izContext, flowSchema, saveFilePath);
299
+ const flowSchemaOwnTopicEndpointCompleteComponent = [...flowSchemaOwnTopicEndpointCompleteFuntionYaml, ...flowSchemaOwnTopicEndpointCompleteHandler, ...flowSchemaOwnTopicEndpointCompleteMainFunction];
295
300
 
296
301
  const flowSchemaOwnTopicQueue = createFlowSchemaOwnTopicQueue(_izContext, flowSchema, saveFilePath);
297
302
  const flowSchemaOwnTopicSnsOut = createFlowSchemaOwnTopicSnsOut(_izContext, flowSchema, saveFilePath);
@@ -302,8 +307,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
302
307
  const flowSchemaOwnTopicFlowStep = [...flowSchemaOwnTopicFlowStepYml, ...flowSchemaOwnTopicFlowStepHandler, ...flowSchemaOwnTopicFlowStepMainFunction]
303
308
  // Group the resources
304
309
  const ownTopicResources = [
305
- ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicCompleteComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicFlowStep
306
- // ...flowSchemaOwnTopicEndpointCompleteComponent
310
+ ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicFlowStep,
311
+ ...flowSchemaOwnTopicEndpointCompleteComponent
307
312
  ];
308
313
 
309
314
 
@@ -76,7 +76,8 @@ function data(_izContext, srcPath) {
76
76
  ]
77
77
  },
78
78
  [
79
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
79
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask"),
80
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "RegisterRecords ")
80
81
  ]
81
82
  ),
82
83
  createIamRole(
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
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
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -19,7 +19,7 @@ along with this program. If not, see
19
19
  'use strict';
20
20
 
21
21
  const hash = require('@izara_project/izara-shared-core').objectHash;
22
- const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
22
+ const { getObjectSchema, identifiersObject } = require('@izara_project/izara-core-library-service-schemas');
23
23
 
24
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
25
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
@@ -29,7 +29,7 @@ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
29
 
30
30
  const externalRequest = require('@izara_project/izara-core-library-external-request');
31
31
  const sns = externalRequest.sns
32
- const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
32
+ const generatedCodeLibs = require("../../../libs/source/GenerateCodeLibs");
33
33
 
34
34
  const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
35
35
  const { NoRetryError } = require('@izara_project/izara-core-library-core')
@@ -37,7 +37,7 @@ const { v4: uuidv4 } = require('uuid')
37
37
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
38
38
  // const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
39
39
  const { generateCodeLibs: { consts: TOPIC_NAME_GENERATE_CODE } } = require('@izara_project/izara-market-library-service-schemas')
40
-
40
+ const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
41
41
  /**
42
42
  * description of function.
43
43
  * @param {Object} _izContext
@@ -61,6 +61,8 @@ module.exports.registerCompleteMain = async (
61
61
  _izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
62
62
  _izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
63
63
 
64
+ let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
65
+
64
66
  // getflowSchema by using send topic name
65
67
  // ! didn't got topicName from requestParams complete endpoint must send flowTag with identifiersTask
66
68
 
@@ -79,12 +81,12 @@ module.exports.registerCompleteMain = async (
79
81
 
80
82
  let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
81
83
 
82
- const getResult = async (objectType) => {
84
+ const getResult = async (objType) => {
83
85
  const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
84
86
  _izContext,
85
87
  {
86
- objectType: objectType,
87
- serviceTag: process.env.iz_serviceTag,
88
+ objectType: objType.objectType,
89
+ serviceTag: objType.serviceTag
88
90
  })
89
91
 
90
92
  _izContext.logger.debug("==> objectSchema", objectSchema)
@@ -92,27 +94,27 @@ module.exports.registerCompleteMain = async (
92
94
  const result = await externalRequest.lambda.invokeSync(_izContext,
93
95
  await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
94
96
  {
95
- identifiers: identifiersLibs.identifiersFromIdentifiersConcat(_izContext, objectType, requestParams.identifiersTask),
96
- objectType: objectType
97
+ identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
98
+ objectType: objType.objectType
97
99
  }
98
100
  )
99
101
 
100
102
  for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
101
103
  if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
102
- if (fieldName[result] !== "complete" || fieldName[result] !== "error") {
104
+ if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
103
105
  // if status is not complete or error will save data into table
104
106
  await dynamodbSharedLib.putItem(_izContext,
105
- await dynamodbSharedLib.tableName(_izContext, "RegisterRecord"),
107
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
106
108
  {
107
109
  identifiersTask: requestParams.identifiersTask,
108
- connecttionId: connecttionId
110
+ connectionId: connectionId
109
111
  }
110
112
  )
111
113
  } else {
112
114
  if (!result) {
113
- await generatedCodeLibs.postToConnection({ message: "not have record" }, connecttionId)
115
+ await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
114
116
  } else {
115
- await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
117
+ await generatedCodeLibs.postToConnection({ message: result }, connectionId)
116
118
  }
117
119
  }
118
120
  }
@@ -122,18 +124,20 @@ module.exports.registerCompleteMain = async (
122
124
  // check statusType
123
125
  switch (flowSchema.statusType) {
124
126
  case "statusField":
125
- await getResult(flowSchema.objType.objectType);
127
+ await getResult(flowSchema.objType);
126
128
  break;
127
129
  case "storedCache":
128
- await getResult(flowSchema.objType.objectType);
130
+ await getResult(flowSchema.objType);
129
131
  break;
130
132
 
131
133
  case "none":
132
134
 
133
135
  let identifier = {};
134
- if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifierisField)) {
135
- for (const fieldNames of requestParams.identifierisField) {
136
- Object.assign(identifier, { [fieldNames]: requestParams[fieldNames] })
136
+ if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifiersField)) {
137
+ for (const fieldNames of requestParams.identifiersField) {
138
+ Object.assign(identifier, {
139
+ [fieldNames]: requestParams[fieldNames]
140
+ })
137
141
  }
138
142
  identifier = identifier;
139
143
  } else {
@@ -142,27 +146,28 @@ module.exports.registerCompleteMain = async (
142
146
 
143
147
  // get task before putItem
144
148
  let tasks = await dynamodbSharedLib.query(_izContext,
145
- await dynamodbSharedLib.tableName(_izContext, "ResgisterRecords"),
149
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
146
150
  {
147
151
  identifiersTask: hash(identifier)
148
152
  }
149
153
  )
150
- if (tasks && tasks.length > 0) {
154
+
155
+ if (tasks.Items && tasks.Items.length > 0) {
151
156
  await Promise.all(tasks.Items.map(async (task) => {
152
- await generatedCodeLibs.postToConnection({ message: task }, task.connecttionId)
157
+ await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
153
158
  }))
154
159
  } else {
155
160
  await dynamodbSharedLib.putItem(_izContext,
156
161
  await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
157
162
  {
158
163
  identifiersTask: hash(identifier),
159
- connecttionId: connecttionId
164
+ connecttionId: connectionId
160
165
  }
161
166
  )
162
167
  }
163
168
  break
164
169
  default:
165
- throw new NoRetryError(`statusType not found ${getFlowSchema.statusType}`)
170
+ throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
166
171
  }
167
172
 
168
173
  } catch (err) {
@@ -59,7 +59,7 @@ const createRegisterTable = (_izContext, srcPath) => {
59
59
  attributes: [
60
60
  {
61
61
  keyType: "partitionKey",
62
- AttributeName: "identifierTask",
62
+ AttributeName: "identifiersTask",
63
63
  AttributeType: "S"
64
64
  },
65
65
  {
@@ -57,7 +57,8 @@ function createDataForSubscriptionOutAll(_izContext, allLocalFlowSchemas, srcPat
57
57
  let queueName;
58
58
  if (flowSchema.outputTopic) {
59
59
  let flowStepOut = Object.keys(flowSchema.flowSteps)[1].split("_")
60
- queueName = flowStepOut[3] + flowStepOut[2]
60
+ // queueName = flowStepOut[3] + flowStepOut[2]
61
+ queueName = flowStepOut[0] + flowSchema.flowTag + "Complete";
61
62
  }
62
63
 
63
64
  if (queueName) {
@@ -26,6 +26,7 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
26
26
  // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
27
27
  const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
28
28
  const { <%- functionName%>Main } = require("./<%- firstLetterUpperCase(functionName) %>_Main");
29
+ const izara = require("@izara_project/izara-middleware");
29
30
 
30
31
  module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
31
32
 
@@ -68,6 +69,7 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
68
69
  { message: result },
69
70
  connectionId
70
71
  )
72
+ return (izara.response.webSocketSuccess());
71
73
  break
72
74
  }
73
75
  } else {
@@ -75,11 +77,12 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
75
77
  // await postMessage({ message: event.message }, connId);
76
78
  await postToConnection({ message: event.message }, connId);
77
79
  }
80
+ return izara.response.webSocketSuccess()
78
81
  } catch (err) {
79
82
  const connId = event.requestContext.connectionId
80
83
  event._izContext.logger.error('Error, WebSocket: ', err);
81
- // await sendErrorMessage({ message: err.message }, connId);
82
84
  await postToConnection({ message: err.message }, connId);
85
+ return (izara.response.failure(err));
83
86
  }
84
87
  });
85
88
  <%_ const join = require('path').join _%>
@@ -19,7 +19,7 @@ along with this program. If not, see
19
19
  'use strict';
20
20
 
21
21
  const hash = require('@izara_project/izara-shared-core').objectHash;
22
- const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
22
+ const { getObjectSchema, identifiersObject } = require('@izara_project/izara-core-library-service-schemas');
23
23
 
24
24
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
25
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
@@ -59,7 +59,7 @@ module.exports.registerMain = async (
59
59
  //(</additionalParams>)
60
60
  ) => {
61
61
  try {
62
- let connecttionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
62
+ let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
63
63
  // receive flowTag and identifiers
64
64
  let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
65
65
  flowTag: requestParams.flowTag,
@@ -71,12 +71,12 @@ module.exports.registerMain = async (
71
71
  throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
72
72
  }
73
73
 
74
- const getResult = async (objectType) => {
74
+ const getResult = async (objType) => {
75
75
  const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
76
76
  _izContext,
77
77
  {
78
- objectType: objectType,
79
- serviceTag: process.env.iz_serviceTag,
78
+ objectType: objType.objectType,
79
+ serviceTag: objType.serviceTag,
80
80
  })
81
81
 
82
82
  _izContext.logger.debug("==> objectSchema", objectSchema)
@@ -84,27 +84,27 @@ module.exports.registerMain = async (
84
84
  const result = await externalRequest.lambda.invokeSync(_izContext,
85
85
  await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
86
86
  {
87
- identifiers: identifiersLibs.identifiersFromIdentifiersConcat(_izContext, objectType, requestParams.identifiersTask),
88
- objectType: objectType
87
+ identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
88
+ objectType: objType.objectType
89
89
  }
90
90
  )
91
91
 
92
92
  for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
93
93
  if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
94
- if (fieldName[result] !== "complete" || fieldName[result] !== "error") {
94
+ if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
95
95
  // if status is not complete or error will save data into table
96
96
  await dynamodbSharedLib.putItem(_izContext,
97
- await dynamodbSharedLib.tableName(_izContext, "RegisterRecord"),
97
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
98
98
  {
99
99
  identifiersTask: requestParams.identifiersTask,
100
- connecttionId: connecttionId
100
+ connectionId: connectionId
101
101
  }
102
102
  )
103
103
  } else {
104
104
  if (!result) {
105
- await generatedCodeLibs.postToConnection({ message: "not have record" }, connecttionId)
105
+ await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
106
106
  } else {
107
- await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
107
+ await generatedCodeLibs.postToConnection({ message: result }, connectionId)
108
108
  }
109
109
  }
110
110
  }
@@ -114,16 +114,18 @@ module.exports.registerMain = async (
114
114
  // Initialize storedCacheData variable that will be used in multiple switch cases
115
115
  switch (flowSchema.statusType) {
116
116
  case "statusField":
117
- await getResult(flowSchema.objType.objectType)
117
+ await getResult(flowSchema.objType)
118
118
  break;
119
119
  case "storedCache":
120
- await getResult(flowSchema.objType.objectType)
120
+ await getResult(flowSchema.objType)
121
121
  break;
122
122
  case "none":
123
123
  let identifier = {};
124
- if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifierisField)) {
125
- for (const fieldNames of requestParams.identifierisField) {
126
- Object.assign(identifier, { [fieldNames]: requestParams[fieldNames] })
124
+ if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifiersField)) {
125
+ for (const fieldNames of requestParams.identifiersField) {
126
+ Object.assign(identifier, {
127
+ [fieldNames]: requestParams[fieldNames]
128
+ })
127
129
  }
128
130
  identifier = identifier;
129
131
  } else {
@@ -132,21 +134,21 @@ module.exports.registerMain = async (
132
134
 
133
135
  // get task before putItem
134
136
  let tasks = await dynamodbSharedLib.query(_izContext,
135
- await dynamodbSharedLib.tableName(_izContext, "ResgisterRecords"),
137
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
136
138
  {
137
139
  identifiersTask: hash(identifier)
138
140
  }
139
141
  )
140
- if (tasks && tasks.length > 0) {
142
+ if (tasks.Items && tasks.Items.length > 0) {
141
143
  await Promise.all(tasks.Items.map(async (task) => {
142
- await generatedCodeLibs.postToConnection({ message: task }, task.connecttionId)
144
+ await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
143
145
  }))
144
146
  } else {
145
147
  await dynamodbSharedLib.putItem(_izContext,
146
148
  await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
147
149
  {
148
150
  identifiersTask: hash(identifier),
149
- connecttionId: connecttionId
151
+ connectionId: connectionId
150
152
  }
151
153
  )
152
154
  }
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  const path = require('path');
20
20
 
21
21
  const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
- const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
23
23
  const {
24
24
  SOURCE_PATH,
25
25
  defaultIamRolePerAction,
@@ -34,8 +34,8 @@ const {
34
34
  externalResourceYaml,
35
35
  SOURCE_GENERATE_IAM_ROLE,
36
36
  SQS_RESOURCE
37
- } = require('../../../../../../MainLibs/src/Consts');
38
- const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../../GenerateCodeLibs/src/Consts');
37
+ } = require('../../../../../MainLibs/src/Consts');
38
+ const { TOPIC_NAME_GENERATE_CODE } = require('../../../../../GenerateCodeLibs/src/Consts');
39
39
 
40
40
  const templatePath = path.join(__dirname, "template.ejs");
41
41
  const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
@@ -47,11 +47,11 @@ const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
47
47
  * @return {{templatePath, templateData,setting}}
48
48
  */
49
49
 
50
- function data(_izContext, srcPath) {
51
- return [createSourceParams(_izContext, srcPath)]
50
+ function data(_izContext, allLocalFlowSchemas, srcPath) {
51
+ return [createSourceParams(_izContext, allLocalFlowSchemas, srcPath)]
52
52
  }
53
53
 
54
- function createSourceParams(_izContext, srcPath) {
54
+ function createSourceParams(_izContext, allLocalFlowSchemas, srcPath) {
55
55
  let functionName = "WebSocketComplete"
56
56
  let handlerType = upperCase(HANDLER.hdrSqs)
57
57
  let additionalResourcePermission = defaultIamRolePerAction();
@@ -90,6 +90,12 @@ function createSourceParams(_izContext, srcPath) {
90
90
  resourceNames(RESOURCE_CLASSES.sqs, queueName),
91
91
  resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
92
92
  ]
93
+ ),
94
+ createIamRole(
95
+ {
96
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.subscribe]
97
+ },
98
+ allLocalFlowSchemas.records.map(flowSchema => resourceNames(RESOURCE_CLASSES.sns, flowSchema.flowTag + "Complete_Out"))
93
99
  )
94
100
  )
95
101
 
@@ -102,7 +108,7 @@ function createSourceParams(_izContext, srcPath) {
102
108
  handlerType,
103
109
  additionalResourcePermission,
104
110
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
105
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaOwnTopic,
111
+ roleName: "WebSocketMain",
106
112
  queueName: queueName
107
113
  },
108
114
  setting: {
@@ -4,11 +4,10 @@
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
6
  - sqs:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %> + <%- handlerType %>
8
8
  batchSize: 10
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
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
  const path = require('path');
20
- const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
21
- const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
22
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
20
+ const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
21
+ const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
22
+ const { SOURCE_PATH } = require('../../../../../MainLibs/src/Consts');
23
23
  const templatePath = path.join(__dirname, "template.ejs")
24
24
 
25
25
  /**
@@ -31,11 +31,11 @@ const templatePath = path.join(__dirname, "template.ejs")
31
31
  */
32
32
 
33
33
 
34
- function data(_izContext, flowSchema, srcPath) {
35
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
34
+ function data(_izContext, srcPath) {
35
+ return [createParamsForCreateSource(_izContext, srcPath)]
36
36
  }
37
37
 
38
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
38
+ function createParamsForCreateSource(_izContext, srcPath) {
39
39
  let functionName = "WebSocketComplete"
40
40
  let handlerType = upperCase(HANDLER.hdrSqs)
41
41
  let queueName = upperCase(functionName) + upperCase(handlerType);
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
20
 
21
- const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../../MainLibs/src/Consts');
22
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
21
+ const { HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { SOURCE_PATH } = require('../../../../../MainLibs/src/Consts');
23
23
  const templatePath = path.join(__dirname, "template.ejs");
24
24
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
25
25
 
@@ -32,11 +32,11 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
32
32
  */
33
33
 
34
34
 
35
- function data(_izContext, flowSchema, srcPath) {
36
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
35
+ function data(_izContext, srcPath) {
36
+ return [createParamsForCreateSource(_izContext, srcPath)]
37
37
  }
38
38
 
39
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
+ function createParamsForCreateSource(_izContext, srcPath) {
40
40
  let functionName = "WebSocketComplete"
41
41
  return {
42
42
  templatePath: templatePath,
@@ -118,7 +118,7 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
118
118
  handlerType: [],
119
119
  resources: {}
120
120
  },
121
- "WebsocketConnect": {
121
+ "WebSocketMain": {
122
122
  handlerType: [],
123
123
  resources: {}
124
124
  },
@@ -233,11 +233,11 @@ const createSharedResource = (_izContext, createSourceParams, srcPath) => {
233
233
  templateData.additionalResourcePermission,
234
234
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole].resources
235
235
  )
236
- } else if (templateData?.roleName?.includes("WebsocketConnect")) {
237
- groupedByObjectType["WebsocketConnect"].handlerType.push(templateData);
236
+ } else if (templateData?.roleName?.includes("WebSocketMain")) {
237
+ groupedByObjectType["WebSocketMain"].handlerType.push(templateData);
238
238
  processResourcePermissions(
239
239
  templateData.additionalResourcePermission,
240
- groupedByObjectType["WebsocketConnect"].resources
240
+ groupedByObjectType["WebSocketMain"].resources
241
241
  )
242
242
  } else if (templateData?.roleName?.includes(SOURCE_GENERATE_IAM_ROLE.EventBridge)) {
243
243
  groupedByObjectType[SOURCE_GENERATE_IAM_ROLE.EventBridge].handlerType.push(templateData);
@@ -127,6 +127,7 @@ module.exports.createObjectComplete = async (
127
127
  identifiers: returnValue.objInstanceFull.identifiers,
128
128
  fields: returnValue.objInstanceFull.fields
129
129
  },
130
+ relationships: returnValue.relationships,
130
131
  status: status,
131
132
  errorsFound: errorsFound
132
133
  }
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,7 +8,6 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
- - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
11
  role: <%- roleName %>Role
13
12
  #<#<%- functionName %><%- handlerType %>IamRole#>
14
13
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -34,6 +34,7 @@ const modules = {
34
34
  */
35
35
  async function generateCodeWithTemplate(_izContext, objSchemaPath, settings) {
36
36
  try {
37
+ console.log("settings generateCodeWithTemplate", settings)
37
38
  let allCreateSource = [];
38
39
  const srcPath = join(objSchemaPath, '../');
39
40