@izara_project/izara-core-generate-service-code 1.0.28 → 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/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/package.json
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
|
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) {
|