client

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package client provides a pure DSN (connection-string) parser for fabriq remote clients. It has no dependency on the rest of the fabriq module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  int
	Code    string
	Message string
	Body    string
}

APIError represents a non-2xx response from the fabriq admin API. Status is always authoritative (the real HTTP status code); Code and Message are a best-effort parse of the response body, which the adminapi emits in several different shapes depending on which layer produced the error.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

type AddEntityFieldsInput

type AddEntityFieldsInput struct {
	Columns []SchemaColumnInput `json:"columns"`
	Indexes []SchemaIndexInput  `json:"indexes,omitempty"`
}

AddEntityFieldsInput is the request body for AddEntityFields. It mirrors adminapi's addFieldsRequest JSON exactly: {columns, indexes}.

type CacheInfo

type CacheInfo struct {
	// Configured reports whether an engine cache is wired (Redis present).
	Configured bool            `json:"configured"`
	Keyspaces  []CacheKeyspace `json:"keyspaces"`
}

CacheInfo is the payload for GetCache. It mirrors adminapi's cacheResponse JSON exactly: {configured, keyspaces}.

type CacheInvalidateResult

type CacheInvalidateResult struct {
	Invalidated bool `json:"invalidated"`
}

CacheInvalidateResult is the payload for CacheInvalidate. It mirrors adminapi's response JSON exactly: {invalidated}.

type CacheKeyspace

type CacheKeyspace struct {
	Entity string `json:"entity"`
	Name   string `json:"name"`
	// Partition is "tenant" or "tenant+scope".
	Partition string `json:"partition"`
	// Mode is the invalidation mode, e.g. "versioned".
	Mode       string `json:"mode"`
	TTLSeconds int64  `json:"ttlSeconds"`
	Scoped     bool   `json:"scoped"`
}

CacheKeyspace describes one entity's read-through cache keyspace, derived from its declarative CacheSpec. It mirrors adminapi's cacheKeyspaceItem JSON exactly: {entity, name, partition, mode, ttlSeconds, scoped}.

type CacheStats

type CacheStats struct {
	// Available is false when a cache is configured but exposes no counters.
	Available     bool  `json:"available"`
	Hits          int64 `json:"hits"`
	Misses        int64 `json:"misses"`
	Sets          int64 `json:"sets"`
	Invalidations int64 `json:"invalidations"`
	// HitRate is Hits/(Hits+Misses), 0 when there have been no lookups.
	HitRate float64 `json:"hitRate"`
}

CacheStats is the payload for GetCacheStats. It mirrors adminapi's cacheStatsResponse JSON exactly: {available, hits, misses, sets, invalidations, hitRate}.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a remote fabriq client bound to a single tenant/key over a transport (currently HTTP only).

func Connect

func Connect(ctx context.Context, dsn string, opts ...Option) (*Client, error)

Connect parses dsn and returns a ready-to-use Client over the HTTP transport (fabriq://) against the adminapi. The fabriq+grpc:// data-plane transport is dialed by remotegrpc.Dial in the remote/grpc module — which returns a query.Fabric, not this admin SDK — so that google.golang.org/grpc stays out of the core module; Connect rejects it with a pointer there.

func (*Client) AddEntityFields

func (c *Client) AddEntityFields(ctx context.Context, entityType string, input AddEntityFieldsInput) (EntitySchema, error)

AddEntityFields adds columns (and optional indexes) to an existing dynamic entity type. It calls POST {BasePath}/schema/:type/fields with body {columns, indexes}. Returns an *APIError with Status 404 when the type is unknown.

func (*Client) CacheInvalidate

func (c *Client) CacheInvalidate(ctx context.Context, entity string) (CacheInvalidateResult, error)

CacheInvalidate bumps an entity's cache generation, orphaning every cached read of it for the tenant (and scope) in one O(1) operation. It calls POST {BasePath}/cache/invalidate with body {entity}. Returns an *APIError with Status 501 when no cache is configured, or Status 400 when the entity is unknown or not cached.

func (*Client) CreateEntity

func (c *Client) CreateEntity(ctx context.Context, input EntityWriteInput) (EntityRecord, error)

CreateEntity creates a new entity row. It calls POST {BasePath}/entities with body {type, data}; the id is generated server-side.

func (*Client) CreateEntityType

func (c *Client) CreateEntityType(ctx context.Context, input CreateEntityTypeInput) (EntitySchema, error)

CreateEntityType defines a new dynamic entity type and creates its backing table. It calls POST {BasePath}/schema with body {type, columns, indexes}. Returns an *APIError with Status 400 on an invalid column kind or default expression, Status 409 when the type is already registered, or Status 501 when no relational store is configured.

func (*Client) CreateFolder

func (c *Client) CreateFolder(ctx context.Context, input CreateFolderInput) (FileNode, error)

CreateFolder creates a folder. It calls POST {BasePath}/files/folder with body {parentId, name}.

func (*Client) DeleteEntity

func (c *Client) DeleteEntity(ctx context.Context, id, entityType string) error

DeleteEntity deletes an entity row by id. It calls DELETE {BasePath}/entities/:id?type=<type>. Type is required by the backend.

func (*Client) DeleteEntityType

func (c *Client) DeleteEntityType(ctx context.Context, entityType string) error

DeleteEntityType drops a dynamic entity type entirely, including its backing table. It calls DELETE {BasePath}/schema/:type?confirm=<type> (the confirm query param guards accidental drops and is set automatically).

func (*Client) DeleteFile

func (c *Client) DeleteFile(ctx context.Context, id string) error

DeleteFile trashes (soft-deletes) a file or folder node and its subtree. It calls DELETE {BasePath}/files/:id.

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, id string) (io.ReadCloser, string, error)

DownloadFile downloads a file's raw bytes. It calls GET {BasePath}/files/:id/content, which - unlike every other endpoint in this client - returns the raw file body (not JSON), with the filename carried in the Content-Disposition response header. Callers MUST close the returned ReadCloser.

