@izara_project/izara-core-generate-service-code 1.0.67 → 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/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +89 -4
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- 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 +5 -2
- 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 +51 -21
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
- 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 +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 +20 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
- 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/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 +107 -11
- 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/generate.js +6 -2
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/customFlowApplicationArtifacts.test.js +48 -23
- 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 +10 -12
- package/test/resourceArtifacts.test.js +12 -2
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -15,18 +15,32 @@ 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
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
objectHash as hash,
|
|
20
|
+
identifierUuid
|
|
21
|
+
} from '@izara_project/izara-shared-core';
|
|
19
22
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
20
23
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
21
24
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
22
25
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
23
26
|
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
24
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
consts as coreConsts,
|
|
29
|
+
NoRetryError
|
|
30
|
+
} from '@izara_project/izara-core-library-core';
|
|
25
31
|
import { consts as middlewareConsts } from '@izara_project/izara-middleware';
|
|
26
|
-
import { sns, lambda } from '@izara_project/izara-core-library-external-request';
|
|
27
32
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
sns,
|
|
34
|
+
lambda
|
|
35
|
+
} from '@izara_project/izara-core-library-external-request';
|
|
36
|
+
import {
|
|
37
|
+
utils,
|
|
38
|
+
createNodeLib,
|
|
39
|
+
uploadUseCase,
|
|
40
|
+
consts,
|
|
41
|
+
getObjectSchema,
|
|
42
|
+
identifiersObject,
|
|
43
|
+
dataDetailsLib
|
|
30
44
|
} from '@izara_project/izara-core-library-service-schemas';
|
|
31
45
|
import graphSharedLibs from '@izara_project/izara-core-library-graph-service';
|
|
32
46
|
|
|
@@ -35,7 +49,8 @@ import graphSharedLibs from '@izara_project/izara-core-library-graph-service';
|
|
|
35
49
|
|
|
36
50
|
const { createObjType, firstLetterUpperCase } = utils;
|
|
37
51
|
const { createDataDetailsLib } = dataDetailsLib;
|
|
38
|
-
const { dynamoDbIdentifiersByStorageResource, createIdentifiersByUseCase } =
|
|
52
|
+
const { dynamoDbIdentifiersByStorageResource, createIdentifiersByUseCase } =
|
|
53
|
+
identifiersObject;
|
|
39
54
|
const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
40
55
|
|
|
41
56
|
const PREFIX = {
|
|
@@ -75,24 +90,38 @@ export async function <%- flowTag %>MainLogical(
|
|
|
75
90
|
const objType = createObjType(requestParams.objectType);
|
|
76
91
|
|
|
77
92
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
78
|
-
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
93
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
94
|
+
_izContext,
|
|
95
|
+
objType
|
|
96
|
+
);
|
|
79
97
|
_izContext.logger.debug('objectSchema', objectSchema);
|
|
80
98
|
|
|
81
|
-
const objectSchemas =
|
|
99
|
+
const objectSchemas =
|
|
100
|
+
uploadUseCase.generateObjectSchemaForCombineFieldNames(
|
|
101
|
+
_izContext,
|
|
102
|
+
objectSchema
|
|
103
|
+
);
|
|
82
104
|
_izContext.logger.debug('objectSchemas', objectSchemas);
|
|
83
105
|
|
|
84
106
|
// ── Parent object ─────────────────────────────────────────────────────────
|
|
85
107
|
let parentObject;
|
|
86
108
|
if (objectSchemas.hasOwnProperty('extendObjType')) {
|
|
87
|
-
parentObject = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
109
|
+
parentObject = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
110
|
+
_izContext,
|
|
111
|
+
objectSchema.extendObjType
|
|
112
|
+
);
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
// ── Detect invocation type ────────────────────────────────────────────────
|
|
91
|
-
const directInvoke =
|
|
116
|
+
const directInvoke =
|
|
117
|
+
requestParams.hasOwnProperty('__context__') &&
|
|
92
118
|
requestParams.izEventSource?.eventSourceTag === 'DirectInvoke';
|
|
93
119
|
|
|
94
120
|
// ── Build createDataDetails ───────────────────────────────────────────────
|
|
95
|
-
const createDataDetails = await createDataDetailsLib(
|
|
121
|
+
const createDataDetails = await createDataDetailsLib(
|
|
122
|
+
_izContext,
|
|
123
|
+
objectSchemas
|
|
124
|
+
);
|
|
96
125
|
_izContext.logger.debug('createDataDetails:', createDataDetails);
|
|
97
126
|
|
|
98
127
|
// ── Build objInstanceFull identifiers ─────────────────────────────────────
|
|
@@ -100,12 +129,18 @@ export async function <%- flowTag %>MainLogical(
|
|
|
100
129
|
|
|
101
130
|
for (const fieldName of Object.keys(requestParams.fieldNames)) {
|
|
102
131
|
if (objectSchemas.identifierFieldNames.includes(fieldName)) {
|
|
103
|
-
Object.assign(objInstanceFull.identifiers, {
|
|
132
|
+
Object.assign(objInstanceFull.identifiers, {
|
|
133
|
+
[fieldName]: requestParams.fieldNames[fieldName]
|
|
134
|
+
});
|
|
104
135
|
}
|
|
105
136
|
}
|
|
106
137
|
|
|
107
138
|
// ── Helper: extract fields per storageTag ─────────────────────────────────
|
|
108
|
-
function createObjInstanceFullFieldsByStorageTag(
|
|
139
|
+
function createObjInstanceFullFieldsByStorageTag(
|
|
140
|
+
_izContext,
|
|
141
|
+
storageTag,
|
|
142
|
+
createDataDetail
|
|
143
|
+
) {
|
|
109
144
|
const fields = {};
|
|
110
145
|
for (const fieldName of Object.keys(requestParams.fieldNames)) {
|
|
111
146
|
if (
|
|
@@ -114,7 +149,9 @@ export async function <%- flowTag %>MainLogical(
|
|
|
114
149
|
!objInstanceFull.identifiers.hasOwnProperty(fieldName) &&
|
|
115
150
|
!fields.hasOwnProperty(fieldName)
|
|
116
151
|
) {
|
|
117
|
-
Object.assign(fields, {
|
|
152
|
+
Object.assign(fields, {
|
|
153
|
+
[fieldName]: requestParams.fieldNames[fieldName]
|
|
154
|
+
});
|
|
118
155
|
}
|
|
119
156
|
}
|
|
120
157
|
return fields;
|
|
@@ -133,36 +170,66 @@ export async function <%- flowTag %>MainLogical(
|
|
|
133
170
|
//(<validateBeforeCreate>)
|
|
134
171
|
//(</validateBeforeCreate>)
|
|
135
172
|
|
|
136
|
-
for (const [storageTag, createDataDetail] of Object.entries(
|
|
173
|
+
for (const [storageTag, createDataDetail] of Object.entries(
|
|
174
|
+
createDataDetails
|
|
175
|
+
)) {
|
|
137
176
|
//(<beforeCreate>)
|
|
138
177
|
//(</beforeCreate>)
|
|
139
178
|
|
|
140
179
|
// ── DynamoDB ──────────────────────────────────────────────────────────
|
|
141
180
|
if (createDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
142
|
-
_izContext.logger.debug('::::::DynamoDB::::::', {
|
|
181
|
+
_izContext.logger.debug('::::::DynamoDB::::::', {
|
|
182
|
+
storageTag,
|
|
183
|
+
objInstanceFull
|
|
184
|
+
});
|
|
143
185
|
|
|
144
|
-
if (
|
|
145
|
-
|
|
186
|
+
if (
|
|
187
|
+
parentObject &&
|
|
188
|
+
createDataDetail.tableName.includes(
|
|
189
|
+
firstLetterUpperCase(`${parentObject.objectType}Records`)
|
|
190
|
+
)
|
|
191
|
+
) {
|
|
192
|
+
Object.assign(objInstanceFullForDynamoDb.fields, {
|
|
193
|
+
[`${parentObject.objectType}HandlerServiceTag`]:
|
|
194
|
+
process.env.iz_serviceTag
|
|
195
|
+
});
|
|
146
196
|
}
|
|
147
197
|
|
|
148
|
-
Object.assign(
|
|
149
|
-
|
|
198
|
+
Object.assign(
|
|
199
|
+
objInstanceFullForDynamoDb.fields,
|
|
200
|
+
createObjInstanceFullFieldsByStorageTag(
|
|
201
|
+
_izContext,
|
|
202
|
+
storageTag,
|
|
203
|
+
createDataDetail
|
|
204
|
+
)
|
|
205
|
+
);
|
|
150
206
|
|
|
151
|
-
_izContext.logger.debug(
|
|
207
|
+
_izContext.logger.debug(
|
|
208
|
+
'objInstanceFull before create item in dynamoDB',
|
|
209
|
+
objInstanceFullForDynamoDb
|
|
210
|
+
);
|
|
152
211
|
|
|
153
|
-
const identifiersForCreateData =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
212
|
+
const identifiersForCreateData =
|
|
213
|
+
await dynamoDbIdentifiersByStorageResource(
|
|
214
|
+
_izContext,
|
|
215
|
+
objectSchema,
|
|
216
|
+
createDataDetails,
|
|
217
|
+
objInstanceFullForDynamoDb.identifiers
|
|
218
|
+
);
|
|
219
|
+
_izContext.logger.debug(
|
|
220
|
+
'identifiersForCreateData',
|
|
221
|
+
identifiersForCreateData
|
|
158
222
|
);
|
|
159
|
-
_izContext.logger.debug('identifiersForCreateData', identifiersForCreateData);
|
|
160
223
|
|
|
161
224
|
//(<beforeCreateRecordDynamo>)
|
|
162
225
|
//(</beforeCreateRecordDynamo>)
|
|
163
226
|
|
|
164
|
-
if (
|
|
165
|
-
|
|
227
|
+
if (
|
|
228
|
+
Object.values(createDataDetails).some(
|
|
229
|
+
(createDataDetail) =>
|
|
230
|
+
createDataDetail.storageType === consts.STORAGE_TYPES.graph
|
|
231
|
+
)
|
|
232
|
+
) {
|
|
166
233
|
_izContext.logger.debug('must process graph first');
|
|
167
234
|
listOfRecords.push({
|
|
168
235
|
[storageTag]: {
|
|
@@ -173,12 +240,13 @@ export async function <%- flowTag %>MainLogical(
|
|
|
173
240
|
fields: objInstanceFullForDynamoDb.fields
|
|
174
241
|
}
|
|
175
242
|
}
|
|
176
|
-
})
|
|
243
|
+
});
|
|
177
244
|
} else {
|
|
178
|
-
_izContext.logger.debug('can process record dynamo')
|
|
245
|
+
_izContext.logger.debug('can process record dynamo');
|
|
179
246
|
await dynamodbSharedLib.putItem(
|
|
180
247
|
_izContext,
|
|
181
|
-
dynamodbSharedLib.tableName(
|
|
248
|
+
dynamodbSharedLib.tableName(
|
|
249
|
+
_izContext,
|
|
182
250
|
createDataDetail.tableName,
|
|
183
251
|
createDataDetail.serviceTag
|
|
184
252
|
),
|
|
@@ -188,25 +256,39 @@ export async function <%- flowTag %>MainLogical(
|
|
|
188
256
|
}
|
|
189
257
|
);
|
|
190
258
|
|
|
191
|
-
objInstanceFullForDynamoDb.fields = {}
|
|
259
|
+
objInstanceFullForDynamoDb.fields = {};
|
|
192
260
|
}
|
|
193
261
|
|
|
194
262
|
//(<afterCreateRecordDynamo>)
|
|
195
263
|
//(</afterCreateRecordDynamo>)
|
|
196
264
|
|
|
197
265
|
// ── Graph ─────────────────────────────────────────────────────────────
|
|
198
|
-
} else if (
|
|
266
|
+
} else if (
|
|
267
|
+
createDataDetail.storageType === consts.STORAGE_TYPES.graph
|
|
268
|
+
) {
|
|
199
269
|
//(<beforeCreateNode>)
|
|
200
270
|
//(</beforeCreateNode>)
|
|
201
|
-
_izContext.logger.debug('::::::Graph::::::', {
|
|
271
|
+
_izContext.logger.debug('::::::Graph::::::', {
|
|
272
|
+
storageTag,
|
|
273
|
+
objInstanceFull
|
|
274
|
+
});
|
|
202
275
|
|
|
203
|
-
Object.assign(
|
|
204
|
-
|
|
205
|
-
|
|
276
|
+
Object.assign(
|
|
277
|
+
objInstanceFullForGraph.fields,
|
|
278
|
+
createObjInstanceFullFieldsByStorageTag(
|
|
279
|
+
_izContext,
|
|
280
|
+
storageTag,
|
|
281
|
+
createDataDetail
|
|
282
|
+
)
|
|
283
|
+
);
|
|
284
|
+
_izContext.logger.debug(
|
|
285
|
+
'objInstanceFull before send to Graph',
|
|
286
|
+
objInstanceFullForGraph
|
|
287
|
+
);
|
|
206
288
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
289
|
+
//(<additionalAttributeCreateNode>)
|
|
290
|
+
const additionalAttributes = {};
|
|
291
|
+
//(</additionalAttributeCreateNode>)
|
|
210
292
|
|
|
211
293
|
const records = allAwaitingStepsId.length === 0 ? listOfRecords : [];
|
|
212
294
|
allAwaitingStepsId.push({
|
|
@@ -214,7 +296,10 @@ export async function <%- flowTag %>MainLogical(
|
|
|
214
296
|
parentFlowId,
|
|
215
297
|
PREFIX.CREATE_OBJECT_ASYNC
|
|
216
298
|
),
|
|
217
|
-
additionalAttributes: {
|
|
299
|
+
additionalAttributes: {
|
|
300
|
+
listOfRecords: records,
|
|
301
|
+
additionalAttributes: additionalAttributes
|
|
302
|
+
}
|
|
218
303
|
});
|
|
219
304
|
|
|
220
305
|
listOfObjectForCreates.push({
|
|
@@ -228,13 +313,28 @@ export async function <%- flowTag %>MainLogical(
|
|
|
228
313
|
});
|
|
229
314
|
|
|
230
315
|
// ── External Topic ────────────────────────────────────────────────────
|
|
231
|
-
} else if (
|
|
232
|
-
|
|
316
|
+
} else if (
|
|
317
|
+
createDataDetail.storageType === consts.STORAGE_TYPES.externalTopic
|
|
318
|
+
) {
|
|
319
|
+
_izContext.logger.debug('::::::externalTopic::::::', {
|
|
320
|
+
storageTag,
|
|
321
|
+
createDataDetail
|
|
322
|
+
});
|
|
233
323
|
//(<beforeSendMessageToExternalTopic>)
|
|
234
324
|
//(</beforeSendMessageToExternalTopic>)
|
|
235
325
|
|
|
236
|
-
Object.assign(
|
|
237
|
-
|
|
326
|
+
Object.assign(
|
|
327
|
+
objInstanceFullForExternalTopic.fields,
|
|
328
|
+
createObjInstanceFullFieldsByStorageTag(
|
|
329
|
+
_izContext,
|
|
330
|
+
storageTag,
|
|
331
|
+
createDataDetail
|
|
332
|
+
)
|
|
333
|
+
);
|
|
334
|
+
_izContext.logger.debug(
|
|
335
|
+
'objInstanceFull before send to external topic',
|
|
336
|
+
objInstanceFullForExternalTopic
|
|
337
|
+
);
|
|
238
338
|
|
|
239
339
|
allAwaitingStepsId.push({
|
|
240
340
|
awaitingStepId: await asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -244,7 +344,9 @@ export async function <%- flowTag %>MainLogical(
|
|
|
244
344
|
additionalAttributes: {}
|
|
245
345
|
});
|
|
246
346
|
|
|
247
|
-
Object.assign(objInstanceFullForExternalTopic, {
|
|
347
|
+
Object.assign(objInstanceFullForExternalTopic, {
|
|
348
|
+
parentFlowId: parentFlowId
|
|
349
|
+
});
|
|
248
350
|
|
|
249
351
|
await sns.publishAsync(_izContext, {
|
|
250
352
|
Message: JSON.stringify(objInstanceFullForExternalTopic),
|
|
@@ -262,14 +364,18 @@ export async function <%- flowTag %>MainLogical(
|
|
|
262
364
|
_izContext.uniqueRequestId,
|
|
263
365
|
PREFIX.CREATE_OBJECT_ASYNC_COMPLETE
|
|
264
366
|
),
|
|
265
|
-
allAwaitingStepsId
|
|
367
|
+
allAwaitingStepsId
|
|
266
368
|
);
|
|
267
369
|
|
|
268
370
|
// ── Process graph objects ─────────────────────────────────────────────────
|
|
269
371
|
let messageObject = {};
|
|
270
372
|
for (const objectCreate of listOfObjectForCreates) {
|
|
271
|
-
for (const [graphServiceName, objectForCreate] of Object.entries(
|
|
272
|
-
|
|
373
|
+
for (const [graphServiceName, objectForCreate] of Object.entries(
|
|
374
|
+
objectCreate
|
|
375
|
+
)) {
|
|
376
|
+
_izContext.logger.debug('Loop each graph:', {
|
|
377
|
+
[graphServiceName]: objectForCreate
|
|
378
|
+
});
|
|
273
379
|
|
|
274
380
|
if (!objectForCreate.allStorageTagComplete) {
|
|
275
381
|
//(<beforeSendMessageToGraph>)
|
|
@@ -286,24 +392,35 @@ export async function <%- flowTag %>MainLogical(
|
|
|
286
392
|
|
|
287
393
|
if (errorsFound.length > 0) break;
|
|
288
394
|
|
|
289
|
-
Object.assign(messageObject, {
|
|
395
|
+
Object.assign(messageObject, {
|
|
396
|
+
settings: { updatePropertiesOnMatch: false },
|
|
397
|
+
originTimestamp: Date.now()
|
|
398
|
+
});
|
|
290
399
|
|
|
291
|
-
messageObject =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
400
|
+
messageObject =
|
|
401
|
+
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
402
|
+
messageObject,
|
|
403
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
404
|
+
callingFlowConfig,
|
|
405
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
406
|
+
//(<callingFlowProperties>)
|
|
407
|
+
await lambdaSharedLib.lambdaFunctionName(
|
|
408
|
+
_izContext,
|
|
409
|
+
TOPIC_NAME_GENERATE_CODE.createNodeComplete
|
|
410
|
+
),
|
|
411
|
+
{}
|
|
412
|
+
//(</callingFlowProperties>)
|
|
413
|
+
)
|
|
300
414
|
)
|
|
301
|
-
)
|
|
302
|
-
);
|
|
415
|
+
);
|
|
303
416
|
|
|
304
417
|
await sns.publishAsync(_izContext, {
|
|
305
418
|
Message: JSON.stringify(messageObject),
|
|
306
|
-
TopicArn:
|
|
419
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
420
|
+
_izContext,
|
|
421
|
+
TOPIC_NAME_GRAPH_HANDLER.inCreateNode,
|
|
422
|
+
graphServiceName
|
|
423
|
+
)
|
|
307
424
|
});
|
|
308
425
|
|
|
309
426
|
//(<afterSendMessageToGraph>)
|
|
@@ -331,25 +448,41 @@ export async function <%- flowTag %>MainLogical(
|
|
|
331
448
|
)
|
|
332
449
|
);
|
|
333
450
|
|
|
334
|
-
messageObject =
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
451
|
+
messageObject =
|
|
452
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
453
|
+
callingFlowConfig,
|
|
454
|
+
{ objType, identifiers: null, errorsFound }
|
|
455
|
+
);
|
|
338
456
|
|
|
339
457
|
await sns.publishAsync(_izContext, {
|
|
340
458
|
Message: JSON.stringify(messageObject),
|
|
341
459
|
MessageAttributes: sns.createStringMessageAttributes(
|
|
342
460
|
_izContext,
|
|
343
|
-
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
461
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
462
|
+
callingFlowConfig,
|
|
463
|
+
{}
|
|
464
|
+
)
|
|
344
465
|
),
|
|
345
|
-
TopicArn:
|
|
466
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
467
|
+
_izContext,
|
|
468
|
+
TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete
|
|
469
|
+
)
|
|
346
470
|
});
|
|
347
471
|
|
|
348
|
-
return {
|
|
472
|
+
return {
|
|
473
|
+
objType,
|
|
474
|
+
objInstanceFull,
|
|
475
|
+
relationships: requestParams.relationships || [],
|
|
476
|
+
status: 'error',
|
|
477
|
+
errorsFound
|
|
478
|
+
};
|
|
349
479
|
}
|
|
350
480
|
|
|
351
481
|
// ── DynamoDB-only complete path ───────────────────────────────────────────
|
|
352
|
-
if (
|
|
482
|
+
if (
|
|
483
|
+
allAwaitingStepsId.length === 0 &&
|
|
484
|
+
listOfObjectForCreates.length === 0
|
|
485
|
+
) {
|
|
353
486
|
const outMessage =
|
|
354
487
|
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
355
488
|
callingFlowConfig,
|
|
@@ -362,15 +495,23 @@ export async function <%- flowTag %>MainLogical(
|
|
|
362
495
|
}
|
|
363
496
|
);
|
|
364
497
|
|
|
365
|
-
if (
|
|
498
|
+
if (
|
|
499
|
+
callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
|
|
500
|
+
) {
|
|
366
501
|
_izContext.logger.debug('HAVE CallingFlow');
|
|
367
502
|
await sns.publishAsync(_izContext, {
|
|
368
503
|
Message: JSON.stringify(outMessage),
|
|
369
504
|
MessageAttributes: sns.createStringMessageAttributes(
|
|
370
505
|
_izContext,
|
|
371
|
-
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
506
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
507
|
+
callingFlowConfig,
|
|
508
|
+
{}
|
|
509
|
+
)
|
|
372
510
|
),
|
|
373
|
-
TopicArn:
|
|
511
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
512
|
+
_izContext,
|
|
513
|
+
TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete
|
|
514
|
+
)
|
|
374
515
|
});
|
|
375
516
|
}
|
|
376
517
|
}
|
|
@@ -385,7 +526,6 @@ export async function <%- flowTag %>MainLogical(
|
|
|
385
526
|
status: 'complete',
|
|
386
527
|
errorsFound
|
|
387
528
|
};
|
|
388
|
-
|
|
389
529
|
} catch (err) {
|
|
390
530
|
throw err;
|
|
391
531
|
}
|
|
@@ -406,13 +546,19 @@ export default async function <%- flowTag %>(
|
|
|
406
546
|
//(</additionalParams>)
|
|
407
547
|
) {
|
|
408
548
|
try {
|
|
409
|
-
_izContext.logger.debug('[<%- flowTag %>] createMain:', {
|
|
549
|
+
_izContext.logger.debug('[<%- flowTag %>] createMain:', {
|
|
550
|
+
requestParams,
|
|
551
|
+
callingFlowConfig
|
|
552
|
+
});
|
|
410
553
|
|
|
411
554
|
const errorsFound = [];
|
|
412
555
|
const objType = createObjType(requestParams.objectType);
|
|
413
556
|
|
|
414
557
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
415
|
-
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
558
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
559
|
+
_izContext,
|
|
560
|
+
objType
|
|
561
|
+
);
|
|
416
562
|
_izContext.logger.debug('objectSchema', objectSchema);
|
|
417
563
|
|
|
418
564
|
// ── Resolve userId / targetId ─────────────────────────────────────────────
|
|
@@ -421,20 +567,30 @@ export default async function <%- flowTag %>(
|
|
|
421
567
|
userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
|
|
422
568
|
targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
|
|
423
569
|
if (!userId) errorsFound.push('Not have userId');
|
|
424
|
-
if (objectSchema.hasOwnProperty('belongTo') && !targetId)
|
|
570
|
+
if (objectSchema.hasOwnProperty('belongTo') && !targetId)
|
|
571
|
+
errorsFound.push('not have targetId');
|
|
425
572
|
} else if (objectSchema.generatedBy === 'searchResultGenerated') {
|
|
426
|
-
throw new NoRetryError(
|
|
573
|
+
throw new NoRetryError(
|
|
574
|
+
'error searchResultGenerated should not happen here'
|
|
575
|
+
);
|
|
427
576
|
}
|
|
428
577
|
|
|
429
578
|
//(<beforeQuery>)
|
|
430
579
|
//(</beforeQuery>)
|
|
431
580
|
|
|
432
581
|
// ── Build objectSchemas ───────────────────────────────────────────────────
|
|
433
|
-
const objectSchemas =
|
|
582
|
+
const objectSchemas =
|
|
583
|
+
uploadUseCase.generateObjectSchemaForCombineFieldNames(
|
|
584
|
+
_izContext,
|
|
585
|
+
objectSchema
|
|
586
|
+
);
|
|
434
587
|
_izContext.logger.debug('objectSchemas', objectSchemas);
|
|
435
588
|
|
|
436
589
|
// ── Build createDataDetails ───────────────────────────────────────────────
|
|
437
|
-
const createDataDetails = await createDataDetailsLib(
|
|
590
|
+
const createDataDetails = await createDataDetailsLib(
|
|
591
|
+
_izContext,
|
|
592
|
+
objectSchemas
|
|
593
|
+
);
|
|
438
594
|
_izContext.logger.debug('createDataDetails:', createDataDetails);
|
|
439
595
|
|
|
440
596
|
if (requestParams.relationships?.length > 0) {
|
|
@@ -443,7 +599,11 @@ export default async function <%- flowTag %>(
|
|
|
443
599
|
}
|
|
444
600
|
|
|
445
601
|
errorsFound.push(
|
|
446
|
-
...(await createNodeLib.validateRequiredOnCreateLinks(
|
|
602
|
+
...(await createNodeLib.validateRequiredOnCreateLinks(
|
|
603
|
+
_izContext,
|
|
604
|
+
objType,
|
|
605
|
+
requestParams.relationships
|
|
606
|
+
))
|
|
447
607
|
);
|
|
448
608
|
_izContext.logger.debug('errorsFound', errorsFound);
|
|
449
609
|
|
|
@@ -452,7 +612,11 @@ export default async function <%- flowTag %>(
|
|
|
452
612
|
const listOfOptionalOnCreate = [];
|
|
453
613
|
|
|
454
614
|
for (const [key, val] of Object.entries(objectSchemas.fieldNames)) {
|
|
455
|
-
if (
|
|
615
|
+
if (
|
|
616
|
+
val.randomOnCreate === true ||
|
|
617
|
+
val.requiredOnCreate === true ||
|
|
618
|
+
val.hashOnCreate?.length
|
|
619
|
+
) {
|
|
456
620
|
listOfRequiredOnCreate.push(key);
|
|
457
621
|
}
|
|
458
622
|
if (val.requiredOnCreate === false && val.optionalOnCreate === true) {
|
|
@@ -471,11 +635,26 @@ export default async function <%- flowTag %>(
|
|
|
471
635
|
let optionalOnCreateIdentifiers;
|
|
472
636
|
//(</createOptionalOnCreateIdentifiers>)
|
|
473
637
|
|
|
474
|
-
if (
|
|
475
|
-
|
|
638
|
+
if (
|
|
639
|
+
identifiers.length === 1 &&
|
|
640
|
+
!identifiers[0].hasOwnProperty('fieldNames')
|
|
641
|
+
) {
|
|
642
|
+
[requestParams, errors] = await createIdentifiersByUseCase(
|
|
643
|
+
_izContext,
|
|
644
|
+
requestParams,
|
|
645
|
+
objectSchemas,
|
|
646
|
+
identifiers[0],
|
|
647
|
+
optionalOnCreateIdentifiers
|
|
648
|
+
);
|
|
476
649
|
} else if (identifiers.length > 1) {
|
|
477
650
|
for (const identifier of identifiers) {
|
|
478
|
-
[requestParams, errors] = await createIdentifiersByUseCase(
|
|
651
|
+
[requestParams, errors] = await createIdentifiersByUseCase(
|
|
652
|
+
_izContext,
|
|
653
|
+
requestParams,
|
|
654
|
+
objectSchemas,
|
|
655
|
+
identifier,
|
|
656
|
+
optionalOnCreateIdentifiers
|
|
657
|
+
);
|
|
479
658
|
}
|
|
480
659
|
}
|
|
481
660
|
|
|
@@ -498,16 +677,24 @@ export default async function <%- flowTag %>(
|
|
|
498
677
|
//(</optionalObjInstanceFull>)
|
|
499
678
|
|
|
500
679
|
for (const fieldName of Object.keys(requestParams.fieldNames)) {
|
|
501
|
-
if (
|
|
680
|
+
if (
|
|
681
|
+
!listOfRequiredOnCreate.includes(fieldName) &&
|
|
682
|
+
!listOfOptionalOnCreate.includes(fieldName)
|
|
683
|
+
) {
|
|
502
684
|
errorsFound.push('[invalid] over fieldNames create object');
|
|
503
685
|
}
|
|
504
|
-
if (
|
|
686
|
+
if (
|
|
687
|
+
listOfOptionalOnCreate.length > 0 &&
|
|
688
|
+
listOfRequiredOnCreate.includes(fieldName)
|
|
689
|
+
) {
|
|
505
690
|
//(<optionalParams>)
|
|
506
691
|
//(</optionalParams>)
|
|
507
692
|
}
|
|
508
693
|
if (objectSchemas.identifierFieldNames.includes(fieldName)) {
|
|
509
694
|
_izContext.logger.debug('identifiers is', fieldName);
|
|
510
|
-
Object.assign(objInstanceFull.identifiers, {
|
|
695
|
+
Object.assign(objInstanceFull.identifiers, {
|
|
696
|
+
[fieldName]: requestParams.fieldNames[fieldName]
|
|
697
|
+
});
|
|
511
698
|
}
|
|
512
699
|
if (errorsFound.length > 0) {
|
|
513
700
|
_izContext.logger.debug('HaveError::', errorsFound);
|
|
@@ -527,32 +714,36 @@ export default async function <%- flowTag %>(
|
|
|
527
714
|
}, {});
|
|
528
715
|
_%>
|
|
529
716
|
<%_ Object.entries(groupedByObjType).forEach(([objectType, configs]) => { _%>
|
|
530
|
-
|
|
717
|
+
<%_
|
|
531
718
|
const hasOwnTopic = configs.some(c => c.invocationType === 'ownTopic');
|
|
532
719
|
const hasLambdaSyncInv = configs.some(c => c.invocationType === 'lambdaSyncInv');
|
|
533
720
|
_%>
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
721
|
+
if (requestParams.objectType === '<%= objectType %>') {
|
|
722
|
+
<%_ if (hasLambdaSyncInv) { _%>
|
|
723
|
+
const lambdaSyncInvResults = await Promise.all([
|
|
724
|
+
<%_ configs.filter(c => c.invocationType === 'lambdaSyncInv').forEach((config, index, arr) => { _%>
|
|
725
|
+
// lambdaSyncInv <%= config.flowTag %>
|
|
726
|
+
lambda
|
|
727
|
+
.invokeSync(
|
|
541
728
|
_izContext,
|
|
542
729
|
await lambdaSharedLib.lambdaFunctionName(
|
|
543
730
|
_izContext,
|
|
544
731
|
'Process<%= config.flowTag %>HdrInv'
|
|
545
732
|
),
|
|
546
733
|
{ requestParams, callingFlowConfig }
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
734
|
+
)
|
|
735
|
+
.then((returnValue) => ({
|
|
736
|
+
flowTag: '<%= config.flowTag %>',
|
|
737
|
+
returnValue
|
|
738
|
+
})) /*__EJS_COMMA_14__*/
|
|
739
|
+
// lambdaSyncInv <%= config.flowTag %>
|
|
740
|
+
<%_ }) _%>
|
|
741
|
+
]);
|
|
551
742
|
|
|
552
|
-
|
|
743
|
+
<%_ } _%>
|
|
553
744
|
|
|
554
|
-
|
|
555
|
-
|
|
745
|
+
//(<afterBeforeLogical_<%= objectType %>>)
|
|
746
|
+
//(</afterBeforeLogical_<%= objectType %>>)
|
|
556
747
|
|
|
557
748
|
<%_ if (hasOwnTopic) { _%>
|
|
558
749
|
// ── ownTopic (async — create awaitingSteps and then publish) ──────────────
|
|
@@ -598,7 +789,7 @@ export default async function <%- flowTag %>(
|
|
|
598
789
|
'<%= configs[0].codeHookTag %>_<%= objectType %>_' + syncResult.flowTag
|
|
599
790
|
),
|
|
600
791
|
additionalAttributes: {
|
|
601
|
-
complete:
|
|
792
|
+
complete: true,
|
|
602
793
|
errorsFound: [],
|
|
603
794
|
returnValue: syncResult.returnValue
|
|
604
795
|
}
|