-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1059 from JupiterOne/APP-15115
[APP-15115] - Add integration-sdk-entity-validator package
- Loading branch information
Showing
16 changed files
with
1,205 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../babel.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
...require('../../jest.config.base'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@jupiterone/integration-sdk-entity-validator", | ||
"version": "12.4.1", | ||
"description": "Validator for JupiterOne integration entities", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"repository": "[email protected]:JupiterOne/sdk.git", | ||
"author": "JupiterOne <[email protected]>", | ||
"license": "MPL-2.0", | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=18.0.0 <21.x" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"prebuild:dist": "rm -rf dist && mkdir dist", | ||
"build:dist": "tsc -p tsconfig.dist.json --declaration", | ||
"prepack": "yarn build:dist" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.17.0", | ||
"ts-node": "10.9.2", | ||
"typescript": "5.4.3" | ||
}, | ||
"dependencies": { | ||
"ajv": "^8.12.0", | ||
"ajv-formats": "^3.0.1", | ||
"prettier": "^3.2.5" | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/integration-sdk-entity-validator/src/__tests__/entityValidationError.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ajvErrorToEntityValidationError } from '../entityValidationError'; | ||
|
||
describe('entityValidationError', () => { | ||
test('should return property key with required keyword', () => { | ||
expect( | ||
ajvErrorToEntityValidationError('#type', { | ||
instancePath: '', | ||
schemaPath: '#/required', | ||
keyword: 'required', | ||
params: { missingProperty: '_key' }, | ||
message: "must have required property '_key'", | ||
}), | ||
).toEqual({ | ||
schemaId: '#type', | ||
property: '_key', | ||
message: "must have required property '_key'", | ||
validation: 'required', | ||
}); | ||
}); | ||
|
||
test('should return property key with required keyword', () => { | ||
expect( | ||
ajvErrorToEntityValidationError('#type', { | ||
instancePath: '/_key', | ||
schemaPath: '#/properties/_key/minLength', | ||
keyword: 'minLength', | ||
params: { limit: 10 }, | ||
message: 'must NOT have fewer than 10 characters', | ||
}), | ||
).toEqual({ | ||
schemaId: '#type', | ||
property: '_key', | ||
message: 'must NOT have fewer than 10 characters', | ||
validation: 'minLength', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.