This commit is contained in:
Xu Chang 2022-04-24 19:54:56 +08:00
commit d2e64f8373
3 changed files with 1 additions and 46 deletions

12
lib/context.d.ts vendored
View File

@ -1,12 +0,0 @@
import { Context as ContextInterface } from 'oak-domain/lib/types/Context';
import { EntityDict, OpRecord } from 'oak-domain/lib/types/Entity';
import TreeStore from './store';
export declare class Context<ED extends EntityDict> implements ContextInterface<ED> {
rowStore: TreeStore<ED>;
uuid?: string;
opRecords: OpRecord<ED>[];
constructor(store: TreeStore<ED>);
begin(options?: object): Promise<void>;
commit(): Promise<void>;
rollback(): Promise<void>;
}

View File

@ -1,33 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
const uuid_1 = require("uuid");
class Context {
rowStore;
uuid;
opRecords;
constructor(store) {
this.rowStore = store;
this.opRecords = [];
}
async begin(options) {
if (!this.uuid) {
const random = await getRandomValues(16);
this.uuid = (0, uuid_1.v4)({ random });
this.rowStore.begin(this.uuid);
}
}
async commit() {
if (this.uuid) {
this.rowStore.commit(this.uuid);
this.uuid = undefined;
}
}
async rollback() {
if (this.uuid) {
this.rowStore.rollback(this.uuid);
this.uuid = undefined;
}
}
}
exports.Context = Context;

View File

@ -13,7 +13,7 @@
"build": "tsc",
"postinstall": "npm link oak-domain"
},
"main": "src/index",
"main": "lib/index",
"devDependencies": {
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",