@izara_project/izara-market-library-service-schemas 1.0.52 → 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 (58) hide show
  1. package/package.json +5 -5
  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 +4 -4
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +4 -1
  15. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +2 -2
  16. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +12 -14
  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/data.js +1 -1
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +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 +7 -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 +37 -24
  37. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +79 -0
  38. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{functionYaml/templateApi.ejs → Api/functionYaml/template.ejs} +11 -5
  39. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{handler → Api/handler}/data.js +7 -33
  40. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{handler/templateApi.ejs → Api/handler/template.ejs} +28 -24
  41. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +78 -0
  42. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +58 -0
  43. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{handler/templateInv.ejs → Inv/handler/template.ejs} +11 -5
  44. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +15 -7
  45. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +1 -1
  46. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +9 -1
  47. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -1
  48. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +9 -10
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +0 -75
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +0 -98
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +0 -52
  52. package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/data.js +0 -128
  53. package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/data.js +0 -74
  54. package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/template.ejs +0 -96
  55. /package/src/reStructure/TemplateData/flowSchema/lambdaSync/{functionYaml/templateInv.ejs → Inv/functionYaml/template.ejs} +0 -0
  56. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/statusFieldTemplate.ejs +0 -0
  57. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/storedCacheTemplate.ejs +0 -0
  58. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/triggerCacheTemplate.ejs +0 -0
@@ -19,11 +19,10 @@ 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, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
23
- const { SOURCE_PATH } = require('../../../../../MainLibs/src/Consts');
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
+ const { SOURCE_PATH } = require('../../../../../../MainLibs/src/Consts');
24
24
 
25
- const templatePathInvoke = path.join(__dirname, "./templateInv.ejs");
26
- const templatePathApi = path.join(__dirname, "./templateApi.ejs");
25
+ const templatePath = path.join(__dirname, "./template.ejs");
27
26
  /**
28
27
  * receive objectSchema
29
28
  * create data for WebScoket handler template
@@ -33,40 +32,15 @@ const templatePathApi = path.join(__dirname, "./templateApi.ejs");
33
32
  */
34
33
 
35
34
  function data(_izContext, flowSchema, srcPath) {
36
- let returnCreateSource = [];
37
- returnCreateSource.push(createSourceParamsInvoke(_izContext, flowSchema, srcPath))
38
- if (flowSchema.externalEndpoint) {
39
- returnCreateSource.push(createSourceParamsApi(_izContext, flowSchema, srcPath))
40
- }
41
- return returnCreateSource
42
- }
43
-
44
- function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
45
- let functionName = upperCase(flowSchema.flowTag)
46
- let handlerType = upperCase(HANDLER.hdrInv)
47
-
48
- return {
49
- templatePath: templatePathInvoke,
50
- templateData: {
51
- functionName,
52
- handlerType,
53
- },
54
- setting: {
55
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
56
- saveFileName: `${functionName}_${handlerType}`,
57
- fileExtension: ".js",
58
- isAppend: false
59
- }
60
- }
35
+ return createSourceParamsApi(_izContext, flowSchema, srcPath)
61
36
  }
62
37
 
