@izara_project/izara-core-generate-service-code 1.0.27 → 1.0.29
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/ownTopicComponent/sns-in/sqsTemplate.ejs +2 -9
- package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +1 -1
- package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/sns/template.ejs +2 -9
- 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/changeRelationship/action/mainFunction/template.ejs +36 -12
- package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/action/mainFunction/template.ejs +10 -0
- package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/mainFunction/template.ejs +6 -6
- 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
|
@@ -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#>
|
|
@@ -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: {
|
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#>
|
|
@@ -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,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
|
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
19
|
|
|
22
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
@@ -124,10 +122,36 @@ export default async function <%- functionName %> (
|
|
|
124
122
|
//(<afterValidateChangeRel>)
|
|
125
123
|
//(</afterValidateChangeRel>)
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
_izContext
|
|
125
|
+
// check old relType canChangeToRelType
|
|
126
|
+
const oldRelationshipSchema = await getRelationshipSchemaWithCache(_izContext, oldRelTypeAndDirection.relType);
|
|
127
|
+
_izContext.logger.debug("oldRelationshipSchema ", oldRelationshipSchema);
|
|
128
|
+
|
|
129
|
+
const newRelationshipSchema = await getRelationshipSchemaWithCache(_izContext, newRelType);
|
|
130
|
+
_izContext.logger.debug("newRelationshipSchema: ", newRelationshipSchema);
|
|
131
|
+
if (!oldRelationshipSchema.hasOwnProperty('canChangeToRelTypes')) {
|
|
132
|
+
errorsFound.push(`${oldRelTypeAndDirection.relType} not have property to change to another relType`);
|
|
133
|
+
} else {
|
|
134
|
+
if (!newRelationshipSchema) {
|
|
135
|
+
errorsFound.push(`${newRelationshipSchema} not exists can't changeToRelType`);
|
|
136
|
+
} else {
|
|
137
|
+
oldRelationshipSchema.canChangeToRelTypes.find(canChangeToRelType => {
|
|
138
|
+
if (canChangeToRelType.relType.serviceTag === newRelType.serviceTag &&
|
|
139
|
+
canChangeToRelType.relType.relationshipTag === newRelType.relationshipTag) {
|
|
140
|
+
// check changeBy
|
|
141
|
+
if (canChangeToRelType.changeBy === "user") {
|
|
142
|
+
// if changeBy is user will check for importBatch callingFlow
|
|
143
|
+
if (callingFlowConfig) {
|
|
144
|
+
if (callingFlowConfig.callingFlow !== "ImportDataTestExternalUpdateRelationshipHdrSqs") {
|
|
145
|
+
errorsFound.push(`CanChangeToRelType changeBy is user but it's not user process with importData`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
};
|
|
129
153
|
|
|
130
|
-
const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType],
|
|
154
|
+
const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], newRelationshipSchema.links)
|
|
131
155
|
_izContext.logger.debug("links", links)
|
|
132
156
|
if (!links.length) {
|
|
133
157
|
errorsFound.push(`not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`)
|
|
@@ -147,8 +171,8 @@ export default async function <%- functionName %> (
|
|
|
147
171
|
const matchToFrom = fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
|
|
148
172
|
toServiceTag === firstServiceTag && toObjType === firstObjectType;
|
|
149
173
|
|
|
150
|
-
if ((
|
|
151
|
-
(
|
|
174
|
+
if ((newRelationshipSchema.relationshipDirection === "from" && matchFromTo) ||
|
|
175
|
+
(newRelationshipSchema.relationshipDirection === "to" && matchToFrom)) {
|
|
152
176
|
checkCorrectLink = true
|
|
153
177
|
break;
|
|
154
178
|
}
|
|
@@ -160,10 +184,10 @@ export default async function <%- functionName %> (
|
|
|
160
184
|
|
|
161
185
|
let targetStorageResources = [];
|
|
162
186
|
|
|
163
|
-
if (
|
|
187
|
+
if (newRelationshipSchema) {
|
|
164
188
|
// find targetStorageResources and validate each storageResources
|
|
165
189
|
await Promise.all(
|
|
166
|
-
|
|
190
|
+
newRelationshipSchema.links.map(async ({ from, to, storageResourceTags }) => {
|
|
167
191
|
const { serviceTag: fromServiceTag, objectType: fromObjectType } = from.objType
|
|
168
192
|
const { serviceTag: toServiceTag, objectType: toObjectType } = to.objType
|
|
169
193
|
|
|
@@ -184,7 +208,7 @@ export default async function <%- functionName %> (
|
|
|
184
208
|
|
|
185
209
|
// check founded storageResource of link and collect used storageResources
|
|
186
210
|
await Promise.all(storageResourceTags.map(async storageResourceTag => {
|
|
187
|
-
const usedStorageResource =
|
|
211
|
+
const usedStorageResource = newRelationshipSchema.storageResources[storageResourceTag];
|
|
188
212
|
|
|
189
213
|
if (usedStorageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
190
214
|
const graphServiceTag = await getGraphServiceTagWithCache(_izContext, usedStorageResource.graphServerTag);
|
|
@@ -213,8 +237,8 @@ export default async function <%- functionName %> (
|
|
|
213
237
|
|
|
214
238
|
|
|
215
239
|
// validate properties exists with schema
|
|
216
|
-
for (const propKey in oldRelTypeAndDirection.
|
|
217
|
-
if (!
|
|
240
|
+
for (const propKey in oldRelTypeAndDirection.fieldNames) {
|
|
241
|
+
if (!newRelationshipSchema.fieldNames.hasOwnProperty(propKey)) {
|
|
218
242
|
errorsFound.push(`property: ${propKey} not exists in relationshipSchema`);
|
|
219
243
|
}
|
|
220
244
|
}
|
|
@@ -128,6 +128,16 @@ export default async function <%- functionName %> (
|
|
|
128
128
|
const relationshipSchema = await getRelationshipSchemaWithCache(_izContext, relType);
|
|
129
129
|
_izContext.logger.debug("relationshipSchema: ", relationshipSchema);
|
|
130
130
|
|
|
131
|
+
if (!relationshipSchema.hasOwnProperty("moveBy") || relationshipSchema.moveBy === "none") {
|
|
132
|
+
errorsFound.push(`relationship: ${relType.relationshipTag} can't move`);
|
|
133
|
+
} else if (relationshipSchema.moveBy === "user") {
|
|
134
|
+
if (callingFlowConfig) {
|
|
135
|
+
if (callingFlowConfig.callingFlow !== "ImportDataTestExternalUpdateRelationshipHdrSqs") {
|
|
136
|
+
errorsFound.push(`moveBy is user but it's not user process with importData`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
131
141
|
const links = await findLinksByObjTypes(_izContext, [firstObject.objType, secondObject.objType], relationshipSchema.links)
|
|
132
142
|
_izContext.logger.debug("links", links)
|
|
133
143
|
if (!links.length) {
|
|
@@ -193,18 +193,18 @@ export default async function updateRelationship(
|
|
|
193
193
|
_izContext.logger.debug("propValue: ", propValue);
|
|
194
194
|
|
|
195
195
|
if (relationshipSchema.fieldNames[propKey]) {
|
|
196
|
-
if (relationshipSchema.fieldNames[propKey].
|
|
197
|
-
|
|
196
|
+
if (relationshipSchema.fieldNames[propKey].updateBy === "user") {
|
|
197
|
+
if (callingFlowConfig) {
|
|
198
|
+
if (callingFlowConfig.callingFlow !== "ImportDataTestExternalUpdateRelationshipHdrSqs") {
|
|
199
|
+
errorsFound.push(`property:${propKey} can update user but it's not user process with importData`)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
198
202
|
}
|
|
199
203
|
} else {
|
|
200
204
|
errorsFound.push(`property:${propKey} not exists in relationshipSchema`);
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
} else {
|
|
205
|
-
errorsFound.push(`relationshipSchema not exists`);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
208
|
|
|
209
209
|
// if found errors will stop processing
|
|
210
210
|
if (errorsFound.length) {
|
|
@@ -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
|