@izara_project/izara-core-generate-service-code 1.0.55 → 1.0.56
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/codeGenerators/app/initial_setup/InitialSetupGenerator.js +223 -123
- package/src/codeGenerators/app/initial_setup/templates/InitialSetup_LambdaRole.ejs +6 -6
- package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +1 -1
- package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +299 -197
- package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +84 -60
- package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +304 -271
- package/src/codeGenerators/app/sls_yaml/__tests__/SharedResourceYamlGenerator.test.js +91 -32
- package/src/codeGenerators/app/sls_yaml/templates/SharedResource_Yaml.ejs +2 -2
- package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/EndpointsGenerator.js +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/FlowRbac_Main.ejs +252 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/RelationshipFlowGenerator.js +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowClassifier.js +3 -2
- package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js +12 -5
- package/src/codeGenerators/app/src/generatedCode/libs/templates/Consts.ejs +23 -23
- package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +1 -1
- package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +4 -6
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +26 -10
- package/src/codeGenerators/resource/sls_yaml/templates/SystemDynamoDB_Yaml.ejs +64 -0
- package/src/generate.js +1 -1
- package/src/generateCode.js +7 -7
- package/src/generateSchema.js +1 -1
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/FlowSchemaGenerator.js +0 -1
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/RbacFlowSchemaGenerator.js +16 -2
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +12 -12
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicRbacFlowSchemaTemplate.ejs +1 -0
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/UserRbacFlowSchemaTemplate.ejs +22 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/.gitkeep +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/templates/FlowEndpointBeforeLogical_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/templates/crud/CreateEndpoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/templates/crud/DeleteEndpoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/templates/crud/GetEndpoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/templates/crud/UpdateEndpoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessChangeRelationshipComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessChangeRelationship_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessCreateRelationshipComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessCreateRelationship_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessDeleteRelationshipComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessDeleteRelationship_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessGetRelationshipComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessGetRelationship_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessMoveRelationshipComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessMoveRelationship_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessUpdateRelationshipComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessUpdateRelationship_Main.ejs +0 -0
|
@@ -33,7 +33,7 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
33
33
|
|
|
34
34
|
let generatedCount = 0;
|
|
35
35
|
const yamlOutputPath = path.join(resourceYamlDir, 'generated-sns-in-sqs.yml');
|
|
36
|
-
await fs.writeFile(yamlOutputPath, '', 'utf-8');
|
|
36
|
+
await fs.writeFile(yamlOutputPath, 'Resources:\n', 'utf-8'); // ponytail: build minimum that works, one-line initialization fix
|
|
37
37
|
|
|
38
38
|
const generatedResources = new Set();
|
|
39
39
|
|
|
@@ -88,12 +88,21 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
88
88
|
queueName = `${flowTag}Complete`;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
if (ev === '
|
|
91
|
+
if (ev === 'ownTopic') {
|
|
92
92
|
await appendUnique(queueName, resourceYamlTpl, { queueName });
|
|
93
|
-
} else if (ev === '
|
|
93
|
+
} else if (ev === 'sqs') {
|
|
94
|
+
// ponytail: purely SQS events don't need SNS topics, use resourceSqsYamlTpl
|
|
95
|
+
await appendUnique(`${queueName}HdrSqs`, resourceSqsYamlTpl, {
|
|
96
|
+
queueName: `${queueName}HdrSqs`
|
|
97
|
+
});
|
|
98
|
+
} else if (ev === 'dsq') {
|
|
94
99
|
await appendUnique(`${queueName}HdrDsq`, resourceSqsYamlTpl, {
|
|
95
100
|
queueName: `${queueName}HdrDsq`
|
|
96
101
|
});
|
|
102
|
+
} else if (ev === 'extTopic') {
|
|
103
|
+
await appendUnique(`${queueName}HdrSqs`, resourceSqsYamlTpl, {
|
|
104
|
+
queueName: `${queueName}HdrSqs`
|
|
105
|
+
});
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
108
|
}
|
|
@@ -117,6 +126,9 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
const systemOwnTopicFlows = [
|
|
129
|
+
'ProcessLogical',
|
|
130
|
+
'PaginateProcessLogical',
|
|
131
|
+
'FindData',
|
|
120
132
|
'Create',
|
|
121
133
|
'Update',
|
|
122
134
|
'Delete',
|
|
@@ -152,15 +164,19 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
152
164
|
}
|
|
153
165
|
|
|
154
166
|
const systemQueues = [
|
|
155
|
-
'ProcessLogical',
|
|
156
|
-
'PaginateProcessLogical',
|
|
157
|
-
'FindData',
|
|
158
167
|
'Register',
|
|
159
168
|
'WebSocket',
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
'
|
|
163
|
-
'
|
|
169
|
+
'CreateComplete',
|
|
170
|
+
'UpdateComplete',
|
|
171
|
+
'DeleteComplete',
|
|
172
|
+
'GetComplete',
|
|
173
|
+
'GetRelationship',
|
|
174
|
+
'CreateRelationshipComplete',
|
|
175
|
+
'UpdateRelationshipComplete',
|
|
176
|
+
'DeleteRelationshipComplete',
|
|
177
|
+
'GetRelationshipComplete',
|
|
178
|
+
'ChangeRelationshipComplete',
|
|
179
|
+
'MoveRelationshipComplete'
|
|
164
180
|
];
|
|
165
181
|
|
|
166
182
|
for (const sysQueue of systemQueues) {
|
|
@@ -136,3 +136,67 @@ Resources:
|
|
|
136
136
|
KeyType: HASH
|
|
137
137
|
- AttributeName: pendingStepId
|
|
138
138
|
KeyType: RANGE
|
|
139
|
+
|
|
140
|
+
TargetRolesTable:
|
|
141
|
+
Type: "AWS::DynamoDB::Table"
|
|
142
|
+
Properties:
|
|
143
|
+
TableName: ${self:custom.iz_resourcePrefix}TargetRoles
|
|
144
|
+
BillingMode: PAY_PER_REQUEST
|
|
145
|
+
AttributeDefinitions:
|
|
146
|
+
- AttributeName: targetId
|
|
147
|
+
AttributeType: S
|
|
148
|
+
- AttributeName: roleIdKey
|
|
149
|
+
AttributeType: S
|
|
150
|
+
KeySchema:
|
|
151
|
+
- AttributeName: targetId
|
|
152
|
+
KeyType: HASH
|
|
153
|
+
- AttributeName: roleIdKey
|
|
154
|
+
KeyType: RANGE
|
|
155
|
+
|
|
156
|
+
RolePermissionsTable:
|
|
157
|
+
Type: "AWS::DynamoDB::Table"
|
|
158
|
+
Properties:
|
|
159
|
+
TableName: ${self:custom.iz_resourcePrefix}RolePermissions
|
|
160
|
+
BillingMode: PAY_PER_REQUEST
|
|
161
|
+
AttributeDefinitions:
|
|
162
|
+
- AttributeName: roleIdKey
|
|
163
|
+
AttributeType: S
|
|
164
|
+
- AttributeName: flowTypeConcat
|
|
165
|
+
AttributeType: S
|
|
166
|
+
KeySchema:
|
|
167
|
+
- AttributeName: roleIdKey
|
|
168
|
+
KeyType: HASH
|
|
169
|
+
- AttributeName: flowTypeConcat
|
|
170
|
+
KeyType: RANGE
|
|
171
|
+
|
|
172
|
+
RoleUsersTable:
|
|
173
|
+
Type: "AWS::DynamoDB::Table"
|
|
174
|
+
Properties:
|
|
175
|
+
TableName: ${self:custom.iz_resourcePrefix}RoleUsers
|
|
176
|
+
BillingMode: PAY_PER_REQUEST
|
|
177
|
+
AttributeDefinitions:
|
|
178
|
+
- AttributeName: roleIdKey
|
|
179
|
+
AttributeType: S
|
|
180
|
+
- AttributeName: userId
|
|
181
|
+
AttributeType: S
|
|
182
|
+
KeySchema:
|
|
183
|
+
- AttributeName: roleIdKey
|
|
184
|
+
KeyType: HASH
|
|
185
|
+
- AttributeName: userId
|
|
186
|
+
KeyType: RANGE
|
|
187
|
+
|
|
188
|
+
UserRolesTable:
|
|
189
|
+
Type: "AWS::DynamoDB::Table"
|
|
190
|
+
Properties:
|
|
191
|
+
TableName: ${self:custom.iz_resourcePrefix}UserRoles
|
|
192
|
+
BillingMode: PAY_PER_REQUEST
|
|
193
|
+
AttributeDefinitions:
|
|
194
|
+
- AttributeName: userId
|
|
195
|
+
AttributeType: S
|
|
196
|
+
- AttributeName: roleIdKey
|
|
197
|
+
AttributeType: S
|
|
198
|
+
KeySchema:
|
|
199
|
+
- AttributeName: userId
|
|
200
|
+
KeyType: HASH
|
|
201
|
+
- AttributeName: roleIdKey
|
|
202
|
+
KeyType: RANGE
|
package/src/generate.js
CHANGED
|
@@ -52,7 +52,7 @@ async function generate(rootPath, options = {}) {
|
|
|
52
52
|
|
|
53
53
|
// Auto-generate dynamic schemas before validation (unless skipped)
|
|
54
54
|
if (!skipGenerateSchema) {
|
|
55
|
-
await generateSchema(rootPath, { outputPath });
|
|
55
|
+
await generateSchema(rootPath, { outputPath, configPath });
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// Validate schemas before generating (unless skipped)
|
package/src/generateCode.js
CHANGED
|
@@ -9,11 +9,11 @@ import { generateFlowEntryPoint } from './codeGenerators/app/src/generatedCode/F
|
|
|
9
9
|
import { generateFlowMainFunction } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js';
|
|
10
10
|
import { generateFlowSteps } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js';
|
|
11
11
|
|
|
12
|
-
import { generateEndpointsFlow } from './codeGenerators/app/src/generatedCode/Flow/
|
|
12
|
+
import { generateEndpointsFlow } from './codeGenerators/app/src/generatedCode/Flow/FlowObjects/EndpointsGenerator.js';
|
|
13
13
|
import { generateFlowOut } from './codeGenerators/resource/sls_yaml/FlowOutGenerator.js';
|
|
14
14
|
import { generateFlowResourceYaml } from './codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js';
|
|
15
15
|
import { generateRbacFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js';
|
|
16
|
-
import { generateRelationshipFlows } from './codeGenerators/app/src/generatedCode/Flow/
|
|
16
|
+
import { generateRelationshipFlows } from './codeGenerators/app/src/generatedCode/Flow/FlowRelationships/RelationshipFlowGenerator.js';
|
|
17
17
|
import { generateWebSocket } from './codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js';
|
|
18
18
|
import { validateFlowsForGeneration } from './codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js';
|
|
19
19
|
import { generateRegisterFlow } from './codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js';
|
|
@@ -131,7 +131,7 @@ export async function generateCode(rootPath, options = {}) {
|
|
|
131
131
|
collectHookBackups(outputPath);
|
|
132
132
|
|
|
133
133
|
console.log(
|
|
134
|
-
'[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode
|
|
134
|
+
'[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode directories...'
|
|
135
135
|
);
|
|
136
136
|
await fs.promises.rm(generatedCodePath, {
|
|
137
137
|
recursive: true,
|
|
@@ -141,10 +141,10 @@ export async function generateCode(rootPath, options = {}) {
|
|
|
141
141
|
path.join(outputPath, 'app', 'sls_yaml', 'generatedCode'),
|
|
142
142
|
{ recursive: true, force: true }
|
|
143
143
|
);
|
|
144
|
-
await fs.promises.rm(
|
|
145
|
-
|
|
146
|
-
force: true
|
|
147
|
-
|
|
144
|
+
await fs.promises.rm(
|
|
145
|
+
path.join(outputPath, 'resource', 'sls_yaml', 'generatedCode'),
|
|
146
|
+
{ recursive: true, force: true }
|
|
147
|
+
);
|
|
148
148
|
|
|
149
149
|
policyRegistry.clear();
|
|
150
150
|
|
package/src/generateSchema.js
CHANGED
|
@@ -21,7 +21,7 @@ export async function generateSchema(rootPath, options) {
|
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
// Parse service config to get serviceTag
|
|
24
|
-
const configPath = path.join(rootPath, 'config', 'serverless.config.yml');
|
|
24
|
+
const configPath = options?.configPath || path.join(rootPath, 'config', 'serverless.config.yml');
|
|
25
25
|
let serviceTag = 'unknownService';
|
|
26
26
|
try {
|
|
27
27
|
const serviceConfigStr = fs.readFileSync(configPath, 'utf8');
|
|
@@ -61,8 +61,8 @@ export async function generateRbacFlowSchemas(hydratedObjectData, options) {
|
|
|
61
61
|
|
|
62
62
|
for (const def of rbacFlowDefinitions) {
|
|
63
63
|
const flowTag = def.flowTag;
|
|
64
|
-
// Use
|
|
65
|
-
const filePath = path.join(schemasOutputDir, `${
|
|
64
|
+
// Use flowTag as filename directly
|
|
65
|
+
const filePath = path.join(schemasOutputDir, `${flowTag}.js`);
|
|
66
66
|
|
|
67
67
|
const eventsArrayStr = JSON.stringify(def.eventNames).replace(/"/g, "'");
|
|
68
68
|
|
|
@@ -76,6 +76,20 @@ export async function generateRbacFlowSchemas(hydratedObjectData, options) {
|
|
|
76
76
|
await fs.writeFile(filePath, fileContent, 'utf-8');
|
|
77
77
|
generatedCount++;
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
// Generate specific UserRbacFlow
|
|
81
|
+
const userRbacFlowTag = `${objectType.charAt(0).toUpperCase() + objectType.slice(1)}RbacFlow`;
|
|
82
|
+
const userRbacFilePath = path.join(schemasOutputDir, `${userRbacFlowTag}.js`);
|
|
83
|
+
const userRbacTemplatePath = path.join(__dirname, 'templates', 'UserRbacFlowSchemaTemplate.ejs');
|
|
84
|
+
const userRbacTemplateString = await fs.readFile(userRbacTemplatePath, 'utf-8');
|
|
85
|
+
const userRbacContent = ejs.render(userRbacTemplateString, {
|
|
86
|
+
flowTag: userRbacFlowTag,
|
|
87
|
+
serviceTag: options.serviceTag,
|
|
88
|
+
objectType: objectType
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await fs.writeFile(userRbacFilePath, userRbacContent, 'utf-8');
|
|
92
|
+
generatedCount++;
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
console.log(
|
package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs
CHANGED
|
@@ -22,20 +22,20 @@ export default {
|
|
|
22
22
|
messageAttributes: ['userId', 'correlationId']
|
|
23
23
|
},
|
|
24
24
|
<% if (hasBeforeLogicalStep) { %>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
{
|
|
26
|
+
stepName: 'BeforeLogical',
|
|
27
|
+
event: ['sqs'],
|
|
28
|
+
properties: [],
|
|
29
|
+
messageAttributes: ['userId', 'correlationId']
|
|
30
|
+
},
|
|
31
31
|
<% } %>
|
|
32
32
|
<% if (['Create', 'Update', 'Delete'].includes(action)) { %>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
{
|
|
34
|
+
stepName: 'Complete',
|
|
35
|
+
event: ['sqs'],
|
|
36
|
+
properties: [],
|
|
37
|
+
messageAttributes: ['userId', 'correlationId']
|
|
38
|
+
}
|
|
39
39
|
<% } %>
|
|
40
40
|
]
|
|
41
41
|
};
|
package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/UserRbacFlowSchemaTemplate.ejs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
flowTag: '<%= flowTag %>',
|
|
3
|
+
fileName: 'flow-rbac',
|
|
4
|
+
objType: {
|
|
5
|
+
serviceTag: '<%= serviceTag %>',
|
|
6
|
+
objectType: '<%= objectType %>'
|
|
7
|
+
},
|
|
8
|
+
event: ['lambdaSyncInv'],
|
|
9
|
+
initiateBy: 'system',
|
|
10
|
+
handleObj: 'one',
|
|
11
|
+
statusType: 'none',
|
|
12
|
+
stepMessageAttributes: {
|
|
13
|
+
userId: { propertyName: 'x-correlation-base-user-id', type: 'string' },
|
|
14
|
+
correlationId: { propertyName: 'x-correlation-id', type: 'string' }
|
|
15
|
+
},
|
|
16
|
+
steps: [
|
|
17
|
+
{
|
|
18
|
+
stepName: 'InTag',
|
|
19
|
+
messageAttributes: ['userId', 'correlationId']
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
/package/src/codeGenerators/app/src/generatedCode/Flow/{FlowEndpoints → FlowObjects}/.gitkeep
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|