oak-backend-base 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt exten
5
5
  private dbStore;
6
6
  private aspectDict;
7
7
  private contextBuilder;
8
- constructor(path: string, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, dbConfig: MySQLConfiguration);
8
+ constructor(path: string, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, dbConfig: MySQLConfiguration);
9
9
  mount(initialize?: true): Promise<void>;
10
10
  unmount(): Promise<void>;
11
11
  execAspect(name: string, context: Cxt, params?: any): Promise<any>;
package/lib/AppLoader.js CHANGED
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AppLoader = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const actionDef_1 = require("oak-domain/lib/store/actionDef");
6
+ const checkers_1 = require("oak-domain/lib/checkers");
7
+ const triggers_1 = require("oak-domain/lib/triggers");
6
8
  const types_1 = require("oak-domain/lib/types");
7
9
  const DbStore_1 = require("./DbStore");
8
10
  const index_1 = tslib_1.__importDefault(require("oak-common-aspect/lib/index"));
@@ -15,6 +17,10 @@ function initTriggers(dbStore, path) {
15
17
  adTriggers.forEach((trigger) => dbStore.registerTrigger(trigger));
16
18
  checkers.forEach((checker) => dbStore.registerChecker(checker));
17
19
  adCheckers.forEach((checker) => dbStore.registerChecker(checker));
20
+ const dynamicCheckers = (0, checkers_1.createDynamicCheckers)(dbStore.getSchema());
21
+ dynamicCheckers.forEach((checker) => dbStore.registerChecker(checker));
22
+ const dynamicTriggers = (0, triggers_1.createDynamicTriggers)(dbStore.getSchema());
23
+ dynamicTriggers.forEach((trigger) => dbStore.registerTrigger(trigger));
18
24
  }
19
25
  class AppLoader extends types_1.AppLoader {
20
26
  dbStore;
@@ -47,7 +53,7 @@ class AppLoader extends types_1.AppLoader {
47
53
  async initialize(dropIfExists) {
48
54
  await this.dbStore.initialize(dropIfExists);
49
55
  const { data } = require(`${this.path}/lib/data/index`);
50
- const context = this.contextBuilder()(this.dbStore);
56
+ const context = await this.contextBuilder()(this.dbStore);
51
57
  await context.begin();
52
58
  for (const entity in data) {
53
59
  let rows = data[entity];
package/lib/DbStore.d.ts CHANGED
@@ -4,7 +4,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
4
4
  import { MySQLConfiguration } from 'oak-db/lib/MySQL/types/Configuration';
5
5
  export declare class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends MysqlStore<ED, Cxt> {
6
6
  private executor;
7
- constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, mysqlConfiguration: MySQLConfiguration);
7
+ constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Promise<Cxt>, mysqlConfiguration: MySQLConfiguration);
8
8
  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>>;
9
9
  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']>[]>;
10
10
  operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
package/lib/DbStore.js CHANGED
@@ -7,7 +7,7 @@ class DbStore extends oak_db_1.MysqlStore {
7
7
  executor;
8
8
  constructor(storageSchema, contextBuilder, mysqlConfiguration) {
9
9
  super(storageSchema, mysqlConfiguration);
10
- this.executor = new TriggerExecutor_1.TriggerExecutor(async (scene) => contextBuilder(scene)(this));
10
+ this.executor = new TriggerExecutor_1.TriggerExecutor((scene) => contextBuilder(scene)(this));
11
11
  }
12
12
  async cascadeUpdate(entity, operation, context, option) {
13
13
  if (!option.blockTrigger) {
package/lib/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export { Context as BackendContext } from './BackendContext';
2
1
  export { AppLoader } from './AppLoader';
package/lib/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppLoader = exports.BackendContext = void 0;
4
- var BackendContext_1 = require("./BackendContext");
5
- Object.defineProperty(exports, "BackendContext", { enumerable: true, get: function () { return BackendContext_1.Context; } });
3
+ exports.AppLoader = void 0;
6
4
  var AppLoader_1 = require("./AppLoader");
7
5
  Object.defineProperty(exports, "AppLoader", { enumerable: true, get: function () { return AppLoader_1.AppLoader; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-backend-base",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "oak-backend-base",
5
5
  "main": "lib/index.js",
6
6
  "author": {
@@ -21,8 +21,7 @@
21
21
  "mysql": "^2.18.1",
22
22
  "mysql2": "^2.3.3",
23
23
  "oak-db": "^1.0.2",
24
- "oak-domain": "^1.1.0",
25
- "oak-general-business": "^1.0.5",
24
+ "oak-domain": "^1.1.8",
26
25
  "oak-common-aspect": "^1.0.2",
27
26
  "uuid": "^8.3.2"
28
27
  },
@@ -1,7 +0,0 @@
1
- import { RowStore } from 'oak-domain/lib/types';
2
- import { GeneralRuntimeContext } from 'oak-general-business';
3
- import { EntityDict } from 'oak-general-business/lib/general-app-domain';
4
- import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
5
- export declare class Context<ED extends EntityDict & BaseEntityDict> extends GeneralRuntimeContext<ED> {
6
- static FromCxtStr(cxtStr?: string): <ED extends EntityDict & BaseEntityDict>(store: RowStore<ED, Context<ED>>) => Context<ED>;
7
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Context = void 0;
4
- const oak_general_business_1 = require("oak-general-business");
5
- class Context extends oak_general_business_1.GeneralRuntimeContext {
6
- static FromCxtStr(cxtStr) {
7
- const { token, applicationId, scene } = cxtStr ? oak_general_business_1.GeneralRuntimeContext.fromString(cxtStr) : {
8
- token: undefined,
9
- applicationId: undefined,
10
- scene: undefined,
11
- };
12
- return (store) => {
13
- const context = new Context(store, applicationId);
14
- context.setScene(scene);
15
- context.setToken(token);
16
- return context;
17
- };
18
- }
19
- }
20
- exports.Context = Context;