UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

44 lines • 4.18 kB
import { GSheetsAccessor } from '../../accessor/gsheets.ts'; import type { GoogleConfig } from '../../core/google/config.ts'; import type { DeltaHook } from '../../events/base.ts'; import type { FileStat, PathSpec } from '../../types.ts'; import { type DirListing } from '../../types.ts'; import { BaseVFS } from '../base.ts'; import type { RedactedSchema } from '../secrets.ts'; import type { ConfigState, Handed } from '../types.ts'; import { GSheetsConfig } from './config.ts'; export declare const VFS_MD = "```text\n{prefix}\n owned/ # sheets you created\n <YYYY-MM-DD>_<title>__<spreadsheet-id>.gsheet.json\n shared/ # sheets others shared with you\n <YYYY-MM-DD>_<title>__<spreadsheet-id>.gsheet.json\n```\n\n- `<YYYY-MM-DD>` is the file's `modifiedTime`, so a date glob such as\n `2026-05-*` narrows by it.\n- `<title>` is sanitized: spaces and any character outside\n `[A-Za-z0-9_.-]` become `_`, at most 100 characters.\n- `<spreadsheet-id>` is the Google Sheets spreadsheet id.\n- `shared/` holds sheets shared with you by others; ones you own\n and shared with others are still in `owned/`.\n\nA `.gsheet.json` matches the Google Sheets API `spreadsheets.get`\nresponse:\n\n```jsonc\n{\n \"spreadsheetId\": \"...\",\n \"spreadsheetUrl\": \"...\",\n \"properties\": { \"title\": \"...\", \"locale\": \"...\", \"timeZone\": \"...\" },\n \"sheets\": [\n { // one element per tab\n \"properties\": {\n \"sheetId\": 0, \"title\": \"...\", \"index\": 0,\n \"gridProperties\": { \"rowCount\": 1000, \"columnCount\": 26 }\n },\n \"data\": [\n {\n \"rowData\": [\n { \"values\": [\n { \"formattedValue\": \"...\",\n \"userEnteredValue\": {...},\n \"effectiveValue\": {...} }\n ]} // an empty cell is {}, a trailing one absent\n ]\n }\n ]\n }\n ],\n \"namedRanges\": [...]\n}\n```\n\nUseful `jq` paths:\n\n```jq\n.properties.title\n.sheets[].properties.title # tab names\n.sheets[0].data[0].rowData[].values[].formattedValue # cell strings\n.namedRanges[]\n```\n\nDelete, on a `write` path:\n\n```sh\nrm {prefix}/owned/<file>.gsheet.json # deletes it from Drive for good\nrm -f <path> # ignores a missing file\n```\n\nOnly `.gsheet.json` files can be removed; `owned/` and `shared/` cannot.\n\nRename to a new title, on a `write` path:\n\n```sh\nmv {prefix}/owned/<date>_<old>__<id>.gsheet.json \\\n {prefix}/owned/<date>_<new>__<id>.gsheet.json\n```\n\nKeep the folder, the date and the id, and spell the title the way the\nlisting does (spaces become `_`); any other name is refused."; export declare class GSheetsVFS extends BaseVFS { readonly name: string; readonly cachesReads: boolean; readonly indexTtl: number; readonly readRevalidatable: boolean; vfsMd: string; readonly wholeWordSearch: boolean; readonly config: GSheetsConfig; readonly accessor: GSheetsAccessor; constructor(config: GSheetsConfig); readonly handed: { readonly unlink: readonly ["entry"]; readonly rename: readonly ["entry"]; }; readonly renderers: Readonly<Record<string, string>>; /** * Whether this VFS answers `name`; with no walk limit it reads every * file rather than ask the service's search. */ supports(name: string): boolean; filesContaining(path: PathSpec, text: string, opts: { wholeWord: boolean; ignoreCase: boolean; }): Promise<PathSpec[] | null>; readdir(path: PathSpec): Promise<FileStat[] | DirListing>; /** Render the file as the JSON its `.gsheet.json` name holds. */ readSheet(path: PathSpec, _handed?: Handed, offset?: number, size?: number | null): Promise<Uint8Array>; stat(path: PathSpec): Promise<FileStat>; unlink(path: PathSpec, handed?: Handed): Promise<void>; rename(src: PathSpec, dst: PathSpec, handed?: Handed): Promise<void>; deltaHook(): DeltaHook; getState(): Promise<ConfigState<RedactedSchema<typeof GoogleConfig>>>; } //# sourceMappingURL=gsheets.d.ts.map