adorn-api 1.1.10 → 1.1.12

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 (68) hide show
  1. package/dist/adapter/express/index.js +1 -1
  2. package/dist/adapter/express/types.d.ts +5 -46
  3. package/dist/adapter/fastify/coercion.d.ts +12 -0
  4. package/dist/adapter/fastify/coercion.js +289 -0
  5. package/dist/adapter/fastify/controllers.d.ts +7 -0
  6. package/dist/adapter/fastify/controllers.js +201 -0
  7. package/dist/adapter/fastify/index.d.ts +14 -0
  8. package/dist/adapter/fastify/index.js +67 -0
  9. package/dist/adapter/fastify/multipart.d.ts +26 -0
  10. package/dist/adapter/fastify/multipart.js +75 -0
  11. package/dist/adapter/fastify/openapi.d.ts +10 -0
  12. package/dist/adapter/fastify/openapi.js +76 -0
  13. package/dist/adapter/fastify/response-serializer.d.ts +2 -0
  14. package/dist/adapter/fastify/response-serializer.js +162 -0
  15. package/dist/adapter/fastify/types.d.ts +100 -0
  16. package/dist/adapter/fastify/types.js +2 -0
  17. package/dist/adapter/native/coercion.d.ts +12 -0
  18. package/dist/adapter/native/coercion.js +289 -0
  19. package/dist/adapter/native/controllers.d.ts +17 -0
  20. package/dist/adapter/native/controllers.js +215 -0
  21. package/dist/adapter/native/index.d.ts +14 -0
  22. package/dist/adapter/native/index.js +127 -0
  23. package/dist/adapter/native/openapi.d.ts +7 -0
  24. package/dist/adapter/native/openapi.js +82 -0
  25. package/dist/adapter/native/response-serializer.d.ts +5 -0
  26. package/dist/adapter/native/response-serializer.js +160 -0
  27. package/dist/adapter/native/router.d.ts +25 -0
  28. package/dist/adapter/native/router.js +68 -0
  29. package/dist/adapter/native/types.d.ts +77 -0
  30. package/dist/adapter/native/types.js +2 -0
  31. package/dist/core/auth.d.ts +11 -12
  32. package/dist/core/auth.js +2 -2
  33. package/dist/core/logger.d.ts +3 -4
  34. package/dist/core/logger.js +2 -2
  35. package/dist/core/streaming.d.ts +10 -10
  36. package/dist/core/streaming.js +31 -19
  37. package/dist/core/types.d.ts +102 -0
  38. package/dist/index.d.ts +6 -1
  39. package/dist/index.js +16 -1
  40. package/examples/fastify/app.ts +16 -0
  41. package/examples/fastify/index.ts +21 -0
  42. package/package.json +22 -18
  43. package/src/adapter/express/controllers.ts +249 -249
  44. package/src/adapter/express/types.ts +121 -160
  45. package/src/adapter/fastify/coercion.ts +369 -0
  46. package/src/adapter/fastify/controllers.ts +255 -0
  47. package/src/adapter/fastify/index.ts +53 -0
  48. package/src/adapter/fastify/multipart.ts +94 -0
  49. package/src/adapter/fastify/openapi.ts +93 -0
  50. package/src/adapter/fastify/response-serializer.ts +179 -0
  51. package/src/adapter/fastify/types.ts +119 -0
  52. package/src/adapter/native/coercion.ts +369 -0
  53. package/src/adapter/native/controllers.ts +271 -0
  54. package/src/adapter/native/index.ts +116 -0
  55. package/src/adapter/native/openapi.ts +109 -0
  56. package/src/adapter/native/response-serializer.ts +177 -0
  57. package/src/adapter/native/router.ts +90 -0
  58. package/src/adapter/native/types.ts +96 -0
  59. package/src/core/auth.ts +314 -315
  60. package/src/core/health.ts +234 -235
  61. package/src/core/logger.ts +245 -247
  62. package/src/core/streaming.ts +342 -330
  63. package/src/core/types.ts +115 -0
  64. package/src/index.ts +46 -16
  65. package/tests/e2e/fastify.e2e.test.ts +174 -0
  66. package/tests/native.test.ts +191 -0
  67. package/tests/unit/openapi-parameters.test.ts +97 -97
  68. package/tsconfig.json +14 -13
