@jupiterone/integration-sdk-core
Advanced tools
Comparing version 12.7.0-alpha.0 to 12.7.0
@@ -5,2 +5,3 @@ "use strict"; | ||
const data_model_1 = require("@jupiterone/data-model"); | ||
const integration_sdk_entity_validator_1 = require("@jupiterone/integration-sdk-entity-validator"); | ||
const errors_1 = require("../errors"); | ||
@@ -11,2 +12,19 @@ const converters_1 = require("./converters"); | ||
const SUPPORTED_TYPES = ['string', 'number', 'boolean']; | ||
const VALIDATOR = new integration_sdk_entity_validator_1.EntityValidator({ | ||
schemas: Object.values(data_model_1.entitySchemas), | ||
}); | ||
const validateEntityWithSchema = (entity) => { | ||
const { isValid, errors, skippedSchemas } = VALIDATOR.validateEntity(entity); | ||
const classNotFound = skippedSchemas?.find((skippedSchema) => skippedSchema.reason === 'not-found' && skippedSchema.type === 'class'); | ||
if (classNotFound) { | ||
throw new Error(`Could not find schema for class ${classNotFound.schemaId.replace('#', '')}!`); | ||
} | ||
const validationType = skippedSchemas?.find((skippedSchema) => skippedSchema.type === 'class' && | ||
skippedSchema.reason === 'type-already-validated') | ||
? 'type' | ||
: 'class'; | ||
if (!isValid) { | ||
throw new Error(`Entity fails to validate as ${validationType} '${validationType === 'type' ? entity._type : entity._class}':\n\n${JSON.stringify(errors, null, 2)}`); | ||
} | ||
}; | ||
/** | ||
@@ -19,3 +37,3 @@ * Generates an `Entity` using the provided `entityData`. | ||
if (process.env.ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION) { | ||
(0, data_model_1.validateEntityWithSchema)(generatedEntity); | ||
validateEntityWithSchema(generatedEntity); | ||
} | ||
@@ -22,0 +40,0 @@ return generatedEntity; |
{ | ||
"name": "@jupiterone/integration-sdk-core", | ||
"version": "12.7.0-alpha.0", | ||
"version": "12.7.0", | ||
"description": "The SDK for developing JupiterOne integrations", | ||
@@ -26,3 +26,4 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@jupiterone/data-model": "^0.55.0", | ||
"@jupiterone/data-model": "^0.57.0", | ||
"@jupiterone/integration-sdk-entity-validator": "^12.7.0", | ||
"lodash": "^4.17.21" | ||
@@ -33,3 +34,3 @@ }, | ||
}, | ||
"gitHead": "06d649df85d7212776b998226023517306826141" | ||
"gitHead": "8e59967c9a6a16192605492caa8c6ed760e574a8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
272631
2834
1
3
+ Added@jupiterone/data-model@0.57.0(transitive)
+ Added@jupiterone/integration-sdk-entity-validator@12.8.3(transitive)
+ Addedajv-formats@3.0.1(transitive)
+ Addedprettier@3.3.3(transitive)
- Removed@jupiterone/data-model@0.55.0(transitive)