跳转到内容

类型与错误

下列为辅助数据类型。错误码表示失败类别,不代表每个方法都可能返回所有错误。权限和生命周期由宿主检查。失败时保留用户输入,不要盲目重试非幂等写入。文本编辑的 stale 和保存的 conflict 是返回状态,不是错误码。导入的 Eidos 数据类型属于 @eidos.space/eidos-file,DOM 与 ECMAScript 类型使用其标准定义。

使用指南: files. API 索引.

签名、参数及返回类型从 SDK 自动生成;可选成员不保证在每个宿主和上下文中存在。

源码

export type PluginIconDefinition = string | {
paths: string[];
} | {
src: string;
} | {
file: string;
};

源码

export type ResourceSource = {
kind: "file";
path: string;
editor?: string;
} | {
kind: "eidos-view";
path: string;
tableId: string;
viewId: string;
};

源码

export type ResourceViewInfo = {
kind: "file";
editor: string;
name: string;
type: string;
} | {
kind?: "eidos-view";
tableId: string;
tableName: string;
viewId: string;
name: string;
type: string;
};

源码

export type ViewCapability = "document" | "eidos/schema" | "eidos/table" | "eidos/config";

源码

export type FileHookEventType = "document.saved" | "file.renamed";

源码

type: FileHookEventType;
operationId: string;
source: "local" | "plugin" | "sync";
path: string;
previousPath?: string;
previousText?: string;
document: {
text: string;
version: string;
};

关联类型: FileHookEventType.

源码

text?: string;
name?: string;

源码

text: string;
path: string;
signal: AbortSignal;

源码

dispose(): void;

返回值: void.

源码

export type BackgroundMessage = null | boolean | number | string | BackgroundMessage[] | {
[key: string]: BackgroundMessage;
};

源码

readonly path: string;
readonly name: string;
readonly extension: string;
readonly size: number;
readonly isDirectory: boolean;
readonly modifiedAtMs?: number;

源码

extensions?: string[];
recursive?: boolean;
includeDirectories?: boolean;

源码

export type FileMetaValue = null | string | number | boolean | FileMetaValue[] | {
[key: string]: FileMetaValue;
};

源码

export type FileMetaValues = Record<string, FileMetaValue>;

关联类型: FileMetaValue.

源码

set?: FileMetaValues;
remove?: string[];

关联类型: FileMetaValues.

源码

rootDirectory: string | null;
activePath: string | null;
sort: {
by: "name" | "modified" | "type";
direction: "ascending" | "descending";
};

源码

readonly path: string;
readonly name: string;
readonly baseName: string;
readonly extension: string;
readonly mimeType?: string;
readonly size: number;

源码

interface FileRef extends Partial<FileMetadata> { /* members below */ }
readonly id: string;

关联类型: FileMetadata.

源码

export type ViewBinding = {
kind: "page";
route: string;
} | {
kind: "file";
file: FileRef;
location?: {
kind: "eidos-table";
tableId: string;
viewId: string;
};
};

关联类型: FileRef.

源码

export type ActionBinding = {
kind: "workspace";
} | {
kind: "file";
file: FileRef;
};

关联类型: FileRef.

源码

id: string;
title: string;
icon?: {
paths: string[];
};
targets: Array<"row" | "selection" | "view">;

源码

id: string;
values: Record<string, LogicalValue>;
readToken: string;

源码

format: 1 | 2 | 3;
manifest: PluginManifest;
modules: Record<string, string>;
resources?: Record<string, string>;

关联类型: PluginManifest.

源码

text: string;
version: string;
encoding: "utf-8" | "utf-16le" | "utf-16be";
bom: boolean;
dirty: boolean;
conflicted: boolean;

源码

value: JsonObject | null;
version: string;

源码

fields: EidosFileFieldInfo[];
view: EidosFileViewInfo;

源码

export type TableAggregateMetric = "count" | "sum" | "average" | "min" | "max";

源码

export type TableAggregateDateInterval = "exact" | "day" | "month" | "year";

源码

groupBy?: {
fieldId: string;
dateInterval?: TableAggregateDateInterval;
};
metric: {
fieldId?: string;
op: TableAggregateMetric;
};
sort?: "label" | "value-desc" | "value-asc";

关联类型: TableAggregateDateInterval, TableAggregateMetric.

源码

key: unknown;
label: string;
value: number;

源码

items: TableAggregateItem[];
totalRecords: number;

关联类型: TableAggregateItem.

源码

export type SettingValue = boolean | string | number;

源码

name: string;
mimeType: string;
data: Uint8Array;

源码

export type FileExportResult = {
status: "saved" | "download-started" | "cancelled";
};

源码

export type ObserverErrorHandler = (error: {
code: string;
message: string;
}) => void;

源码

export type PluginErrorCode = "INVALID_REQUEST" | "UNSUPPORTED_API" | "PERMISSION_DENIED" | "DOCUMENT_UNAVAILABLE" | "INSTANCE_CLOSED" | "STALE_REVISION" | "ALREADY_EXISTS" | "BUSY" | "TOO_LARGE" | "IO_ERROR" | "TIMEOUT" | "CANCELLED" | "REGISTRATION_CONFLICT" | "DEPENDENCY_MISSING" | "SOURCE_INVALID";