@@ -1,97 +1,97 @@
1
- import { describe, expect, it, beforeEach } from "vitest";
2
- import { t } from "../../src/core/schema";
3
- import { registerController, registerDto } from "../../src/core/metadata";
4
- import { buildOpenApi } from "../../src/core/openapi";
5
- import { createInputCoercer } from "../../src/adapter/express/coercion";
6
-
7
- describe("OpenAPI query parameter serialization", () => {
8
- class QueryArrayController {}
9
-
10
- beforeEach(() => {
11
- registerController({
12
- basePath: "/items",
13
- controller: QueryArrayController,
14
- routes: [
15
- {
16
- httpMethod: "get",
17
- path: "/",
18
- handlerName: "list",
19
- query: {
20
- schema: {
21
- kind: "object",
22
- properties: {
23
- ids: t.array(t.string()),
24
- nums: t.array(t.integer()),
25
- tags: t.array(t.string(), { examples: [["a", "b"]] })
26
- }
27
- }
28
- },
29
- responses: [{ status: 200 }]
30
- }
31
- ]
32
- });
33
- });
34
-
35
- it("query array<string> generates style=form + explode=true", () => {
36
- const doc = buildOpenApi({
37
- info: { title: "test", version: "1.0.0" },
38
- controllers: [QueryArrayController]
39
- });
40
-
41
- const params = (doc.paths["/items"] as any).get.parameters as any[];
42
- const idsParam = params.find((p: any) => p.name === "ids");
43
-
44
- expect(idsParam).toBeDefined();
45
- expect(idsParam.style).toBe("form");
46
- expect(idsParam.explode).toBe(true);
47
- });
48
-
49
- it("query array<integer> generates style=form + explode=true", () => {
50
- const doc = buildOpenApi({
51
- info: { title: "test", version: "1.0.0" },
52
- controllers: [QueryArrayController]
53
- });
54
-
55
- const params = (doc.paths["/items"] as any).get.parameters as any[];
56
- const numsParam = params.find((p: any) => p.name === "nums");
57
-
58
- expect(numsParam).toBeDefined();
59
- expect(numsParam.style).toBe("form");
60
- expect(numsParam.explode).toBe(true);
61
- });
62
-
63
- it("projects example from schema.examples to parameter.example", () => {
64
- const doc = buildOpenApi({
65
- info: { title: "test", version: "1.0.0" },
66
- controllers: [QueryArrayController]
67
- });
68
-
69
- const params = (doc.paths["/items"] as any).get.parameters as any[];
70
- const tagsParam = params.find((p: any) => p.name === "tags");
71
-
72
- expect(tagsParam).toBeDefined();
73
- expect(tagsParam.example).toEqual(["a", "b"]);
74
- });
75
- });
76
-
77
- describe("Query array coercion – CSV support", () => {
78
- it("?ids=1&ids=2 -> [1,2] via repeated keys", () => {
79
- const coerce = createInputCoercer(
80
- { schema: { kind: "object", properties: { ids: t.array(t.integer()) } } },
81
- { mode: "safe", location: "query" }
82
- )!;
83
-
84
- const result = coerce({ ids: ["1", "2"] });
85
- expect(result.ids).toEqual([1, 2]);
86
- });
87
-
88
- it("?ids=1,2 -> [1,2] via CSV string", () => {
89
- const coerce = createInputCoercer(
90
- { schema: { kind: "object", properties: { ids: t.array(t.integer()) } } },
91
- { mode: "safe", location: "query" }
92
- )!;
93
-
94
- const result = coerce({ ids: "1,2" });
95
- expect(result.ids).toEqual([1, 2]);
96
- });
97
- });
1
+ import { describe, expect, it, beforeEach } from "vitest";
2
+ import { t } from "../../src/core/schema";
3
+ import { registerController } from "../../src/core/metadata";
4
+ import { buildOpenApi } from "../../src/core/openapi";
5
+ import { createInputCoercer } from "../../src/adapter/express/coercion";
6
+
7
+ describe("OpenAPI query parameter serialization", () => {
8
+ class QueryArrayController {}
9
+
10
+ beforeEach(() => {
11
+ registerController({
12
+ basePath: "/items",
13
+ controller: QueryArrayController,
14
+ routes: [
15
+ {
16
+ httpMethod: "get",
17
+ path: "/",
18
+ handlerName: "list",
19
+ query: {
20
+ schema: {
21
+ kind: "object",
22
+ properties: {
23
+ ids: t.array(t.string()),
24
+ nums: t.array(t.integer()),
25
+ tags: t.array(t.string(), { examples: [["a", "b"]] })
26
+ }
27
+ }
28
+ },
29
+ responses: [{ status: 200 }]
30
+ }
31
+ ]
32
+ });
33
+ });
34
+
35
+ it("query array<string> generates style=form + explode=true", () => {
36
+ const doc = buildOpenApi({
37
+ info: { title: "test", version: "1.0.0" },
38
+ controllers: [QueryArrayController]
39
+ });
40
+
41
+ const params = (doc.paths["/items"] as any).get.parameters as any[];
42
+ const idsParam = params.find((p: any) => p.name === "ids");
43
+
44
+ expect(idsParam).toBeDefined();
45
+ expect(idsParam.style).toBe("form");
46
+ expect(idsParam.explode).toBe(true);
47
+ });
48
+
49
+ it("query array<integer> generates style=form + explode=true", () => {
50
+ const doc = buildOpenApi({
51
+ info: { title: "test", version: "1.0.0" },
52
+ controllers: [QueryArrayController]
53
+ });
54
+
55
+ const params = (doc.paths["/items"] as any).get.parameters as any[];
56
+ const numsParam = params.find((p: any) => p.name === "nums");
57
+
58
+ expect(numsParam).toBeDefined();
59
+ expect(numsParam.style).toBe("form");
60
+ expect(numsParam.explode).toBe(true);
61
+ });
62
+
63
+ it("projects example from schema.examples to parameter.example", () => {
64
+ const doc = buildOpenApi({
65
+ info: { title: "test", version: "1.0.0" },
66
+ controllers: [QueryArrayController]
67
+ });
68
+
69
+ const params = (doc.paths["/items"] as any).get.parameters as any[];
70
+ const tagsParam = params.find((p: any) => p.name === "tags");
71
+
72
+ expect(tagsParam).toBeDefined();
73
+ expect(tagsParam.example).toEqual(["a", "b"]);
74
+ });
75
+ });
76
+
77
+ describe("Query array coercion – CSV support", () => {
78
+ it("?ids=1&ids=2 -> [1,2] via repeated keys", () => {
79
+ const coerce = createInputCoercer(
80
+ { schema: { kind: "object", properties: { ids: t.array(t.integer()) } } },
81
+ { mode: "safe", location: "query" }
82
+ )!;
83
+
84
+ const result = coerce({ ids: ["1", "2"] });
85
+ expect(result.ids).toEqual([1, 2]);
86
+ });
87
+
88
+ it("?ids=1,2 -> [1,2] via CSV string", () => {
89
+ const coerce = createInputCoercer(
90
+ { schema: { kind: "object", properties: { ids: t.array(t.integer()) } } },
91
+ { mode: "safe", location: "query" }
92
+ )!;
93
+
94
+ const result = coerce({ ids: "1,2" });
95
+ expect(result.ids).toEqual([1, 2]);
96
+ });
97
+ });
package/tsconfig.json CHANGED
@@ -1,18 +1,19 @@
1
- {
1
+ {
2
2
  "compilerOptions": {
3
3
  "target": "ES2022",
4
4
  "module": "CommonJS",
5
5
  "moduleResolution": "Node",
6
+ "ignoreDeprecations": "6.0",
6
7
  "rootDir": "src",
7
- "outDir": "dist",
8
- "declaration": true,
9
- "strict": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "esModuleInterop": true,
13
- "useDefineForClassFields": true,
14
- "experimentalDecorators": false,
15
- "emitDecoratorMetadata": false
16
- },
17
- "include": ["src"]
18
- }
8
+ "outDir": "dist",
9
+ "declaration": true,
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "esModuleInterop": true,
14
+ "useDefineForClassFields": true,
15
+ "experimentalDecorators": false,
16
+ "emitDecoratorMetadata": false
17
+ },
18
+ "include": ["src"]
19
+ }