client

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAddr = "127.0.0.1:7001"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(addr string, timeout time.Duration) *Client

func (*Client) ACLAccept

func (c *Client) ACLAccept(ctx context.Context, spaceId string, req api.ACLAcceptRequest) error

func (*Client) ACLAdd

func (c *Client) ACLAdd(ctx context.Context, spaceId string, req api.ACLAddRequest) error

func (*Client) ACLCancelJoin

func (c *Client) ACLCancelJoin(ctx context.Context, spaceId string) error

func (*Client) ACLChangePermissions

func (c *Client) ACLChangePermissions(ctx context.Context, spaceId string, req api.ACLChangePermissionsRequest) error

func (*Client) ACLDecline

func (c *Client) ACLDecline(ctx context.Context, spaceId string, req api.ACLDeclineRequest) error

func (*Client) ACLOwnership

func (c *Client) ACLOwnership(ctx context.Context, spaceId string, req api.ACLOwnershipRequest) error

func (*Client) ACLRemove

func (c *Client) ACLRemove(ctx context.Context, spaceId string, req api.ACLRemoveRequest) error

func (*Client) ACLSelfRemove

func (c *Client) ACLSelfRemove(ctx context.Context, spaceId string) error

func (*Client) ACLStopSharing

func (c *Client) ACLStopSharing(ctx context.Context, spaceId string) error

func (*Client) AccountRedeemAccessCode

func (c *Client) AccountRedeemAccessCode(ctx context.Context, code string) (api.AccessCodeResponse, error)

AccountRedeemAccessCode sends an invite code to the invite service on the account's behalf. POST /v1/account/access-code.

func (*Client) AccountUpdateMetadata

func (c *Client) AccountUpdateMetadata(ctx context.Context, meta api.AccountMetadata) error

AccountUpdateMetadata updates the caller's account profile across every space they're a member of. PUT /v1/account/metadata.

func (*Client) Aggregate

func (c *Client) Aggregate(ctx context.Context, spaceId string, body []byte) (*api.AggregateResponse, error)

Aggregate runs an aggregation pipeline over a per-object dataset (POST /v1/spaces/:spaceId/aggregate). body is the pre-built JSON request — objectId, dataset, pipeline, optional limits/explain.

func (*Client) AggregateObjects

func (c *Client) AggregateObjects(ctx context.Context, spaceId string, body []byte) (*api.AggregateResponse, error)

AggregateObjects runs an aggregation pipeline over the per-space `objects` collection (POST /v1/spaces/:spaceId/objects/aggregate).

func (*Client) AuthStatus

func (c *Client) AuthStatus(ctx context.Context) (*api.AuthStatusResponse, error)

AuthStatus reports the server's authorization state and the locally available accounts. GET /v1/auth.

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, req api.AuthRequest) (*api.AuthResponse, error)

Authorize creates, restores or selects an account on a server that started unauthorized — or, with Replace on a managed server, switches it to another account in place. POST /v1/auth.

func (c *Client) Backlinks(ctx context.Context, spaceId, objectId string, opts LinkOpts) (*api.BacklinksResponse, error)

Backlinks — GET /v1/spaces/:spaceId/objects/:objectId/backlinks.

func (*Client) BacklinksAll

func (c *Client) BacklinksAll(ctx context.Context, target string, kinds []string, limit int) (*api.BacklinksAllResponse, error)

BacklinksAll — GET /v1/backlinks?target=… across every indexed space.

func (*Client) BlocksCreate

func (c *Client) BlocksCreate(ctx context.Context, spaceId, objectId, collection string, req api.BlockCreateRequest) (*api.ModifyResult, error)

BlocksCreate posts a new block. The server allocates the new block's id (auto-derived from the change CID) and, when nav.pos is empty in the request, fills in the next pos after the parent's current max. Returns the modify result — recordIds[0] is the new block id; read the block back via /query with dataset=editor_blocks.

func (*Client) BlocksDelete

func (c *Client) BlocksDelete(ctx context.Context, spaceId, objectId, collection, blockId string) (*api.ModifyResult, error)

BlocksDelete tombstones one block. Children of the deleted block are NOT cascaded. Returns the modify result (versionId of the tombstone change).

func (*Client) BlocksPatch

func (c *Client) BlocksPatch(ctx context.Context, spaceId, objectId, collection, blockId string, req api.BlockPatchRequest) (*api.ModifyResult, error)

BlocksPatch applies a {set, unset} patch atomically to one block. Empty patch is a no-op returning recordIds=[blockId] with an empty versionId.

func (*Client) BundleChild

func (c *Client) BundleChild(ctx context.Context, spaceId, bundleId string, req api.BundleChildRequest) (*api.BundleChildResponse, error)

BundleChild derives a setup object under the bundle's winner.

func (*Client) BundleEnsure

func (c *Client) BundleEnsure(ctx context.Context, spaceId string, req api.BundleEnsureRequest) (*api.BundleEnsureResponse, error)

BundleEnsure installs or adopts a bundle in a space.

func (*Client) BundleGet

func (c *Client) BundleGet(ctx context.Context, spaceId, bundleId string) (*api.BundleGetResponse, error)

BundleGet reads one bundle row.

func (*Client) BundleList

func (c *Client) BundleList(ctx context.Context, spaceId string) (*api.BundleListResponse, error)

BundleList lists the space's bundles registry.

func (*Client) BundleResolve

func (c *Client) BundleResolve(ctx context.Context, spaceId, bundleId, loserRootId string) error

