@midwayjs/leoric 4.0.0-beta.6 → 4.0.0-beta.8

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.
@@ -2,6 +2,7 @@ import { IMidwayContainer, MidwayDecoratorService } from '@midwayjs/core';
2
2
  import { LeoricDataSourceManager } from './dataSourceManager';
3
3
  export declare class LeoricConfiguration {
4
4
  decoratorService: MidwayDecoratorService;
5
+ applicationContext: IMidwayContainer;
5
6
  dataSourceManager: LeoricDataSourceManager;
6
7
  init(): Promise<void>;
7
8
  onReady(container: IMidwayContainer): Promise<void>;
@@ -25,9 +25,10 @@ let LeoricConfiguration = class LeoricConfiguration {
25
25
  this.dataSourceManager.getDataSourceNameByModel(meta.modelName) ||
26
26
  this.dataSourceManager.getDefaultDataSourceName());
27
27
  const model = dataSource.models[getModelName(meta.modelName)];
28
- const ctx = instance[core_1.REQUEST_OBJ_CTX_KEY];
29
28
  const app = instance[core_1.APPLICATION_KEY];
30
- if (ctx) {
29
+ if (this.applicationContext.getInstanceScope(instance) ===
30
+ core_1.ScopeEnum.Request) {
31
+ const ctx = instance[core_1.REQUEST_OBJ_CTX_KEY];
31
32
  return class extends model {
32
33
  static get ctx() {
33
34
  return ctx;
@@ -62,6 +63,10 @@ __decorate([
62
63
  (0, core_1.Inject)(),
63
64
  __metadata("design:type", core_1.MidwayDecoratorService)
64
65
  ], LeoricConfiguration.prototype, "decoratorService", void 0);
66
+ __decorate([
67
+ (0, core_1.ApplicationContext)(),
68
+ __metadata("design:type", Object)
69
+ ], LeoricConfiguration.prototype, "applicationContext", void 0);
65
70
  __decorate([
66
71
  (0, core_1.Init)(),
67
72
  __metadata("design:type", Function),
package/dist/decorator.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectModel = exports.InjectDataSource = exports.DATA_SOURCE_KEY = exports.MODEL_KEY = void 0;
3
+ exports.DATA_SOURCE_KEY = exports.MODEL_KEY = void 0;
4
+ exports.InjectDataSource = InjectDataSource;
5
+ exports.InjectModel = InjectModel;
4
6
  const core_1 = require("@midwayjs/core");
5
7
  exports.MODEL_KEY = 'leoric:model_key';
6
8
  exports.DATA_SOURCE_KEY = 'leoric:data_source_key';
@@ -9,7 +11,6 @@ function InjectDataSource(dataSourceName) {
9
11
  dataSourceName,
10
12
  });
11
13
  }
12
- exports.InjectDataSource = InjectDataSource;
13
14
  function InjectModel(modelName, dataSourceName) {
14
15
  return (target, propertyKey) => {
15
16
  if (!modelName)
@@ -20,5 +21,4 @@ function InjectModel(modelName, dataSourceName) {
20
21
  })(target, propertyKey);
21
22
  };
22
23
  }
23
- exports.InjectModel = InjectModel;
24
24
  //# sourceMappingURL=decorator.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/leoric",
3
- "version": "4.0.0-beta.6",
3
+ "version": "4.0.0-beta.8",
4
4
  "description": "Leoric as a Midway model component",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -18,12 +18,12 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "leoric": "2.13.8"
21
+ "leoric": "2.13.9"
22
22
  },
23
23
  "devDependencies": {
24
- "@midwayjs/core": "^4.0.0-beta.6",
25
- "@midwayjs/koa": "^4.0.0-beta.6",
26
- "@midwayjs/mock": "^4.0.0-beta.6",
24
+ "@midwayjs/core": "^4.0.0-beta.8",
25
+ "@midwayjs/koa": "^4.0.0-beta.8",
26
+ "@midwayjs/mock": "^4.0.0-beta.8",
27
27
  "sqlite3": "5.1.7"
28
28
  },
29
29
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "type": "git",
37
37
  "url": "https://github.com/midwayjs/midway.git"
38
38
  },
39
- "gitHead": "a02425777d044ec502d050993bc256dc26d5b586"
39
+ "gitHead": "355e55949fdd132b0bdcb4830222a0a027e92ded"
40
40
  }