Skip to content

Class: ActiveRecordSession ​

Defined in: application/services/records/active-record-session.ts:26

Entry point for the active-record API. Wraps workspaces returned by the workspace service in WorkspaceRecord objects bound to the supplied services.

Example ​

ts
const container = new ServiceContainer({
    workspace: new IndexedDBWorkspaceService(),
    documents: new IndexedDBDocumentService(),
});
const session = createActiveRecordSession({
    workspaceService: new WorkspaceApplicationService(container),
    documentService: new DocumentApplicationService(container),
    validationService: new ValidationApplicationService(container),
    transformationService: new TransformationApplicationService(),
});
const workspace = await session.initializeWorkspace({ name: 'My workspace', owner: 'me', profiles });
const doc = await workspace.createDocument(profiles[0].id);
const markdown = await doc.exportMarkdown();

Constructors ​

Constructor ​

ts
new ActiveRecordSession(services): ActiveRecordSession;

Defined in: application/services/records/active-record-session.ts:30

Parameters ​

ParameterTypeDescription
servicesActiveRecordServicesApplication services the records delegate to.

Returns ​

ActiveRecordSession

Methods ​

getWorkspace() ​

ts
getWorkspace(): Promise<WorkspaceRecord>;

Defined in: application/services/records/active-record-session.ts:43

Load the current workspace from storage and return it as a record.

Returns ​

Promise<WorkspaceRecord>


initializeWorkspace() ​

ts
initializeWorkspace(config): Promise<WorkspaceRecord>;

Defined in: application/services/records/active-record-session.ts:35

Create and persist a new workspace from config and return it as a record.

Parameters ​

ParameterType
configWorkspaceFactoryConfig

Returns ​

Promise<WorkspaceRecord>