On a non-2xx response, the body is read and closed and a *APIError is returned instead (mirroring c.do's error handling, since this method bypasses c.do entirely to avoid its JSON decoding).

func (*Client) DropEntityField

func (c *Client) DropEntityField(ctx context.Context, entityType, column string) error

DropEntityField drops a column from a dynamic entity type. It calls DELETE {BasePath}/schema/:type/fields/:column?confirm=<column> (the confirm query param guards accidental drops and is set automatically).

func (*Client) ExecBatch

func (c *Client) ExecBatch(ctx context.Context, commands []CommandInput) ([]CommandResult, error)

ExecBatch runs N commands, ordered and all-or-nothing, in one transaction. It calls POST {BasePath}/commands/batch with body {commands}. Any command's failure rolls the whole batch back and is reported as that command's error (Status 400/404/409/500 via *APIError).

func (*Client) ExecCommand

func (c *Client) ExecCommand(ctx context.Context, cmd CommandInput) (CommandResult, error)

ExecCommand runs one command through the write plane. It calls POST {BasePath}/commands. Returns an *APIError with Status 400 on a malformed command, Status 404 on a missing aggregate (update/delete), or Status 409 on a version conflict.

func (*Client) GetCache

func (c *Client) GetCache(ctx context.Context) (CacheInfo, error)

GetCache reports whether an engine cache is wired and which registered entities opt into the read-through row cache. It calls GET {BasePath}/cache.

func (*Client) GetCacheStats

func (c *Client) GetCacheStats(ctx context.Context) (CacheStats, error)

GetCacheStats reports cache activity counters and the derived hit-rate. It calls GET {BasePath}/cache/stats. Returns an *APIError with Status 501 when no cache is configured.

func (*Client) GetCrdtDocument

func (c *Client) GetCrdtDocument(ctx context.Context, docID string) (CrdtDocument, error)

GetCrdtDocument fetches the merged (current) state of a collaborative document. docID is "<entity>/<id>"; each "/"-separated segment is percent-escaped individually so a slash inside a segment does not collide with the entity/id separator, then the segments are re-joined with "/" - mirroring the fabriq-admin TS client's encodeDocId so the server's two-path-param route (:entity/:id) sees the same segments either way. It calls GET {BasePath}/crdt/<entity>/<id>.

func (*Client) GetCrdtUpdates

func (c *Client) GetCrdtUpdates(ctx context.Context, params GetCrdtUpdatesParams) (CrdtUpdatePage, error)

GetCrdtUpdates fetches metadata for a document's update log (size + a base64 preview per update; never the full payloads). It calls GET {BasePath}/crdt/<entity>/<id>/updates[?limit=<n>].

func (*Client) GetDigestMap

func (c *Client) GetDigestMap(ctx context.Context) (DigestMap, error)

GetDigestMap fetches the full, deterministically-sorted outline of the tenant's context-distillation Merkle tree. It calls GET {BasePath}/distill/map. When the distillation plane is not configured (digest_node not registered) the server returns 200 with an empty node list rather than an error.

func (*Client) GetDigestNode

func (c *Client) GetDigestNode(ctx context.Context, id string) (DigestView, error)

GetDigestNode drills into one digest node: its own outline line, its summary text (from CAS; empty when no CAS is configured), and its immediate children with their hashes and summaries. It calls GET {BasePath}/distill/node/:id. Returns an *APIError with Status 501 when the distillation plane is not configured, or Status 404 when the id names no node in the tenant's tree.

id is colon-delimited (e.g. "digest:2:tenant"); each ":"-separated segment is percent-escaped individually so a value inside a segment cannot collide with the delimiter, then the segments are re-joined with ":" — mirroring the fabriq-admin TS client's distillNode encoding.

func (*Client) GetEntity

func (c *Client) GetEntity(ctx context.Context, id, entityType string) (EntityRecord, error)

GetEntity fetches a single entity row by id. It calls GET {BasePath}/entities/:id?type=<type>. Type is required by the backend.

func (*Client) GetEntitySchema

func (c *Client) GetEntitySchema(ctx context.Context, entityType string) (EntitySchema, error)

GetEntitySchema fetches a dynamic entity type's field descriptors. It calls GET {BasePath}/schema?type=<entityType>. Returns an *APIError with Status 400 when the type is unknown or not dynamic.

func (*Client) GetEventFacets

func (c *Client) GetEventFacets(ctx context.Context) (EventFacets, error)

GetEventFacets lists the distinct aggregate types and event types present in the active tenant's outbox, for populating the events filter comboboxes. It calls GET {BasePath}/events/facets.

func (*Client) GetEventsBacklog

func (c *Client) GetEventsBacklog(ctx context.Context) (EventsBacklog, error)

GetEventsBacklog reports the unpublished outbox depth for the active tenant (the relay backlog). It calls GET {BasePath}/events/backlog.

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, id string) (FileNode, error)

GetFile fetches a single file/folder node's metadata by id. It calls GET {BasePath}/files/:id.

func (*Client) GetInstanceCapabilities

func (c *Client) GetInstanceCapabilities(ctx context.Context) (InstanceCapabilities, error)

GetInstanceCapabilities reports which fabric subsystems this fabriq instance has configured (relational, graph, vector, spatial, search, crdt, files, distill, timeseries). It calls GET {BasePath}/capabilities (no ?type=).

func (*Client) GetMeta

func (c *Client) GetMeta(ctx context.Context) (Meta, error)

GetMeta fetches the admin API's metadata: its name, version, the static capability-string list, and the resolved tenant (when present). It calls GET {BasePath}/meta.

func (*Client) GetMigrationJob

func (c *Client) GetMigrationJob(ctx context.Context, id string) (MigrationJob, error)

GetMigrationJob polls one migration job's state. It calls GET {BasePath}/migrations/jobs/:id. Returns an *APIError with Status 404 when no such job exists.

func (*Client) GetMigrationStatus

func (c *Client) GetMigrationStatus(ctx context.Context) (MigrationStatus, error)

GetMigrationStatus lists applied and pending migrations, grouped. It calls GET {BasePath}/migrations. This is always available (no schema-admin gate) — it only reports state, it never executes migrations. Returns an *APIError with Status 501 when no migration target is configured.

func (*Client) GetProjections

func (c *Client) GetProjections(ctx context.Context) (ProjectionsInfo, error)

GetProjections reports the graph/search projection bookkeeping for the active tenant plus the outbox backlog (a lag proxy). It calls GET {BasePath}/projections. Returns an *APIError with Status 501 when the instance has no Postgres-backed projection bookkeeping.

func (*Client) GetSchemaDrift

func (c *Client) GetSchemaDrift(ctx context.Context) (SchemaDrift, error)

GetSchemaDrift reports, per registered entity, the registry-vs-physical schema drift: columns the registry expects that are missing physically, and physical columns not in the registry. It calls GET {BasePath}/schema/drift. Returns an *APIError with Status 501 when no relational store is configured.

func (*Client) GetTypeCapabilities

func (c *Client) GetTypeCapabilities(ctx context.Context, entityType string) (TypeCapabilitiesResult, error)

GetTypeCapabilities reports which subsystems a single dynamic entity type participates in, read from its declarative registry EntitySpec. It calls GET {BasePath}/capabilities?type=<entityType>. Returns an *APIError with Status 400 when the type is unknown.

func (*Client) GetWritePolicy

func (c *Client) GetWritePolicy(ctx context.Context) (WritePolicy, error)

GetWritePolicy reports the configured agent write allowlist. It calls GET {BasePath}/agent/write-policy.

func (*Client) GraphNeighbors

func (c *Client) GraphNeighbors(ctx context.Context, params GraphNeighborsParams) (GraphData, error)

GraphNeighbors fetches the 1-hop neighbours of a graph node. It calls GET {BasePath}/graph/neighbors?type=<type>&id=<id>[&limit=<n>]. Returns *APIError with Status 501 when the instance has no graph backend configured.

func (*Client) GraphQuery

func (c *Client) GraphQuery(ctx context.Context, input GraphQueryInput) (GraphQueryResult, error)

GraphQuery runs a read-only openCypher query. It calls POST {BasePath}/graph/query with body {cypher, params}. A mutating statement (CREATE/MERGE/DELETE/SET/REMOVE/DROP) is rejected server-side with a 400 *APIError; an unconfigured graph backend yields a 501 *APIError.

func (*Client) GraphTraverse

func (c *Client) GraphTraverse(ctx context.Context, input GraphTraverseInput) (GraphData, error)

GraphTraverse runs a breadth-bounded traversal from a node. It calls POST {BasePath}/graph/traverse with body {type, id, depth, limit}. Returns *APIError with Status 501 when the instance has no graph backend configured.

func (*Client) ListEntities

func (c *Client) ListEntities(ctx context.Context, params ListEntitiesParams) (EntityPage, error)

