@izara_project/izara-core-generate-service-code 1.0.61 → 1.0.62
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 +5 -6
- package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +100 -150
- package/src/codeGenerators/app/initial_setup/templates/InitialSetup_LambdaRole.ejs +27 -20
- package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +8 -17
- package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +13 -72
- package/src/codeGenerators/app/sls_yaml/_policy/PolicyEmitter.js +3 -2
- package/src/codeGenerators/app/sls_yaml/_policy/__tests__/PolicyEmitter.test.js +3 -3
- package/src/codeGenerators/app/sls_yaml/_policy/templates/ManagedPolicy_Yaml.ejs +2 -2
- package/src/codeGenerators/app/sls_yaml/templates/SharedResource_Yaml.ejs +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint/FlowEndpoint_HdrWbs.ejs +2 -2
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint/FlowEndpoint_Main.ejs +8 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint/FlowMain_Wbs.ejs +4 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3/CreatePreSignUrl_Main.ejs +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3/ProcessS3File_Main.ejs +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/FlowEndpointComplete_Main.ejs +11 -12
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseDsqHandler.js +4 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseSqsHandler.js +14 -15
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncApi.js +4 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncInv.js +4 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/ownTopic.js +16 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/handlers/FlowHandler_HdrDsq.ejs +71 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/handlers/FlowHandler_HdrSqs.ejs +54 -50
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js +7 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js +21 -29
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowNaming.js +16 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js +9 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepNormalizer.js +21 -20
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js +1 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/propertyNormalizer.js +20 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/roleNameDetection.js +49 -0
- package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +1 -10
- package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +1 -10
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +2 -11
- package/src/core/validate.js +9 -5
- package/src/generate.js +1 -1
- package/src/generateCode.js +21 -0
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/FlowSchemaGenerator.js +0 -43
- package/test_generate.js +0 -7
- package/test_normalize.js +0 -17
package/src/generateCode.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import yaml from 'yaml';
|
|
3
4
|
|
|
4
5
|
import { parseObjectSchemas } from './parsers/objectSchemaParser.js';
|
|
5
6
|
import { parseRelationshipSchemas } from './parsers/relationshipSchemaParser.js';
|
|
@@ -54,6 +55,26 @@ export async function generateCode(rootPath, options = {}) {
|
|
|
54
55
|
const generatorOptions = createGeneratorOptions(rootPath, options);
|
|
55
56
|
const { outputPath } = generatorOptions;
|
|
56
57
|
|
|
58
|
+
let serviceName;
|
|
59
|
+
try {
|
|
60
|
+
const configPath = options.configPath || path.join(rootPath, 'config', 'serverless.config.yml');
|
|
61
|
+
if (!fs.existsSync(configPath)) {
|
|
62
|
+
throw new Error(`serverless.config.yml not found at path: ${configPath}`);
|
|
63
|
+
}
|
|
64
|
+
const configStr = fs.readFileSync(configPath, 'utf8');
|
|
65
|
+
const config = yaml.parse(configStr);
|
|
66
|
+
serviceName = config?.main_config?.iz_serviceName || config?.main_config?.iz_serviceTag;
|
|
67
|
+
|
|
68
|
+
if (!serviceName) {
|
|
69
|
+
throw new Error('main_config.iz_serviceName or main_config.iz_serviceTag is missing in serverless.config.yml');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log(`[INFO] [generateCode] Loaded config - serviceName: '${serviceName}' from ${configPath}`);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
throw new Error(`[Developer Error] Failed to read service name from config: ${e.message}`);
|
|
75
|
+
}
|
|
76
|
+
generatorOptions.serviceName = serviceName;
|
|
77
|
+
|
|
57
78
|
// Clean workspace
|
|
58
79
|
const generatedCodePath = path.join(
|
|
59
80
|
outputPath,
|
|
@@ -41,50 +41,7 @@ export async function generateDynamicFlowSchemas(
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const validMainEvents = [
|
|
45
|
-
'ownTopic',
|
|
46
|
-
'extTopic',
|
|
47
|
-
'dsq',
|
|
48
|
-
's3',
|
|
49
|
-
'eventBridge',
|
|
50
|
-
'lambdaSyncInv',
|
|
51
|
-
'lambdaSyncApi'
|
|
52
|
-
];
|
|
53
|
-
const validStepEvents = [
|
|
54
|
-
'sqs',
|
|
55
|
-
'extTopic',
|
|
56
|
-
'dsq',
|
|
57
|
-
'lambdaSyncInv',
|
|
58
|
-
'lambdaSyncApi',
|
|
59
|
-
'queue'
|
|
60
|
-
];
|
|
61
44
|
|
|
62
|
-
if (flowData && flowData.flows) {
|
|
63
|
-
for (const flow of flowData.flows) {
|
|
64
|
-
const flowName = flow.flowTag || 'UnknownFlow';
|
|
65
|
-
// Check main flow events
|
|
66
|
-
if (flow.event && Array.isArray(flow.event)) {
|
|
67
|
-
for (const ev of flow.event) {
|
|
68
|
-
if (!validMainEvents.includes(ev)) {
|
|
69
|
-
throw new Error(`[FlowSchemaGenerator] Invalid event type '${ev}' in main flow '${flowName}'. Allowed: ${validMainEvents.join(', ')}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
// Check flow steps events
|
|
74
|
-
if (flow.flowSteps && Array.isArray(flow.flowSteps)) {
|
|
75
|
-
for (const step of flow.flowSteps) {
|
|
76
|
-
const stepName = step.stepName || 'UnknownStep';
|
|
77
|
-
if (step.event && Array.isArray(step.event)) {
|
|
78
|
-
for (const ev of step.event) {
|
|
79
|
-
if (!validStepEvents.includes(ev)) {
|
|
80
|
-
throw new Error(`[FlowSchemaGenerator] Invalid event type '${ev}' in flow '${flowName}' step '${stepName}'. Allowed: ${validStepEvents.join(', ')}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
45
|
|
|
89
46
|
// Ensure directory exists
|
|
90
47
|
await fs.mkdir(schemasOutputDir, { recursive: true });
|
package/test_generate.js
DELETED
package/test_normalize.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { normalizeUnifiedFlows, normalizeFlowSteps } from './src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepNormalizer.js';
|
|
2
|
-
|
|
3
|
-
const rawFlows = [
|
|
4
|
-
{
|
|
5
|
-
event: 'api',
|
|
6
|
-
flowSteps: {
|
|
7
|
-
MyStep: { properties: [] }
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const result = normalizeUnifiedFlows(rawFlows);
|
|
14
|
-
console.log(JSON.stringify(result, null, 2));
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.error(e.message);
|
|
17
|
-
}
|