@izara_project/izara-market-library-service-schemas 1.0.15 → 1.0.17

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 (63) hide show
  1. package/package.json +2 -2
  2. package/src/GenerateCodeLibs/src/Consts.js +3 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +94 -73
  4. package/src/MainLibs/src/Utils.js +10 -9
  5. package/src/TemplateManager/src/GenerateCode.js +53 -12
  6. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/data.js +86 -0
  7. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/functionYaml/template.ejs +33 -0
  8. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/data.js +59 -0
  9. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/handler/template.ejs +129 -0
  10. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/data.js +53 -0
  11. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/mainFunction/template.ejs +130 -0
  12. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sns-out/data.js +62 -0
  13. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/data.js +58 -0
  14. package/src/TemplateManager/src/OutPerActionComplete/OutGetComplete/sqs-in-sns/template.ejs +47 -0
  15. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +15 -7
  16. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrDsq/data.js +14 -6
  17. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +14 -4
  18. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/data.js +14 -4
  19. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/data.js +171 -0
  20. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/request.json +19 -0
  21. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrWbs/template.ejs +29 -0
  22. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/data.js +60 -0
  23. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/webSocketConnect/template.ejs +10 -0
  24. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/data.js +76 -0
  25. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocket/template.ejs +141 -0
  26. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/data.js +56 -0
  27. package/src/TemplateManager/src/PerActionEndpoint/Handler/WebSocketConnect/template.ejs +55 -0
  28. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +40 -36
  29. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +54 -22
  30. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +59 -25
  31. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/functionYaml/HdrSqs/template.ejs +4 -0
  32. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +2 -1
  33. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +1 -5
  34. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +1 -5
  35. package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +11 -7
  36. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/functionYaml/HdrSqs/template.ejs +4 -0
  37. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/mainFunction/template.ejs +1 -1
  38. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrApi/template.ejs +5 -4
  39. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationship/perAction/HdrInv/template.ejs +3 -2
  40. package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +16 -13
  41. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +9 -6
  42. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/template.ejs +4 -0
  43. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +8 -5
  44. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +1 -1
  45. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +10 -8
  46. package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +1 -1
  47. package/src/TemplateManager/src/ResourceYaml/dynamodb/{awaitingMultipleStepData.js → defaultDynamoDbTable.js} +39 -3
  48. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +6 -3
  49. package/src/TemplateManager/src/externalService/FunctionNameConfig/data.js +1 -1
  50. package/src/TemplateManager/src/externalService/LambdaRole/data.js +5 -10
  51. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +14 -0
  52. package/src/TemplateManager/src/flowTag/resources/dynamoDb/data.js +65 -0
  53. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/data.js +56 -0
  54. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +10 -0
  55. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/data.js +55 -0
  56. package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/template.ejs +63 -0
  57. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/data.js +75 -0
  58. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/template.ejs +33 -0
  59. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/data.js +57 -0
  60. package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +131 -0
  61. package/src/TemplateManager/src/libs/Consts.js +7 -2
  62. package/src/TemplateManager/src/libs/GenerateCodeUtils.js +3 -1
  63. package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +0 -99
