@izara_project/izara-core-library-service-schemas 1.0.83 → 1.0.85
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 +2 -2
- package/src/Consts.js +11 -0
- package/src/ServiceConfig.js +2 -2
- package/src/SharedUtils.js +3 -5
- package/src/UploadObjSchema.js +9 -9
- package/src/Utils.js +66 -3
- package/src/ValidatorSchema.js +1 -1
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.85",
|
|
4
4
|
"description": "Schemas for the service and objects it controls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
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.27",
|
|
33
33
|
"glob": "^11.0.3",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"object-hash": "^3.0.0",
|
package/src/Consts.js
CHANGED
|
@@ -342,6 +342,14 @@ const UPLOAD_PATH_S3 = {
|
|
|
342
342
|
getEndpointPerService: getEndpointPerService
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
function firstLetterUpperCase(str) {
|
|
346
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function firstLetterLowerCase(str) {
|
|
350
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
351
|
+
}
|
|
352
|
+
|
|
345
353
|
// --------- End Upload path ---------------
|
|
346
354
|
|
|
347
355
|
module.exports = {
|
|
@@ -370,4 +378,7 @@ module.exports = {
|
|
|
370
378
|
|
|
371
379
|
LOCAL_FILENAME: LOCAL_FILENAME,
|
|
372
380
|
createValidationFieldNameForEachType,
|
|
381
|
+
|
|
382
|
+
firstLetterUpperCase,
|
|
383
|
+
firstLetterLowerCase
|
|
373
384
|
}
|
package/src/ServiceConfig.js
CHANGED
|
@@ -42,7 +42,7 @@ async function getServiceName(
|
|
|
42
42
|
_izContext.logger.debug("getServiceName: ", serviceTag)
|
|
43
43
|
|
|
44
44
|
const getObjectParam = {
|
|
45
|
-
Bucket: process.env.iz_serviceSchemaBucketName,
|
|
45
|
+
Bucket: process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME,
|
|
46
46
|
Key: UPLOAD_PATH_S3.serviceName(_izContext, serviceTag),
|
|
47
47
|
};
|
|
48
48
|
_izContext.logger.debug("getObjectParam", getObjectParam)
|
|
@@ -82,7 +82,7 @@ const getServiceNameWithCache = inMemoryCacheLib(
|
|
|
82
82
|
async function getGraphServiceTag(
|
|
83
83
|
_izContext,
|
|
84
84
|
graphServerTag,
|
|
85
|
-
bucketName = process.env.iz_serviceSchemaBucketName
|
|
85
|
+
bucketName = process.env.iz_serviceSchemaBucketName || OBJECT_SCHEMA_BUCKET_NAME
|
|
86
86
|
) {
|
|
87
87
|
|
|
88
88
|
// get all graph serverTag
|
package/src/SharedUtils.js
CHANGED
|
@@ -78,7 +78,7 @@ async function _processNodeRelationships(
|
|
|
78
78
|
storageResourceTags,
|
|
79
79
|
objectRelationships,
|
|
80
80
|
relationshipSchema,
|
|
81
|
-
bucketName
|
|
81
|
+
bucketName = process.env.iz_serviceSchemaBucketName
|
|
82
82
|
) {
|
|
83
83
|
const { node, isBase, relationshipDirection } = nodeConfig;
|
|
84
84
|
const results = [];
|
|
@@ -500,7 +500,7 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
|
|
|
500
500
|
storageResourceTags,
|
|
501
501
|
objectRelationships,
|
|
502
502
|
relationshipSchema,
|
|
503
|
-
|
|
503
|
+
process.env.iz_serviceSchemaBucketName
|
|
504
504
|
);
|
|
505
505
|
results.push(...secondNodeResults);
|
|
506
506
|
} catch (error) {
|
|
@@ -554,8 +554,7 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
|
|
|
554
554
|
_izContext,
|
|
555
555
|
relType.relationshipTag,
|
|
556
556
|
objectLinksGroup,
|
|
557
|
-
{ depth: loopSetting.depth + 1 }
|
|
558
|
-
bucketName
|
|
557
|
+
{ depth: loopSetting.depth + 1 }
|
|
559
558
|
)
|
|
560
559
|
}
|
|
561
560
|
|
|
@@ -640,7 +639,6 @@ async function _processObjectLinksGroup(_izContext, relationshipTag, objectLinks
|
|
|
640
639
|
relType.relationshipTag,
|
|
641
640
|
objectLinksGroup,
|
|
642
641
|
{ depth: loopSetting.depth + 1 },
|
|
643
|
-
bucketName
|
|
644
642
|
)
|
|
645
643
|
}
|
|
646
644
|
} catch (error) {
|
package/src/UploadObjSchema.js
CHANGED
|
@@ -49,7 +49,7 @@ const {
|
|
|
49
49
|
validateRelationshipSchema,
|
|
50
50
|
validateRefRelationshipSchema,
|
|
51
51
|
validateBasicFlowSchema,
|
|
52
|
-
|
|
52
|
+
getApiLinksV2
|
|
53
53
|
} = require('./Utils')
|
|
54
54
|
|
|
55
55
|
const {
|
|
@@ -328,7 +328,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
328
328
|
)
|
|
329
329
|
);
|
|
330
330
|
|
|
331
|
-
let apiLink = await
|
|
331
|
+
let apiLink = await getApiLinksV2(objSchema);
|
|
332
332
|
// console.log("apiLink", apiLink)
|
|
333
333
|
uploadList.push(
|
|
334
334
|
uploadObjectToS3(
|
|
@@ -338,13 +338,13 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
|
|
|
338
338
|
)
|
|
339
339
|
)
|
|
340
340
|
|
|
341
|
-
uploadList.push(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
)
|
|
341
|
+
// uploadList.push(
|
|
342
|
+
// uploadObjectToS3(
|
|
343
|
+
// _izContext,
|
|
344
|
+
// UPLOAD_PATH_S3.getEndpointPerService(process.env.iz_serviceTag),
|
|
345
|
+
// apiLink
|
|
346
|
+
// )
|
|
347
|
+
// )
|
|
348
348
|
|
|
349
349
|
// upload to refObjectRelationships for each objectType that have createBy at UserAccount Service and belongTo
|
|
350
350
|
let existsRefObjectRel = refRelationshipPerObjectType[objSchema.objectType];
|
package/src/Utils.js
CHANGED
|
@@ -52,6 +52,13 @@ const {
|
|
|
52
52
|
GetMethodCommand,
|
|
53
53
|
} = require("@aws-sdk/client-api-gateway");
|
|
54
54
|
|
|
55
|
+
const {
|
|
56
|
+
ApiGatewayV2Client,
|
|
57
|
+
GetApisCommand,
|
|
58
|
+
GetRoutesCommand,
|
|
59
|
+
GetStagesCommand,
|
|
60
|
+
} = require("@aws-sdk/client-apigatewayv2");
|
|
61
|
+
|
|
55
62
|
function createObjType(objectType, serviceTag) {
|
|
56
63
|
if (!process.env.iz_serviceTag && !serviceTag) {
|
|
57
64
|
throw new NoRetryError('serviceNameTag not defined and iz_serviceNameTag not defined in environment variables');
|
|
@@ -683,7 +690,7 @@ function switchDirection(direction) {
|
|
|
683
690
|
}
|
|
684
691
|
}
|
|
685
692
|
|
|
686
|
-
async function
|
|
693
|
+
async function getApiLinksV1() {
|
|
687
694
|
try {
|
|
688
695
|
let apiGateway = {}
|
|
689
696
|
let position;
|
|
@@ -707,7 +714,7 @@ async function getApiLinks() {
|
|
|
707
714
|
const resourcesRes = await client.send(
|
|
708
715
|
new GetResourcesCommand({ restApiId: foundApi.id })
|
|
709
716
|
);
|
|
710
|
-
|
|
717
|
+
console.log({ resourcesRes })
|
|
711
718
|
for (const resource of resourcesRes.items) {
|
|
712
719
|
if (resource.resourceMethods) {
|
|
713
720
|
const methods = Object.keys(resource.resourceMethods);
|
|
@@ -728,6 +735,61 @@ async function getApiLinks() {
|
|
|
728
735
|
}
|
|
729
736
|
}
|
|
730
737
|
|
|
738
|
+
async function getApiLinksV2(objSchema) {
|
|
739
|
+
try {
|
|
740
|
+
const client = new ApiGatewayV2Client({ region: process.env.iz_region });
|
|
741
|
+
const urls = [];
|
|
742
|
+
const apiLink = {};
|
|
743
|
+
let nextToken;
|
|
744
|
+
|
|
745
|
+
do {
|
|
746
|
+
const apisRes = await client.send(new GetApisCommand({ NextToken: nextToken }));
|
|
747
|
+
|
|
748
|
+
for (const api of apisRes.Items) {
|
|
749
|
+
const { Name: apiName, ApiId: apiId } = api;
|
|
750
|
+
let routeResResult = []
|
|
751
|
+
let routeRestToken;
|
|
752
|
+
|
|
753
|
+
try {
|
|
754
|
+
|
|
755
|
+
do {
|
|
756
|
+
const routesRes = await client.send(new GetRoutesCommand({ ApiId: apiId, NextToken: routeRestToken }));
|
|
757
|
+
routeResResult.push(...routesRes.Items)
|
|
758
|
+
routeRestToken = routesRes.NextToken;
|
|
759
|
+
|
|
760
|
+
} while (routeRestToken)
|
|
761
|
+
|
|
762
|
+
for (const route of routeResResult) {
|
|
763
|
+
|
|
764
|
+
const routeKeyParts = route.RouteKey.split(" ");
|
|
765
|
+
if (routeKeyParts.length !== 2) continue; // Invalid format
|
|
766
|
+
|
|
767
|
+
const [method, path] = routeKeyParts;
|
|
768
|
+
if (method === "POST" && path.endsWith("get")) {
|
|
769
|
+
if (path.includes(consts.firstLetterLowerCase(objSchema.objectType))) {
|
|
770
|
+
const fullUrl = `https://${apiId}.execute-api.${process.env.iz_region}.amazonaws.com${path}`;
|
|
771
|
+
Object.assign(apiLink, { Url: fullUrl })
|
|
772
|
+
}
|
|
773
|
+
// urls.push({
|
|
774
|
+
// url: fullUrl,
|
|
775
|
+
// });
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
} catch (err) {
|
|
779
|
+
console.error(`Error processing API "${apiName}":`, err);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
nextToken = apisRes.NextToken;
|
|
784
|
+
|
|
785
|
+
} while (nextToken);
|
|
786
|
+
// console.log(apiLink)
|
|
787
|
+
return apiLink;
|
|
788
|
+
// return api;
|
|
789
|
+
} catch (err) {
|
|
790
|
+
console.error("Error fetching API info:", err);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
731
793
|
module.exports = {
|
|
732
794
|
createObjType,
|
|
733
795
|
getIdentifierTypeByPriority,
|
|
@@ -753,5 +815,6 @@ module.exports = {
|
|
|
753
815
|
explodedFlowTypeConcat,
|
|
754
816
|
|
|
755
817
|
createLinkTypeId,
|
|
756
|
-
|
|
818
|
+
getApiLinksV1,
|
|
819
|
+
getApiLinksV2
|
|
757
820
|
}
|
package/src/ValidatorSchema.js
CHANGED
|
@@ -383,7 +383,7 @@ async function generateValidatorSchemaForCreate(_izContext, objType, settings =
|
|
|
383
383
|
}
|
|
384
384
|
_izContext.logger.debug("Function:generateValidatorSchemaForCreate ", {
|
|
385
385
|
objType,
|
|
386
|
-
|
|
386
|
+
settings
|
|
387
387
|
})
|
|
388
388
|
|
|
389
389
|
const objectSchema = await getObjSchemaS3WithHierarchy(_izContext, objType);
|