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

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 (54) 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 +17 -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 +52 -41
  12. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +3 -1
  13. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +1 -1
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +1 -1
  15. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +2 -2
  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/externalTopic/Process/functionYaml/data.js +13 -10
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +1 -46
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +4 -1
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +8 -12
  23. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/data.js +5 -5
  24. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/template.ejs +7 -12
  25. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +12 -8
  26. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +6 -2
  27. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +7 -1
  32. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +2 -2
  33. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +2 -7
  34. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +12 -16
  35. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +1 -1
  36. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +11 -5
  37. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/data.js +1 -1
  38. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/template.ejs +27 -23
  39. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +1 -1
  41. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/template.ejs +10 -4
  42. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +0 -1
  43. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +9 -1
  44. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -1
  45. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +0 -75
  46. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +0 -98
  47. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +0 -52
  48. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/data.js +0 -57
  49. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/template.ejs +0 -81
  50. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/data.js +0 -58
  51. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/template.ejs +0 -81
  52. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/statusFieldTemplate.ejs +0 -0
  53. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/storedCacheTemplate.ejs +0 -0
  54. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/triggerCacheTemplate.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,7 +24,7 @@
24
24
  "@izara_project/izara-core-library-core": "^1.0.20",
25
25
  "@izara_project/izara-core-library-external-request": "^1.0.20",
26
26
  "@izara_project/izara-core-library-logger": "^1.0.7",
27
- "@izara_project/izara-core-library-service-schemas": "^1.0.83",
27
+ "@izara_project/izara-core-library-service-schemas": "^1.0.84",
28
28
  "@izara_project/izara-core-library-sns": "^1.0.6",
29
29
  "@izara_project/izara-core-library-sqs": "^1.0.4",
30
30
  "@izara_project/izara-shared": "^1.0.126",
