import type { ColineCollection } from "./types"; /** The same record protocol for iframe, HTTP, and hosted callers. */ export function createCollectionClient( name: string, call: (operation: string, args: unknown[]) => Promise, ): ColineCollection { return { insert: (data, options) => call("storage.records.insert", [name, data, options ?? {}]), get: (id) => call("storage.records.get", [name, id]), update: (id, data, options) => call("storage.records.update", [name, id, data, options ?? {}]), delete: (id, options) => call("storage.records.delete", [name, id, options ?? {}]), setAccess: (id, access, options) => call("storage.records.setAccess", [name, id, access, options ?? {}]), query: (query) => call("storage.records.query", [name, query ?? {}]), sync: (query, revision) => call("storage.records.sync", [ name, query ?? {}, ...(revision === undefined ? [] : [revision]), ]), }; }