From 8b943cc97fab890085448122e7c13dd035d0e238 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 20 Dec 2023 00:47:15 -0500 Subject: JSON validation (#394) * Set up JSON testing * Add schema validation * Use parseJson * Finish types * Disambiguate ext/json-schema from node dependency with the same name * Add support for specifying the jsconfig file * Don't expose types * Update types * Use dictionary map type * Fix types * Fix AJV warnings * Move types * Move anb rename file * Move common mocks * Simplify types --- types/ext/dictionary-data.d.ts | 20 +++++++++++++++++++- types/ext/structured-content.d.ts | 8 -------- types/ext/translation.d.ts | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'types/ext') diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index f594f913..b194c190 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -44,6 +44,8 @@ export type IndexTag = { score: number; }; +export type TermV1Array = TermV1[]; + export type TermV1 = [ expression: string, reading: string, @@ -53,6 +55,8 @@ export type TermV1 = [ ...glossary: string[], ]; +export type TermV3Array = TermV3[]; + export type TermV3 = [ expression: string, reading: string, @@ -64,6 +68,8 @@ export type TermV3 = [ termTags: string, ]; +export type KanjiV1Array = KanjiV1[]; + export type KanjiV1 = [ character: string, onyomi: string, @@ -72,6 +78,8 @@ export type KanjiV1 = [ ...meanings: string[], ]; +export type KanjiV3Array = KanjiV3[]; + export type KanjiV3 = [ character: string, onyomi: string, @@ -93,7 +101,13 @@ export type TermGlossaryText = {type: 'text', text: string}; export type TermGlossaryImage = {type: 'image'} & TermImage; export type TermGlossaryStructuredContent = {type: 'structured-content', content: StructuredContent.Content}; -export type TermImage = StructuredContent.ImageElementBase; +export type TermImage = StructuredContent.ImageElementBase & { + // Compatibility properties + verticalAlign?: undefined; + sizeUnits?: undefined; +}; + +export type TagArray = Tag[]; export type Tag = [ name: string, @@ -109,6 +123,8 @@ export type GenericFrequencyData = string | number | { reading?: undefined; // Used for type disambiguation, field does not actually exist }; +export type TermMetaArray = TermMeta[]; + export type TermMeta = TermMetaFrequency | TermMetaPitch; export type TermMetaFrequencyDataWithReading = { @@ -138,6 +154,8 @@ export type TermMetaPitch = [ data: TermMetaPitchData, ]; +export type KanjiMetaArray = KanjiMeta[]; + export type KanjiMeta = KanjiMetaFrequency; export type KanjiMetaFrequency = [ diff --git a/types/ext/structured-content.d.ts b/types/ext/structured-content.d.ts index 09755c88..572b827a 100644 --- a/types/ext/structured-content.d.ts +++ b/types/ext/structured-content.d.ts @@ -161,14 +161,6 @@ export type ImageElementBase = { * Whether or not the image can be collapsed. */ collapsible?: boolean; - /** - * This property is not defined on the base class. - */ - verticalAlign?: undefined; - /** - * This property is not defined on the base class. - */ - sizeUnits?: undefined; }; export type ImageElement = ImageElementBase & { diff --git a/types/ext/translation.d.ts b/types/ext/translation.d.ts index 3adfc673..595a5a35 100644 --- a/types/ext/translation.d.ts +++ b/types/ext/translation.d.ts @@ -28,7 +28,7 @@ export type FindKanjiOptions = { * The mapping of dictionaries to search for kanji in. * The key is the dictionary name. */ - enabledDictionaryMap: Map; + enabledDictionaryMap: KanjiEnabledDictionaryMap; /** * Whether or not non-Japanese characters should be searched. */ -- cgit v1.2.3