@izara_project/izara-market-library-service-schemas 1.0.62 → 1.0.63

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 (49) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +7 -3
  3. package/src/MainLibs/src/Consts.js +5 -1
  4. package/src/reStructure/GenerateCode.js +1 -1
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +8 -8
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +114 -83
  7. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +8 -0
  8. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +11 -1
  9. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +13 -9
  10. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +3 -2
  11. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
  12. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +3 -1
  13. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +123 -0
  14. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/template.ejs +20 -0
  15. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +122 -0
  16. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/template.ejs +17 -0
  17. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +123 -0
  18. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/template.ejs +13 -0
  19. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +123 -0
  20. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/template.ejs +17 -0
  21. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/data.js +57 -0
  22. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/request.json +0 -0
  23. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/template.ejs +155 -0
  24. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/data.js +58 -0
  25. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/request.json +0 -0
  26. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/template.ejs +202 -0
  27. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/data.js +59 -0
  28. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/request.json +0 -0
  29. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/template.ejs +144 -0
  30. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/data.js +59 -0
  31. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/request.json +0 -0
  32. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/template.ejs +181 -0
  33. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/data.js +59 -0
  34. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +382 -0
  35. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/data.js +77 -0
  36. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
  37. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  38. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +121 -0
  39. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/template.ejs +20 -0
  40. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/data.js +60 -0
  41. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/template.ejs +129 -0
  42. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/data.js +55 -0
  43. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/template.ejs +154 -0
  44. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/data.js +71 -0
  45. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/template.ejs +46 -0
  46. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/data.js +71 -0
  47. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/template.ejs +10 -0
  48. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -2
  49. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +55 -2
@@ -0,0 +1,71 @@
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 {
23
+ // HANDLER,
24
+ // STORAGE_TYPES
25
+ // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
26
+
27
+
28
+ const STORAGE_TYPES = {
29
+ dynamoDB: "dynamoDB",
30
+ graph: "graph"
31
+ }
32
+
33
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/index.js").utils;
34
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../../../../MainLibs/index.js").consts;
35
+ const templatePath = path.join(__dirname, './template.ejs')
36
+
37
+ /**
38
+ * create data for dynamoDbYaml tempalte from objectSchema
39
+ * return array of dynamoDb data
40
+ * because one objectSchema can create multiple dynamoDb table
41
+ *
42
+ * @param {Object} _izContext
43
+ * @param {String} saveFilePath
44
+ * @returns {Object[]} - data of multiple dynamoDb template
45
+ */
46
+
47
+ function createDefaultSnsOut(_izContext, srcPath) {
48
+ const createSourceParams = createParamsForCreateSource(_izContext, srcPath)
49
+ // console.log("createSourceParamsCreateRelationshipComplete", createSourceParams)
50
+
51
+ return [createSourceParams]
52
+ }
53
+
54
+ function createParamsForCreateSource(_izContext, srcPath) {
55
+ let queueName = FUNCTION_NAME.changeRelComplete;
56
+ return {
57
+ templatePath: templatePath,
58
+ templateData: {
59
+ queueName: upperCase(queueName)
60
+ },
61
+ setting: {
62
+ initialData: 'Resources:\n',
63
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
64
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
65
+ fileExtension: '.yml',
66
+ isAppend: true
67
+ }
68
+ }
69
+ }
70
+
71
+ module.exports = createDefaultSnsOut
@@ -0,0 +1,10 @@
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) %>_Out
7
+
8
+ <%_ function firstLetterUpperCase(text) {
9
+ return text.charAt(0).toUpperCase() + text.slice(1)
10
+ } _%>
@@ -93,8 +93,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
93
93
  // add argument (to invoke lambda) to passOnProperties[]
94
94
  passOnProperties.push(record.body.Message.returnValue)
95
95
  passOnProperties.push(record.body.Message.status)
96
- passOnProperties.push(record.body.Message.errorsFound),
97
- passOnProperties.push(record.body.Message.graphServiceTag),
96
+ passOnProperties.push(record.body.Message.errorsFound)
97
+ passOnProperties.push(record.body.Message.graphServiceTag)
98
98
  passOnProperties.push(callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(record.body.Message)) // is Ok PassBackProperties
99
99
  // passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)) // is Ok callinfFlow
100
100
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
@@ -138,6 +138,31 @@ const getCompleteImports = {
138
138
  snsOut: require('./get/complete/sns-out/data')
139
139
  }
140
140
 
141
+ const changeRelationshipCompleteImports = {
142
+ mainFunction: require('./changeRelationship/complete/mainFunction/data'),
143
+ functionYaml: require('./changeRelationship/complete/functionYaml/data'),
144
+ handler: require('./changeRelationship/complete/handler/sqs/data'),
145
+ snsInSqs: require("./changeRelationship/complete/sns-in-sqs/data"),
146
+ snsOut: require("./changeRelationship/complete/sns-out/data")
147
+ }
148
+
149
+ const changeRelationshipActionImports = {
150
+ mainFunction: require('./changeRelationship/action/mainFunction/data'),
151
+ handler: {
152
+ api: require('./changeRelationship/action/handler/api/data'),
153
+ dsp: require("./changeRelationship/action/handler/dsq/data"),
154
+ inv: require('./changeRelationship/action/handler/inv/data'),
155
+ sqs: require('./changeRelationship/action/handler/sqs/data')
156
+ },
157
+ functionYaml: {
158
+ api: require('./changeRelationship/action/functionYaml/api/data'),
159
+ dsp: require("./changeRelationship/action/functionYaml/dsq/data"),
160
+ inv: require('./changeRelationship/action/functionYaml/inv/data'),
161
+ sqs: require('./changeRelationship/action/functionYaml/sqs/data')
162
+ },
163
+ snsInSqs: require('./changeRelationship/action/sns-in-sqs/data')
164
+ }
165
+
141
166
  /**
142
167
  * Generates code from templates based on object schemas
143
168
  * @param {Object} _izContext - Context object
@@ -151,7 +176,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
151
176
  // console.log('objSchemaPath', objSchemaPath);
152
177
  const allObjectRelationships = getAllLocalRelationshipSchema(_izContext, objSchemaPath);
153
178
  // console.log('allObjectRelationships', JSON.stringify(allObjectRelationships));
154
-
179
+ console.log("allObjectRelationships", allObjectRelationships)
155
180
  // Check if the table yaml is valid
156
181
  if (!allObjectRelationships.length) {
157
182
  return createSourceParams;
@@ -212,6 +237,21 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
212
237
  const getSnsInSqs = getActionImports.snsInSqs(_izContext, saveFilePath);
213
238
  const getCompleteSnsInSqs = getCompleteImports.snsInSqs(_izContext, saveFilePath);
214
239
  const getCompleteSnsOut = getCompleteImports.snsOut(_izContext, saveFilePath);
240
+
241
+ // Generate change relationship data
242
+ const changeRelMainFunction = changeRelationshipActionImports.mainFunction(_izContext, saveFilePath);
243
+ const changeRelCompleteMainFunction = changeRelationshipCompleteImports.mainFunction(_izContext, saveFilePath);
244
+
245
+ const changeRelFunctionYaml = Object.values(changeRelationshipActionImports.functionYaml).map(fn => fn(_izContext, allObjectRelationships, saveFilePath)).flat();
246
+ const changeRelCompleteYaml = changeRelationshipCompleteImports.functionYaml(_izContext, saveFilePath);
247
+
248
+ const changeRelHandlers = Object.values(changeRelationshipActionImports.handler).map(fn => fn(_izContext, saveFilePath)).flat();
249
+ const changeRelCompleteHandler = changeRelationshipCompleteImports.handler(_izContext, saveFilePath);
250
+
251
+ const changeRelSnsInSqs = changeRelationshipActionImports.snsInSqs(_izContext, saveFilePath);
252
+ const changeRelCompleteSnsInSqs = changeRelationshipCompleteImports.snsInSqs(_izContext, saveFilePath);
253
+ const changeRelCompleteSnsOut = changeRelationshipCompleteImports.snsOut(_izContext, saveFilePath);
254
+
215
255
  // Combine all generated data
216
256
  const updateRelationshipData = [
217
257
  ...updateHandlers,
@@ -272,6 +312,18 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
272
312
  ...getCompleteSnsInSqs,
273
313
  ...getCompleteSnsOut
274
314
  ];
315
+
316
+ const changeRelData = [
317
+ ...changeRelMainFunction,
318
+ ...changeRelCompleteMainFunction,
319
+ ...changeRelFunctionYaml,
320
+ ...changeRelCompleteYaml,
321
+ ...changeRelHandlers,
322
+ ...changeRelCompleteHandler,
323
+ ...changeRelSnsInSqs,
324
+ ...changeRelCompleteSnsInSqs,
325
+ ...changeRelCompleteSnsOut,
326
+ ];
275
327
  // Combine all data sets
276
328
  createSourceParams.push(
277
329
  ...updateRelationshipData,
@@ -281,7 +333,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
281
333
  ...deleteRelationshipData,
282
334
  ...deleteRelationshipCompleteData,
283
335
  ...getRelationshipData,
284
- ...getRelationshipCompleteData
336
+ ...getRelationshipCompleteData,
337
+ ...changeRelData
285
338
  );
286
339
 
287
340
  return createSourceParams;