63
-
64
38
  function createSourceParamsApi(_izContext, flowSchema, srcPath) {
65
- let functionName = upperCase(flowSchema.flowTag)
39
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
66
40
  let handlerType = upperCase(HANDLER.hdrApi)
67
41
 
68
42
  return {
69
- templatePath: templatePathApi,
43
+ templatePath: templatePath,
70
44
  templateData: {
71
45
  functionName,
72
46
  handlerType,
@@ -74,7 +48,7 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
74
48
  // properties
75
49
  },
76
50
  setting: {
77
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
51
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
78
52
  saveFileName: `${functionName}_${handlerType}`,
79
53
  fileExtension: ".js",
80
54
  isAppend: false
@@ -21,26 +21,29 @@ const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser |
21
21
 
22
22
  const izara = require("@izara_project/izara-middleware");
23
23
  const middleware = izara.middlewareHandler;
24
- const lambdaFunction = require('./LambdaFunction_Main')
25
-
26
- // validate event params in middlewware before into function.
27
- let validatorSchema = {};
24
+ const <%- functionName %> = require('./<%- functionName %>_Main')
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 lambdaFunction.lambdaFunction(
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
@@ -0,0 +1,78 @@
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 { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
23
+ const {
24
+ SOURCE_PATH,
25
+ defaultIamRolePerAction,
26
+ createIamRole,
27
+ RESOURCE_CLASSES,
28
+ SNS_RESOURCE,
29
+ resourceNames,
30
+ DYNAMO_RESOURCE,
31
+ SAVE_FILE_NAME,
32
+ FUNCTION_NAME,
33
+ shortNameHandler,
34
+ externalResourceYaml,
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE,
37
+ LAMBDA_RESOURCE
38
+ } = require('../../../../../../MainLibs/src/Consts');
39
+ const { NoRetryError } = require('@izara_project/izara-core-library-core');
40
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
41
+
42
+ const templatePath = path.join(__dirname, "./template.ejs");
43
+ /**
44
+ * receive objectSchema
45
+ * create data for WebScoket handler template
46
+ *
47
+ * @param {Object} objectSchema
48
+ * @return {{templatePath, templateData,setting}}
49
+ */
50
+
51
+ function data(_izContext, flowSchema, srcPath) {
52
+ return createSourceParamsInvoke(_izContext, flowSchema, srcPath)
53
+ }
54
+
55
+ function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
56
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
57
+ let handlerType = upperCase(HANDLER.hdrInv)
58
+ let additionalResourcePermission = defaultIamRolePerAction();
59
+
60
+ return {
61
+ templatePath: templatePath,
62
+ templateData: {
63
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
64
+ functionName,
65
+ handlerType,
66
+ additionalResourcePermission,
67
+ functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
68
+ roleName: upperCase(flowSchema.flowTag)
69
+ },
70
+ setting: {
71
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
72
+ saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
73
+ fileExtension: ".yml",
74
+ isAppend: true
75
+ }
76
+ }
77
+ }
78
+ module.exports = data;
@@ -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
+ const path = require('path');
20
+
21
+ const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
23
+ const { SOURCE_PATH } = require('../../../../../../MainLibs/src/Consts');
24
+
25
+ const templatePath = path.join(__dirname, "./template.ejs");
26
+ /**
27
+ * receive objectSchema
28
+ * create data for WebScoket handler template
29
+ *
30
+ * @param {Object} objectSchema
31
+ * @return {{templatePath, templateData,setting}}
32
+ */
33
+
34
+ function data(_izContext, flowSchema, srcPath) {
35
+ return createSourceParamsInvoke(_izContext, flowSchema, srcPath)
36
+ }
37
+
38
+ function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
39
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
40
+ let handlerType = upperCase(HANDLER.hdrInv)
41
+
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {
45
+ functionName,
46
+ handlerType,
47
+ },
48
+ setting: {
49
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
50
+ saveFileName: `${functionName}_${handlerType}`,
51
+ fileExtension: ".js",
52
+ isAppend: false
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ module.exports = data;
@@ -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
- // validate event params in middlewware before into function.
28
- const validatorSchema = {};
27
+ // validate event params in middleware before into function.
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 lambdaFunction.lambdaFunction(
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) {
@@ -90,16 +90,24 @@ function createSourceParams(_izContext, allLocalFlowSchemas, 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 + "_Out"))
99
93
  )
100
94
  )
101
95
 
102
-
96
+ for (const flowSchema of allLocalFlowSchemas.records) {
97
+ console.log("flowSchema", flowSchema)
98
+ if (flowSchema.event.includes("ownTopic") || flowSchema.event.includes("extTopic")) {
99
+ additionalResourcePermission.push(
100
+ createIamRole(
101
+ {
102
+ [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.subscribe]
103
+ },
104
+ [
105
+ resourceNames(RESOURCE_CLASSES.sns, upperCase(flowSchema.flowTag) + "_Out")
106
+ ]
107
+ )
108
+ )
109
+ }
110
+ }
103
111
  return {
104
112
  templatePath: templatePath,
105
113
  templateData: {
@@ -24,7 +24,7 @@ const {
24
24
  PREFIX_RELATIONSHIP,
25
25
  PROPERTY_VALUE_TAG,
26
26
  SAVE_FILE_NAME
27
- } = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
27
+ } = require('../../../../MainLibs/src/Consts');
28
28
 
29
29
  const templatePath = path.join(__dirname, "./tempRelationship.ejs");
30
30
 
@@ -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
  );
@@ -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
  )
@@ -52,6 +52,7 @@ const {
52
52
  TOPIC_NAME_GENERATE_CODE,
53
53
  TOPIC_NAME_GRAPH_HANDLER
54
54
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
+ const graphSharedLib = require('@izara_project/izara-core-library-graph-service')
55
56
  //(<optionalRequire>)
56
57
  //(</optionalRequire>)
57
58
  /**
@@ -246,17 +247,15 @@ module.exports.getRelationship = async (
246
247
  await Promise.all(
247
248
  targetGraphStorageResources.map(async (storageResource) => {
248
249
  if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
249
- let getResultFromGraph = await lambda.invokeSync(_izContext,
250
- await lambdaSharedLib.lambdaFunctionName(_izContext, "GetRelationshipV2", storageResource.graphServiceTag),
251
- {
252
- firstObject: firstObject,
253
- secondObject: secondObject,
254
- relType: relType,
255
- relId: relId,
256
- relationshipDirection,
257
- }
250
+ result = await graphSharedLib.getRelationshipV2(
251
+ _izContext,
252
+ storageResource.graphServiceTag,
253
+ firstObject,
254
+ secondObject,
255
+ relType,
256
+ relId,
257
+ relationshipDirection
258
258
  )
259
- result = getResultFromGraph;
260
259
  } else if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
261
260
 
262
261
  // if have storageResource.storageType === "dynamoDB" will create relationship here
@@ -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
@@ -1,98 +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
16
- <http: //www.gnu.org/licenses />.
17
- */
18
-
19
- 'use strict';
20
-
21
- const hash = require('@izara_project/izara-shared-core').objectHash;
22
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
-
24
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
- const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
27
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
28
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
29
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
30
- const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
31
-
32
- const externalRequest = require('@izara_project/izara-core-library-external-request');
33
- const sns = externalRequest.sns
34
- const sqs = externalRequest.sqs
35
- const lambda = externalRequest.lambda
36
- const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
37
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
38
- const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
39
- const { v4: uuidv4 } = require('uuid')
40
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
41
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
42
- const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
43
- const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
44
- //(<optionalRequire>)
45
- //(</optionalRequire>)
46
- /**
47
- *
48
- *
49
- * description of function.
50
- * @param {Object} _izContext
51
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
52
- * @param {Logger} _izContext.logger - property of _izContext
53
- * @param {Object} requestParams - request params
54
- * @param {Object} requestParams.identifiers - identifiers for get data
55
- * @param {Object} requestParams.additionalRequest - additionalRequest
56
- *
57
- *
58
- * @returns {object} description of return value
59
- */
60
-
61
- module.exports.<%- functionName %> = async (
62
- _izContext,
63
- requestParams,
64
- //(<additionalParams>)
65
- //(</additionalParams>)
66
- callingFlowConfig = {},
67
- ) => {
68
-
69
- try {
70
- _izContext.logger.debug("<%- functionName %> _izContext", _izContext)
71
- _izContext.logger.debug("<%- functionName %> requestParams", requestParams)
72
- _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
73
-
74
- let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID)
75
- let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
76
-
77
- <% if (statusType === "statusField") { %>
78
- <%- include(statusFieldTemplate) %>
79
- <% } else if (statusType === "storedCache") { %>
80
- <%- include(storedCacheTemplate, {tableName:tableName,flowSchemaComplete:flowSchemaComplete}) %>
81
-
82
- <% } else if (statusType === "triggerCache") { %>
83
- <%- include(triggerCacheTemplate, {
84
- tableName: tableName,
85
- flowSchemaComplete: flowSchemaComplete,
86
- triggerType: triggerType
87
- }) %>
88
- <% } %>
89
-
90
-
91
- //(<endpointHook>)
92
- //(</endpointHook>)
93
-
94
- } catch (err) {
95
- _izContext.logger.error('error WebSocketInvoke: ', err)
96
- throw (err)
97
- }
98
- }
@@ -1,52 +0,0 @@
1
- ##===== [subsription to topic In]
2
- Subscription<%- queueName-%>:
3
- Type: AWS::SNS::Subscription
4
- Properties:
5
- TopicArn: !Ref <%- subScription %>
6
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
7
- Protocol: "sqs"
8
- ##===== [Queue]
9
- <%- queueName %>:
10
- Type: "AWS::SQS::Queue"
11
- Properties:
12
- QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
13
- RedrivePolicy:
14
- deadLetterTargetArn:
15
- # !GetAtt
16
- Fn::GetAtt:
17
- - <%- queueName %>DLQ
18
- - Arn
19
- maxReceiveCount: 3
20
- VisibilityTimeout: 120
21
- ##==== [QueueDLQ]
22
- <%- queueName %>DLQ:
23
- Type: AWS::SQS::Queue
24
- Properties:
25
- QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
26
- ##==== [QueuePolicy]
27
- <%- queueName %>Policy:
28
- Type: AWS::SQS::QueuePolicy
29
- Properties:
30
- PolicyDocument:
31
- Version: "2012-10-17"
32
- Statement:
33
- - Sid: "allow-sns-messages"
34
- Effect: Allow
35
- Principal: "*"
36
- Resource:
37
- # !GetAtt
38
- Fn::GetAtt:
39
- - <%- queueName %>
40
- - Arn
41
- Action: "SQS:SendMessage"
42
- Queues:
43
- - Ref: <%- queueName %>
44
- #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
45
- #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
46
-
47
- <%_ function firstLetterUpperCase(text){
48
- return text.charAt(0).toUpperCase() + text.slice(1)
49
- } _%>
50
- <%_ function firstLetterLowerCase(str) {
51
- return str.charAt(0).toLowerCase() + str.slice(1)
52
- } _%>