ListEntities lists rows of a dynamic entity type. It calls GET {BasePath}/entities?type=<type>[&limit=<n>][&cursor=<c>].

func (*Client) ListEntityTypes

func (c *Client) ListEntityTypes(ctx context.Context) ([]string, error)

ListEntityTypes lists the registered dynamic entity type names. It calls GET {BasePath}/entities/types.

func (*Client) ListEvents

func (c *Client) ListEvents(ctx context.Context, params ListEventsParams) (EventPage, error)

ListEvents pages the transactional outbox (durable event log), recent-first. It calls GET {BasePath}/events with optional repeated ?aggregate= and ?type= filters, ?aggId, ?published, ?limit, and ?cursor.

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, params ListFilesParams) (FileListPage, error)

ListFiles lists a folder's children (root when Parent is empty). It calls GET {BasePath}/files?parent=<id>[&limit=<n>][&offset=<n>].

func (*Client) MigrationJobStreamPath

func (c *Client) MigrationJobStreamPath(id string) string

MigrationJobStreamPath returns the request path for the SSE stream of a migration job's state (GET {BasePath}/migrations/jobs/:id/stream). It does not issue a request — the caller opens a streaming/SSE connection to BaseURL()+this path directly, since the client's do() helper only supports request/response JSON calls.

func (*Client) ProjectionRebuild

func (c *Client) ProjectionRebuild(ctx context.Context, projection string) (ProjectionRebuildResult, error)

ProjectionRebuild rebuilds a projection ("graph" or "search") from the source of truth into a fresh target for the active tenant, then finalizes the blue-green swap (promotes the new target, abandons the old). It calls POST {BasePath}/projections/rebuild with body {projection}.

func (*Client) ProjectionReconcile

func (c *Client) ProjectionReconcile(ctx context.Context, projection string, repair bool) (ProjectionReconcileResult, error)

ProjectionReconcile scans a projection ("graph" or "search") against the Postgres source of truth for the active tenant and reports drift, optionally repairing it (republishing drifted aggregates through the pipeline) when repair is true. It calls POST {BasePath}/projections/reconcile with body {projection, repair}.

func (*Client) Recall

func (c *Client) Recall(ctx context.Context, req RecallRequest) (RecallPack, error)

Recall runs the agent toolkit's hybrid-recall pipeline: per-channel candidate generation (vector, full-text search, graph expansion), Reciprocal Rank Fusion across the channels, authoritative relational hydration, and token-budget packing. It calls POST {BasePath}/recall. Returns an *APIError with Status 400 when Query is empty, or Status 501 when hybrid recall is not configured (no embedder wired).

func (*Client) Remember

func (c *Client) Remember(ctx context.Context, input RememberInput) (CommandResult, error)

Remember performs a policy-gated write through the agent toolkit. Power is WritePolicy ∩ tenant scope ∩ lifecycle-hook rules. It calls POST {BasePath}/agent/remember. Returns an *APIError whose Code mirrors the server's WriteError code and whose Status is mapped accordingly: validation_failed→400, not_allowed→403, version_conflict→409, not_found→404, else 500.

func (*Client) RenameEntityField

func (c *Client) RenameEntityField(ctx context.Context, entityType, from, to string) error

RenameEntityField renames a column on an existing dynamic entity type. It calls POST {BasePath}/schema/:type/rename-field with body {from, to}.

func (*Client) RollbackMigrations

func (c *Client) RollbackMigrations(ctx context.Context) (MigrationJobHandle, error)

RollbackMigrations rolls back the last applied migration batch as a background job. It calls POST {BasePath}/migrations/down. Poll the returned job id with GetMigrationJob. Returns an *APIError with Status 403 when schema-admin is not enabled, Status 409 when another migration run is already in flight, or Status 501 when migration execution is unavailable.

func (*Client) RunDDL

func (c *Client) RunDDL(ctx context.Context, sql string) (DDLResult, error)

RunDDL runs a single ad-hoc DDL statement as the schema owner. It is NOT recorded in the migration ledger — this is a gated escape hatch deliberately outside the migration authority. It calls POST {BasePath}/schema/ddl with body {sql}. Returns an *APIError with Status 403 when schema-admin is not enabled, Status 400 on a bad/multi statement or a SQL error (the raw database error is surfaced, since this caller is already privileged), or Status 501 when no relational store is configured.

func (*Client) RunMigrations

func (c *Client) RunMigrations(ctx context.Context) (MigrationJobHandle, error)

RunMigrations runs all pending migrations as a background job. It calls POST {BasePath}/migrations/up. Poll the returned job id with GetMigrationJob. Returns an *APIError with Status 403 when schema-admin is not enabled, Status 409 when another migration run is already in flight, or Status 501 when migration execution is unavailable.

func (*Client) RunQuery

func (c *Client) RunQuery(ctx context.Context, input QueryInput) (QueryResult, error)

RunQuery runs a read-only raw SQL query for the current tenant. It calls POST {BasePath}/query with body {sql, args}. Returns an *APIError with Status 400 on a non-read-only statement, a tenant-guard trip, or a SQL error; Status 501 when no relational store is configured; Status 504 when the query is cancelled or exceeds the server's time limit.

func (*Client) ScaffoldMigration

func (c *Client) ScaffoldMigration(ctx context.Context, input MigrationScaffoldInput) (MigrationScaffold, error)

ScaffoldMigration generates a grove Go migration-file skeleton. It runs nothing and writes nothing — it only returns text for a developer to save into migrations/ and register in module.go. It calls POST {BasePath}/migrations/scaffold. Returns an *APIError with Status 403 when schema-admin is not enabled, or Status 400 on an invalid name/version.

func (*Client) SearchText

func (c *Client) SearchText(ctx context.Context, params SearchTextParams) (SearchPage, error)

SearchText performs full-text search over an entity's indexed fields. It calls GET {BasePath}/search?type=<type>&q=<query>[&limit=<n>][&offset=<n>] [&sort=<s>][&filter=field:value ...].

func (*Client) SearchVector

func (c *Client) SearchVector(ctx context.Context, input VectorSearchInput) (VectorSearchPage, error)

SearchVector performs a vector similarity search. It calls POST {BasePath}/search/vector with body {type, query|id, k, filter}.

func (*Client) SpatialWithin

func (c *Client) SpatialWithin(ctx context.Context, input SpatialWithinInput) (SpatialResult, error)

SpatialWithin performs a within-radius geo search: rows of Entity whose stored geometry lies within RadiusM metres of (Lng, Lat), nearest-first. It calls POST {BasePath}/spatial/within with body {entity, lng, lat, radiusM, limit}. Returns *APIError with Status 501 when the instance has no spatial backend configured, and Status 400 when entity, lng, lat, or radiusM is missing/invalid.

func (*Client) UpdateEntity

func (c *Client) UpdateEntity(ctx context.Context, id string, input EntityWriteInput) (EntityRecord, error)

UpdateEntity replaces an existing entity row's domain columns. It calls PUT {BasePath}/entities/:id with body {type, data}.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, input UploadFileInput) (FileNode, error)

UploadFile uploads a file. It calls POST {BasePath}/files with body {parentId, name, contentType, dataBase64} - the file bytes are base64-encoded into the JSON body (there is no multipart/raw-bytes upload path on the server).

func (*Client) VectorDelete

func (c *Client) VectorDelete(ctx context.Context, entity, id string) (VectorDeleteResult, error)