BundleResolve deletes a losing root after the caller merged it. Returns nil on success (204).

func (*Client) CatalogGet

func (c *Client) CatalogGet(ctx context.Context, usecaseId string) (*api.CatalogUsecase, error)

CatalogGet reads one usecase.

func (*Client) CatalogList

func (c *Client) CatalogList(ctx context.Context) (*api.CatalogListResponse, error)

CatalogList reads the usecase catalog.

func (*Client) CatalogSetup

func (c *Client) CatalogSetup(ctx context.Context, usecaseId, spaceId string) (*api.CatalogSetupResponse, error)

CatalogSetup sets a usecase up in a space, dependencies included.

func (*Client) ChatDelete

func (c *Client) ChatDelete(ctx context.Context, spaceId, objectId, msgId string) (*api.ModifyResult, error)

ChatDelete tombstones a message. 403 if not the original author. Returns the modify result (versionId of the tombstone change).

func (*Client) ChatEdit

func (c *Client) ChatEdit(ctx context.Context, spaceId, objectId, msgId string, req api.ChatEditRequest) (*api.ModifyResult, error)

ChatEdit replaces the text of an existing message. Server-side returns 403 if the caller is not the original author. Returns the modify result (versionId of the edit change).

func (*Client) ChatReact

func (c *Client) ChatReact(ctx context.Context, spaceId, objectId, msgId, emoji string) (*api.ModifyResult, error)

ChatReact toggles the caller's emoji reaction on a message. Returns the modify result (versionId of the toggle change); read the updated reactions back via /query with dataset=chat_messages.

func (*Client) ChatSend

func (c *Client) ChatSend(ctx context.Context, spaceId, objectId string, req api.ChatSendRequest) (*api.ModifyResult, error)

ChatSend posts a new message to the chat object's message stream. Body shape mirrors api.ChatSendRequest. Returns the modify result — recordIds[0] is the server-derived message id; read the record back via /query with dataset=chat_messages.

func (*Client) CollectionAddProperty

func (c *Client) CollectionAddProperty(ctx context.Context, spaceId, collectionId string, req api.AddPropertyRequest) (*api.AddPropertyResponse, error)

CollectionAddProperty mints a new property on a collection. Returns the derived propId.

func (*Client) CollectionGet

func (c *Client) CollectionGet(ctx context.Context, spaceId, collectionId string) (*api.CollectionInfo, error)

CollectionGet reads one collection, hidden ones included.

func (*Client) CollectionListProperties

func (c *Client) CollectionListProperties(ctx context.Context, spaceId, collectionId string) (*api.PropertiesListResponse, error)

CollectionListProperties returns a collection's property definitions.

func (*Client) CollectionPatch

func (c *Client) CollectionPatch(ctx context.Context, spaceId, collectionId string, req api.CollectionPatchRequest) error

CollectionPatch patches a collection's display and listing metadata. Returns nil on success (204).

func (*Client) CollectionPatchProperty

func (c *Client) CollectionPatchProperty(ctx context.Context, spaceId, collectionId, propId string, req api.PropertyPatchRequest) error

CollectionPatchProperty applies a {set, unset} patch to a property definition (rename, option CRUD, colors, order). Returns nil on success (204).

func (*Client) CollectionRemoveProperty

func (c *Client) CollectionRemoveProperty(ctx context.Context, spaceId, collectionId, propId string) error

CollectionRemoveProperty removes a property definition. Returns nil on success (204).

func (*Client) CollectionsCreate

func (c *Client) CollectionsCreate(ctx context.Context, spaceId string, req api.CollectionsCreateRequest) (*api.CollectionsCreateResponse, error)

CollectionsCreate creates a user-defined collection in a space.

func (*Client) CollectionsList

func (c *Client) CollectionsList(ctx context.Context, spaceId string, includeHidden bool) (*api.CollectionsListResponse, error)

CollectionsList lists the collections in a space (built-ins + user-defined). Hidden ones — the built-in miniapp / bin included — come back only with includeHidden.

func (*Client) Datasets

func (c *Client) Datasets(ctx context.Context) (*api.DatasetsResponse, error)

Datasets fetches the account's tech-space system dataset schemas (GET /v1/datasets → Service.Datasets).

func (*Client) Deauthorize

func (c *Client) Deauthorize(ctx context.Context) error

Deauthorize tears the account down in place on a managed server, which stays up unauthorized. DELETE /v1/auth.

func (*Client) DebugObject

func (c *Client) DebugObject(ctx context.Context, spaceId, objectId string) (*api.ObjectDebugResponse, error)

DebugObject fetches the per-object diagnostic snapshot. Triggers a full tree walk on the server (and a cold-restore on first touch); not a hot-poll endpoint.

func (*Client) DebugP2P

func (c *Client) DebugP2P(ctx context.Context) (*api.P2PStatusResponse, error)

DebugP2P fetches the account-wide snapshot of both direct layers: the LAN listener and its discovered peers, and under Global the iroh endpoint, its relay session, the peers records name and the account discovery record.

func (*Client) DebugSpace

func (c *Client) DebugSpace(ctx context.Context, spaceId string) (*api.SpaceDebugResponse, error)

DebugSpace fetches the per-space diagnostic snapshot — outbound headsync counters since boot. In-memory on the server; resets on restart.

func (*Client) DeviceActivate

func (c *Client) DeviceActivate(ctx context.Context, app string) error

