UNPKG

@bachman-dev/wanikani-api-types

Version:

Regularly updated type definitions for the WaniKani API

1,117 lines (1,115 loc) 198 kB
import * as v from 'valibot'; /** * All known WaniKani API revisions, created when breaking changes are introduced to the WaniKani API. * * @see {@link https://docs.api.wanikani.com/20170710/#revisions-aka-versioning} * @category Base */ type ApiRevision = "20170710"; declare const ApiRevision: v.LiteralSchema<"20170710", undefined>; /** * A constant representing the WaniKani API revision. This will match the revision module being imported from, or the * latest revision when importing from the root module. * * @see {@link https://docs.api.wanikani.com/20170710/#revisions-aka-versioning} * @category Base */ declare const API_REVISION: ApiRevision; /** * A type guard that checks if the given value matches the type predicate. * * @category Base * @category Type Guards */ declare function isApiRevision(value: unknown): value is ApiRevision; /** * Items with this type will have their number validated as a safe integer >= 0. * * @category Base */ type SafeInteger = number & {}; declare const SafeInteger: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>; /** * A `string` sent to/returned from the WaniKani API that can be converted into a JavaScript `Date` object. * * @category Base */ type DatableString = v.Brand<"DatableString"> & string; declare const DatableString: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; /** * A type guard that checks if the given value matches the type predicate. * * @category Base * @category Type Guards */ declare function isDatableString(value: unknown): value is DatableString; /** * The minimum level provided by WaniKani; exported for use in lieu of a Magic Number. * * @category Base */ declare const MIN_LEVEL = 1; /** * The maximum level provided by WaniKani; exported for use in lieu of a Magic Number. * * @category Base */ declare const MAX_LEVEL = 60; /** * A number representing a level in WaniKani, from `1` to `60`. * * @category Base */ type Level = number & {}; declare const Level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; /** * A type guard that checks if the given value matches the type predicate. * * @category Base * @category Type Guards */ declare function isLevel(value: unknown): value is Level; /** * The common properties across all Resources from the WaniKani API. * * @remarks This is a partial interface; most use cases involve using a reource that extends it. * * @see {@link https://docs.api.wanikani.com/20170710/#response-structure} * * @category Base * @category Resources */ interface BaseResource { /** * For a resource, this is the last time that particular resource was updated. */ data_updated_at: DatableString; /** * The URL of the requested resource. */ url: string; } declare const BaseResource: v.ObjectSchema<{ readonly data_updated_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly url: v.StringSchema<undefined>; }, undefined>; /** * The common properties across all Collection items from the WaniKani API. * * @remarks This is a partial interface; most use cases involve using a reource that extends it. * * @see {@link https://docs.api.wanikani.com/20170710/#response-structure} * @category Base * @category Collections */ interface BaseCollection { /** * For collections, this is the timestamp of the most recently updated resource in the specified scope and is not * limited by pagination. If no items were returned for the specified scope, then this will be `null`. */ data_updated_at: DatableString | null; /** * The kind of object returned. */ object: "collection"; /** * Pagination Info for the collection. */ pages: { /** * The URL of the next page of results. If there are no more results, the value is `null`. */ next_url: string | null; /** * Maximum number of items delivered per page for this collection. */ per_page: number; /** * The URL of the previous page of results. If there are no results at all or no previous page to go to, the value * is `null`. */ previous_url: string | null; }; /** * The total number of items in the collection. */ total_count: number; /** * The URL of the request. For collections, that will contain all the filters and options you've passed to the API. */ url: string; } declare const BaseCollection: v.ObjectSchema<{ readonly data_updated_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly object: v.LiteralSchema<"collection", undefined>; readonly pages: v.ObjectSchema<{ readonly next_url: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; readonly per_page: v.NumberSchema<undefined>; readonly previous_url: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; }, undefined>; readonly total_count: v.NumberSchema<undefined>; readonly url: v.StringSchema<undefined>; }, undefined>; /** * Query string parameters that can be sent to any WaniKani API collection endpoint. * * @see {@link stringifyParameters} * @category Base * @category Parameters */ interface CollectionParameters { /** * Only resources where `data.id` matches one of the array values are returned. */ ids?: SafeInteger[]; /** * Get a collection's next page containing `pages.per_page` resources after the given ID. * * This will take precedence over `page_before_id` if both are specified. */ page_after_id?: SafeInteger; /** * Get a collection's previous page containing `pages.per_page` resources before the given ID. * * The `page_after_id` parameter takes precedence over this if it is specified alongside this parameter. */ page_before_id?: SafeInteger; /** * Only resources updated after this time are returned. */ updated_after?: DatableString | Date; } declare const CollectionParameters: v.ObjectSchema<{ readonly ids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>; readonly page_after_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>; readonly page_before_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>; readonly updated_after: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.DateSchema<undefined>], string | ((issue: v.UnionIssue<v.DateIssue | v.IsoTimestampIssue<string> | v.StringIssue>) => string)>, undefined>; }, undefined>; /** * Parses a parameter object, for use with the WaniKani API. * * @param params -- An object containing the query string parameters to parse. * @returns A query string of all the parameters, which can be added to a base URL. * @throws A `TypeError` if a non-object is passed to the function. * @category Base */ declare function stringifyParameters(params: CollectionParameters): string; /** * The common properties across all Reports from the WaniKani API * * @remarks This is a partial interface; most use cases involve using a reource that extends it. * * @see {@link https://docs.api.wanikani.com/20170710/#response-structure} * * @category Base * @category Reports */ interface BaseReport { /** * The last time the report was updated. */ data_updated_at: DatableString; /** * The kind of object returned. */ object: "report"; /** * The URL of the requested report. */ url: string; } declare const BaseReport: v.ObjectSchema<{ readonly data_updated_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly object: v.LiteralSchema<"report", undefined>; readonly url: v.StringSchema<undefined>; }, undefined>; /** * An error response returned by the WaniKani API. * * @category Base */ interface ApiError { /** * An HTTP status code indicating the type of error. */ code: number; /** * A message string that describes the error. */ error: string; } declare const ApiError: v.ObjectSchema<{ readonly code: v.NumberSchema<undefined>; readonly error: v.StringSchema<undefined>; }, undefined>; /** * A type guard that checks if the given value matches the type predicate. * * @category Base * @category Type Guards */ declare function isApiError(value: unknown): value is ApiError; /** * The types of subjects used on WaniKani and its API. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ type SubjectType = "kana_vocabulary" | "kanji" | "radical" | "vocabulary"; declare const SubjectType: v.PicklistSchema<["kana_vocabulary", "kanji", "radical", "vocabulary"], undefined>; /** * A type guard that checks if the given value matches the type predicate. * * @category Subjects * @category Type Guards */ declare function isSubjectType(value: unknown): value is SubjectType; /** * A non-empty array of WaniKani subject types. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ type SubjectTuple = [SubjectType, ...SubjectType[]]; declare const SubjectTuple: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.PicklistSchema<["kana_vocabulary", "kanji", "radical", "vocabulary"], undefined>], v.PicklistSchema<["kana_vocabulary", "kanji", "radical", "vocabulary"], undefined>, undefined>, v.NonEmptyAction<["kana_vocabulary" | "kanji" | "radical" | "vocabulary", ...("kana_vocabulary" | "kanji" | "radical" | "vocabulary")[]], undefined>, v.CheckItemsAction<["kana_vocabulary" | "kanji" | "radical" | "vocabulary", ...("kana_vocabulary" | "kanji" | "radical" | "vocabulary")[]], "Duplicate Subject Type detected in Subject Tuple">]>; /** * A type guard that checks if the given value matches the type predicate. * * @category Subjects * @category Type Guards */ declare function isSubjectTuple(value: unknown): value is SubjectTuple; /** * A subject's auxilliary meanings. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface SubjectAuxiliaryMeaning { /** * A singular subject meaning. */ meaning: string; /** * Either `whitelist` or `blacklist`. When evaluating user input, whitelisted meanings are used to match for * correctness. Blacklisted meanings are used to match for incorrectness. */ type: "blacklist" | "whitelist"; } declare const SubjectAuxiliaryMeaning: v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>; /** * Information pertaining to a subject's meaning. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface SubjectMeaning { /** * Indicates if the meaning is used to evaluate user input for correctness. */ accepted_answer: boolean; /** * A singular subject meaning. */ meaning: string; /** * Indicates priority in the WaniKani system. */ primary: boolean; } declare const SubjectMeaning: v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>; /** * The common properties of all subjects on WaniKani. * * @remarks * This only represents a partial structure of a subject, and it's highly recommended to use one of the child type * definitions that extend this type definition. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface SubjectBaseData { /** * Collection of auxiliary meanings. */ auxiliary_meanings: SubjectAuxiliaryMeaning[]; /** * Timestamp when the subject was created. */ created_at: DatableString; /** * A URL pointing to the page on wanikani.com that provides detailed information about this subject. */ document_url: string; /** * Timestamp when the subject was hidden, indicating associated assignments will no longer appear in lessons or * reviews and that the subject page is no longer visible on wanikani.com. */ hidden_at: DatableString | null; /** * The position that the subject appears in lessons. Note that the value is scoped to the level of the subject, so * there are duplicate values across levels. */ lesson_position: number; /** * The level of the subject, from `1` to `60`. */ level: Level; /** * The subject's meaning mnemonic. */ meaning_mnemonic: string; /** * The subject meanings. */ meanings: SubjectMeaning[]; /** * The string that is used when generating the document URL for the subject. Radicals use their meaning, downcased. * Kanji and vocabulary use their characters. */ slug: string; /** * Unique identifier of the associated Spaced Repetition System. */ spaced_repetition_system_id: number; } declare const SubjectBaseData: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; }, undefined>; /** * An image representing a radical subject. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ type RadicalCharacterImage = { /** * The location of the image. */ url: string; } & ({ /** * The content type of the image. */ content_type: "image/png"; /** * Details about the image. Each `content_type` returns a uniquely structured object. */ metadata: { /** * Color of the asset in hexadecimal */ color: string; /** * Dimension of the asset in pixels */ dimensions: string; /** * A name descriptor */ style_name: string; }; } | { /** * The content type of the image. */ content_type: "image/svg+xml"; /** * Details about the image. Each `content_type` returns a uniquely structured object. */ metadata: { /** * The SVG asset contains built-in CSS styling. */ inline_styles: boolean; }; }); declare const RadicalCharacterImage: v.IntersectSchema<[v.ObjectSchema<{ readonly url: v.StringSchema<undefined>; }, undefined>, v.VariantSchema<"content_type", [v.ObjectSchema<{ readonly content_type: v.LiteralSchema<"image/svg+xml", undefined>; readonly metadata: v.ObjectSchema<{ readonly inline_styles: v.BooleanSchema<undefined>; }, undefined>; }, undefined>, v.ObjectSchema<{ readonly content_type: v.LiteralSchema<"image/png", undefined>; readonly metadata: v.ObjectSchema<{ readonly color: v.StringSchema<undefined>; readonly dimensions: v.StringSchema<undefined>; readonly style_name: v.StringSchema<undefined>; }, undefined>; }, undefined>], undefined>], undefined>; /** * Data returned only for radical subjects. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface RadicalData extends SubjectBaseData { /** * An array of numeric identifiers for the kanji that have the radical as a component. */ amalgamation_subject_ids: number[]; /** * A collection of images of the radical. */ character_images: RadicalCharacterImage[]; /** * Unlike kanji and vocabulary, radicals can have a null value for characters. Not all radicals have a UTF entry, so * the radical must be visually represented with an image instead. */ characters: string | null; } declare const RadicalData: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly amalgamation_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly character_images: v.ArraySchema<v.IntersectSchema<[v.ObjectSchema<{ readonly url: v.StringSchema<undefined>; }, undefined>, v.VariantSchema<"content_type", [v.ObjectSchema<{ readonly content_type: v.LiteralSchema<"image/svg+xml", undefined>; readonly metadata: v.ObjectSchema<{ readonly inline_styles: v.BooleanSchema<undefined>; }, undefined>; }, undefined>, v.ObjectSchema<{ readonly content_type: v.LiteralSchema<"image/png", undefined>; readonly metadata: v.ObjectSchema<{ readonly color: v.StringSchema<undefined>; readonly dimensions: v.StringSchema<undefined>; readonly style_name: v.StringSchema<undefined>; }, undefined>; }, undefined>], undefined>], undefined>, undefined>; readonly characters: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; }, undefined>; /** * Information pertaining to a reading of a kanji subject. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface KanjiReading { /** * Indicates if the reading is used to evaluate user input for correctness. */ accepted_answer: boolean; /** * Indicates priority in the WaniKani system. */ primary: boolean; /** * A singular subject reading. */ reading: string; /** * The kanji reading's classfication: `kunyomi`, `nanori`, or `onyomi`. */ type: "kunyomi" | "nanori" | "onyomi"; } declare const KanjiReading: v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; readonly reading: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["kunyomi", "nanori", "onyomi"], undefined>; }, undefined>; /** * Data returned only for kanji subjects. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface KanjiData extends SubjectBaseData { /** * An array of numeric identifiers for the vocabulary that have the kanji as a component. */ amalgamation_subject_ids: number[]; /** * The UTF-8 characters for the subject, including kanji and hiragana. */ characters: string; /** * An array of numeric identifiers for the radicals that make up this kanji. Note that these are the subjects that * must have passed assignments in order to unlock this subject's assignment. */ component_subject_ids: number[]; /** * Meaning hint for the kanji. */ meaning_hint: string | null; /** * Reading hint for the kanji. */ reading_hint: string | null; /** * The kanji's reading mnemonic. */ reading_mnemonic: string; /** * Selected readings for the kanji. */ readings: KanjiReading[]; /** * An array of numeric identifiers for kanji which are visually similar to the kanji in question. */ visually_similar_subject_ids: number[]; } declare const KanjiData: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly amalgamation_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly characters: v.StringSchema<undefined>; readonly component_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly meaning_hint: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; readonly reading_hint: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; readonly reading_mnemonic: v.StringSchema<undefined>; readonly readings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; readonly reading: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["kunyomi", "nanori", "onyomi"], undefined>; }, undefined>, undefined>; readonly visually_similar_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; }, undefined>; /** * Japanese context sentences for vocabulary, with a corresponding English translation. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface VocabularyContextSentence { /** * English translation of the sentence. */ en: string; /** * Japanese context sentence. */ ja: string; } declare const VocabularyContextSentence: v.ObjectSchema<{ readonly en: v.StringSchema<undefined>; readonly ja: v.StringSchema<undefined>; }, undefined>; /** * Information pertaining to pronunciation audio for a vocabulary subject. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface VocabularyPronunciationAudio { /** * The content type of the audio. Currently the API delivers `audio/mpeg`, `audio/ogg`, and `audio/webm`. */ content_type: "audio/mpeg" | "audio/ogg" | "audio/webm"; /** * Details about the pronunciation audio. */ metadata: { /** * The gender of the voice actor. */ gender: "female" | "male"; /** * Vocabulary being pronounced in kana. */ pronunciation: string; /** * A unique ID shared between same source pronunciation audio. */ source_id: number; /** * A unique ID belonging to the voice actor. */ voice_actor_id: number; /** * Humanized name of the voice actor. */ voice_actor_name: string; /** * Description of the voice. */ voice_description: string; }; /** * The location of the audio. */ url: string; } declare const VocabularyPronunciationAudio: v.ObjectSchema<{ readonly content_type: v.PicklistSchema<["audio/mpeg", "audio/ogg", "audio/webm"], undefined>; readonly metadata: v.ObjectSchema<{ readonly gender: v.PicklistSchema<["female", "male"], undefined>; readonly pronunciation: v.StringSchema<undefined>; readonly source_id: v.NumberSchema<undefined>; readonly voice_actor_id: v.NumberSchema<undefined>; readonly voice_actor_name: v.StringSchema<undefined>; readonly voice_description: v.StringSchema<undefined>; }, undefined>; readonly url: v.StringSchema<undefined>; }, undefined>; /** * Information pertaining to a reading of a vocabulary subject.. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface VocabularyReading { /** * Indicates if the reading is used to evaluate user input for correctness. */ accepted_answer: boolean; /** * Indicates priority in the WaniKani system. */ primary: boolean; /** * A singular subject reading. */ reading: string; } declare const VocabularyReading: v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; readonly reading: v.StringSchema<undefined>; }, undefined>; /** * Data returned only for vocabulary subjects. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface VocabularyData extends SubjectBaseData { /** * The UTF-8 characters for the subject, including kanji and hiragana. */ characters: string; /** * An array of numeric identifiers for the kanji that make up this vocabulary. Note that these are the subjects that * must be have passed assignments in order to unlock this subject's assignment. */ component_subject_ids: number[]; /** * A collection of context sentences. */ context_sentences: VocabularyContextSentence[]; /** * Parts of speech. */ parts_of_speech: string[]; /** * A collection of pronunciation audio. */ pronunciation_audios: VocabularyPronunciationAudio[]; /** * The vocabulary's reading mnemonic. */ reading_mnemonic: string; /** * Selected readings for the vocabulary. */ readings: VocabularyReading[]; } declare const VocabularyData: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly characters: v.StringSchema<undefined>; readonly component_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly context_sentences: v.ArraySchema<v.ObjectSchema<{ readonly en: v.StringSchema<undefined>; readonly ja: v.StringSchema<undefined>; }, undefined>, undefined>; readonly parts_of_speech: v.ArraySchema<v.StringSchema<undefined>, undefined>; readonly pronunciation_audios: v.ArraySchema<v.ObjectSchema<{ readonly content_type: v.PicklistSchema<["audio/mpeg", "audio/ogg", "audio/webm"], undefined>; readonly metadata: v.ObjectSchema<{ readonly gender: v.PicklistSchema<["female", "male"], undefined>; readonly pronunciation: v.StringSchema<undefined>; readonly source_id: v.NumberSchema<undefined>; readonly voice_actor_id: v.NumberSchema<undefined>; readonly voice_actor_name: v.StringSchema<undefined>; readonly voice_description: v.StringSchema<undefined>; }, undefined>; readonly url: v.StringSchema<undefined>; }, undefined>, undefined>; readonly reading_mnemonic: v.StringSchema<undefined>; readonly readings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; readonly reading: v.StringSchema<undefined>; }, undefined>, undefined>; }, undefined>; /** * Data returned only for kana-only vocabulary subjects. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Subjects */ interface KanaVocabularyData extends SubjectBaseData { /** * The UTF-8 characters for the subject, including kanji and hiragana. */ characters: string; /** * A collection of context sentences. */ context_sentences: VocabularyContextSentence[]; /** * Parts of speech. */ parts_of_speech: string[]; /** * A collection of pronunciation audio. */ pronunciation_audios: VocabularyPronunciationAudio[]; } declare const KanaVocabularyData: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly characters: v.StringSchema<undefined>; readonly context_sentences: v.ArraySchema<v.ObjectSchema<{ readonly en: v.StringSchema<undefined>; readonly ja: v.StringSchema<undefined>; }, undefined>, undefined>; readonly parts_of_speech: v.ArraySchema<v.StringSchema<undefined>, undefined>; readonly pronunciation_audios: v.ArraySchema<v.ObjectSchema<{ readonly content_type: v.PicklistSchema<["audio/mpeg", "audio/ogg", "audio/webm"], undefined>; readonly metadata: v.ObjectSchema<{ readonly gender: v.PicklistSchema<["female", "male"], undefined>; readonly pronunciation: v.StringSchema<undefined>; readonly source_id: v.NumberSchema<undefined>; readonly voice_actor_id: v.NumberSchema<undefined>; readonly voice_actor_name: v.StringSchema<undefined>; readonly voice_description: v.StringSchema<undefined>; }, undefined>; readonly url: v.StringSchema<undefined>; }, undefined>, undefined>; }, undefined>; /** * The exact structure of a subject depends on the subject type. The available subject types are `kana_vocabulary`, * `kanji`, `radical`, and `vocabulary`. Note that any attributes called out for the specific subject type behaves * differently than the common attribute of the same name. * * This type is for mixed or unknown subject types; it is a discriminated union based on the subject's `object` key. * * @see {@link https://docs.api.wanikani.com/20170710/#subjects} * @category Resources * @category Subjects */ type Subject = BaseResource & { /** * A unique number identifying the subject. */ id: number; } & ({ /** * Data for the returned kana-only vocabulary. */ data: KanaVocabularyData; /** * The kind of object returned. */ object: "kana_vocabulary"; } | { /** * Data for the returned kanji. */ data: KanjiData; /** * The kind of object returned. */ object: "kanji"; } | { /** * Data for the returned radical. */ data: RadicalData; /** * The kind of object returned. */ object: "radical"; } | { /** * Data for the returned vocabulary. */ data: VocabularyData; /** * The kind of object returned. */ object: "vocabulary"; }); declare const Subject: v.IntersectSchema<[v.ObjectSchema<{ readonly data_updated_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly url: v.StringSchema<undefined>; }, undefined>, v.ObjectSchema<{ readonly id: v.NumberSchema<undefined>; }, undefined>, v.VariantSchema<"object", [v.ObjectSchema<{ readonly data: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly characters: v.StringSchema<undefined>; readonly context_sentences: v.ArraySchema<v.ObjectSchema<{ readonly en: v.StringSchema<undefined>; readonly ja: v.StringSchema<undefined>; }, undefined>, undefined>; readonly parts_of_speech: v.ArraySchema<v.StringSchema<undefined>, undefined>; readonly pronunciation_audios: v.ArraySchema<v.ObjectSchema<{ readonly content_type: v.PicklistSchema<["audio/mpeg", "audio/ogg", "audio/webm"], undefined>; readonly metadata: v.ObjectSchema<{ readonly gender: v.PicklistSchema<["female", "male"], undefined>; readonly pronunciation: v.StringSchema<undefined>; readonly source_id: v.NumberSchema<undefined>; readonly voice_actor_id: v.NumberSchema<undefined>; readonly voice_actor_name: v.StringSchema<undefined>; readonly voice_description: v.StringSchema<undefined>; }, undefined>; readonly url: v.StringSchema<undefined>; }, undefined>, undefined>; }, undefined>; readonly object: v.LiteralSchema<"kana_vocabulary", undefined>; }, undefined>, v.ObjectSchema<{ readonly data: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly amalgamation_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly characters: v.StringSchema<undefined>; readonly component_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly meaning_hint: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; readonly reading_hint: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; readonly reading_mnemonic: v.StringSchema<undefined>; readonly readings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; readonly reading: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["kunyomi", "nanori", "onyomi"], undefined>; }, undefined>, undefined>; readonly visually_similar_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; }, undefined>; readonly object: v.LiteralSchema<"kanji", undefined>; }, undefined>, v.ObjectSchema<{ readonly data: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly amalgamation_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly character_images: v.ArraySchema<v.IntersectSchema<[v.ObjectSchema<{ readonly url: v.StringSchema<undefined>; }, undefined>, v.VariantSchema<"content_type", [v.ObjectSchema<{ readonly content_type: v.LiteralSchema<"image/svg+xml", undefined>; readonly metadata: v.ObjectSchema<{ readonly inline_styles: v.BooleanSchema<undefined>; }, undefined>; }, undefined>, v.ObjectSchema<{ readonly content_type: v.LiteralSchema<"image/png", undefined>; readonly metadata: v.ObjectSchema<{ readonly color: v.StringSchema<undefined>; readonly dimensions: v.StringSchema<undefined>; readonly style_name: v.StringSchema<undefined>; }, undefined>; }, undefined>], undefined>], undefined>, undefined>; readonly characters: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; }, undefined>; readonly object: v.LiteralSchema<"radical", undefined>; }, undefined>, v.ObjectSchema<{ readonly data: v.ObjectSchema<{ readonly auxiliary_meanings: v.ArraySchema<v.ObjectSchema<{ readonly meaning: v.StringSchema<undefined>; readonly type: v.PicklistSchema<["blacklist", "whitelist"], undefined>; }, undefined>, undefined>; readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>; readonly document_url: v.StringSchema<undefined>; readonly hidden_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly lesson_position: v.NumberSchema<undefined>; readonly level: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 60, undefined>]>; readonly meaning_mnemonic: v.StringSchema<undefined>; readonly meanings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly meaning: v.StringSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; }, undefined>, undefined>; readonly slug: v.StringSchema<undefined>; readonly spaced_repetition_system_id: v.NumberSchema<undefined>; readonly characters: v.StringSchema<undefined>; readonly component_subject_ids: v.ArraySchema<v.NumberSchema<undefined>, undefined>; readonly context_sentences: v.ArraySchema<v.ObjectSchema<{ readonly en: v.StringSchema<undefined>; readonly ja: v.StringSchema<undefined>; }, undefined>, undefined>; readonly parts_of_speech: v.ArraySchema<v.StringSchema<undefined>, undefined>; readonly pronunciation_audios: v.ArraySchema<v.ObjectSchema<{ readonly content_type: v.PicklistSchema<["audio/mpeg", "audio/ogg", "audio/webm"], undefined>; readonly metadata: v.ObjectSchema<{ readonly gender: v.PicklistSchema<["female", "male"], undefined>; readonly pronunciation: v.StringSchema<undefined>; readonly source_id: v.NumberSchema<undefined>; readonly voice_actor_id: v.NumberSchema<undefined>; readonly voice_actor_name: v.StringSchema<undefined>; readonly voice_description: v.StringSchema<undefined>; }, undefined>; readonly url: v.StringSchema<undefined>; }, undefined>, undefined>; readonly reading_mnemonic: v.StringSchema<undefined>; readonly readings: v.ArraySchema<v.ObjectSchema<{ readonly accepted_answer: v.BooleanSchema<undefined>; readonly primary: v.BooleanSchema<undefined>; readonly reading: v.StringSchema<undefined>; }, undefined>, undefined>; }, undefined>; readonly object: v.LiteralSchema<"vocabulary", undefined>; }, undefined>], undefined>], undefined>; /** * A type guard that checks if the given value matches the type predicate. * * @category Subjects * @category Type Guards */ declare function isSubject(value: unknown): value is Subject; /** * A collection of subjects of mixed or unknown types returned from the WaniKani API. * * @see {@link https://docs.api.wanikani.com/20170710/#get-all-subjects} * @category Collections * @category Subjects */ interface SubjectCollection extends BaseCollection { /** * An array of returned subjects of mixed or unknown type. */ data: Subject[]; } declare const SubjectCollection: v.ObjectSchema<{ readonly data_updated_at: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.IsoTimestampAction<string, undefined>, v.BrandAction<string, "DatableString">]>, v.NullSchema<undefined>], undefined>; readonly object: v.LiteralSchema<"collection", undefined>; readonly pages: v.ObjectSchema<{ readonly next_url: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; readonly per_page: v.NumberSchema<undefined>; readonly previous_url: v.UnionSchema<[v.StringSchema<undefined>, v.NullSchema<undefined>], undefined>; }, undefined>; readonly total_count: v.NumberSchema<undefined>; readonly url: v.StringSchema<undefined>; readonly data: v.ArraySchema<v.Inte