@@ -0,0 +1,75 @@
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
+ const fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, SNS_RESOURCE, resourceNames } = require("../../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, "template.ejs")
28
+
29
+ /**
30
+ * receive objectSchema
31
+ * create data for WebScoket handler template
32
+ *
33
+ * @param {Object} objectSchema
34
+ * @return {{templatePath, templateData,setting}}
35
+ */
36
+
37
+ function data(_izContext, srcPath) {
38
+ return [createSourceParams(_izContext, srcPath)]
39
+ }
40
+
41
+ function createSourceParams(_izContext, srcPath) {
42
+ let functionName = "FlowSchemaInvoke"
43
+ let additionalResourcePermission = defaultIamRolePerAction();
44
+ let handlerType = upperCase("hdrWbs")
45
+ let functionNameConfig = functionName + handlerType
46
+ additionalResourcePermission.push(
47
+ createIamRole(
48
+ {
49
+ [RESOURCE_CLASSES.sns]: [
50
+ SNS_RESOURCE.publish
51
+ ]
52
+ },
53
+ [
54
+ resourceNames(RESOURCE_CLASSES.sns, "*")
55
+ ]
56
+ )
57
+ )
58
+ return {
59
+ templatePath: templatePath,
60
+ templateData: {
61
+ resourceLocation: SOURCE_PATH.resourceLocationPerAction,
62
+ functionName,
63
+ handlerType,
64
+ functionNameConfig,
65
+ additionalResourcePermission
66
+ },
67
+ setting: {
68
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
69
+ saveFileName: "FlowSchemaInvoke",
70
+ fileExtension: ".yml",
71
+ isAppend: true
72
+ }
73
+ }
74
+ }
75
+ module.exports = data;
@@ -0,0 +1,33 @@
1
+ <%_ const join = require('path').join; _%>
2
+ <%- firstLetterUpperCase(functionNameConfig) %>:
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
+ name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
5
+ events:
6
+ - sqs:
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
8
+ batchSize: 10
9
+ filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
+ - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
12
+ iamRoleStatements:
13
+ <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
+ - Effect: <%- resourcePermission.effect %>
15
+ Action:
16
+ <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
+ <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
+ - <%- resourcePerAction %>:<%- permission %>
19
+ <%_}) _%>
20
+ <%_ }) _%>
21
+ Resource:
22
+ <%_ resourcePermission.resource.forEach(resource => { _%>
23
+ - <%- resource %>
24
+ <%_ }) _%>
25
+ <%_}) _%>
26
+ #<#<%- functionName %><%- handlerType %>IamRole#>
27
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
28
+ <%_ function firstLetterUpperCase(text){
29
+ return text.charAt(0).toUpperCase() + text.slice(1)
30
+ } _%>
31
+ <%_ function firstLetterLowerCase(str) {
32
+ return str.charAt(0).toLowerCase() + str.slice(1)
33
+ } _%>
@@ -0,0 +1,57 @@
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
+ const fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase, checkOverWriteGenerateMainFunction } = require("../../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, "template.ejs")
28
+
29
+ /**
30
+ * receive objectSchema
31
+ * create data for WebScoket handler template
32
+ *
33
+ * @param {Object} objectSchema
34
+ * @return {{templatePath, templateData,setting}}
35
+ */
36
+
37
+
38
+ function data(_izContext, srcPath) {
39
+
40
+ return [createParamsForCreateSource(_izContext, srcPath)]
41
+
42
+
43
+ }
44
+
45
+ function createParamsForCreateSource(_izContext, srcPath) {
46
+ return {
47
+ templatePath: templatePath,
48
+ templateData: {},
49
+ setting: {
50
+ savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
51
+ saveFileName: "FlowSchemaInvoke",
52
+ fileExtension: ".js",
53
+ isAppend: false
54
+ }
55
+ }
56
+ }
57
+ module.exports = data
@@ -0,0 +1,131 @@
1
+ /*
2
+ Copyright (C) 2021 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 izara = require("@izara_project/izara-middleware");
21
+ const middleware = izara.middlewareHandler;
22
+ const AWS = require('aws-sdk');
23
+ const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
24
+ const izaraShared = require('@izara_project/izara-shared')
25
+ const dynamodbSharedLib = izaraShared.dynamodbSharedLib
26
+ const sqsSharedLib = izaraShared.sqsSharedLib;
27
+ const snsSharedLib = izaraShared.snsSharedLib;
28
+ const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
29
+
30
+ const externalRequest = require('@izara_project/izara-core-library-external-request');
31
+ const sns = externalRequest.sns;
32
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
33
+
34
+ const utils = require("@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils");
35
+ const NoRetryError = require("@izara_project/izara-core-library-core/src/NoRetryError");
36
+
37
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
38
+
39
+ event._izContext.logger.debug('Event:', event);
40
+
41
+ try {
42
+
43
+ let eventParams = JSON.parse(event.body)
44
+
45
+ if (event.requestContext) {
46
+ const route = event.requestContext.routeKey;
47
+ const connectionId = event.requestContext.connectionId;
48
+
49
+ // const time = Date.now();
50
+ // console.log(`socketxx: ${time}`);
51
+
52
+ switch (route) {
53
+ case null:
54
+ console.log('Received unknown route:', route)
55
+ break
56
+ case 'webScoket':
57
+ console.log("event in route", event)
58
+ let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {}
59
+
60
+ let getFlowSchema = await getObjectSchema.getLocalFlowSchemas(event._izContext, eventParams.flowTag).then(res => res.records)
61
+ event._izContext.logger.debug("getFlowSchema", getFlowSchema)
62
+ let flowSchema = getFlowSchema[0]
63
+ event._izContext.logger.debug("flowSchema", flowSchema);
64
+
65
+ if (!flowSchema) {
66
+ throw new NoRetryError(`flowTag not found ${flowSchema.flowTag}`)
67
+ }
68
+
69
+ // create messageObject send to topic
70
+ let messageObject = {
71
+ propertiesA: eventParams.propertiesA,
72
+ }
73
+
74
+ messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlow, messageObject);
75
+
76
+ let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlow, {});
77
+
78
+ let sendMessageToTopic = {
79
+ Message: JSON.stringify(messageObject),
80
+ MessageAttributes: messageAttributes,
81
+ TopicArn: await snsSharedLib.snsTopicArn(event._izContext, `InProcess${utils.firstLetterLowerCase(flowSchema.flowTag)}`)
82
+ }
83
+
84
+ event._izContext.logger.debug(`message Params before send toInProcess${utils.firstLetterUpperCase(flowSchema.flowTag)}`, sendMessageToTopic);
85
+ await sns.publishAsync(event._izContext, sendMessageToTopic)
86
+
87
+
88
+ await dynamodbSharedLib.putItem(
89
+ event._izContext,
90
+ await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
91
+ {
92
+ taskKey: flowSchema.flowTag + connectionId,
93
+ connectionid: connectionId
94
+ }
95
+ )
96
+
97
+ postMessage(sendMessageToTopic, connectionId)
98
+ break
99
+ }
100
+ } else {
101
+ const connId = event.connId;
102
+ await postMessage({ message: event.message }, connId);
103
+ }
104
+
105
+ return (izara.response.webSocketSuccess());
106
+
107
+ } catch (err) {
108
+ console.log("event", event)
109
+ const connId = event.requestContext.connectionId
110
+ event._izContext.logger.error('Error, WebSocket: ', err);
111
+ await sendErrorMessage({ message: err.message }, connId);
112
+ return (izara.response.failure(err));
113
+ }
114
+ });
115
+
116
+ async function postMessage(data, connectionId) {
117
+ const params = {
118
+ ConnectionId: connectionId,
119
+ Data: JSON.stringify(data),
120
+ // Data: Buffer.from(JSON.stringify(data)),
121
+ }
122
+ return api.postToConnection(params).promise();
123
+ };
124
+
125
+ async function sendErrorMessage(errorMessage, connectionId) {
126
+ const params = {
127
+ ConnectionId: connectionId,
128
+ Data: JSON.stringify(errorMessage)
129
+ }
130
+ return api.postToConnection(params).promise();
131
+ }
@@ -38,7 +38,8 @@ const RESOURCE_CLASSES = {
38
38
  dynamoDbTable: 'dynamodb',
39
39
  dynamoDbAcrossService: 'dynamodb',
40
40
  sns: "SNS",
41
- lambda: "lambda"
41
+ lambda: "lambda",
42
+ webSocket: "webSocket"
42
43
  };
43
44
 
44
45
  /**
@@ -53,7 +54,8 @@ function resourceNames(resourceClass, resourceName) {
53
54
  [RESOURCE_CLASSES.s3]: "arn:aws:s3:::" + resourceName,
54
55
  [RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}" + resourceName,
55
56
  [RESOURCE_CLASSES.sns]: "arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}" + resourceName,
56
- [RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:" + resourceName
57
+ [RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:" + resourceName,
58
+ [RESOURCE_CLASSES.webSocket]: "arn:aws:execute-api:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_webSocketHostId}/Test/POST/@connections/{connectionId}"
57
59
  }[resourceClass];
58
60
  }
59
61
 
@@ -187,6 +189,7 @@ const FUNCTION_NAME = {
187
189
  processLogical: "processLogical",
188
190
  updateNodeComplete: "updateNodeComplete",
189
191
  createObjectComplete: "createObjectComplete",
192
+ getNodeComplete: "getNodeComplete",
190
193
  paginateProcessLogical: "paginateProcessLogical",
191
194
  deleteNode: "deleteNode",
192
195
  deleteNodeComplete: "deleteNodeComplete"
@@ -206,6 +209,7 @@ const SHORT_FUNCTION_NAME = {
206
209
  processLogical: "processLogical",
207
210
  updateNodeComplete: "updateNodeComp",
208
211
  createObjectComplete: "createObjectComp",
212
+ getNodeComplete: "getNodeComp",
209
213
  paginateProcessLogical: "paginateProLogical",
210
214
  deleteNode: "deleteNode",
211
215
  deleteNodeComplete: "deleteNodeComp"
@@ -305,6 +309,7 @@ function shortNameHandler(fullNameHandler) {
305
309
  return fullNameHandler.slice(3)
306
310
  }
307
311
 
312
+
308
313
  module.exports = {
309
314
  ACTIONS,
310
315
  DEFAULT_HANDLER_PER_ACTION,
@@ -54,4 +54,6 @@ function checkValidTableYaml(_izContext, currentTableSetting, existsTableSetting
54
54
  return [filteredDynamoDbYamlSetting, existsTableSetting];
55
55
  }
56
56
 
57
- module.exports = { checkValidTableYaml };
57
+ module.exports = {
58
+ checkValidTableYaml,
59
+ };
@@ -1,99 +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
-
20
- const path = require("path")
21
-
22
-
23
- // const {
24
- // HANDLER,
25
- // STORAGE_TYPES
26
- // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
-
28
- const STORAGE_TYPES = {
29
- dynamoDB: "dynamoDB",
30
- graph: "graph"
31
- }
32
- const templatePath = path.join(__dirname, './template.ejs')
33
- const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../libs/Consts');
34
-
35
- /**
36
- * create param of crateSouce for FindData And processLogical
37
- *
38
- * @param {Object} _izContext
39
- * @param {String} srcPath
40
- * @returns {Object[]}
41
- */
42
- const createDefaultSourceDataDynamoDB = (_izContext, srcPath) => {
43
-
44
- let resultsForCreateSource = [];
45
-
46
- const defaultDynamoDataList = [
47
- {
48
- "tableName": "FindDataMain",
49
- "attributes": [
50
- {
51
- "keyType": "partitionKey",
52
- "AttributeName": "findDataId",
53
- "AttributeType": "S"
54
- }
55
- ]
56
- },
57
- {
58
- "tableName": "LogicalResultsMain",
59
- "attributes": [
60
- {
61
- "keyType": "partitionKey",
62
- "AttributeName": "logicalResultId",
63
- "AttributeType": "S"
64
- }
65
- ]
66
- },
67
- {
68
- "tableName": "LogicalResultsData",
69
- "attributes": [
70
- {
71
- "keyType": "partitionKey",
72
- "AttributeName": "logicalResultId",
73
- "AttributeType": "S"
74
- },
75
- {
76
- "keyType": "sortKey",
77
- "AttributeName": "identifiersId",
78
- "AttributeType": "S"
79
- }
80
- ]
81
- }
82
- ];
83
-
84
- for (let defaultlDynamoData of defaultDynamoDataList) {
85
- resultsForCreateSource.push({
86
- templatePath: templatePath,
87
- templateData: defaultlDynamoData,
88
- setting: {
89
- initialData: 'Resources:\n',
90
- savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
91
- saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
92
- fileExtension: '.yml',
93
- isAppend: true
94
- }
95
- });
96
- }
97
- return resultsForCreateSource;
98
- }
99
- module.exports = createDefaultSourceDataDynamoDB