@@ -108,7 +108,7 @@ async function validateSchemaPerRecord(
108
108
  lambdaFunctionName,
109
109
  objType,
110
110
  action,
111
- setting = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME }
111
+ setting = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME, specificFieldNames: [] }
112
112
  ) {
113
113
  try {
114
114
  record._izContext.logger.debug("validateSchemaPerRecord: ",
@@ -47,7 +47,10 @@ module.exports = {
47
47
  flowSchema: './TemplateData/flowSchema/generateTemplateData.js',
48
48
 
49
49
  // ** endpoint per service **
50
- endpointPerServiceConfig: './TemplateData/EndpointPerService/generateTemplateData.js'
50
+ endpointPerServiceConfig: './TemplateData/EndpointPerService/generateTemplateData.js',
51
+
52
+ // ** Auth **
53
+ auth: "./TemplateData/Auth/generateTemplateData.js"
51
54
  },
52
55
  Plugin: {
53
56
 
@@ -0,0 +1,58 @@
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
+ const path = require('path');
21
+ const fs = require('fs');
22
+ const yaml = require('yaml');
23
+ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
24
+ const {
25
+ SOURCE_PATH,
26
+ } = require("../../../../MainLibs/src/Consts.js");
27
+ const {
28
+ firstLetterLowerCase: lowerCase,
29
+ firstLetterUpperCase: upperCase,
30
+ } = require('../../../../MainLibs/src/Utils.js');
31
+
32
+ const templatePath = path.join(__dirname, "./template.ejs")
33
+
34
+ /**
35
+ * receive objectSchema
36
+ * create data for hdrInv template
37
+ *
38
+ * @param {Object} objectSchema
39
+ * @return {{ templatePath, templateData, setting } }
40
+ */
41
+ function data(_izContext, srcPath) {
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {},
45
+ setting: {
46
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
47
+ saveFileName: "Authorizer",
48
+ fileExtension: '.yml',
49
+ isAppend: true
50
+ }
51
+ }
52
+
53
+ }
54
+
55
+
56
+
57
+
58
+ module.exports = data;
@@ -0,0 +1,17 @@
1
+ authorizer:
2
+ authorizerServiceSchema:
3
+ type: request
4
+ functionArn: ${self:custom.iz_authorizerServiceSchemaV2}
5
+ identitySource:
6
+ - $request.header.Authorization
7
+ - $context.routeKey
8
+ resultTtlInSeconds: 300
9
+
10
+ authorizerIdentifiers:
11
+ type: request
12
+ functionArn: ${self:custom.iz_authorizerServiceSchemaV2}
13
+ identitySource:
14
+ - $request.header.Authorization
15
+ - $context.routeKey
16
+ - $request.querystring.identifiers
17
+ resultTtlInSeconds: 300
@@ -0,0 +1,51 @@
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
+ const { join } = require('path');
21
+ const {
22
+ getAllLocalObjectSchemasWithHierarchy
23
+ } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
24
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
25
+ // Import handlers and generators
26
+ const generateAuth = require('./generateAuthYml/data')
27
+
28
+ // Import code libs generator
29
+ // const createGenerateCodeLibs = require('./libs/data');
30
+
31
+ /**
32
+ * Generates code from templates based on object schemas
33
+ * @param {Object} _izContext - Context object
34
+ * @param {string} objSchemaPath - Path to object schema
35
+ * @returns {Promise<Array>} - Array of parameter objects for code generation
36
+ */
37
+ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
38
+ try {
39
+ const saveFilePath = join(objSchemaPath, `../`);
40
+ let authYamlFile = generateAuth(_izContext, saveFilePath)
41
+
42
+ const createSourceParams = [authYamlFile];
43
+
44
+ return createSourceParams;
45
+ } catch (error) {
46
+ _izContext.logger.error('Error generating code with template endpointPerService:', error);
47
+ return [];
48
+ }
49
+ }
50
+
51
+ module.exports = generateCodeWithTemplate;
@@ -48,8 +48,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
48
48
  let lambdaFunctionResponse = await <%- action %>Main(
49
49
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
50
50
  event.body,
51
+ //(<additionalParams>)
52
+ //(</additionalParams>)
51
53
  callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
52
-
53
54
  );
54
55
 
55
56
  // return error to client
@@ -89,7 +89,8 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
89
89
  //(</additionalParams>)
90
90
 
91
91
  passOnProperties.push(record.body.Message);
92
- passOnProperties.push(OBJTYPE);
92
+ //(<additionalParams>)
93
+ //(</additionalParams>)
93
94
  passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
94
95
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
95
96
 
@@ -56,6 +56,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
56
56
  return await <%- action %>Main(
57
57
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
58
58
  event,
59
+ //(<additionalParams>)
60
+ //(</additionalParams>)
59
61
  callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
60
62
  );
61
63
 
@@ -86,6 +86,8 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
86
86
  //(</additionalParams>)
87
87
 
88
88
  passOnProperties.push(record.body.Message);
89
+ //(<additionalParams>)
90
+ //(</additionalParams>)
89
91
  passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
90
92
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
91
93
 
@@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
+ const lodash = require("lodash")
19
20
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
20
21
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
21
22
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
@@ -24,24 +25,19 @@ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
24
25
 
25
26
  const externalRequest = require('@izara_project/izara-core-library-external-request');
26
27
  const sns = externalRequest.sns;
27
- const lambda = externalRequest.lambda
28
28
 
29
29
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
30
- const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
31
30
 
32
31
  const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
33
32
 
34
33
  const hash = require('@izara_project/izara-shared-core').objectHash;
35
34
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
36
- const path = require('path')
37
- const schemasPath = path.join(__dirname, '../schemas');
38
35
  const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
39
36
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
40
-
37
+ const middlewareConsts = require('@izara_project/izara-middleware').consts
38
+ const graphSharedLibs = require('@izara_project/izara-core-library-graph-service')
41
39
  const {
42
- generateDynamoDbIdentifiers,
43
40
  dynamoDbIdentifiersByStorageResource,
44
- collectGetData
45
41
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
46
42
 
47
43
 
@@ -56,10 +52,6 @@ const PREFIX = {
56
52
  //-----------------------------------------------------------------------------------------------------------
57
53
  const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER, GRAPH_HANDLER_SERVICE_NAME } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
58
54
  const { createDataDetailsLib } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
59
- const { createLinkTypeId, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
60
- const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
61
- const lodash = require("lodash")
62
- const { createRelTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
63
55
  const createNodeLib = require('@izara_project/izara-core-library-service-schemas').createNodeLib
64
56
  //(<optionalRequire>)
65
57
  //(</optionalRequire>)
@@ -74,7 +66,9 @@ const createNodeLib = require('@izara_project/izara-core-library-service-schemas
74
66
  module.exports.createMain = async (
75
67
  _izContext,
76
68
  requestParams,
77
- callingFlowConfig
69
+ //(<additionalParams>)
70
+ //(</additionalParams>)
71
+ callingFlowConfig = {}
78
72
  ) => {
79
73
  try {
80
74
  _izContext.logger.debug("function CreateMain:", {
@@ -117,12 +111,13 @@ module.exports.createMain = async (
117
111
  );
118
112
  _izContext.logger.debug("objectSchemas", objectSchemas);
119
113
 
120
-
114
+ let userAgent = _izContext.correlationIds.get(middlewareConsts.USER_AGENT)
115
+ _izContext.logger.debug("userAgent::", userAgent);
121
116
 
122
117
  let createDataDetails = await createDataDetailsLib(
123
118
  _izContext,
124
119
  objectSchemas,
125
- );
120
+ );
126
121
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
127
122
 
128
123
 
@@ -132,11 +127,11 @@ module.exports.createMain = async (
132
127
  }
133
128
  errorsFound.push(
134
129
  ...await createNodeLib.validateRequiredOnCreateLinks(
135
- _izContext,
136
- objType,
137
- requestParams.relationships,
130
+ _izContext,
131
+ objType,
132
+ requestParams.relationships,
138
133
  )
139
- )
134
+ )
140
135
  _izContext.logger.debug("errorsFound", errorsFound)
141
136
 
142
137
  // end validate
@@ -391,12 +386,14 @@ module.exports.createMain = async (
391
386
  return fields
392
387
  }
393
388
  /// step save awaitingMultipleStep of storageType graph ...........................................................
394
-
395
- await asyncFlowSharedLib.createAwaitingMultipleSteps(
396
- _izContext,
397
- allAwaitingStepsId,
398
- asyncFlowSharedLib.createPendingStepId((hash({ objType: objType, identifiers: objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
399
- );
389
+ if (!userAgent) {
390
+ _izContext.logger.debug("not api will create awaitingStep")
391
+ await asyncFlowSharedLib.createAwaitingMultipleSteps(
392
+ _izContext,
393
+ allAwaitingStepsId,
394
+ asyncFlowSharedLib.createPendingStepId((hash({ objType: objType, identifiers: objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
395
+ );
396
+ }
400
397
  //............................................................................................................
401
398
 
402
399
  // process storageType : graph
@@ -427,25 +424,39 @@ module.exports.createMain = async (
427
424
  settings: { updatePropertiesOnMatch: false },
428
425
  originTimestamp: Date.now(),
429
426
  });
430
-
431
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
432
- messageObject,
433
- callingFlowSharedLib.addParentCallingFlowConfig(
434
- callingFlowConfig, // receive parent callingFlowConfig.
435
- callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
436
- //(<callingFlowProperties>)
437
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
438
- //(</callingFlowProperties>)
439
- )
427
+ if (userAgent) {
428
+ _izContext.logger.debug("have userAgent will invoke GraphHandler")
429
+ let createNodeResult = await graphSharedLibs.createNodeV2(
430
+ _izContext,
431
+ graphServiceName,
432
+ objType,
433
+ objInstanceFullForGraph,
434
+ requestParams.relationships || [],
435
+ Date.now(),
436
+ { updatePropertiesOnMatch: false },
440
437
  )
441
- );
438
+ return createNodeResult
439
+ } else {
440
+ _izContext.logger.debug("not have userAgent will send Message to GraphHandler")
441
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
442
+ messageObject,
443
+ callingFlowSharedLib.addParentCallingFlowConfig(
444
+ callingFlowConfig, // receive parent callingFlowConfig.
445
+ callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
446
+ //(<callingFlowProperties>)
447
+ await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
448
+ //(</callingFlowProperties>)
449
+ )
450
+ )
451
+ );
442
452
 
443
- let messageToCreateObject = {
444
- Message: JSON.stringify(messageObject),
445
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
446
- };
447
- _izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
448
- await sns.publishAsync(_izContext, messageToCreateObject);
453
+ let messageToCreateObject = {
454
+ Message: JSON.stringify(messageObject),
455
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
456
+ };
457
+ _izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
458
+ await sns.publishAsync(_izContext, messageToCreateObject);
459
+ }
449
460
 
450
461
  //(<afterSendMessageToGraph>)
451
462
  //(</afterSendMessageToGraph>)
@@ -62,7 +62,9 @@ const { createObjType } = require("@izara_project/izara-core-library-service-sch
62
62
  module.exports.deleteMain = async (
63
63
  _izContext,
64
64
  requestParams,
65
- callingFlowConfig
65
+ //(<additionalParams>)
66
+ //(</additionalParams>)
67
+ callingFlowConfig = {}
66
68
  ) => {
67
69
  try {
68
70
  _izContext.logger.debug("function:DeleteMain::", {
@@ -72,9 +72,9 @@ const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
72
72
  module.exports.getMain = async (
73
73
  _izContext,
74
74
  requestParams,
75
- callingFlowConfig = {},
76
75
  //(<additionalParams>)
77
76
  //(</additionalParams>)
77
+ callingFlowConfig = {},
78
78
  ) => {
79
79
  try {
80
80
  _izContext.logger.debug('function GetMain: ', {
@@ -58,9 +58,9 @@ const { createObjType } = require("@izara_project/izara-core-library-service-sch
58
58
  module.exports.updateMain = async (
59
59
  _izContext,
60
60
  requestParams,
61
- callingFlowConfig = {},
62
61
  //(<additionalParams>)
63
62
  //(</additionalParams>)
63
+ callingFlowConfig = {},
64
64
  ) => {
65
65
 
66
66
  try {
@@ -183,10 +183,10 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
183
183
  }
184
184
 
185
185
  let resourceApis = [];
186
- if (action === "get", handler === HANDLER.hdrApi) {
186
+ if (handler === HANDLER.hdrApi) {
187
187
  for (const objectSchema of allObjSchemas.records) {
188
188
  resourceApis.push({
189
- event: objectSchema.objectType,
189
+ event: lowerCase(objectSchema.objectType),
190
190
  method: httpEvent(action)
191
191
  })
192
192
  }
@@ -9,22 +9,18 @@
9
9
  batchSize: 10
10
10
  <%_ } else if (handlerType === "hdrApi") { _%>
11
11
  <%_ resourceApis.forEach(resourceApi => { _%>
12
- - http:
13
- path: <%- firstLetterUpperCase(resourceApi.event) %>/<%- action %>
14
- method: <%- resourceApi.method %>
15
- authorizer:
16
- arn: arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:UserAccountTestAuthorizerServiceSchema
17
- resultTtlInSecond: 300
18
- #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
19
- #<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
20
- - http:
21
- path: <%- firstLetterUpperCase(resourceApi.event) %>/<%- action %>/{targetUserId}
22
- method: <%- resourceApi.method %>
23
- authorizer:
24
- arn: arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:UserAccountTestAuthorizerServiceSchema
25
- resultTtlInSecond: 300
26
- #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
27
- #<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
12
+ - httpApi:
13
+ path: /<%- resourceApi.event %>/<%- action %>
14
+ method: <%- resourceApi.method %>
15
+ authorizer: authorizerServiceSchema
16
+ #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
17
+ #<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
18
+ - httpApi:
19
+ path: /<%- resourceApi.event %>/<%- action %>/{targetUserId}
20
+ method: <%- resourceApi.method %>
21
+ authorizer: authorizerIdentifiers
22
+ #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
23
+ #<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
28
24
  <%_ }) _%>
29
25
  <%_ } _%>
30
26
  role: <%- firstLetterUpperCase(roleName) _%>Role
@@ -109,24 +109,40 @@ async function externalLambdaIamRoleDataPerAction(_izContext, allObjSchemas) {
109
109
  additionalResourcePermission.push(
110
110
  createIamRole(
111
111
  { [RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction] },
112
- storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServiceName =>
113
- externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", graphServiceName),
112
+ storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
113
+ externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", graphServerTag),
114
114
  )
115
115
  ),
116
116
  createIamRole(
117
117
  {
118
118
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
119
119
  },
120
- storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServiceName =>
121
- externalResourceName(RESOURCE_CLASSES.sns, "UpdateNode_In", graphServiceName)
120
+ storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
121
+ externalResourceName(RESOURCE_CLASSES.sns, "UpdateNode_In", graphServerTag)
122
122
  )
123
123
  ),
124
124
  createIamRole(
125
125
  {
126
126
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
127
127
  },
128
- storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServiceName =>
129
- externalResourceName(RESOURCE_CLASSES.sns, "CreateNode_In", graphServiceName)
128
+ storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
129
+ externalResourceName(RESOURCE_CLASSES.sns, "CreateNode_In", graphServerTag)
130
+ )
131
+ ),
132
+ createIamRole(
133
+ {
134
+ [RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
135
+ },
136
+ storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
137
+ externalResourceName(RESOURCE_CLASSES.lambda, "CreateNodeHdrInv", graphServerTag)
138
+ )
139
+ ),
140
+ createIamRole(
141
+ {
142
+ [RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
143
+ },
144
+ storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServerTag =>
145
+ externalResourceName(RESOURCE_CLASSES.lambda, "UpdateNodeHdrInv", graphServerTag)
130
146
  )
131
147
  )
132
148
  )
@@ -26,6 +26,6 @@ module.exports.generatedSnsTopicSubscription = [ <% datas.forEach(data => { -%>
26
26
  },
27
27
  <% }) _%>
28
28
  <% }) _%>
29
- //(<optionalSubscription>)
30
- //(</optionalSubscription>)
29
+ //(<additionalSubscription>)
30
+ //(</additionalSubscription>)
31
31
  ]
@@ -68,15 +68,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
68
68
  resourceNames(RESOURCE_CLASSES.sqs, queueName),
69
69
  resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
70
70
  ]
71
- ),
72
- createIamRole(
73
- {
74
- [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
75
- },
76
- [
77
- resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
78
- ]
79
- ),
71
+ )
80
72
  )
81
73
 
82
74
  if (Object.keys(flowSchema.flowSteps).includes("In")) {
@@ -117,12 +109,23 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
117
109
  tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
118
110
  )
119
111
  )
112
+ } else if (flowSchema.statusType === "statusField") {
113
+ additionalResourcePermission.push(
114
+ createIamRole(
115
+ {
116
+ [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
117
+ },
118
+ [
119
+ resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
120
+ ]
121
+ )
122
+ )
120
123
  }
121
124
 
122
125
  return {
123
126
  templatePath: templatePath,
124
127
  templateData: {
125
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
128
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
126
129
  functionName,
127
130
  handlerType,
128
131
  additionalResourcePermission,
@@ -55,52 +55,7 @@ async function data(_izContext, flowSchema, srcPath) {
55
55
  async function createSourceParams(_izContext, flowSchema, srcPath) {
56
56
  let functionName = "Process" + upperCase(flowSchema.flowTag)
57
57
  let handlerType = upperCase(HANDLER.hdrSqs)
58
- let additionalResourcePermission = defaultIamRolePerAction();
59
58
  let queueName = upperCase(flowSchema.flowTag) + handlerType;
60
- additionalResourcePermission.push(
61
- createIamRole(
62
- {
63
- [RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
64
- },
65
- [
66
- resourceNames(RESOURCE_CLASSES.sqs, queueName),
67
- resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
68
- ]
69
- ),
70
- createIamRole(
71
- {
72
- [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
73
- },
74
- [
75
- resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
76
- ]
77
- ),
78
- )
79
-
80
- if (flowSchema.statusType === "storedCache") {
81
- let tableStroedCaches = [];
82
- let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0])
83
- if (!objectSchema) {
84
- throw new NoRetryError('ObjectSchema not found')
85
- }
86
- for (const storageResource of Object.values(objectSchema.storageResources)) {
87
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
88
- if (!tableStroedCaches.includes(storageResource.tableName)) {
89
- tableStroedCaches.push(storageResource.tableName)
90
- }
91
- }
92
- }
93
-
94
- additionalResourcePermission.push(
95
- createIamRole(
96
- {
97
- [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
98
- },
99
- tableStroedCaches.map(
100
- tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
101
- )
102
- )
103
- }
104
59
 
105
60
  return {
106
61
  templatePath: templatePath,
@@ -110,7 +65,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
110
65
  queueName
111
66
  },
112
67
  setting: {
113
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
68
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
114
69
  saveFileName: `${functionName}_${handlerType}`,
115
70
  fileExtension: ".js",
116
71
  isAppend: false
@@ -28,7 +28,10 @@ const Logger = require('@izara_project/izara-core-library-logger');
28
28
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
30
  // validate event properties in body.Message of sqs event
31
- let perRecordsValidatorSchema = {}
31
+ let perRecordsValidatorSchema = {
32
+ //(<validatorSchema>)
33
+ //(</validatorSchema>)
34
+ }
32
35
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
33
36
 
34
37
  module.exports.main = middleware.wrap(async (event, context, callback) => {