@izara_project/izara-core-library-service-schemas 1.0.100 → 1.0.102
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/index.js +37 -19
- package/package.json +15 -15
- package/src/Consts.js +12 -12
- package/src/GetObjectSchema.js +66 -112
- package/src/IdentifiersObject.js +24 -24
- package/src/ServiceConfig.js +11 -16
- package/src/SharedUtils.js +26 -34
- package/src/UploadObjSchema.js +55 -103
- package/src/Utils.js +25 -46
- package/src/ValidatorSchema.js +58 -96
- package/src/libs/CreateNodeLib.js +12 -14
- package/src/libs/DeliminatorTree.js +6 -6
- package/src/libs/ExplodedReqParams.js +3 -3
- package/src/libs/LambdaUtils.js +2 -4
- package/src/libs/RelSchemaLib.js +9 -12
- package/src/libs/SharedUtilsLibs.js +1 -1
- package/src/libs/UploadUseCase.js +12 -27
- package/src/libs/s3Utils.js +11 -11
|
@@ -16,16 +16,15 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const { getObjTypeHierarchy } = require('../GetObjectSchema')
|
|
19
|
+
import utils from '../Utils.js';
|
|
20
|
+
import getObjectSchema from '../GetObjectSchema.js';
|
|
21
|
+
import serviceConfig from '../ServiceConfig.js';
|
|
22
|
+
import consts from '../Consts.js';
|
|
24
23
|
|
|
25
24
|
async function validateRequiredOnCreateLinks(_izContext, objType, relationships = [], settings = {}) {
|
|
26
25
|
_izContext.logger.debug("validateRequiredOnCreateLinks:::", { objType, relationships, settings })
|
|
27
26
|
|
|
28
|
-
let objectHie = await getObjTypeHierarchy(_izContext, objType).then(objSchema => {
|
|
27
|
+
let objectHie = await getObjectSchema.getObjTypeHierarchy(_izContext, objType).then(objSchema => {
|
|
29
28
|
if (objSchema.errorsFound.length > 0) {
|
|
30
29
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
31
30
|
} else {
|
|
@@ -35,7 +34,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
35
34
|
_izContext.logger.debug("objectHierarchy::", objectHie)
|
|
36
35
|
|
|
37
36
|
if (relationships.length) {
|
|
38
|
-
let targetHierarchy = await getObjTypeHierarchy(_izContext, relationships[0].targetObjType).then(objSchema => {
|
|
37
|
+
let targetHierarchy = await getObjectSchema.getObjTypeHierarchy(_izContext, relationships[0].targetObjType).then(objSchema => {
|
|
39
38
|
if (objSchema.errorsFound.length > 0) {
|
|
40
39
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
41
40
|
} else {
|
|
@@ -62,7 +61,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
62
61
|
const serviceTags = await Promise.all(
|
|
63
62
|
requiredOnCreateLink.storageResourceTags.map(async (storageTag) => {
|
|
64
63
|
let storageResource = requiredOnCreateLink.storageResources[storageTag];
|
|
65
|
-
if (storageResource.storageType === STORAGE_TYPES.graph) {
|
|
64
|
+
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
66
65
|
return await serviceConfig.getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag)
|
|
67
66
|
}
|
|
68
67
|
})
|
|
@@ -84,7 +83,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
84
83
|
_izContext.logger.debug("start validate relationship from requestParams")
|
|
85
84
|
for (const relationship of relationships) {
|
|
86
85
|
// validate all relationship in requestParams
|
|
87
|
-
let relTypeConcat = createRelTypeConcat(_izContext, relationship.relType)
|
|
86
|
+
let relTypeConcat = utils.createRelTypeConcat(_izContext, relationship.relType)
|
|
88
87
|
|
|
89
88
|
if (!requiredOnCreateLinkGroups[relTypeConcat]) {
|
|
90
89
|
errorsFound.push(`cannot create relationship ${relTypeConcat}`)
|
|
@@ -101,7 +100,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
101
100
|
|
|
102
101
|
for (let link of usedLinkGroup) {
|
|
103
102
|
// check other with targetObjType, check linkType of other should be 'one',
|
|
104
|
-
let targetObjTypeHierarchy = await getObjTypeHierarchy(_izContext, relationship.targetObjType).then(objSchema => {
|
|
103
|
+
let targetObjTypeHierarchy = await getObjectSchema.getObjTypeHierarchy(_izContext, relationship.targetObjType).then(objSchema => {
|
|
105
104
|
if (objSchema.errorsFound.length > 0) {
|
|
106
105
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
107
106
|
} else {
|
|
@@ -144,7 +143,7 @@ async function validateRequiredOnCreateLinks(_izContext, objType, relationships
|
|
|
144
143
|
function groupRequiredOnCreateLink(_izContext, relationshipSchemas) {
|
|
145
144
|
let groupLink = {};
|
|
146
145
|
for (let relationshipSchema of relationshipSchemas) {
|
|
147
|
-
let relTypeConcat = createRelTypeConcat(_izContext, relationshipSchema.relType);
|
|
146
|
+
let relTypeConcat = utils.createRelTypeConcat(_izContext, relationshipSchema.relType);
|
|
148
147
|
if (!groupLink.hasOwnProperty(relTypeConcat)) {
|
|
149
148
|
Object.assign(groupLink, {
|
|
150
149
|
[relTypeConcat]: {
|
|
@@ -184,10 +183,9 @@ function createLinkTypeIdFromLinkGroup(_izContext, linkGroup) {
|
|
|
184
183
|
let linkTypeIds = new Set();
|
|
185
184
|
for (const objectRelationshipGroup of Object.values(linkGroup)) {
|
|
186
185
|
for (const direction of Object.keys(objectRelationshipGroup)) {
|
|
187
|
-
let objectRelationshipByDirection = objectRelationshipGroup[direction]
|
|
188
186
|
if (objectRelationshipGroup[direction].length) {
|
|
189
187
|
for (const objectRelLink of objectRelationshipGroup[direction]) {
|
|
190
|
-
linkTypeIds.add(createLinkTypeId(
|
|
188
|
+
linkTypeIds.add(utils.createLinkTypeId(
|
|
191
189
|
_izContext,
|
|
192
190
|
objectRelLink?.base?.objType,
|
|
193
191
|
objectRelLink?.other?.objType,
|
|
@@ -210,7 +208,7 @@ function switchDirection(direction) {
|
|
|
210
208
|
}
|
|
211
209
|
}
|
|
212
210
|
|
|
213
|
-
|
|
211
|
+
export default {
|
|
214
212
|
validateRequiredOnCreateLinks,
|
|
215
213
|
groupRequiredOnCreateLink,
|
|
216
214
|
createLinkTypeIdFromLinkGroup,
|
|
@@ -17,10 +17,10 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
import getObjectSchema from "../GetObjectSchema.js";
|
|
23
|
+
import consts from "../Consts.js";
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -51,7 +51,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
51
51
|
|
|
52
52
|
if (fieldNameSetting.fromObjType) {
|
|
53
53
|
|
|
54
|
-
let childObjectSchema = await getObjSchemaS3WithHierarchy(
|
|
54
|
+
let childObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
55
55
|
_izContext,
|
|
56
56
|
// {
|
|
57
57
|
// objectType: fieldNameSetting.fromObjectType,
|
|
@@ -120,7 +120,7 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
120
120
|
|
|
121
121
|
// add deliminator and deliminatorList to deliminatorTree
|
|
122
122
|
if (isConcatCompositeKey) {
|
|
123
|
-
deliminatorTree[fieldName].deliminator = usedIdentifier.deliminator || DEFAULT_IDENTIFIER_DELIMINATOR;
|
|
123
|
+
deliminatorTree[fieldName].deliminator = usedIdentifier.deliminator || consts.DEFAULT_IDENTIFIER_DELIMINATOR;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
if (childDeliminatorList.hasOwnProperty(deliminatorTree[fieldName].deliminator)) {
|
|
@@ -304,7 +304,7 @@ async function generateDeliminatorCompositeIdentifier(_izContext, objSchema) {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
|
|
307
|
+
export default {
|
|
308
308
|
generateDeliminatorTreePerFieldName,
|
|
309
309
|
generateDeliminatorTreeAllFieldNames,
|
|
310
310
|
generateDeliminatorTreeIdentifier,
|
|
@@ -17,9 +17,9 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
import deliminatorTree from "./DeliminatorTree.js";
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -474,7 +474,7 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema, se
|
|
|
474
474
|
return explodedReqParams
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
-
|
|
477
|
+
export default {
|
|
478
478
|
explodeDataField,
|
|
479
479
|
explodedDataForCreate,
|
|
480
480
|
explodedDataForIdentifiers,
|
package/src/libs/LambdaUtils.js
CHANGED
|
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
import { LambdaClient, ListFunctionsCommand } from '@aws-sdk/client-lambda';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* List all lambda functions
|
|
@@ -38,6 +38,4 @@ async function listLambdaFunctions(_izContext, param) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
listLambdaFunctions,
|
|
43
|
-
};
|
|
41
|
+
export default listLambdaFunctions;
|
package/src/libs/RelSchemaLib.js
CHANGED
|
@@ -17,13 +17,12 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
import lodash from "lodash";
|
|
21
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
22
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
23
|
+
import getObjectSchema from "../GetObjectSchema.js";
|
|
24
|
+
import { validateObjType } from "@izara_project/izara-shared-service-schemas";
|
|
21
25
|
|
|
22
|
-
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
23
|
-
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
24
|
-
const getObjectSchema = require("../GetObjectSchema");
|
|
25
|
-
const { validateObjType: { validateObjType } } = require("@izara_project/izara-shared-service-schemas");
|
|
26
|
-
const { getObjTypeHierarchy } = require('../GetObjectSchema');
|
|
27
26
|
/**
|
|
28
27
|
* helper function for find link of 2 objects in links and refactor each link
|
|
29
28
|
*
|
|
@@ -42,7 +41,7 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
for (const objType of objTypes) {
|
|
45
|
-
const validateObjTypeResult = validateObjType(objType);
|
|
44
|
+
const validateObjTypeResult = validateObjType.validateObjType(objType);
|
|
46
45
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
47
46
|
throw NoRetryError(`function checkLinkValid: invalid objType ${objType.name} - ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
48
47
|
}
|
|
@@ -52,14 +51,14 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
|
|
|
52
51
|
const secondObjType = objTypes[1];
|
|
53
52
|
|
|
54
53
|
// first create hierarchy of each objType
|
|
55
|
-
const firstObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[0], process.env.iz_serviceSchemaBucketName).then(objSchema => {
|
|
54
|
+
const firstObjTypeTree = await getObjectSchema.getObjTypeHierarchy(_izContext, objTypes[0], process.env.iz_serviceSchemaBucketName).then(objSchema => {
|
|
56
55
|
if (objSchema.errorsFound.length > 0) {
|
|
57
56
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
58
57
|
} else {
|
|
59
58
|
return objSchema.result
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
|
-
const secondObjTypeTree = await getObjTypeHierarchy(_izContext, objTypes[1], process.env.iz_serviceSchemaBucketName).then(objSchema => {
|
|
61
|
+
const secondObjTypeTree = await getObjectSchema.getObjTypeHierarchy(_izContext, objTypes[1], process.env.iz_serviceSchemaBucketName).then(objSchema => {
|
|
63
62
|
if (objSchema.errorsFound.length > 0) {
|
|
64
63
|
throw new NoRetryError(objSchema.errorsFound.join(","))
|
|
65
64
|
} else {
|
|
@@ -113,6 +112,4 @@ async function findLinksByObjTypes(_izContext, objTypes, relationshipLinks) {
|
|
|
113
112
|
return foundLinks;
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
findLinksByObjTypes
|
|
118
|
-
}
|
|
115
|
+
export default { findLinksByObjTypes }
|
|
@@ -17,26 +17,11 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} = require('@izara_project/izara-shared-service-schemas').reformatObjectSchema
|
|
26
|
-
const {
|
|
27
|
-
getUsedFieldNamesOfIdentifiers,
|
|
28
|
-
findLinkByObjType,
|
|
29
|
-
findLinkByObjTypeV2,
|
|
30
|
-
createLinkTypeId
|
|
31
|
-
} = require('../Utils');
|
|
32
|
-
const {
|
|
33
|
-
OBJECT_SCHEMA_BUCKET_NAME,
|
|
34
|
-
UPLOAD_PATH_S3,
|
|
35
|
-
LOCAL_OBJECT_SCHEMA_PATH,
|
|
36
|
-
LOCAL_FILENAME
|
|
37
|
-
} = require("../Consts");
|
|
38
|
-
|
|
39
|
-
const { headObjectS3, getObjectS3 } = require('./s3Utils')
|
|
20
|
+
import { reformatObjectSchema } from '@izara_project/izara-shared-service-schemas'
|
|
21
|
+
|
|
22
|
+
import utils from '../Utils.js';
|
|
23
|
+
|
|
24
|
+
|
|
40
25
|
|
|
41
26
|
const DEFAULT_REL_ID_SETTING = {
|
|
42
27
|
relId: {
|
|
@@ -66,7 +51,7 @@ const DEFAULT_REL_ID_SETTING = {
|
|
|
66
51
|
*/
|
|
67
52
|
function generateObjectSchemaForCreate(_izContext, objSchema) {
|
|
68
53
|
|
|
69
|
-
return
|
|
54
|
+
return reformatObjectSchema.generateObjectSchemaForCreate(objSchema)
|
|
70
55
|
// // generate data for case create
|
|
71
56
|
// let initReturnObj = {
|
|
72
57
|
// objectType: objSchema.objectType,
|
|
@@ -127,7 +112,7 @@ function generateObjectSchemaForCreate(_izContext, objSchema) {
|
|
|
127
112
|
*/
|
|
128
113
|
function generateObjectSchemaForUpdate(_izContext, objSchema) {
|
|
129
114
|
|
|
130
|
-
return
|
|
115
|
+
return reformatObjectSchema.generateObjectSchemaForUpdate(objSchema)
|
|
131
116
|
// // generate data for case update
|
|
132
117
|
// let initReturnObj = {
|
|
133
118
|
// objectType: objSchema.objectType,
|
|
@@ -201,7 +186,7 @@ function generateObjectSchemaForUpdate(_izContext, objSchema) {
|
|
|
201
186
|
*/
|
|
202
187
|
function generateObjectSchemaForCombineFieldNames(_izContext, objSchema) {
|
|
203
188
|
|
|
204
|
-
return
|
|
189
|
+
return reformatObjectSchema.generateObjectSchemaForCombineFieldNames(objSchema)
|
|
205
190
|
// generate data for case update
|
|
206
191
|
// let initReturnObj = {
|
|
207
192
|
// objectType: objSchema.objectType,
|
|
@@ -272,7 +257,7 @@ function groupRelationshipsPerObjectType(_izContext, allObjectRelationships, obj
|
|
|
272
257
|
|
|
273
258
|
for (let objectType of objectTypes) {
|
|
274
259
|
|
|
275
|
-
const linkResult = findLinkByObjType(
|
|
260
|
+
const linkResult = utils.findLinkByObjType(
|
|
276
261
|
_izContext,
|
|
277
262
|
{
|
|
278
263
|
objectType,
|
|
@@ -322,7 +307,7 @@ function groupLinksPerObjectType(_izContext, allObjectRelationships, objectTypes
|
|
|
322
307
|
|
|
323
308
|
for (let objectType of objectTypes) {
|
|
324
309
|
|
|
325
|
-
const linkRecords =
|
|
310
|
+
const linkRecords = utils.findLinkByObjType(
|
|
326
311
|
_izContext,
|
|
327
312
|
{ // objType
|
|
328
313
|
objectType,
|
|
@@ -355,7 +340,7 @@ function generateLinksDataPerLinkTypeId(_izContext, relationshipTag, relationshi
|
|
|
355
340
|
let linksData = {};
|
|
356
341
|
const storageResources = relationshipData.storageResources
|
|
357
342
|
for (const link of relationshipData.links) {
|
|
358
|
-
const linkTypeId = createLinkTypeId(
|
|
343
|
+
const linkTypeId = utils.createLinkTypeId(
|
|
359
344
|
_izContext,
|
|
360
345
|
link.from.objType,
|
|
361
346
|
link.to.objType,
|
|
@@ -479,7 +464,7 @@ async function refRelationshipPerObjectSchema(_izContext, objSchema) {
|
|
|
479
464
|
}
|
|
480
465
|
|
|
481
466
|
|
|
482
|
-
|
|
467
|
+
export default {
|
|
483
468
|
generateObjectSchemaForCreate,
|
|
484
469
|
generateObjectSchemaForUpdate,
|
|
485
470
|
generateObjectSchemaForCombineFieldNames,
|
package/src/libs/s3Utils.js
CHANGED
|
@@ -17,8 +17,8 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import("@aws-sdk/crc64-nvme-crt");
|
|
21
|
+
import {
|
|
22
22
|
S3Client,
|
|
23
23
|
GetObjectCommand,
|
|
24
24
|
HeadObjectCommand,
|
|
@@ -26,13 +26,13 @@ const {
|
|
|
26
26
|
DeleteObjectCommand,
|
|
27
27
|
DeleteObjectsCommand,
|
|
28
28
|
PutObjectCommand,
|
|
29
|
-
}
|
|
29
|
+
} from "@aws-sdk/client-s3";
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
import { NoRetryError, inMemoryCacheLib } from '@izara_project/izara-core-library-core';
|
|
34
|
+
import { consts } from '@izara_project/izara-shared-service-schemas';
|
|
35
|
+
import coreConsts from '../Consts.js';
|
|
36
36
|
|
|
37
37
|
const s3Client = new S3Client();
|
|
38
38
|
|
|
@@ -67,14 +67,14 @@ async function getSchemaByName(params, bucketName) {
|
|
|
67
67
|
throw new NoRetryError(`getSchemaByName invalid parameters`);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
if (!SCHEMA_NAME_PER_S3_PATH.hasOwnProperty(params.schemaName)) {
|
|
70
|
+
if (!consts.SCHEMA_NAME_PER_S3_PATH.hasOwnProperty(params.schemaName)) {
|
|
71
71
|
throw new NoRetryError(`schemaName:${params.schemaName} not exist`);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// build params for getObjectS3
|
|
75
75
|
let getDataParam = {
|
|
76
|
-
Bucket: bucketName || process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
|
|
77
|
-
Key: SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
|
|
76
|
+
Bucket: bucketName || process.env.iz_serviceSchemaBucketName || coreConsts.OBJECT_SCHEMA_BUCKET_NAME,
|
|
77
|
+
Key: consts.SCHEMA_NAME_PER_S3_PATH[params.schemaName](params.getParams)
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
let [objectSchema] = await getObjectS3Shared({
|
|
@@ -145,7 +145,7 @@ async function putObjectS3(_izContext, param) {
|
|
|
145
145
|
return putResult;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
export default {
|
|
149
149
|
getObjectS3,
|
|
150
150
|
headObjectS3,
|
|
151
151
|
listObjectsV2,
|