@izara_project/izara-market-library-service-schemas 1.0.56 → 1.0.58

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 (34) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +4 -28
  3. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +5 -6
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +6 -4
  5. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +4 -22
  6. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +3 -1
  7. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -1
  8. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +12 -8
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +0 -14
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +19 -13
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +3 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +26 -16
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +9 -12
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +0 -3
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +4 -1
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/template.ejs +1 -1
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +4 -47
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/sns-out/data.js +75 -0
  19. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  20. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +18 -0
  21. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ttlDynamoTemplate.ejs +32 -0
  22. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/userUploadRecords.js +58 -0
  23. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -2
  24. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +23 -15
  25. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +7 -6
  26. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -4
  27. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +2 -2
  28. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
  29. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +22 -2
  30. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/data.js +0 -87
  31. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/template.ejs +0 -30
  32. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/data.js +0 -45
  33. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/template.ejs +0 -151
  34. package/src/reStructure/TemplateData/resourceYaml/dynamodb/request.json +0 -7
@@ -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
+
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
+
29
+ const STORAGE_TYPES = {
30
+ dynamoDB: "dynamoDB",
31
+ graph: "graph"
32
+ }
33
+
34
+ const templatePath = path.join(__dirname, '../../../../../resourceYaml/sns-out/template.ejs')
35
+ const {
36
+ utils: { firstLetterUpperCase: upperCase },
37
+ consts: { SOURCE_PATH, SAVE_FILE_NAME }
38
+ } = require("../../../../../../../MainLibs")
39
+
40
+
41
+ /**
42
+ * create data for template.ejs
43
+ * return array of defaultSnsOutData
44
+ * because must create for FindData and ProcessLogical
45
+ *
46
+ * @param {Object} _izContext
47
+ * @param {String} saveFilePath
48
+ * @returns {Object[]} - data of multiple defaultSnsOutData
49
+ */
50
+
51
+ function createDataForDefaultSnsOut(_izContext, flowSchema, srcPath) {
52
+ let resultsForCreateDefaultSnsOut = [];
53
+ const defaultSnsOutDataList = [
54
+ {
55
+ queueName: upperCase(flowSchema.flowTag)
56
+ },
57
+ ]
58
+
59
+ for (let defaultSnsOutData of defaultSnsOutDataList) {
60
+ resultsForCreateDefaultSnsOut.push({
61
+ templatePath: templatePath,
62
+ templateData: defaultSnsOutData,
63
+ setting: {
64
+ initialData: "Resources:\n",
65
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
66
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
67
+ fileExtension: ".yml",
68
+ isAppend: true
69
+ }
70
+ })
71
+ }
72
+ return resultsForCreateDefaultSnsOut;
73
+ }
74
+
75
+ module.exports = createDataForDefaultSnsOut;
@@ -53,7 +53,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
53
53
  ]
54
54
  },
55
55
  [
56
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
56
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, "UserUploadRecords")
57
57
  ]
58
58
  ),
