@izara_project/izara-market-library-service-schemas 1.0.37 → 1.0.38

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 (107) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +35 -5
  3. package/src/MainLibs/src/Consts.js +5 -2
  4. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  5. package/src/MainLibs/src/Utils.js +12 -0
  6. package/src/reStructure/GenerateCode.js +2 -2
  7. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +36 -11
  8. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +24 -1
  9. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +26 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +22 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +37 -7
  12. package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -2
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +3 -3
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
  19. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  20. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/data.js +127 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/handler/data.js +121 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/{sqs/handler → handler}/template.ejs +16 -61
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/data.js +74 -0
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/template.ejs +131 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +61 -34
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -7
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -5
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +13 -4
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +15 -23
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +2 -4
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +2 -5
  34. package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/functionYaml/data.js +43 -38
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +20 -0
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +80 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/template.ejs +85 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +92 -0
  39. package/src/reStructure/TemplateData/flowSchema/{externalTopic/websocket → flowSchemaOwnTopic/flowStep}/mainFunction/template.ejs +11 -13
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +46 -37
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +14 -19
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/functionYaml/data.js +5 -21
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/functionYaml/template.ejs +20 -0
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/data.js +2 -2
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/data.js +2 -2
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/template.ejs +24 -10
  47. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +23 -25
  48. package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/template.ejs +1 -1
  49. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +172 -0
  50. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +165 -0
  51. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +38 -0
  52. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +39 -0
  53. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -0
  54. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -0
  55. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +2 -7
  56. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +22 -3
  57. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +14 -9
  58. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -6
  59. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +11 -7
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +17 -7
  61. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +23 -4
  62. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +14 -9
  63. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +26 -6
  64. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +10 -7
  65. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
  66. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +23 -4
  67. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +14 -9
  68. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +26 -7
  69. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +10 -7
  70. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +12 -7
  71. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +22 -3
  72. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +14 -6
  73. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +20 -3
  74. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +9 -3
  75. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +12 -6
  76. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +6 -2
  77. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +0 -184
  78. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -11
  79. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +0 -210
  80. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +0 -77
  81. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +0 -8
  82. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +0 -17
  83. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +0 -64
  84. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +0 -61
  85. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +0 -74
  86. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +0 -110
  87. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +0 -18
  88. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +0 -57
  89. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +0 -85
  90. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +0 -67
  91. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/functionYaml/template.ejs +0 -0
  92. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/template.ejs +0 -0
  93. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/data.js +0 -0
  94. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/template.ejs +0 -0
  95. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/data.js +0 -0
  96. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/mainFunction/data.js +0 -0
  97. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/dynamoDB/register.js +0 -0
  98. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/data.js +0 -0
  99. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/template.ejs +0 -0
  100. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/data.js +0 -0
  101. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/template.ejs +0 -0
  102. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/data.js +0 -0
  103. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/template.ejs +0 -0
  104. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/data.js +0 -0
  105. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/template.ejs +0 -0
  106. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/mainFunction/data.js +0 -0
  107. /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -0
