@izara_project/izara-core-generate-service-code 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/data.js +9 -2
- package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-in/sqsTemplate.ejs +2 -9
- package/src/generateCode/generateFlowSchema/flowStep/afterPluginHook/templateMain.ejs +7 -0
- package/src/generateCode/generateFlowSchema/flowStep/firstFlowStep/templateMain.ejs +7 -2
- package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +1 -1
- package/src/generateCode/generateFlowSchema/flowStep/noPlugInHook/templateMain.ejs +7 -2
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/sns/template.ejs +2 -9
- package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/template.ejs +1 -1
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +2 -5
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/get/template.ejs +109 -51
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/complete/mainFunction/template.ejs +1 -2
- package/src/generateCode/generateTranslation/generateTranslation.js +1 -3
- package/src/generateCode/generateTranslation/translations/data.js +22 -18
- package/src/generateCode.js +41 -33
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/Untitled +0 -1
package/package.json
CHANGED
package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/data.js
CHANGED
|
@@ -31,7 +31,7 @@ const { HANDLER, SOURCE_PATH, SAVE_FILE_NAME } = consts;
|
|
|
31
31
|
|
|
32
32
|
const { shortNameHandler, defaultIamRolePerAction } = libs;
|
|
33
33
|
|
|
34
|
-
const { firstLetterUpperCase: upperCase } = utils;
|
|
34
|
+
const { firstLetterUpperCase: upperCase, savePath } = utils;
|
|
35
35
|
|
|
36
36
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
37
37
|
|
|
@@ -54,7 +54,14 @@ function createSourceParamsApi(_izContext, flowSchema, appPath) {
|
|
|
54
54
|
return {
|
|
55
55
|
templatePath: templatePath,
|
|
56
56
|
templateData: {
|
|
57
|
-
|
|
57
|
+
resourceLocation:
|
|
58
|
+
// path.join(
|
|
59
|
+
// SOURCE_PATH.resourceLocationFlowSchema,
|
|
60
|
+
// upperCase(flowSchema.flowTag),
|
|
61
|
+
// 'MainHandler/',
|
|
62
|
+
// 'source/'
|
|
63
|
+
// ),
|
|
64
|
+
savePath.flowSchemaFlowTag(flowSchema.flowTag),
|
|
58
65
|
functionName,
|
|
59
66
|
handlerType,
|
|
60
67
|
additionalResourcePermission,
|
|
@@ -32,12 +32,5 @@
|
|
|
32
32
|
Action: "SQS:SendMessage"
|
|
33
33
|
Queues:
|
|
34
34
|
- Ref: <%- queueName %>
|
|
35
|
-
#<#<%-
|
|
36
|
-
#<#/<%-
|
|
37
|
-
|
|
38
|
-
<%_ function firstLetterUpperCase(text){
|
|
39
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
40
|
-
} _%>
|
|
41
|
-
<%_ function firstLetterLowerCase(str) {
|
|
42
|
-
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
43
|
-
} _%>
|
|
35
|
+
#<#<%- queueName %>QueueSetting#>
|
|
36
|
+
#<#/<%- queueName %>QueueSetting#>
|
|
@@ -24,6 +24,9 @@ import {
|
|
|
24
24
|
//(<optionalRequire>)
|
|
25
25
|
//(</optionalRequire>)
|
|
26
26
|
|
|
27
|
+
//(<helperFunctions>)
|
|
28
|
+
//(</helperFunctions>)
|
|
29
|
+
|
|
27
30
|
/**
|
|
28
31
|
* description of function.
|
|
29
32
|
* @param {Object} _izContext
|
|
@@ -81,6 +84,10 @@ export default async function <%- functionName %>Main (
|
|
|
81
84
|
return '<%- functionName %> completed successfully';
|
|
82
85
|
} catch (err) {
|
|
83
86
|
_izContext.logger.error('error <%- functionName %>: ', err);
|
|
87
|
+
|
|
88
|
+
//(<errorHandling>)
|
|
89
|
+
//(</errorHandling>)
|
|
90
|
+
|
|
84
91
|
throw (err);
|
|
85
92
|
}
|
|
86
93
|
}
|
|
@@ -21,6 +21,9 @@ import { handlePlugInHookTag } from '@izara_project/izara-core-library-plugin';
|
|
|
21
21
|
//(<optionalRequire>)
|
|
22
22
|
//(</optionalRequire>)
|
|
23
23
|
|
|
24
|
+
//(<helperFunctions>)
|
|
25
|
+
//(</helperFunctions>)
|
|
26
|
+
|
|
24
27
|
/**
|
|
25
28
|
* description of function.
|
|
26
29
|
* @param {Object} _izContext
|
|
@@ -30,10 +33,8 @@ import { handlePlugInHookTag } from '@izara_project/izara-core-library-plugin';
|
|
|
30
33
|
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
31
34
|
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
32
35
|
*
|
|
33
|
-
*
|
|
34
36
|
* @returns {object} description of return value
|
|
35
37
|
*/
|
|
36
|
-
|
|
37
38
|
export default async function <%- functionName %>Main (
|
|
38
39
|
_izContext,
|
|
39
40
|
requestParams,
|
|
@@ -85,6 +86,10 @@ export default async function <%- functionName %>Main (
|
|
|
85
86
|
return '<%- functionName %> completed successfully';
|
|
86
87
|
} catch (err) {
|
|
87
88
|
_izContext.logger.error('error <%- functionName %>: ', err)
|
|
89
|
+
|
|
90
|
+
//(<errorHandling>)
|
|
91
|
+
//(</errorHandling>)
|
|
92
|
+
|
|
88
93
|
throw (err)
|
|
89
94
|
}
|
|
90
95
|
}
|
|
@@ -405,7 +405,7 @@ function buildNoPluginHookResources(
|
|
|
405
405
|
templatePath: T.noPluginHook.resource,
|
|
406
406
|
templateData: {
|
|
407
407
|
queueName: `${upperCase(flowTag)}${upperCase(flowStepName)}`,
|
|
408
|
-
topicName: `${upperCase(flowTag)}_${upperCase(flowStepName)}`,
|
|
408
|
+
topicName: `${upperCase(flowTag)}_${upperCase(flowStepName)}_In`,
|
|
409
409
|
resourceName: upperCase(flowTag) + upperCase(flowStepName)
|
|
410
410
|
},
|
|
411
411
|
setting: {
|
|
@@ -19,6 +19,9 @@ along with this program. If not, see
|
|
|
19
19
|
//(<optionalRequire>)
|
|
20
20
|
//(</optionalRequire>)
|
|
21
21
|
|
|
22
|
+
//(<helperFunctions>)
|
|
23
|
+
//(</helperFunctions>)
|
|
24
|
+
|
|
22
25
|
/**
|
|
23
26
|
* description of function.
|
|
24
27
|
* @param {Object} _izContext
|
|
@@ -28,10 +31,8 @@ along with this program. If not, see
|
|
|
28
31
|
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
29
32
|
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
34
|
* @returns {object} description of return value
|
|
33
35
|
*/
|
|
34
|
-
|
|
35
36
|
export default async function <%- functionName %> (
|
|
36
37
|
_izContext,
|
|
37
38
|
requestParams,
|
|
@@ -49,6 +50,10 @@ export default async function <%- functionName %> (
|
|
|
49
50
|
|
|
50
51
|
} catch (err) {
|
|
51
52
|
_izContext.logger.error('error <%- functionName %>: ', err)
|
|
53
|
+
|
|
54
|
+
//(<errorHandling>)
|
|
55
|
+
//(</errorHandling>)
|
|
56
|
+
|
|
52
57
|
throw (err)
|
|
53
58
|
}
|
|
54
59
|
}
|
package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/sns/template.ejs
CHANGED
|
@@ -48,12 +48,5 @@
|
|
|
48
48
|
Action: "SQS:SendMessage"
|
|
49
49
|
Queues:
|
|
50
50
|
- Ref: <%- queueName %>HdrSqs
|
|
51
|
-
#<#<%-
|
|
52
|
-
#<#/<%-
|
|
53
|
-
|
|
54
|
-
<%_ function firstLetterUpperCase(text){
|
|
55
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
56
|
-
} _%>
|
|
57
|
-
<%_ function firstLetterLowerCase(str) {
|
|
58
|
-
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
59
|
-
} _%>
|
|
51
|
+
#<#<%- queueName %>QueueSetting#>
|
|
52
|
+
#<#/<%- queueName %>QueueSetting#>
|
package/src/generateCode/generateInitialSetup/externalServiceComponent/lambdaRole/template.ejs
CHANGED
|
@@ -22,7 +22,7 @@ import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
|
22
22
|
const _izContext = { logger: Logger }
|
|
23
23
|
|
|
24
24
|
export function generatedLambdaRole() {
|
|
25
|
-
|
|
25
|
+
const externalLambdaRole = [ <%_ datas.forEach((data,dataIndex) => { %>
|
|
26
26
|
{
|
|
27
27
|
roleName: "<%- data.objectType %>",
|
|
28
28
|
statement: [
|
|
@@ -22,13 +22,10 @@ import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
|
22
22
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
23
23
|
import _ from 'lodash';
|
|
24
24
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
errors,
|
|
28
|
-
} from '@izara_project/izara-core-library-service-schemas';
|
|
25
|
+
import { consts } from '@izara_project/izara-core-library-service-schemas';
|
|
26
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
29
27
|
|
|
30
28
|
const { TOPIC_NAME_GENERATE_CODE } = consts;
|
|
31
|
-
const { NoRetryError } = errors;
|
|
32
29
|
const PREFIX = {
|
|
33
30
|
CREATE_OBJECT_ASYNC: 'createObjectAsync',
|
|
34
31
|
CREATE_OBJECT_ASYNC_COMPLETE: 'createObjectAsyncComplete',
|
package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/get/template.ejs
CHANGED
|
@@ -17,10 +17,18 @@ along with this program. If not, see
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
// ==================== Izara Core Service Schemas ====================
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
getObjectSchema,
|
|
22
|
+
serviceConfig,
|
|
23
|
+
consts,
|
|
24
|
+
identifiersObject,
|
|
25
|
+
utils,
|
|
26
|
+
dataDetailsLib
|
|
27
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
21
28
|
const { getObjSchemaS3WithHierarchy } = getObjectSchema;
|
|
22
29
|
const { getGraphServiceTagWithCache } = serviceConfig;
|
|
23
|
-
const { objInstanceFromObjInstanceBase, dynamoDbIdentifiersByStorageResource } =
|
|
30
|
+
const { objInstanceFromObjInstanceBase, dynamoDbIdentifiersByStorageResource } =
|
|
31
|
+
identifiersObject;
|
|
24
32
|
const { createObjType } = utils;
|
|
25
33
|
const { collectGetData, createGetDataDetails } = dataDetailsLib;
|
|
26
34
|
const { TOPIC_NAME_GENERATE_CODE } = consts;
|
|
@@ -55,30 +63,34 @@ export default async function getMain(
|
|
|
55
63
|
//(</additionalParams>)
|
|
56
64
|
) {
|
|
57
65
|
try {
|
|
58
|
-
_izContext.logger.debug('function GetMain:', {
|
|
66
|
+
_izContext.logger.debug('function GetMain:', {
|
|
67
|
+
requestParams,
|
|
68
|
+
callingFlowConfig
|
|
69
|
+
});
|
|
59
70
|
|
|
60
71
|
// ── Settings ──────────────────────────────────────────────────────────────
|
|
61
72
|
const settings = requestParams.additionalParams?.settings ?? {};
|
|
62
|
-
const returnSystemFieldsName
|
|
63
|
-
const throwWhenNotFoundSomeRecord
|
|
64
|
-
|
|
73
|
+
const returnSystemFieldsName = settings.returnSystemFieldsName === true;
|
|
74
|
+
const throwWhenNotFoundSomeRecord =
|
|
75
|
+
settings.throwWhenNotFoundSomeRecord !== false;
|
|
76
|
+
const returnVersionedData = settings.returnVersionedData !== false;
|
|
65
77
|
|
|
66
78
|
//(<beforeQuery>)
|
|
67
79
|
//(</beforeQuery>)
|
|
68
80
|
|
|
69
|
-
const
|
|
70
|
-
const objType = createObjType(requestParams.objectType);
|
|
81
|
+
const objType = createObjType(requestParams.objectType);
|
|
71
82
|
|
|
72
83
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
73
84
|
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|
|
74
85
|
_izContext.logger.debug('objectSchema:', objectSchema);
|
|
75
86
|
|
|
76
|
-
// ──
|
|
87
|
+
// ── Validate user context ─────────────────────────────────────────────────
|
|
77
88
|
if (objectSchema.generatedBy === 'userGenerated') {
|
|
78
|
-
const userId
|
|
89
|
+
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
|
|
79
90
|
const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
|
|
80
|
-
if (!userId)
|
|
81
|
-
if (objectSchema.hasOwnProperty('belongTo') && !targetId)
|
|
91
|
+
if (!userId) throw new Error('Not have userId');
|
|
92
|
+
if (objectSchema.hasOwnProperty('belongTo') && !targetId)
|
|
93
|
+
throw new Error('not have targetId');
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
// ── Build getDataDetails ──────────────────────────────────────────────────
|
|
@@ -87,17 +99,21 @@ export default async function getMain(
|
|
|
87
99
|
|
|
88
100
|
// ── Process storage resources ─────────────────────────────────────────────
|
|
89
101
|
const getResults = [];
|
|
90
|
-
const
|
|
102
|
+
const recordStatus = { foundAtLeastOne: false, missingAtLeastOne: false };
|
|
103
|
+
let lastObjInstanceFull = undefined;
|
|
91
104
|
|
|
92
105
|
await Promise.all(
|
|
93
|
-
Object.entries(getDataDetails).map(async ([
|
|
94
|
-
|
|
106
|
+
Object.entries(getDataDetails).map(async ([, getDataDetail]) => {
|
|
95
107
|
// ── Graph ─────────────────────────────────────────────────────────────
|
|
96
108
|
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
97
|
-
const graphServiceName
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
const graphServiceName = await getGraphServiceTagWithCache(
|
|
110
|
+
_izContext,
|
|
111
|
+
getDataDetail.graphServiceTag
|
|
112
|
+
);
|
|
113
|
+
const versionedDataLabels =
|
|
114
|
+
returnVersionedData && getDataDetail.versionedDatas
|
|
115
|
+
? Object.keys(getDataDetail.versionedDatas)
|
|
116
|
+
: [];
|
|
101
117
|
|
|
102
118
|
//(<beforeGetGraph>)
|
|
103
119
|
//(</beforeGetGraph>)
|
|
@@ -113,9 +129,12 @@ export default async function getMain(
|
|
|
113
129
|
_izContext.logger.debug('dataFromGraphV2:', dataFromGraph);
|
|
114
130
|
|
|
115
131
|
if (Object.keys(dataFromGraph).length) {
|
|
116
|
-
|
|
132
|
+
recordStatus.foundAtLeastOne = true;
|
|
133
|
+
lastObjInstanceFull =
|
|
134
|
+
dataFromGraph.returnValue?.queryResults?.refactoredNodes
|
|
135
|
+
?.objInstanceFull;
|
|
117
136
|
} else {
|
|
118
|
-
|
|
137
|
+
recordStatus.missingAtLeastOne = true;
|
|
119
138
|
}
|
|
120
139
|
|
|
121
140
|
//(<afterGetGraph>)
|
|
@@ -123,46 +142,45 @@ export default async function getMain(
|
|
|
123
142
|
|
|
124
143
|
getResults.push([dataFromGraph, getDataDetail]);
|
|
125
144
|
|
|
126
|
-
|
|
127
|
-
_izContext.logger.debug('HAVE CallingFlow');
|
|
128
|
-
const messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
129
|
-
callingFlowConfig,
|
|
130
|
-
{ objType, objInstanceFull: dataFromGraph.returnValue.queryResults.refactoredNodes.objInstanceFull }
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
_izContext.logger.debug('messageParams OutGetNode:::', messageObject);
|
|
134
|
-
await sns.publishAsync(_izContext, {
|
|
135
|
-
Message: JSON.stringify(messageObject),
|
|
136
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
137
|
-
_izContext,
|
|
138
|
-
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {})
|
|
139
|
-
),
|
|
140
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outGetNodeComplete)
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// ── DynamoDB ──────────────────────────────────────────────────────────
|
|
145
|
+
// ── DynamoDB ──────────────────────────────────────────────────────────
|
|
145
146
|
} else {
|
|
146
|
-
const identifiersForGetData =
|
|
147
|
-
|
|
147
|
+
const identifiersForGetData =
|
|
148
|
+
await dynamoDbIdentifiersByStorageResource(
|
|
149
|
+
_izContext,
|
|
150
|
+
objectSchema,
|
|
151
|
+
getDataDetail,
|
|
152
|
+
requestParams.identifiers
|
|
153
|
+
);
|
|
154
|
+
_izContext.logger.debug(
|
|
155
|
+
'identifiersForGetData:',
|
|
156
|
+
identifiersForGetData
|
|
148
157
|
);
|
|
149
|
-
_izContext.logger.debug('identifiersForGetData:', identifiersForGetData);
|
|
150
158
|
|
|
151
159
|
//(<beforeGetDynamoDb>)
|
|
152
160
|
//(</beforeGetDynamoDb>)
|
|
153
161
|
|
|
162
|
+
const tableName = await dynamodbSharedLib.tableName(
|
|
163
|
+
_izContext,
|
|
164
|
+
getDataDetail.tableName,
|
|
165
|
+
getDataDetail.serviceTag
|
|
166
|
+
);
|
|
154
167
|
let dataFromDynamoDb = await dynamodbSharedLib.getItem(
|
|
155
168
|
_izContext,
|
|
156
|
-
|
|
169
|
+
tableName,
|
|
157
170
|
identifiersForGetData
|
|
158
171
|
);
|
|
159
172
|
_izContext.logger.debug('dataFromDynamoDb:', dataFromDynamoDb);
|
|
160
173
|
|
|
161
174
|
if (dataFromDynamoDb) {
|
|
162
|
-
dataFromDynamoDb = await objInstanceFromObjInstanceBase(
|
|
163
|
-
|
|
175
|
+
dataFromDynamoDb = await objInstanceFromObjInstanceBase(
|
|
176
|
+
_izContext,
|
|
177
|
+
objType,
|
|
178
|
+
dataFromDynamoDb
|
|
179
|
+
);
|
|
180
|
+
recordStatus.foundAtLeastOne = true;
|
|
181
|
+
lastObjInstanceFull = dataFromDynamoDb;
|
|
164
182
|
} else {
|
|
165
|
-
|
|
183
|
+
recordStatus.missingAtLeastOne = true;
|
|
166
184
|
}
|
|
167
185
|
|
|
168
186
|
//(<afterGetDynamoDb>)
|
|
@@ -173,16 +191,56 @@ export default async function getMain(
|
|
|
173
191
|
})
|
|
174
192
|
);
|
|
175
193
|
|
|
176
|
-
_izContext.logger.debug('
|
|
194
|
+
_izContext.logger.debug('recordStatus:', recordStatus);
|
|
177
195
|
|
|
178
|
-
if (
|
|
196
|
+
if (
|
|
197
|
+
throwWhenNotFoundSomeRecord &&
|
|
198
|
+
recordStatus.foundAtLeastOne &&
|
|
199
|
+
recordStatus.missingAtLeastOne
|
|
200
|
+
) {
|
|
179
201
|
throw new Error('Not found some record while get data');
|
|
180
202
|
}
|
|
181
203
|
|
|
182
|
-
|
|
204
|
+
// ── Notify calling flow (once, after all storage resources complete) ───────
|
|
205
|
+
if (
|
|
206
|
+
callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
|
|
207
|
+
) {
|
|
208
|
+
_izContext.logger.debug('HAVE CallingFlow');
|
|
209
|
+
|
|
210
|
+
const messageObject =
|
|
211
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
212
|
+
callingFlowConfig,
|
|
213
|
+
{ objType, objInstanceFull: lastObjInstanceFull }
|
|
214
|
+
);
|
|
215
|
+
const messageAttributes =
|
|
216
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
217
|
+
callingFlowConfig,
|
|
218
|
+
{}
|
|
219
|
+
);
|
|
220
|
+
const topicArn = await snsSharedLib.snsTopicArnByFlowSchema(
|
|
221
|
+
_izContext,
|
|
222
|
+
TOPIC_NAME_GENERATE_CODE.outGetNodeComplete
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
_izContext.logger.debug('messageParams OutGetNode:', messageObject);
|
|
226
|
+
await sns.publishAsync(_izContext, {
|
|
227
|
+
Message: JSON.stringify(messageObject),
|
|
228
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
229
|
+
_izContext,
|
|
230
|
+
messageAttributes
|
|
231
|
+
),
|
|
232
|
+
TopicArn: topicArn
|
|
233
|
+
});
|
|
234
|
+
}
|
|
183
235
|
|
|
236
|
+
return collectGetData(
|
|
237
|
+
_izContext,
|
|
238
|
+
getResults,
|
|
239
|
+
objectSchema,
|
|
240
|
+
returnSystemFieldsName
|
|
241
|
+
);
|
|
184
242
|
} catch (err) {
|
|
185
243
|
_izContext.logger.error('error GetMain:', err);
|
|
186
244
|
throw err;
|
|
187
245
|
}
|
|
188
|
-
}
|
|
246
|
+
}
|
|
@@ -15,7 +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
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';
|
|
@@ -75,7 +74,7 @@ export default async function updateRelationshipComplete(
|
|
|
75
74
|
hash({
|
|
76
75
|
linkTypeId,
|
|
77
76
|
relId: returnValue.requestParams.relId,
|
|
78
|
-
relationshipProperties: returnValue.requestParams.relationshipProperties
|
|
77
|
+
relationshipProperties: returnValue.requestParams.relationshipProperties,
|
|
79
78
|
graphServiceTag: graphServiceTag
|
|
80
79
|
}), // hash id
|
|
81
80
|
PREFIX.updateRel // prefix, use constant further
|
|
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
import { join } from 'path';
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
import libs from '#libs/Utils.js';
|
|
22
21
|
|
|
23
22
|
const { checkValidTableYaml } = libs;
|
|
@@ -40,11 +39,10 @@ async function translationComponent(
|
|
|
40
39
|
objSchemaPath
|
|
41
40
|
);
|
|
42
41
|
|
|
43
|
-
console.log(
|
|
42
|
+
// console.log('translationComponent', translationComponent);
|
|
44
43
|
createSources.push(translationComponent);
|
|
45
44
|
|
|
46
45
|
return createSources;
|
|
47
|
-
|
|
48
46
|
} catch (error) {
|
|
49
47
|
_izContext.logger.error(
|
|
50
48
|
'Error generating code with template resourceYaml: ',
|
|
@@ -23,23 +23,29 @@ const __dirname = path.dirname(__filename);
|
|
|
23
23
|
import consts from '#libs/Consts.js';
|
|
24
24
|
import utils from '#libs/Utils.js';
|
|
25
25
|
|
|
26
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } =
|
|
27
|
-
utils;
|
|
28
26
|
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
firstLetterLowerCase: lowerCase,
|
|
28
|
+
firstLetterUpperCase: upperCase,
|
|
29
|
+
getLocalConfig
|
|
30
|
+
} = utils;
|
|
31
|
+
const { SOURCE_PATH, SAVE_FILE_NAME } = consts;
|
|
32
32
|
|
|
33
33
|
const templatePath = path.join(__dirname, 'template.ejs');
|
|
34
34
|
|
|
35
|
-
import { utils as coreUtils } from '@izara_project/izara-core-library-service-schemas'
|
|
35
|
+
import { utils as coreUtils } from '@izara_project/izara-core-library-service-schemas';
|
|
36
|
+
|
|
36
37
|
/**
|
|
37
38
|
* receive objectSchema
|
|
38
39
|
* create data for hdrInv template
|
|
39
40
|
*
|
|
40
41
|
* @return {{ templatePath, templateData, setting } }
|
|
41
42
|
*/
|
|
42
|
-
function createSourceTranslations(
|
|
43
|
+
function createSourceTranslations(
|
|
44
|
+
_izContext,
|
|
45
|
+
allObjectSchema,
|
|
46
|
+
allFlowSchemas,
|
|
47
|
+
schemaPath
|
|
48
|
+
) {
|
|
43
49
|
const createSourceArray = [];
|
|
44
50
|
// console.log("params objSchema", JSON.stringify(allObjectSchema, null, 2));
|
|
45
51
|
for (const objectSchema of allObjectSchema.records) {
|
|
@@ -47,25 +53,25 @@ function createSourceTranslations(_izContext, allObjectSchema, allFlowSchemas, s
|
|
|
47
53
|
const objType = {
|
|
48
54
|
objectType: objectSchema.objectType,
|
|
49
55
|
serviceTag: getLocalConfig('iz_serviceTag')
|
|
50
|
-
}
|
|
56
|
+
};
|
|
51
57
|
const translationTextObjSchemas = {
|
|
52
58
|
nameSpace: `${coreUtils.createObjTypeConcat(_izContext, objType)}_description`, // for each objectType
|
|
53
59
|
systemTextTag: `${fieldName}_${coreUtils.createObjTypeConcat(_izContext, objType)}` // for each fieldName
|
|
54
|
-
}
|
|
55
|
-
createSourceArray.push(translationTextObjSchemas)
|
|
60
|
+
};
|
|
61
|
+
createSourceArray.push(translationTextObjSchemas);
|
|
56
62
|
}
|
|
57
|
-
}
|
|
63
|
+
}
|
|
58
64
|
|
|
59
65
|
for (const flowSchema of allFlowSchemas.records) {
|
|
60
66
|
const flowType = {
|
|
61
67
|
flowTag: flowSchema.flowTag,
|
|
62
68
|
serviceTag: getLocalConfig('iz_serviceTag')
|
|
63
|
-
}
|
|
69
|
+
};
|
|
64
70
|
const translationTextFlowSchemas = {
|
|
65
71
|
nameSpace: `${coreUtils.createFlowTypeConcat(_izContext, flowType)}`, // for each flowType
|
|
66
72
|
systemTextTag: `errors_${coreUtils.createFlowTypeConcat(_izContext, flowType)}`
|
|
67
|
-
}
|
|
68
|
-
createSourceArray.push(translationTextFlowSchemas)
|
|
73
|
+
};
|
|
74
|
+
createSourceArray.push(translationTextFlowSchemas);
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
// console.log("createSourceArray", createSourceArray)
|
|
@@ -73,15 +79,13 @@ function createSourceTranslations(_izContext, allObjectSchema, allFlowSchemas, s
|
|
|
73
79
|
templatePath: templatePath,
|
|
74
80
|
templateData: { datas: createSourceArray },
|
|
75
81
|
setting: {
|
|
76
|
-
savePath: path.join(
|
|
82
|
+
savePath: path.join(schemaPath, SOURCE_PATH.translationSchema),
|
|
77
83
|
saveFileName: SAVE_FILE_NAME.translationSchema,
|
|
78
84
|
fileExtension: '.js',
|
|
79
85
|
isAppend: true,
|
|
80
86
|
generateHookFile: false
|
|
81
87
|
}
|
|
82
88
|
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
}
|
|
86
90
|
|
|
87
91
|
export default createSourceTranslations;
|
package/src/generateCode.js
CHANGED
|
@@ -93,37 +93,47 @@ async function generateCodeWithTemplate(
|
|
|
93
93
|
console.info('[INFO] [generateCode] STATUS=GENERATING| template data...');
|
|
94
94
|
_izContext.logger.info('[generateCode] generating template data...');
|
|
95
95
|
const genStartTime = Date.now();
|
|
96
|
-
const [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
96
|
+
const [
|
|
97
|
+
flowSchemaResult,
|
|
98
|
+
schemaResult,
|
|
99
|
+
initialSetupResult,
|
|
100
|
+
otherResult,
|
|
101
|
+
translationResult
|
|
102
|
+
] = await Promise.all([
|
|
103
|
+
generateTemplateDataFromFlowSchema(
|
|
104
|
+
_izContext,
|
|
105
|
+
appPath,
|
|
106
|
+
allLocalFlowSchemas.records,
|
|
107
|
+
settings
|
|
108
|
+
),
|
|
109
|
+
generateTemplateDataFromSchema(
|
|
110
|
+
_izContext,
|
|
111
|
+
appPath,
|
|
112
|
+
allObjSchemas,
|
|
113
|
+
allLocalRelationshipSchemas,
|
|
114
|
+
allLocalFlowSchemas.records,
|
|
115
|
+
settings
|
|
116
|
+
).catch(error => {
|
|
117
|
+
console.error('[generateCode] schemaResult error:', error);
|
|
118
|
+
_izContext.logger.error('[generateCode] schemaResult error:', error);
|
|
119
|
+
return [];
|
|
120
|
+
}),
|
|
121
|
+
generateTemplateDataInitialSetup(
|
|
122
|
+
_izContext,
|
|
123
|
+
appPath,
|
|
124
|
+
allObjSchemas.records,
|
|
125
|
+
allLocalRelationshipSchemas,
|
|
126
|
+
allLocalFlowSchemas.records,
|
|
127
|
+
settings
|
|
128
|
+
),
|
|
129
|
+
generateTemplateDataOther(_izContext, appPath),
|
|
130
|
+
generateTemplateTranslations(
|
|
131
|
+
_izContext,
|
|
132
|
+
appPath,
|
|
133
|
+
allObjSchemas,
|
|
134
|
+
allLocalFlowSchemas
|
|
135
|
+
)
|
|
136
|
+
]);
|
|
127
137
|
|
|
128
138
|
const genDuration = Date.now() - genStartTime;
|
|
129
139
|
const genStr = `flow=${flowSchemaResult.length} sch=${schemaResult.length} setup=${initialSetupResult.length} other=${otherResult.length}`;
|
|
@@ -131,8 +141,6 @@ async function generateCodeWithTemplate(
|
|
|
131
141
|
`[INFO] [generateCode] STATUS=GENERATED | ${genStr.padEnd(40)} | elapsedMs=${genDuration}`
|
|
132
142
|
);
|
|
133
143
|
|
|
134
|
-
console.log(translationResult)
|
|
135
|
-
|
|
136
144
|
const allCreateSource = [
|
|
137
145
|
...flowSchemaResult,
|
|
138
146
|
...schemaResult,
|
package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/Untitled
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
createObjectComplete
|