VectorDelete removes one stored embedding (idempotent). It calls DELETE {BasePath}/vector/:entity/:id.

func (*Client) VectorDeleteByMeta

func (c *Client) VectorDeleteByMeta(ctx context.Context, input VectorDeleteByMetaInput) (VectorDeleteResult, error)

VectorDeleteByMeta removes every embedding for an entity whose meta matches the given filter (AND-of-equals). An empty filter is the wipe-all path and is rejected server-side unless All is set. It calls POST {BasePath}/vector/delete-by-meta with body {entity, filter, all}.

func (*Client) VectorGet

func (c *Client) VectorGet(ctx context.Context, entity, id string) (VectorEmbeddingInfo, error)

VectorGet inspects a stored embedding (dims, L2 norm, and a leading preview). It calls GET {BasePath}/vector/:entity/:id.

type CommandInput

type CommandInput struct {
	// Entity is the registered entity name (e.g. "product").
	Entity string `json:"entity"`
	// Op is the command verb: create | update | delete | upsert.
	Op CommandOp `json:"op"`
	// AggID identifies the aggregate. Required for update/delete/upsert; a
	// ULID is minted server-side for create when omitted.
	AggID string `json:"aggId,omitempty"`
	// Payload is the column-keyed body (create/update/upsert). Ignored for delete.
	Payload map[string]any `json:"payload,omitempty"`
	// ExpectedVersion enables optimistic concurrency — a mismatch is a 409.
	ExpectedVersion *int64 `json:"expectedVersion,omitempty"`
}

CommandInput is one raw command against the write plane. It mirrors adminapi's commandRequest JSON exactly: {entity, op, aggId, payload, expectedVersion}.

type CommandOp

type CommandOp string

CommandOp is a raw command verb against the write plane.

const (
	CommandOpCreate CommandOp = "create"
	CommandOpUpdate CommandOp = "update"
	CommandOpDelete CommandOp = "delete"
	CommandOpUpsert CommandOp = "upsert"
)

Command verbs accepted by ExecCommand / ExecBatch.

type CommandResult

type CommandResult struct {
	AggID   string `json:"aggId"`
	Version int64  `json:"version"`
	EventID string `json:"eventId"`
}

CommandResult is the outcome of one command. It mirrors adminapi's commandResultItem JSON exactly: {aggId, version, eventId}.

type CrdtDocument

type CrdtDocument struct {
	// DocID is the document id ("<entity>/<id>").
	DocID string `json:"docId"`
	// Version is the aggregate version assigned by the last materialization
	// event; 0 until the quiet-window snapshot lands a relational row.
	Version int64 `json:"version"`
	// Snapshot is the merged CRDT state as a column-keyed JSON object.
	Snapshot json.RawMessage `json:"snapshot"`
}

CrdtDocument is a collaborative document's merged (current) state, as returned by GET {BasePath}/crdt/:entity/:id. It mirrors adminapi's crdtSnapshotResponse JSON exactly: {docId, version, snapshot}. Snapshot's shape is document-specific, so it is left as raw JSON.

type CrdtUpdate

type CrdtUpdate struct {
	// Index is the update's ordinal position in the Sync page (0-based).
	Index int `json:"index"`
	// Size is the byte length of the encoded update blob.
	Size int `json:"size"`
	// Preview is a base64 preview of the first bytes of the blob.
	Preview string `json:"preview"`
}

CrdtUpdate is metadata for a single entry in a document's CRDT update log. It mirrors adminapi's crdtUpdateItem JSON exactly: {index, size, preview}.

type CrdtUpdatePage

type CrdtUpdatePage struct {
	// DocID is the document id the log belongs to.
	DocID string `json:"docId"`
	// HighWaterSeq is the highest log seq folded into this page.
	HighWaterSeq int64 `json:"highWaterSeq"`
	// HasSnapshot reports whether a compacted snapshot preceded the tail
	// updates (older updates have been folded away).
	HasSnapshot bool `json:"hasSnapshot"`
	// Items lists the tail updates (post-snapshot).
	Items []CrdtUpdate `json:"items"`
}

CrdtUpdatePage is a page of CRDT update-log metadata, as returned by GET {BasePath}/crdt/:entity/:id/updates. It mirrors adminapi's crdtUpdateLogResponse JSON exactly: {docId, highWaterSeq, hasSnapshot, items}.

type CreateEntityTypeInput

type CreateEntityTypeInput struct {
	Type    string              `json:"type"`
	Columns []SchemaColumnInput `json:"columns"`
	Indexes []SchemaIndexInput  `json:"indexes,omitempty"`
}

CreateEntityTypeInput is the request body for CreateEntityType. It mirrors adminapi's defineSchemaRequest JSON exactly: {type, columns, indexes}.

type CreateFolderInput

type CreateFolderInput struct {
	// ParentID is the destination folder id; "" creates at root.
	ParentID string `json:"parentId,omitempty"`
	// Name is the new folder's name (required).
	Name string `json:"name"`
}

CreateFolderInput is the request body for CreateFolder. It mirrors adminapi's createFolderRequest JSON exactly: {parentId, name}.

type DDLResult

type DDLResult struct {
	OK       bool   `json:"ok"`
	Executed string `json:"executed"`
}

DDLResult is the payload for RunDDL. It mirrors adminapi's response JSON exactly: {ok, executed}.

type DSN

type DSN struct {
	Transport string
	TLS       bool
	Host      string
	Port      string
	BasePath  string
	Tenant    string
	Key       string
	Version   int
}

DSN represents a parsed fabriq connection string.

func ParseDSN

func ParseDSN(s string) (DSN, error)

ParseDSN parses a fabriq connection string of the form:

fabriq://<key>@<host>[:port][/tenant][?tls=true|false&version=N&basePath=/path]
fabriq+grpc://<key>@<host>[:port][/tenant][?tls=true|false&version=N&basePath=/path]

func (DSN) BaseURL

func (d DSN) BaseURL() string

BaseURL renders the DSN as an HTTP(S) base URL: {http|https}://host:port{basePath}.

type DigestChild

type DigestChild struct {
	ID          string `json:"id"`
	Kind        string `json:"kind"`
	Summary     string `json:"summary"`
	ContentHash string `json:"contentHash"`
	SemHash     string `json:"semHash"`
}

DigestChild is one immediate child of a digest node, as returned by GetDigestNode. It mirrors adminapi's distillChild JSON exactly: {id, kind, summary, contentHash, semHash}.

type DigestMap

type DigestMap struct {
	// RootID is the stable id of the tenant (L2) root: "digest:2:tenant".
	RootID string       `json:"rootId"`
	Nodes  []DigestNode `json:"nodes"`
}

DigestMap is the payload for GetDigestMap. It mirrors adminapi's distillMapResponse JSON exactly: {rootId, nodes}. Nodes is empty (non-nil) when the tenant has no digest data yet.

type DigestNode

type DigestNode struct {
	ID    string `json:"id"`
	Level int    `json:"level"`
	Kind  string `json:"kind"`
	// Scope is the scope value an L1 scope node summarizes (empty otherwise).
	Scope string `json:"scope,omitempty"`
	// ContentHash is the Merkle freshness key (changes when the subtree changes).
	ContentHash string `json:"contentHash"`
	// SemHash is the 16-hex SimHash fingerprint of the node's summary embedding.
	SemHash string `json:"semHash"`
	// Summary is the node's summary text when surfaced; usually empty in the
	// map (see DigestMap) — use GetDigestNode for full text.
	Summary string `json:"summary,omitempty"`
}

