-
Notifications
You must be signed in to change notification settings - Fork 0
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 #20 from cuaklabs/chore/add-json-schema-pointer
Add json schema pointer
- Loading branch information
Showing
15 changed files
with
432 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/*.js | ||
**/*.mjs |
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,8 @@ | ||
/** @type { import("eslint").ESLint.ConfigData } */ | ||
module.exports = { | ||
extends: '@cuaklabs/eslint-config', | ||
parserOptions: { | ||
project: ['./tsconfig.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}; |
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,11 @@ | ||
# node modules | ||
/node_modules/ | ||
|
||
# Test coverage report | ||
/coverage | ||
|
||
# Compiled files | ||
/lib/ | ||
|
||
# Turborepo files | ||
.turbo/ |
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,9 @@ | ||
{ | ||
"*.js": [ | ||
"prettier --write" | ||
], | ||
"*.ts": [ | ||
"prettier --write", | ||
"eslint" | ||
] | ||
} |
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,20 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
<!-- | ||
## [UNRELEASED] | ||
### Added | ||
### Changed | ||
### Deprecated | ||
### Removed | ||
### Fixed | ||
### Security | ||
### Docs | ||
--> | ||
|
||
|
||
|
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,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <https://unlicense.org> |
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 @@ | ||
import { tsGlobalConfig } from '@cuaklabs/jest-config'; | ||
|
||
export default tsGlobalConfig; |
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 @@ | ||
import { jsGlobalConfig } from '@cuaklabs/jest-config'; | ||
|
||
export default jsGlobalConfig; |
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,53 @@ | ||
{ | ||
"author": "Roberto Pintos López (https://github.com/notaphplover)", | ||
"description": "JSON Schema parser", | ||
"devDependencies": { | ||
"@cuaklabs/json-schema-types": "workspace:*", | ||
"@jest/globals": "29.6.4", | ||
"@types/glob": "8.1.0", | ||
"@types/node": "18.17.14", | ||
"@typescript-eslint/eslint-plugin": "6.6.0", | ||
"@typescript-eslint/parser": "6.6.0", | ||
"eslint": "8.48.0", | ||
"eslint-import-resolver-typescript": "3.6.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-jest": "27.2.3", | ||
"eslint-plugin-prettier": "5.0.0", | ||
"jest": "29.6.4", | ||
"jest-mock": "29.6.3", | ||
"prettier": "3.0.3", | ||
"rimraf": "5.0.1", | ||
"ts-jest": "29.1.1", | ||
"ts-node": "10.9.1", | ||
"typescript": "5.2.2" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cuaklabs/ajstt/issues" | ||
}, | ||
"homepage": "https://github.com/cuaklabs/ajstt#readme", | ||
"license": "See license in \"LICENSE\" file", | ||
"exports": "./lib/index.js", | ||
"main": "lib/index.js", | ||
"name": "@cuaklabs/json-schema-pointer", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/cuaklabs/ajstt.git" | ||
}, | ||
"scripts": { | ||
"build": "tsc --build tsconfig.json", | ||
"build:clean": "rimraf lib", | ||
"format": "prettier --write ./src/**/*.ts", | ||
"lint": "eslint --ext ts --ignore-path .gitignore ./src", | ||
"prebuild": "pnpm run build:clean", | ||
"test:ts": "jest --config=jest.config.mjs --runInBand", | ||
"test:integration": "pnpm run test --selectProjects Integration", | ||
"test": "jest --config=jest.js.config.mjs --runInBand", | ||
"test:coverage": "pnpm run test --coverage", | ||
"test:uncommitted": "pnpm run test:ts --changedSince=HEAD", | ||
"test:unit": "pnpm run test --selectProjects Unit" | ||
}, | ||
"version": "0.1.0" | ||
} |
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 @@ | ||
import config from '@cuaklabs/prettier-config'; | ||
|
||
export default 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 @@ | ||
import { resolveJsonPointer } from './resolveJsonPointer'; | ||
|
||
export { resolveJsonPointer }; |
232 changes: 232 additions & 0 deletions
232
packages/parser/json-schema-pointer/src/resolveJsonPointer.spec.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,232 @@ | ||
import { beforeAll, describe, expect, it } from '@jest/globals'; | ||
|
||
import { JsonValue } from '@cuaklabs/json-schema-types'; | ||
|
||
import { resolveJsonPointer } from './resolveJsonPointer'; | ||
|
||
describe(resolveJsonPointer.name, () => { | ||
describe.each<[string, JsonValue, JsonValue | undefined]>([ | ||
[ | ||
'', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
], | ||
[ | ||
'/foo', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
['bar', 'baz'], | ||
], | ||
[ | ||
'/foo/0', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
'bar', | ||
], | ||
[ | ||
'/', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
0, | ||
], | ||
[ | ||
'/a~1b', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
1, | ||
], | ||
[ | ||
'/c%d', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
2, | ||
], | ||
[ | ||
'/e^f', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
3, | ||
], | ||
[ | ||
'/g|h', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
4, | ||
], | ||
[ | ||
'/i\\j', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
5, | ||
], | ||
[ | ||
'/k"l', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
6, | ||
], | ||
[ | ||
'/ ', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
7, | ||
], | ||
[ | ||
'/m~0n', | ||
{ | ||
'': 0, | ||
' ': 7, | ||
'a/b': 1, | ||
'c%d': 2, | ||
'e^f': 3, | ||
foo: ['bar', 'baz'], | ||
'g|h': 4, | ||
'i\\j': 5, | ||
'k"l': 6, | ||
'm~n': 8, | ||
}, | ||
8, | ||
], | ||
])( | ||
'having a "%s" pointer', | ||
( | ||
pointer: string, | ||
json: JsonValue, | ||
expectedResult: JsonValue | undefined, | ||
) => { | ||
describe('when called', () => { | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
result = resolveJsonPointer(json, pointer); | ||
}); | ||
|
||
it('should return the expected result', () => { | ||
expect(result).toStrictEqual(expectedResult); | ||
}); | ||
}); | ||
}, | ||
); | ||
}); |
Oops, something went wrong.