Client¶
TypeScript declarations shipped in GET /api/v1/curio.d.ts under declare namespace Curio, plus runtime extensions supported by curio.js.
Options¶
Configuration object accepted by Curio.connect(options):
interface Options {
token: string;
port?: number;
host?: string;
library?: string;
transport?: 'fetch' | 'gm';
}
Runtime additions in curio.js (not declared in curio.d.ts):
- Optional
token: Omittoken(or callCurio.connect()with no arguments) inside plugin pages (uses thebridgetransport) or plugin Node.js programs (readsCURIO_API_TOKEN). url?: string: Full base API URL overridinghostandport(read fromCURIO_API_URLin plugin Node.js programs).transport: 'bridge': Forces the sandboxed postMessage bridge inside plugin pages.
Client¶
Return type of Curio.connect(options) combining Api namespaces with core client methods:
interface Client extends Api {
call(op: string, params?: Record<string, unknown>): Promise<any>;
subscribe(filter: EventFilter, onEvent: (e: Event) => void, onState?: (state: 'open' | 'retrying' | 'closed', error?: CurioError) => void): Subscription;
on<N extends keyof EventMap>(name: N, onEvent: (e: Event<N>) => void, filter?: Omit<EventFilter, 'events'>): Subscription;
forLibrary(library: string): Client;
}
Runtime additions in curio.js (not declared in curio.d.ts):
client.options: Shallow copy of active connection options withtokenset toundefinedon HTTP clients.- Wildcard and plugin names in
on(): Accepts namespace wildcards ('items.*') and plugin page hooks ('plugin.*') at runtime in addition tokeyof EventMap. - Worker completion helpers: Plugin bridge clients also expose
thumbnailDone(request, picture, info?)andextractDone(request, values, error?)for hidden thumbnail and extractor pages. Curio.apiVersion: Top-level constant (1) exported alongsideCurio.connectandCurio.Error.
Api¶
Typed namespace proxy tree mapping every canonical operation to a method returning a Promise:
- App and libraries:
client.app.*,client.token.*,client.library.*,client.library.grouping.*. - Items:
client.item.*,client.item.add.*. - Organization and storage:
client.folder.*,client.smartFolder.*,client.tag.*,client.tagGroup.*,client.field.*,client.location.*. - Queries and utilities:
client.query.*,client.archive.*,client.duplicates.*. - Window and UI:
client.selection.*,client.view.*,client.viewer.*,client.ui.*,client.dialog.*,client.clipboard.*. - Plugins:
client.plugin.state.*,client.plugin.itemState.*,client.plugin.settings.*,client.plugin.log,client.plugin.close. - Jobs and processes:
client.job.*,client.process.run,client.tool.list.
CurioError¶
Error interface for failures rejected by curio.js, constructed via Curio.Error:
At runtime, Curio.Error sets name to 'CurioError' and defaults status to 0 for network failures and plugin bridge calls. See Error reference for every code and HTTP status.
EventFilter¶
Subscription filter passed to client.subscribe() and POST /api/v1/events:
interface EventFilter {
events?: (keyof EventMap | `${string}.*`)[];
library?: string;
ids?: string[];
}
At runtime, both POST /api/v1/events and curio.js HTTP subscribe() also accept after?: string to resume after a specific event ID (not declared in curio.d.ts). Plugin bridge subscriptions forward only events and ids.
Event¶
Envelope delivered to onEvent callbacks and SSE data: frames:
interface Event<N extends keyof EventMap = keyof EventMap> {
id: string;
name: N;
library: string | null;
at: number;
data: EventMap[N];
}
Page-local plugin hooks (such as plugin.beforeExit) deliver id: null and library: null at runtime.
EventMap¶
Maps all 24 public event names to their exact data payload types:
- Application and library:
app.themeChanged,library.listChanged,library.opened,library.closed,library.switched. - Items and organization:
items.added,items.changed,items.removed,folders.changed,smartFolders.changed,tags.changed,tagGroups.changed,fields.changed. - Locations and scans:
locations.changed,scan.progress,scan.done. - Window and viewer:
selection.changed,view.changed,viewer.opened,viewer.closed. - Jobs:
job.started,job.progress,job.output,job.finished.
Subscription¶
Handle returned by client.subscribe() and client.on():
Parameter types¶
Every operation's parameter interface is documented on its Operations reference page and exported in GET /api/v1/curio.d.ts.