@izara_project/izara-core-library-service-schemas 1.0.88 → 1.0.90

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.88",
3
+ "version": "1.0.90",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Utils.js CHANGED
@@ -743,8 +743,8 @@ async function getApiLinksV2(objectTypes) {
743
743
 
744
744
  do {
745
745
  const apisRes = await client.send(new GetApisCommand({ NextToken: nextToken }));
746
-
747
- for (const api of apisRes.Items) {
746
+ let httpsApi = apisRes.Items.filter(api => api.ApiEndpoint && api.ApiEndpoint.startsWith("https:"))
747
+ for (const api of httpsApi) {
748
748
  const { Name: apiName, ApiId: apiId } = api;
749
749
  let routeResResult = []
750
750
  let routeRestToken;
@@ -764,12 +764,12 @@ async function getApiLinksV2(objectTypes) {
764
764
  if (routeKeyParts.length !== 2) continue; // Invalid format
765
765
 
766
766
  const [method, path] = routeKeyParts;
767
- const [_, object, action] = path.split("/")
767
+ const [_, serviceTag, object, action] = path.split("/")
768
768
  for (const objectType of objectTypes) {
769
769
  if (method === "POST" && path.endsWith("get")) {
770
770
  if (object === consts.firstLetterLowerCase(objectType)) {
771
771
  // console.log({ path, objectType: consts.firstLetterLowerCase(objectType) })
772
- const fullUrl = `https://${apiId}.execute-api.${process.env.iz_region}.amazonaws.com/${process.env.iz_serviceTag}${path}`;
772
+ const fullUrl = `https://${apiId}.execute-api.${process.env.iz_region}.amazonaws.com${path}`;
773
773
  urls.push({
774
774
  Url: fullUrl,
775
775
  });
@@ -792,6 +792,7 @@ async function getApiLinksV2(objectTypes) {
792
792
  console.error("Error fetching API info:", err);
793
793
  }
794
794
  }
795
+
795
796
  module.exports = {
796
797
  createObjType,
797
798
  getIdentifierTypeByPriority,
@@ -25,7 +25,7 @@ const Logger = require('@izara_project/izara-core-library-logger');
25
25
  const uploadUseCase = require('./libs/UploadUseCase')
26
26
 
27
27
  const { getGraphServiceTag, getServiceName } = require('./ServiceConfig')
28
- const { createLinkTypeId } = require('./Utils');
28
+ const { createLinkTypeId, createFlowTypeConcat } = require('./Utils');
29
29
  const hash = require('@izara_project/izara-shared-core').objectHash;
30
30
  const {
31
31
  validateObjectSchema,
@@ -67,6 +67,35 @@ const {
67
67
  } = require("./Consts");
68
68
  const { validateObjType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
69
69
 
70
+ // module.exports.createFieldNameUniqueRequestId = (prefix = 'cache') => {
71
+ // return prefix + "UniqueRequestId";
72
+ // }
73
+
74
+ // module.exports.createFieldNameStatus = (prefix = 'cache') => {
75
+ // return prefix + 'Status';
76
+ // }
77
+
78
+ // module.exports.createFieldNameErrorsFound = (prefix = 'cache') => {
79
+ // return prefix + 'ErrorsFound';
80
+ // }
81
+
82
+ // module.exports.createFieldNameCacheComplete = (prefix = 'cache') => { // timeStamp
83
+ // return prefix + 'CacheComplete';
84
+ // }
85
+
86
+ // module.exports.createFlowParamsFieldName = (prefix = 'cache') => {
87
+ // return prefix + 'FlowParams';
88
+ // }
89
+
90
+ function createSpecificFieldNameForCacheTable(prefix = 'cache') {
91
+ return {
92
+ uniqueRequestId: prefix + "UniqueRequestId",
93
+ fieldNameStatus: prefix + "Status",
94
+ errorsFound: prefix + 'ErrorsFound',
95
+ cacheComplete: prefix + 'CacheComplete',
96
+ flowParams: prefix + 'FlowParams'
97
+ }
98
+ }
70
99
 
71
100
  /**
72
101
  * helper function: generate validatorSchemaTree of fieldName
@@ -1221,7 +1250,7 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1221
1250
  for (const flowSchema of allFlowSchemas) {
1222
1251
  const [status, errors] = validateBasicFlowSchema(_izContext, flowSchema)
1223
1252
 
1224
- if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "statusField" || flowSchema.statusType === "triggerCache") {
1253
+ if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") { // validate triggerCache
1225
1254
  if (!flowSchema.hasOwnProperty("objType")) {
1226
1255
  validateStatus.status = false;
1227
1256
  validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
@@ -1233,13 +1262,53 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1233
1262
 
1234
1263
  if (!objSchema) {
1235
1264
  validateStatus.status = false;
1236
- validateStatus.validateErrors.push(`${flowSchema}.objType is invalid`)
1265
+ validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1266
+ } else {
1267
+ if (Object.keys(objSchema.storageResources).length > 1) { // check for objectSchema must have 1 storageResource
1268
+ validateStatus.status = false;
1269
+ validateStatus.validateErrors.push(`storageResource of objectType:${objSchema.objectType} serviceTag:${flowSchema.objType.serviceTag} is not single storageResource`)
1270
+ } else if (Object.keys(objSchema.storageResources).length = 1) {
1271
+ for (const storageResource of Object.values(objSchema.storageResources)) {
1272
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) { // check for dynamoDB storageResource
1273
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag })))
1274
+ const fieldNames = Object.keys(objSchema.fieldNames)
1275
+ for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1276
+ if (!fieldNames.includes(specificFieldName)) {
1277
+ validateStatus.status = false;
1278
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1279
+ }
1280
+ }
1281
+ } else {
1282
+ validateStatus.status = false;
1283
+ validateStatus.validateErrors.push(`storageResource of objectType:${objSchema.objectType} serviceTag:${flowSchema.objType.serviceTag} must be dynamoDb`)
1284
+ }
1285
+ }
1286
+ }
1287
+ }
1288
+
1289
+
1290
+
1291
+ if (!status) {
1292
+ validateStatus.status = false;
1293
+ validateStatus.validateErrors.push(errors);
1237
1294
  }
1238
1295
  }
1296
+ }
1239
1297
 
1240
- if (!status) {
1298
+ if (flowSchema.statusType === "statusField") {
1299
+ if (!flowSchema.hasOwnProperty("objType")) {
1241
1300
  validateStatus.status = false;
1242
- validateStatus.validateErrors.push(errors);
1301
+ validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
1302
+ } else {
1303
+ let objSchema = await getObjSchemaS3WithHierarchy(_izContext, {
1304
+ objectType: flowSchema.objType.objectType,
1305
+ serviceTag: flowSchema.objType.serviceTag
1306
+ })
1307
+
1308
+ if (!objSchema) {
1309
+ validateStatus.status = false;
1310
+ validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1311
+ }
1243
1312
  }
1244
1313
  }
1245
1314
  }