@tsed/platform-test-sdk 7.18.2 → 7.18.3

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.
Files changed (93) hide show
  1. package/.eslintignore +13 -0
  2. package/.eslintrc.js +1 -0
  3. package/lib/cjs/components/PlatformTestSdk.js.map +1 -1
  4. package/lib/cjs/data/response.data.json +3 -0
  5. package/lib/cjs/errors/CustomBadRequest.js.map +1 -1
  6. package/lib/cjs/errors/CustomInternalError.js.map +1 -1
  7. package/lib/cjs/index.js.map +1 -1
  8. package/lib/cjs/interfaces/PlatformTestingSdkOpts.js.map +1 -1
  9. package/lib/cjs/interfaces/index.js.map +1 -1
  10. package/lib/cjs/modules/feature/FeatureModule.js.map +1 -1
  11. package/lib/cjs/modules/feature/controllers/FeatureController.js.map +1 -1
  12. package/lib/cjs/tests/exports.js.map +1 -1
  13. package/lib/cjs/tests/testAcceptMime.js.map +1 -1
  14. package/lib/cjs/tests/testAuth.js.map +1 -1
  15. package/lib/cjs/tests/testBodyParams.js +12 -12
  16. package/lib/cjs/tests/testBodyParams.js.map +1 -1
  17. package/lib/cjs/tests/testCache.js.map +1 -1
  18. package/lib/cjs/tests/testChildrenControllers.js.map +1 -1
  19. package/lib/cjs/tests/testCookies.js.map +1 -1
  20. package/lib/cjs/tests/testCtrlInheritance.js.map +1 -1
  21. package/lib/cjs/tests/testCustom404.js.map +1 -1
  22. package/lib/cjs/tests/testErrors.js.map +1 -1
  23. package/lib/cjs/tests/testHandlers.js.map +1 -1
  24. package/lib/cjs/tests/testHeaderParams.js.map +1 -1
  25. package/lib/cjs/tests/testHeaders.js.map +1 -1
  26. package/lib/cjs/tests/testInheritanceController.js.map +1 -1
  27. package/lib/cjs/tests/testLocals.js.map +1 -1
  28. package/lib/cjs/tests/testLocation.js.map +1 -1
  29. package/lib/cjs/tests/testMiddlewares.js.map +1 -1
  30. package/lib/cjs/tests/testModule.js.map +1 -1
  31. package/lib/cjs/tests/testMulter.js +19 -9
  32. package/lib/cjs/tests/testMulter.js.map +1 -1
  33. package/lib/cjs/tests/testPathParams.js.map +1 -1
  34. package/lib/cjs/tests/testQueryParams.js.map +1 -1
  35. package/lib/cjs/tests/testRedirect.js.map +1 -1
  36. package/lib/cjs/tests/testResponse.js +5 -2
  37. package/lib/cjs/tests/testResponse.js.map +1 -1
  38. package/lib/cjs/tests/testResponseFilter.js.map +1 -1
  39. package/lib/cjs/tests/testRouting.js.map +1 -1
  40. package/lib/cjs/tests/testScopeRequest.js.map +1 -1
  41. package/lib/cjs/tests/testSession.js.map +1 -1
  42. package/lib/cjs/tests/testStatics.js.map +1 -1
  43. package/lib/cjs/tests/testView.js.map +1 -1
  44. package/lib/esm/components/PlatformTestSdk.js.map +1 -1
  45. package/lib/esm/data/response.data.json +3 -0
  46. package/lib/esm/errors/CustomBadRequest.js.map +1 -1
  47. package/lib/esm/errors/CustomInternalError.js.map +1 -1
  48. package/lib/esm/index.js.map +1 -1
  49. package/lib/esm/interfaces/PlatformTestingSdkOpts.js.map +1 -1
  50. package/lib/esm/interfaces/index.js.map +1 -1
  51. package/lib/esm/modules/feature/FeatureModule.js.map +1 -1
  52. package/lib/esm/modules/feature/controllers/FeatureController.js.map +1 -1
  53. package/lib/esm/tests/exports.js.map +1 -1
  54. package/lib/esm/tests/testAcceptMime.js.map +1 -1
  55. package/lib/esm/tests/testAuth.js.map +1 -1
  56. package/lib/esm/tests/testBodyParams.js +2 -2
  57. package/lib/esm/tests/testBodyParams.js.map +1 -1
  58. package/lib/esm/tests/testCache.js.map +1 -1
  59. package/lib/esm/tests/testChildrenControllers.js.map +1 -1
  60. package/lib/esm/tests/testCookies.js.map +1 -1
  61. package/lib/esm/tests/testCtrlInheritance.js.map +1 -1
  62. package/lib/esm/tests/testCustom404.js.map +1 -1
  63. package/lib/esm/tests/testErrors.js.map +1 -1
  64. package/lib/esm/tests/testHandlers.js.map +1 -1
  65. package/lib/esm/tests/testHeaderParams.js.map +1 -1
  66. package/lib/esm/tests/testHeaders.js.map +1 -1
  67. package/lib/esm/tests/testInheritanceController.js.map +1 -1
  68. package/lib/esm/tests/testLocals.js.map +1 -1
  69. package/lib/esm/tests/testLocation.js.map +1 -1
  70. package/lib/esm/tests/testMiddlewares.js.map +1 -1
  71. package/lib/esm/tests/testModule.js.map +1 -1
  72. package/lib/esm/tests/testMulter.js +18 -8
  73. package/lib/esm/tests/testMulter.js.map +1 -1
  74. package/lib/esm/tests/testPathParams.js.map +1 -1
  75. package/lib/esm/tests/testQueryParams.js.map +1 -1
  76. package/lib/esm/tests/testRedirect.js.map +1 -1
  77. package/lib/esm/tests/testResponse.js +5 -2
  78. package/lib/esm/tests/testResponse.js.map +1 -1
  79. package/lib/esm/tests/testResponseFilter.js.map +1 -1
  80. package/lib/esm/tests/testRouting.js.map +1 -1
  81. package/lib/esm/tests/testScopeRequest.js.map +1 -1
  82. package/lib/esm/tests/testSession.js.map +1 -1
  83. package/lib/esm/tests/testStatics.js.map +1 -1
  84. package/lib/esm/tests/testView.js.map +1 -1
  85. package/lib/tsconfig.esm.tsbuildinfo +1 -0
  86. package/lib/tsconfig.tsbuildinfo +1 -0
  87. package/package.json +24 -18
  88. package/src/tests/testBodyParams.ts +2 -2
  89. package/src/tests/testMulter.ts +23 -11
  90. package/src/tests/testResponse.ts +5 -2
  91. package/tsconfig.esm.json +63 -0
  92. package/tsconfig.json +63 -0
  93. package/tsconfig.compile.esm.json +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-test-sdk",
