@izara_project/izara-core-generate-service-code 1.0.24 → 1.0.26
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/jsconfig.json +7 -3
- package/package.json +2 -2
- package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs +3 -1
- package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/template.ejs +2 -2
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/template.ejs +1 -3
- package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/template.ejs +1 -1
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/DsqHandlerTemplate.ejs +2 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/SqsHandlerTemplate.ejs +2 -2
- package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs +1 -1
- package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +1 -1
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +1 -1
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/mainFunction/template.ejs +1 -1
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/beforeLogical/template.ejs +14 -6
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +21 -3
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/delete/main/template.ejs +24 -4
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/update/main/template.ejs +25 -4
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/complete/mainFunction/template.ejs +1 -1
- package/src/generateCode/generateTranslation/generateTranslation.js +57 -0
- package/src/generateCode/generateTranslation/translations/data.js +87 -0
- package/src/generateCode/generateTranslation/translations/template.ejs +5 -0
- package/src/generateCode.js +8 -3
- package/src/libs/Consts.js +6 -2
package/jsconfig.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"author": "Sven Mason <thebarbariansven@gmail.com>",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@izara_project/izara-core-library-core": "^1.0.31",
|
|
28
28
|
"@izara_project/izara-core-library-logger": "^1.0.8",
|
|
29
29
|
"@izara_project/izara-core-library-s3": "^1.0.5",
|
|
30
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.
|
|
30
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.127",
|
|
31
31
|
"@izara_project/izara-shared-core": "^1.0.9",
|
|
32
32
|
"ejs": "^5.0.1",
|
|
33
33
|
"js-beautify": "^1.15.4",
|
package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs
CHANGED
|
@@ -41,7 +41,9 @@ export const main = middlewareHandler.wrap(async (event, context) => {
|
|
|
41
41
|
return await <%- functionName %> Main(
|
|
42
42
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
|
|
43
43
|
event,
|
|
44
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
44
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event),
|
|
45
|
+
//(<additionalParams>)
|
|
46
|
+
//(</additionalParams>)
|
|
45
47
|
);
|
|
46
48
|
|
|
47
49
|
} catch (err) {
|
package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/template.ejs
CHANGED
|
@@ -65,10 +65,10 @@ export const main = middleware.wrap(async (event, context) => {
|
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
68
|
-
passOnProperties.push(record.body.Message)
|
|
68
|
+
passOnProperties.push(record.body.Message);
|
|
69
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
69
70
|
//(<additionalParams>)
|
|
70
71
|
//(</additionalParams>)
|
|
71
|
-
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
72
72
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
73
73
|
|
|
74
74
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/template.ejs
CHANGED
|
@@ -15,8 +15,6 @@ 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
|
-
|
|
20
18
|
const RBAC_TARGET_ID = process.env.iz_rbacTargetIdUser // iz_rbacTargetIdUser | iz_rbacDeliveryMethodId
|
|
21
19
|
|
|
22
20
|
import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
|
|
@@ -66,9 +64,9 @@ export const main = middleware.wrap(async (event, context, callback) => {
|
|
|
66
64
|
let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>(
|
|
67
65
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
|
|
68
66
|
event.body,
|
|
67
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
69
68
|
//(<additionalParams>)
|
|
70
69
|
//(</additionalParams>)
|
|
71
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
72
70
|
);
|
|
73
71
|
|
|
74
72
|
// return error to client
|
package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/template.ejs
CHANGED
|
@@ -40,9 +40,9 @@ export const main = middleware.wrap(async (event, context, callback) => {
|
|
|
40
40
|
return await <%- functionName %>.<%- functionName %>(
|
|
41
41
|
event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
|
|
42
42
|
event,
|
|
43
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
43
44
|
//(<additionalParams>)
|
|
44
45
|
//(</additionalParams>)
|
|
45
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
} catch (err) {
|
|
@@ -69,10 +69,10 @@ export const main = middleware.wrap(async (event, context) => {
|
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
72
|
-
passOnProperties.push(record.body.Message)
|
|
72
|
+
passOnProperties.push(record.body.Message);
|
|
73
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
73
74
|
//(<additionalParams>)
|
|
74
75
|
//(</additionalParams>)
|
|
75
|
-
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
76
76
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
77
77
|
|
|
78
78
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
@@ -51,10 +51,10 @@ export const main = middleware.wrap(async (event, context) => {
|
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
54
|
-
passOnProperties.push(record.body.Message)
|
|
54
|
+
passOnProperties.push(record.body.Message);
|
|
55
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
55
56
|
//(<additionalParams>)
|
|
56
57
|
//(</additionalParams>)
|
|
57
|
-
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
58
58
|
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
59
59
|
|
|
60
60
|
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs
CHANGED
|
@@ -55,9 +55,9 @@ import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache
|
|
|
55
55
|
export default async function <%- functionName %> (
|
|
56
56
|
_izContext,
|
|
57
57
|
requestParams,
|
|
58
|
+
callingFlowConfig = {},
|
|
58
59
|
//(<additionalParams>)
|
|
59
60
|
//(</additionalParams>)
|
|
60
|
-
callingFlowConfig = {},
|
|
61
61
|
) {
|
|
62
62
|
|
|
63
63
|
try {
|
|
@@ -56,9 +56,9 @@ import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache
|
|
|
56
56
|
export default async function <%- functionName %> (
|
|
57
57
|
_izContext,
|
|
58
58
|
requestParams,
|
|
59
|
+
callingFlowConfig = {},
|
|
59
60
|
//(<additionalParams>)
|
|
60
61
|
//(</additionalParams>)
|
|
61
|
-
callingFlowConfig = {},
|
|
62
62
|
) {
|
|
63
63
|
|
|
64
64
|
try {
|
|
@@ -225,7 +225,7 @@ export default async function createObjectComplete(
|
|
|
225
225
|
await Promise.all(
|
|
226
226
|
recordAwaitingSteps.Items.map(async ({ pendingStepId }) => {
|
|
227
227
|
if (
|
|
228
|
-
await asyncFlowSharedLib.
|
|
228
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
229
229
|
_izContext,
|
|
230
230
|
pendingStepId,
|
|
231
231
|
awaitingStepId,
|
|
@@ -153,7 +153,7 @@ export default async function updateNodeComplete(
|
|
|
153
153
|
await Promise.all(
|
|
154
154
|
updateNodePendingObjects.Items.map(async ({ pendingStepId }) => {
|
|
155
155
|
if (
|
|
156
|
-
await asyncFlowSharedLib.
|
|
156
|
+
await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
|
|
157
157
|
_izContext,
|
|
158
158
|
pendingStepId,
|
|
159
159
|
awaitingStepId,
|
|
@@ -76,8 +76,7 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
|
|
|
76
76
|
}
|
|
77
77
|
<%_ } _%>
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
console.debug('identifiers:::: ', identifiers);
|
|
79
|
+
_izContext.logger.debug('identifiers:::: ', identifiers);
|
|
81
80
|
|
|
82
81
|
// ── Verify + remove awaitingStep ──────────────────────────────────────────
|
|
83
82
|
const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -90,9 +89,12 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
|
|
|
90
89
|
`beforeLogical_${requestParams.returnRequestParams.objectType}`
|
|
91
90
|
);
|
|
92
91
|
|
|
93
|
-
_izContext.logger.debug('createBeforeLogicalMain: checking awaitingStep', {
|
|
92
|
+
_izContext.logger.debug('createBeforeLogicalMain: checking awaitingStep', {
|
|
93
|
+
awaitingStepId,
|
|
94
|
+
pendingStepId
|
|
95
|
+
});
|
|
94
96
|
|
|
95
|
-
const [allComplete, collectedAttributes] =
|
|
97
|
+
const [allComplete, collectedAttributes, errorsFound] =
|
|
96
98
|
await asyncFlowSharedLib.syncAndCheckStepsCompletion(
|
|
97
99
|
_izContext,
|
|
98
100
|
pendingStepId,
|
|
@@ -103,6 +105,12 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
|
|
|
103
105
|
}
|
|
104
106
|
);
|
|
105
107
|
|
|
108
|
+
_izContext.logger.debug('validate step::: ', {
|
|
109
|
+
allComplete,
|
|
110
|
+
collectedAttributes,
|
|
111
|
+
errorsFound
|
|
112
|
+
});
|
|
113
|
+
|
|
106
114
|
if (allComplete === false) {
|
|
107
115
|
_izContext.logger.debug(
|
|
108
116
|
'createBeforeLogicalMain: pendingStepId not completed',
|
|
@@ -130,13 +138,13 @@ import { <%= action %>MainLogical } from './<%= functionName %>_Main.js';
|
|
|
130
138
|
//(<beforeLogicalMain>)
|
|
131
139
|
//(</beforeLogicalMain>)
|
|
132
140
|
|
|
133
|
-
return await
|
|
141
|
+
return await createMainLogical(
|
|
134
142
|
_izContext,
|
|
135
143
|
requestParams.returnRequestParams,
|
|
136
144
|
callingFlowConfig,
|
|
145
|
+
errorsFound,
|
|
137
146
|
beforeLogicalResults
|
|
138
147
|
);
|
|
139
|
-
|
|
140
148
|
} catch (err) {
|
|
141
149
|
throw err;
|
|
142
150
|
}
|
|
@@ -60,6 +60,7 @@ const PREFIX = {
|
|
|
60
60
|
_izContext,
|
|
61
61
|
requestParams,
|
|
62
62
|
callingFlowConfig = {},
|
|
63
|
+
errorsFound = [],
|
|
63
64
|
beforeLogicalResults = {}
|
|
64
65
|
) {
|
|
65
66
|
try {
|
|
@@ -69,7 +70,9 @@ const PREFIX = {
|
|
|
69
70
|
beforeLogicalResults
|
|
70
71
|
});
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
//(<beforeCreateMainLogical>)
|
|
74
|
+
//(</beforeCreateMainLogical>)
|
|
75
|
+
|
|
73
76
|
const objType = createObjType(requestParams.objectType);
|
|
74
77
|
|
|
75
78
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
@@ -443,6 +446,14 @@ export default async function createMain(
|
|
|
443
446
|
errorsFound.push(...errors);
|
|
444
447
|
_izContext.logger.debug('errorsFound::', errorsFound);
|
|
445
448
|
|
|
449
|
+
if (errorsFound.length > 0)
|
|
450
|
+
return await createMainLogical(
|
|
451
|
+
_izContext,
|
|
452
|
+
requestParams,
|
|
453
|
+
callingFlowConfig,
|
|
454
|
+
errorsFound
|
|
455
|
+
);
|
|
456
|
+
|
|
446
457
|
// ── Validate fieldNames ───────────────────────────────────────────────────
|
|
447
458
|
const objInstanceFull = { identifiers: {}, fields: {} };
|
|
448
459
|
|
|
@@ -468,7 +479,6 @@ export default async function createMain(
|
|
|
468
479
|
}
|
|
469
480
|
|
|
470
481
|
// ── beforeLogical phase check ─────────────────────────────────────────────
|
|
471
|
-
//(<beforeLogical>)
|
|
472
482
|
<%_
|
|
473
483
|
const groupedByObjType = generatedCodeConfig
|
|
474
484
|
.filter(c => c.codeHookTag === 'beforeLogical')
|
|
@@ -504,6 +514,9 @@ export default async function createMain(
|
|
|
504
514
|
|
|
505
515
|
<%_ } _%>
|
|
506
516
|
|
|
517
|
+
//(<afterBeforeLogical_<%= objectType %>>)
|
|
518
|
+
//(</afterBeforeLogical_<%= objectType %>>)
|
|
519
|
+
|
|
507
520
|
<%_ if (hasOwnTopic) { _%>
|
|
508
521
|
// ── ownTopic (async — create awaitingSteps and then publish) ──────────────
|
|
509
522
|
const awaitingMultipleStepIds = [];
|
|
@@ -565,6 +578,9 @@ export default async function createMain(
|
|
|
565
578
|
)
|
|
566
579
|
);
|
|
567
580
|
|
|
581
|
+
//(<beforePublish_<%= objectType %>>)
|
|
582
|
+
//(</beforePublish_<%= objectType %>>)
|
|
583
|
+
|
|
568
584
|
for (const recordMsg of recordMsgs) {
|
|
569
585
|
const messageAttributes = sns.createStringMessageAttributes(
|
|
570
586
|
_izContext,
|
|
@@ -604,7 +620,9 @@ export default async function createMain(
|
|
|
604
620
|
<%_ } _%>
|
|
605
621
|
}
|
|
606
622
|
<%_ }) _%>
|
|
607
|
-
|
|
623
|
+
|
|
624
|
+
//(<beforeCreateMainLogical>)
|
|
625
|
+
//(</beforeCreateMainLogical>)
|
|
608
626
|
|
|
609
627
|
// ── No beforeLogical → proceed directly to logical ────────────────────────
|
|
610
628
|
return await createMainLogical(
|
|
@@ -49,12 +49,15 @@ export async function deleteMainLogical(
|
|
|
49
49
|
_izContext,
|
|
50
50
|
requestParams,
|
|
51
51
|
callingFlowConfig = {},
|
|
52
|
+
errorsFound = [],
|
|
52
53
|
beforeLogicalResults = {}
|
|
53
54
|
) {
|
|
54
55
|
try {
|
|
55
56
|
_izContext.logger.debug('deleteMainLogical:', { requestParams, callingFlowConfig, beforeLogicalResults });
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
//(<beforeDeleteMainLogical>)
|
|
59
|
+
//(</beforeDeleteMainLogical>)
|
|
60
|
+
|
|
58
61
|
const objType = createObjType(requestParams.objectType);
|
|
59
62
|
|
|
60
63
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
@@ -159,6 +162,9 @@ export default async function deleteMain(
|
|
|
159
162
|
const errorsFound = [];
|
|
160
163
|
const objType = createObjType(requestParams.objectType);
|
|
161
164
|
|
|
165
|
+
//(<beforeDelete>)
|
|
166
|
+
//(</beforeDelete>)
|
|
167
|
+
|
|
162
168
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
163
169
|
const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
164
170
|
_izContext.logger.debug('objectSchema', objectSchema);
|
|
@@ -177,8 +183,15 @@ export default async function deleteMain(
|
|
|
177
183
|
// ── Build identifiers (used for hash in beforeLogical) ──────────────────
|
|
178
184
|
const identifiers = requestParams.identifiers;
|
|
179
185
|
|
|
186
|
+
if (errorsFound.length > 0)
|
|
187
|
+
return await createMainLogical(
|
|
188
|
+
_izContext,
|
|
189
|
+
requestParams,
|
|
190
|
+
callingFlowConfig,
|
|
191
|
+
errorsFound
|
|
192
|
+
);
|
|
193
|
+
|
|
180
194
|
// ── beforeLogical phase check ─────────────────────────────────────────────
|
|
181
|
-
//(<beforeLogical>)
|
|
182
195
|
<%_
|
|
183
196
|
const groupedByObjType = generatedCodeConfig
|
|
184
197
|
.filter(c => c.codeHookTag === 'beforeLogical')
|
|
@@ -211,9 +224,11 @@ export default async function deleteMain(
|
|
|
211
224
|
// lambdaSyncInv <%= config.flowTag %>
|
|
212
225
|
<%_ }) _%>
|
|
213
226
|
]);
|
|
214
|
-
|
|
215
227
|
<%_ } _%>
|
|
216
228
|
|
|
229
|
+
//(<afterBeforeLogical_<%= objectType %>>)
|
|
230
|
+
//(</afterBeforeLogical_<%= objectType %>>)
|
|
231
|
+
|
|
217
232
|
<%_ if (hasOwnTopic) { _%>
|
|
218
233
|
// ── ownTopic (async — create awaitingSteps and then publish) ──────────
|
|
219
234
|
const awaitingMultipleStepIds = [];
|
|
@@ -275,6 +290,9 @@ export default async function deleteMain(
|
|
|
275
290
|
)
|
|
276
291
|
);
|
|
277
292
|
|
|
293
|
+
//(<beforePublish_<%= objectType %>>)
|
|
294
|
+
//(</beforePublish_<%= objectType %>>)
|
|
295
|
+
|
|
278
296
|
for (const recordMsg of recordMsgs) {
|
|
279
297
|
const messageAttributes = sns.createStringMessageAttributes(
|
|
280
298
|
_izContext,
|
|
@@ -314,7 +332,9 @@ export default async function deleteMain(
|
|
|
314
332
|
<%_ } _%>
|
|
315
333
|
}
|
|
316
334
|
<%_ }) _%>
|
|
317
|
-
|
|
335
|
+
|
|
336
|
+
//(<beforeDeleteMainLogical>)
|
|
337
|
+
//(</beforeDeleteMainLogical>)
|
|
318
338
|
|
|
319
339
|
// ── No beforeLogical → proceed directly to logical ────────────────────────
|
|
320
340
|
return await deleteMainLogical(
|
|
@@ -53,17 +53,20 @@ export async function updateMainLogical(
|
|
|
53
53
|
_izContext,
|
|
54
54
|
requestParams,
|
|
55
55
|
callingFlowConfig = {},
|
|
56
|
+
errorsFound = [],
|
|
56
57
|
beforeLogicalResults = {}
|
|
57
58
|
) {
|
|
58
59
|
try {
|
|
59
60
|
_izContext.logger.debug('updateMainLogical:', { requestParams, callingFlowConfig, beforeLogicalResults });
|
|
60
61
|
|
|
62
|
+
//(<beforeUpdateMainLogical>)
|
|
63
|
+
//(</beforeUpdateMainLogical>)
|
|
64
|
+
|
|
61
65
|
// ── Settings ──────────────────────────────────────────────────────────────
|
|
62
66
|
const settings = requestParams.additionalParams?.settings ?? {};
|
|
63
67
|
const returnSystemFieldsName = settings.returnSystemFieldsName === true;
|
|
64
68
|
const returnOldData = settings.returnOldData === true;
|
|
65
69
|
|
|
66
|
-
const errorsFound = [];
|
|
67
70
|
const objType = createObjType(requestParams.objectType);
|
|
68
71
|
const identifiers = requestParams.objInstanceFull.identifiers;
|
|
69
72
|
const fields = requestParams.objInstanceFull.fields;
|
|
@@ -311,9 +314,20 @@ export default async function updateMain(
|
|
|
311
314
|
|
|
312
315
|
// ── Build identifiers (used for hash in beforeLogical) ──────────────────
|
|
313
316
|
const identifiers = requestParams.objInstanceFull.identifiers;
|
|
317
|
+
const errorsFound = [];
|
|
318
|
+
|
|
319
|
+
//(<validateBeforeUpdate>)
|
|
320
|
+
//(</validateBeforeUpdate>)
|
|
321
|
+
|
|
322
|
+
if (errorsFound.length > 0)
|
|
323
|
+
return await createMainLogical(
|
|
324
|
+
_izContext,
|
|
325
|
+
requestParams,
|
|
326
|
+
callingFlowConfig,
|
|
327
|
+
errorsFound
|
|
328
|
+
);
|
|
314
329
|
|
|
315
330
|
// ── beforeLogical phase check ─────────────────────────────────────────────
|
|
316
|
-
//(<beforeLogical>)
|
|
317
331
|
<%_
|
|
318
332
|
const groupedByObjType = generatedCodeConfig
|
|
319
333
|
.filter(c => c.codeHookTag === 'beforeLogical')
|
|
@@ -346,9 +360,11 @@ export default async function updateMain(
|
|
|
346
360
|
// lambdaSyncInv <%= config.flowTag %>
|
|
347
361
|
<%_ }) _%>
|
|
348
362
|
]);
|
|
349
|
-
|
|
350
363
|
<%_ } _%>
|
|
351
364
|
|
|
365
|
+
//(<afterBeforeLogical_<%= objectType %>>)
|
|
366
|
+
//(</afterBeforeLogical_<%= objectType %>>)
|
|
367
|
+
|
|
352
368
|
<%_ if (hasOwnTopic) { _%>
|
|
353
369
|
// ── ownTopic (async — create awaitingSteps and then publish) ──────────
|
|
354
370
|
const awaitingMultipleStepIds = [];
|
|
@@ -410,6 +426,9 @@ export default async function updateMain(
|
|
|
410
426
|
)
|
|
411
427
|
);
|
|
412
428
|
|
|
429
|
+
//(<beforePublish_<%= objectType %>>)
|
|
430
|
+
//(</beforePublish_<%= objectType %>>)
|
|
431
|
+
|
|
413
432
|
for (const recordMsg of recordMsgs) {
|
|
414
433
|
const messageAttributes = sns.createStringMessageAttributes(
|
|
415
434
|
_izContext,
|
|
@@ -449,7 +468,9 @@ export default async function updateMain(
|
|
|
449
468
|
<%_ } _%>
|
|
450
469
|
}
|
|
451
470
|
<%_ }) _%>
|
|
452
|
-
|
|
471
|
+
|
|
472
|
+
//(<beforeUpdateMainLogical>)
|
|
473
|
+
//(</beforeUpdateMainLogical>)
|
|
453
474
|
|
|
454
475
|
// ── No beforeLogical → proceed directly to logical ────────────────────────
|
|
455
476
|
return await updateMainLogical(
|
|
@@ -75,7 +75,7 @@ export default async function updateRelationshipComplete(
|
|
|
75
75
|
hash({
|
|
76
76
|
linkTypeId,
|
|
77
77
|
relId: returnValue.requestParams.relId,
|
|
78
|
-
relationshipProperties: returnValue.requestParams.
|
|
78
|
+
relationshipProperties: returnValue.requestParams.relationshipProperties
|
|
79
79
|
graphServiceTag: graphServiceTag
|
|
80
80
|
}), // hash id
|
|
81
81
|
PREFIX.updateRel // prefix, use constant further
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { join } from 'path';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
import libs from '#libs/Utils.js';
|
|
22
|
+
|
|
23
|
+
const { checkValidTableYaml } = libs;
|
|
24
|
+
import createSourceTranslations from './translations/data.js';
|
|
25
|
+
|
|
26
|
+
async function translationComponent(
|
|
27
|
+
_izContext,
|
|
28
|
+
appPath,
|
|
29
|
+
allObjSchemas,
|
|
30
|
+
allFlowSchemas
|
|
31
|
+
) {
|
|
32
|
+
try {
|
|
33
|
+
const objSchemaPath = join(appPath, '/src/schemas');
|
|
34
|
+
|
|
35
|
+
const createSources = [];
|
|
36
|
+
const translationComponent = await createSourceTranslations(
|
|
37
|
+
_izContext,
|
|
38
|
+
allObjSchemas,
|
|
39
|
+
allFlowSchemas,
|
|
40
|
+
objSchemaPath
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
console.log("translationComponent", translationComponent)
|
|
44
|
+
createSources.push(translationComponent);
|
|
45
|
+
|
|
46
|
+
return createSources;
|
|
47
|
+
|
|
48
|
+
} catch (error) {
|
|
49
|
+
_izContext.logger.error(
|
|
50
|
+
'Error generating code with template resourceYaml: ',
|
|
51
|
+
error
|
|
52
|
+
);
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default translationComponent;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import { fileURLToPath } from 'url';
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
|
|
23
|
+
import consts from '#libs/Consts.js';
|
|
24
|
+
import utils from '#libs/Utils.js';
|
|
25
|
+
|
|
26
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } =
|
|
27
|
+
utils;
|
|
28
|
+
const {
|
|
29
|
+
SOURCE_PATH,
|
|
30
|
+
SAVE_FILE_NAME,
|
|
31
|
+
} = consts;
|
|
32
|
+
|
|
33
|
+
const templatePath = path.join(__dirname, 'template.ejs');
|
|
34
|
+
|
|
35
|
+
import { utils as coreUtils } from '@izara_project/izara-core-library-service-schemas'
|
|
36
|
+
/**
|
|
37
|
+
* receive objectSchema
|
|
38
|
+
* create data for hdrInv template
|
|
39
|
+
*
|
|
40
|
+
* @return {{ templatePath, templateData, setting } }
|
|
41
|
+
*/
|
|
42
|
+
function createSourceTranslations(_izContext, allObjectSchema, allFlowSchemas, srcPath) {
|
|
43
|
+
const createSourceArray = [];
|
|
44
|
+
// console.log("params objSchema", JSON.stringify(allObjectSchema, null, 2));
|
|
45
|
+
for (const objectSchema of allObjectSchema.records) {
|
|
46
|
+
for (const fieldName of Object.keys(objectSchema.fieldNames)) {
|
|
47
|
+
const objType = {
|
|
48
|
+
objectType: objectSchema.objectType,
|
|
49
|
+
serviceTag: getLocalConfig('iz_serviceTag')
|
|
50
|
+
}
|
|
51
|
+
const translationTextObjSchemas = {
|
|
52
|
+
nameSpace: `${coreUtils.createObjTypeConcat(_izContext, objType)}_description`, // for each objectType
|
|
53
|
+
systemTextTag: `${fieldName}_${coreUtils.createObjTypeConcat(_izContext, objType)}` // for each fieldName
|
|
54
|
+
}
|
|
55
|
+
createSourceArray.push(translationTextObjSchemas)
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
for (const flowSchema of allFlowSchemas.records) {
|
|
60
|
+
const flowType = {
|
|
61
|
+
flowTag: flowSchema.flowTag,
|
|
62
|
+
serviceTag: getLocalConfig('iz_serviceTag')
|
|
63
|
+
}
|
|
64
|
+
const translationTextFlowSchemas = {
|
|
65
|
+
nameSpace: `${coreUtils.createFlowTypeConcat(_izContext, flowType)}`, // for each flowType
|
|
66
|
+
systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`
|
|
67
|
+
}
|
|
68
|
+
createSourceArray.push(translationTextFlowSchemas)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// console.log("createSourceArray", createSourceArray)
|
|
72
|
+
return {
|
|
73
|
+
templatePath: templatePath,
|
|
74
|
+
templateData: { datas: createSourceArray },
|
|
75
|
+
setting: {
|
|
76
|
+
savePath: path.join(srcPath, SOURCE_PATH.translationSchema),
|
|
77
|
+
saveFileName: SAVE_FILE_NAME.translationSchema,
|
|
78
|
+
fileExtension: '.js',
|
|
79
|
+
isAppend: true,
|
|
80
|
+
generateHookFile: false
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export default createSourceTranslations;
|
package/src/generateCode.js
CHANGED
|
@@ -37,6 +37,7 @@ import generateTemplateDataInitialSetup from './generateCode/generateInitialSetu
|
|
|
37
37
|
import generateTemplateDataOther from './generateCode/generateOther/generateCodeOther.js';
|
|
38
38
|
|
|
39
39
|
import generateTemplateDataRole from './generateCode/generateRole/generateCodeRole.js';
|
|
40
|
+
import generateTemplateTranslations from './generateCode/generateTranslation/generateTranslation.js';
|
|
40
41
|
|
|
41
42
|
const __filename = fileURLToPath(import.meta.url);
|
|
42
43
|
const __dirname = dirname(__filename);
|
|
@@ -92,7 +93,7 @@ async function generateCodeWithTemplate(
|
|
|
92
93
|
console.info('[INFO] [generateCode] STATUS=GENERATING| template data...');
|
|
93
94
|
_izContext.logger.info('[generateCode] generating template data...');
|
|
94
95
|
const genStartTime = Date.now();
|
|
95
|
-
const [flowSchemaResult, schemaResult, initialSetupResult, otherResult] =
|
|
96
|
+
const [flowSchemaResult, schemaResult, initialSetupResult, otherResult, translationResult] =
|
|
96
97
|
await Promise.all([
|
|
97
98
|
generateTemplateDataFromFlowSchema(
|
|
98
99
|
_izContext,
|
|
@@ -120,7 +121,8 @@ async function generateCodeWithTemplate(
|
|
|
120
121
|
allLocalFlowSchemas.records,
|
|
121
122
|
settings
|
|
122
123
|
),
|
|
123
|
-
generateTemplateDataOther(_izContext, appPath)
|
|
124
|
+
generateTemplateDataOther(_izContext, appPath),
|
|
125
|
+
generateTemplateTranslations(_izContext, appPath, allObjSchemas, allLocalFlowSchemas),
|
|
124
126
|
]);
|
|
125
127
|
|
|
126
128
|
const genDuration = Date.now() - genStartTime;
|
|
@@ -129,11 +131,14 @@ async function generateCodeWithTemplate(
|
|
|
129
131
|
`[INFO] [generateCode] STATUS=GENERATED | ${genStr.padEnd(40)} | elapsedMs=${genDuration}`
|
|
130
132
|
);
|
|
131
133
|
|
|
134
|
+
console.log(translationResult)
|
|
135
|
+
|
|
132
136
|
const allCreateSource = [
|
|
133
137
|
...flowSchemaResult,
|
|
134
138
|
...schemaResult,
|
|
135
139
|
...initialSetupResult,
|
|
136
|
-
...otherResult
|
|
140
|
+
...otherResult,
|
|
141
|
+
...translationResult
|
|
137
142
|
];
|
|
138
143
|
|
|
139
144
|
// ── 3. Generate role configs ─────────────────────────────────────────────
|
package/src/libs/Consts.js
CHANGED
|
@@ -91,7 +91,10 @@ const SOURCE_PATH = {
|
|
|
91
91
|
'src/generatedCode/ActionEndpoint/source/',
|
|
92
92
|
createRecordComplete: '/src/generatedCode/CreateRecordComplete/',
|
|
93
93
|
resourceLocationCreateRecordComplete:
|
|
94
|
-
'src/generatedCode/CreateRecordComplete/'
|
|
94
|
+
'src/generatedCode/CreateRecordComplete/',
|
|
95
|
+
|
|
96
|
+
// translations
|
|
97
|
+
translationSchema: 'translations/'
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
const SQS_RESOURCE = {
|
|
@@ -151,7 +154,8 @@ const SAVE_FILE_NAME = {
|
|
|
151
154
|
objectRelationship: 'ObjectRelationships',
|
|
152
155
|
refObjectRelationship: 'RefObjectRelationships',
|
|
153
156
|
objectSchema: 'ObjectFieldSchema',
|
|
154
|
-
roleNameConfig: 'RoleNameConfig'
|
|
157
|
+
roleNameConfig: 'RoleNameConfig',
|
|
158
|
+
translationSchema: 'TranslationsSchema'
|
|
155
159
|
};
|
|
156
160
|
|
|
157
161
|
const FUNCTION_NAME = {
|