@tsed/mikro-orm 8.0.0-beta.1 → 8.0.0-beta.11
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.
- package/lib/esm/MikroOrmModule.js +1 -1
- package/lib/esm/MikroOrmModule.js.map +1 -1
- package/lib/esm/filters/OptimisticLockErrorFilter.js +5 -2
- package/lib/esm/filters/OptimisticLockErrorFilter.js.map +1 -1
- package/lib/types/MikroOrmModule.d.ts +1 -1
- package/lib/types/filters/OptimisticLockErrorFilter.d.ts +2 -1
- package/package.json +13 -13
- package/readme.md +16 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
-
import "./services/MikroOrmFactory";
|
|
2
|
+
import "./services/MikroOrmFactory.js";
|
|
3
3
|
import { classOf, isFunction, Store } from "@tsed/core";
|
|
4
4
|
import { Constant, Inject, InjectorService, LocalsContainer, Module, ProviderScope, registerProvider } from "@tsed/di";
|
|
5
5
|
import { DEFAULT_CONTEXT_NAME, SUBSCRIBER_INJECTION_TYPE } from "./constants.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MikroOrmModule.js","sourceRoot":"","sources":["../../src/MikroOrmModule.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"MikroOrmModule.js","sourceRoot":"","sources":["../../src/MikroOrmModule.ts"],"names":[],"mappings":";AAAA,OAAO,+BAA+B,CAAC;AAGvC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAEL,QAAQ,EACR,MAAM,EACN,eAAe,EACf,eAAe,EACf,MAAM,EAGN,aAAa,EACb,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAC,oBAAoB,EAAE,yBAAyB,EAAC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAC,yBAAyB,EAAC,MAAM,wCAAwC,CA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I,EAAC,CAAC,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { OptimisticLockError } from "@mikro-orm/core";
|
|
3
|
-
import { Catch } from "@tsed/
|
|
3
|
+
import { Catch } from "@tsed/platform-exceptions";
|
|
4
4
|
let OptimisticLockErrorFilter = class OptimisticLockErrorFilter {
|
|
5
5
|
catch(exception, ctx) {
|
|
6
6
|
const { response, logger } = ctx;
|
|
7
7
|
logger.error({
|
|
8
|
-
|
|
8
|
+
event: "MIKRO_ORM_OPTIMISTIC_LOCK_ERROR",
|
|
9
|
+
error_name: exception.name,
|
|
10
|
+
error_message: exception.message,
|
|
11
|
+
stack: exception.stack
|
|
9
12
|
});
|
|
10
13
|
response.status(409).body(`Update refused. The resource has changed on the server. Please try again later`);
|
|
11
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimisticLockErrorFilter.js","sourceRoot":"","sources":["../../../src/filters/OptimisticLockErrorFilter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"OptimisticLockErrorFilter.js","sourceRoot":"","sources":["../../../src/filters/OptimisticLockErrorFilter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,KAAK,EAA8B,MAAM,2BAA2B,CAAC;AAItE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAC7B,KAAK,CAAC,SAA8B,EAAE,GAAoB;QAC/D,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,GAAG,CAAC;QAE/B,MAAM,CAAC,KAAK,CAAC;YACX,KAAK,EAAE,iCAAiC;YACxC,UAAU,EAAE,SAAS,CAAC,IAAI;YAC1B,aAAa,EAAE,SAAS,CAAC,OAAO;YAChC,KAAK,EAAE,SAAS,CAAC,KAAK;SACvB,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IAC9G,CAAC;CACF,CAAA;AAbY,yBAAyB;IADrC,KAAK,CAAC,mBAAmB,CAAC;GACd,yBAAyB,CAarC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OptimisticLockError } from "@mikro-orm/core";
|
|
2
|
-
import { ExceptionFilterMethods
|
|
2
|
+
import { type ExceptionFilterMethods } from "@tsed/platform-exceptions";
|
|
3
|
+
import { PlatformContext } from "@tsed/platform-http";
|
|
3
4
|
export declare class OptimisticLockErrorFilter implements ExceptionFilterMethods<OptimisticLockError> {
|
|
4
5
|
catch(exception: OptimisticLockError, ctx: PlatformContext): void;
|
|
5
6
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/mikro-orm",
|
|
3
3
|
"description": "MikroORM package for Ts.ED framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.0.0-beta.
|
|
5
|
+
"version": "8.0.0-beta.11",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@mikro-orm/core": "6.3.12",
|
|
29
29
|
"@mikro-orm/mongodb": "6.3.12",
|
|
30
|
-
"@tsed/barrels": "8.0.0-beta.
|
|
31
|
-
"@tsed/
|
|
32
|
-
"@tsed/
|
|
33
|
-
"@tsed/
|
|
34
|
-
"@tsed/json-mapper": "8.0.0-beta.1",
|
|
30
|
+
"@tsed/barrels": "8.0.0-beta.11",
|
|
31
|
+
"@tsed/core": "8.0.0-beta.11",
|
|
32
|
+
"@tsed/di": "8.0.0-beta.11",
|
|
33
|
+
"@tsed/json-mapper": "8.0.0-beta.11",
|
|
35
34
|
"@tsed/logger": "^6.7.8",
|
|
36
|
-
"@tsed/
|
|
37
|
-
"@tsed/
|
|
38
|
-
"@tsed/
|
|
35
|
+
"@tsed/platform-http": "8.0.0-beta.11",
|
|
36
|
+
"@tsed/schema": "8.0.0-beta.11",
|
|
37
|
+
"@tsed/testcontainers-mongo": "8.0.0-beta.11",
|
|
38
|
+
"@tsed/typescript": "8.0.0-beta.11",
|
|
39
39
|
"cross-env": "7.0.3",
|
|
40
40
|
"eslint": "9.12.0",
|
|
41
41
|
"ts-mockito": "^2.6.1",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@mikro-orm/core": ">=4.5.9",
|
|
47
|
-
"@tsed/
|
|
48
|
-
"@tsed/
|
|
49
|
-
"@tsed/
|
|
50
|
-
"@tsed/
|
|
47
|
+
"@tsed/core": "8.0.0-beta.11",
|
|
48
|
+
"@tsed/di": "8.0.0-beta.11",
|
|
49
|
+
"@tsed/logger": ">=6.7.5",
|
|
50
|
+
"@tsed/platform-http": "8.0.0-beta.11"
|
|
51
51
|
},
|
|
52
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
53
53
|
"bugs": {
|
package/readme.md
CHANGED
|
@@ -101,7 +101,8 @@ The `mikroOrm` options accepts the same configuration object as `init()` from th
|
|
|
101
101
|
`@Orm` decorator lets you retrieve an instance of MikroORM.
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
import {Injectable
|
|
104
|
+
import {Injectable} from "@tsed/di";
|
|
105
|
+
import {AfterRoutesInit} from "@tsed/platform-http";
|
|
105
106
|
import {Orm} from "@tsed/mikro-orm";
|
|
106
107
|
import {MikroORM} from "@mikro-orm/core";
|
|
107
108
|
|
|
@@ -146,7 +147,8 @@ export class MyService {
|
|
|
146
147
|
`@EntityManager` and `@Em` decorators lets you retrieve an instance of EntityManager.
|
|
147
148
|
|
|
148
149
|
```typescript
|
|
149
|
-
import {Injectable
|
|
150
|
+
import {Injectable} from "@tsed/di";
|
|
151
|
+
import {AfterRoutesInit} from "@tsed/platform-http";
|
|
150
152
|
import {Em} from "@tsed/mikro-orm";
|
|
151
153
|
import {EntityManager} from "@mikro-orm/mysql"; // Import EntityManager from your driver package or `@mikro-orm/knex`
|
|
152
154
|
|
|
@@ -167,7 +169,8 @@ export class UsersService {
|
|
|
167
169
|
It's also possible to inject Entity manager by his context name:
|
|
168
170
|
|
|
169
171
|
```typescript
|
|
170
|
-
import {Injectable
|
|
172
|
+
import {Injectable} from "@tsed/di";
|
|
173
|
+
import {AfterRoutesInit} from "@tsed/platform-http";
|
|
171
174
|
import {Em} from "@tsed/mikro-orm";
|
|
172
175
|
import {EntityManager} from "@mikro-orm/mysql"; // Import EntityManager from your driver package or `@mikro-orm/knex`
|
|
173
176
|
|
|
@@ -190,7 +193,7 @@ export class UsersService {
|
|
|
190
193
|
To begin, we need to define an Entity MikroORM like this and use Ts.ED Decorator to define the JSON Schema.
|
|
191
194
|
|
|
192
195
|
```typescript
|
|
193
|
-
import {Property, MaxLength, Required} from "@tsed/
|
|
196
|
+
import {Property, MaxLength, Required} from "@tsed/schema";
|
|
194
197
|
import {Entity, Property, PrimaryKey, Property as Column} from "@mikro-orm/core";
|
|
195
198
|
|
|
196
199
|
@Entity()
|
|
@@ -223,7 +226,9 @@ Now, the model is correctly defined and can be used with a [Controller](https://
|
|
|
223
226
|
We can use this model with a Controller like that:
|
|
224
227
|
|
|
225
228
|
```typescript
|
|
226
|
-
import {Controller,
|
|
229
|
+
import {Controller, Inject} from "@tsed/common";
|
|
230
|
+
import {BodyParamst} from "@tsed/platform-params";
|
|
231
|
+
import {Post, Post, Get} from "@tsed/schema";
|
|
227
232
|
|
|
228
233
|
@Controller("/users")
|
|
229
234
|
export class UsersCtrl {
|
|
@@ -251,7 +256,9 @@ We can use the `@Transactional()` decorator, which will register a new request c
|
|
|
251
256
|
inside the context.
|
|
252
257
|
|
|
253
258
|
```typescript
|
|
254
|
-
import {
|
|
259
|
+
import {BodyParamst} from "@tsed/platform-params";
|
|
260
|
+
import {Post, Post, Get} from "@tsed/schema";
|
|
261
|
+
import {Controller, Inject} from "@tsed/di";
|
|
255
262
|
import {Transactional} from "@tsed/mikro-orm";
|
|
256
263
|
|
|
257
264
|
@Controller("/users")
|
|
@@ -354,7 +361,9 @@ export class ExponentialBackoff implements RetryStrategy {
|
|
|
354
361
|
Once a retry strategy is implemented, you can enable an automatic retry mechanism using the `@Transactional` decorator like that:
|
|
355
362
|
|
|
356
363
|
```typescript
|
|
357
|
-
import {
|
|
364
|
+
import {BodyParamst} from "@tsed/platform-params";
|
|
365
|
+
import {Post, Post, Get} from "@tsed/schema";
|
|
366
|
+
import {Controller, Inject} from "@tsed/di";
|
|
358
367
|
import {Transactional} from "@tsed/mikro-orm";
|
|
359
368
|
|
|
360
369
|
@Controller("/users")
|