@tapedb/tapedb/extension
Alles hier ist stabil, sofern nicht als experimentell gekennzeichnet; siehe API-Stabilität.
Functions
Abschnitt betitelt „Functions“defineExtension
Abschnitt betitelt „defineExtension“Declares the command-line half of an extension.
declare function defineExtension(extension: TapeDBCliExtension): TapeDBCliExtension;Interfaces
Abschnitt betitelt „Interfaces“ExtensionCommand
Abschnitt betitelt „ExtensionCommand“interface ExtensionCommand { /** One line for `tapedb <extension> --help`. */ summary: string; /** e.g. "<file> --workspace <uuid> [--publish]" */ usage: string; /** Returns the exit code. */ run(args: string[], project: ExtensionProject): Promise<number | void> | number | void;}ExtensionProject
Abschnitt betitelt „ExtensionProject“The project the CLI is working in, with the edits an extension may make.
interface ExtensionProject { /** The project's directory. */ root: string; /** Reads a project file, or null when it does not exist. */ read(path: string): string | null; /** * Writes a project file. Without `overwrite`, an existing file is kept and * false is returned, so a second `tapedb add` changes nothing. */ write(path: string, contents: string, options?: { overwrite?: boolean; }): boolean; /** wrangler.jsonc: adds what is missing and leaves the rest as it is. */ wrangler: { /** An R2 bucket binding; the bucket is named `<worker name>-<suffix>` and `tapedb deploy` creates it. */ addR2Bucket(binding: string, suffix: string): void; /** A cron trigger for the Worker's `scheduled` handler. */ addCron(expression: string): void; /** A plain variable (not a secret). */ addVar(name: string, value: string): void; /** Another binding entry under `key` (e.g. "images": { binding: "IMAGES" }), when the key is absent. */ setIfAbsent(key: string, value: unknown): void; }; /** * Adds `expression` to the schema's `schema(models, { extensions: [...] })` * in tapedb.schema.ts, with the import lines it needs. Returns false, and * changes nothing, when the call is not written in a way the CLI can edit * with certainty; say what to add by hand then. */ useInSchema(expression: string, imports: string[]): boolean; /** The same for the Worker's `defineTapeDB({ extensions: [...] })` (wrangler.jsonc's `main`). */ useInWorker(expression: string, imports: string[]): boolean; /** Adds dev dependencies with the project's package manager, skipping those already listed. */ installDev(packages: string[]): void; /** One line of output under the extension's name. */ log(message: string): void;}TapeDBCliExtension
Abschnitt betitelt „TapeDBCliExtension“The command-line half of an extension.
interface TapeDBCliExtension { /** `tapedb <name> <command>`; lowercase letters, digits and dashes. */ name: string; /** Sets the project up for the extension. Runs once from `tapedb add`; safe to run again. */ add?(project: ExtensionProject): Promise<void> | void; /** * Generates files before `tapedb dev` and `tapedb deploy`. Return the * project files to watch: during `tapedb dev`, a change to one runs build again. */ build?(project: ExtensionProject, options: { mode: "dev" | "deploy"; }): Promise<{ watch?: string[]; } | void> | { watch?: string[]; } | void; commands?: Record<string, ExtensionCommand>;}