DigestNode is a single node in the per-tenant context-distillation Merkle tree (the "AI data fabric"). It mirrors adminapi's distillNode JSON exactly: {id, level, kind, scope, contentHash, semHash, summary}. Level 2 is the tenant root, level 1 is a scope/cluster node, level 0 is an entity leaf. Scope and Summary are omitted by the server when empty.

type DigestView

type DigestView struct {
	Node     DigestNode    `json:"node"`
	Summary  string        `json:"summary"`
	Children []DigestChild `json:"children"`
}

DigestView is the payload for GetDigestNode. It mirrors adminapi's distillNodeResponse JSON exactly: {node, summary, children}.

type DriftEntity

type DriftEntity struct {
	Entity  string `json:"entity"`
	Table   string `json:"table"`
	Dynamic bool   `json:"dynamic"`
	InSync  bool   `json:"inSync"`
	// Missing lists columns expected by the registry but absent physically.
	Missing []string `json:"missing"`
	// Extra lists columns present physically but not in the registry.
	Extra []string `json:"extra"`
	// Error is set when this entity's table could not be introspected.
	Error string `json:"error,omitempty"`
}

DriftEntity is one entity's registry-vs-physical schema drift. It mirrors adminapi's driftEntity JSON exactly: {entity, table, dynamic, inSync, missing, extra, error}.

type EntityPage

type EntityPage struct {
	Items      []EntityRecord `json:"items"`
	NextCursor string         `json:"nextCursor"`
}

EntityPage is a page of EntityRecord results, as returned by GET {BasePath}/entities. It mirrors adminapi's entityListResponse JSON exactly: {items, nextCursor}.

type EntityRecord

type EntityRecord struct {
	ID   string         `json:"id"`
	Type string         `json:"type"`
	Data map[string]any `json:"data"`
}

EntityRecord is a single dynamic-entity row, as returned by the entity list and detail endpoints. It mirrors adminapi's entityItem JSON exactly: {id, type, data}.

type EntitySchema

type EntitySchema struct {
	Type   string        `json:"type"`
	Fields []SchemaField `json:"fields"`
}

EntitySchema is the payload for GetEntitySchema and the schema-mutating methods. It mirrors adminapi's schemaResponse JSON exactly: {type, fields}.

type EntityWriteInput

type EntityWriteInput struct {
	// Type is the registered dynamic entity type name (e.g. "product").
	Type string `json:"type"`
	// Data is the column-keyed payload written to the row.
	Data map[string]any `json:"data"`
}

EntityWriteInput is the request body for creating or updating an entity row. It mirrors adminapi's entityWriteRequest JSON exactly: {type, data}.

type Event

type Event struct {
	ID                   string          `json:"id"`
	Aggregate            string          `json:"aggregate"`
	AggID                string          `json:"aggId"`
	Version              int64           `json:"version"`
	Type                 string          `json:"type"`
	At                   string          `json:"at"`
	PayloadSchemaVersion int             `json:"payloadSchemaVersion"`
	Published            bool            `json:"published"`
	StreamID             string          `json:"streamId,omitempty"`
	Payload              json.RawMessage `json:"payload"`
}

Event is a single row of the transactional outbox — the durable event log behind the command plane. It mirrors adminapi's eventItem JSON exactly: {id, aggregate, aggId, version, type, at, payloadSchemaVersion, published, streamId, payload}.

type EventFacets

type EventFacets struct {
	Aggregates []string `json:"aggregates"`
	Types      []string `json:"types"`
}

EventFacets is the payload for EventFacets. It mirrors adminapi's eventFacetsResponse JSON exactly: {aggregates, types}.

type EventPage

type EventPage struct {
	Items      []Event `json:"items"`
	NextCursor string  `json:"nextCursor"`
}

EventPage is a page of outbox events, recent-first. It mirrors adminapi's eventListResponse JSON exactly: {items, nextCursor}.

type EventsBacklog

type EventsBacklog struct {
	Unpublished int64 `json:"unpublished"`
}

EventsBacklog is the payload for EventsBacklog. It mirrors adminapi's eventBacklogResponse JSON exactly: {unpublished}.

type FileListPage

type FileListPage struct {
	Items []FileNode `json:"items"`
}

FileListPage is the payload for GET {BasePath}/files. It mirrors adminapi's fileListResponse JSON exactly: {items}.

type FileNode

type FileNode struct {
	// ID is the fs_node aggregate id.
	ID string `json:"id"`
	// Name is the node's name within its folder.
	Name string `json:"name"`
	// Kind is "folder" or "file".
	Kind string `json:"kind"`
	// Size is the byte size for files; 0 for folders.
	Size int64 `json:"size"`
	// ContentType is the file's MIME type; empty for folders.
	ContentType string `json:"contentType"`
	// ParentID is the parent folder's id; "" for root-level nodes.
	ParentID string `json:"parentId"`
	// UpdatedAt is the last-modified timestamp in RFC 3339, when known.
	UpdatedAt string `json:"updatedAt,omitempty"`
}

FileNode is a single fs_node (file or folder), as returned by the file listing/detail endpoints. It mirrors adminapi's fileNode JSON exactly: {id, name, kind, size, contentType, parentId, updatedAt}.

type GetCrdtUpdatesParams

type GetCrdtUpdatesParams struct {
	// DocID is the document id ("<entity>/<id>").
	DocID string
	// Limit caps the number of returned tail updates (server default 100,
	// capped server-side). Zero omits the query param and defers to the
	// server default.
	Limit int
}

GetCrdtUpdatesParams are the query parameters for GetCrdtUpdates.

type GraphData

type GraphData struct {
	Nodes []GraphNode `json:"nodes"`
	Edges []GraphEdge `json:"edges"`
}

GraphData is the shared {nodes, edges} payload for the neighbors and traverse endpoints. It mirrors adminapi's graphSubgraphResponse JSON exactly: {nodes, edges}.

type GraphEdge

type GraphEdge struct {
	From  string         `json:"from"`
	To    string         `json:"to"`
	Rel   string         `json:"rel"`
	Props map[string]any `json:"props,omitempty"`
}

GraphEdge is one relationship in a graph subgraph response. It mirrors adminapi's graphEdge JSON exactly: {from, to, rel, props}.

type GraphNeighborsParams

type GraphNeighborsParams struct {
	// Type is the node's primary label / entity type (e.g. "product").
	Type string
	// ID is the id of the node to expand.
	ID string
	// Limit caps the number of 1-hop relationships expanded (server default
	// 50). Zero omits the query param and defers to the server default.
	Limit int
}

GraphNeighborsParams are the query parameters for GraphNeighbors. Type and ID are required by the backend; Limit is optional.

type GraphNode

type GraphNode struct {
	ID    string         `json:"id"`
	Type  string         `json:"type,omitempty"`
	Label string         `json:"label,omitempty"`
	Props map[string]any `json:"props,omitempty"`
}

GraphNode is one node in a graph subgraph response, as returned by the neighbors and traverse endpoints. It mirrors adminapi's graphNode JSON exactly: {id, type, label, props}.

type GraphQueryInput

type GraphQueryInput struct {
	// Cypher is the read-only openCypher query to run.
	Cypher string `json:"cypher"`
	// Params are optional named parameters referenced as $name in the query.
	Params map[string]any `json:"params,omitempty"`
}