3
- "version": "7.18.2",
3
+ "version": "7.18.3",
4
4
  "description": "Package to test platform adapter integration with Ts.ED",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -14,10 +14,11 @@
14
14
  "default": "./lib/esm/index.js"
15
15
  },
16
16
  "scripts": {
17
- "build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
18
- "build:cjs": "tsc --build tsconfig.compile.json",
19
- "build:esm": "tsc --build tsconfig.compile.esm.json",
20
- "barrels": "yarn barrelsby --delete -d ./src -d ./src/interfaces -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\""
17
+ "build": "yarn barrels && yarn build:ts",
18
+ "barrels": "yarn barrelsby --delete -d ./src -d ./src/interfaces -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
19
+ "build:ts": "tsc --build tsconfig.json && tsc --build tsconfig.esm.json",
20
+ "lint": "eslint '**/*.{ts,js}'",
21
+ "lint:fix": "eslint '**/*.{ts,js}' --fix"
21
22
  },
22
23
  "keywords": [
23
24
  "Ts.ED",
@@ -27,22 +28,27 @@
27
28
  "Adapter"
28
29
  ],
29
30
  "dependencies": {
30
- "@tsed/ajv": "7.18.2",
31
- "@tsed/common": "7.18.2",
32
- "@tsed/core": "7.18.2",
33
- "@tsed/di": "7.18.2",
34
- "@tsed/json-mapper": "7.18.2",
31
+ "@tsed/ajv": "7.18.3",
32
+ "@tsed/common": "7.18.3",
33
+ "@tsed/core": "7.18.3",
34
+ "@tsed/di": "7.18.3",
35
+ "@tsed/json-mapper": "7.18.3",
35
36
  "@tsed/logger": "6.2.2",
36
- "@tsed/platform-cache": "7.18.2",
37
- "@tsed/platform-params": "7.18.2",
38
- "@tsed/platform-router": "7.18.2",
39
- "@tsed/platform-views": "7.18.2",
40
- "@tsed/schema": "7.18.2",
41
- "@tsed/swagger": "7.18.2",
37
+ "@tsed/platform-cache": "7.18.3",
38
+ "@tsed/platform-params": "7.18.3",
39
+ "@tsed/platform-router": "7.18.3",
40
+ "@tsed/platform-views": "7.18.3",
41
+ "@tsed/schema": "7.18.3",
42
+ "@tsed/swagger": "7.18.3",
42
43
  "ajv": "^8.12.0",
43
- "axios": "^1.3.0"
44
+ "axios": "^1.3.0",
45
+ "read-pkg-up": "7.0.1"
46
+ },
47
+ "devDependencies": {
48
+ "@tsed/eslint": "7.18.3",
49
+ "@tsed/typescript": "7.18.3",
50
+ "eslint": "^8.12.0"
44
51
  },
