Skip to main content

@docstack/client

Classes

ClassDescription
AttributeRepresents a single attribute (field) within a Class schema.
ClassRepresents a data class (schema definition) in the DocStack database.
ClientStackThe core database engine for DocStack client applications.
DocStackThe main entry point for the DocStack client library.
DocStackSyncHandleEvery stack's replication under one object.
DomainRepresents a relationship definition between two Classes in the DocStack database.
JobEngineEngine for executing background jobs in the DocStack system.
JobSchedulerDecides when the jobs an application has approved should run, and dispatches them.
StackLockedErrorRaised when a locked stack is asked to write a class carrying encrypted attributes.
StackScopeMismatchErrorA write whose ~scope label disagrees with its sealed payloads' key ids (spec 02 §2.3 rule 2). Refused, never repaired: re-sealing content the writer could not open under the labeled scope's key is exactly the induced-downgrade attack a tampered label is fishing for. A legitimate relabel opens the original scope first, so its payloads arrive as plaintext.
StackSyncHandleOne stack's replication: its lifecycle, its filter, and its convergence state.
StackWriteGuardErrorRaised when application code tries to write around a stack's authoring path.
SyncSchemaMismatchErrorRaised when a remote is ahead of this device's data model.
TransactionConflictErrorRaised by commit when a staged document's base revision no longer matches the stored winner - a direct write, another transaction's commit, or replication moved it. Nothing is written; the transaction stays open for re-staging or discard.
TransactionDbThe handle's db-like surface. Writes stage; reads overlay. Not a Proxy over the guarded db on purpose: this object has no adapter methods or escape hatches to forward, so staging cannot become a fourth door around the authoring path.
TransactionEngineNamed write transactions for one stack (ADR-0039).
TransactionHandleOne transaction: a private write journal plus a read view that overlays it on committed state (ADR-0039).
TransactionsDisabledErrorRaised by beginTransaction() on a stack opened without transactions: true.
TransactionStateErrorRaised when a handle is used in a state that cannot accept the operation.
TransactionUnsupportedDocErrorRaised at stage time for documents transactions cannot carry: class models (their write propagates to other documents mid-pipeline and cannot be staged or rolled back - ADR-0039), _local/ device state, and design documents.
TransactionValidationErrorRaised when the validation sweep refuses a document - at stage time (the write is not staged) or at commit time (nothing is written, the transaction stays open).
TriggerThe Trigger class dynamically hydrates a function from a string. This allows for declarative, data-driven logic to be executed at runtime.

Interfaces

InterfaceDescription
ClassFilterOptionsWhich classes replicate.
ClassModelDocument-modelling types, re-exported from @docstack/shared.
ContentExportA stack's content, portable to another stack.
ContentExportOptionsControls what ClientStack.exportContent collects.
ContentImportIssueOne document that could not be imported, or that was changed on the way in.
ContentImportOptionsControls how ClientStack.importContent reconciles against the datamodel.
ContentImportReportWhat an import did, per category.
DocStackSyncOptionsOptions for DocStack.sync, which starts one handle per stack.
DomainModelDocument-modelling types, re-exported from @docstack/shared.
InternalDocFilterOptionsOptions controlling which of DocStack's own documents stay on this device.
JobScheduleStatePer-job bookkeeping, as stored in JOB_SCHEDULE_DOC_ID.
PatchDocument-modelling types, re-exported from @docstack/shared.
SchedulerHostWhat the scheduler needs from a stack. Narrow on purpose, so it can be tested without one.
SchedulerOptions-
StackSyncOptionsOptions for ClientStack.sync.
SyncMetaDocThe contents of SYNC_META_DOC_ID.
SyncStatusA point-in-time reading of one stack's replication.
TenantScopeA channel's entitlement, compiled into sync configuration.
TickReport-
TriggerModelDocument-modelling types, re-exported from @docstack/shared.

Type Aliases

