@izara_project/izara-core-library-service-schemas 1.0.97 → 1.0.99

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.97",
3
+ "version": "1.0.99",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -88,14 +88,21 @@ const { validateObjType } = require('@izara_project/izara-shared-service-schemas
88
88
  // return prefix + 'FlowParams';
89
89
  // }
90
90
 
91
- function createSpecificFieldNameForCacheTable(prefix = 'cache') {
91
+ function createSpecificFieldNameForCacheTable(prefix = 'cache', statusType) {
92
92
  return {
93
- uniqueRequestId: prefix + "UniqueRequestId",
94
- fieldNameStatus: prefix + "Status",
95
- errorsFound: prefix + 'ErrorsFound',
96
- cacheComplete: prefix + 'CacheComplete',
97
- flowParams: prefix + 'FlowParams'
98
- }
93
+ 'cacheTable': {
94
+ uniqueRequestId: prefix + "UniqueRequestId",
95
+ fieldNameStatus: prefix + "Status",
96
+ errorsFound: prefix + 'ErrorsFound',
97
+ cacheComplete: prefix + 'CacheComplete',
98
+ flowParams: prefix + 'FlowParams'
99
+ },
100
+ 'statusField': {
101
+ uniqueRequestId: prefix + "UniqueRequestId",
102
+ errorsFound: prefix + "ErrorsFound",
103
+ fieldNameStatus: prefix + "Status"
104
+ }
105
+ }[statusType]
99
106
  }
100
107
 
101
108
  /**
@@ -1285,67 +1292,76 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1285
1292
  for (const flowSchema of allFlowSchemas) {
1286
1293
  const [status, errors] = validateBasicFlowSchema(_izContext, flowSchema)
1287
1294
 
1288
- if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") { // validate triggerCache
1289
- if (!flowSchema.hasOwnProperty("objType")) {
1295
+ if (!flowSchema.hasOwnProperty("objType")) {
1296
+ validateStatus.status = false;
1297
+ validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
1298
+ } else {
1299
+ let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
1300
+
1301
+ if (!objSchema) {
1290
1302
  validateStatus.status = false;
1291
- validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
1303
+ validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1292
1304
  } else {
1293
1305
 
1294
- let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
1306
+ let dynamoDBStorageTags = [];
1295
1307
 
1296
- console.log("objSchema: ", objSchema)
1308
+ for (const [storageTag, storageResource] of Object.entries(objSchema.storageResources)) {
1309
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
1310
+ dynamoDBStorageTags.push(storageTag)
1311
+ }
1312
+ }
1297
1313
 
1298
- if (!objSchema) {
1314
+ if (dynamoDBStorageTags.length > 1) {
1299
1315
  validateStatus.status = false;
1300
- validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1316
+ validateStatus.validateErrors.push(`objectType:${objSchema.objectType} should not shave more than 1 dynamoDB storageResource`)
1301
1317
  } else {
1302
- if (Object.keys(objSchema.storageResources).length > 1) { // check for objectSchema must have 1 storageResource
1303
- validateStatus.status = false;
1304
- validateStatus.validateErrors.push(`storageResource of objectType:${objSchema.objectType} serviceTag:${flowSchema.objType.serviceTag} is not single storageResource`)
1305
- } else if (Object.keys(objSchema.storageResources).length = 1) {
1306
- for (const storageResource of Object.values(objSchema.storageResources)) {
1307
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) { // check for dynamoDB storageResource
1308
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag })))
1309
- const fieldNames = Object.keys(objSchema.fieldNames)
1310
- for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1311
- if (!fieldNames.includes(specificFieldName)) {
1312
- validateStatus.status = false;
1313
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1314
- }
1318
+
1319
+ if (flowSchema.statusType === "statusField") {
1320
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), 'statusField'))
1321
+
1322
+ for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1323
+ if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
1324
+ if (!objSchema.fieldNames[specificFieldName].storageResourceTags.includes(dynamoDBStorageTags[0])) {
1325
+ validateStatus.status = false;
1326
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} fieldNames: ${specificFieldName} not have storageResourceTag: ${dynamoDBStorageTags[0]}`);
1315
1327
  }
1316
1328
  } else {
1317
1329
  validateStatus.status = false;
1318
- validateStatus.validateErrors.push(`storageResource of objectType:${objSchema.objectType} serviceTag:${flowSchema.objType.serviceTag} must be dynamoDb`)
1330
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1319
1331
  }
1320
1332
  }
1321
- }
1322
- }
1323
1333
 
1324
1334
 
1335
+ } else if (flowSchema.statusType === "storedCache" || flowSchema.statusType === "triggerCache") {
1336
+ let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), "cacheTable"))
1325
1337
 
1326
- if (!status) {
1327
- validateStatus.status = false;
1328
- validateStatus.validateErrors.push(errors);
1338
+ for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1339
+ if (objSchema.fieldNames.hasOwnProperty(specificFieldName)) {
1340
+ if (!objSchema.fieldNames[specificFieldName].storageResourceTags.includes(dynamoDBStorageTags[0])) {
1341
+ validateStatus.status = false;
1342
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} fieldNames: ${specificFieldName} not have storageResourceTag: ${dynamoDBStorageTags[0]}`);
1343
+ }
1344
+ } else {
1345
+ validateStatus.status = false;
1346
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1347
+ }
1348
+ }
1349
+ }
1329
1350
  }
1330
1351
  }
1331
1352
  }
1332
1353
 
1333
- if (flowSchema.statusType === "statusField") {
1334
- if (!flowSchema.hasOwnProperty("objType")) {
1335
- validateStatus.status = false;
1336
- validateStatus.validateErrors.push(`flowSchema ${flowSchema.flowTag} must have objType`)
1337
- } else {
1338
- let [objSchema] = await getLocalOrS3ObjectSchema(flowSchema.objType);
1339
-
1340
- if (!objSchema) {
1341
- validateStatus.status = false;
1342
- validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1343
- }
1344
- }
1354
+ if (!status) {
1355
+ validateStatus.status = false;
1356
+ validateStatus.validateErrors.push(errors);
1345
1357
  }
1346
1358
  }
1359
+
1347
1360
  }
1348
1361
 
1362
+
1363
+
1364
+
1349
1365
  if (validateStatus.validateErrors.length) {
1350
1366
  validateStatus.status = false;
1351
1367
  } else {