syncorejs 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_dashboard/assets/ConfirmActionDialog-Db4VzVp6.js +1 -0
- package/dist/_dashboard/assets/circle-x-VsB4Z8W4.js +1 -0
- package/dist/_dashboard/assets/data.lazy-DjdU9CzX.js +18 -0
- package/dist/_dashboard/assets/file-code-BrOKjG4n.js +1 -0
- package/dist/_dashboard/assets/functions.lazy-DvDwAGHq.js +1 -0
- package/dist/_dashboard/assets/funnel-BH8EMMJI.js +1 -0
- package/dist/_dashboard/assets/index-DT9ZEELb.css +1 -0
- package/dist/_dashboard/assets/index-DrSG4qZZ.js +54 -0
- package/dist/_dashboard/assets/loader-circle-CmJFSYga.js +1 -0
- package/dist/_dashboard/assets/logs.lazy-50KTk5yd.js +1 -0
- package/dist/_dashboard/assets/play-DS52VsLN.js +1 -0
- package/dist/_dashboard/assets/queries.lazy-CfysRWkz.js +1 -0
- package/dist/_dashboard/assets/scheduler.lazy-BB88mZk-.js +1 -0
- package/dist/_dashboard/assets/select-THYcR8Wt.js +1 -0
- package/dist/_dashboard/assets/separator-BU7xg615.js +1 -0
- package/dist/_dashboard/assets/shared-Bh0wwC2k.js +1 -0
- package/dist/_dashboard/assets/sql.lazy-CHtU9Qnt.js +13 -0
- package/dist/_dashboard/assets/storage.lazy-CneN7wVU.js +1 -0
- package/dist/_dashboard/assets/table-2-CH8JoMXf.js +1 -0
- package/dist/_dashboard/index.html +18 -0
- package/dist/_vendor/cli/app.d.mts.map +1 -1
- package/dist/_vendor/cli/app.mjs +16 -5
- package/dist/_vendor/cli/app.mjs.map +1 -1
- package/dist/_vendor/core/cli.d.mts.map +1 -1
- package/dist/_vendor/core/cli.mjs +358 -16
- package/dist/_vendor/core/cli.mjs.map +1 -1
- package/dist/_vendor/core/index.d.mts +3 -3
- package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/devtools.mjs +131 -0
- package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
- package/dist/_vendor/core/runtime/functions.d.mts +3 -3
- package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +4 -1
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +6 -3
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs +5 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +99 -13
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +38 -4
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -1
- package/dist/_vendor/core/runtime/runtime.d.mts +65 -8
- package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
- package/dist/_vendor/core/transport.d.mts.map +1 -1
- package/dist/_vendor/core/transport.mjs +30 -5
- package/dist/_vendor/core/transport.mjs.map +1 -1
- package/dist/_vendor/devtools-protocol/index.d.ts +75 -1
- package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
- package/dist/_vendor/devtools-protocol/index.js.map +1 -1
- package/dist/_vendor/next/index.js +9 -1
- package/dist/_vendor/next/index.js.map +1 -1
- package/dist/_vendor/platform-expo/index.d.ts +1 -1
- package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/index.js +6 -1
- package/dist/_vendor/platform-expo/index.js.map +1 -1
- package/dist/_vendor/platform-node/index.d.mts +2 -1
- package/dist/_vendor/platform-node/index.d.mts.map +1 -1
- package/dist/_vendor/platform-node/index.mjs +27 -2
- package/dist/_vendor/platform-node/index.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc-react.mjs +4 -0
- package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
- package/dist/_vendor/platform-web/external-change.d.ts +2 -2
- package/dist/_vendor/platform-web/external-change.js +2 -2
- package/dist/_vendor/platform-web/external-change.js.map +1 -1
- package/dist/_vendor/platform-web/index.d.ts +13 -10
- package/dist/_vendor/platform-web/index.d.ts.map +1 -1
- package/dist/_vendor/platform-web/index.js +66 -10
- package/dist/_vendor/platform-web/index.js.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.d.ts +3 -3
- package/dist/_vendor/platform-web/indexeddb.js +3 -3
- package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
- package/dist/_vendor/platform-web/opfs.d.ts +3 -1
- package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
- package/dist/_vendor/platform-web/opfs.js +29 -3
- package/dist/_vendor/platform-web/opfs.js.map +1 -1
- package/dist/_vendor/platform-web/persistence.d.ts +31 -1
- package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
- package/dist/_vendor/platform-web/persistence.js.map +1 -1
- package/dist/_vendor/platform-web/react.d.ts.map +1 -1
- package/dist/_vendor/platform-web/react.js +9 -1
- package/dist/_vendor/platform-web/react.js.map +1 -1
- package/dist/_vendor/react/index.d.ts +6 -5
- package/dist/_vendor/react/index.d.ts.map +1 -1
- package/dist/_vendor/react/index.js +6 -5
- package/dist/_vendor/react/index.js.map +1 -1
- package/dist/_vendor/svelte/index.d.ts +8 -6
- package/dist/_vendor/svelte/index.d.ts.map +1 -1
- package/dist/_vendor/svelte/index.js +7 -5
- package/dist/_vendor/svelte/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../../src/runtime/runtime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,CAAA,GAAQ,OAAA;EAnRH;;;;;;;EA8RX,YAAA,CAAA,GAAgB,aAAA;EArRwB;;;;;;;;EAiSxC,QAAA,CAAA,GAAY,mBAAA,CAAoB,OAAA;EAI1B,QAAA,gBAAA,CACJ,SAAA,EAAW,iBAAA,UAA2B,KAAA,EAAO,OAAA,GAC7C,IAAA,GAAM,UAAA,EACN,IAAA,GAAM,iBAAA,GACL,OAAA,CAAQ,OAAA;EAIL,WAAA,gBAAA,CACJ,SAAA,EAAW,iBAAA,aAA8B,KAAA,EAAO,OAAA,GAChD,IAAA,GAAM,UAAA,EACN,IAAA,GAAM,iBAAA,GACL,OAAA,CAAQ,OAAA;EAIL,SAAA,gBAAA,CACJ,SAAA,EAAW,iBAAA,WAA4B,KAAA,EAAO,OAAA,GAC9C,IAAA,GAAM,UAAA,EACN,IAAA,GAAM,iBAAA,GACL,OAAA,CAAQ,OAAA;EAIX,UAAA,gBAAA,CACE,SAAA,EAAW,iBAAA,UAA2B,KAAA,EAAO,OAAA,GAC7C,IAAA,GAAM,UAAA,GACL,YAAA,CAAa,OAAA;AAAA;AAAA,iBAKF,uBAAA,eACA,mBAAA,UACN,MAAA,kCAAA,CAER,IAAA,EAAM,KAAA,EAAO,IAAA,WAAe,iBAAA,CAAkB,KAAA,EAAO,KAAA,EAAO,OAAA;;;;;iBAQ9C,0BAAA;EAEZ,IAAA,EAAM,mBAAA;EACN,aAAA,EAAe,SAAA;EACf,gBAAA,GAAmB,SAAA;AAAA,EAAA,CAGrB,IAAA,EAAM,0BAAA,CAA2B,WAAA,GACjC,IAAA,WACC,iBAAA,CACD,0BAAA,CAA2B,WAAA,GAC3B,0BAAA,CAA2B,WAAA,GAC3B,4BAAA,CAA6B,WAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../src/runtime/runtime.ts"],"sourcesContent":["import type {\n DocumentChangePreview,\n SyncoreActiveQueryInfo,\n SyncoreDevtoolsEvent,\n SyncoreDevtoolsEventOrigin,\n SyncoreRuntimeSummary\n} from \"@syncore/devtools-protocol\";\nimport type {\n AnyTableDefinition,\n InferDocument,\n InferTableInput,\n SyncoreSchemaDefinition,\n TableIndexFields,\n TableIndexNames,\n TableSearchIndexConfig,\n TableSearchIndexNames,\n Validator\n} from \"@syncore/schema\";\nimport type {\n ResolvedSyncoreComponent,\n SyncoreComponentFunctionMetadata\n} from \"./components.js\";\nimport type {\n FunctionArgs,\n FunctionArgsFromDefinition,\n FunctionKindFromDefinition,\n FunctionReference,\n FunctionResultFromDefinition,\n MisfirePolicy,\n RecurringJobDefinition,\n RecurringSchedule,\n SyncoreFunctionKind\n} from \"./functions.js\";\nimport { RuntimeKernel } from \"./internal/runtimeKernel.js\";\n\n/**\n * A registered Syncore function ready for execution by the runtime.\n *\n * This is the shape stored in the function registry after Syncore processes a\n * definition exported from `syncore/functions/`. You rarely interact with this\n * directly — prefer the generated `api` object and the high-level function\n * builders ({@link query}, {@link mutation}, {@link action}).\n */\nexport interface RegisteredSyncoreFunction {\n kind: SyncoreFunctionKind;\n argsValidator: Validator<unknown, unknown, string>;\n returnsValidator?: Validator<unknown, unknown, string>;\n handler: RegisteredSyncoreHandler;\n __syncoreComponent?: SyncoreComponentFunctionMetadata;\n}\n\n/**\n * A map from function path strings (e.g. `\"tasks/create\"`) to their registered\n * definitions.\n *\n * This is the type of the second argument to {@link SyncoreRuntimeOptions} and\n * is produced by `npx syncorejs codegen` in `syncore/_generated/functions.ts`.\n * You should not need to implement this interface manually.\n */\nexport interface SyncoreFunctionRegistry {\n readonly [name: string]: RegisteredSyncoreFunction | undefined;\n}\n\n/** @internal Bivariant function handler type used to avoid TypeScript strictness issues with contravariant function parameters. */\nexport type RegisteredSyncoreHandler = {\n bivarianceHack(ctx: unknown, args: unknown): unknown;\n}[\"bivarianceHack\"];\n/** A plain JSON-serialisable object. Used for function arguments and scheduler payloads. */\nexport type JsonObject = Record<string, unknown>;\n\n/** A SQL-style comparison operator used when building index range queries. */\nexport type ComparisonOperator = \"=\" | \">\" | \">=\" | \"<\" | \"<=\";\n\n/**\n * A single field comparison used inside a query filter or index range.\n *\n * You typically get `QueryCondition` values from the builder callbacks passed\n * to {@link IndexRangeBuilder} or {@link FilterBuilder} — you do not construct\n * them manually.\n */\nexport type QueryCondition = {\n field: string;\n operator: ComparisonOperator;\n value: unknown;\n};\n\n/**\n * A composable predicate tree used by {@link FilterBuilder}.\n *\n * Leaf nodes are single {@link QueryCondition} values; branch nodes combine\n * conditions with `and` / `or` semantics. The runtime evaluates these trees\n * against documents during a query scan.\n */\nexport type QueryExpression =\n | { type: \"condition\"; condition: QueryCondition }\n | { type: \"and\"; expressions: QueryExpression[] }\n | { type: \"or\"; expressions: QueryExpression[] };\n\n/**\n * The arguments Syncore passes to its SQLite FTS5 full-text search layer when\n * a query uses `.withSearchIndex()`.\n */\nexport type SearchQuery = {\n searchField: string;\n searchText: string;\n filters: QueryCondition[];\n};\n\n/**\n * Result metadata returned by a single SQL `run` call.\n *\n * Wraps the driver's raw result so callers get consistent change-count and\n * last-insert-rowid values regardless of the underlying SQLite binding.\n */\nexport interface RunResult {\n /** Number of rows affected by the statement. */\n changes: number;\n /** The rowid of the last inserted row, if applicable. */\n lastInsertRowid?: number | string;\n}\n\n/**\n * Describes an optional runtime capability that functions can read from `ctx.capabilities`.\n *\n * Capabilities let platform adapters expose platform-specific services (e.g.\n * push notifications, biometrics) to Syncore functions in a portable way. The\n * runtime validates capabilities against their descriptors at start-up.\n */\nexport interface CapabilityDescriptor {\n /** Unique capability name. Must match the key used in `SyncoreCapabilities`. */\n name: string;\n /** Semantic version number for the capability’s interface contract. */\n version: number;\n /** Optional feature flags exposed by this capability. */\n features?: string[];\n /** Arbitrary metadata for introspection or devtools display. */\n metadata?: Record<string, unknown>;\n /**\n * When `true`, the runtime starts even if the capability is absent. Useful\n * for progressively-enhanced features that degrade gracefully.\n */\n optional?: boolean;\n}\n\n/**\n * Identifies a subset of the runtime state that a query depends on or that a\n * mutation has changed.\n *\n * The reactivity engine uses impact scopes to efficiently determine which\n * active queries need to be re-executed after a mutation commits. Scopes are\n * additive: a query subscribed to `\"table:tasks\"` will be invalidated by any\n * mutation that writes to the `tasks` table.\n *\n * - `\"runtime.summary\"` / `\"runtime.activeQueries\"` / `\"schema.tables\"` /\n * `\"scheduler.jobs\"` — runtime-level state consumed by devtools.\n * - `` `table:${string}` `` — every document in a specific table.\n * - `` `row:${string}:${string}` `` — a single document (table + id).\n * - `` `storage:${string}` `` — a specific storage object.\n */\nexport type ImpactScope =\n | \"runtime.summary\"\n | \"runtime.activeQueries\"\n | \"schema.tables\"\n | \"scheduler.jobs\"\n | `table:${string}`\n | `row:${string}:${string}`\n | `storage:${string}`;\n\n/** A frozen set of {@link ImpactScope} values. */\nexport type ImpactSet = ReadonlySet<ImpactScope>;\n\nexport interface ExecutionResult<TResult = unknown> {\n result: TResult;\n changedTables: Set<string>;\n documentChanges: DocumentChangePreview[];\n storageChanges: Array<{\n storageId: string;\n reason: Extract<SyncoreExternalChangeReason, \"storage-put\" | \"storage-delete\">;\n }>;\n scheduledJobs: string[];\n devtoolsEvents: SyncoreDevtoolsEvent[];\n externalChangeRequests: Array<{\n scope: SyncoreExternalChangeScope;\n reason: SyncoreExternalChangeReason;\n changedScopes: ImpactScope[];\n }>;\n}\n\n/**\n * Low-level interface that Syncore uses to communicate with a SQLite database.\n *\n * The runtime ships concrete implementations for every supported environment\n * (`NodeSqliteDriver`, `SqlJsDriver`, `ExpoSqliteDriver`). Implement this\n * interface only if you need to integrate a custom SQLite binding.\n *\n * All methods must be safe to call concurrently — the runtime serialises\n * concurrent writes through the driver’s own transaction mechanism.\n */\nexport interface SyncoreSqlDriver {\n /**\n * Execute one or more SQL statements that produce no result rows (e.g.\n * `CREATE TABLE`, `PRAGMA journal_mode = WAL`).\n */\n exec(sql: string): Promise<void>;\n /**\n * Execute a single parameterised statement and return change metadata.\n * Typically used for `INSERT`, `UPDATE`, and `DELETE`.\n */\n run(sql: string, params?: unknown[]): Promise<RunResult>;\n /**\n * Execute a query and return the first row, or `undefined` if there are no\n * results. Useful for `SELECT … LIMIT 1` lookups.\n */\n get<T>(sql: string, params?: unknown[]): Promise<T | undefined>;\n /**\n * Execute a query and return all matching rows as an array. Returns an empty\n * array when there are no results.\n */\n all<T>(sql: string, params?: unknown[]): Promise<T[]>;\n /**\n * Run `callback` inside an atomic SQLite transaction.\n *\n * If the callback throws, the transaction is rolled back automatically.\n * Implementations should support nested calls by using `SAVEPOINT`.\n */\n withTransaction<T>(callback: () => Promise<T>): Promise<T>;\n /**\n * Run `callback` inside a named SQLite savepoint, allowing partial rollback\n * within an outer transaction.\n */\n withSavepoint<T>(name: string, callback: () => Promise<T>): Promise<T>;\n /**\n * Release the underlying database handle. Called by the runtime during\n * shutdown. Implementations that hold no persistent resources may omit this.\n */\n close?(): Promise<void>;\n}\n\n/**\n * Identifies which category of local state an external change event affects.\n *\n * - `\"database\"` — One or more SQLite tables were written by an external\n * source (e.g. another Syncore instance sharing the same database file).\n * - `\"storage\"` — One or more blob/file storage objects were added or removed.\n * - `\"all\"` — Both the database and storage should be treated as changed.\n */\nexport type SyncoreExternalChangeScope = \"database\" | \"storage\" | \"all\";\n\n/**\n * Why an external change event was emitted.\n *\n * - `\"commit\"` — A write transaction was committed by another runtime instance.\n * - `\"storage-put\"` — A new storage object was written.\n * - `\"storage-delete\"` — A storage object was removed.\n * - `\"reconcile\"` — The runtime is re-synchronising with the underlying store\n * after a reconnect or restart.\n */\nexport type SyncoreExternalChangeReason =\n | \"commit\"\n | \"storage-put\"\n | \"storage-delete\"\n | \"reconcile\";\n\n/**\n * A message that notifies a Syncore runtime that state has changed in a source\n * it does not own — for example, a write made by a shared Node process that\n * the browser tab needs to reflect.\n *\n * The runtime subscribes to these events through a\n * {@link SyncoreExternalChangeSignal} and uses them to invalidate and refresh\n * affected queries without polling.\n */\nexport interface SyncoreExternalChangeEvent {\n /** Identifies the runtime instance that published this event. */\n sourceId: string;\n /** Which category of state changed. */\n scope: SyncoreExternalChangeScope;\n /** Why the change occurred. */\n reason: SyncoreExternalChangeReason;\n /** Unix timestamp (milliseconds) when the change was published. */\n timestamp: number;\n /** Optional opaque string used to detect duplicate or out-of-order events. */\n revision?: string;\n /** Specific impact scopes that were affected (subset of `scope`). */\n changedScopes?: ImpactScope[];\n /** Table names that were written to, when `scope` includes `\"database\"`. */\n changedTables?: string[];\n /** Storage object IDs that were affected, when `scope` includes `\"storage\"`. */\n storageIds?: string[];\n}\n\n/**\n * A pub/sub channel for cross-instance change notifications.\n *\n * Provide an implementation to `SyncoreRuntimeOptions.externalChangeSignal`\n * when multiple Syncore runtimes share the same underlying database (e.g. an\n * Electron main process and renderer, or multiple browser tabs). The runtime\n * will publish events after its own commits and react to events published by\n * other instances.\n *\n * Platform adapters ship ready-made implementations:\n * - `BroadcastChannelExternalChangeSignal` (browser, shared workers)\n * - Node IPC signal (Electron main ↔ renderer)\n */\nexport interface SyncoreExternalChangeSignal {\n /**\n * Register a listener for incoming change events.\n * @returns A cleanup function that removes the listener when called.\n */\n subscribe(listener: (event: SyncoreExternalChangeEvent) => void): () => void;\n /** Publish an outgoing change event to other subscribers. */\n publish(event: SyncoreExternalChangeEvent): void | Promise<void>;\n /** Optional cleanup called when the runtime shuts down. */\n close?(): void | Promise<void>;\n}\n\n/**\n * Applies an incoming {@link SyncoreExternalChangeEvent} to a local SQL\n * driver, reconciling the local state with a remote source.\n *\n * Typically provided by the same adapter that supplies\n * {@link SyncoreExternalChangeSignal} (e.g. `SqlJsExternalChangeApplier` for\n * browser runtimes). Only necessary when the local driver needs to pull in\n * changes made to the database file on disk by another process.\n */\nexport interface SyncoreExternalChangeApplier {\n applyExternalChange(event: SyncoreExternalChangeEvent): Promise<{\n databaseChanged: boolean;\n storageChanged: boolean;\n changedScopes: ImpactScope[];\n }>;\n}\n\n/**\n * The payload used when writing a new object through Syncore storage APIs.\n *\n * Pass this to `ctx.storage.put()` inside a mutation or action to persist a\n * binary blob alongside your database documents.\n *\n * ```ts\n * const id = await ctx.storage.put({\n * data: new Uint8Array(imageBytes),\n * contentType: \"image/png\",\n * fileName: \"avatar.png\",\n * });\n * // Store `id` in the database to reference the object later.\n * ```\n */\nexport interface StorageWriteInput {\n /**\n * The raw data to store. Accepts `Uint8Array`, `ArrayBuffer`, or a UTF-8\n * string (the string is encoded to bytes automatically).\n */\n data: Uint8Array | ArrayBuffer | string;\n /**\n * MIME type hint stored alongside the object (e.g. `\"image/png\"`,\n * `\"application/pdf\"`). Not validated or enforced by Syncore; purely\n * informational for downstream consumers.\n */\n contentType?: string;\n /**\n * Optional human-readable filename hint. Stored as metadata and surfaced in\n * devtools but not used for addressing the object (the auto-generated `id` is\n * used for that).\n */\n fileName?: string;\n}\n\n/**\n * Metadata describing a stored object managed by the Syncore storage adapter.\n *\n * Returned by `ctx.storage.get()` and `SyncoreStorageAdapter.list()`. The\n * `id` field is the opaque string you store in the database to reference this\n * object; use it with `ctx.storage.read()` to fetch the bytes.\n */\nexport interface StorageObject {\n /** Opaque identifier. Store this in a database document to reference the object. */\n id: string;\n /** Absolute path or key used by the storage backend (filesystem path, OPFS key, etc.). */\n path: string;\n /** Size of the stored data in bytes. */\n size: number;\n /** MIME type provided at write time, or `null` if none was specified. */\n contentType: string | null;\n}\n\n/**\n * Low-level interface for persisting and retrieving binary blobs alongside the\n * Syncore database.\n *\n * The runtime ships concrete implementations for every supported environment\n * (`NodeFileStorageAdapter`, `BrowserFileStorageAdapter`,\n * `ExpoFileStorageAdapter`). Implement this interface only if you need a custom\n * storage backend (e.g. an in-memory store for tests or an S3-compatible\n * remote).\n */\nexport interface SyncoreStorageAdapter {\n /**\n * Write a blob and return its metadata.\n *\n * @param id - The opaque identifier Syncore assigns to this object. Use\n * the same value to retrieve or delete the object later.\n * @param input - The data and optional metadata to persist.\n */\n put(id: string, input: StorageWriteInput): Promise<StorageObject>;\n /**\n * Return the metadata for a stored object, or `null` if it does not exist.\n * Does **not** return the raw bytes — use {@link read} for that.\n */\n get(id: string): Promise<StorageObject | null>;\n /**\n * Return the raw bytes of a stored object, or `null` if it does not exist.\n */\n read(id: string): Promise<Uint8Array | null>;\n /**\n * Permanently remove a stored object. A no-op if the object does not exist.\n */\n delete(id: string): Promise<void>;\n /**\n * Enumerate all stored objects. Used by devtools and migration tooling.\n * Optional — omit for backends that don’t support listing.\n */\n list?(): Promise<StorageObject[]>;\n}\n\n/**\n * Receives structured devtools events emitted by the runtime.\n *\n * In development the platform adapters automatically connect a WebSocket sink\n * that forwards events to the Syncore devtools dashboard. You can also supply\n * a custom sink for testing, logging, or building your own observability layer:\n *\n * ```ts\n * const sink: DevtoolsSink = {\n * emit(event) { console.log(\"[syncore]\", event.type); },\n * };\n * ```\n *\n * Pass `devtools: false` to the runtime options to disable devtools entirely\n * (recommended for production builds).\n */\nexport interface DevtoolsSink {\n /** Called synchronously every time the runtime emits a new event. */\n emit(event: SyncoreDevtoolsEvent): void;\n /**\n * Optional hook called once after the runtime is constructed so the sink can\n * hold a reference to it (e.g. to call `runtime.getAdmin()`).\n */\n attachRuntime?(runtime: SyncoreRuntime<SyncoreDataModel>): void;\n}\n\nexport interface DevtoolsLiveQuerySnapshot {\n summary: SyncoreRuntimeSummary;\n activeQueries: SyncoreActiveQueryInfo[];\n schemaTables: Array<{\n name: string;\n displayName?: string;\n owner: \"root\" | \"component\";\n componentPath?: string;\n componentName?: string;\n fields: Array<{\n name: string;\n type: string;\n optional: boolean;\n }>;\n indexes: Array<{\n name: string;\n fields: string[];\n unique: boolean;\n }>;\n documentCount: number;\n }>;\n}\n\nexport type DevtoolsLiveQueryScope =\n | \"all\"\n | \"runtime.summary\"\n | \"runtime.activeQueries\"\n | \"schema.tables\"\n | \"scheduler.jobs\"\n | `table:${string}`\n | `storage:${string}`;\n\n/**\n * Configuration for the Syncore built-in scheduler.\n *\n * Pass this to `SyncoreRuntimeOptions.scheduler` to enable background job\n * processing. The scheduler polls for pending one-off jobs (created via\n * `ctx.scheduler.runAfter` / `ctx.scheduler.runAt`) and for recurring jobs\n * defined with {@link CronJobs}.\n *\n * ```ts\n * import crons from \"./syncore/crons\";\n *\n * createNodeSyncoreRuntime({\n * ...,\n * scheduler: {\n * pollIntervalMs: 500,\n * recurringJobs: crons.jobs,\n * },\n * });\n * ```\n */\nexport interface SchedulerOptions {\n /**\n * How often the scheduler checks for jobs that are due, in milliseconds.\n * Defaults to `1000` (1 second). Lower values increase responsiveness at\n * the cost of more frequent SQLite reads.\n */\n pollIntervalMs?: number;\n /**\n * Static list of recurring job definitions to register when the runtime\n * starts. Build this with the {@link CronJobs} helper and a call to\n * {@link cronJobs}.\n */\n recurringJobs?: RecurringJobDefinition[];\n}\n\nexport type SyncoreResolvedComponents = readonly ResolvedSyncoreComponent[];\n\nexport interface UpdateScheduledJobOptions {\n id: string;\n schedule?: RecurringSchedule;\n args: JsonObject;\n misfirePolicy?: MisfirePolicy;\n runAt?: number;\n}\n\n/**\n * An open-ended bag of platform-specific capabilities exposed to Syncore\n * function handlers via `ctx.capabilities`.\n *\n * Use capabilities to inject platform services (push notifications, camera\n * access, native storage, etc.) that should be available inside your\n * functions without hard-coding platform imports:\n *\n * ```ts\n * // Runtime setup (platform-specific)\n * createExpoSyncoreRuntime({\n * ...,\n * capabilities: { pushNotifications: Notifications },\n * });\n *\n * // Inside a mutation\n * export const notify = mutation({\n * args: { message: s.string() },\n * handler: async (ctx, { message }) => {\n * await ctx.capabilities?.pushNotifications?.scheduleAsync({ body: message });\n * },\n * });\n * ```\n */\nexport interface SyncoreCapabilities {\n [name: string]: unknown;\n}\n\n/**\n * The typed data model that backs a Syncore runtime.\n *\n * `SyncoreDataModel` is the shape of the value returned by\n * {@link defineSchema}. It is the type parameter you see on\n * {@link SyncoreRuntime}, {@link QueryCtx}, {@link MutationCtx}, and the\n * generated server context types. Application code typically gets this from\n * the schema file rather than constructing it directly:\n *\n * ```ts\n * import schema from \"../syncore/schema\";\n * type MySchema = typeof schema;\n * ```\n */\nexport interface SyncoreDataModel<\n TTables extends SyncoreSchemaDefinition = SyncoreSchemaDefinition\n> {\n readonly tables: TTables;\n getTable(\n tableName: Extract<keyof TTables, string>\n ): TTables[Extract<keyof TTables, string>];\n tableNames(): Array<Extract<keyof TTables, string>>;\n}\n\n/**\n * Low-level options for constructing a {@link SyncoreRuntime} directly.\n *\n * Most applications should use a platform-specific factory function instead\n * (`createNodeSyncoreRuntime`, `createWebSyncoreRuntime`,\n * `createExpoSyncoreRuntime`, etc.), which fill in sensible defaults for the\n * driver, storage adapter, and devtools connection.\n *\n * Only reach for `SyncoreRuntimeOptions` when you need full control over the\n * underlying SQLite driver or storage backend.\n */\nexport interface SyncoreRuntimeOptions<\n TSchema extends SyncoreDataModel\n> {\n /** The data model that defines the available tables, indexes, and schemas. */\n schema: TSchema;\n /**\n * The registered functions Syncore can invoke. In practice this is always\n * the generated `functions` export from `syncore/_generated/functions.ts`.\n */\n functions: SyncoreFunctionRegistry;\n /**\n * Resolved Syncore component instances to mount alongside the root app\n * functions. Only required when your app installs Syncore components.\n */\n components?: SyncoreResolvedComponents;\n /**\n * The SQLite driver Syncore will use for all database operations.\n *\n * Use one of the platform-specific drivers shipped by Syncore\n * (`NodeSqliteDriver`, `SqlJsDriver`, `ExpoSqliteDriver`) or provide a\n * custom implementation of {@link SyncoreSqlDriver}.\n */\n driver: SyncoreSqlDriver;\n /**\n * The blob storage adapter used for `ctx.storage.put()` and related APIs.\n *\n * Use one of the platform-specific adapters\n * (`NodeFileStorageAdapter`, `BrowserFileStorageAdapter`,\n * `ExpoFileStorageAdapter`) or a custom implementation of\n * {@link SyncoreStorageAdapter}.\n */\n storage: SyncoreStorageAdapter;\n /**\n * A pub/sub channel that lets this runtime receive change notifications\n * published by other Syncore instances sharing the same data source.\n *\n * Required when running Syncore across multiple contexts that share a\n * database (e.g. Electron main + renderer, or multiple browser tabs).\n * Platform adapters provide ready-made implementations.\n */\n externalChangeSignal?: SyncoreExternalChangeSignal;\n /**\n * Applies incoming external change events to the local SQLite driver,\n * reconciling the local state with changes written by another process.\n *\n * Usually paired with `externalChangeSignal`. Only required for drivers\n * that hold an in-memory copy of the database (e.g. SQL.js in the browser).\n */\n externalChangeApplier?: SyncoreExternalChangeApplier;\n /**\n * Platform-specific capabilities injected into `ctx.capabilities` inside\n * every function handler. See {@link SyncoreCapabilities}.\n */\n capabilities?: SyncoreCapabilities;\n /** Structured capability descriptors validated at start-up. */\n capabilityDescriptors?: CapabilityDescriptor[];\n /**\n * Label reported to devtools to identify the runtime’s environment\n * (e.g. `\"node\"`, `\"browser\"`, `\"expo\"`, `\"electron-main\"`).\n */\n platform?: string;\n /**\n * Devtools event sink used during development.\n *\n * Pass `false` to disable devtools entirely (recommended for production).\n * Omit to use the platform adapter’s default auto-connect behaviour.\n */\n devtools?: DevtoolsSink;\n /** Scheduler configuration for background and recurring jobs. */\n scheduler?: SchedulerOptions;\n}\n\n/**\n * Arguments for a paginated Syncore query.\n *\n * Add `paginationOpts: s.object({ cursor: s.nullable(s.string()), numItems: s.number() })`\n * to your query’s `args` schema, then accept a `PaginationOptions` value in the\n * handler to enable cursor-based pagination:\n *\n * ```ts\n * export const listTasks = query({\n * args: {\n * paginationOpts: s.object({\n * cursor: s.nullable(s.string()),\n * numItems: s.number(),\n * }),\n * },\n * handler: async (ctx, { paginationOpts }) =>\n * ctx.db.query(\"tasks\").paginate(paginationOpts),\n * });\n * ```\n *\n * In React, use {@link usePaginatedQuery} which manages the cursor for you.\n */\nexport interface PaginationOptions {\n /**\n * The cursor returned by the previous page, or `null` / `undefined` for the\n * first page.\n */\n cursor?: string | null;\n /** Maximum number of items to return in this page. */\n numItems: number;\n}\n\n/**\n * The value returned by `ctx.db.query(…).paginate()`.\n *\n * Store the `cursor` field and pass it back in the next call to fetch the\n * following page. `isDone` is `true` when there are no more results.\n */\nexport interface PaginationResult<TItem> {\n /** The items in this page. May be fewer than `numItems` if `isDone` is `true`. */\n page: TItem[];\n /**\n * Opaque cursor to pass as `PaginationOptions.cursor` in the next call.\n * `null` when `isDone` is `true`.\n */\n cursor: string | null;\n /** `true` when this is the last page and no more results exist. */\n isDone: boolean;\n}\n\n/**\n * Coarse lifecycle phase of a Syncore runtime.\n *\n * - `\"starting\"` — The runtime is initialising (applying schema, loading driver).\n * - `\"ready\"` — The runtime is fully started and accepting function calls.\n * - `\"recovering\"` — A transient error occurred; the runtime is attempting recovery.\n * - `\"unavailable\"` — The runtime is unreachable (worker not started, IPC down, etc.).\n * - `\"error\"` — The runtime encountered an unrecoverable error.\n */\nexport type SyncoreRuntimeStatusKind =\n | \"starting\"\n | \"ready\"\n | \"recovering\"\n | \"unavailable\"\n | \"error\";\n\n/**\n * Explains why the runtime entered its current non-`\"ready\"` state.\n *\n * Useful for rendering descriptive loading or error messages in the UI.\n */\nexport type SyncoreRuntimeStatusReason =\n | \"booting\"\n | \"rehydrating\"\n | \"worker-restarting\"\n | \"worker-unavailable\"\n | \"ipc-unavailable\"\n | \"runtime-unavailable\"\n | \"disposed\";\n\n/**\n * Snapshot of the runtime’s current lifecycle state.\n *\n * Subscribe to changes with `client.watchRuntimeStatus()` or the\n * `useSyncoreStatus()` React hook to adapt the UI while the runtime is\n * starting up or recovering.\n *\n * ```ts\n * const status = useSyncoreStatus();\n * if (status.kind !== \"ready\") return <LoadingSpinner />;\n * ```\n */\nexport interface SyncoreRuntimeStatus {\n /** Coarse lifecycle phase. */\n kind: SyncoreRuntimeStatusKind;\n /** Machine-readable reason for a non-`\"ready\"` state. */\n reason?: SyncoreRuntimeStatusReason;\n /** The underlying error when `kind` is `\"error\"`. */\n error?: Error;\n}\n\n/**\n * Lifecycle status of an individual reactive query subscription.\n *\n * - `\"loading\"` — The query has never produced a result (first load).\n * - `\"success\"` — The query has data and no error.\n * - `\"error\"` — The last execution threw an error. `data` may still hold a\n * stale value from a prior successful run.\n * - `\"skipped\"` — The subscription was suppressed with the `skip` sentinel.\n */\nexport type SyncoreQueryStatus =\n | \"loading\"\n | \"success\"\n | \"error\"\n | \"skipped\";\n\n/**\n * The full reactive state of a Syncore query subscription.\n *\n * Returned by {@link useQueryState} and Svelte’s `createQueryStore`. For most\n * components you only need the `data` field — use {@link useQuery} for that\n * simpler shape.\n */\nexport interface SyncoreQueryState<TData> {\n /** The most recent result from the query, or `undefined` while loading. */\n data: TData | undefined;\n /** The error thrown by the last execution, or `undefined` on success. */\n error: Error | undefined;\n /** Fine-grained subscription lifecycle status. */\n status: SyncoreQueryStatus;\n /** Current lifecycle status of the underlying runtime. */\n runtimeStatus: SyncoreRuntimeStatus;\n /** `true` while waiting for the first result. Equivalent to `status === \"loading\"`. */\n isLoading: boolean;\n /** `true` when the last execution threw an error. */\n isError: boolean;\n /** `true` when `data` is available and the runtime is ready. */\n isReady: boolean;\n}\n\nexport type SyncoreQueryRequest<\n TReference extends FunctionReference<\"query\"> = FunctionReference<\"query\">\n> = (Record<never, never> extends FunctionArgs<TReference>\n ? {\n query: TReference;\n args?: FunctionArgs<TReference>;\n }\n : {\n query: TReference;\n args: FunctionArgs<TReference>;\n }) & {\n skip?: boolean;\n};\n\nexport type SyncoreQueriesRequest = Record<string, SyncoreQueryRequest>;\n\n/**\n * Lifecycle status of a paginated Syncore query subscription.\n *\n * - `\"loading\"` — Waiting for the first page to arrive.\n * - `\"ready\"` — At least one page has loaded and more pages are available.\n * - `\"loadingMore\"` — A `loadMore()` call is in progress.\n * - `\"exhausted\"` — All pages have been loaded (`isDone` is `true` on the\n * last page). `loadMore()` is a no-op in this state.\n * - `\"error\"` — The last page load failed. `error` contains the thrown error.\n */\nexport type SyncorePaginatedQueryStatus =\n | \"loading\"\n | \"ready\"\n | \"loadingMore\"\n | \"exhausted\"\n | \"error\";\n\n/**\n * The result object returned by {@link usePaginatedQuery} and\n * `createPaginatedQueryStore`.\n *\n * Contains the accumulated items, pagination metadata, and a `loadMore`\n * callback for fetching the next page.\n */\nexport interface UsePaginatedQueryResult<TItem> {\n /** All items loaded so far, across all fetched pages. */\n results: TItem[];\n /** Raw page results in order, one entry per fetched page. */\n pages: PaginationResult<TItem>[];\n /** Current lifecycle phase of the paginated query. */\n status: SyncorePaginatedQueryStatus;\n /** The error thrown by the last failed page load, or `undefined`. */\n error: Error | undefined;\n /** `true` while waiting for the first page. */\n isLoading: boolean;\n /** `true` while a `loadMore()` request is in progress. */\n isLoadingMore: boolean;\n /** `true` when there is a next page available to load. */\n hasMore: boolean;\n /** Cursor to pass to the next page request. `null` when `isDone` is `true`. */\n cursor: string | null;\n /** Current lifecycle status of the underlying runtime. */\n runtimeStatus: SyncoreRuntimeStatus;\n /**\n * Fetch the next page of results.\n *\n * @param numItems - Number of items to request. Defaults to `initialNumItems`.\n * A no-op when `hasMore` is `false`, `isLoadingMore` is `true`, or an error\n * occurred.\n */\n loadMore(numItems?: number): Promise<void> | void;\n}\n\n/**\n * A live, cancellable subscription to a reactive Syncore value.\n *\n * The runtime keeps the watched value up-to-date by re-running the underlying\n * query whenever its data dependencies change. `onUpdate` is called each time a\n * fresh result is available so the subscriber can read the new value with\n * `localQueryResult()`.\n *\n * React’s `useQuery` and Svelte’s `createQueryStore` are built on top of this\n * interface — you only need `SyncoreWatch` directly when integrating with\n * frameworks outside the first-party adapters.\n *\n * ```ts\n * const watch = client.watchQuery(api.tasks.list);\n * const unsubscribe = watch.onUpdate(() => {\n * console.log(watch.localQueryResult());\n * });\n * // Later:\n * unsubscribe();\n * watch.dispose?.();\n * ```\n */\nexport interface SyncoreWatch<TValue> {\n /**\n * Register a callback to be called whenever the watched value changes.\n * @returns An `unsubscribe` function; call it to stop receiving updates.\n */\n onUpdate(callback: () => void): () => void;\n /** Return the latest available query result, or `undefined` if not yet loaded. */\n localQueryResult(): TValue | undefined;\n /** Return the error from the last failed execution, or `undefined` on success. */\n localQueryError(): Error | undefined;\n /**\n * Release all resources held by this watch handle.\n *\n * Call this when the subscriber is unmounted or the watch is no longer needed\n * to prevent memory leaks. Framework adapters call this automatically.\n */\n dispose?(): void;\n}\n\nexport interface FilterBuilder {\n eq(field: string, value: unknown): QueryExpression;\n gt(field: string, value: unknown): QueryExpression;\n gte(field: string, value: unknown): QueryExpression;\n lt(field: string, value: unknown): QueryExpression;\n lte(field: string, value: unknown): QueryExpression;\n and(...expressions: QueryExpression[]): QueryExpression;\n or(...expressions: QueryExpression[]): QueryExpression;\n}\n\nexport interface IndexRangeBuilder<TFieldName extends string = string> {\n eq(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n gt(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n gte(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n lt(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n lte(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n build(): QueryCondition[];\n}\n\nexport interface SearchIndexBuilder<\n TSearchField extends string = string,\n TFilterField extends string = string\n> {\n search(\n field: TSearchField,\n value: string\n ): SearchIndexBuilder<TSearchField, TFilterField>;\n eq(\n field: TFilterField,\n value: unknown\n ): SearchIndexBuilder<TSearchField, TFilterField>;\n build(): SearchQuery;\n}\n\nexport type TableNames<\n TSchema extends SyncoreDataModel\n> = Extract<\n keyof TSchema[\"tables\"],\n string\n>;\n\nexport type DocumentForTable<\n TSchema extends SyncoreDataModel,\n TTableName extends TableNames<TSchema>\n> = InferDocument<TSchema[\"tables\"][TTableName]>;\n\nexport type InsertValueForTable<\n TSchema extends SyncoreDataModel,\n TTableName extends TableNames<TSchema>\n> = InferTableInput<TSchema[\"tables\"][TTableName]>;\n\ntype OptionalPropertyNames<TValue> = TValue extends object\n ? {\n [TKey in keyof TValue]-?: Omit<TValue, TKey> extends TValue\n ? TKey\n : never;\n }[keyof TValue]\n : never;\n\ntype PatchValue<TValue> = TValue extends object\n ? {\n [TKey in keyof TValue]?: TKey extends OptionalPropertyNames<TValue>\n ? TValue[TKey] | undefined\n : TValue[TKey];\n }\n : never;\n\nexport type PatchValueForTable<\n TSchema extends SyncoreDataModel,\n TTableName extends TableNames<TSchema>\n> = PatchValue<InsertValueForTable<TSchema, TTableName>>;\n\ntype OptionalArgsTuple<TArgs> =\n Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];\n\n/**\n * Read-only database API available inside Syncore query (and mutation/action)\n * handlers via `ctx.db`.\n *\n * All methods are fully typed against your schema — the table names and\n * returned document shapes are inferred from the `TSchema` type parameter:\n *\n * ```ts\n * // Fetch by ID\n * const task = await ctx.db.get(\"tasks\", taskId);\n *\n * // Chainable query builder\n * const todos = await ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_status\", (q) => q.eq(\"status\", \"todo\"))\n * .order(\"asc\")\n * .take(20);\n *\n * // Raw SQL escape hatch (use sparingly — bypasses type safety)\n * const rows = await ctx.db.raw<{ count: number }>(\n * \"SELECT COUNT(*) AS count FROM tasks\"\n * );\n * ```\n */\nexport interface SyncoreDatabaseReader<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> {\n /**\n * Fetch a single document by its `_id`, or `null` if it does not exist.\n *\n * @param table - The table to look in.\n * @param id - The document’s `_id` string.\n */\n get<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string\n ): Promise<DocumentForTable<TSchema, TTableName> | null>;\n /**\n * Start a chainable {@link QueryBuilder} for the given table.\n *\n * Chain `.withIndex()` or `.withSearchIndex()` to use an index, `.filter()`\n * for additional predicates, `.order()` to control direction, and then a\n * terminal method (`.collect()`, `.first()`, `.take()`, `.paginate()`).\n */\n query<TTableName extends TableNames<TSchema>>(\n table: TTableName\n ): QueryBuilder<\n TSchema[\"tables\"][TTableName],\n DocumentForTable<TSchema, TTableName>\n >;\n /**\n * Execute a raw SQL `SELECT` statement and return the results.\n *\n * Prefer the typed query builder whenever possible. Use `raw` as an escape\n * hatch for complex aggregations or joins that the builder cannot express.\n */\n raw<TValue = unknown>(sql: string, params?: unknown[]): Promise<TValue[]>;\n}\n\n/**\n * Read-write database API available inside Syncore mutation handlers via\n * `ctx.db`. Extends {@link SyncoreDatabaseReader} with write methods that\n * execute atomically within the mutation’s transaction.\n *\n * ```ts\n * // Insert a new document and get its generated _id\n * const id = await ctx.db.insert(\"tasks\", { title: \"Buy milk\", status: \"todo\", projectId: null });\n *\n * // Merge a partial update (other fields are preserved)\n * await ctx.db.patch(\"tasks\", id, { status: \"done\" });\n *\n * // Replace the entire document (all fields must be provided)\n * await ctx.db.replace(\"tasks\", id, { title: \"Buy oat milk\", status: \"todo\", projectId: null });\n *\n * // Delete a document\n * await ctx.db.delete(\"tasks\", id);\n * ```\n */\nexport interface SyncoreDatabaseWriter<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> extends SyncoreDatabaseReader<TSchema> {\n /**\n * Insert a new document and return its generated `_id`.\n *\n * The value must satisfy the table’s validator schema. System fields\n * (`_id`, `_creationTime`) are set automatically.\n */\n insert<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n value: InsertValueForTable<TSchema, TTableName>\n ): Promise<string>;\n /**\n * Merge `value` into the existing document at `id`.\n *\n * Only the keys present in `value` are updated; all other fields retain their\n * current values. Equivalent to a SQL `UPDATE … SET …` for specific columns.\n */\n patch<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string,\n value: PatchValueForTable<TSchema, TTableName>\n ): Promise<void>;\n /**\n * Overwrite the entire document at `id` with `value`.\n *\n * The `_id` and `_creationTime` system fields are preserved; all other\n * fields are replaced. Use `patch` when you only want to change a subset of\n * fields.\n */\n replace<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string,\n value: InsertValueForTable<TSchema, TTableName>\n ): Promise<void>;\n /**\n * Permanently delete the document with the given `id`.\n *\n * A no-op if the document does not exist.\n */\n delete<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string\n ): Promise<void>;\n}\n\n/**\n * Blob storage operations exposed to Syncore function handlers via\n * `ctx.storage`.\n *\n * Store large binary objects (images, PDFs, audio files) separately from the\n * SQLite database. Each object gets an opaque `id` that you can persist in a\n * document field for later retrieval.\n *\n * ```ts\n * // In a mutation\n * const id = await ctx.storage.put({\n * data: imageBuffer,\n * contentType: \"image/png\",\n * });\n * await ctx.db.patch(\"users\", userId, { avatarId: id });\n *\n * // In a query\n * const bytes = await ctx.storage.read(user.avatarId);\n * ```\n */\nexport interface SyncoreStorageApi {\n /**\n * Persist a binary blob and return its auto-generated opaque `id`.\n *\n * Store the returned `id` in a database document to reference the object.\n */\n put(input: StorageWriteInput): Promise<string>;\n /**\n * Return metadata for the stored object, or `null` if it does not exist.\n * Does not fetch the raw bytes — use `read` for that.\n */\n get(id: string): Promise<StorageObject | null>;\n /**\n * Return the raw bytes of the stored object, or `null` if it does not exist.\n */\n read(id: string): Promise<Uint8Array | null>;\n /**\n * Permanently delete the stored object. A no-op if the object does not exist.\n */\n delete(id: string): Promise<void>;\n}\n\n/**\n * Job scheduling API available to mutation and action handlers via\n * `ctx.scheduler`.\n *\n * Use `runAfter` and `runAt` to enqueue a mutation or action that runs outside\n * the current transaction — ideal for sending notifications, retrying\n * failed operations, or breaking long workflows into steps.\n *\n * ```ts\n * // Run a cleanup job 24 hours from now\n * await ctx.scheduler.runAfter(\n * 24 * 60 * 60_000,\n * api.cleanup.deleteExpiredSessions,\n * );\n *\n * // Run at a specific timestamp\n * const tomorrow = Date.now() + 86_400_000;\n * const jobId = await ctx.scheduler.runAt(tomorrow, api.email.sendDigest, { userId });\n *\n * // Cancel if the user opts out before the job fires\n * await ctx.scheduler.cancel(jobId);\n * ```\n */\nexport interface SchedulerApi {\n /**\n * Enqueue a mutation or action to run after `delayMs` milliseconds.\n *\n * @param delayMs - Delay from now in milliseconds.\n * @param functionReference - The mutation or action to execute.\n * @param args - Arguments forwarded to the function.\n * @param misfirePolicy - Optional policy for missed executions.\n * @returns An opaque job `id` you can pass to `cancel`.\n */\n runAfter<TArgs, TResult>(\n delayMs: number,\n functionReference: FunctionReference<\"mutation\" | \"action\", TArgs, TResult>,\n ...args: [...OptionalArgsTuple<TArgs>, misfirePolicy?: MisfirePolicy]\n ): Promise<string>;\n /**\n * Enqueue a mutation or action to run at a specific Unix timestamp (or\n * `Date` object).\n *\n * @param timestamp - When to run the job (ms since epoch, or a Date).\n * @param functionReference - The mutation or action to execute.\n * @param args - Arguments forwarded to the function.\n * @param misfirePolicy - Optional policy for missed executions.\n * @returns An opaque job `id` you can pass to `cancel`.\n */\n runAt<TArgs, TResult>(\n timestamp: number | Date,\n functionReference: FunctionReference<\"mutation\" | \"action\", TArgs, TResult>,\n ...args: [...OptionalArgsTuple<TArgs>, misfirePolicy?: MisfirePolicy]\n ): Promise<string>;\n /**\n * Cancel a pending scheduled job by its `id`.\n *\n * A no-op if the job has already executed or was already cancelled.\n */\n cancel(id: string): Promise<void>;\n}\n\n/**\n * Execution context injected into every Syncore **query** handler.\n *\n * `ctx` is the first argument of every `query()` handler. It provides\n * read-only database access, storage access, platform capabilities, and the\n * ability to call other queries. The type is generic over the app schema so\n * that `ctx.db` is fully typed against your tables.\n *\n * The generated `QueryCtx` in `syncore/_generated/server.ts` is always\n * preferred over the base type because it is pre-bound to your app schema:\n *\n * ```ts\n * import type { QueryCtx } from \"../_generated/server\";\n *\n * export const list = query({\n * args: { projectId: s.optional(s.id(\"projects\")) },\n * handler: async (ctx: QueryCtx, { projectId }) => {\n * return ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_project\", (q) =>\n * projectId ? q.eq(\"projectId\", projectId) : q\n * )\n * .collect();\n * },\n * });\n * ```\n */\nexport interface QueryCtx<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> {\n /** Read-only access to the local SQLite database. */\n db: SyncoreDatabaseReader<TSchema>;\n /** Blob storage access for reading files and images. */\n storage: SyncoreStorageApi;\n /**\n * Platform capabilities injected at runtime setup (e.g. push notifications,\n * biometrics). `undefined` when no capabilities were configured.\n */\n capabilities?: Readonly<SyncoreCapabilities>;\n /** Structured descriptors for the registered capabilities. */\n capabilityDescriptors?: ReadonlyArray<CapabilityDescriptor>;\n /**\n * Metadata about the Syncore component this function belongs to, if it was\n * installed as part of a component package rather than the root app.\n */\n component?: {\n path: string;\n name: string;\n version: string;\n capabilities: readonly string[];\n };\n /**\n * Call another Syncore query inside this handler.\n *\n * The callee’s read-set is merged into the current query’s dependencies, so\n * any change that would invalidate the callee also invalidates this query.\n */\n runQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n}\n\n/**\n * Execution context injected into every Syncore **mutation** handler.\n *\n * Extends {@link QueryCtx} with a writable database (`ctx.db`), a scheduler,\n * and the ability to call mutations or actions. Everything runs inside a single\n * atomic SQLite transaction that is committed when the handler returns or\n * rolled back if it throws.\n *\n * Use the generated `MutationCtx` from `syncore/_generated/server.ts` so that\n * `ctx.db` is typed to your specific schema:\n *\n * ```ts\n * import type { MutationCtx } from \"../_generated/server\";\n *\n * export const create = mutation({\n * args: { title: s.string() },\n * handler: async (ctx: MutationCtx, { title }) => {\n * const id = await ctx.db.insert(\"tasks\", {\n * title,\n * status: \"todo\",\n * projectId: null,\n * });\n * // Schedule a follow-up action without blocking the transaction\n * await ctx.scheduler.runAfter(0, api.tasks.notifyCreated, { id });\n * return id;\n * },\n * });\n * ```\n */\nexport interface MutationCtx<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> extends QueryCtx<TSchema> {\n /** Read-write database access. Changes are committed atomically on handler return. */\n db: SyncoreDatabaseWriter<TSchema>;\n /** Schedule mutations and actions to run outside the current transaction. */\n scheduler: SchedulerApi;\n /**\n * Call another mutation inside this handler’s transaction.\n *\n * The callee shares the current transaction context, so its writes are part\n * of the same atomic commit.\n */\n runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Launch an action from within a mutation. The action runs asynchronously\n * in a separate context **after** the mutation commits.\n */\n runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n}\n\n/**\n * Execution context injected into every Syncore **action** handler.\n *\n * Extends {@link QueryCtx} with a scheduler and the ability to call mutations\n * and other actions. Unlike mutations, actions run **outside** of any\n * transaction, so they can perform long-running or async work (HTTP requests,\n * file I/O, etc.) and delegate writes to mutations.\n *\n * Use the generated `ActionCtx` from `syncore/_generated/server.ts` so the\n * types are bound to your app schema:\n *\n * ```ts\n * import type { ActionCtx } from \"../_generated/server\";\n *\n * export const importFromApi = action({\n * args: { projectId: s.id(\"projects\") },\n * handler: async (ctx: ActionCtx, { projectId }) => {\n * const data = await fetch(\"https://api.example.com/tasks\").then((r) => r.json());\n * for (const item of data) {\n * await ctx.runMutation(api.tasks.create, { title: item.title });\n * }\n * },\n * });\n * ```\n */\nexport interface ActionCtx<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> extends QueryCtx<TSchema> {\n /** Schedule mutations and actions to run at a later time. */\n scheduler: SchedulerApi;\n /**\n * Call a mutation from within this action.\n *\n * Because actions are non-transactional, each `runMutation` call creates its\n * own transaction. If the action fails partway through, earlier mutations are\n * **not** rolled back automatically — design accordingly.\n */\n runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /** Call another action from within this action. */\n runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n}\n\n/**\n * The client-facing API for calling Syncore functions and subscribing to\n * reactive query results.\n *\n * You obtain a `SyncoreClient` by calling `runtime.createClient()` or, for\n * worker-based browser setups, via the platform adapter’s\n * `createWebWorkerClient()` / `createManagedWebWorkerClient()` helpers.\n *\n * In React, the client is provided to the component tree via\n * {@link SyncoreProvider} and consumed through hooks (`useQuery`,\n * `useMutation`, etc.) — you rarely call these methods directly.\n *\n * ```ts\n * const client = runtime.createClient();\n *\n * // One-shot query\n * const tasks = await client.query(api.tasks.list);\n *\n * // One-shot mutation\n * await client.mutation(api.tasks.create, { title: \"Buy milk\" });\n *\n * // Reactive subscription\n * const watch = client.watchQuery(api.tasks.list);\n * watch.onUpdate(() => console.log(watch.localQueryResult()));\n * ```\n */\nexport interface SyncoreClient {\n /**\n * Execute a query and return its result.\n *\n * Unlike a reactive subscription, this is a one-shot call that does not\n * stay up to date. Use `watchQuery` or the `useQuery` hook for live data.\n */\n query<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Execute a mutation and return its result.\n *\n * The mutation runs atomically and all affected queries are automatically\n * re-executed after the commit.\n */\n mutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Execute an action and return its result.\n *\n * Actions are non-transactional and may take arbitrarily long to complete.\n */\n action<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Subscribe to a reactive query and return a {@link SyncoreWatch} handle.\n *\n * The watch delivers a new result every time the underlying data changes.\n * Call `watch.onUpdate()` to listen and `watch.dispose()` when done.\n */\n watchQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): SyncoreWatch<TResult>;\n /**\n * Subscribe to the runtime’s lifecycle status.\n *\n * Useful for showing loading or error states in the UI while the runtime is\n * starting or recovering.\n */\n watchRuntimeStatus(): SyncoreWatch<SyncoreRuntimeStatus>;\n}\n\nexport interface SyncoreRuntimeAdmin<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> {\n prepareForDirectAccess(): Promise<void>;\n createClient(): SyncoreClient;\n runQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n args?: JsonObject,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n args?: JsonObject,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n args?: JsonObject,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n runDevtoolsMutation<TResult>(\n callback: (ctx: { db: SyncoreDatabaseWriter<TSchema> }) => Promise<TResult>,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n getRuntimeSummary(): SyncoreRuntimeSummary;\n getActiveQueryInfos(): SyncoreActiveQueryInfo[];\n getRuntimeId(): string;\n getDriverDatabasePath(): string | undefined;\n subscribeToDevtoolsEvents(\n listener: (event: SyncoreDevtoolsEvent) => void\n ): () => void;\n subscribeToDevtoolsInvalidations(\n listener: (scopes: Set<DevtoolsLiveQueryScope>) => void\n ): () => void;\n notifyDevtoolsScopes(scopes: Iterable<DevtoolsLiveQueryScope>): void;\n forceRefreshDevtools(\n reason: string,\n scopes?: Iterable<ImpactScope>,\n meta?: DevtoolsEventMeta\n ): Promise<void>;\n cancelScheduledJob(id: string): Promise<boolean>;\n updateScheduledJob(options: UpdateScheduledJobOptions): Promise<boolean>;\n}\n\ntype DevtoolsEventMeta = {\n origin?: SyncoreDevtoolsEventOrigin;\n executionId?: string;\n parentExecutionId?: string;\n schedulerJobId?: string;\n schedulerRun?: boolean;\n};\n\n/**\n * Chainable query builder returned by `ctx.db.query(tableName)`.\n *\n * Chain methods in this order to build up a query:\n *\n * 1. **Optional** — `.withIndex()` or `.withSearchIndex()` to use an index.\n * 2. **Optional** — `.filter()` to add arbitrary field predicates.\n * 3. **Optional** — `.order()` to control sort direction (defaults to `\"asc\"`).\n * 4. **Required terminal** — `.collect()`, `.take()`, `.first()`, `.unique()`,\n * or `.paginate()`.\n *\n * ```ts\n * // Fetch all tasks in a project, newest first, limited to 10\n * const tasks = await ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_project\", (q) => q.eq(\"projectId\", id))\n * .order(\"desc\")\n * .take(10);\n *\n * // Full-text search with a filter\n * const results = await ctx.db\n * .query(\"tasks\")\n * .withSearchIndex(\"search_title\", (q) =>\n * q.search(\"title\", searchText).eq(\"status\", \"todo\")\n * )\n * .collect();\n * ```\n */\nexport interface QueryBuilder<\n TTable extends AnyTableDefinition,\n TDocument = InferDocument<TTable>\n> {\n /**\n * Restrict the query to documents matching an index range.\n *\n * @param indexName - The name of the index to use (must be registered via `defineTable().index()`).\n * @param builder - Optional callback that receives an `IndexRangeBuilder` and returns it\n * after chaining `eq`, `gt`, `gte`, `lt`, `lte` calls. Omit to return all documents in\n * index order.\n */\n withIndex<TIndexName extends TableIndexNames<TTable>>(\n indexName: TIndexName,\n builder?: (\n range: IndexRangeBuilder<TableIndexFields<TTable, TIndexName>[number]>\n ) => IndexRangeBuilder<TableIndexFields<TTable, TIndexName>[number]>\n ): this;\n /**\n * Restrict the query to documents matching a full-text search index.\n *\n * @param indexName - The name of the search index (must be registered via `defineTable().searchIndex()`).\n * @param builder - Callback that calls `.search(field, text)` and optionally chains\n * `.eq(filterField, value)` conditions.\n */\n withSearchIndex<TIndexName extends TableSearchIndexNames<TTable>>(\n indexName: TIndexName,\n builder: (\n search: SearchIndexBuilder<\n TableSearchIndexConfig<TTable, TIndexName>[\"searchField\"],\n TableSearchIndexConfig<TTable, TIndexName>[\"filterFields\"]\n >\n ) => SearchIndexBuilder<\n TableSearchIndexConfig<TTable, TIndexName>[\"searchField\"],\n TableSearchIndexConfig<TTable, TIndexName>[\"filterFields\"]\n >\n ): this;\n /**\n * Set the iteration order for this query. Defaults to `\"asc\"`.\n *\n * When used with `withIndex`, the order applies to the index's primary sort key.\n * When used without an index (full table scan), `\"asc\"` and `\"desc\"` refer to\n * insertion order.\n */\n order(order: \"asc\" | \"desc\"): this;\n /**\n * Add an additional in-memory predicate that is applied after index\n * evaluation.\n *\n * Use this for conditions that cannot be expressed as an index range (e.g.\n * checking a field not covered by the active index). Heavy use of `filter`\n * on large tables causes a full index scan — prefer dedicated indexes for\n * frequently filtered fields.\n */\n filter(builder: (filter: FilterBuilder) => QueryExpression): this;\n /** Execute the query and return all matching documents as an array. */\n collect(): Promise<TDocument[]>;\n /**\n * Execute the query and return at most `count` documents.\n *\n * More efficient than `collect()` when you only need a limited number of\n * results.\n */\n take(count: number): Promise<TDocument[]>;\n /**\n * Execute the query and return the first matching document, or `null` if\n * there are no results.\n */\n first(): Promise<TDocument | null>;\n /**\n * Execute the query and return the single matching document, or `null` if\n * there are no results. Throws if more than one document matches.\n *\n * Use when you expect exactly zero or one result (e.g. a unique index\n * lookup).\n */\n unique(): Promise<TDocument | null>;\n /**\n * Execute the query with cursor-based pagination.\n *\n * Pass `PaginationOptions` (a `cursor` and `numItems`) to fetch one page at\n * a time. The returned `PaginationResult` contains the page items, the next\n * cursor, and an `isDone` flag.\n */\n paginate(options: PaginationOptions): Promise<PaginationResult<TDocument>>;\n}\n\n/**\n * Local-first Syncore runtime that hosts your schema, functions, and storage.\n *\n * `SyncoreRuntime` is the central engine of every Syncore app. It owns the\n * SQLite driver, the storage adapter, the reactivity engine, and the\n * background scheduler. Platform-specific factory functions\n * (`createNodeSyncoreRuntime`, `createWebSyncoreRuntime`, etc.) wrap it with\n * environment-appropriate defaults so you rarely need to instantiate it\n * directly.\n *\n * **Lifecycle**\n * 1. Construct the runtime (schema migration is deferred until first use).\n * 2. Call `await runtime.start()` to apply the schema, start the scheduler,\n * and connect to devtools. The runtime emits `\"runtime.connected\"` when ready.\n * 3. Call `runtime.createClient()` to get a {@link SyncoreClient} for\n * invoking functions and subscribing to reactive queries.\n * 4. Call `await runtime.stop()` on shutdown to flush pending jobs and close\n * the database.\n *\n * ```ts\n * const runtime = new SyncoreRuntime({\n * schema,\n * functions,\n * driver: new NodeSqliteDriver(\"./db.sqlite\"),\n * storage: new NodeFileStorageAdapter(\"./storage\"),\n * });\n * await runtime.start();\n * const client = runtime.createClient();\n * ```\n */\nexport class SyncoreRuntime<\n TSchema extends SyncoreDataModel\n> {\n private readonly kernel: RuntimeKernel<TSchema>;\n\n constructor(private readonly options: SyncoreRuntimeOptions<TSchema>) {\n this.kernel = new RuntimeKernel(options, this);\n }\n\n /**\n * Start the runtime: apply the schema migration, initialise the scheduler,\n * and connect to devtools (if configured).\n *\n * Must be called and awaited before using the client. Calling `start()`\n * a second time is a no-op.\n */\n async start(): Promise<void> {\n await this.kernel.start();\n }\n\n /**\n * Prepare the runtime for direct (synchronous) access patterns used by\n * devtools and migration tooling.\n *\n * You do not need to call this in normal application code.\n */\n async prepareForDirectAccess(): Promise<void> {\n await this.kernel.prepareForDirectAccess();\n }\n\n /**\n * Stop the runtime gracefully.\n *\n * Flushes any pending scheduler jobs, closes the SQLite driver, and\n * disconnects from devtools. Call this when your application is shutting\n * down to avoid database file corruption.\n */\n async stop(): Promise<void> {\n await this.kernel.stop();\n }\n\n /**\n * Create a new {@link SyncoreClient} bound to this runtime.\n *\n * Multiple clients can be created from the same runtime — they all share\n * the same underlying database and reactivity engine. Usually you only need\n * one client per runtime instance.\n */\n createClient(): SyncoreClient {\n return this.kernel.createClient();\n }\n\n /**\n * Return the low-level admin API.\n *\n * The admin API exposes devtools introspection, direct query/mutation\n * execution, and scheduler management. It is used by the devtools\n * dashboard and integration tooling — most application code should use\n * the regular `SyncoreClient` instead.\n */\n getAdmin(): SyncoreRuntimeAdmin<TSchema> {\n return this.kernel.admin;\n }\n\n async runQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n args: JsonObject = {},\n meta: DevtoolsEventMeta = {}\n ): Promise<TResult> {\n return this.kernel.executionEngine.runQuery(reference, args, meta);\n }\n\n async runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n args: JsonObject = {},\n meta: DevtoolsEventMeta = {}\n ): Promise<TResult> {\n return this.kernel.executionEngine.runMutation(reference, args, meta);\n }\n\n async runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n args: JsonObject = {},\n meta: DevtoolsEventMeta = {}\n ): Promise<TResult> {\n return this.kernel.executionEngine.runAction(reference, args, meta);\n }\n\n watchQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n args: JsonObject = {}\n ): SyncoreWatch<TResult> {\n return this.kernel.watchQuery(reference, args);\n }\n}\n\nexport function createFunctionReference<\n TKind extends SyncoreFunctionKind,\n TArgs = Record<never, never>,\n TResult = unknown\n>(kind: TKind, name: string): FunctionReference<TKind, TArgs, TResult> {\n return { kind, name };\n}\n\n/**\n * Create a function reference from an existing Syncore function definition\n * while preserving its inferred args and result types.\n */\nexport function createFunctionReferenceFor<\n TDefinition extends {\n kind: SyncoreFunctionKind;\n argsValidator: Validator<unknown, unknown, string>;\n returnsValidator?: Validator<unknown, unknown, string>;\n }\n>(\n kind: FunctionKindFromDefinition<TDefinition>,\n name: string\n): FunctionReference<\n FunctionKindFromDefinition<TDefinition>,\n FunctionArgsFromDefinition<TDefinition>,\n FunctionResultFromDefinition<TDefinition>\n> {\n return { kind, name };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAunDA,IAAa,iBAAb,MAEE;CAG6B;CAF7B;CAEA,YAAY,SAA0D;EAAzC,KAAA,UAAA;EAC3B,KAAK,SAAS,IAAI,cAAc,SAAS,IAAI;CAC/C;;;;;;;;CASA,MAAM,QAAuB;EAC3B,MAAM,KAAK,OAAO,MAAM;CAC1B;;;;;;;CAQA,MAAM,yBAAwC;EAC5C,MAAM,KAAK,OAAO,uBAAuB;CAC3C;;;;;;;;CASA,MAAM,OAAsB;EAC1B,MAAM,KAAK,OAAO,KAAK;CACzB;;;;;;;;CASA,eAA8B;EAC5B,OAAO,KAAK,OAAO,aAAa;CAClC;;;;;;;;;CAUA,WAAyC;EACvC,OAAO,KAAK,OAAO;CACrB;CAEA,MAAM,SACJ,WACA,OAAmB,CAAC,GACpB,OAA0B,CAAC,GACT;EAClB,OAAO,KAAK,OAAO,gBAAgB,SAAS,WAAW,MAAM,IAAI;CACnE;CAEA,MAAM,YACJ,WACA,OAAmB,CAAC,GACpB,OAA0B,CAAC,GACT;EAClB,OAAO,KAAK,OAAO,gBAAgB,YAAY,WAAW,MAAM,IAAI;CACtE;CAEA,MAAM,UACJ,WACA,OAAmB,CAAC,GACpB,OAA0B,CAAC,GACT;EAClB,OAAO,KAAK,OAAO,gBAAgB,UAAU,WAAW,MAAM,IAAI;CACpE;CAEA,WACE,WACA,OAAmB,CAAC,GACG;EACvB,OAAO,KAAK,OAAO,WAAW,WAAW,IAAI;CAC/C;AACF;AAEA,SAAgB,wBAId,MAAa,MAAwD;CACrE,OAAO;EAAE;EAAM;CAAK;AACtB;;;;;AAMA,SAAgB,2BAOd,MACA,MAKA;CACA,OAAO;EAAE;EAAM;CAAK;AACtB"}
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../src/runtime/runtime.ts"],"sourcesContent":["import type {\n DocumentChangePreview,\n StorageEntry,\n SyncoreActiveQueryInfo,\n SyncoreDevtoolsEvent,\n SyncoreDevtoolsEventOrigin,\n SyncoreRuntimeSummary\n} from \"@syncore/devtools-protocol\";\nimport type {\n AnyTableDefinition,\n InferDocument,\n InferTableInput,\n SyncoreSchemaDefinition,\n TableIndexFields,\n TableIndexNames,\n TableSearchIndexConfig,\n TableSearchIndexNames,\n Validator\n} from \"@syncore/schema\";\nimport type {\n ResolvedSyncoreComponent,\n SyncoreComponentFunctionMetadata\n} from \"./components.js\";\nimport type {\n FunctionArgs,\n FunctionArgsFromDefinition,\n FunctionKindFromDefinition,\n FunctionReference,\n FunctionResultFromDefinition,\n MisfirePolicy,\n RecurringJobDefinition,\n RecurringSchedule,\n SyncoreFunctionKind\n} from \"./functions.js\";\nimport { RuntimeKernel } from \"./internal/runtimeKernel.js\";\n\n/**\n * A registered Syncore function ready for execution by the runtime.\n *\n * This is the shape stored in the function registry after Syncore processes a\n * definition exported from `syncore/functions/`. You rarely interact with this\n * directly — prefer the generated `api` object and the high-level function\n * builders ({@link query}, {@link mutation}, {@link action}).\n */\nexport interface RegisteredSyncoreFunction {\n kind: SyncoreFunctionKind;\n argsValidator: Validator<unknown, unknown, string>;\n returnsValidator?: Validator<unknown, unknown, string>;\n handler: RegisteredSyncoreHandler;\n __syncoreComponent?: SyncoreComponentFunctionMetadata;\n}\n\n/**\n * A map from function path strings (e.g. `\"tasks/create\"`) to their registered\n * definitions.\n *\n * This is the type of the second argument to {@link SyncoreRuntimeOptions} and\n * is produced by `npx syncorejs codegen` in `syncore/_generated/functions.ts`.\n * You should not need to implement this interface manually.\n */\nexport interface SyncoreFunctionRegistry {\n readonly [name: string]: RegisteredSyncoreFunction | undefined;\n}\n\n/** @internal Bivariant function handler type used to avoid TypeScript strictness issues with contravariant function parameters. */\nexport type RegisteredSyncoreHandler = {\n bivarianceHack(ctx: unknown, args: unknown): unknown;\n}[\"bivarianceHack\"];\n/** A plain JSON-serialisable object. Used for function arguments and scheduler payloads. */\nexport type JsonObject = Record<string, unknown>;\n\n/** A SQL-style comparison operator used when building index range queries. */\nexport type ComparisonOperator = \"=\" | \">\" | \">=\" | \"<\" | \"<=\";\n\n/**\n * A single field comparison used inside a query filter or index range.\n *\n * You typically get `QueryCondition` values from the builder callbacks passed\n * to {@link IndexRangeBuilder} or {@link FilterBuilder} — you do not construct\n * them manually.\n */\nexport type QueryCondition = {\n field: string;\n operator: ComparisonOperator;\n value: unknown;\n};\n\n/**\n * A composable predicate tree used by {@link FilterBuilder}.\n *\n * Leaf nodes are single {@link QueryCondition} values; branch nodes combine\n * conditions with `and` / `or` semantics. The runtime evaluates these trees\n * against documents during a query scan.\n */\nexport type QueryExpression =\n | { type: \"condition\"; condition: QueryCondition }\n | { type: \"and\"; expressions: QueryExpression[] }\n | { type: \"or\"; expressions: QueryExpression[] };\n\n/**\n * The arguments Syncore passes to its SQLite FTS5 full-text search layer when\n * a query uses `.withSearchIndex()`.\n */\nexport type SearchQuery = {\n searchField: string;\n searchText: string;\n filters: QueryCondition[];\n};\n\n/**\n * Result metadata returned by a single SQL `run` call.\n *\n * Wraps the driver's raw result so callers get consistent change-count and\n * last-insert-rowid values regardless of the underlying SQLite binding.\n */\nexport interface RunResult {\n /** Number of rows affected by the statement. */\n changes: number;\n /** The rowid of the last inserted row, if applicable. */\n lastInsertRowid?: number | string;\n}\n\n/**\n * Describes an optional runtime capability that functions can read from `ctx.capabilities`.\n *\n * Capabilities let platform adapters expose platform-specific services (e.g.\n * push notifications, biometrics) to Syncore functions in a portable way. The\n * runtime validates capabilities against their descriptors at start-up.\n */\nexport interface CapabilityDescriptor {\n /** Unique capability name. Must match the key used in `SyncoreCapabilities`. */\n name: string;\n /** Semantic version number for the capability’s interface contract. */\n version: number;\n /** Optional feature flags exposed by this capability. */\n features?: string[];\n /** Arbitrary metadata for introspection or devtools display. */\n metadata?: Record<string, unknown>;\n /**\n * When `true`, the runtime starts even if the capability is absent. Useful\n * for progressively-enhanced features that degrade gracefully.\n */\n optional?: boolean;\n}\n\n/**\n * Identifies a subset of the runtime state that a query depends on or that a\n * mutation has changed.\n *\n * The reactivity engine uses impact scopes to efficiently determine which\n * active queries need to be re-executed after a mutation commits. Scopes are\n * additive: a query subscribed to `\"table:tasks\"` will be invalidated by any\n * mutation that writes to the `tasks` table.\n *\n * - `\"runtime.summary\"` / `\"runtime.activeQueries\"` / `\"schema.tables\"` /\n * `\"scheduler.jobs\"` / `\"storage.objects\"` - runtime-level state consumed by devtools.\n * - `table:${string}` - every document in a specific table.\n * - `row:${string}:${string}` - a single document (table + id).\n * - `storage:${string}` - a specific storage object.\n */\nexport type ImpactScope =\n | \"runtime.summary\"\n | \"runtime.activeQueries\"\n | \"schema.tables\"\n | \"scheduler.jobs\"\n | \"storage.objects\"\n | `table:${string}`\n | `row:${string}:${string}`\n | `storage:${string}`;\n\n/** A frozen set of {@link ImpactScope} values. */\nexport type ImpactSet = ReadonlySet<ImpactScope>;\n\nexport interface ExecutionResult<TResult = unknown> {\n result: TResult;\n changedTables: Set<string>;\n documentChanges: DocumentChangePreview[];\n storageChanges: Array<{\n storageId: string;\n reason: Extract<\n SyncoreExternalChangeReason,\n \"storage-put\" | \"storage-delete\"\n >;\n }>;\n scheduledJobs: string[];\n devtoolsEvents: SyncoreDevtoolsEvent[];\n externalChangeRequests: Array<{\n scope: SyncoreExternalChangeScope;\n reason: SyncoreExternalChangeReason;\n changedScopes: ImpactScope[];\n }>;\n}\n\n/**\n * Low-level interface that Syncore uses to communicate with a SQLite database.\n *\n * The runtime ships concrete implementations for every supported environment\n * (`NodeSqliteDriver`, `SqlJsDriver`, `ExpoSqliteDriver`). Implement this\n * interface only if you need to integrate a custom SQLite binding.\n *\n * All methods must be safe to call concurrently — the runtime serialises\n * concurrent writes through the driver’s own transaction mechanism.\n */\nexport interface SyncoreSqlDriver {\n /**\n * Execute one or more SQL statements that produce no result rows (e.g.\n * `CREATE TABLE`, `PRAGMA journal_mode = WAL`).\n */\n exec(sql: string): Promise<void>;\n /**\n * Execute a single parameterised statement and return change metadata.\n * Typically used for `INSERT`, `UPDATE`, and `DELETE`.\n */\n run(sql: string, params?: unknown[]): Promise<RunResult>;\n /**\n * Execute a query and return the first row, or `undefined` if there are no\n * results. Useful for `SELECT … LIMIT 1` lookups.\n */\n get<T>(sql: string, params?: unknown[]): Promise<T | undefined>;\n /**\n * Execute a query and return all matching rows as an array. Returns an empty\n * array when there are no results.\n */\n all<T>(sql: string, params?: unknown[]): Promise<T[]>;\n /**\n * Run `callback` inside an atomic SQLite transaction.\n *\n * If the callback throws, the transaction is rolled back automatically.\n * Implementations should support nested calls by using `SAVEPOINT`.\n */\n withTransaction<T>(callback: () => Promise<T>): Promise<T>;\n /**\n * Run `callback` inside a named SQLite savepoint, allowing partial rollback\n * within an outer transaction.\n */\n withSavepoint<T>(name: string, callback: () => Promise<T>): Promise<T>;\n /**\n * Release the underlying database handle. Called by the runtime during\n * shutdown. Implementations that hold no persistent resources may omit this.\n */\n close?(): Promise<void>;\n}\n\n/**\n * Identifies which category of local state an external change event affects.\n *\n * - `\"database\"` — One or more SQLite tables were written by an external\n * source (e.g. another Syncore instance sharing the same database file).\n * - `\"storage\"` — One or more blob/file storage objects were added or removed.\n * - `\"all\"` — Both the database and storage should be treated as changed.\n */\nexport type SyncoreExternalChangeScope = \"database\" | \"storage\" | \"all\";\n\n/**\n * Why an external change event was emitted.\n *\n * - `\"commit\"` — A write transaction was committed by another runtime instance.\n * - `\"storage-put\"` — A new storage object was written.\n * - `\"storage-delete\"` — A storage object was removed.\n * - `\"reconcile\"` — The runtime is re-synchronising with the underlying store\n * after a reconnect or restart.\n */\nexport type SyncoreExternalChangeReason =\n | \"commit\"\n | \"storage-put\"\n | \"storage-delete\"\n | \"reconcile\";\n\n/**\n * A message that notifies a Syncore runtime that state has changed in a source\n * it does not own — for example, a write made by a shared Node process that\n * the browser tab needs to reflect.\n *\n * The runtime subscribes to these events through a\n * {@link SyncoreExternalChangeSignal} and uses them to invalidate and refresh\n * affected queries without polling.\n */\nexport interface SyncoreExternalChangeEvent {\n /** Identifies the runtime instance that published this event. */\n sourceId: string;\n /** Which category of state changed. */\n scope: SyncoreExternalChangeScope;\n /** Why the change occurred. */\n reason: SyncoreExternalChangeReason;\n /** Unix timestamp (milliseconds) when the change was published. */\n timestamp: number;\n /** Optional opaque string used to detect duplicate or out-of-order events. */\n revision?: string;\n /** Specific impact scopes that were affected (subset of `scope`). */\n changedScopes?: ImpactScope[];\n /** Table names that were written to, when `scope` includes `\"database\"`. */\n changedTables?: string[];\n /** Storage object IDs that were affected, when `scope` includes `\"storage\"`. */\n storageIds?: string[];\n}\n\n/**\n * A pub/sub channel for cross-instance change notifications.\n *\n * Provide an implementation to `SyncoreRuntimeOptions.externalChangeSignal`\n * when multiple Syncore runtimes share the same underlying database (e.g. an\n * Electron main process and renderer, or multiple browser tabs). The runtime\n * will publish events after its own commits and react to events published by\n * other instances.\n *\n * Platform adapters ship ready-made implementations:\n * - `BroadcastChannelExternalChangeSignal` (browser, shared workers)\n * - Node IPC signal (Electron main ↔ renderer)\n */\nexport interface SyncoreExternalChangeSignal {\n /**\n * Register a listener for incoming change events.\n * @returns A cleanup function that removes the listener when called.\n */\n subscribe(listener: (event: SyncoreExternalChangeEvent) => void): () => void;\n /** Publish an outgoing change event to other subscribers. */\n publish(event: SyncoreExternalChangeEvent): void | Promise<void>;\n /** Optional cleanup called when the runtime shuts down. */\n close?(): void | Promise<void>;\n}\n\n/**\n * Applies an incoming {@link SyncoreExternalChangeEvent} to a local SQL\n * driver, reconciling the local state with a remote source.\n *\n * Typically provided by the same adapter that supplies\n * {@link SyncoreExternalChangeSignal} (e.g. `SqlJsExternalChangeApplier` for\n * browser runtimes). Only necessary when the local driver needs to pull in\n * changes made to the database file on disk by another process.\n */\nexport interface SyncoreExternalChangeApplier {\n applyExternalChange(event: SyncoreExternalChangeEvent): Promise<{\n databaseChanged: boolean;\n storageChanged: boolean;\n changedScopes: ImpactScope[];\n }>;\n}\n\n/**\n * The payload used when writing a new object through Syncore storage APIs.\n *\n * Pass this to `ctx.storage.put()` inside a mutation or action to persist a\n * binary blob alongside your database documents.\n *\n * ```ts\n * const id = await ctx.storage.put({\n * data: new Uint8Array(imageBytes),\n * contentType: \"image/png\",\n * fileName: \"avatar.png\",\n * });\n * // Store `id` in the database to reference the object later.\n * ```\n */\nexport interface StorageWriteInput {\n /**\n * The raw data to store. Accepts `Uint8Array`, `ArrayBuffer`, or a UTF-8\n * string (the string is encoded to bytes automatically).\n */\n data: Uint8Array | ArrayBuffer | string;\n /**\n * MIME type hint stored alongside the object (e.g. `\"image/png\"`,\n * `\"application/pdf\"`). Not validated or enforced by Syncore; purely\n * informational for downstream consumers.\n */\n contentType?: string;\n /**\n * Optional human-readable filename hint. Stored as metadata and surfaced in\n * devtools but not used for addressing the object (the auto-generated `id` is\n * used for that).\n */\n fileName?: string;\n}\n\n/**\n * Metadata describing a stored object managed by the Syncore storage adapter.\n *\n * Returned by `ctx.storage.get()` and `SyncoreStorageAdapter.list()`. The\n * `id` field is the opaque string you store in the database to reference this\n * object; use it with `ctx.storage.read()` to fetch the bytes.\n */\nexport interface StorageObject {\n /** Opaque identifier. Store this in a database document to reference the object. */\n id: string;\n /** Absolute path or key used by the storage backend (filesystem path, OPFS key, etc.). */\n path: string;\n /** Size of the stored data in bytes. */\n size: number;\n /** MIME type provided at write time, or `null` if none was specified. */\n contentType: string | null;\n}\n\n/**\n * Low-level interface for persisting and retrieving binary blobs alongside the\n * Syncore database.\n *\n * The runtime ships concrete implementations for every supported environment\n * (`NodeFileStorageAdapter`, `BrowserFileStorageAdapter`,\n * `ExpoFileStorageAdapter`). Implement this interface only if you need a custom\n * storage backend (e.g. an in-memory store for tests or an S3-compatible\n * remote).\n */\nexport interface SyncoreStorageAdapter {\n /**\n * Write a blob and return its metadata.\n *\n * @param id - The opaque identifier Syncore assigns to this object. Use\n * the same value to retrieve or delete the object later.\n * @param input - The data and optional metadata to persist.\n */\n put(id: string, input: StorageWriteInput): Promise<StorageObject>;\n /**\n * Return the metadata for a stored object, or `null` if it does not exist.\n * Does **not** return the raw bytes — use {@link read} for that.\n */\n get(id: string): Promise<StorageObject | null>;\n /**\n * Return the raw bytes of a stored object, or `null` if it does not exist.\n */\n read(id: string): Promise<Uint8Array | null>;\n /**\n * Return a byte range for a stored object, or `null` if it does not exist.\n *\n * Adapters that can seek without loading the whole object should implement\n * this so devtools preview and download endpoints can stream large files.\n */\n readRange?(\n id: string,\n offset: number,\n length: number\n ): Promise<Uint8Array | null>;\n /**\n * Return `false` when `readRange` is intentionally unavailable for this\n * adapter instance.\n */\n supportsRange?(): boolean;\n /**\n * Permanently remove a stored object. A no-op if the object does not exist.\n */\n delete(id: string): Promise<void>;\n /**\n * Enumerate all stored objects. Used by devtools and migration tooling.\n * Optional — omit for backends that don’t support listing.\n */\n list?(): Promise<StorageObject[]>;\n}\n\n/**\n * Receives structured devtools events emitted by the runtime.\n *\n * In development the platform adapters automatically connect a WebSocket sink\n * that forwards events to the Syncore devtools dashboard. You can also supply\n * a custom sink for testing, logging, or building your own observability layer:\n *\n * ```ts\n * const sink: DevtoolsSink = {\n * emit(event) { console.log(\"[syncore]\", event.type); },\n * };\n * ```\n *\n * Pass `devtools: false` to the runtime options to disable devtools entirely\n * (recommended for production builds).\n */\nexport interface DevtoolsSink {\n /** Called synchronously every time the runtime emits a new event. */\n emit(event: SyncoreDevtoolsEvent): void;\n /**\n * Optional hook called once after the runtime is constructed so the sink can\n * hold a reference to it (e.g. to call `runtime.getAdmin()`).\n */\n attachRuntime?(runtime: SyncoreRuntime<SyncoreDataModel>): void;\n}\n\nexport interface DevtoolsLiveQuerySnapshot {\n summary: SyncoreRuntimeSummary;\n activeQueries: SyncoreActiveQueryInfo[];\n schemaTables: Array<{\n name: string;\n displayName?: string;\n owner: \"root\" | \"component\";\n componentPath?: string;\n componentName?: string;\n fields: Array<{\n name: string;\n type: string;\n optional: boolean;\n }>;\n indexes: Array<{\n name: string;\n fields: string[];\n unique: boolean;\n }>;\n documentCount: number;\n }>;\n}\n\nexport type DevtoolsLiveQueryScope =\n | \"all\"\n | \"runtime.summary\"\n | \"runtime.activeQueries\"\n | \"schema.tables\"\n | \"scheduler.jobs\"\n | \"storage.objects\"\n | `table:${string}`\n | `storage:${string}`;\n\n/**\n * Configuration for the Syncore built-in scheduler.\n *\n * Pass this to `SyncoreRuntimeOptions.scheduler` to enable background job\n * processing. The scheduler polls for pending one-off jobs (created via\n * `ctx.scheduler.runAfter` / `ctx.scheduler.runAt`) and for recurring jobs\n * defined with {@link CronJobs}.\n *\n * ```ts\n * import crons from \"./syncore/crons\";\n *\n * createNodeSyncoreRuntime({\n * ...,\n * scheduler: {\n * pollIntervalMs: 500,\n * recurringJobs: crons.jobs,\n * },\n * });\n * ```\n */\nexport interface SchedulerOptions {\n /**\n * How often the scheduler checks for jobs that are due, in milliseconds.\n * Defaults to `1000` (1 second). Lower values increase responsiveness at\n * the cost of more frequent SQLite reads.\n */\n pollIntervalMs?: number;\n /**\n * Static list of recurring job definitions to register when the runtime\n * starts. Build this with the {@link CronJobs} helper and a call to\n * {@link cronJobs}.\n */\n recurringJobs?: RecurringJobDefinition[];\n}\n\nexport type SyncoreResolvedComponents = readonly ResolvedSyncoreComponent[];\n\nexport interface UpdateScheduledJobOptions {\n id: string;\n schedule?: RecurringSchedule;\n args: JsonObject;\n misfirePolicy?: MisfirePolicy;\n runAt?: number;\n}\n\n/**\n * An open-ended bag of platform-specific capabilities exposed to Syncore\n * function handlers via `ctx.capabilities`.\n *\n * Use capabilities to inject platform services (push notifications, camera\n * access, native storage, etc.) that should be available inside your\n * functions without hard-coding platform imports:\n *\n * ```ts\n * // Runtime setup (platform-specific)\n * createExpoSyncoreRuntime({\n * ...,\n * capabilities: { pushNotifications: Notifications },\n * });\n *\n * // Inside a mutation\n * export const notify = mutation({\n * args: { message: s.string() },\n * handler: async (ctx, { message }) => {\n * await ctx.capabilities?.pushNotifications?.scheduleAsync({ body: message });\n * },\n * });\n * ```\n */\nexport interface SyncoreCapabilities {\n [name: string]: unknown;\n}\n\n/**\n * The typed data model that backs a Syncore runtime.\n *\n * `SyncoreDataModel` is the shape of the value returned by\n * {@link defineSchema}. It is the type parameter you see on\n * {@link SyncoreRuntime}, {@link QueryCtx}, {@link MutationCtx}, and the\n * generated server context types. Application code typically gets this from\n * the schema file rather than constructing it directly:\n *\n * ```ts\n * import schema from \"../syncore/schema\";\n * type MySchema = typeof schema;\n * ```\n */\nexport interface SyncoreDataModel<\n TTables extends SyncoreSchemaDefinition = SyncoreSchemaDefinition\n> {\n readonly tables: TTables;\n getTable(\n tableName: Extract<keyof TTables, string>\n ): TTables[Extract<keyof TTables, string>];\n tableNames(): Array<Extract<keyof TTables, string>>;\n}\n\n/**\n * Low-level options for constructing a {@link SyncoreRuntime} directly.\n *\n * Most applications should use a platform-specific factory function instead\n * (`createNodeSyncoreRuntime`, `createWebSyncoreRuntime`,\n * `createExpoSyncoreRuntime`, etc.), which fill in sensible defaults for the\n * driver, storage adapter, and devtools connection.\n *\n * Only reach for `SyncoreRuntimeOptions` when you need full control over the\n * underlying SQLite driver or storage backend.\n */\nexport interface SyncoreRuntimeOptions<TSchema extends SyncoreDataModel> {\n /** The data model that defines the available tables, indexes, and schemas. */\n schema: TSchema;\n /**\n * The registered functions Syncore can invoke. In practice this is always\n * the generated `functions` export from `syncore/_generated/functions.ts`.\n */\n functions: SyncoreFunctionRegistry;\n /**\n * Resolved Syncore component instances to mount alongside the root app\n * functions. Only required when your app installs Syncore components.\n */\n components?: SyncoreResolvedComponents;\n /**\n * The SQLite driver Syncore will use for all database operations.\n *\n * Use one of the platform-specific drivers shipped by Syncore\n * (`NodeSqliteDriver`, `SqlJsDriver`, `ExpoSqliteDriver`) or provide a\n * custom implementation of {@link SyncoreSqlDriver}.\n */\n driver: SyncoreSqlDriver;\n /**\n * The blob storage adapter used for `ctx.storage.put()` and related APIs.\n *\n * Use one of the platform-specific adapters\n * (`NodeFileStorageAdapter`, `BrowserFileStorageAdapter`,\n * `ExpoFileStorageAdapter`) or a custom implementation of\n * {@link SyncoreStorageAdapter}.\n */\n storage: SyncoreStorageAdapter;\n /**\n * A pub/sub channel that lets this runtime receive change notifications\n * published by other Syncore instances sharing the same data source.\n *\n * Required when running Syncore across multiple contexts that share a\n * database (e.g. Electron main + renderer, or multiple browser tabs).\n * Platform adapters provide ready-made implementations.\n */\n externalChangeSignal?: SyncoreExternalChangeSignal;\n /**\n * Applies incoming external change events to the local SQLite driver,\n * reconciling the local state with changes written by another process.\n *\n * Usually paired with `externalChangeSignal`. Only required for drivers\n * that hold an in-memory copy of the database (e.g. SQL.js in the browser).\n */\n externalChangeApplier?: SyncoreExternalChangeApplier;\n /**\n * Platform-specific capabilities injected into `ctx.capabilities` inside\n * every function handler. See {@link SyncoreCapabilities}.\n */\n capabilities?: SyncoreCapabilities;\n /**\n * Capabilities exposed to clients through `watchRuntimeStatus()`.\n *\n * Platform adapters fill this with feature availability that app UIs should\n * honor, such as whether `ctx.storage` is usable in the current environment.\n */\n runtimeCapabilities?: SyncoreRuntimeCapabilities;\n /** Structured capability descriptors validated at start-up. */\n capabilityDescriptors?: CapabilityDescriptor[];\n /**\n * Label reported to devtools to identify the runtime’s environment\n * (e.g. `\"node\"`, `\"browser\"`, `\"expo\"`, `\"electron-main\"`).\n */\n platform?: string;\n /**\n * Devtools event sink used during development.\n *\n * Pass `false` to disable devtools entirely (recommended for production).\n * Omit to use the platform adapter’s default auto-connect behaviour.\n */\n devtools?: DevtoolsSink;\n /** Scheduler configuration for background and recurring jobs. */\n scheduler?: SchedulerOptions;\n}\n\n/**\n * Arguments for a paginated Syncore query.\n *\n * Add `paginationOpts: s.object({ cursor: s.nullable(s.string()), numItems: s.number() })`\n * to your query’s `args` schema, then accept a `PaginationOptions` value in the\n * handler to enable cursor-based pagination:\n *\n * ```ts\n * export const listTasks = query({\n * args: {\n * paginationOpts: s.object({\n * cursor: s.nullable(s.string()),\n * numItems: s.number(),\n * }),\n * },\n * handler: async (ctx, { paginationOpts }) =>\n * ctx.db.query(\"tasks\").paginate(paginationOpts),\n * });\n * ```\n *\n * In React, use {@link usePaginatedQuery} which manages the cursor for you.\n */\nexport interface PaginationOptions {\n /**\n * The cursor returned by the previous page, or `null` / `undefined` for the\n * first page.\n */\n cursor?: string | null;\n /** Maximum number of items to return in this page. */\n numItems: number;\n}\n\n/**\n * The value returned by `ctx.db.query(…).paginate()`.\n *\n * Store the `cursor` field and pass it back in the next call to fetch the\n * following page. `isDone` is `true` when there are no more results.\n */\nexport interface PaginationResult<TItem> {\n /** The items in this page. May be fewer than `numItems` if `isDone` is `true`. */\n page: TItem[];\n /**\n * Opaque cursor to pass as `PaginationOptions.cursor` in the next call.\n * `null` when `isDone` is `true`.\n */\n cursor: string | null;\n /** `true` when this is the last page and no more results exist. */\n isDone: boolean;\n}\n\n/**\n * Coarse lifecycle phase of a Syncore runtime.\n *\n * - `\"starting\"` — The runtime is initialising (applying schema, loading driver).\n * - `\"ready\"` — The runtime is fully started and accepting function calls.\n * - `\"recovering\"` — A transient error occurred; the runtime is attempting recovery.\n * - `\"unavailable\"` — The runtime is unreachable (worker not started, IPC down, etc.).\n * - `\"error\"` — The runtime encountered an unrecoverable error.\n */\nexport type SyncoreRuntimeStatusKind =\n | \"starting\"\n | \"ready\"\n | \"recovering\"\n | \"unavailable\"\n | \"error\";\n\n/**\n * Explains why the runtime entered its current non-`\"ready\"` state.\n *\n * Useful for rendering descriptive loading or error messages in the UI.\n */\nexport type SyncoreRuntimeStatusReason =\n | \"booting\"\n | \"rehydrating\"\n | \"worker-restarting\"\n | \"worker-unavailable\"\n | \"ipc-unavailable\"\n | \"runtime-unavailable\"\n | \"disposed\";\n\n/** Runtime-visible storage capability for app UIs and adapters. */\nexport interface SyncoreRuntimeStorageCapability {\n /** Whether `ctx.storage` can read/write objects in this runtime. */\n available: boolean;\n /** Short reason to show when storage is unavailable. */\n reason?: string;\n /** Storage protocol used by the adapter, such as `\"file\"` or `\"opfs\"`. */\n protocol?: string;\n /** Whether the adapter can read byte ranges without loading the full object. */\n supportsRange?: boolean;\n}\n\n/** Runtime capabilities exposed through `watchRuntimeStatus()`. */\nexport interface SyncoreRuntimeCapabilities {\n storage: SyncoreRuntimeStorageCapability;\n}\n\n/**\n * Snapshot of the runtime’s current lifecycle state.\n *\n * Subscribe to changes with `client.watchRuntimeStatus()` or the\n * `useSyncoreStatus()` React hook to adapt the UI while the runtime is\n * starting up or recovering.\n *\n * ```ts\n * const status = useSyncoreStatus();\n * if (status.kind !== \"ready\") return <LoadingSpinner />;\n * ```\n */\nexport interface SyncoreRuntimeStatus {\n /** Coarse lifecycle phase. */\n kind: SyncoreRuntimeStatusKind;\n /** Machine-readable reason for a non-`\"ready\"` state. */\n reason?: SyncoreRuntimeStatusReason;\n /** The underlying error when `kind` is `\"error\"`. */\n error?: Error;\n /** Runtime capabilities that app UIs can use to enable or hide affordances. */\n capabilities?: SyncoreRuntimeCapabilities;\n}\n\n/**\n * Lifecycle status of an individual reactive query subscription.\n *\n * - `\"loading\"` — The query has never produced a result (first load).\n * - `\"success\"` — The query has data and no error.\n * - `\"error\"` — The last execution threw an error. `data` may still hold a\n * stale value from a prior successful run.\n * - `\"skipped\"` — The subscription was suppressed with the `skip` sentinel.\n */\nexport type SyncoreQueryStatus = \"loading\" | \"success\" | \"error\" | \"skipped\";\n\n/**\n * The full reactive state of a Syncore query subscription.\n *\n * Returned by {@link useQueryState} and Svelte’s `createQueryStore`. For most\n * components you only need the `data` field — use {@link useQuery} for that\n * simpler shape.\n */\nexport interface SyncoreQueryState<TData> {\n /** The most recent result from the query, or `undefined` while loading. */\n data: TData | undefined;\n /** The error thrown by the last execution, or `undefined` on success. */\n error: Error | undefined;\n /** Fine-grained subscription lifecycle status. */\n status: SyncoreQueryStatus;\n /** Current lifecycle status of the underlying runtime. */\n runtimeStatus: SyncoreRuntimeStatus;\n /** `true` while waiting for the first result. Equivalent to `status === \"loading\"`. */\n isLoading: boolean;\n /** `true` when the last execution threw an error. */\n isError: boolean;\n /** `true` when `data` is available and the runtime is ready. */\n isReady: boolean;\n}\n\nexport type SyncoreQueryRequest<\n TReference extends FunctionReference<\"query\"> = FunctionReference<\"query\">\n> = (Record<never, never> extends FunctionArgs<TReference>\n ? {\n query: TReference;\n args?: FunctionArgs<TReference>;\n }\n : {\n query: TReference;\n args: FunctionArgs<TReference>;\n }) & {\n skip?: boolean;\n};\n\nexport type SyncoreQueriesRequest = Record<string, SyncoreQueryRequest>;\n\n/**\n * Lifecycle status of a paginated Syncore query subscription.\n *\n * - `\"loading\"` — Waiting for the first page to arrive.\n * - `\"ready\"` — At least one page has loaded and more pages are available.\n * - `\"loadingMore\"` — A `loadMore()` call is in progress.\n * - `\"exhausted\"` — All pages have been loaded (`isDone` is `true` on the\n * last page). `loadMore()` is a no-op in this state.\n * - `\"error\"` — The last page load failed. `error` contains the thrown error.\n */\nexport type SyncorePaginatedQueryStatus =\n | \"loading\"\n | \"ready\"\n | \"loadingMore\"\n | \"exhausted\"\n | \"error\";\n\n/**\n * The result object returned by {@link usePaginatedQuery} and\n * `createPaginatedQueryStore`.\n *\n * Contains the accumulated items, pagination metadata, and a `loadMore`\n * callback for fetching the next page.\n */\nexport interface UsePaginatedQueryResult<TItem> {\n /** All items loaded so far, across all fetched pages. */\n results: TItem[];\n /** Raw page results in order, one entry per fetched page. */\n pages: PaginationResult<TItem>[];\n /** Current lifecycle phase of the paginated query. */\n status: SyncorePaginatedQueryStatus;\n /** The error thrown by the last failed page load, or `undefined`. */\n error: Error | undefined;\n /** `true` while waiting for the first page. */\n isLoading: boolean;\n /** `true` while a `loadMore()` request is in progress. */\n isLoadingMore: boolean;\n /** `true` when there is a next page available to load. */\n hasMore: boolean;\n /** Cursor to pass to the next page request. `null` when `isDone` is `true`. */\n cursor: string | null;\n /** Current lifecycle status of the underlying runtime. */\n runtimeStatus: SyncoreRuntimeStatus;\n /**\n * Fetch the next page of results.\n *\n * @param numItems - Number of items to request. Defaults to `initialNumItems`.\n * A no-op when `hasMore` is `false`, `isLoadingMore` is `true`, or an error\n * occurred.\n */\n loadMore(numItems?: number): Promise<void> | void;\n}\n\n/**\n * A live, cancellable subscription to a reactive Syncore value.\n *\n * The runtime keeps the watched value up-to-date by re-running the underlying\n * query whenever its data dependencies change. `onUpdate` is called each time a\n * fresh result is available so the subscriber can read the new value with\n * `localQueryResult()`.\n *\n * React’s `useQuery` and Svelte’s `createQueryStore` are built on top of this\n * interface — you only need `SyncoreWatch` directly when integrating with\n * frameworks outside the first-party adapters.\n *\n * ```ts\n * const watch = client.watchQuery(api.tasks.list);\n * const unsubscribe = watch.onUpdate(() => {\n * console.log(watch.localQueryResult());\n * });\n * // Later:\n * unsubscribe();\n * watch.dispose?.();\n * ```\n */\nexport interface SyncoreWatch<TValue> {\n /**\n * Register a callback to be called whenever the watched value changes.\n * @returns An `unsubscribe` function; call it to stop receiving updates.\n */\n onUpdate(callback: () => void): () => void;\n /** Return the latest available query result, or `undefined` if not yet loaded. */\n localQueryResult(): TValue | undefined;\n /** Return the error from the last failed execution, or `undefined` on success. */\n localQueryError(): Error | undefined;\n /**\n * Release all resources held by this watch handle.\n *\n * Call this when the subscriber is unmounted or the watch is no longer needed\n * to prevent memory leaks. Framework adapters call this automatically.\n */\n dispose?(): void;\n}\n\nexport interface FilterBuilder {\n eq(field: string, value: unknown): QueryExpression;\n gt(field: string, value: unknown): QueryExpression;\n gte(field: string, value: unknown): QueryExpression;\n lt(field: string, value: unknown): QueryExpression;\n lte(field: string, value: unknown): QueryExpression;\n and(...expressions: QueryExpression[]): QueryExpression;\n or(...expressions: QueryExpression[]): QueryExpression;\n}\n\nexport interface IndexRangeBuilder<TFieldName extends string = string> {\n eq(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n gt(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n gte(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n lt(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n lte(field: TFieldName, value: unknown): IndexRangeBuilder<TFieldName>;\n build(): QueryCondition[];\n}\n\nexport interface SearchIndexBuilder<\n TSearchField extends string = string,\n TFilterField extends string = string\n> {\n search(\n field: TSearchField,\n value: string\n ): SearchIndexBuilder<TSearchField, TFilterField>;\n eq(\n field: TFilterField,\n value: unknown\n ): SearchIndexBuilder<TSearchField, TFilterField>;\n build(): SearchQuery;\n}\n\nexport type TableNames<TSchema extends SyncoreDataModel> = Extract<\n keyof TSchema[\"tables\"],\n string\n>;\n\nexport type DocumentForTable<\n TSchema extends SyncoreDataModel,\n TTableName extends TableNames<TSchema>\n> = InferDocument<TSchema[\"tables\"][TTableName]>;\n\nexport type InsertValueForTable<\n TSchema extends SyncoreDataModel,\n TTableName extends TableNames<TSchema>\n> = InferTableInput<TSchema[\"tables\"][TTableName]>;\n\ntype OptionalPropertyNames<TValue> = TValue extends object\n ? {\n [TKey in keyof TValue]-?: Omit<TValue, TKey> extends TValue\n ? TKey\n : never;\n }[keyof TValue]\n : never;\n\ntype PatchValue<TValue> = TValue extends object\n ? {\n [TKey in keyof TValue]?: TKey extends OptionalPropertyNames<TValue>\n ? TValue[TKey] | undefined\n : TValue[TKey];\n }\n : never;\n\nexport type PatchValueForTable<\n TSchema extends SyncoreDataModel,\n TTableName extends TableNames<TSchema>\n> = PatchValue<InsertValueForTable<TSchema, TTableName>>;\n\ntype OptionalArgsTuple<TArgs> =\n Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];\n\n/**\n * Read-only database API available inside Syncore query (and mutation/action)\n * handlers via `ctx.db`.\n *\n * All methods are fully typed against your schema — the table names and\n * returned document shapes are inferred from the `TSchema` type parameter:\n *\n * ```ts\n * // Fetch by ID\n * const task = await ctx.db.get(\"tasks\", taskId);\n *\n * // Chainable query builder\n * const todos = await ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_status\", (q) => q.eq(\"status\", \"todo\"))\n * .order(\"asc\")\n * .take(20);\n *\n * // Raw SQL escape hatch (use sparingly — bypasses type safety)\n * const rows = await ctx.db.raw<{ count: number }>(\n * \"SELECT COUNT(*) AS count FROM tasks\"\n * );\n * ```\n */\nexport interface SyncoreDatabaseReader<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> {\n /**\n * Fetch a single document by its `_id`, or `null` if it does not exist.\n *\n * @param table - The table to look in.\n * @param id - The document’s `_id` string.\n */\n get<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string\n ): Promise<DocumentForTable<TSchema, TTableName> | null>;\n /**\n * Start a chainable {@link QueryBuilder} for the given table.\n *\n * Chain `.withIndex()` or `.withSearchIndex()` to use an index, `.filter()`\n * for additional predicates, `.order()` to control direction, and then a\n * terminal method (`.collect()`, `.first()`, `.take()`, `.paginate()`).\n */\n query<TTableName extends TableNames<TSchema>>(\n table: TTableName\n ): QueryBuilder<\n TSchema[\"tables\"][TTableName],\n DocumentForTable<TSchema, TTableName>\n >;\n /**\n * Execute a raw SQL `SELECT` statement and return the results.\n *\n * Prefer the typed query builder whenever possible. Use `raw` as an escape\n * hatch for complex aggregations or joins that the builder cannot express.\n */\n raw<TValue = unknown>(sql: string, params?: unknown[]): Promise<TValue[]>;\n}\n\n/**\n * Read-write database API available inside Syncore mutation handlers via\n * `ctx.db`. Extends {@link SyncoreDatabaseReader} with write methods that\n * execute atomically within the mutation’s transaction.\n *\n * ```ts\n * // Insert a new document and get its generated _id\n * const id = await ctx.db.insert(\"tasks\", { title: \"Buy milk\", status: \"todo\", projectId: null });\n *\n * // Merge a partial update (other fields are preserved)\n * await ctx.db.patch(\"tasks\", id, { status: \"done\" });\n *\n * // Replace the entire document (all fields must be provided)\n * await ctx.db.replace(\"tasks\", id, { title: \"Buy oat milk\", status: \"todo\", projectId: null });\n *\n * // Delete a document\n * await ctx.db.delete(\"tasks\", id);\n * ```\n */\nexport interface SyncoreDatabaseWriter<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> extends SyncoreDatabaseReader<TSchema> {\n /**\n * Insert a new document and return its generated `_id`.\n *\n * The value must satisfy the table’s validator schema. System fields\n * (`_id`, `_creationTime`) are set automatically.\n */\n insert<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n value: InsertValueForTable<TSchema, TTableName>\n ): Promise<string>;\n /**\n * Merge `value` into the existing document at `id`.\n *\n * Only the keys present in `value` are updated; all other fields retain their\n * current values. Equivalent to a SQL `UPDATE … SET …` for specific columns.\n */\n patch<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string,\n value: PatchValueForTable<TSchema, TTableName>\n ): Promise<void>;\n /**\n * Overwrite the entire document at `id` with `value`.\n *\n * The `_id` and `_creationTime` system fields are preserved; all other\n * fields are replaced. Use `patch` when you only want to change a subset of\n * fields.\n */\n replace<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string,\n value: InsertValueForTable<TSchema, TTableName>\n ): Promise<void>;\n /**\n * Permanently delete the document with the given `id`.\n *\n * A no-op if the document does not exist.\n */\n delete<TTableName extends TableNames<TSchema>>(\n table: TTableName,\n id: string\n ): Promise<void>;\n}\n\n/**\n * Blob storage operations exposed to Syncore function handlers via\n * `ctx.storage`.\n *\n * Store large binary objects (images, PDFs, audio files) separately from the\n * SQLite database. Each object gets an opaque `id` that you can persist in a\n * document field for later retrieval.\n *\n * ```ts\n * // In a mutation\n * const id = await ctx.storage.put({\n * data: imageBuffer,\n * contentType: \"image/png\",\n * });\n * await ctx.db.patch(\"users\", userId, { avatarId: id });\n *\n * // In a query\n * const bytes = await ctx.storage.read(user.avatarId);\n * ```\n */\nexport interface SyncoreStorageApi {\n /**\n * Persist a binary blob and return its auto-generated opaque `id`.\n *\n * Store the returned `id` in a database document to reference the object.\n */\n put(input: StorageWriteInput): Promise<string>;\n /**\n * Return metadata for the stored object, or `null` if it does not exist.\n * Does not fetch the raw bytes — use `read` for that.\n */\n get(id: string): Promise<StorageObject | null>;\n /**\n * Return the raw bytes of the stored object, or `null` if it does not exist.\n */\n read(id: string): Promise<Uint8Array | null>;\n /**\n * Permanently delete the stored object. A no-op if the object does not exist.\n */\n delete(id: string): Promise<void>;\n}\n\n/**\n * Job scheduling API available to mutation and action handlers via\n * `ctx.scheduler`.\n *\n * Use `runAfter` and `runAt` to enqueue a mutation or action that runs outside\n * the current transaction — ideal for sending notifications, retrying\n * failed operations, or breaking long workflows into steps.\n *\n * ```ts\n * // Run a cleanup job 24 hours from now\n * await ctx.scheduler.runAfter(\n * 24 * 60 * 60_000,\n * api.cleanup.deleteExpiredSessions,\n * );\n *\n * // Run at a specific timestamp\n * const tomorrow = Date.now() + 86_400_000;\n * const jobId = await ctx.scheduler.runAt(tomorrow, api.email.sendDigest, { userId });\n *\n * // Cancel if the user opts out before the job fires\n * await ctx.scheduler.cancel(jobId);\n * ```\n */\nexport interface SchedulerApi {\n /**\n * Enqueue a mutation or action to run after `delayMs` milliseconds.\n *\n * @param delayMs - Delay from now in milliseconds.\n * @param functionReference - The mutation or action to execute.\n * @param args - Arguments forwarded to the function.\n * @param misfirePolicy - Optional policy for missed executions.\n * @returns An opaque job `id` you can pass to `cancel`.\n */\n runAfter<TArgs, TResult>(\n delayMs: number,\n functionReference: FunctionReference<\"mutation\" | \"action\", TArgs, TResult>,\n ...args: [...OptionalArgsTuple<TArgs>, misfirePolicy?: MisfirePolicy]\n ): Promise<string>;\n /**\n * Enqueue a mutation or action to run at a specific Unix timestamp (or\n * `Date` object).\n *\n * @param timestamp - When to run the job (ms since epoch, or a Date).\n * @param functionReference - The mutation or action to execute.\n * @param args - Arguments forwarded to the function.\n * @param misfirePolicy - Optional policy for missed executions.\n * @returns An opaque job `id` you can pass to `cancel`.\n */\n runAt<TArgs, TResult>(\n timestamp: number | Date,\n functionReference: FunctionReference<\"mutation\" | \"action\", TArgs, TResult>,\n ...args: [...OptionalArgsTuple<TArgs>, misfirePolicy?: MisfirePolicy]\n ): Promise<string>;\n /**\n * Cancel a pending scheduled job by its `id`.\n *\n * A no-op if the job has already executed or was already cancelled.\n */\n cancel(id: string): Promise<void>;\n}\n\n/**\n * Execution context injected into every Syncore **query** handler.\n *\n * `ctx` is the first argument of every `query()` handler. It provides\n * read-only database access, storage access, platform capabilities, and the\n * ability to call other queries. The type is generic over the app schema so\n * that `ctx.db` is fully typed against your tables.\n *\n * The generated `QueryCtx` in `syncore/_generated/server.ts` is always\n * preferred over the base type because it is pre-bound to your app schema:\n *\n * ```ts\n * import type { QueryCtx } from \"../_generated/server\";\n *\n * export const list = query({\n * args: { projectId: s.optional(s.id(\"projects\")) },\n * handler: async (ctx: QueryCtx, { projectId }) => {\n * return ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_project\", (q) =>\n * projectId ? q.eq(\"projectId\", projectId) : q\n * )\n * .collect();\n * },\n * });\n * ```\n */\nexport interface QueryCtx<TSchema extends SyncoreDataModel = SyncoreDataModel> {\n /** Read-only access to the local SQLite database. */\n db: SyncoreDatabaseReader<TSchema>;\n /** Blob storage access for reading files and images. */\n storage: SyncoreStorageApi;\n /**\n * Platform capabilities injected at runtime setup (e.g. push notifications,\n * biometrics). `undefined` when no capabilities were configured.\n */\n capabilities?: Readonly<SyncoreCapabilities>;\n /** Structured descriptors for the registered capabilities. */\n capabilityDescriptors?: ReadonlyArray<CapabilityDescriptor>;\n /**\n * Metadata about the Syncore component this function belongs to, if it was\n * installed as part of a component package rather than the root app.\n */\n component?: {\n path: string;\n name: string;\n version: string;\n capabilities: readonly string[];\n };\n /**\n * Call another Syncore query inside this handler.\n *\n * The callee’s read-set is merged into the current query’s dependencies, so\n * any change that would invalidate the callee also invalidates this query.\n */\n runQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n}\n\n/**\n * Execution context injected into every Syncore **mutation** handler.\n *\n * Extends {@link QueryCtx} with a writable database (`ctx.db`), a scheduler,\n * and the ability to call mutations or actions. Everything runs inside a single\n * atomic SQLite transaction that is committed when the handler returns or\n * rolled back if it throws.\n *\n * Use the generated `MutationCtx` from `syncore/_generated/server.ts` so that\n * `ctx.db` is typed to your specific schema:\n *\n * ```ts\n * import type { MutationCtx } from \"../_generated/server\";\n *\n * export const create = mutation({\n * args: { title: s.string() },\n * handler: async (ctx: MutationCtx, { title }) => {\n * const id = await ctx.db.insert(\"tasks\", {\n * title,\n * status: \"todo\",\n * projectId: null,\n * });\n * // Schedule a follow-up action without blocking the transaction\n * await ctx.scheduler.runAfter(0, api.tasks.notifyCreated, { id });\n * return id;\n * },\n * });\n * ```\n */\nexport interface MutationCtx<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> extends QueryCtx<TSchema> {\n /** Read-write database access. Changes are committed atomically on handler return. */\n db: SyncoreDatabaseWriter<TSchema>;\n /** Schedule mutations and actions to run outside the current transaction. */\n scheduler: SchedulerApi;\n /**\n * Call another mutation inside this handler’s transaction.\n *\n * The callee shares the current transaction context, so its writes are part\n * of the same atomic commit.\n */\n runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Launch an action from within a mutation. The action runs asynchronously\n * in a separate context **after** the mutation commits.\n */\n runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n}\n\n/**\n * Execution context injected into every Syncore **action** handler.\n *\n * Extends {@link QueryCtx} with a scheduler and the ability to call mutations\n * and other actions. Unlike mutations, actions run **outside** of any\n * transaction, so they can perform long-running or async work (HTTP requests,\n * file I/O, etc.) and delegate writes to mutations.\n *\n * Use the generated `ActionCtx` from `syncore/_generated/server.ts` so the\n * types are bound to your app schema:\n *\n * ```ts\n * import type { ActionCtx } from \"../_generated/server\";\n *\n * export const importFromApi = action({\n * args: { projectId: s.id(\"projects\") },\n * handler: async (ctx: ActionCtx, { projectId }) => {\n * const data = await fetch(\"https://api.example.com/tasks\").then((r) => r.json());\n * for (const item of data) {\n * await ctx.runMutation(api.tasks.create, { title: item.title });\n * }\n * },\n * });\n * ```\n */\nexport interface ActionCtx<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> extends QueryCtx<TSchema> {\n /** Schedule mutations and actions to run at a later time. */\n scheduler: SchedulerApi;\n /**\n * Call a mutation from within this action.\n *\n * Because actions are non-transactional, each `runMutation` call creates its\n * own transaction. If the action fails partway through, earlier mutations are\n * **not** rolled back automatically — design accordingly.\n */\n runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /** Call another action from within this action. */\n runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n}\n\n/**\n * The client-facing API for calling Syncore functions and subscribing to\n * reactive query results.\n *\n * You obtain a `SyncoreClient` by calling `runtime.createClient()` or, for\n * worker-based browser setups, via the platform adapter’s\n * `createWebWorkerClient()` / `createManagedWebWorkerClient()` helpers.\n *\n * In React, the client is provided to the component tree via\n * {@link SyncoreProvider} and consumed through hooks (`useQuery`,\n * `useMutation`, etc.) — you rarely call these methods directly.\n *\n * ```ts\n * const client = runtime.createClient();\n *\n * // One-shot query\n * const tasks = await client.query(api.tasks.list);\n *\n * // One-shot mutation\n * await client.mutation(api.tasks.create, { title: \"Buy milk\" });\n *\n * // Reactive subscription\n * const watch = client.watchQuery(api.tasks.list);\n * watch.onUpdate(() => console.log(watch.localQueryResult()));\n * ```\n */\nexport interface SyncoreClient {\n /**\n * Execute a query and return its result.\n *\n * Unlike a reactive subscription, this is a one-shot call that does not\n * stay up to date. Use `watchQuery` or the `useQuery` hook for live data.\n */\n query<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Execute a mutation and return its result.\n *\n * The mutation runs atomically and all affected queries are automatically\n * re-executed after the commit.\n */\n mutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Execute an action and return its result.\n *\n * Actions are non-transactional and may take arbitrarily long to complete.\n */\n action<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): Promise<TResult>;\n /**\n * Subscribe to a reactive query and return a {@link SyncoreWatch} handle.\n *\n * The watch delivers a new result every time the underlying data changes.\n * Call `watch.onUpdate()` to listen and `watch.dispose()` when done.\n */\n watchQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n ...args: OptionalArgsTuple<TArgs>\n ): SyncoreWatch<TResult>;\n /**\n * Subscribe to the runtime’s lifecycle status.\n *\n * Useful for showing loading or error states in the UI while the runtime is\n * starting or recovering.\n */\n watchRuntimeStatus(): SyncoreWatch<SyncoreRuntimeStatus>;\n}\n\nexport interface SyncoreRuntimeAdmin<\n TSchema extends SyncoreDataModel = SyncoreDataModel\n> {\n prepareForDirectAccess(): Promise<void>;\n createClient(): SyncoreClient;\n runQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n args?: JsonObject,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n args?: JsonObject,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n args?: JsonObject,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n runDevtoolsMutation<TResult>(\n callback: (ctx: { db: SyncoreDatabaseWriter<TSchema> }) => Promise<TResult>,\n meta?: DevtoolsEventMeta\n ): Promise<TResult>;\n getRuntimeSummary(): SyncoreRuntimeSummary;\n getActiveQueryInfos(): SyncoreActiveQueryInfo[];\n getRuntimeId(): string;\n getDriverDatabasePath(): string | undefined;\n subscribeToDevtoolsEvents(\n listener: (event: SyncoreDevtoolsEvent) => void\n ): () => void;\n subscribeToDevtoolsInvalidations(\n listener: (scopes: Set<DevtoolsLiveQueryScope>) => void\n ): () => void;\n notifyDevtoolsScopes(scopes: Iterable<DevtoolsLiveQueryScope>): void;\n forceRefreshDevtools(\n reason: string,\n scopes?: Iterable<ImpactScope>,\n meta?: DevtoolsEventMeta\n ): Promise<void>;\n listStorageObjects(options?: {\n limit?: number;\n offset?: number;\n search?: string;\n }): Promise<{ entries: StorageEntry[]; totalCount: number }>;\n getStorageObjectAccessInfo(id: string): Promise<{\n entry: StorageEntry;\n supportsRange: boolean;\n } | null>;\n readStorageObjectRange(\n id: string,\n offset: number,\n length: number\n ): Promise<{\n entry: StorageEntry;\n bytes: Uint8Array;\n offset: number;\n bytesRead: number;\n done: boolean;\n supportsRange: boolean;\n } | null>;\n deleteStorageObject(id: string, meta?: DevtoolsEventMeta): Promise<boolean>;\n cancelScheduledJob(id: string): Promise<boolean>;\n updateScheduledJob(options: UpdateScheduledJobOptions): Promise<boolean>;\n}\n\ntype DevtoolsEventMeta = {\n origin?: SyncoreDevtoolsEventOrigin;\n executionId?: string;\n parentExecutionId?: string;\n schedulerJobId?: string;\n schedulerRun?: boolean;\n};\n\n/**\n * Chainable query builder returned by `ctx.db.query(tableName)`.\n *\n * Chain methods in this order to build up a query:\n *\n * 1. **Optional** — `.withIndex()` or `.withSearchIndex()` to use an index.\n * 2. **Optional** — `.filter()` to add arbitrary field predicates.\n * 3. **Optional** — `.order()` to control sort direction (defaults to `\"asc\"`).\n * 4. **Required terminal** — `.collect()`, `.take()`, `.first()`, `.unique()`,\n * or `.paginate()`.\n *\n * ```ts\n * // Fetch all tasks in a project, newest first, limited to 10\n * const tasks = await ctx.db\n * .query(\"tasks\")\n * .withIndex(\"by_project\", (q) => q.eq(\"projectId\", id))\n * .order(\"desc\")\n * .take(10);\n *\n * // Full-text search with a filter\n * const results = await ctx.db\n * .query(\"tasks\")\n * .withSearchIndex(\"search_title\", (q) =>\n * q.search(\"title\", searchText).eq(\"status\", \"todo\")\n * )\n * .collect();\n * ```\n */\nexport interface QueryBuilder<\n TTable extends AnyTableDefinition,\n TDocument = InferDocument<TTable>\n> {\n /**\n * Restrict the query to documents matching an index range.\n *\n * @param indexName - The name of the index to use (must be registered via `defineTable().index()`).\n * @param builder - Optional callback that receives an `IndexRangeBuilder` and returns it\n * after chaining `eq`, `gt`, `gte`, `lt`, `lte` calls. Omit to return all documents in\n * index order.\n */\n withIndex<TIndexName extends TableIndexNames<TTable>>(\n indexName: TIndexName,\n builder?: (\n range: IndexRangeBuilder<TableIndexFields<TTable, TIndexName>[number]>\n ) => IndexRangeBuilder<TableIndexFields<TTable, TIndexName>[number]>\n ): this;\n /**\n * Restrict the query to documents matching a full-text search index.\n *\n * @param indexName - The name of the search index (must be registered via `defineTable().searchIndex()`).\n * @param builder - Callback that calls `.search(field, text)` and optionally chains\n * `.eq(filterField, value)` conditions.\n */\n withSearchIndex<TIndexName extends TableSearchIndexNames<TTable>>(\n indexName: TIndexName,\n builder: (\n search: SearchIndexBuilder<\n TableSearchIndexConfig<TTable, TIndexName>[\"searchField\"],\n TableSearchIndexConfig<TTable, TIndexName>[\"filterFields\"]\n >\n ) => SearchIndexBuilder<\n TableSearchIndexConfig<TTable, TIndexName>[\"searchField\"],\n TableSearchIndexConfig<TTable, TIndexName>[\"filterFields\"]\n >\n ): this;\n /**\n * Set the iteration order for this query. Defaults to `\"asc\"`.\n *\n * When used with `withIndex`, the order applies to the index's primary sort key.\n * When used without an index (full table scan), `\"asc\"` and `\"desc\"` refer to\n * insertion order.\n */\n order(order: \"asc\" | \"desc\"): this;\n /**\n * Add an additional in-memory predicate that is applied after index\n * evaluation.\n *\n * Use this for conditions that cannot be expressed as an index range (e.g.\n * checking a field not covered by the active index). Heavy use of `filter`\n * on large tables causes a full index scan — prefer dedicated indexes for\n * frequently filtered fields.\n */\n filter(builder: (filter: FilterBuilder) => QueryExpression): this;\n /** Execute the query and return all matching documents as an array. */\n collect(): Promise<TDocument[]>;\n /**\n * Execute the query and return at most `count` documents.\n *\n * More efficient than `collect()` when you only need a limited number of\n * results.\n */\n take(count: number): Promise<TDocument[]>;\n /**\n * Execute the query and return the first matching document, or `null` if\n * there are no results.\n */\n first(): Promise<TDocument | null>;\n /**\n * Execute the query and return the single matching document, or `null` if\n * there are no results. Throws if more than one document matches.\n *\n * Use when you expect exactly zero or one result (e.g. a unique index\n * lookup).\n */\n unique(): Promise<TDocument | null>;\n /**\n * Execute the query with cursor-based pagination.\n *\n * Pass `PaginationOptions` (a `cursor` and `numItems`) to fetch one page at\n * a time. The returned `PaginationResult` contains the page items, the next\n * cursor, and an `isDone` flag.\n */\n paginate(options: PaginationOptions): Promise<PaginationResult<TDocument>>;\n}\n\n/**\n * Local-first Syncore runtime that hosts your schema, functions, and storage.\n *\n * `SyncoreRuntime` is the central engine of every Syncore app. It owns the\n * SQLite driver, the storage adapter, the reactivity engine, and the\n * background scheduler. Platform-specific factory functions\n * (`createNodeSyncoreRuntime`, `createWebSyncoreRuntime`, etc.) wrap it with\n * environment-appropriate defaults so you rarely need to instantiate it\n * directly.\n *\n * **Lifecycle**\n * 1. Construct the runtime (schema migration is deferred until first use).\n * 2. Call `await runtime.start()` to apply the schema, start the scheduler,\n * and connect to devtools. The runtime emits `\"runtime.connected\"` when ready.\n * 3. Call `runtime.createClient()` to get a {@link SyncoreClient} for\n * invoking functions and subscribing to reactive queries.\n * 4. Call `await runtime.stop()` on shutdown to flush pending jobs and close\n * the database.\n *\n * ```ts\n * const runtime = new SyncoreRuntime({\n * schema,\n * functions,\n * driver: new NodeSqliteDriver(\"./db.sqlite\"),\n * storage: new NodeFileStorageAdapter(\"./storage\"),\n * });\n * await runtime.start();\n * const client = runtime.createClient();\n * ```\n */\nexport class SyncoreRuntime<TSchema extends SyncoreDataModel> {\n private readonly kernel: RuntimeKernel<TSchema>;\n\n constructor(private readonly options: SyncoreRuntimeOptions<TSchema>) {\n this.kernel = new RuntimeKernel(options, this);\n }\n\n /**\n * Start the runtime: apply the schema migration, initialise the scheduler,\n * and connect to devtools (if configured).\n *\n * Must be called and awaited before using the client. Calling `start()`\n * a second time is a no-op.\n */\n async start(): Promise<void> {\n await this.kernel.start();\n }\n\n /**\n * Prepare the runtime for direct (synchronous) access patterns used by\n * devtools and migration tooling.\n *\n * You do not need to call this in normal application code.\n */\n async prepareForDirectAccess(): Promise<void> {\n await this.kernel.prepareForDirectAccess();\n }\n\n /**\n * Stop the runtime gracefully.\n *\n * Flushes any pending scheduler jobs, closes the SQLite driver, and\n * disconnects from devtools. Call this when your application is shutting\n * down to avoid database file corruption.\n */\n async stop(): Promise<void> {\n await this.kernel.stop();\n }\n\n /**\n * Create a new {@link SyncoreClient} bound to this runtime.\n *\n * Multiple clients can be created from the same runtime — they all share\n * the same underlying database and reactivity engine. Usually you only need\n * one client per runtime instance.\n */\n createClient(): SyncoreClient {\n return this.kernel.createClient();\n }\n\n /**\n * Return the low-level admin API.\n *\n * The admin API exposes devtools introspection, direct query/mutation\n * execution, and scheduler management. It is used by the devtools\n * dashboard and integration tooling — most application code should use\n * the regular `SyncoreClient` instead.\n */\n getAdmin(): SyncoreRuntimeAdmin<TSchema> {\n return this.kernel.admin;\n }\n\n async runQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n args: JsonObject = {},\n meta: DevtoolsEventMeta = {}\n ): Promise<TResult> {\n return this.kernel.executionEngine.runQuery(reference, args, meta);\n }\n\n async runMutation<TArgs, TResult>(\n reference: FunctionReference<\"mutation\", TArgs, TResult>,\n args: JsonObject = {},\n meta: DevtoolsEventMeta = {}\n ): Promise<TResult> {\n return this.kernel.executionEngine.runMutation(reference, args, meta);\n }\n\n async runAction<TArgs, TResult>(\n reference: FunctionReference<\"action\", TArgs, TResult>,\n args: JsonObject = {},\n meta: DevtoolsEventMeta = {}\n ): Promise<TResult> {\n return this.kernel.executionEngine.runAction(reference, args, meta);\n }\n\n watchQuery<TArgs, TResult>(\n reference: FunctionReference<\"query\", TArgs, TResult>,\n args: JsonObject = {}\n ): SyncoreWatch<TResult> {\n return this.kernel.watchQuery(reference, args);\n }\n}\n\nexport function createFunctionReference<\n TKind extends SyncoreFunctionKind,\n TArgs = Record<never, never>,\n TResult = unknown\n>(kind: TKind, name: string): FunctionReference<TKind, TArgs, TResult> {\n return { kind, name };\n}\n\n/**\n * Create a function reference from an existing Syncore function definition\n * while preserving its inferred args and result types.\n */\nexport function createFunctionReferenceFor<\n TDefinition extends {\n kind: SyncoreFunctionKind;\n argsValidator: Validator<unknown, unknown, string>;\n returnsValidator?: Validator<unknown, unknown, string>;\n }\n>(\n kind: FunctionKindFromDefinition<TDefinition>,\n name: string\n): FunctionReference<\n FunctionKindFromDefinition<TDefinition>,\n FunctionArgsFromDefinition<TDefinition>,\n FunctionResultFromDefinition<TDefinition>\n> {\n return { kind, name };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmrDA,IAAa,iBAAb,MAA8D;CAG/B;CAF7B;CAEA,YAAY,SAA0D;EAAzC,KAAA,UAAA;EAC3B,KAAK,SAAS,IAAI,cAAc,SAAS,IAAI;CAC/C;;;;;;;;CASA,MAAM,QAAuB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("type" in message)) return;
|
|
17
17
|
switch (message.type) {
|
|
18
|
-
case "runtime.ready":
|
|
19
|
-
this.runtimeStatus.
|
|
18
|
+
case "runtime.ready": {
|
|
19
|
+
const currentStatus = this.runtimeStatus.getStatus();
|
|
20
|
+
this.runtimeStatus.setStatus({
|
|
21
|
+
kind: "ready",
|
|
22
|
+
...currentStatus.capabilities ? { capabilities: currentStatus.capabilities } : {}
|
|
23
|
+
});
|
|
20
24
|
return;
|
|
21
|
-
|
|
25
|
+
}
|
|
26
|
+
case "runtime.error": {
|
|
27
|
+
const statusBeforeError = this.runtimeStatus.getStatus();
|
|
22
28
|
this.runtimeStatus.setStatus({
|
|
23
29
|
kind: "error",
|
|
24
30
|
reason: "runtime-unavailable",
|
|
31
|
+
...statusBeforeError.capabilities ? { capabilities: statusBeforeError.capabilities } : {},
|
|
25
32
|
error: new Error(message.error)
|
|
26
33
|
});
|
|
27
34
|
for (const watchRecord of this.watchRecordsByKey.values()) for (const listener of watchRecord.listeners) listener();
|
|
28
35
|
this.rejectAllPending(new Error(message.error));
|
|
29
36
|
return;
|
|
37
|
+
}
|
|
30
38
|
case "runtime.status":
|
|
31
39
|
this.runtimeStatus.setStatus(message.status);
|
|
32
40
|
for (const watchRecord of this.watchRecordsByKey.values()) for (const listener of watchRecord.listeners) listener();
|
|
@@ -259,6 +267,8 @@ function attachRuntimeBridge(options) {
|
|
|
259
267
|
kind: "starting",
|
|
260
268
|
reason: "booting"
|
|
261
269
|
};
|
|
270
|
+
let runtimeStatusWatch;
|
|
271
|
+
let detachRuntimeStatus;
|
|
262
272
|
const sendStatus = (status) => {
|
|
263
273
|
latestStatus = status;
|
|
264
274
|
options.endpoint.postMessage({
|
|
@@ -270,9 +280,22 @@ function attachRuntimeBridge(options) {
|
|
|
270
280
|
await runtime.start();
|
|
271
281
|
return runtime;
|
|
272
282
|
});
|
|
273
|
-
const clientPromise = runtimePromise.then((runtime) =>
|
|
283
|
+
const clientPromise = runtimePromise.then((runtime) => {
|
|
284
|
+
const client = runtime.createClient();
|
|
285
|
+
runtimeStatusWatch = client.watchRuntimeStatus();
|
|
286
|
+
const forwardRuntimeStatus = () => {
|
|
287
|
+
const status = runtimeStatusWatch?.localQueryResult();
|
|
288
|
+
if (status) sendStatus(status);
|
|
289
|
+
};
|
|
290
|
+
forwardRuntimeStatus();
|
|
291
|
+
detachRuntimeStatus = runtimeStatusWatch.onUpdate(forwardRuntimeStatus);
|
|
292
|
+
return client;
|
|
293
|
+
});
|
|
274
294
|
const ready = clientPromise.then(() => {
|
|
275
|
-
|
|
295
|
+
if (latestStatus.kind !== "ready") sendStatus({
|
|
296
|
+
kind: "ready",
|
|
297
|
+
...latestStatus.capabilities ? { capabilities: latestStatus.capabilities } : {}
|
|
298
|
+
});
|
|
276
299
|
options.endpoint.postMessage({ type: "runtime.ready" });
|
|
277
300
|
}).catch((error) => {
|
|
278
301
|
sendStatus({
|
|
@@ -379,6 +402,8 @@ function attachRuntimeBridge(options) {
|
|
|
379
402
|
subscription.watch.dispose?.();
|
|
380
403
|
}
|
|
381
404
|
subscriptions.clear();
|
|
405
|
+
detachRuntimeStatus?.();
|
|
406
|
+
runtimeStatusWatch?.dispose?.();
|
|
382
407
|
await (await runtimePromise).stop();
|
|
383
408
|
}
|
|
384
409
|
};
|