DeviceActivate claims the active role for one app slug on THIS device. POST /v1/devices/activate.

func (*Client) DeviceDelete

func (c *Client) DeviceDelete(ctx context.Context, peerId string) error

DeviceDelete prunes a device's registry row. Permanent for that peerId — record tombstones are sticky, so a deleted device can never re-register without re-deriving peer keys. DELETE /v1/devices/:peerId.

func (*Client) DeviceUpdateMe

func (c *Client) DeviceUpdateMe(ctx context.Context, req api.DeviceUpdateRequest) error

DeviceUpdateMe updates THIS device's registry row (name, installed apps). PUT /v1/devices/me.

func (*Client) DevicesList

func (c *Client) DevicesList(ctx context.Context) (*api.DevicesListResponse, error)

DevicesList fetches the account's device registry — one row per device (peer) plus the per-app active winners resolved by the canonical election rule. GET /v1/devices.

func (*Client) DevicesQuery

func (c *Client) DevicesQuery(ctx context.Context, body []byte) (*api.QueryResponse, error)

DevicesQuery runs a windowed snapshot over the raw `devices` rows (POST /v1/devices/query). body carries the standard query fields (filter / sort / limit / offset / includeTotal).

func (*Client) EventsPublish

func (c *Client) EventsPublish(ctx context.Context, req api.EventPublishRequest) (*api.EventPublishResponse, error)

EventsPublish posts one event to the account-wide event bus (POST /v1/events). Returns how many local subscribers matched it (0 = nobody listening; still a success). See docs/21-events.md.

func (*Client) FileAttach

func (c *Client) FileAttach(ctx context.Context, spaceId, objectId string, r io.Reader, opts FileAttachOpts) (*api.FileInfo, error)

FileAttach uploads r as a file bound to objectId — the raw request body IS the file, streamed without buffering.

func (*Client) FileCacheFree

func (c *Client) FileCacheFree(ctx context.Context, bytes int64) (*api.FileCacheFreeResult, error)

FileCacheFree reclaims at least `bytes` of local file cache (LRU, safe-to-drop content only); returns the bytes actually freed.

func (*Client) FileCacheSize

func (c *Client) FileCacheSize(ctx context.Context) (*api.FileCacheInfo, error)

FileCacheSize fetches the local bytes held by file content across all spaces.

func (*Client) FileCacheSweep

func (c *Client) FileCacheSweep(ctx context.Context) error

FileCacheSweep runs one manual file-cache safety pass.

func (*Client) FileDelete

func (c *Client) FileDelete(ctx context.Context, spaceId, fileId string) error

FileDelete removes the file — synced row delete (variants of an original go with it) plus local cleanup. 404 file.not_found for an unknown or already-deleted fileId.

func (*Client) FileDownload

func (c *Client) FileDownload(ctx context.Context, spaceId, fileId, variant string) (*FileDownloadResult, error)

FileDownload opens GET .../files/:fileId/content — the file's plaintext as a raw HTTP body. variant "" downloads the original.

func (*Client) FileGet

func (c *Client) FileGet(ctx context.Context, spaceId, fileId string) (*api.FileInfo, error)

FileGet fetches one file's info (the unsealed member view).

func (*Client) FileList

func (c *Client) FileList(ctx context.Context, spaceId, objectId string, limit int) (*api.FileListResponse, error)

FileList lists the space's files; objectId "" lists everything, limit 0 is unlimited.

func (*Client) FileOffload

func (c *Client) FileOffload(ctx context.Context, spaceId, fileId string) error

FileOffload drops the file's local bytes (refused with 409 file.not_durable while they are the only copy).

func (*Client) FilePin

func (c *Client) FilePin(ctx context.Context, spaceId, fileId string) error

FilePin schedules a full background fetch of the file's content.

func (*Client) FileRetry

func (c *Client) FileRetry(ctx context.Context, spaceId, fileId string) error

FileRetry makes the file's pending background work due immediately.

func (*Client) FileStats

func (c *Client) FileStats(ctx context.Context, spaceId string) (*api.FileStats, error)

FileStats fetches the space's aggregate durability counts.

func (*Client) FileStatus

func (c *Client) FileStatus(ctx context.Context, spaceId, fileId string) (*api.FileStatus, error)

FileStatus fetches one file's durability status.

func (*Client) FilesQuery

func (c *Client) FilesQuery(ctx context.Context, spaceId, objectId string, body []byte) (*api.QueryResponse, error)

FilesQuery runs POST .../objects/:objectId/files/query — a snapshot over the payload rows of one object's files. body carries the standard query fields (filter/sort/limit/offset/includeTotal); nil is a plain full snapshot.

func (*Client) GuestKeyCreate

func (c *Client) GuestKeyCreate(ctx context.Context, spaceId string) (*api.InviteCreateResponse, error)

func (*Client) GuestKeyRevoke

func (c *Client) GuestKeyRevoke(ctx context.Context, spaceId string) error

func (*Client) Health

func (c *Client) Health(ctx context.Context) (*api.HealthResponse, error)

func (*Client) IdentitiesList

func (c *Client) IdentitiesList(ctx context.Context) (*api.IdentitiesListResponse, error)

IdentitiesList fetches the account-global identities directory — every account identity this account has encountered (across spaces, 1-1s, inbox invites), with the last resolved profile and the spaces where each was seen. GET /v1/identities.

func (*Client) IdentityGet

func (c *Client) IdentityGet(ctx context.Context, identity string) (*api.IdentityInfo, error)