45
- "devDependencies": {},
46
52
  "peerDependencies": {},
47
53
  "repository": "https://github.com/tsedio/tsed",
48
54
  "bugs": {
@@ -1,6 +1,6 @@
1
1
  import "@tsed/ajv";
2
- import {BodyParams, Context, Controller, HeaderParams, PlatformTest, Post, RawBodyParams} from "@tsed/common";
3
- import {Default, Description, GenericOf, Generics, Maximum, Minimum, Nullable, Property, Required, Status} from "@tsed/schema";
2
+ import {BodyParams, Context, Controller, HeaderParams, PlatformTest, RawBodyParams} from "@tsed/common";
3
+ import {Post, Default, Description, GenericOf, Generics, Maximum, Minimum, Nullable, Property, Required, Status} from "@tsed/schema";
4
4
  import SuperTest from "supertest";
5
5
  import {PlatformTestingSdkOpts} from "../interfaces";
6
6
 
@@ -1,10 +1,15 @@
1
- import {BodyParams, Controller, MulterOptions, MultipartFile, PlatformMulterFile, PlatformTest, Post} from "@tsed/common";
2
- import {CollectionOf, Property, Required, Status} from "@tsed/schema";
3
- import {Request} from "express";
1
+ import {BodyParams, Controller, MulterOptions, MultipartFile, PlatformMulterFile, PlatformTest} from "@tsed/common";
2
+ import {CollectionOf, Post, Property, Required, Status} from "@tsed/schema";
3
+ import filedirname from "filedirname";
4
4
  import multer, {FileFilterCallback} from "multer";
5
+ import {dirname, join} from "path";
6
+ import readPkgUp from "read-pkg-up";
5
7
  import SuperTest from "supertest";
6
8
  import {PlatformTestingSdkOpts} from "../interfaces";
7
9
 
10
+ // FIXME remove when esm is ready
11
+ const [, rootDir] = filedirname();
12
+
8
13
  export class Task {
9
14
  @Property()
10
15
  id: string;
@@ -23,7 +28,7 @@ export class Event {
23
28
  }
24
29
 
25
30
  const fileFilterStub = jest.fn();
26
- const fileFilter = (req: Request, file: PlatformMulterFile, callback: FileFilterCallback) => {
31
+ const fileFilter = (req: any, file: PlatformMulterFile, callback: FileFilterCallback) => {
27
32
  fileFilterStub();
28
33
  callback(null, true);
29
34
  };
@@ -31,8 +36,8 @@ const fileFilter = (req: Request, file: PlatformMulterFile, callback: FileFilter
31
36
  function getFileConfig(): any {
32
37
  return {
33
38
  storage: multer.diskStorage({
34
- destination: (req: Express.Request, _fileItem, cb) => {
35
- const path = `${__dirname}/../.tmp`;
39
+ destination: (req: any, _fileItem, cb) => {
40
+ const path = `${rootDir}/../.tmp`;
36
41
  cb(null, path);
37
42
  }
38
43
  }),
@@ -44,14 +49,14 @@ function getFileConfig(): any {
44
49
  export class TestMulterController {
45
50
  @Post("/scenario-1")
46
51
  @Status(201)
47
- @MulterOptions({dest: `${__dirname}/../.tmp`})
52
+ @MulterOptions({dest: `${rootDir}/../.tmp`})
48
53
  uploadWithName(@Required() @MultipartFile("media") media: PlatformMulterFile) {
49
54
  return media.originalname;
50
55
  }
51
56
 
52
57
  @Post("/scenario-2")
53
58
  @Status(201)
54
- @MulterOptions({dest: `${__dirname}/../.tmp`})
59
+ @MulterOptions({dest: `${rootDir}/../.tmp`})
55
60
  uploadWithPayload(@MultipartFile("media") media: PlatformMulterFile, @BodyParams("form_id") formId: string) {
56
61
  return {
57
62
  file: media.originalname,
@@ -72,6 +77,13 @@ export class TestMulterController {
72
77
  export function testMulter(options: PlatformTestingSdkOpts) {
73
78
  let request: SuperTest.SuperTest<SuperTest.Test>;
74
79
 
80
+ const buffer = Buffer.from("test content");
81
+
82
+ const pkg = readPkgUp.sync({
83
+ cwd: __dirname
84
+ });
85
+ const rootDir = join(dirname(pkg?.path || ""), "src");
86
+
75
87
  beforeAll(
76
88
  PlatformTest.bootstrap(options.server, {
77
89
  ...options,
@@ -87,7 +99,7 @@ export function testMulter(options: PlatformTestingSdkOpts) {
87
99
  beforeAll(() => jest.resetAllMocks());
88
100
  describe("Scenario 1: POST /rest/multer/scenario-1", () => {
89
101
  it("should upload file with multer", async () => {
90
- const result = await request.post("/rest/multer/scenario-1").attach("media", `${__dirname}/../data/file.txt`).expect(201);
102
+ const result = await request.post("/rest/multer/scenario-1").attach("media", `${rootDir}/data/file.txt`).expect(201);
91
103
 
92
104
  expect(result.text).toEqual("file.txt");
93
105
  });
@@ -116,7 +128,7 @@ export function testMulter(options: PlatformTestingSdkOpts) {
116
128
  it("should upload file with multer", async () => {
117
129
  const result = await request
118
130
  .post("/rest/multer/scenario-2")
119
- .attach("media", `${__dirname}/../data/file.txt`)
131
+ .attach("media", `${rootDir}/data/file.txt`)
120
132
  .field({
121
133
  form_id: "form_id"
122
134
  })
@@ -127,7 +139,7 @@ export function testMulter(options: PlatformTestingSdkOpts) {
127
139
  });
128
140
  describe("Scenario 3: POST /rest/multer/scenario-3", () => {
129
141
  it("should upload file with multer", async () => {
130
- const result = await request.post("/rest/multer/scenario-3").attach("media", `${__dirname}/../data/file.txt`).field({}).expect(201);
142
+ const result = await request.post("/rest/multer/scenario-3").attach("media", `${rootDir}/data/file.txt`).field({}).expect(201);
131
143
 
132
144
  expect(result.body).toEqual({
133
145
  file: "file.txt"
@@ -1,12 +1,15 @@
1
1
  import {Context, Controller, Get, getContext, PathParams, PlatformResponse, PlatformTest, Post, Res} from "@tsed/common";
2
2
  import {CollectionOf, ContentType, Enum, ForwardGroups, Groups, Ignore, Name, Property, Required, Returns, Status} from "@tsed/schema";
3
3
  import axios from "axios";
4
+ import filedirname from "filedirname";
4
5
  import {createReadStream} from "fs";
5
6
  import {join} from "path";
6
7
  import {of} from "rxjs";
7
8
  import {agent, SuperAgentStatic} from "superagent";
8
9
  import SuperTest from "supertest";
9
10
  import {PlatformTestingSdkOpts} from "../interfaces";
11
+ // FIXME remove when esm is ready
12
+ const [, rootDir] = filedirname();
10
13
 
11
14
  class Base {
12
15
  @Ignore()
@@ -131,13 +134,13 @@ class TestResponseParamsCtrl {
131
134
  @Get("/scenario7")
132
135
  @ContentType("application/json")
133
136
  testScenario7Stream() {
134
- return createReadStream(join(__dirname, "../data/response.data.json"));
137
+ return createReadStream(join(rootDir, "../data/response.data.json"));
135
138
  }
136
139
 
137
140
  @Get("/scenario7b")
138
141
  @ContentType("application/json")
139
142
  async testScenario7bStream() {
140
- return createReadStream(join(__dirname, "../data/response.data.json"));
143
+ return createReadStream(join(rootDir, "../data/response.data.json"));
141
144
  }
142
145
 
143
146
  @Get("/scenario9/static")
@@ -0,0 +1,63 @@
1
+ {
2
+ "extends": "@tsed/typescript/tsconfig.node.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types",
10
+ "composite": true,
11
+ "noEmit": false
12
+ },
13
+ "include": ["src", "src/**/*.json"],
14
+ "exclude": [
15
+ "node_modules",
16
+ "test",
17
+ "lib",
18
+ "benchmark",
19
+ "coverage",
20
+ "spec",
21
+ "**/*.benchmark.ts",
22
+ "**/*.spec.ts",
23
+ "keys",
24
+ "jest.config.js",
25
+ "**/__mock__/**",
26
+ "webpack.config.js"
27
+ ],
28
+ "references": [
29
+ {
30
+ "path": "../../specs/ajv"
31
+ },
32
+ {
33
+ "path": "../common"
34
+ },
35
+ {
36
+ "path": "../../core"
37
+ },
38
+ {
39
+ "path": "../../di"
40
+ },
41
+ {
42
+ "path": "../../specs/json-mapper"
43
+ },
44
+ {
45
+ "path": "../platform-cache"
46
+ },
47
+ {
48
+ "path": "../platform-params"
49
+ },
50
+ {
51
+ "path": "../platform-router"
52
+ },
53
+ {
54
+ "path": "../platform-views"
55
+ },
56
+ {
57
+ "path": "../../specs/schema"
58
+ },
59
+ {
60
+ "path": "../../specs/swagger"
61
+ }
62
+ ]
63
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "extends": "@tsed/typescript/tsconfig.node.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "commonjs",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/cjs",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types",
10
+ "composite": true,
11
+ "noEmit": false
12
+ },
13
+ "include": ["src", "src/**/*.json"],
14
+ "exclude": [
15
+ "node_modules",
16
+ "test",
17
+ "lib",
18
+ "benchmark",
19
+ "coverage",
20
+ "spec",
21
+ "**/*.benchmark.ts",
22
+ "**/*.spec.ts",
23
+ "keys",
24
+ "jest.config.js",
25
+ "**/__mock__/**",
26
+ "webpack.config.js"
27
+ ],
28
+ "references": [
29
+ {
30
+ "path": "../../specs/ajv"
31
+ },
32
+ {
33
+ "path": "../common"
34
+ },
35
+ {
36
+ "path": "../../core"
37
+ },
38
+ {
39
+ "path": "../../di"
40
+ },
41
+ {
42
+ "path": "../../specs/json-mapper"
43
+ },
44
+ {
45
+ "path": "../platform-cache"
46
+ },
47
+ {
48
+ "path": "../platform-params"
49
+ },
50
+ {
51
+ "path": "../platform-router"
52
+ },
53
+ {
54
+ "path": "../platform-views"
55
+ },
56
+ {
57
+ "path": "../../specs/schema"
58
+ },
59
+ {
60
+ "path": "../../specs/swagger"
61
+ }
62
+ ]
63
+ }
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "./tsconfig.compile.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "module": "ES2020",
6
- "rootDir": "src",
7
- "outDir": "./lib/esm",
8
- "declaration": true,
9
- "declarationDir": "./lib/types"
10
- },
11
- "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
12
- }