@izara_project/izara-core-library-service-schemas 1.0.104 → 1.0.105

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-library-service-schemas",
3
- "version": "1.0.104",
3
+ "version": "1.0.105",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,12 +24,12 @@
24
24
  "@aws-sdk/client-api-gateway": "^3.943.0",
25
25
  "@aws-sdk/client-apigatewayv2": "^3.943.0",
26
26
  "@aws-sdk/client-lambda": "^3.943.0",
27
- "@aws-sdk/client-s3": "^3.943.0",
28
27
  "@aws-sdk/crc64-nvme-crt": "^3.943.0",
29
28
  "@izara_project/izara-core-library-core": "^1.0.29",
30
29
  "@izara_project/izara-core-library-external-request": "^1.0.22",
31
30
  "@izara_project/izara-core-library-lambda": "^1.0.6",
32
31
  "@izara_project/izara-core-library-logger": "^1.0.8",
32
+ "@izara_project/izara-core-library-s3": "^1.0.4",
33
33
  "@izara_project/izara-shared-core": "^1.0.8",
34
34
  "@izara_project/izara-shared-service-schemas": "^1.0.34",
35
35
  "glob": "^13.0.0",
@@ -129,6 +129,7 @@ async function uploadObjectSchemaByUseCase(_izContext, bucketName) {
129
129
 
130
130
  const allObjectRelationships = await getObjectSchema.getAllLocalRelationshipSchema(_izContext)
131
131
  const allReferenceObjectRelationships = await getObjectSchema.getAllLocalRefObjectRelationshipSchema(_izContext)
132
+
132
133
  let refRelationshipPerObjectType = uploadUseCase.groupRefObjectRelPerObjectType(_izContext, allReferenceObjectRelationships);
133
134
  _izContext.logger.debug("refRelationshipPerObjectType: ", refRelationshipPerObjectType);
134
135
 
package/src/Utils.js CHANGED
@@ -26,12 +26,6 @@ import { basicValidatorSchema, validateObjType, reformatObjectSchema } from '@iz
26
26
 
27
27
  import consts from './Consts.js';
28
28
 
29
- import {
30
- APIGatewayClient,
31
- GetRestApisCommand,
32
- GetResourcesCommand,
33
- } from "@aws-sdk/client-api-gateway";
34
-
35
29
  import {
36
30
  ApiGatewayV2Client,
37
31
  GetApisCommand,
@@ -1254,58 +1254,65 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1254
1254
  for (const flowSchema of allFlowSchemas) {
1255
1255
  const [status, errors] = utils.validateBasicFlowSchema(_izContext, flowSchema)
1256
1256
 
1257
- if (!flowSchema.hasOwnProperty("objType")) {
1257
+ if (!status) {
1258
1258
  validateStatus.status = false;
1259
- validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
1260
- } else {
1261
- let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
1259
+ validateStatus.validateErrors.push(errors);
1260
+ }
1262
1261
 
1263
- if (!objSchema) {
1262
+ if (flowSchema.statusType !== none) {
1263
+ if (!flowSchema.hasOwnProperty("objType")) {
1264
1264
  validateStatus.status = false;
1265
- validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1265
+ validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
1266
1266
  } else {
1267
+ let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
1268
+
1269
+ if (!objSchema) {
1270
+ validateStatus.status = false;
1271
+ validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1272
+ } else {
1267
1273
 
1268
- let dynamoDBStorageTags = [];
1274
+ let dynamoDBStorageTags = [];
1269
1275
 
1270
- for (const [storageTag, storageResource] of Object.entries(objSchema.storageResources)) {
1271
- if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
1272
- dynamoDBStorageTags.push(storageTag)
1276
+ for (const [storageTag, storageResource] of Object.entries(objSchema.storageResources)) {
1277
+ if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
1278
+ dynamoDBStorageTags.push(storageTag)
1279
+ }
1273
1280
  }
1274
- }
1275
1281
 
1276
- if (dynamoDBStorageTags.length > 1) {
1277
- validateStatus.status = false;
1278
- validateStatus.validateErrors.push(`objectType:${objSchema.objectType} should not shave more than 1 dynamoDB storageResource`)
1279
- } else {
1282
+ if (dynamoDBStorageTags.length > 1) {
1283
+ validateStatus.status = false;
1284
+ validateStatus.validateErrors.push(`objectType:${objSchema.objectType} should not shave more than 1 dynamoDB storageResource`)
1285
+ } else {
1280
1286
 
1281
- if (flowSchema.statusType === "statusField") {
1282
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(utils.createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), 'statusField'))
1287
+ if (flowSchema.statusType === "statusField") {
1288
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(utils.createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), 'statusField'))
1283
1289
 
1284
- for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1285
- if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
1286
- if (!objSchema.fieldNames[specificFieldName].storageResourceTags.includes(dynamoDBStorageTags[0])) {
1290
+ for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1291
+ if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
1292
+ if (!objSchema.fieldNames[specificFieldName].storageResourceTags.includes(dynamoDBStorageTags[0])) {
1293
+ validateStatus.status = false;
1294
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} fieldNames: ${specificFieldName} not have storageResourceTag: ${dynamoDBStorageTags[0]}`);
1295
+ }
1296
+ } else {
1287
1297
  validateStatus.status = false;
1288
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} fieldNames: ${specificFieldName} not have storageResourceTag: ${dynamoDBStorageTags[0]}`);
1298
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1289
1299
  }
1290
- } else {
1291
- validateStatus.status = false;
1292
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1293
1300
  }
1294
- }
1295
1301
 
1296
1302
 
1297
- } else if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
1298
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(utils.createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), "cacheTable"))
1303
+ } else if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
1304
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(utils.createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), "cacheTable"))
1299
1305
 