IdentityGet fetches a single directory entry by account address. Returns a 404 (identity.not_found) when never encountered. GET /v1/identities/:identity.

func (*Client) InviteCreate

func (c *Client) InviteCreate(ctx context.Context, spaceId string) (*api.InviteCreateResponse, error)

func (*Client) InviteGet

func (c *Client) InviteGet(ctx context.Context, spaceId, recordId string) (*api.InviteInfo, error)

func (*Client) InviteRevoke

func (c *Client) InviteRevoke(ctx context.Context, spaceId, recordId string) error

func (*Client) InvitesList

func (c *Client) InvitesList(ctx context.Context, spaceId string) (*api.InvitesListResponse, error)

func (*Client) InvitesRevokeAll

func (c *Client) InvitesRevokeAll(ctx context.Context, spaceId string) error

func (*Client) JoinRequests

func (c *Client) JoinRequests(ctx context.Context, spaceId string) (*api.JoinRequestsResponse, error)
func (c *Client) Links(ctx context.Context, spaceId, objectId string, opts LinkOpts) (*api.LinksResponse, error)

Links — GET /v1/spaces/:spaceId/objects/:objectId/links.

func (*Client) LocalAggregate

LocalAggregate — POST /v1/local/aggregate.

func (*Client) LocalCollections

func (c *Client) LocalCollections(ctx context.Context, scope, spaceId string) (*api.LocalListResponse, error)

LocalCollections — GET /v1/local/collections. Empty scope lists both scopes; a spaceId alone implies scope=space.

func (*Client) LocalDelete

LocalDelete — POST /v1/local/delete.

func (*Client) LocalDiscovery added in v0.2.3

func (c *Client) LocalDiscovery(ctx context.Context) (*api.LocalDiscoveryResponse, error)

LocalDiscovery reads the local-discovery (mDNS) switch. Works before auth: with no engine up it is what the next boot starts with.

func (*Client) LocalDrop

func (c *Client) LocalDrop(ctx context.Context, coll api.LocalCollection) error

LocalDrop — DELETE /v1/local/collections.

func (*Client) LocalEnsure

LocalEnsure — PUT /v1/local/collections (idempotent).

func (*Client) LocalExport

func (c *Client) LocalExport(ctx context.Context, scope, spaceId string, names []string) (io.ReadCloser, error)

LocalExport — GET /v1/local/export: the named collections as one gzip'd anyenc stream. The caller streams the body and MUST close it. names nil with a scope exports every collection in that scope; both empty, the whole local store.

func (*Client) LocalGet

LocalGet — POST /v1/local/get.

func (*Client) LocalImport

func (c *Client) LocalImport(ctx context.Context, r io.Reader) (*api.LocalImportResponse, error)

LocalImport — POST /v1/local/import: r is an export file, streamed as the raw body.

func (*Client) LocalIndexes

LocalIndexes — POST /v1/local/indexes.

func (*Client) LocalInsert

func (c *Client) LocalInsert(ctx context.Context, req api.LocalDocsRequest) (*api.LocalIdsResponse, error)

LocalInsert — POST /v1/local/insert.

func (*Client) LocalMeta

func (c *Client) LocalMeta(ctx context.Context) (*api.LocalMetaResponse, error)

LocalMeta — GET /v1/local/meta.

func (*Client) LocalQuery

func (c *Client) LocalQuery(ctx context.Context, req api.LocalQueryRequest) (*api.QueryResponse, error)

LocalQuery — POST /v1/local/query.

func (*Client) LocalUpdate

LocalUpdate — POST /v1/local/update.

func (*Client) LocalUpsert

func (c *Client) LocalUpsert(ctx context.Context, req api.LocalDocsRequest) (*api.LocalIdsResponse, error)

LocalUpsert — POST /v1/local/upsert.

func (*Client) MarkdownEdit

func (c *Client) MarkdownEdit(ctx context.Context, spaceId, objectId, collection string, req api.MarkdownEditRequest) (*api.MarkdownSetResponse, error)

MarkdownEdit applies targeted oldText → newText replacements against an object's rendered markdown (PATCH .../editor/markdown).

func (*Client) MembersGet

func (c *Client) MembersGet(ctx context.Context, spaceId, identity string) (*api.Member, error)

func (*Client) MembersList

func (c *Client) MembersList(ctx context.Context, spaceId string) (*api.MembersListResponse, error)

func (*Client) MembersMe

func (c *Client) MembersMe(ctx context.Context, spaceId string) (*api.Member, error)

func (*Client) ObjectAttachCollection

func (c *Client) ObjectAttachCollection(ctx context.Context, spaceId, objectId, collectionId string) (*api.ModifyResult, error)

ObjectAttachCollection files the object under a collection (idempotent), admitting writes to its columns. The `bin` collection is move to bin.

func (*Client) ObjectDetachCollection

func (c *Client) ObjectDetachCollection(ctx context.Context, spaceId, objectId, collectionId string) (*api.ModifyResult, error)

ObjectDetachCollection removes the object from a collection (idempotent); values in that namespace stay as orphan data. Detaching `bin` is restore from the bin.

func (*Client) ObjectSetType

func (c *Client) ObjectSetType(ctx context.Context, spaceId, objectId, typeId string) (*api.ModifyResult, error)

ObjectSetType sets the object's one type, replacing any previous one (its values stay as orphan data). The object must already exist.

func (*Client) ObjectsCreate

