Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace deprecated uri-js with uri-js-replace package #24

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Include human-readable messages in errors. `true` by default. `false` can be pas

### uriResolver

By default `uriResolver` is undefined and relies on the embedded uriResolver [uri-js](https://github.com/garycourt/uri-js). Pass an object that satisfies the interface [UriResolver](https://github.com/ajv-validator/ajv/blob/master/lib/types/index.ts) to be used in replacement. One alternative is [fast-uri](https://github.com/fastify/fast-uri).
By default `uriResolver` is undefined and relies on the embedded uriResolver [uri-js-replace](https://github.com/andreinwald/uri-js-replace). Pass an object that satisfies the interface [UriResolver](https://github.com/ajv-validator/ajv/blob/master/lib/types/index.ts) to be used in replacement. One alternative is [fast-uri](https://github.com/fastify/fast-uri).

### code <Badge text="v7" />

Expand Down
2 changes: 1 addition & 1 deletion lib/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import N from "./names"
import {LocalRefs, getFullPath, _getFullPath, inlineRef, normalizeId, resolveUrl} from "./resolve"
import {schemaHasRulesButRef, unescapeFragment} from "./util"
import {validateFunctionCode} from "./validate"
import * as URI from "uri-js"
import * as URI from "uri-js-replace"
import {JSONType} from "./rules"

export type SchemaRefs = {
Expand Down
2 changes: 1 addition & 1 deletion lib/compile/jtd/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const jtdForms = [
"ref",
] as const

export type JTDForm = typeof jtdForms[number]
export type JTDForm = (typeof jtdForms)[number]
2 changes: 1 addition & 1 deletion lib/compile/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {AnySchema, AnySchemaObject, UriResolver} from "../types"
import type Ajv from "../ajv"
import type {URIComponents} from "uri-js"
import type {URIComponents} from "uri-js-replace"
import {eachItem} from "./util"
import * as equal from "fast-deep-equal"
import * as traverse from "json-schema-traverse"
Expand Down Expand Up @@ -102,7 +102,7 @@
traverse(schema, {allKeys: true}, (sch, jsonPtr, _, parentJsonPtr) => {
if (parentJsonPtr === undefined) return
const fullPath = pathPrefix + jsonPtr
let baseId = baseIds[parentJsonPtr]

Check warning on line 105 in lib/compile/resolve.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'baseId' is already declared in the upper scope on line 93 column 61
if (typeof sch[schemaId] == "string") baseId = addRef.call(this, sch[schemaId])
addAnchor.call(this, sch.$anchor)
addAnchor.call(this, sch.$dynamicAnchor)
Expand Down
2 changes: 1 addition & 1 deletion lib/compile/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {AddedKeywordDefinition} from "../types"

const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"] as const

export type JSONType = typeof _jsonTypes[number]
export type JSONType = (typeof _jsonTypes)[number]

const jsonTypes: Set<string> = new Set(_jsonTypes)

Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/uri.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as uri from "uri-js"
import * as uri from "uri-js-replace"

type URI = typeof uri & {code: string}
;(uri as URI).code = 'require("ajv/dist/runtime/uri").default'
Expand Down
2 changes: 1 addition & 1 deletion lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as URI from "uri-js"
import * as URI from "uri-js-replace"
import type {CodeGen, Code, Name, ScopeValueSets, ValueScopeName} from "../compile/codegen"
import type {SchemaEnv, SchemaCxt, SchemaObjCxt} from "../compile"
import type {JSONType} from "../compile/rules"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"fast-deep-equal": "^3.1.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2",
"uri-js": "^4.2.2"
"uri-js-replace": "^1.0.1"
},
"devDependencies": {
"@ajv-validator/config": "^0.3.0",
Expand All @@ -73,7 +73,7 @@
"@rollup/plugin-typescript": "^8.2.1",
"@types/chai": "^4.2.12",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.0",
"@types/node": "^22.5.4",
"@types/require-from-string": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
Expand Down Expand Up @@ -106,7 +106,7 @@
"rollup-plugin-terser": "^7.0.2",
"ts-node": "^10.0.0",
"tsify": "^5.0.2",
"typescript": "^4.2.0"
"typescript": "^5.5.4"
},
"collective": {
"type": "opencollective",
Expand Down
2 changes: 1 addition & 1 deletion spec/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ uriResolvers.forEach((resolver) => {
if (resolver !== undefined) {
describeTitle = "fast-uri resolver"
} else {
describeTitle = "uri-js resolver"
describeTitle = "uri-js-replace resolver"
}
describe(describeTitle, () => {
describe("resolve", () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"include": ["lib"],
"compilerOptions": {
"outDir": "dist",
"lib": ["ES2018", "DOM"],
"lib": ["ESNext"],
"types": ["node"],
"allowJs": true,
"target": "ES2018",
"moduleResolution": "node",
"resolveJsonModule": true
}
}
Loading