@izara_project/izara-core-generate-service-code 1.0.66 → 1.0.68
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/.prettierrc +11 -0
- package/docs/TriggeredCache Flow.drawio +193 -0
- package/docs/TriggeredCacheFlow.mmd +47 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +108 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +9 -5
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +300 -109
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +221 -143
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +150 -38
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +57 -31
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +407 -252
- package/src/emit/custom/customFlows.js +112 -31
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +89 -77
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +49 -37
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +46 -12
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +179 -66
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +6 -5
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +260 -144
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +499 -108
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
- package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
- package/src/generate.js +8 -4
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +1 -1
- package/test/customFlowApplicationArtifacts.test.js +71 -43
- package/test/dynamicCrudFlowSchemas.test.js +6 -6
- package/test/dynamicRbacFlowSchemas.test.js +8 -12
- package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
- package/test/publicApi.test.js +11 -13
- package/test/resourceArtifacts.test.js +13 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
|
@@ -1,202 +1,202 @@
|
|
|
1
1
|
Resources:
|
|
2
2
|
WebSocketTaskTable:
|
|
3
|
-
Type:
|
|
3
|
+
Type: 'AWS::DynamoDB::Table'
|
|
4
4
|
Properties:
|
|
5
5
|
TableName: ${self:custom.iz_resourcePrefix}WebSocketTask
|
|
6
6
|
BillingMode: PAY_PER_REQUEST
|
|
7
7
|
AttributeDefinitions:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
- AttributeName: taskKey
|
|
9
|
+
AttributeType: S
|
|
10
|
+
- AttributeName: connectionId
|
|
11
|
+
AttributeType: S
|
|
12
12
|
KeySchema:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
- AttributeName: taskKey
|
|
14
|
+
KeyType: HASH
|
|
15
|
+
- AttributeName: connectionId
|
|
16
|
+
KeyType: RANGE
|
|
17
17
|
TimeToLiveSpecification:
|
|
18
18
|
AttributeName: expirationTime
|
|
19
19
|
Enabled: true
|
|
20
20
|
|
|
21
21
|
UserUploadRecordsTable:
|
|
22
|
-
Type:
|
|
22
|
+
Type: 'AWS::DynamoDB::Table'
|
|
23
23
|
Properties:
|
|
24
24
|
TableName: ${self:custom.iz_resourcePrefix}UserUploadRecords
|
|
25
25
|
BillingMode: PAY_PER_REQUEST
|
|
26
26
|
AttributeDefinitions:
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
- AttributeName: connectionId
|
|
28
|
+
AttributeType: S
|
|
29
29
|
KeySchema:
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
- AttributeName: connectionId
|
|
31
|
+
KeyType: HASH
|
|
32
32
|
TimeToLiveSpecification:
|
|
33
33
|
AttributeName: expirationTime
|
|
34
34
|
Enabled: true
|
|
35
35
|
|
|
36
36
|
RegisterRecordsTable:
|
|
37
|
-
Type:
|
|
37
|
+
Type: 'AWS::DynamoDB::Table'
|
|
38
38
|
Properties:
|
|
39
39
|
TableName: ${self:custom.iz_resourcePrefix}RegisterRecords
|
|
40
40
|
BillingMode: PAY_PER_REQUEST
|
|
41
41
|
AttributeDefinitions:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
- AttributeName: identifiersTask
|
|
43
|
+
AttributeType: S
|
|
44
|
+
- AttributeName: connectionId
|
|
45
|
+
AttributeType: S
|
|
46
46
|
KeySchema:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
- AttributeName: identifiersTask
|
|
48
|
+
KeyType: HASH
|
|
49
|
+
- AttributeName: connectionId
|
|
50
|
+
KeyType: RANGE
|
|
51
51
|
|
|
52
52
|
AwaitingMultipleStepsTable:
|
|
53
|
-
Type:
|
|
53
|
+
Type: 'AWS::DynamoDB::Table'
|
|
54
54
|
Properties:
|
|
55
55
|
TableName: ${self:custom.iz_resourcePrefix}AwaitingMultipleSteps
|
|
56
56
|
BillingMode: PAY_PER_REQUEST
|
|
57
57
|
AttributeDefinitions:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
- AttributeName: awaitingStepId
|
|
59
|
+
AttributeType: S
|
|
60
|
+
- AttributeName: pendingStepId
|
|
61
|
+
AttributeType: S
|
|
62
62
|
KeySchema:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
- AttributeName: awaitingStepId
|
|
64
|
+
KeyType: HASH
|
|
65
|
+
- AttributeName: pendingStepId
|
|
66
|
+
KeyType: RANGE
|
|
67
67
|
|
|
68
68
|
AwaitingMultipleStepByPendingTable:
|
|
69
|
-
Type:
|
|
69
|
+
Type: 'AWS::DynamoDB::Table'
|
|
70
70
|
Properties:
|
|
71
71
|
TableName: ${self:custom.iz_resourcePrefix}AwaitingMultipleStepByPending
|
|
72
72
|
BillingMode: PAY_PER_REQUEST
|
|
73
73
|
AttributeDefinitions:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
- AttributeName: pendingStepId
|
|
75
|
+
AttributeType: S
|
|
76
|
+
- AttributeName: awaitingStepId
|
|
77
|
+
AttributeType: S
|
|
78
78
|
KeySchema:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
- AttributeName: pendingStepId
|
|
80
|
+
KeyType: HASH
|
|
81
|
+
- AttributeName: awaitingStepId
|
|
82
|
+
KeyType: RANGE
|
|
83
83
|
|
|
84
84
|
FindDataMainTable:
|
|
85
|
-
Type:
|
|
85
|
+
Type: 'AWS::DynamoDB::Table'
|
|
86
86
|
Properties:
|
|
87
87
|
TableName: ${self:custom.iz_resourcePrefix}FindDataMain
|
|
88
88
|
BillingMode: PAY_PER_REQUEST
|
|
89
89
|
AttributeDefinitions:
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
- AttributeName: findDataId
|
|
91
|
+
AttributeType: S
|
|
92
92
|
KeySchema:
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
- AttributeName: findDataId
|
|
94
|
+
KeyType: HASH
|
|
95
95
|
|
|
96
96
|
LogicalResultsMainTable:
|
|
97
|
-
Type:
|
|
97
|
+
Type: 'AWS::DynamoDB::Table'
|
|
98
98
|
Properties:
|
|
99
99
|
TableName: ${self:custom.iz_resourcePrefix}LogicalResultsMain
|
|
100
100
|
BillingMode: PAY_PER_REQUEST
|
|
101
101
|
AttributeDefinitions:
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
- AttributeName: logicalResultId
|
|
103
|
+
AttributeType: S
|
|
104
104
|
KeySchema:
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
- AttributeName: logicalResultId
|
|
106
|
+
KeyType: HASH
|
|
107
107
|
|
|
108
108
|
LogicalResultsDataTable:
|
|
109
|
-
Type:
|
|
109
|
+
Type: 'AWS::DynamoDB::Table'
|
|
110
110
|
Properties:
|
|
111
111
|
TableName: ${self:custom.iz_resourcePrefix}LogicalResultsData
|
|
112
112
|
BillingMode: PAY_PER_REQUEST
|
|
113
113
|
AttributeDefinitions:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
- AttributeName: logicalResultId
|
|
115
|
+
AttributeType: S
|
|
116
|
+
- AttributeName: identifiersId
|
|
117
|
+
AttributeType: S
|
|
118
118
|
KeySchema:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
- AttributeName: logicalResultId
|
|
120
|
+
KeyType: HASH
|
|
121
|
+
- AttributeName: identifiersId
|
|
122
|
+
KeyType: RANGE
|
|
123
123
|
|
|
124
124
|
AwaitingStepTable:
|
|
125
|
-
Type:
|
|
125
|
+
Type: 'AWS::DynamoDB::Table'
|
|
126
126
|
Properties:
|
|
127
127
|
TableName: ${self:custom.iz_resourcePrefix}AwaitingStep
|
|
128
128
|
BillingMode: PAY_PER_REQUEST
|
|
129
129
|
AttributeDefinitions:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
- AttributeName: awaitingStepId
|
|
131
|
+
AttributeType: S
|
|
132
|
+
- AttributeName: pendingStepId
|
|
133
|
+
AttributeType: S
|
|
134
134
|
KeySchema:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
- AttributeName: awaitingStepId
|
|
136
|
+
KeyType: HASH
|
|
137
|
+
- AttributeName: pendingStepId
|
|
138
|
+
KeyType: RANGE
|
|
139
139
|
|
|
140
140
|
TargetRolesTable:
|
|
141
|
-
Type:
|
|
141
|
+
Type: 'AWS::DynamoDB::Table'
|
|
142
142
|
Properties:
|
|
143
143
|
TableName: ${self:custom.iz_resourcePrefix}TargetRoles
|
|
144
144
|
BillingMode: PAY_PER_REQUEST
|
|
145
145
|
AttributeDefinitions:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
- AttributeName: targetId
|
|
147
|
+
AttributeType: S
|
|
148
|
+
- AttributeName: roleIdKey
|
|
149
|
+
AttributeType: S
|
|
150
150
|
KeySchema:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
- AttributeName: targetId
|
|
152
|
+
KeyType: HASH
|
|
153
|
+
- AttributeName: roleIdKey
|
|
154
|
+
KeyType: RANGE
|
|
155
155
|
|
|
156
156
|
RolePermissionsTable:
|
|
157
|
-
Type:
|
|
157
|
+
Type: 'AWS::DynamoDB::Table'
|
|
158
158
|
Properties:
|
|
159
159
|
TableName: ${self:custom.iz_resourcePrefix}RolePermissions
|
|
160
160
|
BillingMode: PAY_PER_REQUEST
|
|
161
161
|
AttributeDefinitions:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
- AttributeName: roleIdKey
|
|
163
|
+
AttributeType: S
|
|
164
|
+
- AttributeName: flowTypeConcat
|
|
165
|
+
AttributeType: S
|
|
166
166
|
KeySchema:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
- AttributeName: roleIdKey
|
|
168
|
+
KeyType: HASH
|
|
169
|
+
- AttributeName: flowTypeConcat
|
|
170
|
+
KeyType: RANGE
|
|
171
171
|
|
|
172
172
|
RoleUsersTable:
|
|
173
|
-
Type:
|
|
173
|
+
Type: 'AWS::DynamoDB::Table'
|
|
174
174
|
Properties:
|
|
175
175
|
TableName: ${self:custom.iz_resourcePrefix}RoleUsers
|
|
176
176
|
BillingMode: PAY_PER_REQUEST
|
|
177
177
|
AttributeDefinitions:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
- AttributeName: roleIdKey
|
|
179
|
+
AttributeType: S
|
|
180
|
+
- AttributeName: userId
|
|
181
|
+
AttributeType: S
|
|
182
182
|
KeySchema:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
- AttributeName: roleIdKey
|
|
184
|
+
KeyType: HASH
|
|
185
|
+
- AttributeName: userId
|
|
186
|
+
KeyType: RANGE
|
|
187
187
|
|
|
188
188
|
UserRolesTable:
|
|
189
|
-
Type:
|
|
189
|
+
Type: 'AWS::DynamoDB::Table'
|
|
190
190
|
Properties:
|
|
191
191
|
TableName: ${self:custom.iz_resourcePrefix}UserRoles
|
|
192
192
|
BillingMode: PAY_PER_REQUEST
|
|
193
193
|
AttributeDefinitions:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
- AttributeName: userId
|
|
195
|
+
AttributeType: S
|
|
196
|
+
- AttributeName: roleIdKey
|
|
197
|
+
AttributeType: S
|
|
198
198
|
KeySchema:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
- AttributeName: userId
|
|
200
|
+
KeyType: HASH
|
|
201
|
+
- AttributeName: roleIdKey
|
|
202
|
+
KeyType: RANGE
|
|
@@ -25,7 +25,8 @@ export function systemWebSocketManagedPaths() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function hasSystemWebSocket(flows, { includeRelationshipOwnTopic = false } = {}) {
|
|
28
|
-
return
|
|
28
|
+
// return true;
|
|
29
|
+
return Array.isArray(flows) && flows.some(flow => Array.isArray(flow?.event) && (flow.event.includes('s3') || (includeRelationshipOwnTopic && flow.event.includes('ownTopic') && flow.initiateBy === 'user')));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
function renderWebSocketConnectYaml() {
|
package/src/generate.js
CHANGED
|
@@ -9,7 +9,7 @@ import { emitRbacApplicationArtifacts, rbacApplicationManagedPaths } from './emi
|
|
|
9
9
|
import { dynamicRelationshipFlowSchemaPaths, emitDynamicRelationshipFlowSchemas } from './emit/relationship/emitDynamicRelationshipFlowSchemas.js';
|
|
10
10
|
import { emitRelationshipApplicationArtifacts, relationshipApplicationManagedPaths } from './emit/relationship/emitRelationshipApplicationArtifacts.js';
|
|
11
11
|
import { emitResourceArtifacts, resourceArtifactPaths } from './emit/resource/emitResourceArtifacts.js';
|
|
12
|
-
import { loadLocalSchemaDirectory } from './compile/loadSchemas.js';
|
|
12
|
+
import { loadLocalSchemaDirectory, resolveExtendedObjectSchemas } from './compile/loadSchemas.js';
|
|
13
13
|
import { emitSystemWebSocketArtifacts, hasSystemWebSocket, systemWebSocketManagedPaths } from './emit/system/emitSystemWebSocketArtifacts.js';
|
|
14
14
|
|
|
15
15
|
export async function generate(rootPath, options = {}) {
|
|
@@ -18,11 +18,15 @@ export async function generate(rootPath, options = {}) {
|
|
|
18
18
|
logger?.info?.(`[INFO] [Generate] STATUS=STARTED | rootPath=${rootPath}`);
|
|
19
19
|
try {
|
|
20
20
|
const project = compileProject({ ...options, rootPath });
|
|
21
|
-
const [
|
|
21
|
+
const [rawObjects, relationships, flows] = await Promise.all([
|
|
22
22
|
loadLocalSchemaDirectory(project, 'ObjectSchemas'),
|
|
23
23
|
loadLocalSchemaDirectory(project, 'RelationshipSchemas'),
|
|
24
24
|
loadLocalSchemaDirectory(project, 'FlowSchemas')
|
|
25
25
|
]);
|
|
26
|
+
const objects = await resolveExtendedObjectSchemas(
|
|
27
|
+
rawObjects,
|
|
28
|
+
options.schemaBucketName
|
|
29
|
+
);
|
|
26
30
|
logger?.debug?.(`[DEBUG] [Generate] STATUS=SCHEMAS_LOADED | objects=${objects.length} relationships=${relationships.length} flows=${flows.length}`);
|
|
27
31
|
const groups = await emitGroups({ project, objects, relationships, flows });
|
|
28
32
|
logger?.debug?.(`[DEBUG] [Generate] STATUS=ARTIFACTS_EMITTED | ${groups.map(group => `${group.scope}=${group.artifacts.length}`).join(' ')}`);
|
|
@@ -46,7 +50,7 @@ async function emitGroups({ project, objects, relationships, flows }) {
|
|
|
46
50
|
emitCrudApplicationArtifacts({ objects, flows, serviceTag: project.serviceTag }),
|
|
47
51
|
emitRelationshipApplicationArtifacts({ relationships, flows, serviceTag: project.serviceTag }),
|
|
48
52
|
emitRbacApplicationArtifacts(objects),
|
|
49
|
-
emitSystemWebSocketArtifacts(flows, { includeRelationshipOwnTopic:
|
|
53
|
+
emitSystemWebSocketArtifacts(flows, { includeRelationshipOwnTopic: true }),
|
|
50
54
|
emitResourceArtifacts({ objects, relationships, flows })
|
|
51
55
|
]);
|
|
52
56
|
const custom = await emitCustomFlowApplicationArtifacts(flows, { systemFunctions: system.functions, objects });
|
|
@@ -58,7 +62,7 @@ async function emitGroups({ project, objects, relationships, flows }) {
|
|
|
58
62
|
{ scope: 'relationship-application', managedPaths: relationshipApplicationManagedPaths(), artifacts: relationship },
|
|
59
63
|
{ scope: 'rbac-application', managedPaths: rbacApplicationManagedPaths(objects), artifacts: rbac },
|
|
60
64
|
{ scope: 'system-websocket', managedPaths: systemWebSocketManagedPaths(), artifacts: system.artifacts },
|
|
61
|
-
{ scope: 'custom-flow-application', managedPaths: customFlowApplicationManagedPaths(flows, { includeYaml: hasSystemWebSocket(flows, { includeRelationshipOwnTopic:
|
|
65
|
+
{ scope: 'custom-flow-application', managedPaths: customFlowApplicationManagedPaths(flows, { includeYaml: hasSystemWebSocket(flows, { includeRelationshipOwnTopic: true }) }), artifacts: custom },
|
|
62
66
|
{ scope: 'shared-resources', managedPaths: resourceArtifactPaths, artifacts: resource }
|
|
63
67
|
];
|
|
64
68
|
}
|
|
@@ -15,27 +15,55 @@ const OWN_TOPIC_FLOWS = [
|
|
|
15
15
|
'CreateUserRole',
|
|
16
16
|
'DeleteUserFromRole'
|
|
17
17
|
];
|
|
18
|
-
after(() =>
|
|
18
|
+
after(() =>
|
|
19
|
+
Promise.all(
|
|
20
|
+
[...roots].map(root => rm(root, { recursive: true, force: true }))
|
|
21
|
+
)
|
|
22
|
+
);
|
|
19
23
|
|
|
20
24
|
test('generates RBAC own-topic WebSocket entries alongside their SQS handlers', async () => {
|
|
21
25
|
const rootPath = await createProject(true);
|
|
22
26
|
const result = await generateCreateTargetRoleHandler(rootPath);
|
|
23
27
|
|
|
24
28
|
assert.equal(result.files.length, 36);
|
|
25
|
-
assert.match(await readFile(join(rootPath, result.files[0].path), 'utf8'), /ProcessCreateTargetRole/);
|
|
26
|
-
assert.match(await readFile(join(rootPath, result.files[1].path), 'utf8'), /ProcessCreateTargetRoleHdrSqs/);
|
|
27
29
|
assert.match(
|
|
28
|
-
await readFile(join(rootPath,
|
|
30
|
+
await readFile(join(rootPath, result.files[0].path), 'utf8'),
|
|
31
|
+
/CreateTargetRole/
|
|
32
|
+
);
|
|
33
|
+
assert.match(
|
|
34
|
+
await readFile(join(rootPath, result.files[1].path), 'utf8'),
|
|
35
|
+
/CreateTargetRoleHdrSqs/
|
|
36
|
+
);
|
|
37
|
+
assert.match(
|
|
38
|
+
await readFile(
|
|
39
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-rbac.yml'),
|
|
40
|
+
'utf8'
|
|
41
|
+
),
|
|
29
42
|
/FlowRbacRole/
|
|
30
43
|
);
|
|
31
44
|
assert.match(
|
|
32
|
-
await readFile(
|
|
33
|
-
|
|
45
|
+
await readFile(
|
|
46
|
+
join(
|
|
47
|
+
rootPath,
|
|
48
|
+
'app/src/generatedCode/FlowRbac/ListTargetRole/source/ListTargetRole_HdrApi.js'
|
|
49
|
+
),
|
|
50
|
+
'utf8'
|
|
51
|
+
),
|
|
52
|
+
/ListTargetRole/
|
|
53
|
+
);
|
|
54
|
+
const yaml = await readFile(
|
|
55
|
+
join(rootPath, 'app/sls_yaml/generatedCode/source/flow-rbac.yml'),
|
|
56
|
+
'utf8'
|
|
34
57
|
);
|
|
35
|
-
const yaml = await readFile(join(rootPath, 'app/sls_yaml/generatedCode/source/flow-rbac.yml'), 'utf8');
|
|
36
58
|
for (const flowTag of OWN_TOPIC_FLOWS) {
|
|
37
59
|
assert.match(
|
|
38
|
-
await readFile(
|
|
60
|
+
await readFile(
|
|
61
|
+
join(
|
|
62
|
+
rootPath,
|
|
63
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
64
|
+
),
|
|
65
|
+
'utf8'
|
|
66
|
+
),
|
|
39
67
|
new RegExp(`import ${flowTag}`)
|
|
40
68
|
);
|
|
41
69
|
assert.match(yaml, new RegExp(`${flowTag}HdrWbs:\\n[\\s\\S]*websocket:`));
|
|
@@ -46,23 +74,44 @@ test('removes CreateTargetRole handler when RBAC is removed', async () => {
|
|
|
46
74
|
const rootPath = await createProject(true);
|
|
47
75
|
const objectPath = join(rootPath, 'app/src/schemas/ObjectSchemas/User.js');
|
|
48
76
|
await generateCreateTargetRoleHandler(rootPath);
|
|
49
|
-
await writeFile(
|
|
77
|
+
await writeFile(
|
|
78
|
+
objectPath,
|
|
79
|
+
"export default { objectType: 'user', addOnDataStructure: [] };\n"
|
|
80
|
+
);
|
|
50
81
|
|
|
51
82
|
assert.deepEqual((await generateCreateTargetRoleHandler(rootPath)).files, []);
|
|
52
|
-
await assert.rejects(
|
|
53
|
-
|
|
54
|
-
|
|
83
|
+
await assert.rejects(
|
|
84
|
+
readFile(
|
|
85
|
+
join(
|
|
86
|
+
rootPath,
|
|
87
|
+
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_Main.js'
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
await assert.rejects(
|
|
92
|
+
readFile(
|
|
93
|
+
join(
|
|
94
|
+
rootPath,
|
|
95
|
+
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_HdrWbs.js'
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
await assert.rejects(
|
|
100
|
+
readFile(join(rootPath, 'app/sls_yaml/generatedCode/source/flow-rbac.yml'))
|
|
101
|
+
);
|
|
55
102
|
});
|
|
56
103
|
|
|
57
104
|
async function createProject(hasRbac) {
|
|
58
|
-
const rootPath = await mkdtemp(
|
|
105
|
+
const rootPath = await mkdtemp(
|
|
106
|
+
join(tmpdir(), 'generate-service-code-v2-rbac-handler-')
|
|
107
|
+
);
|
|
59
108
|
roots.add(rootPath);
|
|
60
109
|
const directory = join(rootPath, 'app/src/schemas/ObjectSchemas');
|
|
61
110
|
const addOns = hasRbac ? "[{ type: 'rbac' }]" : '[]';
|
|
62
111
|
await mkdir(directory, { recursive: true });
|
|
63
112
|
await writeFile(
|
|
64
113
|
join(directory, 'User.js'),
|
|
65
|
-
`export default { objectType: 'user', addOnDataStructure: ${addOns} };\n`
|
|
114
|
+
`export default { objectType: 'user', fieldNames: [], identifiers: [], addOnDataStructure: ${addOns} };\n`
|
|
66
115
|
);
|
|
67
116
|
return rootPath;
|
|
68
117
|
}
|
|
@@ -14,7 +14,7 @@ test('emits CRUD handlers and function YAML from schema data without reading gen
|
|
|
14
14
|
const rootPath = await createProject(true);
|
|
15
15
|
const result = await generateCrudApplicationArtifacts(rootPath, { serviceTag: 'orders' });
|
|
16
16
|
|
|
17
|
-
assert.equal(result.files.length,
|
|
17
|
+
assert.equal(result.files.length, 26);
|
|
18
18
|
assert.ok(result.files.every(file => !file.path.includes('/Process')));
|
|
19
19
|
assert.match(
|
|
20
20
|
await readFile(join(rootPath, 'app/src/generatedCode/FlowObjects/Get/source/Get_Main.js'), 'utf8'),
|