@izara_project/izara-market-library-service-schemas 1.0.53 → 1.0.55

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 (59) hide show
  1. package/package.json +2 -2
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -1
  3. package/src/reStructure/TemplateConfig.js +4 -1
  4. package/src/reStructure/TemplateData/Auth/generateAuthYml/data.js +58 -0
  5. package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +16 -0
  6. package/src/reStructure/TemplateData/Auth/generateTemplateData.js +51 -0
  7. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -1
  8. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +2 -1
  9. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +2 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +78 -54
  12. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +42 -22
  13. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +44 -9
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +30 -10
  15. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +6 -3
  16. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +12 -16
  17. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +22 -6
  18. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +2 -2
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +4 -0
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +14 -11
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +2 -47
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +4 -1
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +9 -13
  25. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/data.js +6 -6
  26. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/template.ejs +11 -14
  27. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +12 -8
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +6 -2
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +8 -1
  34. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +2 -2
  35. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +2 -7
  36. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +22 -24
  37. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +11 -2
  38. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +11 -5
  39. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/template.ejs +27 -23
  41. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +1 -1
  42. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +1 -1
  43. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/template.ejs +10 -4
  44. package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/storedCacheTemplate.ejs +3 -0
  45. package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/triggerCacheTemplate.ejs +3 -0
  46. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +0 -1
  47. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/data.js +10 -2
  48. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/template.ejs +1 -1
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +18 -2
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -1
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -1
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +0 -75
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +0 -98
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +0 -52
  55. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/data.js +0 -57
  56. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/template.ejs +0 -81
  57. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/data.js +0 -58
  58. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/template.ejs +0 -81
  59. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/statusFieldTemplate.ejs +0 -0
@@ -73,8 +73,8 @@ function data(_izContext, flowSchema, srcPath) {
73
73
  }
74
74
 
75
75
  function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
76
- let functionName = upperCase(flowTag)
77
- let topicArn = `${upperCase(flowStep)}_In`
76
+ let functionName = upperCase(flowStep)
77
+ let topicArn = `${upperCase(flowStep)}`
78
78
 
