@izara_project/izara-core-library-service-schemas 1.0.98 → 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.98",
3
+ "version": "1.0.99",
4
4
  "description": "Schemas for the service and objects it controls",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1302,34 +1302,49 @@ async function validateLocalSchema(_izContext, schemasPath, serviceConfigPath) {
1302
1302
  validateStatus.status = false;
1303
1303
  validateStatus.validateErrors.push(`${flowSchema.flowTag}.objType is invalid`)
1304
1304
  } else {
1305
- if (Object.keys(objSchema.storageResources).length > 1) { // check for objectSchema must have 1 storageResource
1305
+
1306
+ let dynamoDBStorageTags = [];
1307
+
1308
+ for (const [storageTag, storageResource] of Object.entries(objSchema.storageResources)) {
1309
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
1310
+ dynamoDBStorageTags.push(storageTag)
1311
+ }
1312
+ }
1313
+
1314
+ if (dynamoDBStorageTags.length > 1) {
1306
1315
  validateStatus.status = false;
1307
- validateStatus.validateErrors.push(`storageResource of objectType:${objSchema.objectType} serviceTag:${flowSchema.objType.serviceTag} is not single storageResource`)
1308
- } else if (Object.keys(objSchema.storageResources).length = 1) {
1309
- for (const storageResource of Object.values(objSchema.storageResources)) {
1310
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
1311
- if (flowSchema.statusType === "triggerCache" || flowSchema.statusType === "storedCache") {
1312
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), "cacheTable"))
1313
- const fieldNames = Object.keys(objSchema.fieldNames)
1314
- for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1315
- if (!fieldNames.includes(specificFieldName)) {
1316
- validateStatus.status = false;
1317
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1318
- }
1316
+ validateStatus.validateErrors.push(`objectType:${objSchema.objectType} should not shave more than 1 dynamoDB storageResource`)
1317
+ } else {
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]}`);
1319
1327
  }
1320
- } else if (flowSchema.statusType === "statusField") {
1321
- let specificFieldNames = Object.values(createSpecificFieldNameForCacheTable(createFlowTypeConcat(_izContext, { flowTag: flowSchema.flowTag, serviceTag: iz_serviceTag }), 'statusField'))
1322
- const fieldNames = Object.keys(objSchema.fieldNames)
1323
- for (const specificFieldName of specificFieldNames) { // check for specific fieldName
1324
- if (!fieldNames.includes(specificFieldName)) {
1325
- validateStatus.status = false;
1326
- validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1327
- }
1328
+ } else {
1329
+ validateStatus.status = false;
1330
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1331
+ }
1332
+ }
1333
+
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"))
1337
+
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]}`);
1328
1343
  }
1344
+ } else {
1345
+ validateStatus.status = false;
1346
+ validateStatus.validateErrors.push(`objectType: ${objSchema.objectType} not have fieldNames: ${specificFieldName} in objectSchema.fieldNames`)
1329
1347
  }
1330
- } else {
1331
- validateStatus.status = false;
1332
- validateStatus.validateErrors.push(`storageResource of ObjectType: $${flowSchema.objType.flowTag} from flowTag: ${flowSchema.flowTag} must be dynamoDB`);
1333
1348
  }
1334
1349
  }
1335
1350
  }