UNPKG

api

Version:

Magical SDK generation from an OpenAPI definition 🪄

132 lines • 4.5 kB
import type { SupportedLanguage } from './codegen/factory.js'; import type { Lockfile } from './lockfileSchema.js'; import type { OASDocument } from 'oas/types'; import Fetcher from './fetcher.js'; export default class Storage { static dir: string; static lockfile: Lockfile | false; fetcher: Fetcher; /** * This is the original source that the file came from (relative/absolute file path, URL, ReadMe * registry UUID, etc.). * * @example @developers/v2.0#nysezql0wwo236 * @example https://raw.githubusercontent.com/readmeio/oas-examples/main/3.0/json/petstore-simple.json * @example ./petstore.json */ source: string; /** * The language that this SDK was generated for. */ private language; /** * The identifier that this was installed as. * * @example petstore */ identifier: string; constructor(source: string, language?: SupportedLanguage, identifier?: string); static getLockfilePath(): string; static getAPIsDir(): string; static setStorageDir(dir?: string): void; /** * Retrieves the project's root directory path. * * If a storage directory has not been explicitly set, this method will default it to * the current working directory. It then returns the directory name of the storage path. * */ static getProjectDir(): string; /** * Reset the state of the entire storage system. * * This will completely destroy the contents of the `.api/` directory! * * @internal */ static reset(): Promise<void>; static getDefaultLockfile(): Lockfile; static generateIntegrityHash(definition: OASDocument): string; static getLockfile(): { $schema?: string | undefined; apis: { private?: boolean | undefined; source?: string | undefined; updatedAt?: string | undefined; createdAt: string; identifier: string; installerVersion: string; integrity: string; language: "js"; }[]; }; static isIdentifierValid(identifier: string, prefixWithAPINamespace?: boolean): boolean; static isInLockFile(search: { identifier?: string; source?: string; }): false | { private?: boolean | undefined; source?: string | undefined; updatedAt?: string | undefined; createdAt: string; identifier: string; installerVersion: string; integrity: string; language: "js"; }; setLanguage(language?: SupportedLanguage): void; setIdentifier(identifier: string): void; /** * Determine if the current spec + identifier we're working with is already in the lockfile. */ isInLockfile(): boolean; /** * Retrieve the lockfile record for the current spec + identifier if it exists in the lockfile. * */ getFromLockfile(): { private?: boolean | undefined; source?: string | undefined; updatedAt?: string | undefined; createdAt: string; identifier: string; installerVersion: string; integrity: string; language: "js"; } | undefined; /** * Retrieve the lockfile record, if it exists, for a given identifier. * */ static getFromLockfile(identifier: string): { private?: boolean | undefined; source?: string | undefined; updatedAt?: string | undefined; createdAt: string; identifier: string; installerVersion: string; integrity: string; language: "js"; } | undefined; getSDKLanguage(): "js"; getPackageName(): string | undefined; getIdentifierStorageDir(): string; getAPIDefinitionPath(): string; getAPIDefinition(): any; saveSourceFiles(files: Record<string, string>): Promise<unknown>; load(shouldSave?: boolean): Promise<OASDocument>; /** * Initialize a directory in the storage system for this identifier and add it into the lockfile. * This does not create or save the source code for this SDK, that work happens within the * code generation system. * * @see {@link https://api.readme.dev/docs/how-it-works#api-directory} */ save(spec: OASDocument): OASDocument; /** * Delete the stored source code for the given identifier and purge it from the lockfile. * */ remove(): Promise<void>; } //# sourceMappingURL=storage.d.ts.map