func (c *Client) ObjectsCreate(ctx context.Context, spaceId string, req api.ObjectCreateRequest) (*api.ObjectsCreateResponse, error)

ObjectsCreate creates an object from its type, the collections it is filed under and its initial property values. Returns the new object id.

func (*Client) ProcessCancel

func (c *Client) ProcessCancel(ctx context.Context, id string, req api.ProcessCancelRequest) (*api.EventPublishResponse, error)

ProcessCancel calls POST /v1/processes/:id/cancel — address process.cancel at the owner. 404 process.not_found on no live match, 409 process.ambiguous when several identities share the id (pass req.Identity to pick one).

func (*Client) ProcessFinish

func (c *Client) ProcessFinish(ctx context.Context, id string, req api.ProcessFinishRequest) (*api.EventPublishResponse, error)

ProcessFinish calls POST /v1/processes/:id/finish — emit the terminal event (error required iff status failed).

func (*Client) ProcessProgress

func (c *Client) ProcessProgress(ctx context.Context, id string, req api.ProcessProgressRequest) (*api.EventPublishResponse, error)

ProcessProgress calls POST /v1/processes/:id/progress — the progress/heartbeat frame. 404 process.not_found when the process isn't live under this account (register first).

func (*Client) ProcessRegister

func (c *Client) ProcessRegister(ctx context.Context, req api.ProcessRegisterRequest) (*api.EventPublishResponse, error)

ProcessRegister calls POST /v1/processes — register a process and emit process.started on its scope.

func (*Client) ProcessesList

func (c *Client) ProcessesList(ctx context.Context) (*api.ProcessListResponse, error)

ProcessesList calls GET /v1/processes — the live last-event-wins process view (expired entries swept).

func (*Client) PushSubscriptions

func (c *Client) PushSubscriptions(ctx context.Context) (*api.PushSubscriptionsResponse, error)

PushSubscriptions lists the account's topic set as the push server holds it (GET /v1/push/subscriptions) — raw {spaceKey, topic} rows, unsigned; spaceKey is the base58 space push public key, not a spaceId.

func (*Client) PushTokenRevoke

func (c *Client) PushTokenRevoke(ctx context.Context) error

PushTokenRevoke drops this device's token (DELETE /v1/push/token). The local persist is deleted even when the push node is unreachable (best-effort forward). Returns 204.

func (*Client) PushTokenSet

func (c *Client) PushTokenSet(ctx context.Context, req api.PushTokenSetRequest) error

PushTokenSet registers this device's mobile push token (POST /v1/push/token). platform is "ios" or "android"; call again on token rotation. Returns 204 on success; 409 push.disabled when the server has no push node configured.

func (*Client) PushTokenStatus

func (c *Client) PushTokenStatus(ctx context.Context) (*api.PushTokenStatus, error)

PushTokenStatus reads the LOCAL registration state (GET /v1/push/token) — whether a persisted token exists on this device and for which platform. No push-node round trip.

func (*Client) Search

func (c *Client) Search(ctx context.Context, spaceId string, req api.SearchRequest) (*api.SearchResponse, error)

Search runs a local-index search in the space (FTS / vector / hybrid; see docs/13-index.md).

func (*Client) SetLocalDiscovery added in v0.2.3

func (c *Client) SetLocalDiscovery(ctx context.Context, enabled bool) (*api.LocalDiscoveryResponse, error)

SetLocalDiscovery switches mDNS announce and browse on or off and returns the resulting state. A managed server needs the control token (WithControlToken).

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) error

func (*Client) SpaceDatasets

func (c *Client) SpaceDatasets(ctx context.Context, spaceId string) (*api.DatasetsResponse, error)

SpaceDatasets fetches one space's dataset schemas (GET /v1/spaces/:id/datasets → Space.Datasets).

func (*Client) SpaceDelete

func (c *Client) SpaceDelete(ctx context.Context, spaceId string) error

SpaceDelete deletes a space (DELETE /v1/spaces/:id → Service.Delete). Offline-first: the server writes the synced `deleted` tombstone and offloads local state immediately, while the signed coordinator delete is driven in the background. The tech-space row stays in `Service.List` with `status:"deleted"` (sticky tombstone). Returns 204 on success.

func (*Client) SpaceDerivedCreate

func (c *Client) SpaceDerivedCreate(ctx context.Context, name string) (*api.SpaceInfo, error)

SpaceDerivedCreate materializes a well-known derived space by its registry name (POST /v1/spaces/derived/:name → Service.Derive). Idempotent — repeat calls land on the same space.

func (*Client) SpaceDerivedList

func (c *Client) SpaceDerivedList(ctx context.Context) (*api.DerivedSpaceListResponse, error)

SpaceDerivedList fetches the well-known derived-space registry resolved against the account (GET /v1/spaces/derived): per entry the deterministic spaceId and whether it has been materialized yet. Resolving never creates anything.

func (*Client) SpaceGet

func (c *Client) SpaceGet(ctx context.Context, spaceId string) (*api.SpaceInfo, error)

SpaceGet fetches one space's wire-shape info (including spaceIndexObjectId).

func (*Client) SpaceInviteAccept

func (c *Client) SpaceInviteAccept(ctx context.Context, spaceId string) (*api.SpaceInfo, error)

SpaceInviteAccept approves a direct-add invite by space id — POST /v1/spaces/:id/invite/accept → Service.AcceptInvite. 200 returns the loaded space; 202 means accepted with the load continuing in the background (the returned info carries the current status).