GraphQueryInput is the request body for GraphQuery. It mirrors adminapi's graphQueryRequest JSON exactly: {cypher, params}.

type GraphQueryResult

type GraphQueryResult struct {
	Columns []string `json:"columns"`
	Rows    [][]any  `json:"rows"`
}

GraphQueryResult is the tabular payload for the read-only Cypher playground. It mirrors adminapi's graphQueryResponse JSON exactly: {columns, rows}. Rows mirror Columns positionally.

type GraphTraverseInput

type GraphTraverseInput struct {
	// Type is the node's primary label / entity type (e.g. "product").
	Type string `json:"type"`
	// ID is the id of the root node to traverse from.
	ID string `json:"id"`
	// Depth is the BFS hop count (1-3); values outside the range are clamped
	// server-side.
	Depth int `json:"depth"`
	// Limit caps the number of nodes returned (server default/maximum 200).
	Limit int `json:"limit,omitempty"`
}

GraphTraverseInput is the request body for GraphTraverse. It mirrors adminapi's traverseRequest JSON exactly: {type, id, depth, limit}.

type InstanceCapabilities

type InstanceCapabilities struct {
	Relational bool `json:"relational"`
	Graph      bool `json:"graph"`
	Vector     bool `json:"vector"`
	Spatial    bool `json:"spatial"`
	Search     bool `json:"search"`
	CRDT       bool `json:"crdt"`
	Files      bool `json:"files"`
	Distill    bool `json:"distill"`
	Timeseries bool `json:"timeseries"`
}

InstanceCapabilities reports which fabric subsystems this fabriq instance has configured. It mirrors adminapi's instanceCapabilities JSON exactly: {relational, graph, vector, spatial, search, crdt, files, distill, timeseries}.

type ListEntitiesParams

type ListEntitiesParams struct {
	// Type is the registered dynamic entity type name (e.g. "product").
	Type string
	// Limit caps the page size (server default 50, max 200). Zero omits the
	// query param and defers to the server default.
	Limit int
	// Cursor resumes a previous listing (server emits this as
	// EntityPage.NextCursor). Empty starts from the first page.
	Cursor string
}

ListEntitiesParams are the query parameters for ListEntities. Type is required by the backend; Limit and Cursor are optional.

type ListEventsParams

type ListEventsParams struct {
	// Aggregate matches any of these aggregate types (OR / SQL IN).
	Aggregate []string
	// Type matches any of these event types (OR / SQL IN).
	Type []string
	// AggID filters to a single aggregate instance id.
	AggID string
	// Published filters to published (true) or unpublished (false) events.
	// Nil omits the filter.
	Published *bool
	// Limit caps the page size (server default 50, max 200). Zero omits the
	// query param and defers to the server default.
	Limit int
	// Cursor resumes a previous listing (server emits this as
	// EventPage.NextCursor). Empty starts from the first page.
	Cursor string
}

ListEventsParams are the query parameters for ListEvents. Aggregate and Type are multi-valued (OR / SQL IN): each value is sent as a repeated query parameter (?aggregate=a&aggregate=b), mirroring the TS client and the server's IN-filter. Published is a tri-state: nil omits the filter, non-nil sends "true" or "false".

type ListFilesParams

type ListFilesParams struct {
	// Parent is the folder id whose children to list; "" lists the root.
	Parent string
	// Limit caps the page size (server default 100, capped server-side).
	// Zero omits the query param and defers to the server default.
	Limit int
	// Offset paginates past earlier results. Zero omits the query param.
	Offset int
}

ListFilesParams are the query parameters for ListFiles. All are optional: Parent absent/empty lists the root; Limit/Offset default server-side.

type Meta

type Meta struct {
	Name         string   `json:"name"`
	Version      string   `json:"version"`
	Capabilities []string `json:"capabilities"`
	// Tenant is the resolved tenant id echoed back when X-Tenant-ID is sent.
	// Empty for unauthenticated or tenant-agnostic callers.
	Tenant string `json:"tenant,omitempty"`
}

Meta is the payload for GetMeta. It mirrors adminapi's metaResponse JSON exactly: {name, version, capabilities, tenant}.

type MigrationGroupStatus

type MigrationGroupStatus struct {
	Name    string          `json:"name"`
	Applied []MigrationInfo `json:"applied"`
	Pending []MigrationInfo `json:"pending"`
}

MigrationGroupStatus is one migration group's applied/pending status. It mirrors adminapi's migrationGroup JSON exactly: {name, applied, pending}.

type MigrationInfo

type MigrationInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Group   string `json:"group"`
	Comment string `json:"comment"`
	Applied bool   `json:"applied"`
	// AppliedAt is empty when the migration has not been applied.
	AppliedAt string `json:"appliedAt,omitempty"`
}

MigrationInfo is one migration's status. It mirrors adminapi's migrationItem JSON exactly: {name, version, group, comment, applied, appliedAt}.

type MigrationJob

type MigrationJob struct {
	ID string `json:"id"`
	// Kind is "up" or "down".
	Kind string `json:"kind"`
	// State is "running", "done", or "failed".
	State     string   `json:"state"`
	Names     []string `json:"names,omitempty"`
	Error     string   `json:"error,omitempty"`
	StartedAt string   `json:"startedAt"`
	// EndedAt is empty while the job is running.
	EndedAt string `json:"endedAt,omitempty"`
}

MigrationJob is one async migration run (up or down), as returned by GetMigrationJob. It mirrors adminapi's migrationJob JSON exactly: {id, kind, state, names, error, startedAt, endedAt}.

type MigrationJobHandle

type MigrationJobHandle struct {
	JobID string `json:"jobId"`
}

MigrationJobHandle is the payload for RunMigrations and RollbackMigrations. It mirrors adminapi's response JSON exactly: {jobId}.

type MigrationScaffold

type MigrationScaffold struct {
	Filename string `json:"filename"`
	Content  string `json:"content"`
}

MigrationScaffold is the payload for ScaffoldMigration. It mirrors adminapi's response JSON exactly: {filename, content}.

type MigrationScaffoldInput

type MigrationScaffoldInput struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	// Up/Down are optional forward/reverse DDL statements (one per element);
	// omitted, the generated file carries TODO placeholders.
	Up   []string `json:"up,omitempty"`
	Down []string `json:"down,omitempty"`
}

MigrationScaffoldInput is the request body for ScaffoldMigration. It mirrors adminapi's scaffoldRequest JSON exactly: {name, version, up, down}.

type MigrationStatus

type MigrationStatus struct {
	Groups []MigrationGroupStatus `json:"groups"`
}

MigrationStatus is the payload for GetMigrationStatus. It mirrors adminapi's migrationStatusResponse JSON exactly: {groups}.

type Option

type Option func(*Client)

Option customizes a Client during Connect.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient overrides the *http.Client used for requests. Useful for tests (httptest) or custom transports/timeouts.

type ProjectionDrift

type ProjectionDrift struct {
	Entity           string `json:"entity"`
	AggID            string `json:"aggId"`
	TruthVersion     int64  `json:"truthVersion"`
	ProjectedVersion int64  `json:"projectedVersion"`
}

ProjectionDrift is one aggregate whose projected version differs from the source of truth. It mirrors adminapi's driftItem JSON exactly: {entity, aggId, truthVersion, projectedVersion}.

type ProjectionRebuildResult