79
79
  return {
80
80
  templatePath: templatePath,
@@ -26,15 +26,10 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
26
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
27
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
28
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
- const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
30
29
  const externalRequest = require('@izara_project/izara-core-library-external-request');
31
30
  const sns = externalRequest.sns
32
-
33
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
31
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
36
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
37
- const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
32
+
38
33
  //(<optionalRequire>)
39
34
  //(</optionalRequire>)
40
35
  /**
@@ -55,9 +50,9 @@ const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
55
50
  module.exports.<%- functionName %> = async (
56
51
  _izContext,
57
52
  requestParams,
58
- callingFlowConfig = {},
59
53
  //(<additionalParams>)
60
54
  //(</additionalParams>)
55
+ callingFlowConfig = {},
61
56
  ) => {
62
57
 
63
58
  try {
@@ -72,17 +72,18 @@ const createConfirmAfterUploadS3Queue = require('./components/upload/confirmRese
72
72
  // flowSchema ExternalTopic components //
73
73
  const createExternalSqsFunctionYaml = require('./externalTopic/Process/functionYaml/data');
74
74
  const createExternalSqsHandler = require('./externalTopic/Process/handler/data');
75
- const createExternalSqsMainFunction = require('./externalTopic/Process/mainFunction/data');
76
75
  const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
77
76
  const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
78
77
  const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
79
78
  const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
80
79
  const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
81
80
 
81
+ const createFlowSchemaEndpointMainFunction = require('./flowSchemaMainFunction/data');
82
+
82
83
  // flowSchema OwnTopic component
84
+ const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
83
85
  const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data');
84
86
  const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchemaComponent/handler/data');
85
- const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
86
87
 
87
88
  // flowSchema OwnTopicComplete component
88
89
  const createWebSocketCompleteMainFunctionYaml = require("./webSocketComplete/functionYaml/data");
@@ -93,7 +94,6 @@ const createWebSocketCompleteMainSqs = require('./webSocketComplete/sqs/data');
93
94
 
94
95
  const createFlowSchemaOwnTopicEndpointFunctionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
95
96
  const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
96
- const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
97
97
 
98
98
  // flowSchema OnwTopic flowStep component
99
99
  const createFlowSchemaFlowStepFunctionYaml = require('./flowStep/functionYaml/data');
@@ -115,15 +115,13 @@ const createFlowSchemaEventBridgeMainFunction = require('./eventBridge/mainFunct
115
115
  // flowSchema lambdaSync components
116
116
  const createFlowSchemaLambdaSyncFunctionYamlInv = require('./lambdaSync/Inv/functionYaml/data');
117
117
  const createFlowSchemaLambdaSyncHandlerInv = require('./lambdaSync/Inv/handler/data');
118
- const createFlowSchemaLambdaSyncMainFunctionInv = require('./lambdaSync/Inv/mainFunction/data');
119
118
 
120
119
  const createFlowSchemaLambdaSyncFunctionYamlApi = require("./lambdaSync/Api/functionYaml/data");
121
120
  const createFlowSchemaLambdaSyncHandlerApi = require("./lambdaSync/Api/handler/data");
122
- const createFlowSchemaLambdaSyncMainFunctionApi = require("./lambdaSync/Api/mainFunction/data")
123
121
 
124
122
  const createAwaitingMultipleStepDynamoDbData = require('./dynamoDb/data');
125
123
  // create record status Field Complete
126
- const createCreateObjectCompleteFuntionYaml = require('./CreateRecordComplete/functionYaml/data');
124
+ const createCreateObjectCompleteFunctionYaml = require('./CreateRecordComplete/functionYaml/data');
127
125
  const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
128
126
  const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
129
127
  const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
@@ -180,7 +178,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
180
178
  for (const flowSchema of allLocalFlowSchemas.records) {
181
179
  // console.log("flowSchema in Generate TemplateData", flowSchema);
182
180
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
183
- createSourceParams.push(...webSocketGenerateCodeLibs)
181
+ if (!flowSchema.event.includes("s3")) {
182
+ const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
183
+ createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
184
+ }
184
185
 
185
186
  // event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
186
187
  for (const event of flowSchema.event) {
@@ -191,10 +192,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
191
192
  const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
192
193
  const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
193
194
  const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
194
- const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
195
- const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
196
- const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
197
- const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
195
+ // const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
196
+ // const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
197
+ // const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
198
+ // const webSocketCreateObjectCompleteHandler = createWebSocketCreateObjectCompleteHandler(_izContext, flowSchema, saveFilePath);
198
199
 
199
200
  // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
200
201
 
@@ -224,10 +225,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
224
225
  ...functionYamlCreateObjectWebSocket,
225
226
  ...handlerCreateObjectWebSocket,
226
227
  ...mainFunctionCreateObjectWebSocket,
227
- ...webSocketCreateObjectCompleteFunctionYaml,
228
- ...webSocketCreateObjectCompleteQueue,
229
- ...webSocketCreateObjectCompleteMainFunction,
230
- ...webSocketCreateObjectCompleteHandler
228
+ // ...webSocketCreateObjectCompleteFunctionYaml,
229
+ // ...webSocketCreateObjectCompleteQueue,
230
+ // ...webSocketCreateObjectCompleteMainFunction,
231
+ // ...webSocketCreateObjectCompleteHandler
231
232
  ];
232
233
 
233
234
  const getPreSignUrlResources = [
@@ -280,7 +281,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
280
281
  // ** External Topic ** //
281
282
  const externalSqsFunctionYaml = await createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath);
282
283
  const externalSqsHandler = await createExternalSqsHandler(_izContext, flowSchema, saveFilePath);
283
- const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
284
+ // const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
284
285
  const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
285
286
  const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
286
287
 
@@ -291,14 +292,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
291
292
  const externalTopic = [
292
293
  ...externalSqsFunctionYaml,
293
294
  ...externalSqsHandler,
294
- ...externalSqsMainFunction,
295
+ // ...externalSqsMainFunction,
295
296
  ...externalTopicSnsInSqs,
296
297
  ...externalTopicSnsOut,
297
298
  // ...externalTopicCompleteFunctionYml, ...externalTopicCompleteHandler, ...externalTopicCompleteMainFunction
298
299
  ];
299
300
 
300
301
  createSourceParams.push(...externalTopic)
301
-
302
+ console.log("flowSchema external topic generated")
302
303
  } else if (event.includes("ownTopic")) {
303
304
 
304
305
  // flowSchema OwnTopic components
@@ -310,8 +311,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
310
311
  // flowSchemaOwnTopic Endpoint
311
312
  const flowSchemaOwnTopicEndpointFunctionYaml = await createFlowSchemaOwnTopicEndpointFunctionYaml(_izContext, flowSchema, saveFilePath);
312
313
  const flowSchemaOwnTopicEndpointHandler = createFlowSchemaOwnTopicEndpointHandler(_izContext, flowSchema, saveFilePath);
313
- const flowSchemaOwnTopicEndpointMainFunction = await createFlowSchemaOwnTopicEndpointMainFunction(_izContext, flowSchema, saveFilePath);
314
- const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFunctionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
314
+ const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFunctionYaml, ...flowSchemaOwnTopicEndpointHandler]
315
315
 
316
316
  // flowSchemaOwnTopic EndpointComplete
317
317
  // const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
@@ -350,14 +350,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
350
350
  } else if (event.includes("lambdaSyncInv")) {
351
351
  const flowSchemaLambdaSyncFunctionYamlInv = createFlowSchemaLambdaSyncFunctionYamlInv(_izContext, flowSchema, saveFilePath);
352
352
  const flowSchemaLambdaSyncHandlerInv = createFlowSchemaLambdaSyncHandlerInv(_izContext, flowSchema, saveFilePath);
353
- const flowSchemaLambdaSyncMainFunctionInv = createFlowSchemaLambdaSyncMainFunctionInv(_izContext, flowSchema, saveFilePath);
353
+ // const flowSchemaLambdaSyncMainFunctionInv = createFlowSchemaLambdaSyncMainFunctionInv(_izContext, flowSchema, saveFilePath);
354
354
 
355
355
 
356
356
  // Group the resources
357
357
  const lambdaSyncInvResources = [
358
358
  flowSchemaLambdaSyncFunctionYamlInv,
359
359
  flowSchemaLambdaSyncHandlerInv,
360
- flowSchemaLambdaSyncMainFunctionInv,
360
+ // flowSchemaLambdaSyncMainFunctionInv,
361
361
  ];
362
362
 
363
363
  console.log("event lambdaSyncInv generated")
@@ -366,12 +366,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
366
366
  } else if (event.includes("lambdaSyncApi")) {
367
367
  const flowSchemaLambdaSyncFunctionYamlApi = createFlowSchemaLambdaSyncFunctionYamlApi(_izContext, flowSchema, saveFilePath);
368
368
  const flowSchemaLambdaSyncHandlerApi = createFlowSchemaLambdaSyncHandlerApi(_izContext, flowSchema, saveFilePath);
369
- const flowSchemaLambdaSyncMainFunctionApi = createFlowSchemaLambdaSyncMainFunctionApi(_izContext, flowSchema, saveFilePath);
370
369
 
371
370
  const lambdaSyncApiResources = [
372
371
  flowSchemaLambdaSyncFunctionYamlApi,
373
372
  flowSchemaLambdaSyncHandlerApi,
374
- flowSchemaLambdaSyncMainFunctionApi
375
373
  ];
376
374
  createSourceParams.push(...lambdaSyncApiResources)
377
375
  console.log("event lambdaSyncApi generated")
@@ -16,7 +16,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
+
19
20
  const path = require('path');
21
+ const fs = require('fs');
22
+ const yaml = require('yaml');
20
23
 
21
24
  const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
25
  const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
@@ -52,10 +55,15 @@ function data(_izContext, flowSchema, srcPath) {
52
55
  }
53
56
 
54
57
  function createSourceParamsApi(_izContext, flowSchema, srcPath) {
55
- let functionName = upperCase(flowSchema.flowTag)
58
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
56
59
  let handlerType = upperCase(HANDLER.hdrApi)
57
60
  let additionalResourcePermission = defaultIamRolePerAction();
58
61
 
62
+ const configPath = path.join(srcPath, '../../config/serverless.config.yml');
63
+ const serverlessConfig = fs.readFileSync(configPath, 'utf8');
64
+ const config = yaml.parse(serverlessConfig);
65
+ const serviceTag = config.main_config.iz_serviceTag;
66
+
59
67
  return {
60
68
  templatePath: templatePath,
61
69
  templateData: {
@@ -65,7 +73,8 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
65
73
  additionalResourcePermission,
66
74
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
67
75
  roleName: upperCase(flowSchema.flowTag),
68
- event: "post"
76
+ event: "post",
77
+ serviceTag: serviceTag
69
78
  },
70
79
  setting: {
71
80
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -3,12 +3,18 @@
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`) %>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
- - http:
7
- path: <%- firstLetterUpperCase(functionName) %>
6
+ - httpApi:
7
+ path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>
8
8
  method: <%- event %>
9
- cors: true
10
- #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>Authorizer#>
11
- #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>Authorizer#>
9
+ authorizer: authorizerServiceSchema
10
+ #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
11
+ #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
12
+ - httpApi:
13
+ path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>/{targetUserId}
14
+ method: <%- event %>
15
+ authorizer: authorizerServiceSchema
16
+ #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
17
+ #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
12
18
  role: <%- firstLetterUpperCase(roleName) _%>Role
13
19
  #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>IamRole#>
14
20
  #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>IamRole#>
@@ -36,7 +36,7 @@ function data(_izContext, flowSchema, srcPath) {
36
36
  }
37
37
 
38
38
  function createSourceParamsApi(_izContext, flowSchema, srcPath) {
39
- let functionName = upperCase(flowSchema.flowTag)
39
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
40
40
  let handlerType = upperCase(HANDLER.hdrApi)
41
41
 
42
42
  return {
@@ -22,25 +22,28 @@ const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser |
22
22
  const izara = require("@izara_project/izara-middleware");
23
23
  const middleware = izara.middlewareHandler;
24
24
  const <%- functionName %> = require('./<%- functionName %>_Main')
25
-
26
- // validate event params in middlewware before into function.
27
- let validatorSchema = {};
25
+ const callingFlowSharedLib = require("@izara_project/izara-core-library-calling-flow")
26
+ // validate event params in middleware before into function.
27
+ let validatorSchema = {
28
+ //(<validatorSchema>)
29
+ //(</validatorSchema>)
30
+ };
28
31
  // NOTE: not sure about remap_when_flatten and remove_when_flatten function of api still require for validate or not? Tam(19-Nov) -- Yes
29
32
 
30
33
  // for auth userLevel
31
- if (process.env.iz_rbacTargetIdUser) {
32
- validatorSchema.required.push('pathParameters');
33
- validatorSchema.properties.pathParameters = {
34
- additionalProperties: false,
35
- type: ['object', 'boolean'],
36
- required: [process.env.iz_rbacTargetIdUser],
37
- properties: {
38
- }
39
- };
40
- validatorSchema.properties.pathParameters.properties[process.env.iz_rbacTargetIdUser] = {
41
- type: 'string'
42
- };
43
- }
34
+ // if (process.env.iz_rbacTargetIdUser) {
35
+ // validatorSchema["required"] = ['pathParameters'];
36
+ // validatorSchema.properties.pathParameters = {
37
+ // additionalProperties: false,
38
+ // type: ['object', 'boolean'],
39
+ // required: [process.env.iz_rbacTargetIdUser],
40
+ // properties: {
41
+ // }
42
+ // };
43
+ // validatorSchema.properties.pathParameters.properties[process.env.iz_rbacTargetIdUser] = {
44
+ // type: 'string'
45
+ // };
46
+ //}
44
47
  // If not have Authorizer set setMiddlewareSettings.
45
48
  middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true })
46
49
 
@@ -53,16 +56,17 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
53
56
  try {
54
57
 
55
58
  // for targetUserId
56
- let targetUserId = null
57
- if (process.env.iz_rbacTargetIdUser) {
58
- targetUserId = event.pathParameters[process.env.iz_rbacTargetIdUser]
59
- }
59
+ // let targetUserId = null
60
+ // if (process.env.iz_rbacTargetIdUser) {
61
+ // targetUserId = event.pathParameters[process.env.iz_rbacTargetIdUser]
62
+ // }
60
63
  // invoke LambdaFunction
61
- let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>Main(
64
+ let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
62
65
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
63
66
  event.body,
64
- event._izContext.userId, // send userId last element
65
- targetUserId
67
+ //(<additionalParams>)
68
+ //(</additionalParams>)
69
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
66
70
  );
67
71
 
68
72
  // return error to client
@@ -53,7 +53,7 @@ function data(_izContext, flowSchema, srcPath) {
53
53
  }
54
54
 
55
55
  function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
56
- let functionName = upperCase(flowSchema.flowTag)
56
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
57
57
  let handlerType = upperCase(HANDLER.hdrInv)
58
58
  let additionalResourcePermission = defaultIamRolePerAction();
59
59
 
@@ -36,7 +36,7 @@ function data(_izContext, flowSchema, srcPath) {
36
36
  }
37
37
 
38
38
  function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
39
- let functionName = upperCase(flowSchema.flowTag)
39
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
40
40
  let handlerType = upperCase(HANDLER.hdrInv)
41
41
 
42
42
  return {
@@ -21,11 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
  // const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
22
22
 
23
23
  const middleware = require("@izara_project/izara-middleware").middlewareHandler;
24
-
24
+ const callingFlowSharedLib = require("@izara_project/izara-core-library-calling-flow")
25
25
  const <%- functionName %> = require('./<%- functionName %>_Main')
26
26
 
27
27
  // validate event params in middleware before into function.
28
- const validatorSchema = {};
28
+ const validatorSchema = {
29
+ //(<validatorSchema>)
30
+ //(</validatorSchema>)
31
+ };
29
32
  middleware.setValidatorSchema(validatorSchema)
30
33
 
31
34
  module.exports.main = middleware.wrap(async (event, context, callback) => {
@@ -35,9 +38,12 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
35
38
  try {
36
39
 
37
40
  // invoke LambdaFunction
38
- return await <%- functionName %>.<%- functionName %>Main(
41
+ return await <%- functionName %>.<%- functionName %>(
39
42
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
40
- event
43
+ event,
44
+ //(<additionalParams>)
45
+ //(</additionalParams>)
46
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
41
47
  );
42
48
 
43
49
  } catch (err) {
@@ -5,6 +5,9 @@ let [ cacheMainStatus, cacheMain, cacheExist ] = await storedCacheSharedLib.chec
5
5
  //(<keyValueStoredCacheTable>)
6
6
  //(</keyValueStoredCacheTable>)
7
7
  },
8
+ //(<additionalAttributesWhenCreateStoredCache>)
9
+ //(</additionalAttributesWhenCreateStoredCache>),
10
+ createFlowTypeConcat(_izContext,{flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag}),
8
11
  //(<storedCacheConfig>)
9
12
  //(</storedCacheConfig>)
10
13
  )
@@ -5,6 +5,9 @@
5
5
  //(<keyValueTriggerCacheTable>)
6
6
  //(</keyValueTriggerCacheTable>)
7
7
  },
8
+ //(<additionalAttributesWhenCreateTriggerCache>)
9
+ //(</additionalAttributesWhenCreateTriggerCache>)
10
+ createFlowTypeConcat(_izContext,{flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag}),
8
11
  //(<triggerCacheConfig>)
9
12
  //(</triggerCacheConfig>)
10
13
  )
@@ -96,7 +96,6 @@ function createSourceParams(_izContext, allLocalFlowSchemas, srcPath) {
96
96
  for (const flowSchema of allLocalFlowSchemas.records) {
97
97
  console.log("flowSchema", flowSchema)
98
98
  if (flowSchema.event.includes("ownTopic") || flowSchema.event.includes("extTopic")) {
99
- console.log("this is topic")
100
99
  additionalResourcePermission.push(
101
100
  createIamRole(
102
101
  {
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
  const path = require('path');
21
+ const fs = require('fs');
22
+ const yaml = require('yaml');
21
23
 
22
24
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
25
 
@@ -56,14 +58,14 @@ function data(_izContext, objectSchema, srcPath) {
56
58
  let createSourceArray = [];
57
59
  for (const action of Object.values(ACTIONS)) {
58
60
  if (objectSchema.overWriteHandlers?.[action]) {
59
- // if have overWriteHander of action check hdrApi inside
61
+ // if have overWriteHandler of action check hdrApi inside
60
62
  if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrApi)) {
61
63
  // create template data
62
64
  const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
63
65
  createSourceArray.push(createSourceParam)
64
66
  }
65
67
  } else {
66
- // if not have overWriteHander of action will use default handler
68
+ // if not have overWriteHandler of action will use default handler
67
69
  const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
68
70
  if (defaultHandler.includes(HANDLER.hdrApi)) {
69
71
  // create template data and object for create source
@@ -86,6 +88,11 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
86
88
  let functionNameObjectType = objectSchema?.shortNameObjectType ? objectSchema.shortNameObjectType : objectSchema.objectType
87
89
  let functionNameConfig = upperCase(functionNameObjectType) + upperCase(action) + upperCase(shortNameHandler(HANDLER.hdrApi))
88
90
 
91
+ const configPath = path.join(srcPath, '../../config/serverless.config.yml');
92
+ const serverlessConfig = fs.readFileSync(configPath, 'utf8');
93
+ const config = yaml.parse(serverlessConfig);
94
+ const serviceTag = config.main_config.iz_serviceTag;
95
+
89
96
  for (let storageResource of Object.values(objectSchema.storageResources)) {
90
97
  if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
91
98
  // add IamRole for dynamodb depend on tableName in storageResources of objectSchema
@@ -184,6 +191,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
184
191
  roleName: groupBy,
185
192
  action: action,
186
193
  functionNameConfig,
194
+ serviceTag: serviceTag
187
195
  },
188
196
  setting: {
189
197
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -4,7 +4,7 @@
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
6
  - http:
7
- path: <%- firstLetterUpperCase(objectType) %>/<%- firstLetterUpperCase(action) %>
7
+ path: /<%- serviceTag%>/<%- firstLetterUpperCase(objectType) %>/<%- firstLetterUpperCase(action) %>
8
8
  method: <%- event %>
9
9
  cors: true
10
10
  #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>Authorizer#>
@@ -299,7 +299,15 @@ module.exports.createRelationship = async (
299
299
  // awaitingStepId per graphServiceTag
300
300
  awaitingStepIds.push(
301
301
  asyncFlowSharedLib.createAwaitingStepId(
302
- hash({ linkTypeId, relationshipProperties, graphServiceTag: targetStorageResource.graphServiceTag }), // hash id
302
+ hash({
303
+ linkTypeId,
304
+ relationshipProperties,
305
+ graphServiceTag: targetStorageResource.graphServiceTag,
306
+ callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
307
+ firstObject: firstObject,
308
+ secondObject: secondObject,
309
+ relType: relType,
310
+ }), // hash id
303
311
  PREFIX.createRel // prefix, use constant further
304
312
  )
305
313
  );
@@ -340,7 +348,15 @@ module.exports.createRelationship = async (
340
348
  _izContext,
341
349
  awaitingStepIds, // awaitingStepIds
342
350
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
343
- hash({ linkTypeId, relationshipProperties, correlationId: _izContext.correlationIds.get("id") }), // hash id
351
+ hash({
352
+ linkTypeId,
353
+ relationshipProperties,
354
+ correlationId: _izContext.correlationIds.get("id"),
355
+ callingFlowProperties: callingFlowConfig.callingFlowProperties || {},
356
+ firstObject: firstObject,
357
+ secondObject: secondObject,
358
+ relType: relType
359
+ }), // hash id
344
360
  PREFIX.createRel // prefix, use constant further
345
361
  )
346
362
  );
@@ -93,7 +93,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
93
93
  // add argument (to invoke lambda) to passOnProperties[]
94
94
  passOnProperties.push(record.body.Message.returnValue)
95
95
  passOnProperties.push(record.body.Message.status)
96
- passOnProperties.push(record.body.Message.errorsFound)
96
+ passOnProperties.push(record.body.Message.errorsFound),
97
+ passOnProperties.push(record.body.Message.graphServiceTag),
97
98
  passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
98
99
  // passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
99
100
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
@@ -68,7 +68,11 @@ module.exports.createRelationshipComplete = async (
68
68
  hash({
69
69
  linkTypeId,
70
70
  relationshipProperties: returnValue.requestParams.relationshipProperties,
71
- graphServiceTag: graphServiceTag
71
+ graphServiceTag: graphServiceTag,
72
+ callingFlowProperties: passBackProperties.passBackProperties.parentPassBackProperties.callingFlowProperties || {},
73
+ firstObject: returnValue.requestParams.firstObject,
74
+ secondObject: returnValue.requestParams.secondObject,
75
+ relType: returnValue.requestParams.relType,
72
76
  }), // hash id
73
77
  PREFIX.createRel // prefix, use constant further
74
78
  )
@@ -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
- 'use strict';
19
- const path = require('path');
20
-
21
- const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../../../MainLibs/src/Consts');
22
-
23
- const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
24
- const templatePath = path.join(__dirname, "template.ejs");
25
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
26
- const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
- const statusFieldTemplate = path.join(__dirname, "../../../templateBystatusType/statusFieldTemplate.ejs");
28
- const storedCacheTemplate = path.join(__dirname, "../../../templateBystatusType/storedCacheTemplate.ejs");
29
- const triggerCacheTemplate = path.join(__dirname, "../../../templateBystatusType/triggerCacheTemplate.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
-
39
- async function data(_izContext, flowSchema, srcPath) {
40
- return [await createParamsForCreateSource(_izContext, flowSchema, srcPath)]
41
- }
42
-
43
- async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
44
- let functionName = "Process" + upperCase(flowSchema.flowTag);
45
- let tableName = null;
46
- if (flowSchema.statusType === "storedCache") {
47
- let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
48
- for (const storageResource of Object.values(objectSchema.storageResources)) {
49
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
50
- tableName = storageResource.tableName
51
- }
52
- }
53
- }
54
- let flowSchemaComplete = upperCase(flowSchema.flowTag) + "Complete"
55
- return {
56
- templatePath: templatePath,
57
- templateData: {
58
- statusType: flowSchema.statusType,
59
- statusFieldTemplate,
60
- storedCacheTemplate,
61
- triggerCacheTemplate,
62
- flowTag: flowSchema.flowTag,
63
- functionName,
64
- tableName,
65
- flowSchemaComplete
66
- },
67
- setting: {
68
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
69
- saveFileName: `${functionName}_Main`,
70
- fileExtension: ".js",
71
- isAppend: false
72
- }
73
- }
74
- }
75
- module.exports = data