59
59
  createIamRole(
@@ -32,11 +32,29 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
32
32
  switch (eventType) {
33
33
  case 'CONNECT':
34
34
  console.log('Connect websocket')
35
+
36
+ let { userId, submittedByUserId } = event.queryStringParameters;
37
+
38
+ await dynamodbSharedLib.putItem(event._izContext,
39
+ await dynamodbSharedLib.tableName(event._izContext, "UserUploadRecords"),
40
+ {
41
+ connectionId: connectionId,
42
+ userId: userId,
43
+ submittedByUserId: submittedByUserId,
44
+ expirationTime: Math.floor(Date.now() / 1000) + 7200 // ttl time milliSecond to second + 2 hour
45
+ }
46
+ )
35
47
  //(<webSocketConnect>)
36
48
  //(</webSocketConnect>)
37
49
  break
38
50
  case 'DISCONNECT':
39
51
  console.log('Websocket are Disconnection')
52
+ await dynamodbSharedLib.deleteItem(event._izContext,
53
+ await dynamodbSharedLib.tableName(event._izContext, "UserUploadRecords"),
54
+ {
55
+ connectionId: connectionId,
56
+ }
57
+ )
40
58
  //(<webSocketDisconnect>)
41
59
  //(</webSocketDisconnect>)
42
60
  break
@@ -0,0 +1,32 @@
1
+ <%- resourceName %>Table:
2
+ Type: "AWS::DynamoDB::Table"
3
+ Properties:
4
+ TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
5
+ BillingMode: PAY_PER_REQUEST
6
+ AttributeDefinitions:
7
+ <%_ attributes.forEach(attribute => { -%>
8
+ - AttributeName: <%- attribute['AttributeName'] %>
9
+ AttributeType: <%- attribute['AttributeType'] %>
10
+ <%_ }) _%>
11
+ KeySchema:
12
+ <%_ attributes.forEach(attribute => { -%>
13
+ <%_ if (attribute.keyType === 'partitionKey' || attribute.keyType === "identifier") { -%>
14
+ - AttributeName: <%- attribute["AttributeName"] %>
15
+ KeyType: HASH
16
+ <%_ } -%>
17
+ <%_ if(attribute.keyType === "sortKey") { -%>
18
+ - AttributeName: <%- attribute["AttributeName"] %>
19
+ KeyType: RANGE
20
+ <%_ } -%>
21
+ <%_ }) _%>
22
+ TimeToLiveSpecification:
23
+ AttributeName: expirationTime
24
+ Enabled: true
25
+ #<#<%- firstLetterUpperCase(tableName) %>DynamoDbSetting#>
26
+ #<#/<%- firstLetterUpperCase(tableName) %>DynamoDbSetting#>
27
+ <%_ function firstLetterUpperCase(text){
28
+ return text.charAt(0).toUpperCase() + text.slice(1)
29
+ } _%>
30
+ <%_ function firstLetterLowerCase(str) {
31
+ return str.charAt(0).toLowerCase() + str.slice(1)
32
+ } _%>
@@ -0,0 +1,58 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../../../MainLibs/src/Consts');
21
+
22
+ const templatePath = path.join(__dirname, "./ttlDynamoTemplate.ejs")
23
+
24
+ function data(_izContext, srcPath) {
25
+ let resultForCreateSources = [];
26
+ const userUploadRecords = [
27
+ {
28
+ tableName: "UserUploadRecords",
29
+ resourceName: "UserUploadRecords",
30
+ attributes: [
31
+ {
32
+ keyType: "partitionKey",
33
+ AttributeName: "connectionId",
34
+ AttributeType: "S"
35
+ }
36
+ ]
37
+ }
38
+ ];
39
+
40
+ for (let userUploadRecord of userUploadRecords) {
41
+ resultForCreateSources.push(
42
+ {
43
+ templatePath: templatePath,
44
+ templateData: userUploadRecord,
45
+ setting: {
46
+ initialData: 'Resources:\n',
47
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
48
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
49
+ fileExtension: ".yml",
50
+ isAppend: true
51
+ }
52
+ }
53
+ )
54
+ }
55
+ return resultForCreateSources;
56
+ }
57
+
58
+ module.exports = data;
@@ -28,6 +28,7 @@ const hash = require('@izara_project/izara-shared-core').objectHash;
28
28
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
29
29
  const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
30
30
  const <%- functionName %> = require('./<%- functionName %>_Main');
31
+ const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
31
32
  module.exports.main = middleware.wrap(async (event, context, callback) => {
32
33
 
33
34
  event._izContext.logger.debug('Event:', event);
@@ -63,7 +64,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
63
64
  await dynamodbSharedLib.putItem(event._izContext,
64
65
  await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
65
66
  {
66
- taskKey: `${utils.createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
67
+ taskKey: `${createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
67
68
  connectionId: connectionId,
68
69
  }
69
70
  )
@@ -73,7 +74,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
73
74
  event._izContext,
74
75
  await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
75
76
  {
76
- taskKey: `${utils.createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${correlationId}`,
77
+ taskKey: `${createFlowTypeConcat(event._izContext, { flowTag: "<%- route %>", serviceTag: process.env.iz_serviceTag })}${correlationId}`,
77
78
  connectionId: connectionId,
78
79
  }
79
80
  )
@@ -29,21 +29,23 @@ const {
29
29
 
30
30
  // Core components
31
31
  const createWebSocketDynamoDb = require('./components/websocket/dynamoDb/WebSocketTaskData');
32
+ const createUserUploadRecordTable = require('./components/websocket/dynamoDb/userUploadRecords')
32
33
  const createReservedDataMainTable = require('./components/websocket/dynamoDb/ReservedTableData');
33
34
  const createBucketS3 = require('./components/upload/relate/S3/data');
34
35
  const createWebSocketGenerateCodeLibs = require('./components/upload/relate/libs/data');
35
36
  const createWebSocketConnectYaml = require('./components/websocket/connect/functionYaml/data')
36
37
  const createWebSocketConnectHandler = require('./components/websocket/connect/handler/data')
38
+ const createSnsTopicForUploadS3 = require('./components/upload/relate/sns-out/data')
37
39
  // CreateObject components
38
40
  const createFunctionYamlCreateObjectWebSocket = require('./components/upload/createObject/functionYaml/data');
39
41
  const createHandlerCreateObjectWebSocket = require('./components/upload/createObject/handler/data');
40
42
  const createMainFunctionCreateObjectWebSocket = require('./components/upload/createObject/mainFunction/data');
41
43
 
42
44
  // CreateObjectComplete components
43
- const createWebSocketCreateObjectCompleteFunctionYaml = require('./components/upload/createObjectComplete/functionYaml/data');
44
- const createWebSocketCreateObjectCompleteQueue = require('./components/upload/createObjectComplete/sns-sqs/data');
45
- const createWebSocketCreateObjectCompleteHandler = require('./components/upload/createObjectComplete/handler/data');
46
- const createWebSocketCreateObjectCompleteMainFunction = require('./components/upload/createObjectComplete/mainFunction/data');
45
+ // const createWebSocketCreateObjectCompleteFunctionYaml = require('./components/upload/createObjectComplete/functionYaml/data');
46
+ // const createWebSocketCreateObjectCompleteQueue = require('./components/upload/createObjectComplete/sns-sqs/data');
47
+ // const createWebSocketCreateObjectCompleteHandler = require('./components/upload/createObjectComplete/handler/data');
48
+ // const createWebSocketCreateObjectCompleteMainFunction = require('./components/upload/createObjectComplete/mainFunction/data');
47
49
 
48
50
  // PreSign URL components
49
51
  const createReservedLimitFunctionYaml = require('./components/upload/preSignUrl/reservedLimit/functionYaml/data');
@@ -72,9 +74,9 @@ const createConfirmAfterUploadS3Queue = require('./components/upload/confirmRese
72
74
  // flowSchema ExternalTopic components //
73
75
  const createExternalSqsFunctionYaml = require('./externalTopic/Process/functionYaml/data');
74
76
  const createExternalSqsHandler = require('./externalTopic/Process/handler/data');
75
- const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
76
- const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
77
- const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
77
+ // const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
78
+ // const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
79
+ // const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
78
80
  const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
79
81
  const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
80
82
 
@@ -101,9 +103,9 @@ const createFlowSchemaFlowStepHandler = require('./flowStep/handler/data');
101
103
  const createFlowSchemaFlowStepMainFunction = require('./flowStep/mainFunction/data')
102
104
  const createFlowSchemaFlowStepSnsIn = require('./flowStep/sns-in/data');
103
105
  // flowSchema OwnTopicEndpointComplete component
104
- const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
105
- const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
106
- const createFlowSchemaOwnTopicEndpointCompleteMainFunction = require('./flowSchemaOwnTopic/EndpointComplete/mainFunction/data');
106
+ // const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
107
+ // const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
108
+ // const createFlowSchemaOwnTopicEndpointCompleteMainFunction = require('./flowSchemaOwnTopic/EndpointComplete/mainFunction/data');
107
109
 
108
110
  const createFlowSchemaOwnTopicQueue = require('./flowSchemaOwnTopic/sns-in/data');
109
111
  const createFlowSchemaOwnTopicSnsOut = require('./flowSchemaOwnTopic/sns-out/data');
@@ -121,10 +123,10 @@ const createFlowSchemaLambdaSyncHandlerApi = require("./lambdaSync/Api/handler/d
121
123
 
122
124
  const createAwaitingMultipleStepDynamoDbData = require('./dynamoDb/data');
123
125
  // create record status Field Complete
124
- const createCreateObjectCompleteFunctionYaml = require('./CreateRecordComplete/functionYaml/data');
125
- const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
126
- const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
127
- const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
126
+ // const createCreateObjectCompleteFunctionYaml = require('./CreateRecordComplete/functionYaml/data');
127
+ // const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
128
+ // const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
129
+ // const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
128
130
 
129
131
  const createFlowSchemaRegisterHandlerComplete = require('./register/complete/handler/data');
130
132
  const createFlowSchemaRegisterMainCompleteFunc = require('./register/complete/mainFunction/data');
@@ -178,9 +180,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
178
180
  for (const flowSchema of allLocalFlowSchemas.records) {
179
181
  // console.log("flowSchema in Generate TemplateData", flowSchema);
180
182
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
183
+ createSourceParams.push(...webSocketGenerateCodeLibs)
181
184
  if (!flowSchema.event.includes("s3")) {
182
185
  const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
183
- createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
186
+ createSourceParams.push(...flowSchemaEndpointMainFunction)
184
187
  }
185
188
 
186
189
  // event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
@@ -188,6 +191,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
188
191
  if (event.includes("s3")) {
189
192
  const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
190
193
  const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
194
+ const userUploadRecordTable = createUserUploadRecordTable(_izContext, saveFilePath)
191
195
 
192
196
  const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
193
197
  const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
@@ -221,6 +225,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
221
225
  const confirmReservedAfterUploadMainFunction = createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, saveFilePath);
222
226
  const confirmReservedAfterUploadQueue = createConfirmAfterUploadS3Queue(_izContext, saveFilePath);
223
227
 
228
+ const snsTopicOutFlowSchemaUploadS3 = createSnsTopicForUploadS3(_izContext, flowSchema, saveFilePath);
229
+
224
230
  const webSocketFunctions = [
225
231
  ...functionYamlCreateObjectWebSocket,
226
232
  ...handlerCreateObjectWebSocket,
@@ -275,6 +281,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
275
281
  ...reservedLimitResources,
276
282
  ...processAfterUploadResources,
277
283
  ...confirmAfterUploadResources,
284
+ ...snsTopicOutFlowSchemaUploadS3,
285
+ ...userUploadRecordTable
278
286
  );
279
287
 
280
288
  } else if (event.includes("extTopic")) {
@@ -88,21 +88,24 @@ module.exports.<%- functionName %> = async (
88
88
  throw new NoRetryError("not have flowSchema in S3")
89
89
  }
90
90
 
91
- let wbsTasks;
91
+ let wbsTasks;
92
+ let taskKey;
92
93
  if (flowSchema.statusType === "statusField" || flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
94
+ taskKey = `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${identifiers}`
93
95
  wbsTasks = await dynamodbSharedLib.query(
94
96
  _izContext,
95
97
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
96
98
  {
97
- taskKey: `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${identifiers}`
99
+ taskKey: taskKey
98
100
  }
99
101
  )
100
102
  } else if (flowSchema.statusType === "none") {
103
+ taskKey = `${createFlowTypeConcat(_izContext,{flowTag: topicName[2],serviceTag: topicName[0]})}${correlationId}`
101
104
  wbsTasks = await dynamodbSharedLib.query(
102
105
  _izContext,
103
106
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
104
107
  {
105
- taskKey: correlationId,
108
+ taskKey: taskKey
106
109
  }
107
110
  )
108
111
  }
@@ -119,13 +122,11 @@ module.exports.<%- functionName %> = async (
119
122
  await dynamodbSharedLib.deleteItem(_izContext,
120
123
  await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
121
124
  {
122
- taskKey: correlationId,
125
+ taskKey: taskKey,
123
126
  connectionId: connectionId
124
127
  }
125
128
  )
126
129
  }))
127
-
128
-
129
130
  }
130
131
 
131
132
  } catch (err) {
@@ -54,10 +54,10 @@ module.exports.updateNodeComplete = async (
54
54
  // start create AwaitingStepId
55
55
  let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
56
56
  hash({
57
- objectType: returnValue.queryResult.objType.objectType,
58
- serviceTag: returnValue.queryResult.objType.serviceTag,
59
- identifiers: returnValue.queryResult.objInstanceFull.identifiers,
60
- fields: returnValue.queryResult.objInstanceFull.fields
57
+ objectType: returnValue.requestParams.objType.objectType,
58
+ serviceTag: returnValue.requestParams.objType.objectType,
59
+ identifiers: returnValue.requestParams.objInstanceFull.identifiers,
60
+ fields: returnValue.requestParams.objInstanceFull.fields
61
61
  }),
62
62
  PREFIX.updateNode
63
63
  )
@@ -315,7 +315,7 @@ module.exports.processLogical = async (
315
315
  comparison: comparison,
316
316
  callingFlow: callingFlow
317
317
  }),
318
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InPaginateProcessLogical")
318
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "InPaginateProcessLogical")
319
319
  };
320
320
  _izContext.logger.debug('Request params before send to topic InPaginateProcessLogical: ', sentMessageToPaginateProcessLogical);
321
321
 
@@ -374,7 +374,7 @@ module.exports.processLogical = async (
374
374
  sortKeyFieldName: sortKeyFieldName,
375
375
  callingFlow: callingFlow
376
376
  }),
377
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, "InPaginateProcessLogical")
377
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "InPaginateProcessLogical")
378
378
  };
