针对runtimeContext结构变化的一些适配
This commit is contained in:
parent
351a577f8a
commit
897a22c177
|
|
@ -5,7 +5,7 @@ export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt exten
|
|||
private dbStore;
|
||||
private aspectDict;
|
||||
private contextBuilder;
|
||||
constructor(path: string, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, dbConfig: MySQLConfiguration);
|
||||
constructor(path: string, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, dbConfig: MySQLConfiguration);
|
||||
mount(initialize?: true): Promise<void>;
|
||||
unmount(): Promise<void>;
|
||||
execAspect(name: string, context: Cxt, params?: any): Promise<any>;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class AppLoader extends types_1.AppLoader {
|
|||
async initialize(dropIfExists) {
|
||||
await this.dbStore.initialize(dropIfExists);
|
||||
const { data } = require(`${this.path}/lib/data/index`);
|
||||
const context = this.contextBuilder()(this.dbStore);
|
||||
const context = await this.contextBuilder()(this.dbStore);
|
||||
await context.begin();
|
||||
for (const entity in data) {
|
||||
let rows = data[entity];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|||
import { MySQLConfiguration } from 'oak-db/lib/MySQL/types/Configuration';
|
||||
export declare class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends MysqlStore<ED, Cxt> {
|
||||
private executor;
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, mysqlConfiguration: MySQLConfiguration);
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, mysqlConfiguration: MySQLConfiguration);
|
||||
protected cascadeUpdate<T extends keyof ED>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
|
||||
protected cascadeSelect<T extends keyof ED, S extends ED[T]["Selection"]>(entity: T, selection: S, context: Cxt, option: MySqlSelectOption): Promise<SelectRowShape<ED[T]['Schema'], S['data']>[]>;
|
||||
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DbStore extends oak_db_1.MysqlStore {
|
|||
executor;
|
||||
constructor(storageSchema, contextBuilder, mysqlConfiguration) {
|
||||
super(storageSchema, mysqlConfiguration);
|
||||
this.executor = new TriggerExecutor_1.TriggerExecutor(async (scene) => contextBuilder(scene)(this));
|
||||
this.executor = new TriggerExecutor_1.TriggerExecutor((scene) => contextBuilder(scene)(this));
|
||||
}
|
||||
async cascadeUpdate(entity, operation, context, option) {
|
||||
if (!option.blockTrigger) {
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
export { Context as BackendContext } from './BackendContext';
|
||||
export { AppLoader } from './AppLoader';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppLoader = exports.BackendContext = void 0;
|
||||
var BackendContext_1 = require("./BackendContext");
|
||||
Object.defineProperty(exports, "BackendContext", { enumerable: true, get: function () { return BackendContext_1.Context; } });
|
||||
exports.AppLoader = void 0;
|
||||
var AppLoader_1 = require("./AppLoader");
|
||||
Object.defineProperty(exports, "AppLoader", { enumerable: true, get: function () { return AppLoader_1.AppLoader; } });
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
"mysql2": "^2.3.3",
|
||||
"oak-db": "file:../oak-db",
|
||||
"oak-domain": "file:../oak-domain",
|
||||
"oak-general-business": "file:../oak-general-business",
|
||||
"oak-common-aspect": "file:../oak-common-aspect",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ function initTriggers<ED extends EntityDict & BaseEntityDict, Cxt extends Contex
|
|||
export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends GeneralAppLoader<ED, Cxt> {
|
||||
private dbStore: DbStore<ED, Cxt>;
|
||||
private aspectDict: Record<string, Aspect<ED, Cxt>>;
|
||||
private contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt;
|
||||
constructor(path: string, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, dbConfig: MySQLConfiguration) {
|
||||
private contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>;
|
||||
constructor(path: string, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, dbConfig: MySQLConfiguration) {
|
||||
super(path);
|
||||
const { storageSchema } = require(`${path}/lib/oak-app-domain/Storage`);
|
||||
this.aspectDict = Object.assign({}, generalAspectDict, require(`${path}/lib/aspects/index`).aspectDict);
|
||||
|
|
@ -74,7 +74,7 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Conte
|
|||
await this.dbStore.initialize(dropIfExists);
|
||||
|
||||
const { data } = require(`${this.path}/lib/data/index`);
|
||||
const context = this.contextBuilder()(this.dbStore);
|
||||
const context = await this.contextBuilder()(this.dbStore);
|
||||
await context.begin();
|
||||
for (const entity in data) {
|
||||
let rows = data[entity];
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import { MySQLConfiguration, } from 'oak-db/lib/MySQL/types/Configuration';
|
|||
export class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends MysqlStore<ED, Cxt> {
|
||||
private executor: TriggerExecutor<ED, Cxt>;
|
||||
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, mysqlConfiguration: MySQLConfiguration) {
|
||||
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, mysqlConfiguration: MySQLConfiguration) {
|
||||
super(storageSchema, mysqlConfiguration);
|
||||
this.executor = new TriggerExecutor(async (scene) => contextBuilder(scene)(this));
|
||||
this.executor = new TriggerExecutor((scene) => contextBuilder(scene)(this));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
export { Context as BackendContext } from './BackendContext';
|
||||
export { AppLoader } from './AppLoader';
|
||||
Loading…
Reference in New Issue