From 1710cb6719979063af08d5e4ea24be8c65c07459 Mon Sep 17 00:00:00 2001 From: dimaananskyi Date: Fri, 6 Sep 2024 15:50:31 +0300 Subject: [PATCH 1/6] fix: replace depricated uri-js with uri-js-replace package --- docs/options.md | 2 +- lib/compile/index.ts | 2 +- lib/compile/resolve.ts | 2 +- lib/runtime/uri.ts | 2 +- lib/types/index.ts | 2 +- package.json | 4 ++-- spec/resolve.spec.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/options.md b/docs/options.md index c4a303680..d6cd2f55f 100644 --- a/docs/options.md +++ b/docs/options.md @@ -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 diff --git a/lib/compile/index.ts b/lib/compile/index.ts index 9b3f87487..8bc62c313 100644 --- a/lib/compile/index.ts +++ b/lib/compile/index.ts @@ -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 = { diff --git a/lib/compile/resolve.ts b/lib/compile/resolve.ts index 4360eab06..12e64c7fd 100644 --- a/lib/compile/resolve.ts +++ b/lib/compile/resolve.ts @@ -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" diff --git a/lib/runtime/uri.ts b/lib/runtime/uri.ts index 7dd35f9d1..bf4c095f1 100644 --- a/lib/runtime/uri.ts +++ b/lib/runtime/uri.ts @@ -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' diff --git a/lib/types/index.ts b/lib/types/index.ts index 123d9df16..6e0b31d99 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -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" diff --git a/package.json b/package.json index bc0928015..978272d6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@redocly/ajv", - "version": "8.11.0", + "version": "8.11.1", "description": "Another JSON Schema Validator", "main": "dist/ajv.js", "types": "dist/ajv.d.ts", @@ -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", diff --git a/spec/resolve.spec.ts b/spec/resolve.spec.ts index 2fe5b1041..b03dd5524 100644 --- a/spec/resolve.spec.ts +++ b/spec/resolve.spec.ts @@ -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", () => { From 387fbf7a24ad6396aad7dfa68e203936f5ea0236 Mon Sep 17 00:00:00 2001 From: dimaananskyi Date: Fri, 6 Sep 2024 16:05:32 +0300 Subject: [PATCH 2/6] chore: change tsconfig --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 56e8b8a2a..744d52617 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "include": ["lib"], "compilerOptions": { "outDir": "dist", - "lib": ["ES2018", "DOM"], + "lib": ["ESNext"], "types": ["node"], "allowJs": true, "target": "ES2018", From d2dd26c71682f6010acf2b8117e3484d005cff0f Mon Sep 17 00:00:00 2001 From: dimaananskyi Date: Fri, 6 Sep 2024 16:11:55 +0300 Subject: [PATCH 3/6] chore: revert version update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 978272d6d..7291d3744 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@redocly/ajv", - "version": "8.11.1", + "version": "8.11.0", "description": "Another JSON Schema Validator", "main": "dist/ajv.js", "types": "dist/ajv.d.ts", From da8b794ebccf3cbb91c8eff88c481d519bdca80b Mon Sep 17 00:00:00 2001 From: dimaananskyi Date: Fri, 6 Sep 2024 16:12:30 +0300 Subject: [PATCH 4/6] chore: revert tsconfig change --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 744d52617..56e8b8a2a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "include": ["lib"], "compilerOptions": { "outDir": "dist", - "lib": ["ESNext"], + "lib": ["ES2018", "DOM"], "types": ["node"], "allowJs": true, "target": "ES2018", From be1c847e2a095109adff5b0113de9259aab5a6c5 Mon Sep 17 00:00:00 2001 From: dimaananskyi Date: Fri, 6 Sep 2024 16:51:38 +0300 Subject: [PATCH 5/6] chore: change tsconfig --- package.json | 4 ++-- tsconfig.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7291d3744..06b7736b3 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/tsconfig.json b/tsconfig.json index 56e8b8a2a..942121cbc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,10 +3,11 @@ "include": ["lib"], "compilerOptions": { "outDir": "dist", - "lib": ["ES2018", "DOM"], + "lib": ["ESNext"], "types": ["node"], "allowJs": true, "target": "ES2018", + "moduleResolution": "node", "resolveJsonModule": true } } From aaae363ca847c562a6299e3e6c2dd5be92438f7a Mon Sep 17 00:00:00 2001 From: dimaananskyi Date: Fri, 6 Sep 2024 16:56:21 +0300 Subject: [PATCH 6/6] chore: prettier --- lib/compile/jtd/types.ts | 2 +- lib/compile/rules.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compile/jtd/types.ts b/lib/compile/jtd/types.ts index 7f3619576..1258050fd 100644 --- a/lib/compile/jtd/types.ts +++ b/lib/compile/jtd/types.ts @@ -13,4 +13,4 @@ export const jtdForms = [ "ref", ] as const -export type JTDForm = typeof jtdForms[number] +export type JTDForm = (typeof jtdForms)[number] diff --git a/lib/compile/rules.ts b/lib/compile/rules.ts index ea65074f9..7dbf7ab9e 100644 --- a/lib/compile/rules.ts +++ b/lib/compile/rules.ts @@ -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 = new Set(_jsonTypes)