@izara_project/izara-core-library-service-schemas 1.0.81 → 1.0.83
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 +5 -5
- package/src/UploadObjSchema.js +13 -24
- package/src/Utils.js +4 -0
- package/src/ValidatorSchema.js +65 -45
- package/src/libs/DeliminatorTree.js +14 -12
- package/src/libs/ExplodedReqParams.js +18 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.83",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,22 +14,22 @@
|
|
|
14
14
|
"license": "AGPL-3.0-or-later",
|
|
15
15
|
"homepage": "https://bitbucket.org/izara-core-libraries/izara-core-library-service-schemas/src/master/README.md",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"jest": "^30.0.
|
|
17
|
+
"jest": "^30.0.5"
|
|
18
18
|
},
|
|
19
19
|
"jest": {
|
|
20
20
|
"testEnvironment": "node"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@aws-sdk/client-api-gateway": "^3.848.0",
|
|
24
|
-
"@aws-sdk/client-lambda": "^3.
|
|
25
|
-
"@aws-sdk/client-s3": "^3.
|
|
24
|
+
"@aws-sdk/client-lambda": "^3.851.0",
|
|
25
|
+
"@aws-sdk/client-s3": "^3.850.0",
|
|
26
26
|
"@aws-sdk/crc64-nvme-crt": "^3.848.0",
|
|
27
27
|
"@izara_project/izara-core-library-core": "^1.0.19",
|
|
28
28
|
"@izara_project/izara-core-library-external-request": "^1.0.20",
|
|
29
29
|
"@izara_project/izara-core-library-lambda": "^1.0.4",
|
|
30
30
|
"@izara_project/izara-core-library-logger": "^1.0.7",
|
|
31
31
|
"@izara_project/izara-shared-core": "^1.0.2",
|
|
32
|
-
"@izara_project/izara-shared-service-schemas": "^1.0.
|
|
32
|
+
"@izara_project/izara-shared-service-schemas": "^1.0.26",
|
|
33
33
|
"glob": "^11.0.3",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"object-hash": "^3.0.0",
|
package/src/UploadObjSchema.js
CHANGED
|
@@ -242,8 +242,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
242
242
|
uploadObjectToS3(
|
|
243
243
|
_izContext,
|
|
244
244
|
UPLOAD_PATH_S3.lambdaFunctions(_izContext, process.env.iz_serviceTag),
|
|
245
|
-
lambdaFunctions
|
|
246
|
-
|
|
245
|
+
lambdaFunctions
|
|
247
246
|
)
|
|
248
247
|
);
|
|
249
248
|
}
|
|
@@ -253,8 +252,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
253
252
|
uploadObjectToS3(
|
|
254
253
|
_izContext,
|
|
255
254
|
UPLOAD_PATH_S3.serviceName(_izContext, process.env.iz_serviceTag),
|
|
256
|
-
{ serviceName: process.env.iz_serviceName }
|
|
257
|
-
|
|
255
|
+
{ serviceName: process.env.iz_serviceName }
|
|
258
256
|
)
|
|
259
257
|
);
|
|
260
258
|
|
|
@@ -272,8 +270,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
272
270
|
objectType: objSchema.objectType
|
|
273
271
|
}
|
|
274
272
|
),
|
|
275
|
-
objSchema
|
|
276
|
-
|
|
273
|
+
objSchema
|
|
277
274
|
)
|
|
278
275
|
);
|
|
279
276
|
|
|
@@ -290,8 +287,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
290
287
|
objectType: createFieldSchema.objectType
|
|
291
288
|
}
|
|
292
289
|
),
|
|
293
|
-
createFieldSchema
|
|
294
|
-
|
|
290
|
+
createFieldSchema
|
|
295
291
|
)
|
|
296
292
|
);
|
|
297
293
|
|
|
@@ -310,8 +306,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
310
306
|
objectType: createFieldSchema.objectType
|
|
311
307
|
}
|
|
312
308
|
),
|
|
313
|
-
updateFieldSchema
|
|
314
|
-
|
|
309
|
+
updateFieldSchema
|
|
315
310
|
)
|
|
316
311
|
);
|
|
317
312
|
|
|
@@ -329,8 +324,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
329
324
|
objectType: combineFieldNamesObjectSchema.objectType
|
|
330
325
|
}
|
|
331
326
|
),
|
|
332
|
-
combineFieldNamesObjectSchema
|
|
333
|
-
|
|
327
|
+
combineFieldNamesObjectSchema
|
|
334
328
|
)
|
|
335
329
|
);
|
|
336
330
|
|
|
@@ -340,8 +334,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
340
334
|
uploadObjectToS3(
|
|
341
335
|
_izContext,
|
|
342
336
|
UPLOAD_PATH_S3.getEndpointPerObjectType(_izContext, { objectType: objSchema.objectType, serviceTag: process.env.iz_serviceTag }),
|
|
343
|
-
apiLink
|
|
344
|
-
|
|
337
|
+
apiLink
|
|
345
338
|
)
|
|
346
339
|
)
|
|
347
340
|
|
|
@@ -349,8 +342,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
349
342
|
uploadObjectToS3(
|
|
350
343
|
_izContext,
|
|
351
344
|
UPLOAD_PATH_S3.getEndpointPerService(process.env.iz_serviceTag),
|
|
352
|
-
apiLink
|
|
353
|
-
|
|
345
|
+
apiLink
|
|
354
346
|
)
|
|
355
347
|
)
|
|
356
348
|
|
|
@@ -368,8 +360,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
368
360
|
serviceTag: process.env.iz_serviceTag
|
|
369
361
|
}
|
|
370
362
|
),
|
|
371
|
-
existsRefObjectRel
|
|
372
|
-
|
|
363
|
+
existsRefObjectRel
|
|
373
364
|
)
|
|
374
365
|
)
|
|
375
366
|
} else {
|
|
@@ -388,8 +379,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
388
379
|
serviceTag: process.env.iz_serviceTag
|
|
389
380
|
}
|
|
390
381
|
),
|
|
391
|
-
await refRelationshipPerObjectSchema(_izContext, objSchema)
|
|
392
|
-
|
|
382
|
+
await refRelationshipPerObjectSchema(_izContext, objSchema)
|
|
393
383
|
)
|
|
394
384
|
)
|
|
395
385
|
}
|
|
@@ -402,8 +392,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
402
392
|
uploadObjectToS3(
|
|
403
393
|
_izContext,
|
|
404
394
|
UPLOAD_PATH_S3.objectListAll(_izContext, process.env.iz_serviceTag),
|
|
405
|
-
foundedObjectTypes
|
|
406
|
-
|
|
395
|
+
foundedObjectTypes
|
|
407
396
|
)
|
|
408
397
|
);
|
|
409
398
|
|
|
@@ -422,12 +411,12 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
422
411
|
}
|
|
423
412
|
}
|
|
424
413
|
|
|
425
|
-
let serviceTag = objectSchema.extendObjType ? objectSchema.extendObjType.serviceTag : process.env.iz_serviceTag;
|
|
414
|
+
// let serviceTag = objectSchema.extendObjType ? objectSchema.extendObjType.serviceTag : process.env.iz_serviceTag;
|
|
426
415
|
if (graphServerTags.size) {
|
|
427
416
|
createdBys.push({
|
|
428
417
|
objType: {
|
|
429
418
|
objectType: objectSchema.objectType,
|
|
430
|
-
serviceTag:
|
|
419
|
+
serviceTag: process.env.iz_serviceTag
|
|
431
420
|
},
|
|
432
421
|
graphServerTags: [...graphServerTags]
|
|
433
422
|
})
|
package/src/Utils.js
CHANGED
|
@@ -228,6 +228,10 @@ function validateBasicObjectSchema(_izContext, objectSchema) {
|
|
|
228
228
|
if (objectSchema.fieldNames[identifierFieldName]?.canUpdate === true) {
|
|
229
229
|
errors.push(`${objectType}.fieldNames.${identifierFieldName}: canUpdate cannot be true because this fieldName is identifier`);
|
|
230
230
|
}
|
|
231
|
+
|
|
232
|
+
if (objectSchema.fieldNames[identifierFieldName]?.userCanUpdate === true) {
|
|
233
|
+
errors.push(`${objectType}.fieldNames.${identifierFieldName}: userCanUpdate cannot be true because this fieldName is identifier`);
|
|
234
|
+
}
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
errors.push(...validateFieldNamesWithStorageResources(_izContext, objectSchema))
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -20,7 +20,7 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
|
|
|
20
20
|
|
|
21
21
|
const readYamlFile = require('read-yaml-file');
|
|
22
22
|
const lodash = require('lodash')
|
|
23
|
-
const { inMemoryCacheLib, NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
23
|
+
const { inMemoryCacheLib, NoRetryError, consts } = require('@izara_project/izara-core-library-core');
|
|
24
24
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
25
25
|
const uploadUseCase = require('./libs/UploadUseCase')
|
|
26
26
|
|
|
@@ -89,7 +89,7 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
if (fieldNameSetting.
|
|
92
|
+
if (fieldNameSetting.fromObjType) {
|
|
93
93
|
|
|
94
94
|
Object.assign(
|
|
95
95
|
validatorTree[fieldName],
|
|
@@ -102,10 +102,7 @@ async function generateValidatorSchemaTreePerFieldName(_izContext, fieldName, fi
|
|
|
102
102
|
|
|
103
103
|
let childObjectSchema = await getObjSchemaS3WithHierarchy(
|
|
104
104
|
_izContext,
|
|
105
|
-
|
|
106
|
-
objectType: fieldNameSetting.fromObjectType,
|
|
107
|
-
serviceTag: fieldNameSetting.fromServiceNameTag
|
|
108
|
-
}
|
|
105
|
+
fieldNameSetting.fromObjType
|
|
109
106
|
);
|
|
110
107
|
|
|
111
108
|
if (!childObjectSchema) {
|
|
@@ -466,7 +463,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
466
463
|
// ------- create return validatorSchema -------
|
|
467
464
|
let validatorSchemaForCreate = {
|
|
468
465
|
type: "object",
|
|
469
|
-
required: ["fieldNames"
|
|
466
|
+
required: ["fieldNames"],
|
|
470
467
|
properties: {
|
|
471
468
|
fieldNames: {
|
|
472
469
|
additionalProperties: false,
|
|
@@ -476,10 +473,6 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
476
473
|
...allValidatorSchemaFieldNames
|
|
477
474
|
}
|
|
478
475
|
},
|
|
479
|
-
objectType: {
|
|
480
|
-
type: "string",
|
|
481
|
-
pattern: "^[a-zA-Z0-9_-]+$"
|
|
482
|
-
},
|
|
483
476
|
additionalParams: {
|
|
484
477
|
type: "object"
|
|
485
478
|
}
|
|
@@ -493,6 +486,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
493
486
|
// Object.assign(validatorSchemaForCreate.properties, { relationships: relationshipValidatorSchemas })
|
|
494
487
|
// }
|
|
495
488
|
|
|
489
|
+
_izContext.logger.debug("validatorSchema-create::", validatorSchemaForCreate);
|
|
496
490
|
return validatorSchemaForCreate;
|
|
497
491
|
}
|
|
498
492
|
|
|
@@ -521,18 +515,37 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
521
515
|
let identifiersFieldNames = getUsedFieldNamesOfIdentifiers(_izContext, objectSchemas.identifiers, usedIdentifierTypes);
|
|
522
516
|
|
|
523
517
|
let canUpdateFieldNames = [];
|
|
518
|
+
let canUpdateProperties = {};
|
|
524
519
|
let usedFieldNames = identifiersFieldNames;
|
|
525
520
|
let versionedDataFieldNames = [];
|
|
521
|
+
|
|
526
522
|
// collect canUpdate fieldName (all fieldName have CanUpdate setting = true)
|
|
527
523
|
for (let [fieldName, fieldNameSetting] of Object.entries(objectSchemas.fieldNames)) {
|
|
528
|
-
if (
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
524
|
+
if (settings.handler === "ApiGateway") {
|
|
525
|
+
if (fieldNameSetting.userCanUpdate === true) {
|
|
526
|
+
canUpdateFieldNames.push(fieldName);
|
|
527
|
+
canUpdateProperties[fieldName] = {
|
|
528
|
+
type: fieldNameSetting.type
|
|
529
|
+
}
|
|
530
|
+
if (fieldNameSetting.hasOwnProperty("versionedDataLabel")) {
|
|
531
|
+
versionedDataFieldNames.push(fieldName)
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
} else {
|
|
535
|
+
if (fieldNameSetting.canUpdate === true || fieldNameSetting.canUpdate === undefined) {
|
|
536
|
+
canUpdateFieldNames.push(fieldName);
|
|
537
|
+
canUpdateProperties[fieldName] = {
|
|
538
|
+
type: fieldNameSetting.type,
|
|
539
|
+
}
|
|
540
|
+
if (fieldNameSetting.hasOwnProperty("versionedDataLabel")) {
|
|
541
|
+
versionedDataFieldNames.push(fieldName)
|
|
542
|
+
}
|
|
532
543
|
}
|
|
533
544
|
}
|
|
534
545
|
}
|
|
535
546
|
|
|
547
|
+
_izContext.logger.debug("canUpdate::::", { canUpdateFieldNames, canUpdateProperties });
|
|
548
|
+
|
|
536
549
|
// collect usedFieldNames
|
|
537
550
|
if (settings?.specificFieldNames) {
|
|
538
551
|
if (settings.specificFieldNames.length) {
|
|
@@ -553,13 +566,13 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
553
566
|
let defaultFieldNames = usedFieldNames.filter(fieldName => !identifiersFieldNames.includes(fieldName));
|
|
554
567
|
|
|
555
568
|
_izContext.logger.debug('identifiersFieldNames : ', identifiersFieldNames);
|
|
556
|
-
_izContext.logger.debug('usedFieldNames : ', usedFieldNames);
|
|
569
|
+
_izContext.logger.debug('usedFieldNames : ', usedFieldNames); // all fieldName
|
|
557
570
|
_izContext.logger.debug("defaultFieldNames :", defaultFieldNames);
|
|
558
571
|
_izContext.logger.debug("versionedDataFieldNames :", versionedDataFieldNames);
|
|
559
572
|
|
|
560
573
|
let initialValidatorSchemaForUpdate = {
|
|
561
574
|
type: "object",
|
|
562
|
-
required: ["objInstanceFull"
|
|
575
|
+
required: ["objInstanceFull"],
|
|
563
576
|
properties: {
|
|
564
577
|
objectType: {
|
|
565
578
|
type: "string",
|
|
@@ -571,21 +584,25 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
571
584
|
properties: {
|
|
572
585
|
identifiers: {
|
|
573
586
|
type: "object",
|
|
574
|
-
...
|
|
587
|
+
...await filteredFieldNamesOfValidatorSchema(_izContext, objType, identifiersFieldNames, identifiersFieldNames)
|
|
575
588
|
},
|
|
576
589
|
fields: {
|
|
577
590
|
type: "object",
|
|
578
591
|
additionalProperties: false,
|
|
579
|
-
required: [],
|
|
580
|
-
properties: {}
|
|
592
|
+
// required: [],
|
|
593
|
+
// properties: {},
|
|
594
|
+
...await filteredFieldNamesOfValidatorSchema(_izContext, objType, [], defaultFieldNames)
|
|
595
|
+
|
|
581
596
|
},
|
|
582
597
|
}
|
|
583
598
|
},
|
|
584
599
|
versionedDataIds: {
|
|
585
600
|
type: "object",
|
|
586
601
|
additionalProperties: false,
|
|
587
|
-
required: [], // no need to required versionedDataLabel
|
|
588
|
-
properties: {},
|
|
602
|
+
// required: [], // no need to required versionedDataLabel
|
|
603
|
+
// properties: {},
|
|
604
|
+
...await filteredFieldNamesOfValidatorSchema(_izContext, objType, [], versionedDataFieldNames)
|
|
605
|
+
|
|
589
606
|
},
|
|
590
607
|
additionalParams: {
|
|
591
608
|
type: "object"
|
|
@@ -612,17 +629,24 @@ async function generateValidatorSchemaForUpdate(_izContext, objType, settings =
|
|
|
612
629
|
}
|
|
613
630
|
}
|
|
614
631
|
|
|
632
|
+
console.debug("versionedDataReturnInFieldsObjInstanceFull::::", versionedDataReturnInFieldsObjInstanceFull);
|
|
633
|
+
console.debug("initialValidatorSchemaForUpdate:::::", initialValidatorSchemaForUpdate);
|
|
634
|
+
Object.assign(
|
|
635
|
+
initialValidatorSchemaForUpdate.properties.objInstanceFull.properties.fields.properties,
|
|
636
|
+
{
|
|
637
|
+
...versionedDataReturnInFieldsObjInstanceFull,
|
|
638
|
+
...canUpdateProperties
|
|
639
|
+
}
|
|
640
|
+
);
|
|
615
641
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
_izContext.logger.debug("validatorSchema", initialValidatorSchemaForUpdate)
|
|
620
|
-
return initialValidatorSchemaForUpdate
|
|
642
|
+
_izContext.logger.debug("validatorSchema-update::", initialValidatorSchemaForUpdate);
|
|
643
|
+
return initialValidatorSchemaForUpdate;
|
|
621
644
|
}
|
|
622
645
|
|
|
623
646
|
|
|
624
647
|
|
|
625
648
|
|
|
649
|
+
|
|
626
650
|
/**
|
|
627
651
|
* generate validatorSchema by fieldNames that part of objectSchema.identifiers
|
|
628
652
|
*
|
|
@@ -648,12 +672,8 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType, setting
|
|
|
648
672
|
|
|
649
673
|
return {
|
|
650
674
|
type: "object",
|
|
651
|
-
required: ["identifiers"
|
|
675
|
+
required: ["identifiers"],
|
|
652
676
|
properties: {
|
|
653
|
-
objectType: {
|
|
654
|
-
type: "string",
|
|
655
|
-
pattern: "^[a-zA-Z0-9_-]+$"
|
|
656
|
-
},
|
|
657
677
|
identifiers: {
|
|
658
678
|
type: "object",
|
|
659
679
|
required: Object.keys(generatedIdentifiersValidatorSchema),
|
|
@@ -674,6 +694,7 @@ async function generateValidatorSchemaForIdentifier(_izContext, objType, setting
|
|
|
674
694
|
* @param {object} objType
|
|
675
695
|
* @param {string[]} requiredFieldNames
|
|
676
696
|
* @param {string[]} usedFieldNames
|
|
697
|
+
* @param {boolean} required = false
|
|
677
698
|
* @returns
|
|
678
699
|
*/
|
|
679
700
|
async function filteredFieldNamesOfValidatorSchema(_izContext, objType, requiredFieldNames, usedFieldNames) {
|
|
@@ -688,7 +709,7 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
|
|
|
688
709
|
usedFieldNames
|
|
689
710
|
});
|
|
690
711
|
|
|
691
|
-
let allValidatorSchema = await generateValidatorSchemaForExplodedDataWithCache(_izContext, objType
|
|
712
|
+
let allValidatorSchema = await generateValidatorSchemaForExplodedDataWithCache(_izContext, objType);
|
|
692
713
|
_izContext.logger.debug("filteredFieldNamesOfValidatorSchema allValidatorSchema : ", allValidatorSchema)
|
|
693
714
|
|
|
694
715
|
allValidatorSchema.required = requiredFieldNames;
|
|
@@ -698,6 +719,8 @@ async function filteredFieldNamesOfValidatorSchema(_izContext, objType, required
|
|
|
698
719
|
properties: {}
|
|
699
720
|
}
|
|
700
721
|
|
|
722
|
+
|
|
723
|
+
|
|
701
724
|
// filtered allValidatorSchema depend on usedFieldNames
|
|
702
725
|
for (let validatorFieldName in allValidatorSchema.properties) {
|
|
703
726
|
if (usedFieldNames.includes(validatorFieldName)) {
|
|
@@ -824,18 +847,19 @@ const generateValidatorFieldNameWithCache = inMemoryCacheLib(
|
|
|
824
847
|
*/
|
|
825
848
|
async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
|
|
826
849
|
|
|
827
|
-
if (fieldData.hasOwnProperty("
|
|
850
|
+
if (fieldData.hasOwnProperty("fromObjType")) {
|
|
828
851
|
// validate reference
|
|
829
|
-
if (!fieldData.hasOwnProperty("
|
|
852
|
+
if (!fieldData.hasOwnProperty("fromObjType")) {
|
|
830
853
|
throw new Error(`Invalid reference fieldName:${fieldName}`);
|
|
831
854
|
}
|
|
832
855
|
|
|
833
856
|
let objectSchemaChild = await getObjSchemaS3WithHierarchy(
|
|
834
857
|
_izContext,
|
|
835
|
-
{
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
}
|
|
858
|
+
// {
|
|
859
|
+
// serviceTag: fieldData.fromServiceNameTag,
|
|
860
|
+
// objectType: fieldData.fromObjectType
|
|
861
|
+
// }
|
|
862
|
+
fieldData.fromObjType
|
|
839
863
|
);
|
|
840
864
|
|
|
841
865
|
let usedIdentifier = null
|
|
@@ -856,12 +880,8 @@ async function generateValidatorFieldName(_izContext, fieldName, fieldData) {
|
|
|
856
880
|
|
|
857
881
|
for (let compositeKey of identifierCompositeKeys) {
|
|
858
882
|
|
|
859
|
-
if (objectSchemaChild.fieldNames[compositeKey].hasOwnProperty("
|
|
860
|
-
|
|
861
|
-
) {
|
|
862
|
-
|
|
863
|
-
if (!objectSchemaChild.fieldNames[compositeKey].hasOwnProperty("fromObjectType")
|
|
864
|
-
|| !objectSchemaChild.fieldNames[compositeKey].hasOwnProperty("fromServiceNameTag")
|
|
883
|
+
if (objectSchemaChild.fieldNames[compositeKey].hasOwnProperty("fromObjType")) {
|
|
884
|
+
if (!objectSchemaChild.fieldNames[compositeKey].hasOwnProperty("fromObjType")
|
|
865
885
|
) {
|
|
866
886
|
throw new Error(`Invalid reference fieldName:${compositeKey}`);
|
|
867
887
|
}
|
|
@@ -49,14 +49,15 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
49
49
|
|
|
50
50
|
// ------- create tree first -------
|
|
51
51
|
|
|
52
|
-
if (fieldNameSetting.
|
|
52
|
+
if (fieldNameSetting.fromObjType) {
|
|
53
53
|
|
|
54
54
|
let childObjectSchema = await getObjSchemaS3WithHierarchy(
|
|
55
55
|
_izContext,
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
56
|
+
// {
|
|
57
|
+
// objectType: fieldNameSetting.fromObjectType,
|
|
58
|
+
// serviceTag: fieldNameSetting.fromServiceNameTag
|
|
59
|
+
// },
|
|
60
|
+
fieldNameSetting.fromObjType,
|
|
60
61
|
process.env.iz_serviceSchemaBucketName
|
|
61
62
|
);
|
|
62
63
|
|
|
@@ -89,10 +90,11 @@ async function generateDeliminatorTreePerFieldName(_izContext, fieldName, fieldN
|
|
|
89
90
|
_izContext,
|
|
90
91
|
eachKey, // fieldName
|
|
91
92
|
childObjectSchema.fieldNames[eachKey], // fieldName setting
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
93
|
+
// {
|
|
94
|
+
// objectType: fieldNameSetting.fromObjectType,
|
|
95
|
+
// serviceTag: fieldNameSetting.fromServiceNameTag
|
|
96
|
+
// },
|
|
97
|
+
fieldNameSetting.fromObjType,
|
|
96
98
|
iter
|
|
97
99
|
);
|
|
98
100
|
_izContext.logger.debug("childDeliminator: ", childDeliminator)
|
|
@@ -199,9 +201,9 @@ async function generateDeliminatorTreeIdentifier(_izContext, objectSchema) {
|
|
|
199
201
|
|
|
200
202
|
// collect deliminatorTree of composite key
|
|
201
203
|
await Promise.all(identifier.fieldNames.map(async (compositeKey) => {
|
|
202
|
-
let
|
|
203
|
-
_izContext.logger.debug("
|
|
204
|
-
Object.assign(compositeKeysDeliminatorTree,
|
|
204
|
+
let compositeKeyDeliminatorTree = await generateDeliminatorTreePerFieldName(_izContext, compositeKey, objectSchema.fieldNames[compositeKey]);
|
|
205
|
+
_izContext.logger.debug("compositeKeyDeliminatorTree each fieldname: ", compositeKeyDeliminatorTree);
|
|
206
|
+
Object.assign(compositeKeysDeliminatorTree, compositeKeyDeliminatorTree);
|
|
205
207
|
}));
|
|
206
208
|
|
|
207
209
|
// calculate deliminatorTree of identifier
|
|
@@ -122,8 +122,9 @@ function explodeDataField(
|
|
|
122
122
|
* @param {Object} requestParams
|
|
123
123
|
* @param {Object} objType
|
|
124
124
|
*/
|
|
125
|
-
async function explodedDataForCreate(_izContext, requestParams, objectSchema) {
|
|
126
|
-
|
|
125
|
+
async function explodedDataForCreate(_izContext, requestParams, objectSchema, settings) {
|
|
126
|
+
_izContext.logger.debug("explodedDataForCreate::", { requestParams, objectSchema });
|
|
127
|
+
_izContext.logger.debug("settings: ", settings);
|
|
127
128
|
// ------- validate requestParams -------
|
|
128
129
|
let errors = [];
|
|
129
130
|
|
|
@@ -225,10 +226,9 @@ async function explodedDataForCreate(_izContext, requestParams, objectSchema) {
|
|
|
225
226
|
* @param {Object} requestParams
|
|
226
227
|
* @param {Object} objType
|
|
227
228
|
*/
|
|
228
|
-
async function explodedDataForIdentifiers(_izContext, requestParams, objectSchema) {
|
|
229
|
-
_izContext.logger.debug("explodedDataForIdentifiers
|
|
230
|
-
|
|
231
|
-
);
|
|
229
|
+
async function explodedDataForIdentifiers(_izContext, requestParams, objectSchema, settings) {
|
|
230
|
+
_izContext.logger.debug("explodedDataForIdentifiers::", { requestParams, objectSchema });
|
|
231
|
+
_izContext.logger.debug("settings: ", settings);
|
|
232
232
|
|
|
233
233
|
// ------- manual validate requestParams -------
|
|
234
234
|
let errors = [];
|
|
@@ -339,13 +339,10 @@ async function explodedDataForIdentifiers(_izContext, requestParams, objectSchem
|
|
|
339
339
|
return explodedReqParams;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
async function explodedDataForUpdate(_izContext, requestParams, objectSchema) {
|
|
342
|
+
async function explodedDataForUpdate(_izContext, requestParams, objectSchema, settings) {
|
|
343
343
|
//validate requestParams
|
|
344
|
-
_izContext.logger.debug("explodedDataForUpdate::",
|
|
345
|
-
|
|
346
|
-
requestParams, objectSchema, settings
|
|
347
|
-
}
|
|
348
|
-
)
|
|
344
|
+
_izContext.logger.debug("explodedDataForUpdate::", { requestParams, objectSchema });
|
|
345
|
+
_izContext.logger.debug("settings: ", settings);
|
|
349
346
|
let errorsFound = [];
|
|
350
347
|
|
|
351
348
|
const propertiesTypeForUpdate = {
|
|
@@ -465,6 +462,15 @@ async function explodedDataForUpdate(_izContext, requestParams, objectSchema) {
|
|
|
465
462
|
)
|
|
466
463
|
)
|
|
467
464
|
}
|
|
465
|
+
|
|
466
|
+
for (let reqKey in requestParams) {
|
|
467
|
+
if (reqKey === "fieldNames") {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
Object.assign(explodedReqParams, { [reqKey]: requestParams[reqKey] });
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
console.debug("explodedReqParams-update", JSON.stringify(explodedReqParams, null, 2));
|
|
468
474
|
return explodedReqParams
|
|
469
475
|
}
|
|
470
476
|
|