379
379
  _izContext.logger.debug('Request params before send to topic InPaginateProcessLogical: ', sentMessageToPaginateProcessLogical);
380
380
 
@@ -70,7 +70,7 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
70
70
  let attributeType;
71
71
  if (fieldNameType === 'string') {
72
72
  attributeType = "S"
73
- } else if (fieldNameType === 'number') {
73
+ } else if (fieldNameType === 'number' || fieldNameType === "timestamp") {
74
74
  attributeType = "N"
75
75
  }
76
76
  Object.assign(
@@ -30,7 +30,7 @@ const STORAGE_TYPES = {
30
30
  graph: "graph"
31
31
  }
32
32
  const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../MainLibs/src/Consts')
33
- const { firstUpperCase: upperCase } = require('../../../../MainLibs/src/Utils')
33
+ const { firstUpperCase: upperCase, getLocalConfig } = require('../../../../MainLibs/src/Utils')
34
34
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
35
35
  const { NoRetryError } = require("@izara_project/izara-core-library-core");
36
36
 
@@ -45,7 +45,13 @@ async function filterCreateResourceYaml(_izContext, createSourceParams, objSchem
45
45
  }
46
46
  }))
47
47
 
48
- const filteredCreateSourceParams = createSourceParams.filter(
48
+ const allLocalObjSchema = await getObjectSchema.getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
49
+ await Promise.all(allLocalObjSchema.records.map(async (objSchema) => {
50
+ if (objSchema.hasOwnProperty("extendObjType")) {
51
+ tableNamesToFilter.add(...await getParentTableFromObjSchema(_izContext, objSchema, objSchemaPath))
52
+ }
53
+ }))
54
+ let filteredCreateSourceParams = createSourceParams.filter(
49
55
  (result) => !tableNamesToFilter.has(result.templateData.tableName)
50
56
  )
51
57
 
@@ -69,3 +75,17 @@ async function getStoredCacheTableFromFlowSchema(_izContext, flowSchema, objSche
69
75
  }
70
76
  return tableNameStoredCache;
71
77
  }
