From d789339c7ec6429c659989b32d1fde9bb5fe3675 Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Wed, 27 Dec 2023 21:54:33 -1000 Subject: [PATCH] clean up generateJsonSchemaTypes - Remove needless dep json-schema-ref-parser - Use stricter options --- lib/protocol/package.json | 1 - .../src/opencodegraph-protocol.schema.ts | 2 +- lib/schema/dev/generateJsonSchemaTypes.ts | 24 ++----------------- lib/schema/package.json | 1 - pnpm-lock.yaml | 23 ------------------ 5 files changed, 3 insertions(+), 48 deletions(-) diff --git a/lib/protocol/package.json b/lib/protocol/package.json index 89e8e355..b22d78b6 100644 --- a/lib/protocol/package.json +++ b/lib/protocol/package.json @@ -26,7 +26,6 @@ "@opencodegraph/schema": "workspace:*" }, "devDependencies": { - "json-schema-ref-parser": "^9.0.9", "json-schema-to-typescript": "^13.1.1" } } diff --git a/lib/protocol/src/opencodegraph-protocol.schema.ts b/lib/protocol/src/opencodegraph-protocol.schema.ts index 8a52ad5a..8fb10ee1 100644 --- a/lib/protocol/src/opencodegraph-protocol.schema.ts +++ b/lib/protocol/src/opencodegraph-protocol.schema.ts @@ -23,7 +23,7 @@ export interface RequestMessage { * User settings sent by the client to the provider. */ export interface ProviderSettings { - [k: string]: unknown + [k: string]: unknown | undefined } export interface ResponseMessage { result?: unknown diff --git a/lib/schema/dev/generateJsonSchemaTypes.ts b/lib/schema/dev/generateJsonSchemaTypes.ts index d0d77758..e0d7f9de 100644 --- a/lib/schema/dev/generateJsonSchemaTypes.ts +++ b/lib/schema/dev/generateJsonSchemaTypes.ts @@ -5,35 +5,15 @@ import { readFile } from 'fs/promises' import path from 'path' import { pathToFileURL } from 'url' -import { type ResolverOptions } from 'json-schema-ref-parser' import { compile as compileJSONSchema } from 'json-schema-to-typescript' -/** - * Allow json-schema-ref-parser to resolve the v7 draft of JSON Schema - * using a local copy of the spec for offline development. - */ -const draftV7resolver: ResolverOptions = { - order: 1, - read: () => readFile(path.join(__dirname, 'json-schema-draft-07.schema.json')), - canRead: file => file.url === 'http://json-schema.org/draft-07/schema', -} - async function generateSchema(schemaPath: string, preamble?: string): Promise { const schema = await readFile(schemaPath, 'utf8') const types = await compileJSONSchema(JSON.parse(schema), 'settings.schema', { bannerComment: '', // no eslint-disable cwd: path.dirname(schemaPath), - $refOptions: { - resolve: { - draftV7resolver, - // There should be no reason to make network calls during this process. If there - // are, we've broken the dev env for offline development and increased dev startup - // time. - // - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - http: false as any, - }, - }, + additionalProperties: false, + strictIndexSignatures: true, }) if (preamble) { diff --git a/lib/schema/package.json b/lib/schema/package.json index 242bf71b..57a48864 100644 --- a/lib/schema/package.json +++ b/lib/schema/package.json @@ -23,7 +23,6 @@ "prepublishOnly": "tsc --build --clean && pnpm run build" }, "devDependencies": { - "json-schema-ref-parser": "^9.0.9", "json-schema-to-typescript": "^13.1.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 032ce298..7106f647 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -405,9 +405,6 @@ importers: specifier: workspace:* version: link:../schema devDependencies: - json-schema-ref-parser: - specifier: ^9.0.9 - version: 9.0.9 json-schema-to-typescript: specifier: ^13.1.1 version: 13.1.1 @@ -430,9 +427,6 @@ importers: lib/schema: devDependencies: - json-schema-ref-parser: - specifier: ^9.0.9 - version: 9.0.9 json-schema-to-typescript: specifier: ^13.1.1 version: 13.1.1 @@ -701,15 +695,6 @@ packages: '@jridgewell/trace-mapping': 0.3.18 dev: true - /@apidevtools/json-schema-ref-parser@9.0.9: - resolution: {integrity: sha512-GBD2Le9w2+lVFoc4vswGI/TjkNIZSVp7+9xPf+X3uidBfWnAeUWmquteSyt0+VCrhNMWj/FTABISQrD3Z/YA+w==} - dependencies: - '@jsdevtools/ono': 7.1.3 - '@types/json-schema': 7.0.14 - call-me-maybe: 1.0.2 - js-yaml: 4.1.0 - dev: true - /@aw-web-design/x-default-browser@1.4.126: resolution: {integrity: sha512-Xk1sIhyNC/esHGGVjL/niHLowM0csl/kFO5uawBy4IrWwy0o1G8LGt3jP6nmWGz+USxeeqbihAmp/oVZju6wug==} hasBin: true @@ -11787,14 +11772,6 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} dev: true - /json-schema-ref-parser@9.0.9: - resolution: {integrity: sha512-qcP2lmGy+JUoQJ4DOQeLaZDqH9qSkeGCK3suKWxJXS82dg728Mn3j97azDMaOUmJAN4uCq91LdPx4K7E8F1a7Q==} - engines: {node: '>=10'} - deprecated: Please switch to @apidevtools/json-schema-ref-parser - dependencies: - '@apidevtools/json-schema-ref-parser': 9.0.9 - dev: true - /json-schema-to-typescript@13.1.1: resolution: {integrity: sha512-F3CYhtA7F3yPbb8vF7sFchk/2dnr1/yTKf8RcvoNpjnh67ZS/ZMH1ElLt5KHAtf2/bymiejLQQszszPWEeTdSw==} engines: {node: '>=12.0.0'}