1300
- for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1301
- if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
1302
- if (!objSchema.fieldNames[specificFieldName].storageResourceTags.includes(dynamoDBStorageTags[0])) {
1306
+ for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1307
+ if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
1308
+ if (!objSchema.fieldNames[specificFieldName].storageResourceTags.includes(dynamoDBStorageTags[0])) {
1309
+ validateStatus.status = false;
1310
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} fieldNames: ${specificFieldName} not have storageResourceTag: ${dynamoDBStorageTags[0]}`);
1311
+ }
1312
+ } else {
1303
1313
  validateStatus.status = false;
1304
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} fieldNames: ${specificFieldName} not have storageResourceTag: ${dynamoDBStorageTags[0]}`);
1314
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1305
1315
  }
1306
- } else {
1307
- validateStatus.status = false;
1308
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1309
1316
  }
1310
1317
  }
1311
1318
  }
@@ -1313,10 +1320,6 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1313
1320
  }
1314
1321
  }
1315
1322
 
1316
- if (!status) {
1317
- validateStatus.status = false;
1318
- validateStatus.validateErrors.push(errors);
1319
- }
1320
1323
  }
1321
1324
 
1322
1325
  }
@@ -263,6 +263,10 @@ function groupRelationshipsPerObjectType(_izContext, allObjectRelationships, obj
263
263
  objectType,
264
264
  serviceTag: process.env.iz_serviceTag
265
265
  },
266
+ // {
267
+ // relationshipTag,
268
+ // serviceTag: process.env.iz_serviceTag
269
+ // },
266
270
  relationshipTagData
267
271
  );
268
272
 