78
+
79
+ async function getParentTableFromObjSchema(_izContext, objSchema, objSchemaPath) {
80
+ let parentTableNames = new Set();
81
+ let ownServiceTag = getLocalConfig(path.join(objSchemaPath, "../../"), "iz_serviceTag")
82
+ for (const storageResource of Object.values(objSchema.storageResources)) {
83
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
84
+ if (storageResource.serviceTag && storageResource.serviceTag !== ownServiceTag) {
85
+ parentTableNames.add(storageResource.tableName)
86
+ }
87
+ }
88
+ }
89
+
90
+ return parentTableNames
91
+ }
@@ -1,87 +0,0 @@
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 path = require("path")
21
-
22
- const { firstLetterUpperCase: upperCase } = require('../../../../../../../MainLibs/src/Utils');
23
- const { SOURCE_PATH, SAVE_FILE_NAME, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, S3_RESOURCE, resourceNames, DYNAMO_RESOURCE, SQS_RESOURCE, SNS_RESOURCE, shortNameHandler, HANDLER, FUNCTION_NAME } = require("../../../../../libs/Consts");
24
- const templatePath = path.join(__dirname, "./template.ejs")
25
-
26
- function data(_izContext, srcPath) {
27
- return [createSourceParam(_izContext, srcPath)]
28
- }
29
-
30
- function createSourceParam(_izContext, srcPath) {
31
- let functionName = upperCase(FUNCTION_NAME.processAfterUploadS3);
32
- let handlerType = HANDLER.hdrDsq;
33
- let additionalResourcePermission = defaultIamRolePerAction();
34
- additionalResourcePermission.push(
35
-
36
- createIamRole(
37
- {
38
- [RESOURCE_CLASSES.dynamoDbTable]: [
39
- DYNAMO_RESOURCE.updateItem,
40
- DYNAMO_RESOURCE.getItem
41
- ]
42
- },
43
- [
44
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, "ImportBatchMain")
45
- ]
46
- ),
47
- createIamRole(
48
- {
49
- [RESOURCE_CLASSES.sqs]: [
50
- SQS_RESOURCE.sendMessage,
51
- SQS_RESOURCE.receiveMessage,
52
- SQS_RESOURCE.deleteMessage,
53
- SQS_RESOURCE.getQueueAttributes
54
- ]
55
- },
56
- [
57
- resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
58
- resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType + "DLQ")
59
- ]
60
- ),
61
- createIamRole(
62
- {
63
- [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
64
- },
65
- [
66
- resourceNames(RESOURCE_CLASSES.sns, "In" + functionName)
67
- ]
68
- )
69
- )
70
- return {
71
- templatePath: templatePath,
72
- templateData: {
73
- functionName,
74
- handlerType,
75
- additionalResourcePermission,
76
- resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
77
- },
78
- setting: {
79
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
80
- saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
81
- isAppend: true,
82
- fileExtension: ".yml"
83
- }
84
- }
85
- }
86
-
87
- module.exports = data
@@ -1,30 +0,0 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
- events:
6
- - sqs:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
8
- batchSize: 10
9
- iamRoleStatements:
10
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
11
- - Effect: <%- resourcePermission.effect %>
12
- Action:
13
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
14
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
15
- - <%- resourcePerAction %>:<%- permission %>
16
- <%_}) _%>
17
- <%_ }) _%>
18
- Resource:
19
- <%_ resourcePermission.resource.forEach(resource => { _%>
20
- - <%- resource %>
21
- <%_ }) _%>
22
- <%_}) _%>
23
- #<#<%- functionName %><%- handlerType %>IamRole#>
24
- #<#/<%- functionName %><%- handlerType %>IamRole#>
25
- <%_ function firstLetterUpperCase(text){
26
- return text.charAt(0).toUpperCase() + text.slice(1)
27
- } _%>
28
- <%_ function firstLetterLowerCase(str) {
29
- return str.charAt(0).toLowerCase() + str.slice(1)
30
- } _%>
@@ -1,45 +0,0 @@
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 path = require("path")
21
-
22
- const { firstLetterUpperCase: upperCase } = require('../../../../../../../MainLibs/src/Utils');
23
- const { SOURCE_PATH, SAVE_FILE_NAME, defaultIamRolePerAction, createIamRole, RESOURCE_CLASSES, S3_RESOURCE, resourceNames, DYNAMO_RESOURCE, SQS_RESOURCE, SNS_RESOURCE, shortNameHandler, HANDLER, FUNCTION_NAME } = require("../../../../../libs/Consts");
24
- const templatePath = path.join(__dirname, "./template.ejs")
25
-
26
- function data(_izContext, srcPath) {
27
- return [createSourceData(_izContext, srcPath)]
28
- }
29
-
30
- function createSourceData(_izContext, srcPath) {
31
- let functionName = FUNCTION_NAME.processAfterUploadS3;
32
- let handlerType = HANDLER.hdrDsq;
33
-
34
- return {
35
- templatePath: templatePath,
36
- templateData: {},
37
- setting: {
38
- saveFileName: `${upperCase(functionName)}_${upperCase(handlerType)}`,
39
- savePath: path.join(srcPath, SOURCE_PATH.webSocket),
40
- fileExtension: ".js",
41
- isAppend: false
42
- }
43
- }
44
- }
45
- module.exports = data;