Type AliasDescription
AttributeModelDocument-modelling types, re-exported from @docstack/shared.
AttributeTypeDocument-modelling types, re-exported from @docstack/shared.
AttributeTypeConfigDocument-modelling types, re-exported from @docstack/shared.
ClassBuildOptionsHow a Class instance should be built.
ClientCredentialsDocument-modelling types, re-exported from @docstack/shared.
DocstackReadyDocument-modelling types, re-exported from @docstack/shared.
DocumentDocument-modelling types, re-exported from @docstack/shared.
EncryptedPayload-
ParsedScheduleA schedule string after parsing. source is kept so callers can report what they read.
PatchJobA one-shot job carried by a patch (ADR-0044): preApply massages data so the patch's model can validate, postApply backfills what needs the model landed. Never persisted as a ~Job - a migration is not a schedulable job, and replicable executable content keeps its one existing surface.
RelationDocumentDocument-modelling types, re-exported from @docstack/shared.
RemoteResolverHow a stack finds its remote.
SelectASTDocument-modelling types, re-exported from @docstack/shared.
SkipReasonWhy a due-looking job was not dispatched. Reported rather than thrown.
StackConfigDocument-modelling types, re-exported from @docstack/shared.
StackOptionsDocument-modelling types, re-exported from @docstack/shared.
SyncDirectionWhich way documents move.
SyncStateWhere a stack's replication currently stands.
TransactionCommitReportWhat one commit did, and on what guarantee.
TransactionStatus-
UnionASTDocument-modelling types, re-exported from @docstack/shared.

Variables

VariableDescription
CONTENT_EXPORT_FORMATThe envelope format identifier, so an importer can refuse what it does not understand.
DATA_MODEL_CLASSESClasses that describe the stack itself rather than its subject matter.
INTERNAL_DOC_CLASSES~class values whose documents describe device-local state.
INTERNAL_DOC_ID_PREFIXESIdentifier prefixes that mark a document as device-local.
INTERNAL_DOC_IDSDocument identifiers that are device-local in full.
JOB_SCHEDULE_DOC_IDThe _local/ document holding this device's schedule state. Never replicates.
META_CLASSES~class values that describe the stack rather than hold its content.
OPTIONAL_INTERNAL_DOC_CLASSES~class values that are device-local by default but that a caller may choose to replicate. Sessions belong to the device that authenticated; the patch ledger is written by whichever device applied the patch, and patches themselves ship with the application code rather than through the database.
SYNC_META_DOC_IDThe document DocStack keeps on a remote to record which schema wrote it.
SYSTEM_SEEDED_DOC_IDSEvery document id the system patches seed.

Functions

FunctionDescription
classTenantsNormalizes a class model's tenant declaration.
collectQueryClassesCollects the class names a parsed query reads.
createClassFilterBuilds a class-level replication filter.
createReplicationFilterBuilds the replication filter DocStack passes to PouchDB.
deriveKeyIdDerives the stable identifier of a document key.
deriveTenantScopeCompiles an entitlement into the stacks it reaches and the class rules it needs.
describeFilterBuilds the identity string for a filter of a given kind and configuration.
hasClassRulesReports whether a set of options would filter anything at all.
isContentClassNameReports whether a class name belongs to application content.
isContentDocumentReports whether a document is application content rather than part of the stack.
isContentRelationReports whether a document is an application relation.
isEncryptedPayloadThe sync layer: lifecycle, filtering, convergence state and the schema gate.
isInternalDocReports whether a document describes device-local state rather than stack data.
nextOccurrenceThe first moment this schedule comes due strictly after from.
parseScheduleReads a schedule string, or returns null when it is not one.
publishSchemaVersionRecords this device's schema version on a remote, if it is the newest seen.
readRemoteConsumerSchemaVersionReads the highest consumer patch version recorded on a remote.
readRemoteSchemaVersionReads the schema version a remote was last written with.
resolveInternalClassesResolves the full set of device-local classes for a given set of options.
withFilterIdentityReplaces a filter's toString with a stable, configuration-derived identity.

References

default

Renames and re-exports DocStack