dofs
Version:
A filesystem for Cloudflare Durable Objects.
63 lines (61 loc) • 2 kB
TypeScript
import { Fs } from "./Fs-CX3m-F9L.js";
import { DurableObject } from "cloudflare:workers";
import { Hono } from "hono";
import * as hono_types0 from "hono/types";
//#region src/hono/types.d.ts
type DofsContext = {
Variables: {
fs: Rpc.Stub<Fs>;
};
};
/**
* Represents an instance of a Durable Object
*/
interface DurableObjectInstance {
/** The unique slug identifier for the instance */
slug: string;
/** The display name of the instance */
name: string;
}
type FsStat = {
mtime: Date;
atime: Date;
ctime: Date;
size: number;
mode: number;
uid: number;
gid: number;
nlink: number;
};
/**
* Configuration for a single Durable Object
*/
interface DurableObjectConfigItem<TEnv extends Cloudflare.Env> {
/** The name of the Durable Object */
name: string;
/** Reference to the Durable Object class for compatibility checking */
classRef: typeof DurableObject<any>;
/** Function to get instances, optionally paginated */
getInstances: (page?: number) => Promise<DurableObjectInstance[]>;
/** Function to get the stat for the namespace directory */
resolveNamespaceStat?: (cfg: DurableObjectConfig<TEnv>) => Promise<FsStat>;
/** Function to get the stat for the instance directory */
resolveInstanceStat?: (cfg: DurableObjectConfig<TEnv>, instanceId: string) => Promise<FsStat>;
}
/**
* Configuration object for Durable Objects
*/
type DurableObjectConfig<TEnv extends Cloudflare.Env> = {
resolveRootStat?: (cfg: DurableObjectConfig<TEnv>) => Promise<FsStat>;
dos: Record<string, DurableObjectConfigItem<TEnv>>;
};
//# sourceMappingURL=types.d.ts.map
//#endregion
//#region src/hono/index.d.ts
declare const dofs: <TEnv extends Cloudflare.Env>(config: DurableObjectConfig<TEnv>) => Hono<{
Bindings: TEnv;
} & DofsContext, hono_types0.BlankSchema, "/">;
//# sourceMappingURL=index.d.ts.map
//#endregion
export { DofsContext, DurableObjectConfig, DurableObjectConfigItem, DurableObjectInstance, FsStat, dofs };
//# sourceMappingURL=hono.d.ts.map