func (*Client) SpaceInviteDecline

func (c *Client) SpaceInviteDecline(ctx context.Context, spaceId string) error

SpaceInviteDecline rejects a direct-add invite by space id — POST /v1/spaces/:id/invite/decline → Service.DeclineInvite. Returns 204.

func (*Client) SpaceJoin

func (c *Client) SpaceJoin(ctx context.Context, req api.SpaceJoinRequest) (*api.SpaceInfo, error)

func (*Client) SpaceList

func (c *Client) SpaceList(ctx context.Context, status string) (*api.SpaceListResponse, error)

SpaceList fetches the account's spaces (GET /v1/spaces → Service.List, mapped to []SpaceInfo). An empty status keeps the server default (active-only); pass "all" for every status or a specific status string (e.g. "one_to_one_pending") to filter.

func (*Client) SpaceListQuery

func (c *Client) SpaceListQuery(ctx context.Context, body []byte) (*api.QueryResponse, error)

SpaceListQuery runs a windowed snapshot over the account's space list (POST /v1/spaces/query → Service.Query on the `spaces` dataset). body carries the standard query fields (filter / sort / limit / offset / includeTotal) plus an optional `dataset` override.

func (*Client) SpaceOneToOne

func (c *Client) SpaceOneToOne(ctx context.Context, req api.SpaceOneToOneRequest) (*api.SpaceInfo, error)

SpaceOneToOne opens (initiates or explicitly accepts) a 1-1 (direct) space with the given account identity — POST /v1/spaces/one-to-one → Service.OneToOne. Activates locally; returns the space info.

func (*Client) SpaceOneToOneAccept

func (c *Client) SpaceOneToOneAccept(ctx context.Context, spaceId string) (*api.SpaceInfo, error)

SpaceOneToOneAccept approves an incoming pending 1-1 by space id — POST /v1/spaces/:id/one-to-one/accept → Service.AcceptOneToOne.

func (*Client) SpaceOneToOneDecline

func (c *Client) SpaceOneToOneDecline(ctx context.Context, spaceId string) error

SpaceOneToOneDecline rejects an incoming pending 1-1 by space id — POST /v1/spaces/:id/one-to-one/decline → Service.DeclineOneToOne. Returns 204.

func (*Client) SpaceRegisterIncoming

func (c *Client) SpaceRegisterIncoming(ctx context.Context, req api.SpaceRegisterIncomingRequest) error

SpaceRegisterIncoming records an out-of-band incoming 1-1 request as a pending row — POST /v1/spaces/one-to-one/register-incoming → Service.RegisterIncoming. Returns 204.

func (*Client) SpaceSettingsPatch

func (c *Client) SpaceSettingsPatch(ctx context.Context, spaceId string, req api.SpaceSettingsPatchRequest) error

SpaceSettingsPatch patches the account-private per-space settings object (PATCH /v1/spaces/:id/settings → Spaces().SetSettings): a per-key set/unset of scalar values on the space's tech-space row. Deliberately separate from SpaceUpdate, which writes the member-replicated spaceIndex metadata. Works on any known row — deleted tombstones and pending 1-1s included. Returns 204.

func (*Client) SpaceSync

func (c *Client) SpaceSync(ctx context.Context, spaceId string) error

SpaceSync forces an immediate head-sync round (POST /v1/spaces/:id/sync → Space.SyncHeads). Blocks until the round completes server-side. Use to converge on demand instead of waiting for the periodic headsync timer.

func (*Client) SpaceUpdate

func (c *Client) SpaceUpdate(ctx context.Context, spaceId string, req api.SpaceUpdateRequest) error

SpaceUpdate patches space metadata (name / description / iconCid). Pointer-to-string semantics — only non-nil fields are touched. Returns 204 on success; the spaceIndex mirror to the local tech-space row catches up asynchronously, so a follow-up GET may briefly show stale values.

func (*Client) StreamDevicesQuerySubscribe

func (c *Client) StreamDevicesQuerySubscribe(ctx context.Context, body []byte, fn func(SSEFrame) error) error

StreamDevicesQuerySubscribe opens POST /v1/devices/query/subscribe — the windowed live view over the device registry. An empty body is a full snapshot + live stream.

func (*Client) StreamEvents

func (c *Client) StreamEvents(ctx context.Context, filter url.Values, fn func(SSEFrame) error) error

StreamEvents opens GET /v1/events/subscribe with the given filter params (repeatable keys scope / spaceId / type / target; nil = no filter) and dispatches every SSE frame to fn. Blocks until a `closed` frame, EOF, or ctx cancel. There is no snapshot — only events published after connect are delivered.

func (*Client) StreamFileStatusSubscribe

func (c *Client) StreamFileStatusSubscribe(ctx context.Context, spaceId string, fn func(SSEFrame) error) error

StreamFileStatusSubscribe opens GET /v1/spaces/:spaceId/files/subscribe — SSE of the space's file durability transitions (local ones).

func (*Client) StreamFilesQuerySubscribe

func (c *Client) StreamFilesQuerySubscribe(ctx context.Context, spaceId, objectId string, body []byte, fn func(SSEFrame) error) error

StreamFilesQuerySubscribe opens the live sibling of FilesQuery.

func (*Client) StreamIdentities

func (c *Client) StreamIdentities(ctx context.Context, fn func(SSEFrame) error) error

StreamIdentities opens GET /v1/identities/subscribe — one SSE stream of directory changes (added / updated / removed batches). Blocks until the server sends `closed`, the body returns EOF, or ctx is canceled.