type ProjectionRebuildResult struct {
	Projection string `json:"projection"`
	OldTarget  string `json:"oldTarget"`
	NewTarget  string `json:"newTarget"`
}

ProjectionRebuildResult is the payload for ProjectionRebuild. It mirrors adminapi's rebuildResponse JSON exactly: {projection, oldTarget, newTarget}.

type ProjectionReconcileResult

type ProjectionReconcileResult struct {
	Projection string            `json:"projection"`
	Repaired   bool              `json:"repaired"`
	DriftCount int               `json:"driftCount"`
	Drifts     []ProjectionDrift `json:"drifts"`
}

ProjectionReconcileResult is the payload for ProjectionReconcile. It mirrors adminapi's reconcileResponse JSON exactly: {projection, repaired, driftCount, drifts}.

type ProjectionStatus

type ProjectionStatus struct {
	Name string `json:"name"`
	// Status is the blue-green pointer state: live | building | soaking | abandoned.
	Status string `json:"status"`
	// ModelVersion is the _v{N} generation bumped by rebuilds.
	ModelVersion int `json:"modelVersion"`
	// EventVersion is the last applied event ULID (stream position); empty
	// when nothing has been applied through the projection engine.
	EventVersion string `json:"eventVersion"`
	// TargetName is the engine target currently receiving applies (e.g.
	// tenant_<id>_v2); empty when the default live target is used.
	TargetName string `json:"targetName"`
}

ProjectionStatus is the bookkeeping for one projection plane (graph or search): its blue-green pointer and stream position. It mirrors adminapi's projectionStatusItem JSON exactly: {name, status, modelVersion, eventVersion, targetName}.

type ProjectionsInfo

type ProjectionsInfo struct {
	Projections []ProjectionStatus `json:"projections"`
	// Backlog is the unpublished outbox depth — a proxy for projection lag.
	Backlog int64 `json:"backlog"`
}

ProjectionsInfo is the payload for GetProjections. It mirrors adminapi's projectionsResponse JSON exactly: {projections, backlog}.

type QueryInput

type QueryInput struct {
	// SQL is a single read-only SELECT or WITH statement. Statement stacking
	// (multiple ;-separated statements) is rejected server-side.
	SQL string `json:"sql"`
	// Args are positional query parameters substituted into SQL.
	Args []any `json:"args,omitempty"`
}

QueryInput is the request body for RunQuery. It mirrors adminapi's queryRequest JSON exactly: {sql, args}.

type QueryResult

type QueryResult struct {
	Columns   []string         `json:"columns"`
	Rows      []map[string]any `json:"rows"`
	RowCount  int              `json:"rowCount"`
	Truncated bool             `json:"truncated"`
	ElapsedMs int64            `json:"elapsedMs"`
}

QueryResult is the payload for RunQuery. It mirrors adminapi's queryResponse JSON exactly: {columns, rows, rowCount, truncated, elapsedMs}.

type RecallItem

type RecallItem struct {
	Entity string          `json:"entity"`
	ID     string          `json:"id"`
	Row    json.RawMessage `json:"row"`
	Score  float64         `json:"score"`
	Source []string        `json:"source"`
	Tokens int             `json:"tokens"`
}

RecallItem is a single hydrated, fused row in a hybrid-recall pack. It mirrors adminapi's recallItem JSON exactly: {entity, id, row, score, source, tokens}. Row is carried verbatim as a JSON object (json.RawMessage), not a quoted/escaped string. Source lists the channels that contributed the row to the fusion ("vector", "search", "graph").

type RecallPack

type RecallPack struct {
	Items    []RecallItem `json:"items"`
	Omitted  int          `json:"omitted"`
	Tokens   int          `json:"tokens"`
	Warnings []string     `json:"warnings"`
}

RecallPack is the payload for Recall. It mirrors adminapi's recallResponse JSON exactly: {items, omitted, tokens, warnings}. Items are ordered best-first by fused score; Omitted counts rows that did not fit the budget; Tokens is the total used; Warnings carries per-channel degradation notes from the lenient recall pipeline.

type RecallRequest

type RecallRequest struct {
	// Query is the free-text recall query. Required; an empty query yields
	// an *APIError with Status 400.
	Query string `json:"query"`
	// Entities scopes recall to these dynamic entity types. When omitted the
	// server defaults to every registered dynamic (schema-backed) entity type.
	Entities []string `json:"entities,omitempty"`
	// Budget is the token budget for the assembled context pack. Zero defers
	// to the server default.
	Budget int `json:"budget,omitempty"`
	// K is the per-channel candidate count fed into RRF fusion. Zero defers
	// to the server default.
	K int `json:"k,omitempty"`
	// Hops is the graph-expansion depth for the graph channel. Zero defers
	// to the server default.
	Hops int `json:"hops,omitempty"`
}

RecallRequest is the request body for Recall. It mirrors adminapi's recallRequest JSON exactly: {query, entities, budget, k, hops}.

type RememberInput

type RememberInput struct {
	Entity string    `json:"entity"`
	Op     CommandOp `json:"op"`
	// AggID identifies the aggregate. Required for update/delete/upsert; a
	// ULID is minted server-side for create when omitted.
	AggID string `json:"aggId,omitempty"`
	// Payload is the column-keyed body (create/update/upsert). Ignored for delete.
	Payload map[string]any `json:"payload,omitempty"`
	// ExpectedVersion enables optimistic concurrency — a mismatch is a 409.
	ExpectedVersion *int64 `json:"expectedVersion,omitempty"`
}

RememberInput is the request body for Remember. It mirrors adminapi's agent.RememberRequest JSON exactly: {entity, op, aggId, payload, expectedVersion} — the same shape as CommandInput.

type SchemaColumnInput

type SchemaColumnInput struct {
	Name string `json:"name"`
	// Kind is one of: string, number, boolean, time, object.
	Kind     string `json:"kind"`
	Required bool   `json:"required"`
	// Default is a SQL default expression. Allowed forms: a number,
	// true/false/null, now(), or a single-quoted string literal. Empty omits
	// the field.
	Default string `json:"default,omitempty"`
}

SchemaColumnInput describes a column when defining or extending a dynamic entity type's schema. It mirrors adminapi's schemaWriteColumn JSON exactly: {name, kind, required, default}.

type SchemaDrift

type SchemaDrift struct {
	Entities []DriftEntity `json:"entities"`
}

SchemaDrift is the payload for GetSchemaDrift. It mirrors adminapi's driftResponse JSON exactly: {entities}.

type SchemaField

type SchemaField struct {
	// Name is the column name.
	Name string `json:"name"`
	// Kind is the simplified field kind: string, number, boolean, time, or object.
	Kind string `json:"kind"`
	// Required reports whether the column is NOT NULL.
	Required bool `json:"required"`
}

SchemaField is one field descriptor in a dynamic entity's schema. It mirrors adminapi's schemaField JSON exactly: {name, kind, required}.

type SchemaIndexInput

type SchemaIndexInput struct {
	Name    string   `json:"name"`
	Columns []string `json:"columns"`
	Unique  bool     `json:"unique,omitempty"`
}

SchemaIndexInput describes an index when defining or extending a dynamic entity type's schema. It mirrors adminapi's schemaWriteIndex JSON exactly: {name, columns, unique}.

type SearchPage

type SearchPage struct {
	Items []EntityRecord `json:"items"`
}

SearchPage is the payload for GET {BasePath}/search. It mirrors adminapi's searchResponse JSON exactly: {items}. Each item mirrors EntityRecord ({id, type, data}).

