@izara_project/izara-market-library-service-schemas 1.0.82 → 1.0.83

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -49,9 +49,9 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
49
49
  // collect all result of template data for execute createSource
50
50
  let allCreateSource = []
51
51
 
52
-
52
+ // console.log({ intTestPath })
53
53
  // let generateTemplateData = (await import(join(__dirname, IntTestConfig.TemplateAndData[templateName]))).default;
54
- let createSourceResult = await generateTest(_izContext, savePath);
54
+ let createSourceResult = await generateTest(_izContext, savePath, { serviceTag, s3Prefix: settings });
55
55
  // console.log({ createSourceResult })
56
56
  // Filter out empty or invalid objects before adding to allCreateSource
57
57
  if (Array.isArray(createSourceResult)) {
@@ -85,7 +85,7 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
85
85
  }
86
86
 
87
87
  // validatePathWithRootServicePath(localServicePath, setting.savePath)
88
- await deleteFileInDir(setting.savePath);
88
+ // await deleteFileInDir(setting.savePath);
89
89
  }
90
90
 
91
91
  // generate all source
@@ -109,10 +109,12 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
109
109
  console.log('Generated all source files successfully');
110
110
 
111
111
  console.log("upload file to S3")
112
- const intTestPath = join(saveFilePath, `../../src/generateIntegrationTest/${serviceTag}`)
113
- console.log({ intTestPath })
114
112
 
115
- await uploadLib(intTestPath, { s3Prefix: settings, serviceTag: serviceTag })
113
+
114
+ await uploadLib.uploadTos3(
115
+ join(saveFilePath, `../../src/generateIntegrationTest/${serviceTag}`), //intTest path
116
+ { s3Prefix: settings, serviceTag: serviceTag } // settings
117
+ )
116
118
 
117
119
 
118
120
  // exec(`bash ${ path.join(packagePath, "./frontEnd/NpmBash.bash") } `, (error, stdout, stderr) => {
@@ -1,31 +1,33 @@
1
1
  {
2
2
  "Lambda": {
3
- <% Object.entries(functionComponent).forEach(([funcName, filePath], index, array) => { -%>
3
+ <% Object.entries(functionComponent).forEach(([funcName, filePath], index, array) => { %>
4
4
  "<%= funcName %>": {
5
5
  "localLocation": "/<%= filePath %>.js",
6
6
  "localHandler": "main",
7
7
  "functionName": "<%= funcName %>"
8
- }<%= index !== array.length - 1 ? ',' : '' %>
9
- <% }); -%>
10
- }, <% Object.keys(s3Component).length ? "," : "" %>
11
- <% if (Object.keys(s3Component).length) { -%>
8
+ }<%= index < array.length - 1 ? "," : "" %>
9
+ <% }) %>
10
+ }<%= Object.keys(s3Component).length || Object.keys(tableNames).length ? "," : "" %>
11
+
12
+ <% if (Object.keys(s3Component).length) { %>
12
13
  "S3": {
13
- <% Object.entries(s3Component).forEach(([functionName,filePath],index) => { -%>
14
- "<%- functionName %>": {
15
- "localLocation": "/<%- filePath %>",
14
+ <% Object.entries(s3Component).forEach(([functionName, filePath], index, array) => { %>
15
+ "<%= functionName %>": {
16
+ "localLocation": "/<%= filePath %>",
16
17
  "localHandler": "main",
17
- "functionName": "<%- functionName %>"
18
- }<%= index < Object.keys(s3Component).length - 1 ? "," : "" %>
19
- <% }); -%>
20
- } <% Object.keys(tableNames).length ? "," : "" -%>
21
- <% } -%>
22
- <% if (Object.keys(tableNames).length) { -%>
18
+ "functionName": "<%= functionName %>"
19
+ }<%= index < array.length - 1 ? "," : "" %>
20
+ <% }) %>
21
+ }<%= Object.keys(tableNames).length ? "," : "" %>
22
+ <% } %>
23
+
24
+ <% if (Object.keys(tableNames).length) { %>
23
25
  "Dynamodb": {
24
- <% tableNames.forEach(function(tableName, index) { %>
26
+ <% tableNames.forEach((tableName, index) => { %>
25
27
  "<%= tableName %>": {
26
28
  "tableName": "<%= tableName %>"
27
- }<% if (index < tableNames.length - 1) { %>,<% } %>
28
- <% }); %>
29
+ }<%= index < tableNames.length - 1 ? "," : "" %>
30
+ <% }) %>
29
31
  }