@@ -1,11 +0,0 @@
1
- let expiryTime = storedCacheSharedLib.createExpiryTime(_izContext, 31536000);
2
-
3
- //(<createKeyValuesStoredCacheTable>)
4
- //(</createKeyValuesStoredCacheTable>)
5
-
6
- let [ cacheMainStauts, cacheId, cacheMain ] = await storedCacheSharedLib.checkStoredCacheStatus(
7
- _izContext,
8
- "<%- tableName %>",
9
- //(<keyValueStoredCacheTable>)
10
- //(</keyValueStoredCacheTable>)
11
- )
@@ -1,210 +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');
23
-
24
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
-
30
- const externalRequest = require('@izara_project/izara-core-library-external-request');
31
- const sns = externalRequest.sns
32
-
33
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
- const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
- const { v4: uuidv4 } = require('uuid')
36
- const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
37
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
- const generatedCodeLibs = require('../../../libs/source/GenerateCodeLibs')
39
- /**
40
- *
41
- *
42
- * description of function.
43
- * @param {Object} _izContext
44
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
45
- * @param {Logger} _izContext.logger - property of _izContext
46
- * @param {Object} requestParams - request params
47
- * @param {Object} requestParams.identifiers - identifiers for get data
48
- * @param {Object} requestParams.additionalRequest - additionalRequest
49
- *
50
- *
51
- * @returns {object} description of return value
52
- */
53
-
54
- module.exports.registerMain = async (
55
- _izContext,
56
- requestParams,
57
- callingFlowConfig = {},
58
- //(<additionalParams>)
59
- //(</additionalParams>)
60
- ) => {
61
- try {
62
- let connecttionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
63
- // receive flowTag and identifiers
64
- let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
65
- flowTag: requestParams.flowTag,
66
- serviceTag: process.env.iz_serviceTag,
67
- })
68
-
69
- _izContext.logger.debug("flowSchema", flowSchema)
70
- if (!flowSchema) {
71
- throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
72
- }
73
-
74
- // get data from dynamoDB of objectType of flowSchema
75
- const getStoredCache = async (objectType) => {
76
- const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
77
- _izContext,
78
- {
79
- objectType: objectType,
80
- serviceTag: process.env.iz_serviceTag,
81
- })
82
-
83
- _izContext.logger.debug("==> objectSchema", objectSchema)
84
-
85
- // this returns the table name of the first storage resource with storageType "dynamoDB"
86
- const tableName = Object.values(objectSchema.storageResources).find(
87
- (storageResource) => storageResource.storageType === "dynamoDB"
88
- )?.tableName
89
- _izContext.logger.debug("==> tableName", tableName)
90
-
91
- // const identifierPK = objectSchema[identifierPK].find(
92
- // (identifier) => identifier.type === "partitionKey"
93
- // )?.fieldName
94
-
95
- // const identifierSK = objectSchema[identifierSK].find(
96
- // (identifier) => identifier.type === "sortKey"
97
- // )?.fieldName
98
-
99
- let identifierPK = null
100
- let identifierSK = null
101
- objectSchema.identifiers.map((identifier) => {
102
- if (identifier.type === "partitionKey") {
103
- identifierPK = identifier.fieldName
104
- } else if (identifier.type === "sortKey") {
105
- identifierSK = identifier.fieldName
106
- }
107
- })
108
-
109
- _izContext.logger.debug("==> identifierPK", identifierPK)
110
- _izContext.logger.debug("==> identifierSK", identifierSK)
111
-
112
- const payloadGetStoredCache = {
113
- [identifierPK]: requestParams.identifiers[identifierPK],
114
- }
115
- if (identifierSK) {
116
- payloadGetStoredCache[identifierSK] = requestParams.identifiers[identifierSK]
117
- }
118
-
119
- _izContext.logger.debug("==> payloadGetStoredCache", payloadGetStoredCache)
120
-
121
- // const getStoredCache = await dynamodbSharedLib.getItem(
122
- // _izContext,
123
- // await dynamodbSharedLib.tableName(_izContext, tableName),
124
- // payloadGetStoredCache
125
- // )
126
-
127
- const getStoredCache = await dynamodbSharedLib.query(
128
- _izContext,
129
- await dynamodbSharedLib.tableName(_izContext, tableName),
130
- payloadGetStoredCache
131
- )
132
- _izContext.logger.debug("==> getStoredCache:::", getStoredCache)
133
- return ({
134
- data: getStoredCache.Items[0],
135
- identifierPK: identifierPK,
136
- })
137
- }
138
-
139
- // Initialize storedCacheData variable that will be used in multiple switch cases
140
- let storedCacheData = null;
141
- switch (flowSchema.statusType) {
142
- case "statusField":
143
- const payload = {
144
- identifiers: requestParams.identifiers,
145
- objectType: flowSchema.objType.objectType
146
- }
147
- const result = await externalRequest.lambda.invokeSync(
148
- _izContext,
149
- await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv", flowSchema.objType.serviceTag),
150
- payload
151
- )
152
- if (!result) {
153
- throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
154
- }
155
- await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
156
- return result
157
-
158
- break;
159
- case "storedCache":
160
- // if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
161
-
162
- storedCacheData = await getStoredCache(flowSchema.objType.objectType)
163
- _izContext.logger.debug("==> storedCacheData", storedCacheData)
164
-
165
- if (!storedCacheData) {
166
- throw new NoRetryError(`storedCache not found ${requestParams.identifiers} ${requestParams.sortKey}`)
167
- }
168
- let payloadPostMessage = {
169
- identifierTask: requestParams.identifiers[storedCacheData.identifierPK],
170
- connectionId: _izContext.correlationIds.get(consts.CONNECTION_ID),
171
- flowType: {
172
- flowTag: flowSchema.flowTag,
173
- serviceTag: process.env.iz_serviceTag,
174
- }
175
- }
176
-
177
- _izContext.logger.debug('==> payloadPostMessage', payloadPostMessage)
178
- if (storedCacheData.data.cacheStatus !== "error" && storedCacheData.data.cacheStatus != "complete") {
179
- await dynamodbSharedLib.putItem(
180
- _izContext,
181
- await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
182
- payloadPostMessage
183
- )
184
-
185
- return payloadPostMessage;
186
- } else {
187
- await dynamodbSharedLib.deleteItem(
188
- _izContext,
189
- await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
190
- {
191
- identifierTask: requestParams.identifiers[storedCacheData.identifierPK],
192
- connectionId: _izContext.correlationIds.get(consts.CONNECTION_ID)
193
- }
194
- )
195
- }
196
- await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
197
- return storedCacheData;
198
-
199
- case "none":
200
- break;
201
- default:
202
- throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
203
- }
204
-
205
- // post result to connectionId
206
- } catch (err) {
207
- _izContext.logger.error('error WebSocketInvoke: ', err)
208
- throw (err)
209
- }
210
- }
@@ -1,77 +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
- // const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
23
-
24
- const {
25
- firstLetterLowerCase: lowerCase,
26
- firstLetterUpperCase: upperCase,
27
- } = require("../../../../../MainLibs/src/Utils");
28
- const {
29
- DEFAULT_HANDLER_PER_ACTION,
30
- SOURCE_PATH,
31
- SAVE_FILE_NAME,
32
- FUNCTION_NAME,
33
- SOURCE_GENERATE_IAM_ROLE
34
- } = require("../../../../../MainLibs/src/Consts");
35
-
36
- const templatePath = path.join(__dirname, "./template.ejs");
37
- // /ResourceYaml/sns-out/template.ejs
38
- // /OutPerActionComplete/OutUpdateComplete/sns-out/data.js
39
-
40
- /**
41
- * create data for dynamoDbYaml tempalte from objectSchema
42
- * return array of dynamoDb data
43
- * because one objectSchema can create multiple dynamoDb table
44
- *
45
- * @param {Object} _izContext
46
- * @param {String} saveFilePath
47
- * @returns {Object[]} - data of multiple dynamoDb template
48
- */
49
- function data(_izContext, flowSchema, srcPath) {
50
- const createSourceParams = createParamsForCreateSource(_izContext, flowSchema, srcPath)
51
- return createSourceParams
52
- }
53
-
54
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
55
- //TranslateIds_Test_TranslateIdsComplete_Out
56
- let flowSteps = Object.keys(flowSchema.flowSteps)
57
- let flowStepTopicOut = flowSteps[1];
58
- let topicComponent = flowStepTopicOut.split("_");
59
- const queueName = `${upperCase(topicComponent[2])}_${upperCase(topicComponent[3])}`
60
- return [
61
- {
62
- templatePath: templatePath,
63
- templateData: {
64
- queueName: upperCase(queueName),
65
- },
66
- setting: {
67
- initialData: 'Resources:\n',
68
- savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
69
- saveFileName: SAVE_FILE_NAME.snsOutYaml,
70
- fileExtension: '.yml',
71
- isAppend: true
72
- }
73
- }
74
- ]
75
- }
76
-
77
- module.exports = data
@@ -1,8 +0,0 @@
1
- ##--------- [Create Topic Out]
2
- Out<%- firstLetterUpperCase(queueName) %>:
3
- Type: AWS::SNS::Topic
4
- Properties:
5
- DisplayName: "SNS Message out"
6
- TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>
7
-
8
- <%_ function firstLetterUpperCase(text) { return text.charAt(0).toUpperCase() + text.slice(1) } _%>
@@ -1,17 +0,0 @@
1
- <%_ const join = require('path').join _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}Out_${firstLetterUpperCase(handlerType)}.main`) %>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
- events:
6
- - sqs:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) + firstLetterUpperCase(handlerType) %>
8
- batchSize: 10
9
- role: <%- firstLetterUpperCase(roleName) _%>Role
10
- #<#<%- functionName %><%- handlerType %>IamRole#>
11
- #<#/<%- functionName %><%- handlerType %>IamRole#>
12
- <%_ function firstLetterUpperCase(text){
13
- return text.charAt(0).toUpperCase() + text.slice(1)
14
- } _%>
15
- <%_ function firstLetterLowerCase(str) {
16
- return str.charAt(0).toLowerCase() + str.slice(1)
17
- } _%>
@@ -1,64 +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
- const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
-
23
- const { SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../../MainLibs/src/Consts");
24
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
25
- const templatePath = path.join(__dirname, "template.ejs")
26
-
27
- /**
28
- * receive objectSchema
29
- * create data for SQS handler template
30
- *
31
- * @param {Object} objectSchema
32
- * @return {{templatePath, templateData,setting}}
33
- */
34
- function data(_izContext, flowSchema, srcPath) {
35
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
36
- }
37
-
38
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
- const flowStepInSplitKey = Object.keys(flowSchema.flowSteps)[0].split('_');
40
- if (flowStepInSplitKey.length < 4) {
41
- _izContext.logger.error(`flowStepInSplitKey.length < 4: ${flowStepInSplitKey.length} ${flowSchema.flowTag}`);
42
- return null;
43
- }
44
- let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicOut"
45
- let handlerType = upperCase(HANDLER.hdrSqs);
46
- return {
47
- templatePath: templatePath,
48
- templateData: {
49
- queueName: functionName + handlerType,
50
- fileName: functionName + '_Main',
51
- functionMain: functionName + 'Main',
52
- handler: HANDLER.hdrSqs,
53
- firstLetterUpperCase: upperCase,
54
- functionName
55
- },
56
- setting: {
57
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
58
- saveFileName: `${functionName}_${handlerType}`,
59
- fileExtension: ".js",
60
- isAppend: false
61
- }
62
- }
63
- }
64
- module.exports = data
@@ -1,61 +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
- const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require("../../../../../../MainLibs/src/Consts");
23
- const { firstLetterLowerCase: lowerCase, 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
-
27
- /**
28
- * receive objectSchema
29
- * create data for Sqs Main template
30
- *
31
- * @param {Object} objectSchema
32
- * @return {{templatePath, templateData,setting}}
33
- */
34
-
35
-
36
- function data(_izContext, flowSchema, srcPath) {
37
- return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
38
- }
39
-
40
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
- let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicOut";
42
- let snsTopicIn = Object.keys(flowSchema.flowSteps)
43
- let snsTopicInWithoutUnderscore = snsTopicIn[0].replace(/_/g, '')
44
- let handlerType = upperCase(HANDLER.hdrSqs);
45
- // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
46
- // let fieldNames = Object.keys(objectSchema.fieldNames)
47
- return {
48
- templatePath: templatePath,
49
- templateData: {
50
- snsTopicIn: snsTopicInWithoutUnderscore,
51
- externalTopicOutMain: functionName,
52
- },
53
- setting: {
54
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
55
- saveFileName: `${functionName}_Main`,
56
- fileExtension: ".js",
57
- isAppend: false
58
- }
59
- }
60
- }
61
- module.exports = data
@@ -1,74 +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 it under the terms of
5
- * the GNU Affero General Public License as published by the Free Software Foundation, either
6
- * version 3 of the License, or (at your option) any later version.
7
- *
8
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
- * See the GNU Affero General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU Affero General Public License along with this program.
13
- * If not, see <http://www.gnu.org/licenses/>.
14
- */
15
-
16
- 'use strict';
17
-
18
- const hash = require('@izara_project/izara-shared-core').objectHash;
19
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
20
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
21
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
22
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
23
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
24
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
25
- const externalRequestSns = require('@izara_project/izara-core-library-external-request').sns;
26
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils');
27
- const { NoRetryError, consts: coreConsts } = require('@izara_project/izara-core-library-core');
28
- const { v4: uuidv4 } = require('uuid');
29
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
30
- const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
31
-
32
- /**
33
- * Description of function.
34
- *
35
- * @param {Object} _izContext
36
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
37
- * @param {Logger} _izContext.logger - property of _izContext
38
- * @param {Object} requestParams - request params
39
- * @param {Object} requestParams.identifiers - identifiers for get data
40
- * @param {Object} requestParams.additionalRequest - additionalRequest
41
- *
42
- * @returns {object} description of return value
43
- */
44
- module.exports.<%- externalTopicOutMain %>Main = async (
45
- _izContext,
46
- requestParams,
47
- callingFlowConfig = {},
48
- // (<additionalParams>)
49
- // (</additionalParams>)
50
- ) => {
51
- try {
52
- let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
53
- let correlationId = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID);
54
-
55
- await postToConnection({
56
- message: requestParams
57
- }, connectionId);
58
-
59
- await dynamodbSharedLib.deleteItem(
60
- _izContext,
61
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
62
- {
63
- taskKey: correlationId,
64
- connectionId: connectionId
65
- }
66
- );
67
-
68
- // (<additionalParams>)
69
- // (</additionalParams>)
70
- } catch (err) {
71
- _izContext.logger.error('error WebSocketInvoke: ', err);
72
- throw err;
73
- }
74
- };
@@ -1,110 +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
- const { FLOW_SCHEMA_HOOK_STATE } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
-
24
- const { firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
25
- const {
26
- SOURCE_PATH,
27
- defaultIamRolePerAction,
28
- createIamRole,
29
- RESOURCE_CLASSES,
30
- SNS_RESOURCE,
31
- resourceNames,
32
- DYNAMO_RESOURCE,
33
- SAVE_FILE_NAME,
34
- FUNCTION_NAME,
35
- shortNameHandler,
36
- externalResourceYaml,
37
- SOURCE_GENERATE_IAM_ROLE
38
- } = require("../../../../../../MainLibs/src/Consts");
39
-
40
- const templatePath = path.join(__dirname, "template.ejs");
41
- const hookTemplate = path.join(__dirname, "./hookTemplate.ejs");
42
- /**
43
- * receive objectSchema
44
- * create data for WebSocket handler template
45
- *
46
- * @param {Object} objectSchema
47
- * @return {{templatePath, templateData,setting}}
48
- */
49
- function data(_izContext, flowSchema, srcPath) {
50
- return [createSourceParams(_izContext, flowSchema, srcPath)]
51
- }
52
-
53
- function createSourceParams(_izContext, flowSchema, srcPath) {
54
- let functionName = upperCase(flowSchema.flowTag);
55
- let handlerType = upperCase("hdrWbs");
56
- let functionConfig = functionName + "ExternalTopicIn" + upperCase(shortNameHandler(handlerType));
57
- let additionalResourcePermission = defaultIamRolePerAction();
58
- let route = flowSchema.flowTag;
59
-
60
- additionalResourcePermission.push(
61
- createIamRole(
62
- {
63
- [RESOURCE_CLASSES.dynamoDbTable]: [
64
- DYNAMO_RESOURCE.putItem,
65
- DYNAMO_RESOURCE.getItem,
66
- DYNAMO_RESOURCE.query,
67
- DYNAMO_RESOURCE.deleteItem,
68
- DYNAMO_RESOURCE.updateItem
69
- ]
70
- },
71
- [
72
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
73
- ]
74
- ),
75
- createIamRole(
76
- {
77
- "execute-api": [
78
- "ManageConnections"
79
- ]
80
- },
81
- [
82
- resourceNames(RESOURCE_CLASSES.webSocket)
83
- ]
84
- ),
85
- )
86
-
87
-
88
-
89
- return {
90
- templatePath: templatePath,
91
- templateData: {
92
- resourceLocation: path.join(SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
93
- functionName,
94
- handlerType,
95
- functionNameConfig: functionConfig,
96
- additionalResourcePermission,
97
- route,
98
- roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
99
- // externalTopicName
100
- },
101
- setting: {
102
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
103
- saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
104
- fileExtension: ".yml",
105
- isAppend: true
106
- }
107
- }
108
- }
109
-
110
- module.exports = data;
@@ -1,18 +0,0 @@
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(functionNameConfig) %>
5
- events:
6
- - websocket:
7
- route: <%- route %>
8
- # authorizer: ${self:custom.iz_authorizerAppLevel}
9
- # identifierResource: 'route.request.header.Auth'
10
- role: <%- roleName %>Role
11
- #<#<%- functionName %><%- handlerType %>IamRole#>
12
- #<#/<%- functionName %><%- handlerType %>IamRole#>
13
- <%_ function firstLetterUpperCase(text){
14
- return text.charAt(0).toUpperCase() + text.slice(1)
15
- } _%>
16
- <%_ function firstLetterLowerCase(str) {
17
- return str.charAt(0).toLowerCase() + str.slice(1)
18
- } _%>