@izara_project/izara-market-library-service-schemas 1.0.54 → 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 (25) hide show
  1. package/package.json +1 -1
  2. package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +15 -16
  3. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +29 -16
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +39 -21
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +43 -8
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +29 -9
  7. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +4 -1
  8. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +2 -2
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +2 -2
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +4 -0
  11. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +1 -1
  13. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +8 -8
  14. package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/data.js +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/template.ejs +5 -3
  16. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +1 -0
  17. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +12 -10
  18. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +10 -1
  19. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +2 -2
  20. package/src/reStructure/TemplateData/flowSchema/templateByStatusType/storedCacheTemplate.ejs +3 -0
  21. package/src/reStructure/TemplateData/flowSchema/templateByStatusType/triggerCacheTemplate.ejs +3 -0
  22. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/data.js +10 -2
  23. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/template.ejs +1 -1
  24. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +9 -1
  25. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,17 +1,16 @@
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
1
+ authorizerServiceSchema:
2
+ type: request
3
+ functionArn: ${self:custom.iz_authorizerServiceSchemaV2}
4
+ identitySource:
5
+ - $request.header.Authorization
6
+ - $context.routeKey
7
+ resultTtlInSeconds: 300
9
8
 
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
9
+ authorizerIdentifiers:
10
+ type: request
11
+ functionArn: ${self:custom.iz_authorizerServiceSchemaV2}
12
+ identitySource:
13
+ - $request.header.Authorization
14
+ - $context.routeKey
15
+ - $request.querystring.identifiers
16
+ resultTtlInSeconds: 300
@@ -16,31 +16,49 @@ 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
+ // ──────────────────────── Core Node Modules ────────────────────────
21
+ const lodash = require("lodash");
22
+
23
+ // ──────────────────────── Shared Core Libraries ────────────────────────
24
+ const hash = require('@izara_project/izara-shared-core').objectHash;
25
+
26
+ // ──────────────────────── Izara Core Libraries ────────────────────────
20
27
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
21
28
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
22
29
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
23
30
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
24
31
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
32
+ const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
33
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
25
34
 
35
+ // ──────────────────────── Middleware / External ────────────────────────
36
+ const middlewareConsts = require('@izara_project/izara-middleware').consts;
26
37
  const externalRequest = require('@izara_project/izara-core-library-external-request');
27
38
  const sns = externalRequest.sns;
28
39
 
