Add Bruno imports and a file-tree importer API (#706)

This commit is contained in:
Gregory Schier authored and GitHub committed 2026-09-24 14:50:44 -07:00
1 parent 46464cfacf
commit aa10c44a45
109 files changed
+4684 -879

No files matched your search

+10 -1
View File
@@ -470,7 +470,16 @@ export type HttpRequestAction = { label: string, icon?: Icon, };
export type Icon = "alert_triangle" | "check" | "check_circle" | "chevron_down" | "copy" | "info" | "pin" | "search" | "trash" | "_unknown";
export type ImportRequest = { content: string, };
/**
* Transport descriptor; plugins see a scoped ImportFiles API, not this representation.
*/
export type ImportFileSource = { "type": "file", name: string, base64: string, } | { "type": "directory", path: string, };
export type ImportRequest = {
/**
* Kept for text-only importers and older runtimes.
*/
content: string, source?: ImportFileSource, };
export type ImportResources = { workspaces: Array<Workspace>, environments: Array<Environment>, folders: Array<Folder>, httpRequests: Array<HttpRequest>, grpcRequests: Array<GrpcRequest>, websocketRequests: Array<WebsocketRequest>, };
+7 -1
View File
@@ -6,4 +6,10 @@ export * from "./bindings/gen_events";
// Some extras for utility
export type { PartialImportResources } from "./plugins/ImporterPlugin";
export type {
PartialImportResources,
ImportFiles,
ImportFileEntry,
ImportSource,
ImportSourceHandler,
} from "./plugins/ImporterPlugin";
@@ -21,11 +21,45 @@ export type ImportPluginResponse =
resources: PartialImportResources;
});
/** A read-only view of a selected directory or ZIP archive. Paths are relative and use
* forward slashes. Directory path checks are best-effort under concurrent filesystem
* changes, not a security boundary. Valid only while onImportSource runs. */
export interface ImportFiles {
readonly name: string;
readonly kind: "zip" | "directory";
/** List immediate children. The root directory is "" (the default). */
readDir(path?: string): Promise<ImportFileEntry[]>;
readFile(path: string): Promise<Uint8Array>;
/** Decode UTF-8 strictly; binary or invalid UTF-8 content throws. */
readTextFile(path: string): Promise<string>;
}
export interface ImportFileEntry {
name: string;
path: string;
type: "file" | "directory";
}
/** What the user chose to import: one text document, or a directory or ZIP read as a tree. */
export type ImportSource =
| { type: "text"; name: string; text: string }
| { type: "directory"; files: ImportFiles };
type ImportTextHandler = (
ctx: Context,
args: { text: string },
) => MaybePromise<ImportPluginResponse | undefined>;
export type ImportSourceHandler = (
ctx: Context,
args: { source: ImportSource },
) => MaybePromise<ImportPluginResponse | undefined>;
export type ImporterPlugin = {
name: string;
description?: string;
onImport(
ctx: Context,
args: { text: string },
): MaybePromise<ImportPluginResponse | null | undefined>;
/** Return null when the source isn't this importer's format. Takes precedence over onImport. */
onImportSource?: ImportSourceHandler;
/** @deprecated Use onImportSource. Only receives single text documents. */
onImport?: ImportTextHandler;
};