oak-backend-base 1.0.1 → 1.0.2

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.
@@ -1,6 +1,7 @@
1
+ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
1
2
  import { AppLoader as GeneralAppLoader, RowStore, Context, EntityDict } from "oak-domain/lib/types";
2
3
  import { MySQLConfiguration } from 'oak-db/lib/MySQL/types/Configuration';
3
- export declare class AppLoader<ED extends EntityDict, Cxt extends Context<ED>> extends GeneralAppLoader<ED, Cxt> {
4
+ export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends GeneralAppLoader<ED, Cxt> {
4
5
  private dbStore;
5
6
  private aspectDict;
6
7
  private contextBuilder;
package/lib/AppLoader.js CHANGED
@@ -58,7 +58,10 @@ class AppLoader extends types_1.AppLoader {
58
58
  await this.dbStore.operate(entity, {
59
59
  data: rows,
60
60
  action: 'create',
61
- }, context);
61
+ }, context, {
62
+ dontCollect: true,
63
+ dontCreateOper: true,
64
+ });
62
65
  console.log(`data in ${entity} initialized!`);
63
66
  }
64
67
  await context.commit();
@@ -1,6 +1,7 @@
1
1
  import { RowStore } from 'oak-domain/lib/types';
2
2
  import { GeneralRuntimeContext } from 'oak-general-business';
3
3
  import { EntityDict } from 'oak-general-business/lib/general-app-domain';
4
- export declare class Context<ED extends EntityDict> extends GeneralRuntimeContext<ED> {
5
- static FromCxtStr(cxtStr?: string): <ED extends EntityDict>(store: RowStore<ED, Context<ED>>) => Context<ED>;
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>;
6
7
  }
package/lib/DbStore.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { MysqlStore, MySqlSelectOption, MysqlOperateOption } from 'oak-db';
2
2
  import { EntityDict, Context, StorageSchema, SelectionResult, Trigger, Checker, SelectRowShape, RowStore } from 'oak-domain/lib/types';
3
+ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
3
4
  import { MySQLConfiguration } from 'oak-db/lib/MySQL/types/Configuration';
4
- export declare class DbStore<ED extends EntityDict, Cxt extends Context<ED>> extends MysqlStore<ED, Cxt> {
5
+ export declare class DbStore<ED extends EntityDict & BaseEntityDict, Cxt extends Context<ED>> extends MysqlStore<ED, Cxt> {
5
6
  private executor;
6
7
  constructor(storageSchema: StorageSchema<ED>, contextBuilder: (scene?: string) => (store: RowStore<ED, Cxt>) => Cxt, mysqlConfiguration: MySQLConfiguration);
7
- 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>>;
8
- 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']>[]>;
9
- operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, params?: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
10
- select<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, params?: MySqlSelectOption): Promise<SelectionResult<ED[T]["Schema"], S["data"]>>;
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
+ 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
+ operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: MysqlOperateOption): Promise<import("oak-domain/lib/types").OperationResult<ED>>;
11
+ select<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, option: MySqlSelectOption): Promise<SelectionResult<ED[T]["Schema"], S["data"]>>;
11
12
  registerTrigger<T extends keyof ED>(trigger: Trigger<ED, T, Cxt>): void;
12
13
  registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>): void;
13
14
  }
package/lib/DbStore.js CHANGED
@@ -10,32 +10,36 @@ class DbStore extends oak_db_1.MysqlStore {
10
10
  this.executor = new TriggerExecutor_1.TriggerExecutor(async (scene) => contextBuilder(scene)(this));
11
11
  }
12
12
  async cascadeUpdate(entity, operation, context, option) {
13
- await this.executor.preOperation(entity, operation, context, option);
13
+ if (!option.blockTrigger) {
14
+ await this.executor.preOperation(entity, operation, context, option);
15
+ }
14
16
  const result = super.cascadeUpdate(entity, operation, context, option);
15
- await this.executor.postOperation(entity, operation, context, option);
17
+ if (!option.blockTrigger) {
18
+ await this.executor.postOperation(entity, operation, context, option);
19
+ }
16
20
  return result;
17
21
  }
18
22
  async cascadeSelect(entity, selection, context, option) {
19
23
  const selection2 = Object.assign({
20
24
  action: 'select',
21
25
  }, selection);
22
- if (!option?.ignoreTrigger) {
26
+ if (!option.blockTrigger) {
23
27
  await this.executor.preOperation(entity, selection2, context, option);
24
28
  }
25
29
  const result = await super.cascadeSelect(entity, selection2, context, option);
26
- if (!option?.ignoreTrigger) {
30
+ if (!option.blockTrigger) {
27
31
  await this.executor.postOperation(entity, selection2, context, option, result);
28
32
  }
29
33
  return result;
30
34
  }
31
- async operate(entity, operation, context, params) {
35
+ async operate(entity, operation, context, option) {
32
36
  const autoCommit = !context.getCurrentTxnId();
33
37
  let result;
34
38
  if (autoCommit) {
35
39
  await context.begin();
36
40
  }
37
41
  try {
38
- result = await super.operate(entity, operation, context, params);
42
+ result = await super.operate(entity, operation, context, option);
39
43
  }
40
44
  catch (err) {
41
45
  await context.rollback();
@@ -46,14 +50,14 @@ class DbStore extends oak_db_1.MysqlStore {
46
50
  }
47
51
  return result;
48
52
  }
49
- async select(entity, selection, context, params) {
53
+ async select(entity, selection, context, option) {
50
54
  const autoCommit = !context.getCurrentTxnId();
51
55
  if (autoCommit) {
52
56
  await context.begin();
53
57
  }
54
58
  let result;
55
59
  try {
56
- result = await super.select(entity, selection, context, params);
60
+ result = await super.select(entity, selection, context, option);
57
61
  }
58
62
  catch (err) {
59
63
  await context.rollback();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-backend-base",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "oak-backend-base",
5
5
  "main": "lib/index.js",
6
6
  "author": {
@@ -20,10 +20,10 @@
20
20
  "lodash": "^4.17.21",
21
21
  "mysql": "^2.18.1",
22
22
  "mysql2": "^2.3.3",
23
- "oak-db": "^1.0.1",
24
- "oak-domain": "^1.0.4",
25
- "oak-general-business": "^1.0.1",
26
- "oak-common-aspect": "^1.0.1",
23
+ "oak-db": "^1.0.2",
24
+ "oak-domain": "^1.1.0",
25
+ "oak-general-business": "^1.0.5",
26
+ "oak-common-aspect": "^1.0.3",
27
27
  "uuid": "^8.3.2"
28
28
  },
29
29
  "license": "ISC",