@@ -307,16 +311,16 @@ function groupLinksPerObjectType(_izContext, allObjectRelationships, objectTypes
307
311
 
308
312
  for (let objectType of objectTypes) {
309
313
 
310
- const linkRecords = utils.findLinkByObjType(
314
+ const linkRecords = utils.findLinkByObjTypeV2(
311
315
  _izContext,
312
316
  { // objType
313
317
  objectType,
314
318
  serviceTag: process.env.iz_serviceTag
315
319
  },
316
- // { // relType
317
- // relationshipTag,
318
- // serviceTag: process.env.iz_serviceTag
319
- // },
320
+ { // relType
321
+ relationshipTag,
322
+ serviceTag: process.env.iz_serviceTag
323
+ },
320
324
  relationshipTagData
321
325
  );
322
326
 
@@ -16,26 +16,24 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
-
20
- import("@aws-sdk/crc64-nvme-crt");
21
- import {
22
- S3Client,
23
- GetObjectCommand,
24
- HeadObjectCommand,
25
- ListObjectsV2Command,
26
- DeleteObjectCommand,
27
- DeleteObjectsCommand,
28
- PutObjectCommand,
29
- } from "@aws-sdk/client-s3";
30
-
31
19
  import { objectHash as hash } from '@izara_project/izara-shared-core';
32
20
 
33
21
  import { NoRetryError, inMemoryCacheLib } from '@izara_project/izara-core-library-core';
34
22
  import { consts } from '@izara_project/izara-shared-service-schemas';
23
+ import Logger from '@izara_project/izara-core-library-logger';
35
24
  import coreConsts from '../Consts.js';
36
25
 
37
- const s3Client = new S3Client();
26
+ import { s3 } from '@izara_project/izara-core-library-s3'
27
+ const {
28
+ getObjectS3: getObjectS3Lib,
29
+ headObjectS3: headObjectS3Lib,
30
+ listObjectsV2: listObjectS3Lib,
31
+ deleteObject: deleteObjectS3Lib,
32
+ deleteObjects: deleteObjectsS3Lib,
33
+ putObjectS3: putObjectS3Lib
34
+ } = s3;
38
35
 
36
+ const _izContext = { Logger };
39
37
 
40
38
  /**
41
39
  * This function is a simplified version of getObjectS3
@@ -44,20 +42,8 @@ const s3Client = new S3Client();
44
42
  * @returns
45
43
  */
46
44
  async function getObjectS3Shared(param) {
47
- let object = [];
48
- try {
49
- const response = await s3Client.send(new GetObjectCommand(param));
50
- object[0] = JSON.parse(await response.Body.transformToString('utf-8'));
51
- object[1] = response;
52
- } catch (error) {
53
- if (error.name === "NoSuchKey") {
54
- object = [null, null]; // Return null if the object doesn't exist
55
- } else {
56
- throw new NoRetryError(error); // Rethrow for further handling
57
- }
58
- }
59
-
60
- return object;
45
+ return await getObjectS3Lib(_izContext, param);
46
+ ;
61
47
  }
62
48
 
63
49
 
@@ -107,42 +93,25 @@ async function getObjectS3(_izContext, param) {
107
93
  }
108
94
 
109
95
  async function headObjectS3(_izContext, param) {
110
- let headObject
111
- try {
112
- headObject = await s3Client.send(new HeadObjectCommand(param));
113
- // headObject = JSON.parse(await response.Body.transformToString('utf-8'));
114
- } catch (error) {
115
- if (error.name === "NotFound") {
116
- headObject = null; // Return null if the object doesn't exist
117
- } else {
118
- _izContext.logger.error(error); // Log other errors
119
- throw new NoRetryError(error); // Rethrow for further handling
120
- }
121
- }
122
- return headObject
96
+
97
+ return await headObjectS3Lib(_izContext, param)
123
98
  }
124
99
 
125
100
  async function listObjectsV2(_izContext, param) {
126
- return await s3Client.send(new ListObjectsV2Command(param));
101
+ return await listObjectS3Lib(_izContext, param)
127
102
  }
128
103
 
129
104
 
130
105
  async function deleteObject(_izContext, param) {
131
- const deleteObjectResult = await s3Client.send(new DeleteObjectCommand(param));
132
- _izContext.logger.debug("deleteObject result: ", deleteObjectResult);
133
- return deleteObjectResult;
106
+ return await deleteObjectS3Lib(_izContext, param);
134
107
  }
135
108
 
136
109
  async function deleteObjects(_izContext, param) {
137
- const deleteObjectsResult = await s3Client.send(new DeleteObjectsCommand(param));
138
- _izContext.logger.debug("deleteObjects result: ", deleteObjectsResult);
139
- return deleteObjectsResult;
110
+ return await deleteObjectsS3Lib(_izContext, param);
140
111
  }
141
112
 
142
113
  async function putObjectS3(_izContext, param) {
143
- const putResult = await s3Client.send(new PutObjectCommand(param));
144
- _izContext.logger.debug("putObject result: ", putResult);
145
- return putResult;
114
+ return await putObjectS3Lib(_izContext, param);
146
115
  }
147
116
 
148
117
  export default {