29
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
40
+ // ──────────────────────── Service Schemas ────────────────────────
41
+ const { createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
42
+ const { createNodeLib, uploadUseCase, consts, getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
30
43
 
31
- const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
44
+ // ──────────────────────── Graph Service Libraries ────────────────────────
45
+ const graphSharedLibs = require('@izara_project/izara-core-library-graph-service');
32
46
 
33
- const hash = require('@izara_project/izara-shared-core').objectHash;
34
- const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
35
- const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
36
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
- const middlewareConsts = require('@izara_project/izara-middleware').consts
38
- const graphSharedLibs = require('@izara_project/izara-core-library-graph-service')
47
+ // ──────────────────────── Market Library Service Schemas ────────────────────────
39
48
  const {
40
49
  dynamoDbIdentifiersByStorageResource,
41
50
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
51
+ const {
52
+ TOPIC_NAME_GENERATE_CODE,
53
+ TOPIC_NAME_GRAPH_HANDLER,
54
+ GRAPH_HANDLER_SERVICE_NAME,
55
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
56
+ const {
57
+ createDataDetailsLib,
58
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
42
59
 
43
-
60
+ //(<optionalRequire>)
61
+ //(</optionalRequire>)
44
62
 
45
63
  //-----------------------------------------------------------------------------------------------------------
46
64
  const PREFIX = {
@@ -50,11 +68,6 @@ const PREFIX = {
50
68
  CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
51
69
  }
52
70
  //-----------------------------------------------------------------------------------------------------------
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')
54
- const { createDataDetailsLib } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
55
- const createNodeLib = require('@izara_project/izara-core-library-service-schemas').createNodeLib
56
- //(<optionalRequire>)
57
- //(</optionalRequire>)
58
71
 
59
72
  /**
60
73
  *
@@ -301,7 +314,7 @@ module.exports.createMain = async (
301
314
  ...objInstanceFullForDynamoDb.fields
302
315
  }
303
316
  );
304
- // (<afterCreateRecordDynamo>)
317
+ //(<afterCreateRecordDynamo>)
305
318
  //(</afterCreateRecordDynamo>)
306
319
  } else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
307
320
  //(<beforeCreateNode>)
@@ -16,42 +16,60 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
20
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
21
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
22
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
23
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
24
19
 
25
- const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
26
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
27
- const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
20
+ // ==================== Built-in Modules ====================
21
+ const path = require('path');
22
+ const schemasPath = path.join(__dirname, '../schemas');
28
23
 
29
- const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
30
24
 
25
+ // ==================== Shared Core Utilities ====================
31
26
  const hash = require('@izara_project/izara-shared-core').objectHash;
32
27
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
33
- const path = require('path')
34
- const schemasPath = path.join(__dirname, '../schemas');
28
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
29
+
30
+
31
+ // ==================== Core Service Schemas ====================
32
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
35
33
  const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
36
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
34
+ const { createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
35
+ const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
36
+ const {
37
+ getGraphServiceTagWithCache,
38
+ getServiceNameWithCache,
39
+ } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
40
+ const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase');
37
41
 
42
+
43
+ // ==================== Market Service Schemas ====================
38
44
  const {
39
45
  generateDynamoDbIdentifiers,
40
46
  dynamoDbIdentifiersByStorageResource,
41
- collectGetData
47
+ collectGetData,
48
+ createDeleteDataDetail,
42
49
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
43
50
 
44
51
  const {
45
- getGraphServiceTagWithCache,
46
- getServiceNameWithCache
47
- } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
52
+ TOPIC_NAME_GENERATE_CODE,
53
+ TOPIC_NAME_GRAPH_HANDLER,
54
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
+
56
+
57
+ // ==================== Shared Libraries ====================
58
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
59
+ const snsSharedLib = require('@izara_project/izara-core-library-sns');
60
+ const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
61
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
62
+ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
63
+
64
+
65
+ // ==================== External Resources ====================
66
+ const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
67
+
48
68
 
49
- const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
50
- const { createDeleteDataDetail } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
51
- const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils");
69
+ // ==================== Optional Requires ====================
70
+ // (<optionalRequire>)
71
+ // (</optionalRequire>)
52
72
 
53
- //(<optionalRequire>)
54
- //(</optionalRequire>)
55
73
  /**
56
74
  *
57
75
  * @param {*} _izContext
@@ -18,6 +18,7 @@ Copyright (C) 2020 Sven Mason <http: //izara.io>
18
18
 
19
19
  'use strict';
20
20
 
21
+ // ==================== Izara Core Service Schemas ====================
21
22
  const {
22
23
  getObjSchemaS3WithHierarchy,
23
24
  } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
@@ -29,17 +30,33 @@ const {
29
30
  const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
30
31
 
31
32
  const {
32
- objInstanceFromObjInstanceBase
33
+ objInstanceFromObjInstanceBase,
33
34
  } = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
34
35
 
36
+ const {
37
+ createObjTypeConcat,
38
+ createObjType,
39
+ } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
40
+
41
+
42
+ // ==================== Izara Market Service Schemas ====================
35
43
  const {
36
44
  dynamoDbIdentifiersByStorageResource,
37
45
  collectGetData,
38
46
  createGetDataDetails,
39
47
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
40
48
 
41
- const { createObjTypeConcat, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
49
+ const {
50
+ TOPIC_NAME_GENERATE_CODE,
51
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
52
+
42
53
 
54
+ // ==================== Shared Core Libraries ====================
55
+ const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
56
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
57
+
58
+
59
+ // ==================== Shared Utility Libraries ====================
43
60
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
44
61
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
45
62
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
@@ -47,14 +64,16 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
47
64
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
48
65
  const graphSharedLib = require('@izara_project/izara-core-library-graph-service');
49
66
 
67
+
68
+ // ==================== External Services ====================
50
69
  const externalRequest = require('@izara_project/izara-core-library-external-request');
51
- const sns = externalRequest.sns
70
+ const sns = externalRequest.sns;
71
+
72
+
73
+ // ==================== Optional Requires ====================
74
+ // (<optionalRequire>)
75
+ // (</optionalRequire>)
52
76
 
53
- const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
54
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
56
- //(<optionalRequire>)
57
- //(</optionalRequire>)
58
77
  /**
59
78
  *
60
79
  *
@@ -87,6 +106,7 @@ module.exports.getMain = async (
87
106
 
88
107
  //(<beforeQuery>)
89
108
  //(</beforeQuery>)
109
+
90
110
  const objType = createObjType(requestParams.objectType)
91
111
  let objectSchema = await getObjSchemaS3WithHierarchy(
92
112
  _izContext,
@@ -95,6 +115,21 @@ module.exports.getMain = async (
95
115
 
96
116
  _izContext.logger.debug("objectSchema: ", objectSchema);
97
117
 
118
+ let userId;
119
+ let targetId;
120
+ if (objectSchema.generatedBy === "userGenerated") {
121
+ userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
122
+ targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
123
+
124
+ if (!userId) {
125
+ errorsFound.push("Not have userId")
126
+ }
127
+
128
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
129
+ errorsFound.push('not have targetId')
130
+ }
131
+ }
132
+
98
133
  let getDataDetails = await createGetDataDetails(
99
134
  _izContext,
100
135
  objectSchema,
@@ -18,28 +18,48 @@ along with this program. If not, see
18
18
 
19
19
  'use strict';
20
20
 
21
+ // ==================== Shared Core Utilities ====================
21
22
  const hash = require('@izara_project/izara-shared-core').objectHash;
23
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
24
+
25
+
26
+ // ==================== Core Service Schemas ====================
22
27
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
28
  const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
29
+ const { createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
30
+
31
+
32
+ // ==================== Market Service Schemas ====================
24
33
  const {
25
34
  dynamoDbIdentifiersByStorageResource,
26
- createFieldForUpdateDynamoDb
35
+ createFieldForUpdateDynamoDb,
36
+ createUpdateDataDetail,
27
37
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
38
+
39
+ const {
40
+ PREFIX,
41
+ TOPIC_NAME_GENERATE_CODE,
42
+ TOPIC_NAME_GRAPH_HANDLER,
43
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
44
+
45
+
46
+ // ==================== Shared Libraries ====================
28
47
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
29
48
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
30
49
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
31
50
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
32
51
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
33
52
 
53
+
54
+ // ==================== External Services ====================
34
55
  const externalRequest = require('@izara_project/izara-core-library-external-request');
35
- const sns = externalRequest.sns
36
-
37
- const { createUpdateDataDetail } = require("@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs")
38
- const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
39
- const coreConsts = require('@izara_project/izara-core-library-core/src/Consts')
40
- const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils")
41
- //(<optionalRequire>)
42
- //(</optionalRequire>)
56
+ const sns = externalRequest.sns;
57
+
58
+
59
+ // ==================== Optional Requires ====================
60
+ // (<optionalRequire>)
61
+ // (</optionalRequire>)
62
+
43
63
  /**
44
64
  *
45
65
  *
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  const path = require('path');
21
21
  const fs = require('fs');
22
22
  const yaml = require('yaml');
23
+
23
24
  const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
24
25
  const {
25
26
  DEFAULT_HANDLER_PER_ACTION,
@@ -56,6 +57,7 @@ const templatePath = path.join(__dirname, "./template.ejs")
56
57
  */
57
58
  async function data(_izContext, allObjSchemas, srcPath) {
58
59
  let createSourceSet = new Set();
60
+ console.debug('templatePath:::', templatePath)
59
61
  for (const action of Object.values(ACTIONS)) {
60
62
  const defaultHandlers = DEFAULT_HANDLER_PER_ACTION[action]
61
63
  for (const defaultHandler of defaultHandlers) {
@@ -202,7 +204,8 @@ async function createParamForCreateSource(_izContext, allObjSchemas, action, han
202
204
  roleName: groupBy,
203
205
  action: action,
204
206
  functionNameConfig,
205
- resourceApis
207
+ resourceApis,
208
+ serviceTag: serviceTag
206
209
  },
207
210
  setting: {
208
211
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -10,13 +10,13 @@
10
10
  <%_ } else if (handlerType === "hdrApi") { _%>
11
11
  <%_ resourceApis.forEach(resourceApi => { _%>
12
12
  - httpApi:
13
- path: /<%- resourceApi.event %>/<%- action %>
13
+ path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>
14
14
  method: <%- resourceApi.method %>
15
15
  authorizer: authorizerServiceSchema
16
16
  #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
17
17
  #<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
18
18
  - httpApi:
19
- path: /<%- resourceApi.event %>/<%- action %>/{targetUserId}
19
+ path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>/{targetUserId}
20
20
  method: <%- resourceApi.method %>
21
21
  authorizer: authorizerIdentifiers
22
22
  #<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
@@ -25,7 +25,7 @@ const getObjectSchema = require('@izara_project/izara-core-library-service-schem
25
25
 
26
26
  /**
27
27
  * receive objectSchema
28
- * create data for WebScoket handler template
28
+ * create data for WebSocket handler template
29
29
  *
30
30
  * @param {Object} objectSchema
31
31
  * @return {{templatePath, templateData,setting}}
@@ -42,7 +42,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
42
42
  // let fieldNames = Object.keys(objectSchema.fieldNames)
43
43
  return {
44
44
  templatePath: templatePath,
45
- templateData: {},
45
+ templateData: { flowTag: flowSchema.flowTag },
46
46
  setting: {
47
47
  savePath: path.join(srcPath, SOURCE_PATH.webSocket, flowSchema.flowTag, "source/"),
48
48
  saveFileName: `${functionName}_Main`,
@@ -130,7 +130,9 @@ module.exports.reservedLimit = async (
130
130
  callingFlowSharedLib.addParentCallingFlowConfig(
131
131
  callingFlowConfig,
132
132
  callingFlowSharedLib.createCallingFlowConfig(
133
+ //(<callingFlowProperties>)
133
134
  await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
135
+ //(</callingFlowProperties>)
134
136
  callingFlowProperties
135
137
  )
136
138
  )
@@ -139,7 +141,9 @@ module.exports.reservedLimit = async (
139
141
  sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
140
142
  sendMsgReservedDynamic,
141
143
  callingFlowSharedLib.createCallingFlowConfig(
144
+ //(<callingFlowProperties>)
142
145
  await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
146
+ //(</callingFlowProperties>)
143
147
  callingFlowProperties
144
148
  )
145
149
  );
@@ -57,7 +57,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
57
57
  let handlerType = upperCase(HANDLER.hdrSqs)
58
58
  let additionalResourcePermission = defaultIamRolePerAction();
59
59
  let route = upperCase(flowSchema.flowTag);
60
- let queueName = upperCase(flowSchema.flowTag) + handlerType;
60
+ let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
61
61
  let topicIn = route + "_In";
62
62
  additionalResourcePermission.push(
63
63
  createIamRole(
@@ -55,7 +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 queueName = upperCase(flowSchema.flowTag) + handlerType;
58
+ let queueName = "Process" + upperCase(flowSchema.flowTag) + handlerType;
59
59
 
60
60
  return {
61
61
  templatePath: templatePath,
@@ -62,18 +62,18 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
62
62
  if (flowSteps.includes("In")) {
63
63
  generatedSnsTopicInForFlowSchema.push(
64
64
  {
65
- queueName: upperCase(flowSchema.flowTag),
65
+ queueName: "Process" + upperCase(flowSchema.flowTag) + upperCase(HANDLER.hdrSqs)
66
66
  }
67
67
  )
68
68
  }
69
69
 
70
- if (flowSteps.includes("Out") && flowSchema.outputTopic === true) {
71
- generatedSnsTopicInForFlowSchema.push(
72
- {
73
- queueName: upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
74
- }
75
- )
76
- }
70
+ // if (flowSteps.includes("Out") && flowSchema.outputTopic === true) {
71
+ // generatedSnsTopicInForFlowSchema.push(
72
+ // {
73
+ // queueName: upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
74
+ // }
75
+ // )
76
+ // }
77
77
 
78
78
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
79
79
  resultsForCreateDefaultSnsInSqs.push({
@@ -70,7 +70,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
70
70
  functionName,
71
71
  tableName,
72
72
  flowSchemaComplete,
73
- triggerType
73
+ triggerType,
74
74
  },
75
75
  setting: {
76
76
  savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
@@ -36,7 +36,8 @@ const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigg
36
36
  const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
37
37
  <% } else if (statusType === "storedCache") { -%>
38
38
  const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
39
- <% } %>
39
+ <% } -%>
40
+ const { createFlowTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
40
41
  //(<optionalRequire>)
41
42
  //(</optionalRequire>)
42
43
  /**
@@ -73,13 +74,14 @@ module.exports.<%- functionName %> = async (
73
74
  <% if (statusType === "statusField") { %>
74
75
  <%- include(statusFieldTemplate) %>
75
76
  <% } else if (statusType === "storedCache") { %>
76
- <%- include(storedCacheTemplate, {tableName:tableName,flowSchemaComplete:flowSchemaComplete}) %>
77
+ <%- include(storedCacheTemplate, {tableName:tableName, flowSchemaComplete:flowSchemaComplete,flowTag}) %>
77
78
 
78
79
  <% } else if (statusType === "triggerCache") { %>
79
80
  <%- include(triggerCacheTemplate, {
80
81
  tableName: tableName,
81
82
  flowSchemaComplete: flowSchemaComplete,
82
- triggerType: triggerType
83
+ triggerType: triggerType,
84
+ flowTag
83
85
  }) %>
84
86
  <% } %>
85
87
 
@@ -24,6 +24,7 @@ const izara = require("@izara_project/izara-middleware");
24
24
  const middleware = izara.middlewareHandler;
25
25
  const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
26
26
  const Logger = require('@izara_project/izara-core-library-logger');
27
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
27
28
 
28
29
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
30
 
@@ -178,8 +178,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
178
178
  for (const flowSchema of allLocalFlowSchemas.records) {
179
179
  // console.log("flowSchema in Generate TemplateData", flowSchema);
180
180
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
181
- const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
182
- createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
181
+ if (!flowSchema.event.includes("s3")) {
182
+ const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
183
+ createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
184
+ }
183
185
 
184
186
  // event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
185
187
  for (const event of flowSchema.event) {
@@ -190,10 +192,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
190
192
  const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
191
193
  const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
192
194
  const mainFunctionCreateObjectWebSocket = await createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
193
- const webSocketCreateObjectCompleteFunctionYaml = createWebSocketCreateObjectCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
194
- const webSocketCreateObjectCompleteQueue = createWebSocketCreateObjectCompleteQueue(_izContext, saveFilePath);
195
- const webSocketCreateObjectCompleteMainFunction = createWebSocketCreateObjectCompleteMainFunction(_izContext, flowSchema, saveFilePath)
196
- 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);
197
199
 
198
200
  // const webSocketCreateObjectStordCache = createWebSocketCreateObjectStoredCache(_izContext, saveFilePath);
199
201
 
@@ -223,10 +225,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
223
225
  ...functionYamlCreateObjectWebSocket,
224
226
  ...handlerCreateObjectWebSocket,
225
227
  ...mainFunctionCreateObjectWebSocket,
226
- ...webSocketCreateObjectCompleteFunctionYaml,
227
- ...webSocketCreateObjectCompleteQueue,
228
- ...webSocketCreateObjectCompleteMainFunction,
229
- ...webSocketCreateObjectCompleteHandler
228
+ // ...webSocketCreateObjectCompleteFunctionYaml,
229
+ // ...webSocketCreateObjectCompleteQueue,
230
+ // ...webSocketCreateObjectCompleteMainFunction,
231
+ // ...webSocketCreateObjectCompleteHandler
230
232
  ];
231
233
 
232
234
  const getPreSignUrlResources = [
@@ -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')
@@ -56,6 +59,11 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
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),
@@ -4,13 +4,13 @@
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
6
  - httpApi:
7
- path: /<%- firstLetterLowerCase(functionName) %>/
7
+ path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>
8
8
  method: <%- event %>
9
9
  authorizer: authorizerServiceSchema
10
10
  #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
11
11
  #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
12
12
  - httpApi:
13
- path: /<%- firstLetterLowerCase(functionName) %>/{targetUserId}
13
+ path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>/{targetUserId}
14
14
  method: <%- event %>
15
15
  authorizer: authorizerServiceSchema
16
16
  #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
@@ -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
  )
@@ -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#>
@@ -348,7 +348,15 @@ module.exports.createRelationship = async (
348
348
  _izContext,
349
349
  awaitingStepIds, // awaitingStepIds
350
350
  asyncFlowSharedLib.createPendingStepId( // pendingStepId
351
- 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
352
360
  PREFIX.createRel // prefix, use constant further
353
361
  )
354
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);