import type { Type } from 'ts-gems'; import { ResponsiveMap } from '../helpers/index.js'; import type { TranslationBundle, TranslationStore } from '../i18n/translation-store.js'; import { OpraSchema } from '../schema/index.js'; import { DataTypeMap } from './common/data-type-map.js'; import { DocumentElement } from './common/document-element.js'; import type { TranslationCollector } from './common/translate-doc.js'; import { kTypeNSMap } from './constants.js'; import { DataType } from './data-type/data-type.js'; import type { EnumType } from './data-type/enum-type.js'; import { HttpApi } from './http/http-api.js'; import { MQApi } from './mq/mq-api.js'; import { WSApi } from './ws/ws-api.js'; /** * * @class ApiDocument */ export declare class ApiDocument extends DocumentElement { protected [kTypeNSMap]: WeakMap; readonly id: string; url?: string; info: OpraSchema.DocumentInfo; references: ResponsiveMap; types: DataTypeMap; api?: HttpApi | MQApi | WSApi; /** Documentation texts per language, materialized while this document was * built (see `ApiDocumentFactory`) so that `export()` can stay entirely * synchronous. A referenced document carries its own — a node's texts are * always looked up in the document that declares it, which is what keeps * two documents from ever competing for the same key. */ translations: Map; /** Where those bundles came from, kept rather than dropped after the build * so that anything editing this document's prose writes back to the one * place it is read from. Without it the only way to name that location is * to repeat it beside the document, which is two facts that can disagree — * and the one that disagrees silently is the write. `undefined` when the * texts were handed over directly (`translations`) or there are none. */ translationStore?: TranslationStore; /** The language `export()` falls back to when the requested one has no * bundle of its own. */ defaultLanguage: string; constructor(); /** * Returns NS of datatype. Returns undefined if not found * @param nameOrCtor */ getDataTypeNs(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject | DataType): string | undefined; findDocument(id: string): ApiDocument | undefined; get httpApi(): HttpApi | undefined; get mqApi(): MQApi | undefined; get wsApi(): WSApi | undefined; getHttpApi(): HttpApi; getMqApi(): MQApi; getWsApi(): WSApi; toJSON(): OpraSchema.ApiDocument; /** * Export as Opra schema definition object */ export(options?: ApiDocument.ExportOptions): OpraSchema.ApiDocument; /** * Picks which of this document's own bundles serves `lang`: exact match → * base language (`tr-TR` → `tr`) → `defaultLanguage` → the first language * available (sorted, so the same request never resolves differently * between runs). `undefined` when this document has no translations. */ resolveLanguage(lang?: string): string | undefined; getTranslations(lang?: string): TranslationBundle | undefined; /** * `info`'s own texts, translated when a language was asked for. Kept * separate from `export()` because a reference document's `info` is * emitted from *its* bundle, not the importing document's. */ exportInfo(options?: ApiDocument.ExportOptions): OpraSchema.DocumentInfo; invalidate(): void; protected _findDataType(nameOrCtor: string | Type | Function | EnumType.EnumArray | EnumType.EnumObject, scope?: string, visitedRefs?: WeakMap): DataType | undefined; } export declare namespace ApiDocument { interface ExportOptions { scope?: string; /** Language to resolve documentation texts in (see * `TranslationStore`). When omitted, nothing is looked up at all and * the texts written in the source itself are exported as they are — * this is what keeps the document's own id independent of any * translation (see `invalidate()`). */ lang?: string; /** Set by `extractTranslations()` to harvest the keys this export would * look up, rather than to render a schema. */ collect?: TranslationCollector; } }