From 95918e7012dd9bee2f32b3618673e79371ded204 Mon Sep 17 00:00:00 2001 From: Raphael Mobis Tacla Date: Mon, 17 Aug 2026 16:40:38 -0300 Subject: [PATCH 1/4] remove schema ids (makes it work inside vscode) --- schema/root.schema.json | 1 - schema/task-list.schema.json | 1 - schema/task-tier.schema.json | 3 +-- schema/task.schema.json | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/schema/root.schema.json b/schema/root.schema.json index d559961..e78cbfe 100644 --- a/schema/root.schema.json +++ b/schema/root.schema.json @@ -1,5 +1,4 @@ { - "$id": "http://osrs-taskman.com/root.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "definitions": { diff --git a/schema/task-list.schema.json b/schema/task-list.schema.json index 71ff158..0dd47b6 100644 --- a/schema/task-list.schema.json +++ b/schema/task-list.schema.json @@ -1,5 +1,4 @@ { - "$id": "http://osrs-taskman.com/task-list.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "additionalProperties": { diff --git a/schema/task-tier.schema.json b/schema/task-tier.schema.json index 68056fb..da1c728 100644 --- a/schema/task-tier.schema.json +++ b/schema/task-tier.schema.json @@ -1,5 +1,4 @@ { - "$id": "http://osrs-taskman.com/task-tier.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "required": ["name", "tasks"], @@ -12,7 +11,7 @@ "tasks": { "type": "array", "items": { - "$ref": "task.schema.json#" + "$ref": "./task.schema.json#" } } } diff --git a/schema/task.schema.json b/schema/task.schema.json index 1d20c98..ea5bbb0 100644 --- a/schema/task.schema.json +++ b/schema/task.schema.json @@ -1,5 +1,4 @@ { - "$id": "http://osrs-taskman.com/task.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "definitions": { "diary-region": { From a941757daaddd3393c80532b7985f5c689a9ce74 Mon Sep 17 00:00:00 2001 From: Raphael Mobis Tacla Date: Mon, 17 Aug 2026 16:44:15 -0300 Subject: [PATCH 2/4] bring schema ids back but without url --- schema/root.schema.json | 7 ++++--- schema/task-list.schema.json | 3 ++- schema/task-tier.schema.json | 3 ++- schema/task.schema.json | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/schema/root.schema.json b/schema/root.schema.json index e78cbfe..ae6ebdb 100644 --- a/schema/root.schema.json +++ b/schema/root.schema.json @@ -1,15 +1,16 @@ { + "$id": "root", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "definitions": { "task": { - "$ref": "task.schema.json#" + "$ref": "task" }, "task-tier": { - "$ref": "task-tier.schema.json#" + "$ref": "task-tier" }, "task-list": { - "$ref": "task-list.schema.json#" + "$ref": "task-list" } } } diff --git a/schema/task-list.schema.json b/schema/task-list.schema.json index 0dd47b6..e976056 100644 --- a/schema/task-list.schema.json +++ b/schema/task-list.schema.json @@ -1,10 +1,11 @@ { + "$id": "task-list", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "additionalProperties": { "type": "array", "items": { - "$ref": "task.schema.json#" + "$ref": "task" } } } diff --git a/schema/task-tier.schema.json b/schema/task-tier.schema.json index da1c728..4618f96 100644 --- a/schema/task-tier.schema.json +++ b/schema/task-tier.schema.json @@ -1,4 +1,5 @@ { + "$id": "task-tier", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "required": ["name", "tasks"], @@ -11,7 +12,7 @@ "tasks": { "type": "array", "items": { - "$ref": "./task.schema.json#" + "$ref": "task" } } } diff --git a/schema/task.schema.json b/schema/task.schema.json index ea5bbb0..f747153 100644 --- a/schema/task.schema.json +++ b/schema/task.schema.json @@ -1,4 +1,5 @@ { + "$id": "task", "$schema": "http://json-schema.org/draft-07/schema", "definitions": { "diary-region": { From af5ff607403dc1a0f235d48741fd8f78cf5dc675 Mon Sep 17 00:00:00 2001 From: Raphael Mobis Tacla Date: Mon, 17 Aug 2026 16:50:58 -0300 Subject: [PATCH 3/4] update reference to schema ids in scripts --- bin/gen-list.mts | 4 +--- bin/gen-types.mts | 3 +-- bin/validate-links.mts | 4 +--- bin/validate-schema.mts | 8 ++------ 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/bin/gen-list.mts b/bin/gen-list.mts index 96a2487..51034d8 100644 --- a/bin/gen-list.mts +++ b/bin/gen-list.mts @@ -9,9 +9,7 @@ const [listName, tierString] = process.argv.slice(2); const listTiers = tierString.split(','); // type "casting" is required here for type guards to work -const validateTier = ajv.getSchema( - 'http://osrs-taskman.com/task-tier.schema.json' -) as ValidateFunction; +const validateTier = ajv.getSchema('task-tier') as ValidateFunction; const listData: TaskList = {}; for (const tier of listTiers) { diff --git a/bin/gen-types.mts b/bin/gen-types.mts index bdbd58e..0396cd9 100644 --- a/bin/gen-types.mts +++ b/bin/gen-types.mts @@ -1,5 +1,4 @@ import { writeFile } from 'node:fs/promises'; -import { basename } from 'node:path'; import { compileFromFile } from 'json-schema-to-typescript'; import { pascal } from 'radash'; @@ -10,7 +9,7 @@ const typeContent = await compileFromFile(file, { type.tsEnumNames = type.tsEnumNames.map((v) => pascal(v)); } - return type?.$id ? pascal(basename(type.$id, '.schema.json')) : undefined; + return type?.$id ? pascal(type.$id) : undefined; }, inferStringEnumKeysFromValues: true, unreachableDefinitions: true, diff --git a/bin/validate-links.mts b/bin/validate-links.mts index 15e899a..02ca52b 100644 --- a/bin/validate-links.mts +++ b/bin/validate-links.mts @@ -33,9 +33,7 @@ async function validateLink(link: string, contentTypeRegex: RegExp): Promise; +const validateTier = ajv.getSchema('task-tier') as ValidateFunction; // create cache directory if needed await mkdir(CACHE_DIR, { recursive: true }); diff --git a/bin/validate-schema.mts b/bin/validate-schema.mts index d772d51..dd7ebd0 100644 --- a/bin/validate-schema.mts +++ b/bin/validate-schema.mts @@ -6,12 +6,8 @@ import type { TaskList, TaskTier } from '@/types.js'; import ajv from '@/util/ajv.mjs'; // type "casting" is required here for type guards to work -const validateTier = ajv.getSchema( - 'http://osrs-taskman.com/task-tier.schema.json' -) as ValidateFunction; -const validateList = ajv.getSchema( - 'http://osrs-taskman.com/task-list.schema.json' -) as ValidateFunction; +const validateTier = ajv.getSchema('task-tier') as ValidateFunction; +const validateList = ajv.getSchema('task-list') as ValidateFunction; const allErrors = new Map(); From 51d2ac651db38ae650042e23be683b58a4c6aeba Mon Sep 17 00:00:00 2001 From: Raphael Mobis Tacla Date: Mon, 17 Aug 2026 16:55:01 -0300 Subject: [PATCH 4/4] idk bro i cba to think --- bin/gen-list.mts | 12 +----------- bin/gen-types.mts | 3 ++- bin/validate-links.mts | 11 +---------- bin/validate-schema.mts | 4 ++-- schema/root.schema.json | 8 ++++---- schema/task-list.schema.json | 4 ++-- schema/task-tier.schema.json | 4 ++-- schema/task.schema.json | 2 +- 8 files changed, 15 insertions(+), 33 deletions(-) diff --git a/bin/gen-list.mts b/bin/gen-list.mts index 51034d8..2795114 100644 --- a/bin/gen-list.mts +++ b/bin/gen-list.mts @@ -1,23 +1,13 @@ import { mkdir, readFile, writeFile } from 'node:fs/promises'; -import { exit } from 'node:process'; -import type { ValidateFunction } from 'ajv'; import type { TaskList, TaskTier } from '@/types.js'; -import ajv from '@/util/ajv.mjs'; import fmt from '@/util/formatter.mjs'; const [listName, tierString] = process.argv.slice(2); const listTiers = tierString.split(','); -// type "casting" is required here for type guards to work -const validateTier = ajv.getSchema('task-tier') as ValidateFunction; - const listData: TaskList = {}; for (const tier of listTiers) { - const tierData = JSON.parse((await readFile(`./tiers/${tier}.json`)).toString()); - if (!validateTier(tierData)) { - console.error(`Unable to locate JSON file for tier ${tier}`); - exit(1); - } + const tierData: TaskTier = JSON.parse((await readFile(`./tiers/${tier}.json`)).toString()); listData[tierData.name] = tierData.tasks; } diff --git a/bin/gen-types.mts b/bin/gen-types.mts index 0396cd9..bdbd58e 100644 --- a/bin/gen-types.mts +++ b/bin/gen-types.mts @@ -1,4 +1,5 @@ import { writeFile } from 'node:fs/promises'; +import { basename } from 'node:path'; import { compileFromFile } from 'json-schema-to-typescript'; import { pascal } from 'radash'; @@ -9,7 +10,7 @@ const typeContent = await compileFromFile(file, { type.tsEnumNames = type.tsEnumNames.map((v) => pascal(v)); } - return type?.$id ? pascal(type.$id) : undefined; + return type?.$id ? pascal(basename(type.$id, '.schema.json')) : undefined; }, inferStringEnumKeysFromValues: true, unreachableDefinitions: true, diff --git a/bin/validate-links.mts b/bin/validate-links.mts index 02ca52b..5661426 100644 --- a/bin/validate-links.mts +++ b/bin/validate-links.mts @@ -2,10 +2,8 @@ import { hash } from 'node:crypto'; import { mkdir, readFile, writeFile } from 'node:fs/promises'; import { basename } from 'node:path'; import { exit } from 'node:process'; -import type { ValidateFunction } from 'ajv'; import { Glob } from 'glob'; import type { TaskTier } from '@/types.js'; -import ajv from '@/util/ajv.mjs'; const CACHE_DIR = './.cache/links'; const IMAGE_CONTENT_TYPE_REGEX = /^image\/(png|gif)/; @@ -32,9 +30,6 @@ async function validateLink(link: string, contentTypeRegex: RegExp): Promise; - // create cache directory if needed await mkdir(CACHE_DIR, { recursive: true }); @@ -52,11 +47,7 @@ const imageLinks = new Set(); const tierWalker = new Glob('./tiers/*.json', {}); for await (const tierFile of tierWalker) { - const tierData = JSON.parse((await readFile(tierFile)).toString()); - if (!validateTier(tierData)) { - console.error(`File ${tierFile} does not match schema`); - exit(1); - } + const tierData: TaskTier = JSON.parse((await readFile(tierFile)).toString()); for (const task of tierData.tasks) { wikiLinks.add(task.wikiLink); diff --git a/bin/validate-schema.mts b/bin/validate-schema.mts index dd7ebd0..9ddc8c9 100644 --- a/bin/validate-schema.mts +++ b/bin/validate-schema.mts @@ -6,8 +6,8 @@ import type { TaskList, TaskTier } from '@/types.js'; import ajv from '@/util/ajv.mjs'; // type "casting" is required here for type guards to work -const validateTier = ajv.getSchema('task-tier') as ValidateFunction; -const validateList = ajv.getSchema('task-list') as ValidateFunction; +const validateTier = ajv.getSchema('task-tier.schema.json') as ValidateFunction; +const validateList = ajv.getSchema('task-list.schema.json') as ValidateFunction; const allErrors = new Map(); diff --git a/schema/root.schema.json b/schema/root.schema.json index ae6ebdb..3240674 100644 --- a/schema/root.schema.json +++ b/schema/root.schema.json @@ -1,16 +1,16 @@ { - "$id": "root", + "$id": "root.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "definitions": { "task": { - "$ref": "task" + "$ref": "task.schema.json" }, "task-tier": { - "$ref": "task-tier" + "$ref": "task-tier.schema.json" }, "task-list": { - "$ref": "task-list" + "$ref": "task-list.schema.json" } } } diff --git a/schema/task-list.schema.json b/schema/task-list.schema.json index e976056..401accc 100644 --- a/schema/task-list.schema.json +++ b/schema/task-list.schema.json @@ -1,11 +1,11 @@ { - "$id": "task-list", + "$id": "task-list.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "additionalProperties": { "type": "array", "items": { - "$ref": "task" + "$ref": "task.schema.json" } } } diff --git a/schema/task-tier.schema.json b/schema/task-tier.schema.json index 4618f96..dae3e6c 100644 --- a/schema/task-tier.schema.json +++ b/schema/task-tier.schema.json @@ -1,5 +1,5 @@ { - "$id": "task-tier", + "$id": "task-tier.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "required": ["name", "tasks"], @@ -12,7 +12,7 @@ "tasks": { "type": "array", "items": { - "$ref": "task" + "$ref": "task.schema.json" } } } diff --git a/schema/task.schema.json b/schema/task.schema.json index f747153..8ed67ef 100644 --- a/schema/task.schema.json +++ b/schema/task.schema.json @@ -1,5 +1,5 @@ { - "$id": "task", + "$id": "task.schema.json", "$schema": "http://json-schema.org/draft-07/schema", "definitions": { "diary-region": {