type SearchTextParams

type SearchTextParams struct {
	// Type is the registered dynamic entity type name (e.g. "product"). Must
	// be search-indexed.
	Type string
	// Query is the full-text query string.
	Query string
	// Limit caps the page size (server default 25, capped server-side). Zero
	// omits the query param and defers to the server default.
	Limit int
	// Offset paginates past earlier results. Zero omits the query param.
	Offset int
	// Sort is an indexed column, optionally suffixed " DESC". Empty omits
	// the query param and defers to relevance-score ordering.
	Sort string
	// Filter is a set of equality filters over indexed fields, AND-ed. Each
	// entry is sent as a repeated ?filter=field:value query param.
	Filter map[string]string
}

SearchTextParams are the query parameters for SearchText. Type and Query are required by the backend; Limit, Offset, Sort and Filter are optional.

type SpatialMatch

type SpatialMatch struct {
	ID        string         `json:"id"`
	DistanceM float64        `json:"distanceM,omitempty"`
	Lng       *float64       `json:"lng,omitempty"`
	Lat       *float64       `json:"lat,omitempty"`
	Data      map[string]any `json:"data,omitempty"`
}

SpatialMatch is one within-radius search hit, nearest first. It mirrors adminapi's spatialMatchItem JSON exactly: {id, distanceM, lng, lat, data}.

type SpatialResult

type SpatialResult struct {
	Matches []SpatialMatch `json:"matches"`
}

SpatialResult is the payload for POST {BasePath}/spatial/within. It mirrors adminapi's spatialWithinResponse JSON exactly: {matches}.

type SpatialWithinInput

type SpatialWithinInput struct {
	// Entity is the registered dynamic entity type name (e.g. "place").
	Entity string `json:"entity"`
	// Lng is the centre longitude (X), degrees, WGS84.
	Lng float64 `json:"lng"`
	// Lat is the centre latitude (Y), degrees, WGS84.
	Lat float64 `json:"lat"`
	// RadiusM is the search radius in metres.
	RadiusM float64 `json:"radiusM"`
	// Limit caps the number of returned matches (server default 25). Zero
	// defers to the server default.
	Limit int `json:"limit,omitempty"`
}

SpatialWithinInput is the request body for SpatialWithin. It mirrors adminapi's spatialWithinRequest JSON exactly: {entity, lng, lat, radiusM, limit}. Coordinates are WGS84 (SRID 4326).

type TypeCapabilities

type TypeCapabilities struct {
	Relational bool `json:"relational"`
	Vector     bool `json:"vector"`
	Search     bool `json:"search"`
	Spatial    bool `json:"spatial"`
	CRDT       bool `json:"crdt"`
	Graph      bool `json:"graph"`
}

TypeCapabilities reports which subsystems a single dynamic entity type participates in. It mirrors adminapi's typeCapabilities JSON exactly: {relational, vector, search, spatial, crdt, graph}.

type TypeCapabilitiesResult

type TypeCapabilitiesResult struct {
	Type         string           `json:"type"`
	Capabilities TypeCapabilities `json:"capabilities"`
}

TypeCapabilitiesResult is the payload for GetTypeCapabilities. It mirrors adminapi's typeCapabilitiesResponse JSON exactly: {type, capabilities}.

type UploadFileInput

type UploadFileInput struct {
	// ParentID is the destination folder id; "" creates at root.
	ParentID string `json:"parentId,omitempty"`
	// Name is the new file's name (required).
	Name string `json:"name"`
	// ContentType is the file's MIME type (optional).
	ContentType string `json:"contentType,omitempty"`
	// Data is the raw file body; UploadFile base64-encodes it into the
	// request's dataBase64 field.
	Data []byte `json:"-"`
}

UploadFileInput is the request body for UploadFile. It mirrors adminapi's createFileRequest JSON exactly: {parentId, name, contentType, dataBase64}. Data is carried as base64-encoded JSON, matching the server contract (not a multipart/raw-bytes upload).

type VectorDeleteByMetaInput

type VectorDeleteByMetaInput struct {
	// Entity is the registered entity whose embeddings are targeted.
	Entity string `json:"entity"`
	// Filter is an AND-of-equals over embedding meta. An empty filter would
	// delete every embedding for the entity, so it is rejected server-side
	// unless All is set.
	Filter map[string]string `json:"filter,omitempty"`
	// All must be explicitly true to opt into the wipe-all (empty-filter) path.
	All bool `json:"all,omitempty"`
}

VectorDeleteByMetaInput is the request body for VectorDeleteByMeta. It mirrors adminapi's vectorDeleteByMetaRequest JSON exactly: {entity, filter, all}.

type VectorDeleteResult

type VectorDeleteResult struct {
	Deleted bool `json:"deleted"`
}

VectorDeleteResult is the payload for the embedding delete endpoints. It mirrors adminapi's vectorDeleteResponse JSON exactly: {deleted}.

type VectorEmbeddingInfo

type VectorEmbeddingInfo struct {
	Entity  string    `json:"entity"`
	ID      string    `json:"id"`
	Dims    int       `json:"dims"`
	Norm    float64   `json:"norm"`
	Preview []float32 `json:"preview"`
}

VectorEmbeddingInfo is the payload for GET {BasePath}/vector/:entity/:id — a read-only inspection of one stored embedding. It mirrors adminapi's vectorGetResponse JSON exactly: {entity, id, dims, norm, preview}.

type VectorMatch

type VectorMatch struct {
	ID    string         `json:"id"`
	Score float64        `json:"score"`
	Data  map[string]any `json:"data,omitempty"`
}

VectorMatch is one nearest-neighbour hit, as returned by vector similarity search. It mirrors adminapi's vectorMatchItem JSON exactly: {id, score, data}.

type VectorSearchInput

type VectorSearchInput struct {
	// Type is the registered dynamic entity type name (e.g. "product").
	Type string `json:"type"`
	// Query is the free-text query for TEXT mode. Requires a configured
	// server-side embedder.
	Query string `json:"query,omitempty"`
	// ID selects SIMILAR-TO-ENTITY mode: find rows similar to this stored
	// embedding.
	ID string `json:"id,omitempty"`
	// K caps the number of returned matches (server default 10).
	K int `json:"k,omitempty"`
	// Filter restricts matches to embeddings whose meta contains all of
	// these key=value pairs (AND-ed). Optional; empty means no meta filter.
	Filter map[string]string `json:"filter,omitempty"`
}

VectorSearchInput is the request body for SearchVector. It carries one of two mutually exclusive modes:

  • TEXT: {type, query, k} — Query is embedded server-side and the resulting vector drives a nearest-neighbour search.
  • SIMILAR-TO-ENTITY: {type, id, k} — the embedding stored for ID is fetched and used as the query vector.

When both Query and ID are set, ID (similar-to-entity) takes precedence.

type VectorSearchPage

type VectorSearchPage struct {
	Matches []VectorMatch `json:"matches"`
}

VectorSearchPage is the payload for POST {BasePath}/search/vector. It mirrors adminapi's vectorSearchResponse JSON exactly: {matches}.

type WritePolicy

type WritePolicy struct {
	Allow map[string][]string `json:"allow"`
}

WritePolicy is the agent write allowlist (deny-by-default): a map of entity name to permitted ops. It mirrors adminapi's writePolicyResponse JSON exactly: {allow}. An empty Allow map means every write is denied.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL