@izara_project/izara-core-generate-service-code 1.0.55 → 1.0.57
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 +19 -3
- package/src/codeGenerators/app/src/generatedCode/Flow/{FlowRelationshipEndpoints → FlowRelationships}/templates/relationship/ProcessCreateRelationship_Main.ejs +1 -1
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +4 -4
- 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/Flow/_shared/shared/flowValidator.js +1 -1
- 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 +3 -6
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +29 -10
- package/src/codeGenerators/resource/sls_yaml/templates/SystemDynamoDB_Yaml.ejs +64 -0
- package/src/generate.js +1 -1
- package/src/generateCode.js +14 -11
- 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/RelationshipFlowSchemaGenerator.js +2 -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/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
|
@@ -166,12 +166,12 @@ const FUNCTION_NAME = {
|
|
|
166
166
|
outTranslateIds: 'processTranslateIdsComplete',
|
|
167
167
|
findData: 'findData',
|
|
168
168
|
processLogical: 'processLogical',
|
|
169
|
-
updateNodeComplete: '
|
|
170
|
-
createObjectComplete: '
|
|
171
|
-
getNodeComplete: '
|
|
169
|
+
updateNodeComplete: 'updateComplete',
|
|
170
|
+
createObjectComplete: 'createComplete',
|
|
171
|
+
getNodeComplete: 'getComplete',
|
|
172
172
|
paginateProcessLogical: 'paginateProcessLogical',
|
|
173
173
|
deleteNode: 'deleteNode',
|
|
174
|
-
deleteNodeComplete: '
|
|
174
|
+
deleteNodeComplete: 'deleteComplete',
|
|
175
175
|
createObjectS3: 'createObjectS3',
|
|
176
176
|
createObjectS3Complete: 'webSocketTaskComplete',
|
|
177
177
|
processAfterUploadS3: 'processAfterUploadS3',
|
|
@@ -203,12 +203,12 @@ const SHORT_FUNCTION_NAME = functionName => {
|
|
|
203
203
|
[FUNCTION_NAME.deleteRelComplete]: 'deleteRelComp',
|
|
204
204
|
[FUNCTION_NAME.findData]: 'findData',
|
|
205
205
|
[FUNCTION_NAME.processLogical]: 'processLogical',
|
|
206
|
-
[FUNCTION_NAME.updateNodeComplete]: '
|
|
207
|
-
[FUNCTION_NAME.createObjectComplete]: '
|
|
208
|
-
[FUNCTION_NAME.getNodeComplete]: '
|
|
206
|
+
[FUNCTION_NAME.updateNodeComplete]: 'updateComp',
|
|
207
|
+
[FUNCTION_NAME.createObjectComplete]: 'createComp',
|
|
208
|
+
[FUNCTION_NAME.getNodeComplete]: 'getComp',
|
|
209
209
|
[FUNCTION_NAME.paginateProcessLogical]: 'paginateProLogical',
|
|
210
210
|
[FUNCTION_NAME.deleteNode]: 'deleteNode',
|
|
211
|
-
[FUNCTION_NAME.deleteNodeComplete]: '
|
|
211
|
+
[FUNCTION_NAME.deleteNodeComplete]: 'deleteComp',
|
|
212
212
|
[FUNCTION_NAME.createObjectS3Complete]: 'webSocketTaskComp',
|
|
213
213
|
[FUNCTION_NAME.getRel]: 'getRel',
|
|
214
214
|
[FUNCTION_NAME.getRelComplete]: 'getRelComp',
|
|
@@ -238,7 +238,7 @@ const SOURCE_GENERATE_IAM_ROLE = {
|
|
|
238
238
|
ProcessFindDataRole: 'ProcFindData',
|
|
239
239
|
ObjectCompleteRole: 'ObjectCom',
|
|
240
240
|
NodeCompleteRole: 'NodeCom',
|
|
241
|
-
|
|
241
|
+
FlowRelationshipRole: 'Relationship',
|
|
242
242
|
RelationshipCompleteRole: 'RelationshipCom',
|
|
243
243
|
FlowSchemaUploadS3Role: 'FlowSchemaUploadS3',
|
|
244
244
|
FlowSchemaOwnTopic: 'FlowSchemaOwnTopic',
|
|
@@ -320,27 +320,27 @@ const TOPIC_NAME_GENERATE_CODE = {
|
|
|
320
320
|
createRelComplete: 'CreateRelationshipComplete',
|
|
321
321
|
deleteRelComplete: 'DeleteRelationshipComplete',
|
|
322
322
|
getRelComplete: 'GetRelationshipComplete',
|
|
323
|
-
outUpdateRelComplete: '
|
|
324
|
-
outCreateRelComplete: '
|
|
325
|
-
outDeleteRelComplete: '
|
|
326
|
-
outGetRelComplete: '
|
|
327
|
-
updateNodeComplete: '
|
|
328
|
-
outUpdateNodeComplete: '
|
|
329
|
-
createNodeComplete: '
|
|
330
|
-
outCreateNodeComplete: '
|
|
331
|
-
deleteNodeComplete: '
|
|
332
|
-
outDeleteNodeComplete: '
|
|
333
|
-
getNodeComplete: '
|
|
334
|
-
outGetNodeComplete: '
|
|
323
|
+
outUpdateRelComplete: 'UpdateRelationship_Out',
|
|
324
|
+
outCreateRelComplete: 'CreateRelationship_Out',
|
|
325
|
+
outDeleteRelComplete: 'DeleteRelationship_Out',
|
|
326
|
+
outGetRelComplete: 'GetRelationship_Out',
|
|
327
|
+
updateNodeComplete: 'UpdateComplete',
|
|
328
|
+
outUpdateNodeComplete: 'Update_Out',
|
|
329
|
+
createNodeComplete: 'CreateComplete',
|
|
330
|
+
outCreateNodeComplete: 'Create_Out',
|
|
331
|
+
deleteNodeComplete: 'DeleteComplete',
|
|
332
|
+
outDeleteNodeComplete: 'Delete_Out',
|
|
333
|
+
getNodeComplete: 'GetComplete',
|
|
334
|
+
outGetNodeComplete: 'Get_Out',
|
|
335
335
|
reservedLimitComplete: 'ReservedLimitComplete',
|
|
336
336
|
createPreSignUrl: 'CreatePreSignUrl',
|
|
337
337
|
flowSchemaOwnTopicComplete: 'FlowSchemaOwnTopicComplete',
|
|
338
338
|
flowSchemaOwnTopicEndpointComplete: 'FlowSchemaOwnTopicEndpointComplete',
|
|
339
339
|
createRecordComplete: 'CreateRecordComplete',
|
|
340
340
|
changeRelationshipComplete: 'ChangeRelationshipComplete',
|
|
341
|
-
outChangeRelationshipComplete: '
|
|
341
|
+
outChangeRelationshipComplete: 'ChangeRelationship_Out',
|
|
342
342
|
moveRelationshipComplete: 'MoveRelationshipComplete',
|
|
343
|
-
outMoveRelationshipComplete: '
|
|
343
|
+
outMoveRelationshipComplete: 'MoveRelationship_Out'
|
|
344
344
|
};
|
|
345
345
|
|
|
346
346
|
const GRAPH_HANDLER_SERVICE_NAME = {
|
|
@@ -80,7 +80,7 @@ export async function generateDynamoDBTables(allSchemas, options) {
|
|
|
80
80
|
const systemYamlTpl = await fs.readFile(systemYamlTplPath, 'utf-8');
|
|
81
81
|
const systemYamlContent = ejs.render(systemYamlTpl, {});
|
|
82
82
|
await fs.writeFile(yamlOutputPath, `${systemYamlContent}\n`, 'utf-8');
|
|
83
|
-
generatedCount +=
|
|
83
|
+
generatedCount += 12; // 12 system tables
|
|
84
84
|
|
|
85
85
|
for (const [tableName, keys] of tables.entries()) {
|
|
86
86
|
const yamlContent = ejs.render(yamlTpl, {
|
|
@@ -28,7 +28,7 @@ export async function generateFlowOut(allSchemas, options) {
|
|
|
28
28
|
|
|
29
29
|
let generatedCount = 0;
|
|
30
30
|
const yamlOutputPath = path.join(resourceYamlDir, 'generated-sns-out.yml');
|
|
31
|
-
await fs.writeFile(yamlOutputPath, '', 'utf-8');
|
|
31
|
+
await fs.writeFile(yamlOutputPath, 'Resources:\n', 'utf-8'); // ponytail: simplest one-line fix
|
|
32
32
|
|
|
33
33
|
const generatedTopics = new Set();
|
|
34
34
|
|
|
@@ -48,11 +48,8 @@ export async function generateFlowOut(allSchemas, options) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const systemTopics = [
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
'UpdateNodeComplete',
|
|
54
|
-
'ProcessLogicalComplete',
|
|
55
|
-
'FindDataComplete',
|
|
51
|
+
'ProcessLogical',
|
|
52
|
+
'FindData',
|
|
56
53
|
'Create',
|
|
57
54
|
'Update',
|
|
58
55
|
'Delete',
|
|
@@ -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,12 +126,15 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
const systemOwnTopicFlows = [
|
|
129
|
+
'ProcessLogical',
|
|
130
|
+
'FindData',
|
|
120
131
|
'Create',
|
|
121
132
|
'Update',
|
|
122
133
|
'Delete',
|
|
123
134
|
'CreateRelationship',
|
|
124
135
|
'UpdateRelationship',
|
|
125
136
|
'DeleteRelationship',
|
|
137
|
+
'GetRelationship',
|
|
126
138
|
'ChangeRelationship',
|
|
127
139
|
'MoveRelationship',
|
|
128
140
|
'CreateTargetRole',
|
|
@@ -151,16 +163,23 @@ export async function generateFlowResourceYaml(allSchemas, options) {
|
|
|
151
163
|
await appendUnique(queueName, resourceSqsYamlTpl, { queueName });
|
|
152
164
|
}
|
|
153
165
|
|
|
166
|
+
// ponytail: add Dsq queue for PaginateProcessLogical
|
|
167
|
+
await appendUnique('PaginateProcessLogicalHdrDsq', resourceSqsYamlTpl, { queueName: 'PaginateProcessLogicalHdrDsq' });
|
|
168
|
+
|
|
154
169
|
const systemQueues = [
|
|
155
|
-
'ProcessLogical',
|
|
156
|
-
'PaginateProcessLogical',
|
|
157
|
-
'FindData',
|
|
158
170
|
'Register',
|
|
159
171
|
'WebSocket',
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
'
|
|
163
|
-
'
|
|
172
|
+
'PaginateProcessLogical',
|
|
173
|
+
'CreateComplete',
|
|
174
|
+
'UpdateComplete',
|
|
175
|
+
'DeleteComplete',
|
|
176
|
+
'GetComplete',
|
|
177
|
+
'CreateRelationshipComplete',
|
|
178
|
+
'UpdateRelationshipComplete',
|
|
179
|
+
'DeleteRelationshipComplete',
|
|
180
|
+
'GetRelationshipComplete',
|
|
181
|
+
'ChangeRelationshipComplete',
|
|
182
|
+
'MoveRelationshipComplete'
|
|
164
183
|
];
|
|
165
184
|
|
|
166
185
|
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';
|
|
@@ -130,9 +130,11 @@ export async function generateCode(rootPath, options = {}) {
|
|
|
130
130
|
);
|
|
131
131
|
collectHookBackups(outputPath);
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
// ponytail: ensure hooks are restored even if generation fails
|
|
134
|
+
try {
|
|
135
|
+
console.log(
|
|
136
|
+
'[INFO] [generateCode] STATUS=CLEANUP | Removing old generatedCode directories...'
|
|
137
|
+
);
|
|
136
138
|
await fs.promises.rm(generatedCodePath, {
|
|
137
139
|
recursive: true,
|
|
138
140
|
force: true
|
|
@@ -141,10 +143,10 @@ export async function generateCode(rootPath, options = {}) {
|
|
|
141
143
|
path.join(outputPath, 'app', 'sls_yaml', 'generatedCode'),
|
|
142
144
|
{ recursive: true, force: true }
|
|
143
145
|
);
|
|
144
|
-
await fs.promises.rm(
|
|
145
|
-
|
|
146
|
-
force: true
|
|
147
|
-
|
|
146
|
+
await fs.promises.rm(
|
|
147
|
+
path.join(outputPath, 'resource', 'sls_yaml', 'generatedCode'),
|
|
148
|
+
{ recursive: true, force: true }
|
|
149
|
+
);
|
|
148
150
|
|
|
149
151
|
policyRegistry.clear();
|
|
150
152
|
|
|
@@ -258,8 +260,9 @@ export async function generateCode(rootPath, options = {}) {
|
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
} finally {
|
|
264
|
+
// Restore backed-up hooks
|
|
265
|
+
if (hookDirs.size > 0 || hookBackups.length > 0) {
|
|
263
266
|
console.log(
|
|
264
267
|
`[INFO] [generateCode] STATUS=RESTORE | Restoring ${hookBackups.length} hook files...`
|
|
265
268
|
);
|
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(
|
|
@@ -65,8 +65,8 @@ export async function generateRelationshipFlowSchemas(
|
|
|
65
65
|
let outputTopic = true;
|
|
66
66
|
let hasCompleteStep = true;
|
|
67
67
|
|
|
68
|
-
if (action === '
|
|
69
|
-
events = "['lambdaSyncInv', 'lambdaSyncApi']";
|
|
68
|
+
if (action === 'GetRelationship') {
|
|
69
|
+
events = "['lambdaSyncInv', 'lambdaSyncApi', 'dsq', 'ownTopic']";
|
|
70
70
|
outputTopic = false;
|
|
71
71
|
hasCompleteStep = false;
|
|
72
72
|
}
|
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
|