func (*Client) StreamObjectsQuerySubscribe

func (c *Client) StreamObjectsQuerySubscribe(ctx context.Context, spaceId string, body []byte, fn func(SSEFrame) error) error

StreamObjectsQuerySubscribe opens POST /v1/spaces/:spaceId/objects/query/subscribe with body as the query (filter / sort / limit / offset / includeTotal / mailboxCapacity / driftBudgetPercent) and dispatches every SSE frame to fn. Blocks until the server sends a `closed` frame, the body returns EOF, or ctx is canceled.

func (*Client) StreamQuerySubscribe

func (c *Client) StreamQuerySubscribe(ctx context.Context, spaceId string, body []byte, fn func(SSEFrame) error) error

StreamQuerySubscribe opens POST /v1/spaces/:spaceId/query/subscribe with body containing objectId + dataset + standard query fields.

func (*Client) StreamSpaceListQuerySubscribe

func (c *Client) StreamSpaceListQuerySubscribe(ctx context.Context, body []byte, fn func(SSEFrame) error) error

StreamSpaceListQuerySubscribe opens POST /v1/spaces/query/subscribe — the windowed live view over the account's space list. body carries the standard query fields plus an optional `dataset` override; an empty body is a full snapshot + live stream.

func (*Client) StreamSubscribeMembers

func (c *Client) StreamSubscribeMembers(ctx context.Context, spaceId string, fn func(SSEFrame) error) error

StreamSubscribeMembers opens GET /v1/spaces/:spaceId/members/subscribe and dispatches every SSE frame to fn. Blocks until closed or ctx canceled.

func (*Client) StreamSyncStatusAccount

func (c *Client) StreamSyncStatusAccount(ctx context.Context, fn func(SSEFrame) error) error

StreamSyncStatusAccount opens GET /v1/sync-status/subscribe — one SSE stream covering every known space's rollup transitions. Blocks until the server sends `closed`, the body returns EOF, or ctx is canceled.

func (*Client) StreamSyncStatusObject

func (c *Client) StreamSyncStatusObject(ctx context.Context, spaceId, objectId string, fn func(SSEFrame) error) error

StreamSyncStatusObject opens GET /v1/spaces/:spaceId/sync-status/objects/:objectId/subscribe. Per-object state transitions for the given (spaceId, objectId).

func (*Client) SyncStatusObject

func (c *Client) SyncStatusObject(ctx context.Context, spaceId, objectId string) (*api.ObjectSyncStatusResponse, error)

SyncStatusObject fetches the per-object sync state. Unknown ids return State = "unknown" — the SDK is forgiving here; callers that need existence checks should use the object catalog endpoints.

func (*Client) SyncStatusSpace

func (c *Client) SyncStatusSpace(ctx context.Context, spaceId string) (*api.SpaceSyncStatusResponse, error)

SyncStatusSpace fetches the per-space rolled-up sync state. Cheap; safe to poll on render ticks. Use StreamSyncStatusAccount for a push stream covering every known space.

func (*Client) TypeAddDataset

func (c *Client) TypeAddDataset(ctx context.Context, spaceId, typeId, partId string, req api.DatasetDraftRequest) (*api.AddDatasetResponse, error)

TypeAddDataset declares a dataset on a part. Returns the definition id and the computed collection.

func (*Client) TypeAddDatasetField

func (c *Client) TypeAddDatasetField(ctx context.Context, spaceId, typeId, defId string, req api.DatasetFieldDraft) (*api.AddDatasetFieldResponse, error)

TypeAddDatasetField appends a field to a dataset definition. Returns the field definition id.

func (*Client) TypeAddPart

func (c *Client) TypeAddPart(ctx context.Context, spaceId, typeId string, req api.PartDraftRequest) (*api.AddPartResponse, error)

TypeAddPart declares a part (with its datasets) on a type. Returns the part id.

func (*Client) TypeAddProperty

func (c *Client) TypeAddProperty(ctx context.Context, spaceId, typeId string, req api.AddPropertyRequest) (*api.AddPropertyResponse, error)

TypeAddProperty mints a new property on a type. Returns the derived propId.

func (*Client) TypeDatasets

func (c *Client) TypeDatasets(ctx context.Context, spaceId, typeId string) (*api.TypeDatasetsListResponse, error)

TypeDatasets lists a type's runtime dataset definitions.

func (*Client) TypeListProperties

func (c *Client) TypeListProperties(ctx context.Context, spaceId, typeId string) (*api.PropertiesListResponse, error)

TypeListProperties returns a type's property definitions.

func (*Client) TypeParts

func (c *Client) TypeParts(ctx context.Context, spaceId, typeId string) (*api.TypePartsListResponse, error)

TypeParts lists a type's parts with their datasets.

func (*Client) TypePatch

func (c *Client) TypePatch(ctx context.Context, spaceId, typeId string, req api.TypePatchRequest) error

TypePatch patches a type's display and rendering metadata. Returns nil on success (204).

func (*Client) TypePatchDataset

func (c *Client) TypePatchDataset(ctx context.Context, spaceId, typeId, defId string, req api.DatasetPatchRequest) error

TypePatchDataset applies a {set, unset} patch over a dataset definition's mutable leaves. Returns nil on success (204).

func (*Client) TypePatchDatasetField

func (c *Client) TypePatchDatasetField(ctx context.Context, spaceId, typeId, defId, fieldId string, req api.DatasetFieldPatchRequest) error

