@izara_project/izara-core-library-service-schemas 1.0.100 → 1.0.101
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 +14 -14
- package/src/Consts.js +12 -12
- package/src/GetObjectSchema.js +54 -97
- 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 +57 -95
- 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
package/src/UploadObjSchema.js
CHANGED
|
@@ -17,62 +17,14 @@ 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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
PREFIX_PATH_S3,
|
|
29
|
-
UPLOAD_PATH_S3,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
LOCAL_FILENAME,
|
|
33
|
-
STORAGE_TYPES
|
|
34
|
-
} = require("./Consts")
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
getLocalObjectSchemas,
|
|
38
|
-
getAllLocalObjectSchemasWithoutHierarchy,
|
|
39
|
-
getDataFromPath,
|
|
40
|
-
getAllLocalFlowSchemas,
|
|
41
|
-
getAllLocalRelationshipSchema,
|
|
42
|
-
getAllLocalRefObjectRelationshipSchema,
|
|
43
|
-
getLambdaFunctionNames,
|
|
44
|
-
|
|
45
|
-
} = require("./GetObjectSchema");
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
validateObjectSchema,
|
|
49
|
-
validateRelationshipSchema,
|
|
50
|
-
validateRefRelationshipSchema,
|
|
51
|
-
validateBasicFlowSchema,
|
|
52
|
-
getApiLinksV2
|
|
53
|
-
} = require('./Utils')
|
|
54
|
-
|
|
55
|
-
const {
|
|
56
|
-
DEFAULT_REL_ID_SETTING,
|
|
57
|
-
// ORIGIN_TIMESTAMP_FIELDNAME,
|
|
58
|
-
generateObjectSchemaForCreate,
|
|
59
|
-
generateObjectSchemaForUpdate,
|
|
60
|
-
generateObjectSchemaForCombineFieldNames,
|
|
61
|
-
|
|
62
|
-
groupLinksPerObjectType,
|
|
63
|
-
generateLinksDataPerLinkTypeId,
|
|
64
|
-
groupRefObjectRelPerObjectType,
|
|
65
|
-
|
|
66
|
-
refRelationshipPerObjectSchema
|
|
67
|
-
} = require('./libs/UploadUseCase');
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
putObjectS3,
|
|
72
|
-
listObjectsV2,
|
|
73
|
-
deleteObjects
|
|
74
|
-
} = require('./libs/s3Utils');
|
|
75
|
-
|
|
20
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
21
|
+
import { lambda } from '@izara_project/izara-core-library-external-request';
|
|
22
|
+
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
23
|
+
import consts from './Consts.js';
|
|
24
|
+
import getObjectSchema from './GetObjectSchema.js';
|
|
25
|
+
import utils from './Utils.js';
|
|
26
|
+
import uploadUseCase from './libs/UploadUseCase.js';
|
|
27
|
+
import s3Utils from './libs/s3Utils.js';
|
|
76
28
|
|
|
77
29
|
/**
|
|
78
30
|
* upload javascripts object to s3
|
|
@@ -93,7 +45,7 @@ async function uploadObjectToS3(
|
|
|
93
45
|
const Key = pathToUpload
|
|
94
46
|
|
|
95
47
|
let data = {
|
|
96
|
-
Bucket: process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
|
|
48
|
+
Bucket: process.env.iz_serviceSchemaBucketName || consts.OBJECT_SCHEMA_BUCKET_NAME,
|
|
97
49
|
Key,
|
|
98
50
|
Body: buffer,
|
|
99
51
|
ContentEncoding: 'base64',
|
|
@@ -103,7 +55,7 @@ async function uploadObjectToS3(
|
|
|
103
55
|
|
|
104
56
|
try {
|
|
105
57
|
// await s3.putObject(data).promise();
|
|
106
|
-
await putObjectS3(_izContext, data);
|
|
58
|
+
await s3Utils.putObjectS3(_izContext, data);
|
|
107
59
|
} catch (error) {
|
|
108
60
|
throw Error(error);
|
|
109
61
|
}
|
|
@@ -132,8 +84,8 @@ async function emptyS3Path(
|
|
|
132
84
|
Prefix: bucketPath
|
|
133
85
|
};
|
|
134
86
|
|
|
135
|
-
// const listedObjects = await s3.listObjectsV2(listParams).promise();
|
|
136
|
-
const listedObjects = await listObjectsV2(_izContext, listParams);
|
|
87
|
+
// const listedObjects = await s3.s3Utils.listObjectsV2(listParams).promise();
|
|
88
|
+
const listedObjects = await s3Utils.listObjectsV2(_izContext, listParams);
|
|
137
89
|
|
|
138
90
|
_izContext.logger.debug("listedObjects: ", listedObjects);
|
|
139
91
|
|
|
@@ -148,8 +100,8 @@ async function emptyS3Path(
|
|
|
148
100
|
deleteParams.Delete.Objects.push({ Key });
|
|
149
101
|
});
|
|
150
102
|
|
|
151
|
-
// await s3.deleteObjects(deleteParams).promise();
|
|
152
|
-
await deleteObjects(_izContext, deleteParams);
|
|
103
|
+
// await s3.s3Utils.deleteObjects(deleteParams).promise();
|
|
104
|
+
await s3Utils.deleteObjects(_izContext, deleteParams);
|
|
153
105
|
|
|
154
106
|
// if path not empty yet will start delete again
|
|
155
107
|
if (listedObjects.IsTruncated) {
|
|
@@ -168,20 +120,20 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
168
120
|
|
|
169
121
|
const objectTypesForCreate = [];
|
|
170
122
|
|
|
171
|
-
const allObjectSchemasResult = await getAllLocalObjectSchemasWithoutHierarchy(_izContext);
|
|
123
|
+
const allObjectSchemasResult = await getObjectSchema.getAllLocalObjectSchemasWithoutHierarchy(_izContext);
|
|
172
124
|
// console.log("allObjectSchemasResult: ", allObjectSchemasResult);
|
|
173
125
|
const allObjectSchema = await allObjectSchemasResult.records;
|
|
174
|
-
// const allObjectRelationships = getDataFromPath(_izContext, LOCAL_FILENAME.OBJECT_RELATIONSHIPS, LOCAL_OBJECT_SCHEMA_PATH, { fileLimit: 1 })[0] || [];
|
|
175
|
-
// const allReferenceObjectRelationships = getDataFromPath(_izContext, LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, LOCAL_OBJECT_SCHEMA_PATH, { fileLimit: 1 })[0] || [];
|
|
176
|
-
const allFlowSchemas = await getAllLocalFlowSchemas(_izContext).then(res => res.records);
|
|
126
|
+
// const allObjectRelationships = getDataFromPath(_izContext, consts.LOCAL_FILENAME.OBJECT_RELATIONSHIPS, consts.LOCAL_OBJECT_SCHEMA_PATH, { fileLimit: 1 })[0] || [];
|
|
127
|
+
// const allReferenceObjectRelationships = getDataFromPath(_izContext, consts.LOCAL_FILENAME.REFERENCE_OBJECT_RELATIONSHIPS, consts.LOCAL_OBJECT_SCHEMA_PATH, { fileLimit: 1 })[0] || [];
|
|
128
|
+
const allFlowSchemas = await getObjectSchema.getAllLocalFlowSchemas(_izContext).then(res => res.records);
|
|
177
129
|
|
|
178
|
-
const allObjectRelationships = getAllLocalRelationshipSchema(_izContext)
|
|
179
|
-
const allReferenceObjectRelationships = getAllLocalRefObjectRelationshipSchema(_izContext)
|
|
180
|
-
let refRelationshipPerObjectType = groupRefObjectRelPerObjectType(_izContext, allReferenceObjectRelationships);
|
|
130
|
+
const allObjectRelationships = getObjectSchema.getAllLocalRelationshipSchema(_izContext)
|
|
131
|
+
const allReferenceObjectRelationships = getObjectSchema.getAllLocalRefObjectRelationshipSchema(_izContext)
|
|
132
|
+
let refRelationshipPerObjectType = uploadUseCase.groupRefObjectRelPerObjectType(_izContext, allReferenceObjectRelationships);
|
|
181
133
|
_izContext.logger.debug("refRelationshipPerObjectType: ", refRelationshipPerObjectType);
|
|
182
134
|
|
|
183
135
|
|
|
184
|
-
const lambdaFunctions = await getLambdaFunctionNames(_izContext);
|
|
136
|
+
const lambdaFunctions = await getObjectSchema.getLambdaFunctionNames(_izContext);
|
|
185
137
|
_izContext.logger.debug("lambdaFunctions: ", lambdaFunctions);
|
|
186
138
|
|
|
187
139
|
const foundedObjectTypes = allObjectSchema.map(objectSchema => objectSchema.objectType);
|
|
@@ -190,7 +142,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
190
142
|
// validate all schema
|
|
191
143
|
let validateErrors = [];
|
|
192
144
|
for (let objSchema of allObjectSchema) {
|
|
193
|
-
let [status, errors] = validateObjectSchema(_izContext, objSchema);
|
|
145
|
+
let [status, errors] = utils.validateObjectSchema(_izContext, objSchema);
|
|
194
146
|
|
|
195
147
|
if (!status) {
|
|
196
148
|
validateErrors.push(errors);
|
|
@@ -198,29 +150,29 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
198
150
|
}
|
|
199
151
|
|
|
200
152
|
for (let relSchema of allObjectRelationships) {
|
|
201
|
-
let [status, errors] = validateRelationshipSchema(_izContext, relSchema);
|
|
153
|
+
let [status, errors] = utils.validateRelationshipSchema(_izContext, relSchema);
|
|
202
154
|
if (!status) {
|
|
203
155
|
validateErrors.push(errors);
|
|
204
156
|
} else {
|
|
205
157
|
let relSchemaData = Object.values(relSchema)[0];
|
|
206
158
|
_izContext.logger.debug("each rel: ", relSchemaData);
|
|
207
159
|
_izContext.logger.debug("relSchemaData.fieldNames: ", relSchemaData.fieldNames);
|
|
208
|
-
_izContext.logger.debug("DEFAULT_REL_ID_SETTING: ", DEFAULT_REL_ID_SETTING);
|
|
160
|
+
_izContext.logger.debug("DEFAULT_REL_ID_SETTING: ", uploadUseCase.DEFAULT_REL_ID_SETTING);
|
|
209
161
|
|
|
210
|
-
Object.assign(relSchemaData.fieldNames, DEFAULT_REL_ID_SETTING);
|
|
211
|
-
// Object.assign(relSchemaData.fieldNames, DEFAULT_REL_ID_SETTING, ORIGIN_TIMESTAMP_FIELDNAME);
|
|
162
|
+
Object.assign(relSchemaData.fieldNames, uploadUseCase.DEFAULT_REL_ID_SETTING);
|
|
163
|
+
// Object.assign(relSchemaData.fieldNames, uploadUseCase.DEFAULT_REL_ID_SETTING, ORIGIN_TIMESTAMP_FIELDNAME);
|
|
212
164
|
}
|
|
213
165
|
}
|
|
214
166
|
|
|
215
167
|
for (let refRelSchema of allReferenceObjectRelationships) {
|
|
216
|
-
let [status, errors] = validateRefRelationshipSchema(_izContext, refRelSchema);
|
|
168
|
+
let [status, errors] = utils.validateRefRelationshipSchema(_izContext, refRelSchema);
|
|
217
169
|
if (!status) {
|
|
218
170
|
validateErrors.push(errors);
|
|
219
171
|
}
|
|
220
172
|
}
|
|
221
173
|
|
|
222
174
|
for (let flowSchema of allFlowSchemas) {
|
|
223
|
-
let [status, errors] = validateBasicFlowSchema(_izContext, flowSchema);
|
|
175
|
+
let [status, errors] = utils.validateBasicFlowSchema(_izContext, flowSchema);
|
|
224
176
|
|
|
225
177
|
if (!status) {
|
|
226
178
|
validateErrors.push(errors)
|
|
@@ -234,14 +186,14 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
234
186
|
// end validate all schema
|
|
235
187
|
|
|
236
188
|
// delete all file in servicePath before upload
|
|
237
|
-
await emptyS3Path(_izContext, process.env.iz_serviceSchemaBucketName, `${PREFIX_PATH_S3.perServiceSchemas}/${process.env.iz_serviceTag}/`);
|
|
189
|
+
await emptyS3Path(_izContext, process.env.iz_serviceSchemaBucketName, `${consts.PREFIX_PATH_S3.perServiceSchemas}/${process.env.iz_serviceTag}/`);
|
|
238
190
|
|
|
239
191
|
|
|
240
192
|
if (lambdaFunctions) {
|
|
241
193
|
uploadList.push(
|
|
242
194
|
uploadObjectToS3(
|
|
243
195
|
_izContext,
|
|
244
|
-
UPLOAD_PATH_S3.lambdaFunctions(_izContext, process.env.iz_serviceTag),
|
|
196
|
+
consts.UPLOAD_PATH_S3.lambdaFunctions(_izContext, process.env.iz_serviceTag),
|
|
245
197
|
lambdaFunctions
|
|
246
198
|
)
|
|
247
199
|
);
|
|
@@ -251,7 +203,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
251
203
|
uploadList.push(
|
|
252
204
|
uploadObjectToS3(
|
|
253
205
|
_izContext,
|
|
254
|
-
UPLOAD_PATH_S3.serviceName(_izContext, process.env.iz_serviceTag),
|
|
206
|
+
consts.UPLOAD_PATH_S3.serviceName(_izContext, process.env.iz_serviceTag),
|
|
255
207
|
{ serviceName: process.env.iz_serviceName }
|
|
256
208
|
)
|
|
257
209
|
);
|
|
@@ -263,7 +215,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
263
215
|
uploadList.push(
|
|
264
216
|
uploadObjectToS3(
|
|
265
217
|
_izContext,
|
|
266
|
-
UPLOAD_PATH_S3.objectSchemaAll(
|
|
218
|
+
consts.UPLOAD_PATH_S3.objectSchemaAll(
|
|
267
219
|
_izContext,
|
|
268
220
|
{
|
|
269
221
|
serviceTag: process.env.iz_serviceTag,
|
|
@@ -280,7 +232,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
280
232
|
// uploadList.push(
|
|
281
233
|
// uploadObjectToS3(
|
|
282
234
|
// _izContext,
|
|
283
|
-
// UPLOAD_PATH_S3.objectSchemaCreate(
|
|
235
|
+
// consts.UPLOAD_PATH_S3.objectSchemaCreate(
|
|
284
236
|
// _izContext,
|
|
285
237
|
// {
|
|
286
238
|
// serviceTag: process.env.iz_serviceTag,
|
|
@@ -299,7 +251,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
299
251
|
// uploadList.push(
|
|
300
252
|
// uploadObjectToS3(
|
|
301
253
|
// _izContext,
|
|
302
|
-
// UPLOAD_PATH_S3.objectSchemaDisplay(
|
|
254
|
+
// consts.UPLOAD_PATH_S3.objectSchemaDisplay(
|
|
303
255
|
// _izContext,
|
|
304
256
|
// {
|
|
305
257
|
// serviceTag: process.env.iz_serviceTag,
|
|
@@ -317,7 +269,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
317
269
|
// uploadList.push(
|
|
318
270
|
// uploadObjectToS3(
|
|
319
271
|
// _izContext,
|
|
320
|
-
// UPLOAD_PATH_S3.objectSchemaCombineFieldNames(
|
|
272
|
+
// consts.UPLOAD_PATH_S3.objectSchemaCombineFieldNames(
|
|
321
273
|
// _izContext,
|
|
322
274
|
// {
|
|
323
275
|
// serviceTag: process.env.iz_serviceTag,
|
|
@@ -331,12 +283,12 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
331
283
|
// upload to refObjectRelationships for each objectType that have createBy at UserAccount Service and belongTo
|
|
332
284
|
let existsRefObjectRel = refRelationshipPerObjectType[objSchema.objectType];
|
|
333
285
|
if (existsRefObjectRel) {
|
|
334
|
-
Object.assign(existsRefObjectRel, await refRelationshipPerObjectSchema(_izContext, objSchema));
|
|
286
|
+
Object.assign(existsRefObjectRel, await uploadUseCase.refRelationshipPerObjectSchema(_izContext, objSchema));
|
|
335
287
|
|
|
336
288
|
uploadList.push(
|
|
337
289
|
uploadObjectToS3(
|
|
338
290
|
_izContext,
|
|
339
|
-
UPLOAD_PATH_S3.refObjectRelationship(_izContext,
|
|
291
|
+
consts.UPLOAD_PATH_S3.refObjectRelationship(_izContext,
|
|
340
292
|
{
|
|
341
293
|
objectType: objSchema.objectType,
|
|
342
294
|
serviceTag: process.env.iz_serviceTag
|
|
@@ -348,20 +300,20 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
348
300
|
} else {
|
|
349
301
|
// add new rule if objectType is not have storageType graph not upload to refObjectRelationships
|
|
350
302
|
if (!objSchema.storageResources || !Object.values(objSchema.storageResources)
|
|
351
|
-
.some(storageResource => storageResource.storageType === STORAGE_TYPES.graph)) {
|
|
303
|
+
.some(storageResource => storageResource.storageType === consts.STORAGE_TYPES.graph)) {
|
|
352
304
|
continue;
|
|
353
305
|
}
|
|
354
306
|
|
|
355
307
|
uploadList.push(
|
|
356
308
|
uploadObjectToS3(
|
|
357
309
|
_izContext,
|
|
358
|
-
UPLOAD_PATH_S3.refObjectRelationship(_izContext,
|
|
310
|
+
consts.UPLOAD_PATH_S3.refObjectRelationship(_izContext,
|
|
359
311
|
{
|
|
360
312
|
objectType: objSchema.objectType,
|
|
361
313
|
serviceTag: process.env.iz_serviceTag
|
|
362
314
|
}
|
|
363
315
|
),
|
|
364
|
-
await refRelationshipPerObjectSchema(_izContext, objSchema)
|
|
316
|
+
await uploadUseCase.refRelationshipPerObjectSchema(_izContext, objSchema)
|
|
365
317
|
)
|
|
366
318
|
)
|
|
367
319
|
}
|
|
@@ -373,16 +325,16 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
373
325
|
uploadList.push(
|
|
374
326
|
uploadObjectToS3(
|
|
375
327
|
_izContext,
|
|
376
|
-
UPLOAD_PATH_S3.objectListAll(_izContext, process.env.iz_serviceTag),
|
|
328
|
+
consts.UPLOAD_PATH_S3.objectListAll(_izContext, process.env.iz_serviceTag),
|
|
377
329
|
foundedObjectTypes
|
|
378
330
|
)
|
|
379
331
|
);
|
|
380
332
|
|
|
381
|
-
let apiLinks = await getApiLinksV2(foundedObjectTypes);
|
|
333
|
+
let apiLinks = await utils.getApiLinksV2(foundedObjectTypes);
|
|
382
334
|
uploadList.push(
|
|
383
335
|
uploadObjectToS3(
|
|
384
336
|
_izContext,
|
|
385
|
-
UPLOAD_PATH_S3.getEndpointPerService(_izContext, process.env.iz_serviceTag),
|
|
337
|
+
consts.UPLOAD_PATH_S3.getEndpointPerService(_izContext, process.env.iz_serviceTag),
|
|
386
338
|
apiLinks
|
|
387
339
|
)
|
|
388
340
|
)
|
|
@@ -397,7 +349,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
397
349
|
let graphServerTags = new Set();
|
|
398
350
|
|
|
399
351
|
for (const storageResources of Object.values(objectSchema.storageResources)) {
|
|
400
|
-
if (storageResources.storageType === STORAGE_TYPES.graph) {
|
|
352
|
+
if (storageResources.storageType === consts.STORAGE_TYPES.graph) {
|
|
401
353
|
graphServerTags.add(storageResources.graphServerTag);
|
|
402
354
|
}
|
|
403
355
|
}
|
|
@@ -483,7 +435,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
483
435
|
uploadList.push(
|
|
484
436
|
uploadObjectToS3(
|
|
485
437
|
_izContext,
|
|
486
|
-
UPLOAD_PATH_S3.relationshipTag(
|
|
438
|
+
consts.UPLOAD_PATH_S3.relationshipTag(
|
|
487
439
|
_izContext,
|
|
488
440
|
{
|
|
489
441
|
serviceTag: process.env.iz_serviceTag,
|
|
@@ -498,13 +450,13 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
498
450
|
);
|
|
499
451
|
|
|
500
452
|
// upload per linkTypeId
|
|
501
|
-
const linksData = generateLinksDataPerLinkTypeId(_izContext, relationshipTag, relTagDetail[relationshipTag]);
|
|
453
|
+
const linksData = uploadUseCase.generateLinksDataPerLinkTypeId(_izContext, relationshipTag, relTagDetail[relationshipTag]);
|
|
502
454
|
|
|
503
455
|
for (const [linkTypeId, link] of Object.entries(linksData)) {
|
|
504
456
|
uploadList.push(
|
|
505
457
|
uploadObjectToS3(
|
|
506
458
|
_izContext,
|
|
507
|
-
UPLOAD_PATH_S3.linkByLinkTypeId(_izContext, process.env.iz_serviceTag, linkTypeId),
|
|
459
|
+
consts.UPLOAD_PATH_S3.linkByLinkTypeId(_izContext, process.env.iz_serviceTag, linkTypeId),
|
|
508
460
|
link
|
|
509
461
|
)
|
|
510
462
|
);
|
|
@@ -512,7 +464,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
512
464
|
|
|
513
465
|
// send params to translateIds to create permission fpr query dynamoDB
|
|
514
466
|
for (const [storageResourceTag, storageResource] of Object.entries(relTagDetail[relationshipTag].storageResources)) {
|
|
515
|
-
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
467
|
+
if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
516
468
|
for (const link of relTagDetail[relationshipTag].links) {
|
|
517
469
|
if (link.storageResourceTags.includes(storageResourceTag)) {
|
|
518
470
|
setRelationships.add(
|
|
@@ -537,13 +489,13 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
537
489
|
)
|
|
538
490
|
}
|
|
539
491
|
|
|
540
|
-
const linksPerObjectType = groupLinksPerObjectType(_izContext, allObjectRelationships, foundedObjectTypes)
|
|
492
|
+
const linksPerObjectType = uploadUseCase.groupLinksPerObjectType(_izContext, allObjectRelationships, foundedObjectTypes)
|
|
541
493
|
|
|
542
494
|
for (const [relObjectType, relTagsData] of Object.entries(linksPerObjectType)) {
|
|
543
495
|
uploadList.push(
|
|
544
496
|
uploadObjectToS3(
|
|
545
497
|
_izContext,
|
|
546
|
-
UPLOAD_PATH_S3.objectRelationship(_izContext, { serviceTag: process.env.iz_serviceTag, objectType: relObjectType }),
|
|
498
|
+
consts.UPLOAD_PATH_S3.objectRelationship(_izContext, { serviceTag: process.env.iz_serviceTag, objectType: relObjectType }),
|
|
547
499
|
relTagsData
|
|
548
500
|
)
|
|
549
501
|
);
|
|
@@ -555,12 +507,12 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
555
507
|
|
|
556
508
|
// // upload refObjectRelationships
|
|
557
509
|
// if (allReferenceObjectRelationships) {
|
|
558
|
-
// const refPerObjectType = groupRefObjectRelPerObjectType(_izContext, allReferenceObjectRelationships)
|
|
510
|
+
// const refPerObjectType = uploadUseCase.groupRefObjectRelPerObjectType(_izContext, allReferenceObjectRelationships)
|
|
559
511
|
// for (const [refObjectType, refRelsData] of Object.entries(refPerObjectType)) {
|
|
560
512
|
// uploadList.push(
|
|
561
513
|
// uploadObjectToS3(
|
|
562
514
|
// _izContext,
|
|
563
|
-
// UPLOAD_PATH_S3.refObjectRelationship(_izContext, { serviceTag: process.env.iz_serviceTag, objectType: refObjectType }),
|
|
515
|
+
// consts.UPLOAD_PATH_S3.refObjectRelationship(_izContext, { serviceTag: process.env.iz_serviceTag, objectType: refObjectType }),
|
|
564
516
|
// refRelsData
|
|
565
517
|
// )
|
|
566
518
|
// );
|
|
@@ -573,7 +525,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
573
525
|
uploadList.push(
|
|
574
526
|
uploadObjectToS3(
|
|
575
527
|
_izContext,
|
|
576
|
-
UPLOAD_PATH_S3.flowSchema(_izContext,
|
|
528
|
+
consts.UPLOAD_PATH_S3.flowSchema(_izContext,
|
|
577
529
|
{
|
|
578
530
|
serviceTag: process.env.iz_serviceTag,
|
|
579
531
|
flowTag: flowSchema.flowTag
|
|
@@ -589,7 +541,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
589
541
|
}
|
|
590
542
|
|
|
591
543
|
|
|
592
|
-
|
|
544
|
+
export default {
|
|
593
545
|
uploadObjectSchemaByUseCase,
|
|
594
546
|
uploadObjectToS3,
|
|
595
547
|
emptyS3Path
|
package/src/Utils.js
CHANGED
|
@@ -17,47 +17,26 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
|
+
import {
|
|
22
22
|
NoRetryError,
|
|
23
|
-
validator
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
basicValidatorSchema: {
|
|
28
|
-
basicObjectSchema,
|
|
29
|
-
basicExtendObjectSchema,
|
|
30
|
-
relationshipBasicSchema,
|
|
31
|
-
refRelationshipBasicSchema,
|
|
32
|
-
basicFlowSchema
|
|
33
|
-
},
|
|
34
|
-
validateObjType: {
|
|
35
|
-
validateObjType,
|
|
36
|
-
validateRelType,
|
|
37
|
-
validateFlowType
|
|
38
|
-
},
|
|
39
|
-
reformatObjectSchema: {
|
|
40
|
-
getUsedFieldNamesOfIdentifiers: getUsedFieldNamesOfIdentifiersShared
|
|
41
|
-
}
|
|
42
|
-
} = require('@izara_project/izara-shared-service-schemas');
|
|
23
|
+
validator
|
|
24
|
+
} from '@izara_project/izara-core-library-core';
|
|
25
|
+
import { basicValidatorSchema, validateObjType, reformatObjectSchema } from '@izara_project/izara-shared-service-schemas'
|
|
43
26
|
|
|
44
|
-
|
|
45
|
-
// const getSchema = require('./GetObjectSchema');
|
|
46
|
-
// const deliminatorTree = require('./libs/DeliminatorTree');
|
|
27
|
+
import consts from './Consts.js';
|
|
47
28
|
|
|
48
|
-
|
|
29
|
+
import {
|
|
49
30
|
APIGatewayClient,
|
|
50
31
|
GetRestApisCommand,
|
|
51
32
|
GetResourcesCommand,
|
|
52
|
-
|
|
53
|
-
} = require("@aws-sdk/client-api-gateway");
|
|
33
|
+
} from "@aws-sdk/client-api-gateway";
|
|
54
34
|
|
|
55
|
-
|
|
35
|
+
import {
|
|
56
36
|
ApiGatewayV2Client,
|
|
57
37
|
GetApisCommand,
|
|
58
38
|
GetRoutesCommand,
|
|
59
|
-
|
|
60
|
-
} = require("@aws-sdk/client-apigatewayv2");
|
|
39
|
+
} from "@aws-sdk/client-apigatewayv2";
|
|
61
40
|
|
|
62
41
|
function createObjType(objectType, serviceTag) {
|
|
63
42
|
if (!process.env.iz_serviceTag && !serviceTag) {
|
|
@@ -116,7 +95,7 @@ function getIdentifierTypeByPriority(_izContext, storageTypes = [], objSchema) {
|
|
|
116
95
|
* @returns {string[]} - array of fieldName from objectSchema.identifiers
|
|
117
96
|
*/
|
|
118
97
|
function getUsedFieldNamesOfIdentifiers(_izContext, identifiers, identifierTypes = []) {
|
|
119
|
-
return
|
|
98
|
+
return reformatObjectSchema.getUsedFieldNamesOfIdentifiers(identifiers, identifierTypes)
|
|
120
99
|
// let identifierFieldNames = [];
|
|
121
100
|
|
|
122
101
|
// for (let identifier of identifiers) {
|
|
@@ -138,7 +117,7 @@ function getUsedFieldNamesOfIdentifiers(_izContext, identifiers, identifierTypes
|
|
|
138
117
|
|
|
139
118
|
function validateBasicObjectSchema(_izContext, objectSchema) {
|
|
140
119
|
|
|
141
|
-
const validateStatus = validateObject(basicObjectSchema, objectSchema, null, { strict: false });
|
|
120
|
+
const validateStatus = validator.validateObject(basicValidatorSchema.basicObjectSchema, objectSchema, null, { strict: false });
|
|
142
121
|
|
|
143
122
|
if (validateStatus.pass) {
|
|
144
123
|
let errors = []
|
|
@@ -256,7 +235,7 @@ function validateBasicObjectSchema(_izContext, objectSchema) {
|
|
|
256
235
|
}
|
|
257
236
|
|
|
258
237
|
function validateExtendObjectSchema(_izContext, extendObjectSchema) {
|
|
259
|
-
let validateStatus = validateObject(basicExtendObjectSchema, extendObjectSchema, null, { strict: false });
|
|
238
|
+
let validateStatus = validator.validateObject(basicValidatorSchema.basicExtendObjectSchema, extendObjectSchema, null, { strict: false });
|
|
260
239
|
|
|
261
240
|
if (validateStatus.pass) {
|
|
262
241
|
let errors = []
|
|
@@ -385,7 +364,7 @@ function validateObjectSchema(_izContext, objectSchema) {
|
|
|
385
364
|
|
|
386
365
|
|
|
387
366
|
function validateRelationshipSchema(_izContext, relationshipSchema) {
|
|
388
|
-
let validateStatus = validateObject(relationshipBasicSchema, relationshipSchema, null, { strict: false });
|
|
367
|
+
let validateStatus = validator.validateObject(basicValidatorSchema.relationshipBasicSchema, relationshipSchema, null, { strict: false });
|
|
389
368
|
|
|
390
369
|
const relationshipTag = Object.keys(relationshipSchema)[0];
|
|
391
370
|
_izContext.logger.debug("relationshipSchema: ", relationshipSchema);
|
|
@@ -439,7 +418,7 @@ function validateRelationshipSchema(_izContext, relationshipSchema) {
|
|
|
439
418
|
}
|
|
440
419
|
|
|
441
420
|
function validateRefRelationshipSchema(_izContext, refRelationshipSchema, serviceTag) {
|
|
442
|
-
let validateStatus = validateObject(refRelationshipBasicSchema, refRelationshipSchema, null, { strict: false });
|
|
421
|
+
let validateStatus = validator.validateObject(basicValidatorSchema.refRelationshipBasicSchema, refRelationshipSchema, null, { strict: false });
|
|
443
422
|
if (validateStatus.pass) {
|
|
444
423
|
if (!serviceTag) {
|
|
445
424
|
serviceTag = process.env.iz_serviceTag
|
|
@@ -473,7 +452,7 @@ function validateRefRelationshipSchema(_izContext, refRelationshipSchema, servic
|
|
|
473
452
|
* @returns
|
|
474
453
|
*/
|
|
475
454
|
function findLinkByObjType(_izContext, objType, relationshipSchema) {
|
|
476
|
-
const validateObjTypeResult = validateObjType(objType);
|
|
455
|
+
const validateObjTypeResult = validateObjType.validateObjType(objType);
|
|
477
456
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
478
457
|
_izContext.logger.error(`findLinkByObjType: invalid objType: ${JSON.stringify(objType)}`);
|
|
479
458
|
throw new NoRetryError(`findLinkByObjType: invalid objType: ${JSON.stringify(objType)}`);
|
|
@@ -524,7 +503,7 @@ function findLinkByObjType(_izContext, objType, relationshipSchema) {
|
|
|
524
503
|
* @returns
|
|
525
504
|
*/
|
|
526
505
|
function findLinkByObjTypeV2(_izContext, objType, relType, relationshipSchema) {
|
|
527
|
-
const validateObjTypeResult = validateObjType(objType);
|
|
506
|
+
const validateObjTypeResult = validateObjType.validateObjType(objType);
|
|
528
507
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
529
508
|
_izContext.logger.error(`findLinkByObjTypeV2: invalid objType: ${JSON.stringify(objType)}`);
|
|
530
509
|
throw new NoRetryError(`findLinkByObjTypeV2: invalid objType: ${JSON.stringify(objType)}`);
|
|
@@ -588,7 +567,7 @@ function findLinkByObjTypeV2(_izContext, objType, relType, relationshipSchema) {
|
|
|
588
567
|
|
|
589
568
|
|
|
590
569
|
function createObjTypeConcat(_izContext, objType) {
|
|
591
|
-
const validateObjTypeResult = validateObjType(objType);
|
|
570
|
+
const validateObjTypeResult = validateObjType.validateObjType(objType);
|
|
592
571
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
593
572
|
_izContext.logger.error("createObjTypeConcat validateObjTypeResult", validateObjTypeResult);
|
|
594
573
|
throw new NoRetryError(`Invalid objType:${JSON.stringify(objType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
@@ -601,7 +580,7 @@ function explodedObjTypeConcat(_izContext, objectTypeId) {
|
|
|
601
580
|
}
|
|
602
581
|
|
|
603
582
|
function createRelTypeConcat(_izContext, relType) {
|
|
604
|
-
const validateRelTypeResult = validateRelType(relType);
|
|
583
|
+
const validateRelTypeResult = validateObjType.validateRelType(relType);
|
|
605
584
|
if (validateRelTypeResult.errorsFound.length > 0) {
|
|
606
585
|
_izContext.logger.error("createRelTypeConcat validateRelTypeResult", validateRelTypeResult);
|
|
607
586
|
throw new NoRetryError(`Invalid relType:${JSON.stringify(relType)}, ${validateRelTypeResult.errorsFound.join(", ")}`);
|
|
@@ -614,7 +593,7 @@ function explodedRelTypeConcat(_izContext, relationshipTypeId) {
|
|
|
614
593
|
}
|
|
615
594
|
|
|
616
595
|
function createFlowTypeConcat(_izContext, flowType) {
|
|
617
|
-
const validateFlowTypeResult = validateFlowType(flowType);
|
|
596
|
+
const validateFlowTypeResult = validateObjType.validateFlowType(flowType);
|
|
618
597
|
if (validateFlowTypeResult.errorsFound.length > 0) {
|
|
619
598
|
_izContext.logger.error("createFlowTypeConcat validateFlowTypeResult", validateFlowTypeResult);
|
|
620
599
|
throw new NoRetryError(`Invalid flowType:${JSON.stringify(flowType)}, ${validateFlowTypeResult.errorsFound.join(", ")}`);
|
|
@@ -628,20 +607,20 @@ function explodedFlowTypeConcat(_izContext, flowTypeId) {
|
|
|
628
607
|
|
|
629
608
|
function createLinkTypeId(_izContext, firstObjType, secondObjType, relType, direction) {
|
|
630
609
|
// validate objType
|
|
631
|
-
let validateObjTypeResult = validateObjType(firstObjType);
|
|
610
|
+
let validateObjTypeResult = validateObjType.validateObjType(firstObjType);
|
|
632
611
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
633
612
|
_izContext.logger.error("createLinkTypeId validateObjTypeResult", validateObjTypeResult);
|
|
634
613
|
throw new NoRetryError(`Invalid objType:${JSON.stringify(firstObjType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
635
614
|
}
|
|
636
615
|
|
|
637
|
-
validateObjTypeResult = validateObjType(secondObjType);
|
|
616
|
+
validateObjTypeResult = validateObjType.validateObjType(secondObjType);
|
|
638
617
|
if (validateObjTypeResult.errorsFound.length > 0) {
|
|
639
618
|
_izContext.logger.error("createLinkTypeId validateObjTypeResult", validateObjTypeResult);
|
|
640
619
|
throw new NoRetryError(`Invalid objType:${JSON.stringify(secondObjType)}, ${validateObjTypeResult.errorsFound.join(", ")}`);
|
|
641
620
|
}
|
|
642
621
|
|
|
643
622
|
// validate relType
|
|
644
|
-
let validateRelTypeResult = validateRelType(relType);
|
|
623
|
+
let validateRelTypeResult = validateObjType.validateRelType(relType);
|
|
645
624
|
|
|
646
625
|
if (validateRelTypeResult.errorsFound.length > 0) {
|
|
647
626
|
_izContext.logger.error("createLinkTypeId validateRelTypeResult", validateRelTypeResult);
|
|
@@ -667,7 +646,7 @@ function createLinkTypeId(_izContext, firstObjType, secondObjType, relType, dire
|
|
|
667
646
|
}
|
|
668
647
|
|
|
669
648
|
function validateBasicFlowSchema(_izContext, flowSchema) {
|
|
670
|
-
const validateStatus = validateObject(basicFlowSchema, flowSchema, null, { strict: false });
|
|
649
|
+
const validateStatus = validator.validateObject(basicValidatorSchema.basicFlowSchema, flowSchema, null, { strict: false });
|
|
671
650
|
|
|
672
651
|
if (validateStatus.pass) {
|
|
673
652
|
let errors = [];
|
|
@@ -793,7 +772,7 @@ async function getApiLinksV2(objectTypes) {
|
|
|
793
772
|
}
|
|
794
773
|
}
|
|
795
774
|
|
|
796
|
-
|
|
775
|
+
export default {
|
|
797
776
|
createObjType,
|
|
798
777
|
getIdentifierTypeByPriority,
|
|
799
778
|
getUsedFieldNamesOfIdentifiers,
|