Documentation
¶
Overview ¶
Package protocol defines stable JSON envelopes shared by Ridu's HTTP API, generated TypeScript contracts, Fetch SDK, and admin.
Index ¶
- Constants
- type APIKey
- type APIKeyEnvelope
- type APIKeyInfo
- type APIKeysEnvelope
- type AccessCapabilitiesEnvelope
- type AuthActionEnvelope
- type AuthBootstrapEnvelope
- type AuthSession
- type AuthSessionInfo
- type AuthSessionsEnvelope
- type BulkEnvelope
- type CollectionSelectionEnvelope
- type CollectionSelectionInput
- type CollectionSelectionItem
- type CountEnvelope
- type DeleteEnvelope
- type DocumentEnvelope
- type DocumentLock
- type DocumentLockEnvelope
- type ErrorCode
- type ErrorEnvelope
- type ErrorPayload
- type FieldCapabilities
- type JoinMutationEnvelope
- type JoinMutationInput
- type LiveValidationEmbeddedScope
- type LiveValidationEnvelope
- type LiveValidationEvaluation
- type LiveValidationRequest
- type LogoutEnvelope
- type OperationCapabilities
- type PageEnvelope
- type Pagination
- type PreferenceEnvelope
- type PreviewToken
- type PreviewTokenEnvelope
- type ScheduledPublish
- type ScheduledPublishEnvelope
- type ScheduledPublishesEnvelope
- type SchemaEnvelope
- type SessionEnvelope
- type ValidationIssue
Constants ¶
const CurrentVersion uint32 = 1
CurrentVersion is the framework wire-protocol version. It changes independently from the schema manifest and project-command protocols.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
ID string `json:"id"`
Name string `json:"name"`
Key string `json:"key"`
CreatedAt string `json:"createdAt"`
ExpiresAt string `json:"expiresAt,omitempty"`
}
APIKey contains a newly generated bearer secret. Key is emitted only once.
type APIKeyEnvelope ¶
type APIKeyEnvelope struct {
APIKey APIKey `json:"apiKey"`
}
APIKeyEnvelope returns a newly minted API key.
type APIKeyInfo ¶
type APIKeyInfo struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"createdAt"`
LastUsedAt string `json:"lastUsedAt,omitempty"`
ExpiresAt string `json:"expiresAt,omitempty"`
}
APIKeyInfo is safe metadata for an existing API key.
type APIKeysEnvelope ¶
type APIKeysEnvelope struct {
APIKeys []APIKeyInfo `json:"apiKeys"`
}
APIKeysEnvelope lists safe API key metadata.
type AccessCapabilitiesEnvelope ¶
type AccessCapabilitiesEnvelope struct {
Operations OperationCapabilities `json:"operations"`
Fields map[string]FieldCapabilities `json:"fields"`
}
AccessCapabilitiesEnvelope carries the evaluated access state for the current actor and optional document/input snapshot.
type AuthActionEnvelope ¶
type AuthActionEnvelope struct {
Success bool `json:"success"`
}
AuthActionEnvelope acknowledges a recovery or verification operation without disclosing whether an identity exists.
type AuthBootstrapEnvelope ¶
type AuthBootstrapEnvelope struct {
Available bool `json:"available"`
}
AuthBootstrapEnvelope reports whether the configured admin-user collection can still accept its one anonymous first-user initialization.
type AuthSession ¶
type AuthSession[User any] struct { // ID is the safe, non-secret identifier used for session management. ID string `json:"id"` // Collection is the auth-enabled collection that owns the user identity. Collection string `json:"collection"` // User is the current authenticated document. User User `json:"user"` // ExpiresAt is the session's RFC 3339 expiry timestamp. ExpiresAt string `json:"expiresAt"` }
AuthSession contains framework-level session metadata and a typed user.
type AuthSessionInfo ¶
type AuthSessionInfo struct {
ID string `json:"id"`
CreatedAt string `json:"createdAt"`
LastSeenAt string `json:"lastSeenAt"`
ExpiresAt string `json:"expiresAt"`
IPAddress string `json:"ipAddress,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Current bool `json:"current"`
}
AuthSessionInfo is safe device/session metadata. It never exposes a bearer token or token digest.
type AuthSessionsEnvelope ¶
type AuthSessionsEnvelope struct {
Sessions []AuthSessionInfo `json:"sessions"`
}
AuthSessionsEnvelope lists the current user's active sessions.
type BulkEnvelope ¶
type BulkEnvelope[Document any] struct { Docs []Document `json:"docs"` }
BulkEnvelope contains the documents changed by one atomic bulk operation.
type CollectionSelectionEnvelope ¶
type CollectionSelectionEnvelope struct {
Items []CollectionSelectionItem `json:"items"`
TotalDocs int `json:"totalDocs"`
}
CollectionSelectionEnvelope contains one complete bounded selection.
type CollectionSelectionInput ¶
type CollectionSelectionInput struct {
Where json.RawMessage `json:"where,omitempty"`
Trash bool `json:"trash,omitempty"`
}
CollectionSelectionInput carries the active list predicate to the bounded server-owned selection resolver.
type CollectionSelectionItem ¶
type CollectionSelectionItem struct {
ID string `json:"id"`
Access AccessCapabilitiesEnvelope `json:"access"`
}
CollectionSelectionItem freezes one read-visible ID and the capabilities used only to present its available authoring actions.
type CountEnvelope ¶
type CountEnvelope struct {
TotalDocs int `json:"totalDocs"`
}
CountEnvelope is the exact cardinality after caller and access filters.
type DeleteEnvelope ¶
DeleteEnvelope confirms a document deletion.
type DocumentEnvelope ¶
type DocumentEnvelope[Document any] struct { Doc Document `json:"doc"` }
DocumentEnvelope contains one typed document.
type DocumentLock ¶
type DocumentLock struct {
DocumentID string `json:"documentId"`
OwnerID string `json:"ownerId"`
OwnerLabel string `json:"ownerLabel"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
ExpiresAt string `json:"expiresAt"`
}
DocumentLock is the safe author identity and lease metadata shown in the admin.
type DocumentLockEnvelope ¶
type DocumentLockEnvelope struct {
Lock *DocumentLock `json:"lock"`
Owned bool `json:"owned"`
Acquired bool `json:"acquired"`
CanTakeOver bool `json:"canTakeOver"`
}
DocumentLockEnvelope carries the current lock and current-actor capabilities.
type ErrorCode ¶
type ErrorCode string
ErrorCode is a stable machine-readable failure category.
const ( ErrorValidation ErrorCode = "validation" ErrorAccess ErrorCode = "access_denied" ErrorNotFound ErrorCode = "not_found" ErrorConflict ErrorCode = "conflict" ErrorDeleteRestricted ErrorCode = "delete_restricted" ErrorBadRequest ErrorCode = "bad_request" ErrorInternal ErrorCode = "internal" ErrorRateLimited ErrorCode = "rate_limited" ErrorEmailNotVerified ErrorCode = "email_not_verified" ErrorAuthFeatureDisabled ErrorCode = "auth_feature_disabled" ErrorInvalidAuthToken ErrorCode = "invalid_auth_token" ErrorInvalidPreviewToken ErrorCode = "invalid_preview_token" ErrorSelectionTooLarge ErrorCode = "selection_too_large" )
type ErrorEnvelope ¶
type ErrorEnvelope struct {
Error ErrorPayload `json:"error"`
}
ErrorEnvelope is returned for every failed HTTP operation.
type ErrorPayload ¶
type ErrorPayload struct {
Code ErrorCode `json:"code"`
Status int `json:"status"`
Message string `json:"message"`
RequestID string `json:"requestId,omitempty"`
Issues []ValidationIssue `json:"issues"`
Details json.RawMessage `json:"details,omitempty"`
}
ErrorPayload is the stable structured error carried by ErrorEnvelope.
type FieldCapabilities ¶
type FieldCapabilities struct {
Read bool `json:"read"`
Create bool `json:"create"`
Update bool `json:"update"`
}
FieldCapabilities summarizes field visibility and write access. Keys in an AccessCapabilitiesEnvelope are authored or concrete runtime field paths.
type JoinMutationEnvelope ¶
type JoinMutationEnvelope[Document any] struct { Doc Document `json:"doc"` Added int `json:"added"` Removed int `json:"removed"` }
JoinMutationEnvelope reports the refreshed source and applied target deltas.
type JoinMutationInput ¶
type JoinMutationInput struct {
Additions []string `json:"additions"`
Removals []string `json:"removals"`
}
JoinMutationInput carries explicit inverse-relation deltas. It deliberately does not imply that the caller loaded the complete relationship set.
type LiveValidationEmbeddedScope ¶ added in v0.2.0
type LiveValidationEmbeddedScope struct {
Field string `json:"field"`
TreeKey string `json:"treeKey"`
CaseTag string `json:"caseTag"`
VariantSlug string `json:"variantSlug"`
Identity string `json:"identity"`
Data store.Values `json:"data"`
}
LiveValidationEmbeddedScope selects a declared plugin payload being edited before Apply. Chained field paths are relative to the previous payload. Identity is the item's ordinary stable key, never an internal occurrence ID.
type LiveValidationEnvelope ¶ added in v0.2.0
type LiveValidationEnvelope struct {
Evaluations []LiveValidationEvaluation `json:"evaluations"`
}
LiveValidationEnvelope carries advisory feedback, not authorization or a promise that a future save will pass authoritative validation.
type LiveValidationEvaluation ¶ added in v0.2.0
type LiveValidationEvaluation struct {
Path string `json:"path"`
Target string `json:"target,omitempty"`
Status string `json:"status"`
Issues []ValidationIssue `json:"issues"`
}
LiveValidationEvaluation distinguishes a completed check from unavailable typed input. A skipped check makes no claim that the input is valid.
type LiveValidationRequest ¶ added in v0.2.0
type LiveValidationRequest struct {
// ID selects an existing collection document. Global requests must omit it.
ID string `json:"id,omitempty"`
Data store.Values `json:"data"`
Fields []string `json:"fields"`
Embedded []LiveValidationEmbeddedScope `json:"embedded,omitempty"`
}
LiveValidationRequest asks for explicitly enabled advisory checks of an unsaved snapshot. It cannot save, initialize defaults or run mutation hooks. Field paths refer to the submitted snapshot and are validated by the server.
type LogoutEnvelope ¶
type LogoutEnvelope struct {
LoggedOut bool `json:"loggedOut"`
}
LogoutEnvelope confirms that the current session was cleared.
type OperationCapabilities ¶
type OperationCapabilities struct {
Admin bool `json:"admin"`
Create bool `json:"create"`
Read bool `json:"read"`
ReadVersions bool `json:"readVersions"`
Update bool `json:"update"`
Delete bool `json:"delete"`
Duplicate bool `json:"duplicate"`
Publish bool `json:"publish"`
Unpublish bool `json:"unpublish"`
RestoreDeleted bool `json:"restoreDeleted"`
DeletePermanent bool `json:"deletePermanent"`
SelectAll bool `json:"selectAll"`
}
OperationCapabilities is a non-secret summary of operations the current actor may attempt for one resource or document. It never contains access predicates or executable authorization rules.
type PageEnvelope ¶
type PageEnvelope[Document any] struct { Docs []Document `json:"docs"` Pagination Pagination `json:"pagination"` }
PageEnvelope contains one page of typed documents.
type Pagination ¶
type Pagination struct {
Page int `json:"page"`
Limit int `json:"limit"`
TotalDocs int `json:"totalDocs"`
TotalPages int `json:"totalPages"`
HasNextPage bool `json:"hasNextPage"`
HasPrevPage bool `json:"hasPrevPage"`
}
Pagination contains stable page metadata independent of a document type.
type PreferenceEnvelope ¶
type PreferenceEnvelope[Value any] struct { Value Value `json:"value"` }
PreferenceEnvelope carries one opaque user-owned preference value.
type PreviewToken ¶
type PreviewToken struct {
Token string `json:"token"`
Resource string `json:"resource"`
Slug string `json:"slug"`
DocumentID string `json:"documentId"`
ExpiresAt string `json:"expiresAt"`
}
PreviewToken is a short-lived read-only capability scoped to one resource.
type PreviewTokenEnvelope ¶
type PreviewTokenEnvelope struct {
PreviewToken PreviewToken `json:"previewToken"`
}
PreviewTokenEnvelope carries a newly minted preview capability exactly once.
type ScheduledPublish ¶
type ScheduledPublish struct {
ID string `json:"id"`
DocumentID string `json:"documentId"`
ExpectedRevision int `json:"expectedRevision"`
RunAt string `json:"runAt"`
Attempts int `json:"attempts"`
LastError string `json:"lastError,omitempty"`
CreatedAt string `json:"createdAt"`
}
ScheduledPublish is the safe public representation of one queued publish. Requesting auth identities are deliberately not exposed.
type ScheduledPublishEnvelope ¶
type ScheduledPublishEnvelope struct {
ScheduledPublish ScheduledPublish `json:"scheduledPublish"`
}
type ScheduledPublishesEnvelope ¶
type ScheduledPublishesEnvelope struct {
ScheduledPublishes []ScheduledPublish `json:"scheduledPublishes"`
}
type SchemaEnvelope ¶
SchemaEnvelope exposes the resolved declarative schema to trusted tooling and the admin. It never contains executable authorization or secrets.
type SessionEnvelope ¶
type SessionEnvelope[User any] struct { Session AuthSession[User] `json:"session"` }
SessionEnvelope contains the current typed auth session.
type ValidationIssue ¶
type ValidationIssue struct {
Code string `json:"code"`
Path string `json:"path"`
Message string `json:"message"`
// Target is an opaque schema/stable-occurrence correlation token for structured field issues.
Target string `json:"target,omitempty"`
FieldID schema.StableID `json:"fieldId,omitempty"`
CollectionID schema.StableID `json:"collectionId,omitempty"`
GlobalID schema.StableID `json:"globalId,omitempty"`
Locale schema.LocaleCode `json:"locale,omitempty"`
}
ValidationIssue identifies one invalid input path.