30
32
  <% } %>
31
33
  }
@@ -20,17 +20,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  import { join } from 'path';
21
21
  import generateEvent from './events/data.js'
22
22
  import generateTest from "./tests/data.js"
23
+ import generatePathIntTest from './pathIntTest/data.js';
23
24
  // import generateBashScript from './bashScript/data.js'
24
25
  import libs from '../libs/libs.js'
25
- const { getIntTestConfig } = libs;
26
+ const { getIntTestConfig, getLocalConfig } = libs;
26
27
  /**
27
28
  * Generates code with templates for different actions
28
29
  * @param {Object} _izContext - Context object
29
30
  * @param {string} savePath - Path to the schema
30
31
  * @returns {Array} Array of generated code parameters
31
32
  */
32
- async function generateCodeWithTemplate(_izContext, savePath) {
33
+ async function generateCodeWithTemplate(_izContext, savePath, settings) {
33
34
  try {
35
+ console.log("settingsInGenerateCodeWithTemplate", settings)
36
+ let serviceTag = getLocalConfig("iz_serviceTag")
34
37
  // console.log({ savePath })
35
38
  // console.log("settings generateCodeWithTemplate", settings)
36
39
  let allCreateSource = [];
@@ -42,10 +45,12 @@ async function generateCodeWithTemplate(_izContext, savePath) {
42
45
  // console.log("event", JSON.stringify(event, null, 2))
43
46
  const test = await generateTest(_izContext, allIntTestConfig, savePath)
44
47
  // console.log("test", JSON.stringify(test, null, 2));
48
+ const intTestBucketPath = await generatePathIntTest(_izContext, savePath, { serviceTag, s3Prefix: settings.s3Prefix })
45
49
 
46
50
  allCreateSource.push(
47
51
  ...event,
48
- ...test
52
+ ...test,
53
+ intTestBucketPath
49
54
  )
50
55
 
51
56
  // console.log("allCreateSource", allCreateSource)
@@ -0,0 +1,46 @@
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
+ import path, { join } from 'path';
21
+ import { fileURLToPath } from 'url';
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = path.dirname(__filename);
24
+ const templatePath = path.join(__dirname, "./template.ejs")
25
+ import uploadIntTest from '../../upload/uploadIntTest.js';
26
+ const { bucketPathForUpload } = uploadIntTest;
27
+
28
+ async function data(_izContext, srcPath, settings) {
29
+ console.log("settingsInData", settings)
30
+ let pathIntTestInBuckets = await bucketPathForUpload(join(srcPath, `../../src/generateIntegrationTest/${settings.serviceTag}`), settings)
31
+ console.log({ pathIntTestInBuckets })
32
+
33
+ return {
34
+ templateData: { pathIntTestInBuckets },
35
+ templatePath: templatePath,
36
+ setting: {
37
+ generateHookFile: false,
38
+ savePath: path.join(srcPath, `./libs/`),
39
+ saveFileName: 'IntTestPath',
40
+ fileExtension: ".js",
41
+ isAppend: false
42
+ }
43
+ }
44
+ }
45
+
46
+ export default data
@@ -0,0 +1,5 @@
1
+ let intTestPath = [
2
+ <% pathIntTestInBuckets.forEach((item, index) => { %>
3
+ "<%- item.key %>"<%= index < pathIntTestInBuckets.length - 1 ? "," : "" -%>
4
+ <% }) %>
5
+ ]
@@ -104,6 +104,9 @@ async function data(_izContext, allIntTestConfig, srcPath) {
104
104
  // baseIntTest.stage[currentStageIdx].initialStage = true;
105
105
  stages[currentStageIdx].initialStage = true;
106
106
  if (handler === HANDLER.hdrSqs) {
107
+ if (functionName.startsWith("Process")) {
108
+ functionName = functionName.split("Process")[1]
109
+ }
107
110
  // Object.assign(baseIntTest.stage[currentStageIdx], {
108
111
  Object.assign(stages[currentStageIdx], {
109
112
  resourceName,
@@ -25,12 +25,13 @@ import Logger from "@izara_project/izara-core-library-logger";
25
25
 
26
26
  const _izContext = { Logger }
27
27
 
28
- async function uploadFolder(folderPath, settings) {
29
-
28
+ async function bucketPathForUpload(folderPath, settings) {
29
+ console.log({ folderPath, settings })
30
+ let dataToUploads = [];
30
31
  try {
31
32
 
32
33
  const files = getAllFiles(folderPath);
33
- console.log({ files })
34
+ // console.log({ files })
34
35
  for (const filePath of files) {
35
36
  const fileContent = fs.readFileSync(filePath);
36
37
  const index = filePath.indexOf(settings.serviceTag);
@@ -43,19 +44,14 @@ async function uploadFolder(folderPath, settings) {
43
44
  }
44
45
 
45
46
  let s3Key = path.join('test_config', settings.s3Prefix, relativePath).split(path.sep).join('/');
46
- const params = {
47
- Bucket: 'integrationtest-config-us-east-2',
48
- Key: s3Key,
49
- Body: fileContent,
50
- ContentType: 'application/json'
51
- };
52
-
53
- await s3.putObjectS3(_izContext, params)
54
47
 
48
+ dataToUploads.push({ key: s3Key, fileContent })
55
49
  }
56
50
 
51
+ return dataToUploads
52
+
57
53
  } catch (err) {
58
- console.error("Upload Failed:", err);
54
+ console.error("prepare data to upload fail", err);
59
55
  }
60
56
  }
61
57
 
@@ -77,4 +73,20 @@ function getAllFiles(dirPath, filePaths) {
77
73
  return filePaths;
78
74
  }
79
75
 
80
- export default uploadFolder;
76
+ async function uploadTos3(folderPath, settings) {
77
+ let uploadLists = [];
78
+ let datas = await bucketPathForUpload(folderPath, settings)
79
+ // console.log({ keys })
80
+ await Promise.all(datas.map(async (data) => {
81
+ uploadLists.push(s3.putObjectS3(_izContext, {
82
+ Bucket: 'integrationtest-config-us-east-2',
83
+ Key: data.key,
84
+ Body: data.fileContent,
85
+ ContentType: 'application/json'
86
+ }));
87
+ }))
88
+
89
+ await Promise.all(uploadLists);
90
+ }
91
+
92
+ export default { uploadTos3, bucketPathForUpload };
@@ -17,12 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
20
+ import { middlewareHandler } from "@izara_project/izara-middleware";
21
21
  import Logger from '@izara_project/izara-core-library-logger';
22
22
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
23
23
  import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
24
24
 
25
- import <%- functionName %> from './<%- functionName %>_Main.js';
25
+ import <%- functionName %> from './<%- firstLetterUpperCase(functionName) %>_Main.js';
26
26
 
27
27
  // validate event properties in body.Message of sqs event
28
28
  middlewareHandler.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
@@ -38,7 +38,7 @@ import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-tri
38
38
  * @returns {object} description of return value
39
39
  */
40
40
 
41
- export default async function <%- functionName %> (
41
+ export default async function <% - functionName %> (
42
42
  _izContext,
43
43
  identifiers,
44
44
  topicArn,
@@ -67,12 +67,10 @@ export default async function <%- functionName %> (
67
67
  flowTag: flowTag
68
68
  },
69
69
  ...identifiers,
70
- //(<triggerCacheAdditionalParam>)
71
- "", // overwriteUniqueRequestId,
72
- {}, // flowParams
73
- true, // createIfNotExists
74
- {}, // triggerFlowIdentifiers
75
- //(</triggerCacheAdditionalParam>)
70
+ {
71
+ flowTag: <%- flowTag %>,
72
+ serviceTag: process.env.iz_serviceTag
73
+ }
76
74
  )
77
75
 
78
76
  _izContext.logger.debug("checkTriggerCache: ", checkTriggerCache)
@@ -57,9 +57,10 @@ async function data(_izContext, flowSchema, srcPath) {
57
57
  async function createSourceParams(_izContext, flowSchema, srcPath) {
58
58
  let functionName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag)
59
59
  // let functionName = createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })
60
- let handlerType = upperCase(HANDLER.hdrSqs)
60
+ let handlerType = upperCase(HANDLER.hdrDsq)
61
61
  let additionalResourcePermission = defaultIamRolePerAction();
62
62
  // let queueName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag) + handlerType;
63
+
63
64
  let queueName = `${createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })}_Main`
64
65
 
65
66
 
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
  import path from 'path';
20
+ import path from 'path';
20
21
  import { fileURLToPath } from 'url';
21
22
  const __filename = fileURLToPath(import.meta.url);
22
23
  const __dirname = path.dirname(__filename);
@@ -47,7 +48,7 @@ function data(_izContext, flowSchema, srcPath) {
47
48
  function createSourceParams(_izContext, flowSchema, srcPath) {
48
49
  let functionName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag)
49
50
  // let functionName = createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })
50
- let handlerType = upperCase(HANDLER.hdrSqs)
51
+ let handlerType = upperCase(HANDLER.hdrDsq)
51
52
  let queueName = `${createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })}_Main`
52
53
 
53
54
 
@@ -27,7 +27,7 @@ import <%- functionName %> from './<%- functionName %>_Main.js';
27
27
  // validate event properties in body.Message of sqs event
28
28
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
29
29
  let perRecordsValidatorSchema = {}
30
- module.exports.main = middleware.wrap(async (event, context, callback) => {
30
+ export const main = middleware.wrap(async (event, context, callback) => {
31
31
 
32
32
  try {
33
33
 
@@ -20,12 +20,11 @@ along with this program. If not, see
20
20
 
21
21
  import { NoRetryError } from '@izara_project/izara-core-library-core';
22
22
  import { consts } from "@izara_project/izara-middleware"
23
- import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas/src/GetObjectSchema';
24
- import { utils } from "@izara_project/izara-core-library-service-schemas"
23
+ import { getObjectSchema, utils } from '@izara_project/izara-core-library-service-schemas';
25
24
  const { createFlowTypeConcat } = utils;
26
25
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
27
26
 
28
- import { postToConnection } from "../../../libs/source/GenerateCodeLibs";
27
+ import { postToConnection } from "../../../libs/source/GenerateCodeLibs.js";
29
28
 
30
29
  //(<optionalRequire>)
31
30
  //(</optionalRequire>)
@@ -26,25 +26,29 @@ import asyncFlowSharedLib from "@izara_project/izara-core-library-asynchronous-f
26
26
 
27
27
  import { sns } from "@izara_project/izara-core-library-external-request";
28
28
 
29
- import { getObjectSchema, utils, serviceConfig, consts, relSchemaLib as findLinksByObjTypes } from '@izara_project/izara-core-library-service-schemas'
29
+ import {
30
+ getObjectSchema,
31
+ utils,
32
+ serviceConfig,
33
+ consts,
34
+ relSchemaLib
35
+ } from '@izara_project/izara-core-library-service-schemas';
30
36
 
31
- const {
32
- getRelationshipSchemaWithCache,
33
- getObjSchemaS3WithHierarchy
34
- } = getObjectSchema
37
+ const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } = getObjectSchema;
35
38
 
36
- const {
37
- createLinkTypeId
38
- } = utils;
39
+ const { createLinkTypeId } = utils;
39
40
 
40
- const {
41
- getGraphServiceTagWithCache
42
- } = serviceConfig;
41
+ const { getGraphServiceTagWithCache } = serviceConfig;
42
+
43
+ const { findLinksByObjTypes } = relSchemaLib;
43
44
 
44
45
  import { constsGenerateCodeLibs } from '@izara_project/izara-market-library-service-schemas';
45
- const { PREFIX,
46
+ const {
47
+ PREFIX,
46
48
  TOPIC_NAME_GENERATE_CODE,
47
- TOPIC_NAME_GRAPH_HANDLER } = constsGenerateCodeLibs;
49
+ TOPIC_NAME_GRAPH_HANDLER
50
+ } = constsGenerateCodeLibs;
51
+
48
52
  import { const as coreConsts } from '@izara_project/izara-core-library-core';
49
53
 
50
54
  //(<optionalRequire>)
@@ -130,7 +130,7 @@ export default async function createRelationship(
130
130
  const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
131
131
  _izContext.logger.debug("relationshipSchema: ", relationshipSchema);
132
132
 
133
- const links = await findLinksByObjTypes.findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
133
+ const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
134
134
  _izContext.logger.debug("links", links)
135
135
  if (!links.length) {
136
136
  errorsFound.push(`not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`)