@tsed/platform-test-sdk 7.29.0 → 7.29.1
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/cjs/tests/testHandlers.js +2 -2
- package/lib/cjs/tests/testHandlers.js.map +1 -1
- package/lib/cjs/tests/testInheritanceController.js +7 -7
- package/lib/cjs/tests/testInheritanceController.js.map +1 -1
- package/lib/cjs/tests/testPathParams.js +13 -13
- package/lib/cjs/tests/testPathParams.js.map +1 -1
- package/lib/cjs/tests/testResponse.js +16 -16
- package/lib/cjs/tests/testResponse.js.map +1 -1
- package/lib/cjs/tests/testScopeRequest.js +1 -1
- package/lib/cjs/tests/testScopeRequest.js.map +1 -1
- package/lib/cjs/tests/testSession.js +10 -9
- package/lib/cjs/tests/testSession.js.map +1 -1
- package/lib/esm/tests/testHandlers.js +2 -2
- package/lib/esm/tests/testHandlers.js.map +1 -1
- package/lib/esm/tests/testInheritanceController.js +7 -7
- package/lib/esm/tests/testInheritanceController.js.map +1 -1
- package/lib/esm/tests/testPathParams.js +13 -13
- package/lib/esm/tests/testPathParams.js.map +1 -1
- package/lib/esm/tests/testResponse.js +16 -16
- package/lib/esm/tests/testResponse.js.map +1 -1
- package/lib/esm/tests/testScopeRequest.js +1 -1
- package/lib/esm/tests/testScopeRequest.js.map +1 -1
- package/lib/esm/tests/testSession.js +10 -9
- package/lib/esm/tests/testSession.js.map +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/tests/testInheritanceController.d.ts +1 -1
- package/lib/types/tests/testSession.d.ts +1 -1
- package/package.json +14 -14
- package/src/tests/testHandlers.ts +2 -2
- package/src/tests/testInheritanceController.ts +6 -6
- package/src/tests/testPathParams.ts +8 -8
- package/src/tests/testResponse.ts +13 -12
- package/src/tests/testScopeRequest.ts +1 -1
- package/src/tests/testSession.ts +10 -7
|
@@ -16,7 +16,7 @@ export declare class ResourcesCtrl extends BaseController<Resource> {
|
|
|
16
16
|
name: string;
|
|
17
17
|
}[];
|
|
18
18
|
get(id: string): Promise<any>;
|
|
19
|
-
post(resource: Resource):
|
|
19
|
+
post(resource: Resource): Resource;
|
|
20
20
|
}
|
|
21
21
|
declare abstract class AttachmentController {
|
|
22
22
|
getAll(parentID: string): string;
|
|
@@ -11,6 +11,6 @@ export declare class SessionCtrl {
|
|
|
11
11
|
platformName: string;
|
|
12
12
|
connect(session: any, user: UserCreation): Promise<UserCreation>;
|
|
13
13
|
userInfo(user: User): Promise<User>;
|
|
14
|
-
logout(req: any):
|
|
14
|
+
logout(req: any): any;
|
|
15
15
|
}
|
|
16
16
|
export declare function testSession(options: PlatformTestingSdkOpts): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-test-sdk",
|
|
3
|
-
"version": "7.29.
|
|
3
|
+
"version": "7.29.1",
|
|
4
4
|
"description": "Package to test platform adapter integration with Ts.ED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -28,25 +28,25 @@
|
|
|
28
28
|
"Adapter"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@tsed/ajv": "7.29.
|
|
32
|
-
"@tsed/common": "7.29.
|
|
33
|
-
"@tsed/core": "7.29.
|
|
34
|
-
"@tsed/di": "7.29.
|
|
35
|
-
"@tsed/json-mapper": "7.29.
|
|
31
|
+
"@tsed/ajv": "7.29.1",
|
|
32
|
+
"@tsed/common": "7.29.1",
|
|
33
|
+
"@tsed/core": "7.29.1",
|
|
34
|
+
"@tsed/di": "7.29.1",
|
|
35
|
+
"@tsed/json-mapper": "7.29.1",
|
|
36
36
|
"@tsed/logger": "6.2.2",
|
|
37
|
-
"@tsed/platform-cache": "7.29.
|
|
38
|
-
"@tsed/platform-params": "7.29.
|
|
39
|
-
"@tsed/platform-router": "7.29.
|
|
40
|
-
"@tsed/platform-views": "7.29.
|
|
41
|
-
"@tsed/schema": "7.29.
|
|
42
|
-
"@tsed/swagger": "7.29.
|
|
37
|
+
"@tsed/platform-cache": "7.29.1",
|
|
38
|
+
"@tsed/platform-params": "7.29.1",
|
|
39
|
+
"@tsed/platform-router": "7.29.1",
|
|
40
|
+
"@tsed/platform-views": "7.29.1",
|
|
41
|
+
"@tsed/schema": "7.29.1",
|
|
42
|
+
"@tsed/swagger": "7.29.1",
|
|
43
43
|
"ajv": "^8.12.0",
|
|
44
44
|
"axios": "^1.3.0",
|
|
45
45
|
"read-pkg-up": "7.0.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@tsed/eslint": "7.29.
|
|
49
|
-
"@tsed/typescript": "7.29.
|
|
48
|
+
"@tsed/eslint": "7.29.1",
|
|
49
|
+
"@tsed/typescript": "7.29.1",
|
|
50
50
|
"eslint": "^8.12.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {},
|
|
@@ -43,12 +43,12 @@ export class HandlersCtrl {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@Get("/scenario-3/:id") // Ts.ED style
|
|
46
|
-
public
|
|
46
|
+
public scenario3(@PathParams("id") id: string): Promise<any> {
|
|
47
47
|
const model = new MyModel();
|
|
48
48
|
model.id = id;
|
|
49
49
|
model.name = "test";
|
|
50
50
|
|
|
51
|
-
return model;
|
|
51
|
+
return Promise.resolve(model);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -19,7 +19,7 @@ export class BaseController<T extends {id: string}> {
|
|
|
19
19
|
|
|
20
20
|
@Get("/:id")
|
|
21
21
|
@Summary("Return an element by his resource")
|
|
22
|
-
|
|
22
|
+
get(
|
|
23
23
|
@Description("Id of the resource")
|
|
24
24
|
@PathParams("id")
|
|
25
25
|
id: string
|
|
@@ -27,16 +27,16 @@ export class BaseController<T extends {id: string}> {
|
|
|
27
27
|
const resource = this.resources.find((resource) => resource.id === id);
|
|
28
28
|
|
|
29
29
|
if (!resource) {
|
|
30
|
-
|
|
30
|
+
return Promise.reject(new NotFound("Not found"));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return resource;
|
|
33
|
+
return Promise.resolve(resource);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@Get("/")
|
|
37
37
|
@Summary("Return all elements from a service")
|
|
38
|
-
|
|
39
|
-
return this.resources;
|
|
38
|
+
list(): Promise<any[]> {
|
|
39
|
+
return Promise.resolve(this.resources);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -60,7 +60,7 @@ export class ResourcesCtrl extends BaseController<Resource> {
|
|
|
60
60
|
|
|
61
61
|
@Post("/")
|
|
62
62
|
@Returns(201).Type(Resource)
|
|
63
|
-
|
|
63
|
+
post(@BodyParams() resource: Resource) {
|
|
64
64
|
resource.id = require("uuid").v4();
|
|
65
65
|
this.resources.push(resource);
|
|
66
66
|
|
|
@@ -6,15 +6,15 @@ import {PlatformTestingSdkOpts} from "../interfaces";
|
|
|
6
6
|
@Controller("/path-params")
|
|
7
7
|
class TestPathParamsCtrl {
|
|
8
8
|
@Get("/scenario-1/:scope/:scopeId")
|
|
9
|
-
|
|
9
|
+
testScenario1(@PathParams("scope") scope: string) {
|
|
10
10
|
// Here scope will be {0: 'a', 1: 'b', 2: 'c'} instead of 'abc' in version 5.47.0
|
|
11
11
|
expect(scope).toEqual("abc");
|
|
12
12
|
|
|
13
|
-
return scope;
|
|
13
|
+
return Promise.resolve(scope);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
@Get("/scenario-2/:scope/:scopeId")
|
|
17
|
-
|
|
17
|
+
testScenario2(@PathParams("scope") scope: any) {
|
|
18
18
|
// This way it works in version 5.47.0
|
|
19
19
|
expect(scope).toEqual("abc");
|
|
20
20
|
|
|
@@ -22,15 +22,15 @@ class TestPathParamsCtrl {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
@Post("/scenario-3/:scope/:scopeId")
|
|
25
|
-
|
|
25
|
+
testScenario3(@PathParams("scope") scope: string): Promise<any[]> {
|
|
26
26
|
expect(scope).toEqual("abc");
|
|
27
27
|
|
|
28
28
|
// Here the function will return {0: 'a', 1: 'b', 2: 'c'} instead of ['a','b','c'] in version 5.44.13
|
|
29
|
-
return ["a", "b", "c"];
|
|
29
|
+
return Promise.resolve(["a", "b", "c"]);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
@Post("/scenario-4/:scope/:scopeId")
|
|
33
|
-
|
|
33
|
+
testScenario4(@PathParams("scope") scope: string, @Context() ctx: Context) {
|
|
34
34
|
expect(scope).toEqual("abc");
|
|
35
35
|
|
|
36
36
|
// This way it works in version 5.44.13
|
|
@@ -38,12 +38,12 @@ class TestPathParamsCtrl {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@Get("/scenario-5/:scopeId")
|
|
41
|
-
|
|
41
|
+
testScenario5(@PathParams("scopeId") @Pattern(/^[0-9a-fA-F]{24}$/) scopeId: string, @Context() ctx: Context) {
|
|
42
42
|
return "test";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@Get("/scenario-6/:id")
|
|
46
|
-
|
|
46
|
+
testScenario6(@PathParams("id") id: number) {
|
|
47
47
|
return {id};
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -127,8 +127,8 @@ class TestResponseParamsCtrl {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
@Get("/scenario6b")
|
|
130
|
-
|
|
131
|
-
return of({id: 1});
|
|
130
|
+
testScenario6bObservable() {
|
|
131
|
+
return Promise.resolve(of({id: 1}));
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
@Get("/scenario7")
|
|
@@ -139,8 +139,8 @@ class TestResponseParamsCtrl {
|
|
|
139
139
|
|
|
140
140
|
@Get("/scenario7b")
|
|
141
141
|
@ContentType("application/json")
|
|
142
|
-
|
|
143
|
-
return createReadStream(join(rootDir, "../data/response.data.json"));
|
|
142
|
+
testScenario7bStream() {
|
|
143
|
+
return Promise.resolve(createReadStream(join(rootDir, "../data/response.data.json")));
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
@Get("/scenario9/static")
|
|
@@ -210,29 +210,30 @@ class TestResponseParamsCtrl {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
@Get("/scenario15b")
|
|
213
|
-
|
|
213
|
+
testScenario15b() {
|
|
214
214
|
return axios.get(`https://api.tsed.io/rest/github/typed/test`, {
|
|
215
215
|
responseType: "json"
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
@Get("/scenario16")
|
|
220
|
-
|
|
220
|
+
testScenario16(): Promise<TestNestedEnum> {
|
|
221
221
|
const test = new TestNestedEnum();
|
|
222
222
|
const nested = new NestedEnum();
|
|
223
223
|
nested.value = EnumValue.One;
|
|
224
224
|
test.nested = nested;
|
|
225
|
-
|
|
225
|
+
|
|
226
|
+
return Promise.resolve(test);
|
|
226
227
|
}
|
|
227
228
|
|
|
228
229
|
@Get("/scenario17")
|
|
229
230
|
@Returns(201, ModelGroup).Groups("creation")
|
|
230
|
-
|
|
231
|
+
testScenario17(): Promise<ModelGroup> {
|
|
231
232
|
const model = new ModelGroup();
|
|
232
233
|
model.id = "id";
|
|
233
234
|
model.groups = "groups";
|
|
234
235
|
|
|
235
|
-
return model;
|
|
236
|
+
return Promise.resolve(model);
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
@Get("/scenario18")
|
|
@@ -248,7 +249,7 @@ class TestResponseParamsCtrl {
|
|
|
248
249
|
|
|
249
250
|
@Get("/scenario19")
|
|
250
251
|
@Returns(200, AllowedModel).Groups("!admin").AllowedGroups("summary", "details")
|
|
251
|
-
|
|
252
|
+
testScenario19(): Promise<AllowedModel> {
|
|
252
253
|
const model = new AllowedModel();
|
|
253
254
|
model.id = "id";
|
|
254
255
|
model.prop1 = "prop1";
|
|
@@ -256,11 +257,11 @@ class TestResponseParamsCtrl {
|
|
|
256
257
|
model.prop2 = "prop2";
|
|
257
258
|
model.sensitiveProp = "sensitiveProp";
|
|
258
259
|
|
|
259
|
-
return model;
|
|
260
|
+
return Promise.resolve(model);
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
@Get("/scenario20")
|
|
263
|
-
|
|
264
|
+
testScenario20() {
|
|
264
265
|
const $ctx = getContext();
|
|
265
266
|
|
|
266
267
|
return {id: $ctx?.request.query.id};
|
|
@@ -20,7 +20,7 @@ export class ScopeRequestCtrl {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
@Get("/:id")
|
|
23
|
-
|
|
23
|
+
testPerRequest(@PathParams("id") userId: string): Promise<any> {
|
|
24
24
|
this.scopeRequestService.user = userId;
|
|
25
25
|
this.userId = userId;
|
|
26
26
|
|
package/src/tests/testSession.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {Allow, Email, Ignore, MinLength, Property, Required, Returns} from "@tse
|
|
|
4
4
|
import SuperTest from "supertest";
|
|
5
5
|
import {promisify} from "util";
|
|
6
6
|
import {PlatformTestingSdkOpts} from "../interfaces";
|
|
7
|
+
|
|
7
8
|
export class UserCreation {
|
|
8
9
|
@Property()
|
|
9
10
|
name: string;
|
|
@@ -30,33 +31,35 @@ export class SessionCtrl {
|
|
|
30
31
|
platformName: string;
|
|
31
32
|
|
|
32
33
|
@Post("/connect")
|
|
33
|
-
|
|
34
|
+
connect(@Session() session: any, @BodyParams() user: UserCreation) {
|
|
34
35
|
session.user = user;
|
|
35
36
|
|
|
36
|
-
return user;
|
|
37
|
+
return Promise.resolve(user);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
@Get("/userinfo")
|
|
40
41
|
@Returns(200, User)
|
|
41
|
-
|
|
42
|
+
userInfo(@Session("user") user: User): Promise<User> {
|
|
42
43
|
if (!user) {
|
|
43
|
-
|
|
44
|
+
return Promise.reject(new NotFound("User not found"));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
return user;
|
|
47
|
+
return Promise.resolve(user);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
@Get("/logout")
|
|
50
51
|
@Returns(204)
|
|
51
|
-
|
|
52
|
+
logout(@Req() req: any) {
|
|
52
53
|
switch (this.platformName) {
|
|
53
54
|
case "koa":
|
|
54
|
-
return (req.ctx.session = null);
|
|
55
|
+
return Promise.resolve((req.ctx.session = null));
|
|
55
56
|
case "express":
|
|
56
57
|
delete req.session.user;
|
|
57
58
|
|
|
58
59
|
return promisify(req.session.destroy.bind(req.session))();
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
return Promise.resolve();
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|