@izara_project/izara-core-generate-service-code 1.0.33 → 1.0.35
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 +1 -1
- package/src/generateCode/generateFlowSchema/GenerateCodeFlowSchema.js +1 -1
- package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +1 -1
- package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +11 -5
- package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +3 -3
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/mainFunction/template.ejs +0 -2
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/data.js +61 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/templateApi.ejs +84 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/handler/templateWebSocket.ejs +64 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/mainFunction/data.js +52 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/mainFunction/template.ejs +76 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/data.js +86 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/recievePlugIn/yaml/template.ejs +18 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/handler/data.js +0 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/handler/template.ejs +0 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/mainFunction/data.js +45 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/mainFunction/template.ejs +82 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/yaml/data.js +0 -0
- package/src/generateCode/generateFlowStepWithPlugIn/afterFirstFlowStep/sendPlugIn/yaml/template.ejs +0 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/data.js +53 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateApi.ejs +84 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateDsq.ejs +105 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateInv.ejs +53 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/handler/templateSqs.ejs +87 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/data.js +45 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/template.ejs +82 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/data.js +50 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/template.ejs +0 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/topicOut/data.js +45 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/yaml/data.js +47 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/yaml/template.ejs +28 -0
- package/src/generateCode/generateFlowStepWithPlugIn/index.js +259 -0
- package/src/generateCode/generateSchema/generateTextTag/systemText/data.js +68 -47
- package/src/generateCode/generateSchema/generateTextTag/systemText/template.ejs +6 -1
- package/src/generateCode/resourceYamlComponent/sns-out/template.ejs +4 -0
- package/src/generateCode.js +41 -32
- package/src/libs/Libs.js +106 -8
package/src/libs/Libs.js
CHANGED
|
@@ -15,11 +15,13 @@ You should have received a copy of the GNU Affero General Public License
|
|
|
15
15
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { serviceConfig } from '@izara_project/izara-core-library-service-schemas';
|
|
18
|
+
import { serviceConfig, getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
19
19
|
import consts from './Consts.js';
|
|
20
20
|
const {
|
|
21
21
|
STORAGE_TYPES,
|
|
22
22
|
RESOURCE_CLASSES,
|
|
23
|
+
SQS_RESOURCE,
|
|
24
|
+
SNS_RESOURCE,
|
|
23
25
|
DYNAMO_RESOURCE,
|
|
24
26
|
S3_RESOURCE,
|
|
25
27
|
FIELD_NAME_TYPE
|
|
@@ -58,8 +60,8 @@ function resourceNames(resourceClass, resourceName) {
|
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
*
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
+
* @param {object} action - key:resourceClass value:actionValue
|
|
64
|
+
* @param {array} resource
|
|
63
65
|
* @param {string} effect - optional default Allow
|
|
64
66
|
* @returns {{ effect, action, resource}}
|
|
65
67
|
*/
|
|
@@ -449,11 +451,13 @@ function tableRoleForFlowSchema(objectSchema) {
|
|
|
449
451
|
return resourcePermission;
|
|
450
452
|
}
|
|
451
453
|
|
|
452
|
-
|
|
453
|
-
`${item.setting.savePath.replace(/\/+$/, '')}/${item.setting.saveFileName}${item.setting.fileExtension || ''}`;
|
|
454
|
+
function toFilePath(item) {
|
|
455
|
+
return `${item.setting.savePath.replace(/\/+$/, '')}/${item.setting.saveFileName}${item.setting.fileExtension || ''}`;
|
|
454
456
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function toUniqueFilePaths(items) {
|
|
460
|
+
return Array.from(
|
|
457
461
|
new Set(
|
|
458
462
|
items
|
|
459
463
|
.flat(5)
|
|
@@ -461,6 +465,96 @@ const toUniqueFilePaths = items =>
|
|
|
461
465
|
.map(toFilePath)
|
|
462
466
|
)
|
|
463
467
|
).sort();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function createSqsResource(queueNames) {
|
|
471
|
+
if (!Array.isArray(queueNames)) {
|
|
472
|
+
queueNames = [queueNames];
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
return createIamRole(
|
|
476
|
+
{
|
|
477
|
+
[RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
|
|
478
|
+
},
|
|
479
|
+
queueNames.map(queueName =>
|
|
480
|
+
resourceNames(RESOURCE_CLASSES.sqs, queueName))
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function createSnsResource(topicNames) {
|
|
485
|
+
if (!Array.isArray(topicNames)) {
|
|
486
|
+
topicNames = [topicNames];
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
return createIamRole(
|
|
490
|
+
{
|
|
491
|
+
[RESOURCE_CLASSES.sns]: Object.values(SNS_RESOURCE)
|
|
492
|
+
},
|
|
493
|
+
topicNames.map(topicName =>
|
|
494
|
+
resourceNames(RESOURCE_CLASSES.sns, topicName))
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
async function getLocalOrS3ObjectSchema(_izContext, objType, schemasPath) {
|
|
498
|
+
console.log("objType, schemasPath", objType, schemasPath)
|
|
499
|
+
const iz_serviceTag = getLocalConfig('iz_serviceTag');
|
|
500
|
+
const iz_serviceSchemaBucketName = getLocalConfig('iz_serviceSchemaBucketName');
|
|
501
|
+
let objSchema;
|
|
502
|
+
let errorMessage;
|
|
503
|
+
if (objType.serviceTag === iz_serviceTag) {
|
|
504
|
+
objSchema = await getObjectSchema
|
|
505
|
+
.getLocalObjectSchemasWithHierarchy(
|
|
506
|
+
_izContext,
|
|
507
|
+
objType.objectType,
|
|
508
|
+
schemasPath
|
|
509
|
+
)
|
|
510
|
+
.then(res => {
|
|
511
|
+
return res.records[0];
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
if (!objSchema) {
|
|
515
|
+
errorMessage = 'local not exists';
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
objSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
519
|
+
_izContext,
|
|
520
|
+
objType,
|
|
521
|
+
iz_serviceSchemaBucketName
|
|
522
|
+
);
|
|
523
|
+
errorMessage = 's3 not exists';
|
|
524
|
+
}
|
|
525
|
+
return [objSchema, errorMessage];
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
async function getLocalOrS3FlowSchema(_izContext, flowType, schemasPath) {
|
|
529
|
+
const iz_serviceTag = getLocalConfig('iz_serviceTag');
|
|
530
|
+
const iz_serviceSchemaBucketName = getLocalConfig('iz_serviceSchemaBucketName');
|
|
531
|
+
|
|
532
|
+
let flowSchema;
|
|
533
|
+
let errorMessage;
|
|
534
|
+
if (flowType.serviceTag === iz_serviceTag) {
|
|
535
|
+
flowSchema = await getObjectSchema
|
|
536
|
+
.getLocalFlowSchemas(
|
|
537
|
+
_izContext,
|
|
538
|
+
flowType.flowTag,
|
|
539
|
+
schemasPath
|
|
540
|
+
)
|
|
541
|
+
.then(res => {
|
|
542
|
+
return res.records[0];
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
if (!flowSchema) {
|
|
546
|
+
errorMessage = 'local not exists';
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
flowSchema = await getObjectSchema.getFlowSchemaS3(
|
|
550
|
+
_izContext,
|
|
551
|
+
flowType,
|
|
552
|
+
iz_serviceSchemaBucketName
|
|
553
|
+
);
|
|
554
|
+
errorMessage = 's3 not exists';
|
|
555
|
+
}
|
|
556
|
+
return [flowSchema, errorMessage];
|
|
557
|
+
}
|
|
464
558
|
|
|
465
559
|
export default {
|
|
466
560
|
resourceNames,
|
|
@@ -478,5 +572,9 @@ export default {
|
|
|
478
572
|
getStorageResourceFromObjectSchemas,
|
|
479
573
|
getExternalTopicComponentFromAllObjectSchemas,
|
|
480
574
|
tableRoleForFlowSchema,
|
|
481
|
-
toUniqueFilePaths
|
|
575
|
+
toUniqueFilePaths,
|
|
576
|
+
getLocalOrS3ObjectSchema,
|
|
577
|
+
getLocalOrS3FlowSchema,
|
|
578
|
+
createSqsResource,
|
|
579
|
+
createSnsResource
|
|
482
580
|
};
|