TypePatchDatasetField applies a {set, unset} patch over one field definition's mutable leaves (name, description, xFormat.*). Returns nil on success (204).

func (*Client) TypePatchPart

func (c *Client) TypePatchPart(ctx context.Context, spaceId, typeId, partId string, req api.PartPatchRequest) error

TypePatchPart applies a {set, unset} patch over a part's display slice. Returns nil on success (204).

func (*Client) TypePatchProperty

func (c *Client) TypePatchProperty(ctx context.Context, spaceId, typeId, propId string, req api.PropertyPatchRequest) error

TypePatchProperty applies a {set, unset} patch to a property definition (rename, option CRUD, colors, order). Returns nil on success (204).

func (*Client) TypeRemoveDataset

func (c *Client) TypeRemoveDataset(ctx context.Context, spaceId, typeId, defId string) error

TypeRemoveDataset removes a dataset definition (record data stays).

func (*Client) TypeRemoveDatasetField

func (c *Client) TypeRemoveDatasetField(ctx context.Context, spaceId, typeId, defId, fieldId string) error

TypeRemoveDatasetField removes one field definition.

func (*Client) TypeRemovePart

func (c *Client) TypeRemovePart(ctx context.Context, spaceId, typeId, partId string) error

TypeRemovePart removes a part and its datasets (record data stays).

func (*Client) TypeRemoveProperty

func (c *Client) TypeRemoveProperty(ctx context.Context, spaceId, typeId, propId string) error

TypeRemoveProperty removes a property definition. Returns nil on success (204).

func (*Client) TypesCreate

func (c *Client) TypesCreate(ctx context.Context, spaceId string, req api.TypesCreateRequest) (*api.TypesCreateResponse, error)

TypesCreate creates a user-defined type in a space.

func (*Client) TypesList

func (c *Client) TypesList(ctx context.Context, spaceId string, includeHidden bool) (*api.TypesListResponse, error)

TypesList lists the types in a space (built-ins + user-defined).

func (*Client) Upsert

func (c *Client) Upsert(ctx context.Context, spaceId string, req api.UpsertRequest) (*api.UpsertResult, error)

Upsert batch-ingests records into an id:user dataset.

func (*Client) WithControlToken

func (c *Client) WithControlToken(token string) *Client

WithControlToken attaches the managed-mode control token to every request the client makes. Returns the client for chaining.

type FileAttachOpts

type FileAttachOpts struct {
	// Name is the user-facing file name (query param).
	Name string
	// Mime is sent as the request Content-Type; empty sends nothing
	// and the server resolves the type from the content and the name
	// (docs/03-api.md § Files, Mime precedence).
	Mime string
	// Variant + VariantOf attach the content as an alternate
	// representation of an existing file on the same object. Both or
	// neither.
	Variant   string
	VariantOf string
}

FileAttachOpts is the client-side metadata of one upload.

type FileDownloadResult

type FileDownloadResult struct {
	Body io.ReadCloser
	Size int64
	Mime string
	// Name is the filename from Content-Disposition ("" when absent).
	Name string
}

FileDownloadResult is an open download: the caller streams Body and MUST Close it. Size is -1 when the server didn't send a length.

type LinkOpts

type LinkOpts struct {
	Record  string
	Dataset string
	Prop    string
	Kinds   []string
	Limit   int
}

LinkOpts narrows a links / backlinks read: one part of the object (Record + Dataset, or Prop), the edge kinds to keep, and a cap.

type QuerySubscribeFrame

type QuerySubscribeFrame struct {
	Type     string
	Ready    *api.SubscribeReady
	Snapshot *api.QuerySubscribeSnapshot
	Changes  []api.QuerySubscribeEvent
	Closed   *api.SubscribeClosed
}

QuerySubscribeFrame is a typed view over an SSEFrame from a query/subscribe stream. Exactly one of Ready/Snapshot/Changes/Closed is non-nil. Unknown event types pass through with Type set to the raw event name and Data unset — additive future events stay consumable without a client update.

type SSEFrame

type SSEFrame struct {
	Event string
	Id    string
	Data  []byte
}

SSEFrame is one parsed Server-Sent Events frame. Comment frames (lines starting with `:`) are skipped by StreamSSE; only data frames surface here. Event is the value of the `event:` line ("" if the server omitted it). Id is the value of the `id:` line. Data is the joined `data:` lines, newline-separated when there were several.

type ServerError

type ServerError struct {
	Status int
	API    api.APIError
}

ServerError is a 4xx/5xx response parsed out of the canonical envelope. Maps to CLI exit code 1 (4xx) or 2 (5xx).

func (*ServerError) Error

func (e *ServerError) Error() string

func (*ServerError) IsClient

func (e *ServerError) IsClient() bool

func (*ServerError) IsServer

func (e *ServerError) IsServer() bool

type TransportError

type TransportError struct {
	Addr string
	Err  error
}

TransportError wraps any failure to reach the server (connection refused, DNS, timeout). Maps to CLI exit code 3.

func (*TransportError) Error

func (e *TransportError) Error() string

func (*TransportError) IsConnectionRefused

func (e *TransportError) IsConnectionRefused() bool

IsConnectionRefused reports whether the transport error is "server not running" as opposed to a mid-flight network failure. The CLI prints a specific hint in that case.

func (*TransportError) Unwrap

func (e *TransportError) Unwrap() error

Jump to

Keyboard shortcuts

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