@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.69
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/package.json +16 -12
- package/scripts/format-ejs.js +104 -0
- package/src/compile/compileProject.js +40 -9
- package/src/compile/loadSchemas.js +120 -11
- package/src/emit/crud/emitCrudApplicationArtifacts.js +188 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -18
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- 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 +402 -249
- package/src/emit/custom/customFlows.js +68 -28
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +520 -123
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- 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 +14 -9
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +65 -56
- 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 +272 -79
- package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
- package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
- package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
- package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
- package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
- package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +40 -29
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +171 -72
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
- package/src/emit/rbac/rbacFlowTag.js +3 -1
- 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 +26 -11
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +179 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- 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 +274 -105
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +139 -0
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +32 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +46 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +25 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +141 -34
- package/src/generateIntTest.js +76 -28
- package/src/generateResourceIntTest.js +35 -12
- package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
- package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
- package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
- package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
- package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
- package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
- package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
- package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
- package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
- package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
- package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
- package/src/intTestGeneratorShared.js +15 -10
- package/src/output/commitArtifacts.js +99 -39
- package/src/output/mergeHooks.js +24 -10
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +116 -49
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +128 -23
- package/test/customFlowApplicationArtifacts.test.js +391 -84
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +63 -20
- package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
- package/test/functionYamlArtifact.test.js +67 -10
- package/test/intTestApi.test.js +9 -10
- package/test/publicApi.test.js +184 -44
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +183 -33
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ejsLib from 'ejs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -19,22 +19,36 @@ const ACTIONS = [
|
|
|
19
19
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-relationships.yml';
|
|
20
20
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
21
21
|
|
|
22
|
-
export async function emitRelationshipApplicationArtifacts({
|
|
22
|
+
export async function emitRelationshipApplicationArtifacts({
|
|
23
|
+
relationships,
|
|
24
|
+
flows = [],
|
|
25
|
+
serviceTag
|
|
26
|
+
}) {
|
|
23
27
|
if (!Array.isArray(relationships) || !Array.isArray(flows)) {
|
|
24
28
|
throw new TypeError('relationships and flows must be arrays');
|
|
25
29
|
}
|
|
26
30
|
if (relationships.length === 0) return [];
|
|
27
31
|
|
|
28
|
-
const handlers = await Promise.all(
|
|
32
|
+
const handlers = await Promise.all(
|
|
33
|
+
ACTIONS.map((action) =>
|
|
34
|
+
emitAction(action, relationships, flows, serviceTag)
|
|
35
|
+
)
|
|
36
|
+
);
|
|
29
37
|
return [
|
|
30
|
-
...handlers.flatMap(handler => handler.artifacts),
|
|
31
|
-
{
|
|
38
|
+
...handlers.flatMap((handler) => handler.artifacts),
|
|
39
|
+
{
|
|
40
|
+
path: YAML_PATH,
|
|
41
|
+
content: handlers
|
|
42
|
+
.flatMap((handler) => handler.functions)
|
|
43
|
+
.map(renderFunction)
|
|
44
|
+
.join('\n')
|
|
45
|
+
}
|
|
32
46
|
];
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
export function relationshipApplicationManagedPaths() {
|
|
36
50
|
return [
|
|
37
|
-
...ACTIONS.flatMap(action => {
|
|
51
|
+
...ACTIONS.flatMap((action) => {
|
|
38
52
|
const source = `app/src/generatedCode/FlowRelationships/${action}/source`;
|
|
39
53
|
return [
|
|
40
54
|
`${source}/${action}_Main.js`,
|
|
@@ -55,75 +69,200 @@ export function relationshipApplicationManagedPaths() {
|
|
|
55
69
|
async function emitAction(action, relationships, flows, serviceTag) {
|
|
56
70
|
const source = `app/src/generatedCode/FlowRelationships/${action}/source`;
|
|
57
71
|
const handlerRoot = `src/generatedCode/FlowRelationships/${action}/source`;
|
|
58
|
-
const flow = flows.find(candidate => candidate?.flowTag === action);
|
|
59
|
-
const events = normalizeEvents(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
const flow = flows.find((candidate) => candidate?.flowTag === action);
|
|
73
|
+
const events = normalizeEvents(
|
|
74
|
+
flow?.event,
|
|
75
|
+
action === 'GetRelationship'
|
|
76
|
+
? ['lambdaSyncInv', 'lambdaSyncApi', 'dsq', 'ownTopic']
|
|
77
|
+
: ['ownTopic']
|
|
78
|
+
);
|
|
79
|
+
const shared = {
|
|
80
|
+
flowTag: action,
|
|
81
|
+
flowStepName: '',
|
|
82
|
+
mainFileName: `${action}_Main`,
|
|
83
|
+
functionName: action,
|
|
84
|
+
startConfig: null
|
|
85
|
+
};
|
|
86
|
+
const artifacts = [
|
|
87
|
+
{
|
|
88
|
+
path: `${source}/${action}_Main.js`,
|
|
89
|
+
content: await render(`${action}_Main.ejs`, {
|
|
90
|
+
functionName: action,
|
|
91
|
+
upperFunctionName: action
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
];
|
|
64
95
|
const functions = [];
|
|
65
96
|
|
|
66
97
|
if (events.includes('ownTopic')) {
|
|
67
98
|
artifacts.push(
|
|
68
|
-
{
|
|
69
|
-
|
|
99
|
+
{
|
|
100
|
+
path: `${source}/${action}_WbsMain.js`,
|
|
101
|
+
content: await renderShared('FlowMain_Wbs.ejs', {
|
|
102
|
+
flowTag: action,
|
|
103
|
+
upperCaseFlowTag: action,
|
|
104
|
+
functionName: action
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
path: `${source}/${action}_HdrWbs.js`,
|
|
109
|
+
content: await renderShared('FlowEndpoint_HdrWbs.ejs', {
|
|
110
|
+
flowTag: action,
|
|
111
|
+
upperCaseFlowTag: action,
|
|
112
|
+
functionName: action,
|
|
113
|
+
mainFileName: `${action}_WbsMain`,
|
|
114
|
+
route: action
|
|
115
|
+
})
|
|
116
|
+
}
|
|
70
117
|
);
|
|
71
|
-
functions.push({
|
|
118
|
+
functions.push({
|
|
119
|
+
type: 'wbs',
|
|
120
|
+
functionName: `${action}HdrWbs`,
|
|
121
|
+
handlerPath: `${handlerRoot}/${action}_HdrWbs.main`,
|
|
122
|
+
roleName: 'FlowRelationshipRole',
|
|
123
|
+
routeName: action,
|
|
124
|
+
flowTag: action,
|
|
125
|
+
flowStepName: ''
|
|
126
|
+
});
|
|
72
127
|
}
|
|
73
128
|
|
|
74
129
|
for (const event of events) {
|
|
75
|
-
const handler = eventHandler(
|
|
130
|
+
const handler = eventHandler(
|
|
131
|
+
event,
|
|
132
|
+
action,
|
|
133
|
+
handlerRoot,
|
|
134
|
+
relationships,
|
|
135
|
+
serviceTag
|
|
136
|
+
);
|
|
76
137
|
if (!handler) continue;
|
|
77
|
-
artifacts.push({
|
|
138
|
+
artifacts.push({
|
|
139
|
+
path: `${source}/${handler.fileName}.js`,
|
|
140
|
+
content: await render(handler.template, {
|
|
141
|
+
...shared,
|
|
142
|
+
queueName: handler.queueName
|
|
143
|
+
})
|
|
144
|
+
});
|
|
78
145
|
functions.push(handler.descriptor);
|
|
79
146
|
}
|
|
80
147
|
|
|
81
148
|
const complete = `${action}Complete`;
|
|
82
149
|
artifacts.push(
|
|
83
|
-
{
|
|
84
|
-
|
|
150
|
+
{
|
|
151
|
+
path: `${source}/${complete}_Main.js`,
|
|
152
|
+
content: await render(`${action}Complete_Main.ejs`, {
|
|
153
|
+
functionName: complete,
|
|
154
|
+
upperFunctionName: complete
|
|
155
|
+
})
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
path: `${source}/${complete}_HdrSqs.js`,
|
|
159
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
160
|
+
...shared,
|
|
161
|
+
flowStepName: 'Complete',
|
|
162
|
+
mainFileName: `${complete}_Main`,
|
|
163
|
+
functionName: complete,
|
|
164
|
+
queueName: `${complete}HdrSqs`
|
|
165
|
+
})
|
|
166
|
+
}
|
|
85
167
|
);
|
|
86
|
-
functions.push({
|
|
168
|
+
functions.push({
|
|
169
|
+
type: 'sqs',
|
|
170
|
+
functionName: `${action}CompleteHdrSqs`,
|
|
171
|
+
handlerPath: `${handlerRoot}/${complete}_HdrSqs.main`,
|
|
172
|
+
roleName: 'FlowRelationshipRole',
|
|
173
|
+
queueName: `${complete}HdrSqs`,
|
|
174
|
+
flowTag: action,
|
|
175
|
+
flowStepName: 'Complete'
|
|
176
|
+
});
|
|
87
177
|
return { artifacts, functions };
|
|
88
178
|
}
|
|
89
179
|
|
|
90
180
|
function eventHandler(event, action, handlerRoot, relationships, serviceTag) {
|
|
91
181
|
if (event === 'ownTopic' || event === 'extTopic') {
|
|
92
182
|
return {
|
|
93
|
-
fileName: `${action}_HdrSqs`,
|
|
94
|
-
|
|
183
|
+
fileName: `${action}_HdrSqs`,
|
|
184
|
+
template: 'FlowHandler_HdrSqs.ejs',
|
|
185
|
+
queueName: `${action}HdrSqs`,
|
|
186
|
+
descriptor: {
|
|
187
|
+
type: 'sqs',
|
|
188
|
+
functionName: `${action.replace('Relationship', 'Rel')}HdrSqs`,
|
|
189
|
+
handlerPath: `${handlerRoot}/${action}_HdrSqs.main`,
|
|
190
|
+
roleName: 'FlowRelationshipRole',
|
|
191
|
+
queueName: `${action}HdrSqs`,
|
|
192
|
+
flowTag: action,
|
|
193
|
+
flowStepName: ''
|
|
194
|
+
}
|
|
95
195
|
};
|
|
96
196
|
}
|
|
97
197
|
if (event === 'dsq') {
|
|
98
198
|
return {
|
|
99
|
-
fileName: `${action}_HdrDsq`,
|
|
100
|
-
|
|
199
|
+
fileName: `${action}_HdrDsq`,
|
|
200
|
+
template: 'FlowHandler_HdrDsq.ejs',
|
|
201
|
+
queueName: `${action}HdrDsq`,
|
|
202
|
+
descriptor: {
|
|
203
|
+
type: 'sqs',
|
|
204
|
+
functionName: `${action.replace('Relationship', 'Rel')}HdrDsq`,
|
|
205
|
+
handlerPath: `${handlerRoot}/${action}_HdrDsq.main`,
|
|
206
|
+
roleName: 'FlowRelationshipRole',
|
|
207
|
+
queueName: `${action}HdrDsq`,
|
|
208
|
+
flowTag: action,
|
|
209
|
+
flowStepName: ''
|
|
210
|
+
}
|
|
101
211
|
};
|
|
102
212
|
}
|
|
103
213
|
if (event === 'lambdaSyncInv') {
|
|
104
214
|
return {
|
|
105
|
-
fileName: `${action}_HdrInv`,
|
|
106
|
-
|
|
215
|
+
fileName: `${action}_HdrInv`,
|
|
216
|
+
template: 'FlowHandler_HdrInv.ejs',
|
|
217
|
+
descriptor: {
|
|
218
|
+
type: 'inv',
|
|
219
|
+
functionName: `${action.replace('Relationship', 'Rel')}HdrInv`,
|
|
220
|
+
handlerPath: `${handlerRoot}/${action}_HdrInv.main`,
|
|
221
|
+
roleName: 'FlowRelationshipRole',
|
|
222
|
+
flowTag: action,
|
|
223
|
+
flowStepName: ''
|
|
224
|
+
}
|
|
107
225
|
};
|
|
108
226
|
}
|
|
109
227
|
if (event === 'lambdaSyncApi') {
|
|
110
228
|
return {
|
|
111
|
-
fileName: `${action}_HdrApi`,
|
|
229
|
+
fileName: `${action}_HdrApi`,
|
|
230
|
+
template: 'FlowHandler_HdrApi.ejs',
|
|
112
231
|
descriptor: {
|
|
113
|
-
type: 'api',
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
232
|
+
type: 'api',
|
|
233
|
+
functionName: `${action.replace('Relationship', 'Rel')}HdrApi`,
|
|
234
|
+
handlerPath: `${handlerRoot}/${action}_HdrApi.main`,
|
|
235
|
+
roleName: 'FlowRelationshipRole',
|
|
236
|
+
flowTag: action,
|
|
237
|
+
flowStepName: '',
|
|
238
|
+
routes: relationships.map((relationship) => {
|
|
239
|
+
let name = Object.keys(relationship)[0];
|
|
240
|
+
if (relationship.relationshipTag) {
|
|
241
|
+
name = relationship.relationshipTag;
|
|
242
|
+
}
|
|
243
|
+
let targetServiceTag = '${self:custom.iz_serviceName}';
|
|
244
|
+
if (serviceTag) {
|
|
245
|
+
targetServiceTag = serviceTag;
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
path: `/${targetServiceTag}/${name}/${action.toLowerCase().replace('relationship', '')}`,
|
|
249
|
+
upperName: upperFirst(name)
|
|
250
|
+
};
|
|
118
251
|
})
|
|
119
252
|
}
|
|
120
253
|
};
|
|
121
254
|
}
|
|
122
|
-
return
|
|
255
|
+
return null;
|
|
123
256
|
}
|
|
124
257
|
|
|
125
258
|
function normalizeEvents(events, fallback) {
|
|
126
|
-
|
|
259
|
+
if (events === undefined) {
|
|
260
|
+
return fallback;
|
|
261
|
+
}
|
|
262
|
+
if (Array.isArray(events)) {
|
|
263
|
+
return events;
|
|
264
|
+
}
|
|
265
|
+
return [events];
|
|
127
266
|
}
|
|
128
267
|
|
|
129
268
|
function upperFirst(value) {
|
|
@@ -132,12 +271,15 @@ function upperFirst(value) {
|
|
|
132
271
|
|
|
133
272
|
async function render(templateName, data) {
|
|
134
273
|
const template = await readFile(new URL(templateName, TEMPLATE_URL), 'utf8');
|
|
135
|
-
return
|
|
274
|
+
return ejsLib.render(template, data);
|
|
136
275
|
}
|
|
137
276
|
|
|
138
277
|
async function renderShared(templateName, data) {
|
|
139
|
-
const template = await readFile(
|
|
140
|
-
|
|
278
|
+
const template = await readFile(
|
|
279
|
+
new URL(`../crud/templates/${templateName}`, import.meta.url),
|
|
280
|
+
'utf8'
|
|
281
|
+
);
|
|
282
|
+
return ejsLib.render(template, data);
|
|
141
283
|
}
|
|
142
284
|
|
|
143
285
|
function renderFunction(descriptor) {
|
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
emitDynamicRelationshipFlowSchemas
|
|
8
8
|
} from './emitDynamicRelationshipFlowSchemas.js';
|
|
9
9
|
|
|
10
|
-
export async function generateDynamicRelationshipFlowSchemas(
|
|
10
|
+
export async function generateDynamicRelationshipFlowSchemas(
|
|
11
|
+
rootPath,
|
|
12
|
+
options = {}
|
|
13
|
+
) {
|
|
11
14
|
const project = compileProject({ ...options, rootPath });
|
|
12
15
|
// The legacy generator creates these endpoints even with no relationships. Load now to
|
|
13
16
|
// validate the V2 source-module contract before later slices consume relationship data.
|
|
@@ -15,7 +18,10 @@ export async function generateDynamicRelationshipFlowSchemas(rootPath, options =
|
|
|
15
18
|
const plan = buildGenerationPlan(
|
|
16
19
|
project,
|
|
17
20
|
emitDynamicRelationshipFlowSchemas(),
|
|
18
|
-
{
|
|
21
|
+
{
|
|
22
|
+
managedPaths: dynamicRelationshipFlowSchemaPaths,
|
|
23
|
+
managedScope: 'relationship-flow-schemas'
|
|
24
|
+
}
|
|
19
25
|
);
|
|
20
26
|
const files = await commitArtifacts(plan);
|
|
21
27
|
|
|
@@ -7,16 +7,25 @@ import {
|
|
|
7
7
|
relationshipApplicationManagedPaths
|
|
8
8
|
} from './emitRelationshipApplicationArtifacts.js';
|
|
9
9
|
|
|
10
|
-
export async function generateRelationshipApplicationArtifacts(
|
|
10
|
+
export async function generateRelationshipApplicationArtifacts(
|
|
11
|
+
rootPath,
|
|
12
|
+
options = {}
|
|
13
|
+
) {
|
|
11
14
|
const project = compileProject({ ...options, rootPath });
|
|
12
15
|
const [relationships, flows] = await Promise.all([
|
|
13
16
|
loadLocalSchemaDirectory(project, 'RelationshipSchemas'),
|
|
14
17
|
loadLocalSchemaDirectory(project, 'FlowSchemas')
|
|
15
18
|
]);
|
|
16
|
-
const artifacts = await emitRelationshipApplicationArtifacts({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
19
|
+
const artifacts = await emitRelationshipApplicationArtifacts({
|
|
20
|
+
relationships,
|
|
21
|
+
flows,
|
|
22
|
+
serviceTag: project.serviceTag
|
|
23
|
+
});
|
|
24
|
+
const files = await commitArtifacts(
|
|
25
|
+
buildGenerationPlan(project, artifacts, {
|
|
26
|
+
managedPaths: relationshipApplicationManagedPaths(),
|
|
27
|
+
managedScope: 'relationship-application'
|
|
28
|
+
})
|
|
29
|
+
);
|
|
21
30
|
return { project, files };
|
|
22
31
|
}
|
|
@@ -15,22 +15,21 @@ 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
|
-
|
|
19
18
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
20
19
|
|
|
21
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
22
|
-
import snsSharedLib from
|
|
23
|
-
import dynamodbSharedLib from
|
|
24
|
-
import asyncFlowSharedLib from
|
|
25
|
-
|
|
26
|
-
import { sns } from
|
|
27
|
-
import {
|
|
21
|
+
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
23
|
+
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
|
+
|
|
25
|
+
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
26
|
+
import {
|
|
27
|
+
utils,
|
|
28
|
+
consts
|
|
29
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
28
30
|
const { createLinkTypeId } = utils;
|
|
29
31
|
|
|
30
|
-
const {
|
|
31
|
-
TOPIC_NAME_GENERATE_CODE,
|
|
32
|
-
PREFIX
|
|
33
|
-
} = consts;
|
|
32
|
+
const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
|
|
34
33
|
|
|
35
34
|
//(<optionalRequire>)
|
|
36
35
|
//(</optionalRequire>)
|
|
@@ -41,15 +40,15 @@ export default async function changeRelationshipComplete(
|
|
|
41
40
|
status,
|
|
42
41
|
errorsFound,
|
|
43
42
|
graphServiceTag,
|
|
44
|
-
passBackProperties = {}
|
|
43
|
+
passBackProperties = {}
|
|
45
44
|
) {
|
|
46
45
|
try {
|
|
47
|
-
_izContext.logger.debug(
|
|
46
|
+
_izContext.logger.debug('Function:ChangeRelationshipComplete', {
|
|
48
47
|
returnValue: returnValue,
|
|
49
48
|
status: status,
|
|
50
49
|
errorsFound: errorsFound,
|
|
51
50
|
graphServiceTag: graphServiceTag,
|
|
52
|
-
passBackProperties: passBackProperties
|
|
51
|
+
passBackProperties: passBackProperties
|
|
53
52
|
});
|
|
54
53
|
|
|
55
54
|
// start create awaitingStepId
|
|
@@ -64,54 +63,83 @@ export default async function changeRelationshipComplete(
|
|
|
64
63
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
65
64
|
returnValue.parentFlowId, // hash id
|
|
66
65
|
PREFIX.changeRel // prefix, use constant further
|
|
67
|
-
)
|
|
68
|
-
|
|
66
|
+
);
|
|
69
67
|
|
|
70
68
|
let createRelPendingObjects = await dynamodbSharedLib.query(
|
|
71
69
|
_izContext,
|
|
72
|
-
await dynamodbSharedLib.tableName(_izContext,
|
|
70
|
+
await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
|
|
73
71
|
{
|
|
74
72
|
awaitingStepId: awaitingStepId
|
|
75
73
|
}
|
|
76
74
|
);
|
|
77
|
-
_izContext.logger.debug(
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
_izContext.logger.debug(
|
|
76
|
+
'record of createRelPendingObjects ::',
|
|
77
|
+
createRelPendingObjects
|
|
78
|
+
);
|
|
80
79
|
|
|
81
80
|
await Promise.all(
|
|
82
81
|
createRelPendingObjects.Items.map(async ({ pendingStepId }) => {
|
|
83
|
-
if (
|
|
82
|
+
if (
|
|
83
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
84
84
|
_izContext,
|
|
85
85
|
pendingStepId, // task waiting
|
|
86
86
|
awaitingStepId,
|
|
87
87
|
errorsFound
|
|
88
|
-
)
|
|
89
|
-
|
|
88
|
+
)
|
|
89
|
+
) {
|
|
90
|
+
_izContext.logger.debug('finished all awaitingStep');
|
|
90
91
|
|
|
91
92
|
let changeRelCompleteMsg = {
|
|
92
93
|
firstObject: returnValue.requestParams.firstObject,
|
|
93
94
|
secondObject: returnValue.requestParams.secondObject,
|
|
94
95
|
relType: returnValue.requestParams.relType,
|
|
95
|
-
oldRelTypeAndDirection:
|
|
96
|
+
oldRelTypeAndDirection:
|
|
97
|
+
returnValue.requestParams.oldRelTypeAndDirection,
|
|
96
98
|
newRelType: returnValue.requestParams.newRelType,
|
|
97
99
|
parentFlowId: returnValue.parentFlowId,
|
|
98
100
|
status: status,
|
|
99
101
|
errorsFound: errorsFound
|
|
100
102
|
};
|
|
101
103
|
|
|
102
|
-
changeRelCompleteMsg =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
changeRelCompleteMsg =
|
|
105
|
+
callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
|
|
106
|
+
passBackProperties,
|
|
107
|
+
changeRelCompleteMsg
|
|
108
|
+
);
|
|
109
|
+
_izContext.logger.debug(
|
|
110
|
+
'After addCallingFlowToSnsResponseMessageObject',
|
|
111
|
+
changeRelCompleteMsg
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
let messageAttributes =
|
|
115
|
+
callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
|
|
116
|
+
passBackProperties,
|
|
117
|
+
{}
|
|
118
|
+
);
|
|
119
|
+
_izContext.logger.debug(
|
|
120
|
+
'After addCallingFlowToSnsResponseMessageAttributes',
|
|
121
|
+
changeRelCompleteMsg
|
|
122
|
+
);
|
|
107
123
|
|
|
108
124
|
let sendMessageToOutChangeRelationshipComplete = {
|
|
109
125
|
Message: JSON.stringify(changeRelCompleteMsg),
|
|
110
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
111
|
-
|
|
126
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
127
|
+
_izContext,
|
|
128
|
+
messageAttributes
|
|
129
|
+
),
|
|
130
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
131
|
+
_izContext,
|
|
132
|
+
TOPIC_NAME_GENERATE_CODE.outChangeRelationshipComplete
|
|
133
|
+
)
|
|
112
134
|
};
|
|
113
|
-
_izContext.logger.debug(
|
|
114
|
-
|
|
135
|
+
_izContext.logger.debug(
|
|
136
|
+
'Send message to OutChangeRelationshipComplete :::>',
|
|
137
|
+
sendMessageToOutChangeRelationshipComplete
|
|
138
|
+
);
|
|
139
|
+
await sns.publishAsync(
|
|
140
|
+
_izContext,
|
|
141
|
+
sendMessageToOutChangeRelationshipComplete
|
|
142
|
+
);
|
|
115
143
|
|
|
116
144
|
//(<afterCheckAwaitingStep>)
|
|
117
145
|
//(</afterCheckAwaitingStep>)
|
|
@@ -134,10 +162,9 @@ export default async function changeRelationshipComplete(
|
|
|
134
162
|
returnValue,
|
|
135
163
|
status,
|
|
136
164
|
errorsFound
|
|
137
|
-
}
|
|
138
|
-
|
|
165
|
+
};
|
|
139
166
|
} catch (err) {
|
|
140
|
-
_izContext.logger.error('error createRelationshipComplete:', err)
|
|
141
|
-
throw
|
|
167
|
+
_izContext.logger.error('error createRelationshipComplete:', err);
|
|
168
|
+
throw err;
|
|
142
169
|
}
|
|
143
170
|
}
|