Skip to content

Commit

Permalink
Merge pull request #1059 from JupiterOne/APP-15115
Browse files Browse the repository at this point in the history
[APP-15115] - Add integration-sdk-entity-validator package
  • Loading branch information
Geovanni Pacheco authored Apr 18, 2024
2 parents 4030569 + 820f174 commit d2621ab
Show file tree
Hide file tree
Showing 16 changed files with 1,205 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to

# Unreleased

- entity-validator: first release

## 12.4.1 - 2024-04-11

- updated `json-diff` dependency
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"clean": "yarn lerna clean --yes && yarn clean:build && rm -r node_modules",
"clean:build": "yarn lerna exec \"rm -rf ./dist tsconfig.tsbuildinfo\"",
"prebuild": "yarn clean:build",
"build": "tsc -b packages/integration-sdk-core packages/integration-sdk-runtime packages/integration-sdk-private-test-utils packages/integration-sdk-cli packages/integration-sdk-testing packages/integration-sdk-http-client packages/integration-sdk-entities",
"build": "tsc -b packages/integration-sdk-entity-validator packages/integration-sdk-core packages/integration-sdk-runtime packages/integration-sdk-private-test-utils packages/integration-sdk-cli packages/integration-sdk-testing packages/integration-sdk-http-client packages/integration-sdk-entities",
"prebuild:dist": "yarn clean:build",
"build:dist": "lerna run build:dist",
"format": "prettier --write \"**/*.{ts,js,json,md,yml}\"",
Expand Down
373 changes: 373 additions & 0 deletions packages/integration-sdk-entity-validator/LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/integration-sdk-entity-validator/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../babel.config');
3 changes: 3 additions & 0 deletions packages/integration-sdk-entity-validator/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('../../jest.config.base'),
};
35 changes: 35 additions & 0 deletions packages/integration-sdk-entity-validator/package.json
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"
}
}
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',
});
});
});
Loading

0 comments on commit d2621ab

Please sign in to comment.