@visulima/api-platform 1.0.2 → 1.0.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 (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/bin/index.js +46 -0
  3. package/dist/{chunk-XXZ56SKG.mjs → chunk-2M45MXC2.mjs} +1 -2
  4. package/dist/chunk-2M45MXC2.mjs.map +1 -0
  5. package/dist/chunk-3Y3YBDRS.mjs +284 -0
  6. package/dist/chunk-3Y3YBDRS.mjs.map +1 -0
  7. package/dist/chunk-NY75KGAH.js +284 -0
  8. package/dist/chunk-NY75KGAH.js.map +1 -0
  9. package/dist/{chunk-AJKZCWFG.js → chunk-S46GRBOS.js} +1 -2
  10. package/dist/chunk-S46GRBOS.js.map +1 -0
  11. package/dist/index-server.d.ts +2 -0
  12. package/dist/index-server.js +9 -10
  13. package/dist/index-server.js.map +1 -1
  14. package/dist/index-server.mjs +7 -8
  15. package/dist/index-server.mjs.map +1 -1
  16. package/dist/next/cli/index.js +8 -8
  17. package/dist/next/cli/index.js.map +1 -1
  18. package/dist/next/cli/index.mjs +8 -8
  19. package/dist/next/cli/index.mjs.map +1 -1
  20. package/dist/next/index-browser.js +2 -2
  21. package/dist/next/index-browser.mjs +1 -1
  22. package/dist/next/index-server.d.ts +9 -5
  23. package/dist/next/index-server.js +4 -4
  24. package/dist/next/index-server.mjs +2 -2
  25. package/next/cli/package.json +12 -3
  26. package/next/package.json +9 -0
  27. package/package.json +20 -20
  28. package/recipes/api/swagger.ts +12 -0
  29. package/recipes/pages/redoc-ui.tsx +5 -0
  30. package/recipes/pages/swagger-ui.tsx +5 -0
  31. package/dist/chunk-2LATTLUM.mjs +0 -166
  32. package/dist/chunk-2LATTLUM.mjs.map +0 -1
  33. package/dist/chunk-AJKZCWFG.js.map +0 -1
  34. package/dist/chunk-S7GUPAL4.js +0 -166
  35. package/dist/chunk-S7GUPAL4.js.map +0 -1
  36. package/dist/chunk-XXZ56SKG.mjs.map +0 -1
  37. package/src/connect/create-node-router.ts +0 -44
  38. package/src/connect/handler.ts +0 -46
  39. package/src/connect/middleware/cors-middleware.ts +0 -10
  40. package/src/connect/middleware/http-header-normalizer.ts +0 -93
  41. package/src/connect/middleware/rate-limiter-middleware.ts +0 -43
  42. package/src/connect/middleware/serializers-middleware.ts +0 -121
  43. package/src/connect/serializers/types.d.ts +0 -1
  44. package/src/connect/serializers/xml.ts +0 -13
  45. package/src/connect/serializers/yaml.ts +0 -7
  46. package/src/error-handler/jsonapi-error-handler.ts +0 -46
  47. package/src/error-handler/problem-error-handler.ts +0 -44
  48. package/src/error-handler/types.d.ts +0 -14
  49. package/src/error-handler/utils.ts +0 -39
  50. package/src/index-browser.tsx +0 -1
  51. package/src/index-server.ts +0 -75
  52. package/src/next/cli/index.ts +0 -2
  53. package/src/next/cli/list/api-route-file-parser.ts +0 -74
  54. package/src/next/cli/list/collect-api-route-files.ts +0 -42
  55. package/src/next/cli/list/list-command.ts +0 -105
  56. package/src/next/cli/list/routes-render.ts +0 -62
  57. package/src/next/cli/list/types.d.ts +0 -1
  58. package/src/next/index-browser.tsx +0 -3
  59. package/src/next/index-server.ts +0 -6
  60. package/src/next/routes/api/swagger.ts +0 -23
  61. package/src/next/routes/pages/swagger/get-static-properties-swagger.ts +0 -32
  62. package/src/next/routes/pages/swagger/redoc.tsx +0 -35
  63. package/src/next/routes/pages/swagger/swagger.tsx +0 -44
  64. package/src/next/webpack/with-open-api.ts +0 -63
  65. package/src/swagger/extend-swagger-spec.ts +0 -167
  66. package/src/swagger/swagger-handler.ts +0 -83
  67. package/src/utils.ts +0 -37
  68. package/src/zod/date-in-schema.ts +0 -57
  69. package/src/zod/date-out-schema.ts +0 -41
  70. package/src/zod/index.ts +0 -9
package/src/utils.ts DELETED
@@ -1,37 +0,0 @@
1
- import { IncomingMessage } from "node:http";
2
- import { parse as urlParse } from "node:url";
3
-
4
- type IncomingApiRequest<TApiRequest = IncomingMessage> = TApiRequest & {
5
- body?: any;
6
- query?: any;
7
- };
8
-
9
- export const jsonResponse = (response: any, status: number, data?: unknown): void => {
10
- response.statusCode = status;
11
- response.setHeader("Content-Type", "application/json");
12
- response.end(data ? JSON.stringify(data) : "");
13
- };
14
-
15
- export const parseBody = async (request: IncomingApiRequest): Promise<unknown> => {
16
- if (request.body) {
17
- return request.body;
18
- }
19
-
20
- const buffers = [];
21
-
22
- // eslint-disable-next-line no-restricted-syntax
23
- for await (const chunk of request) {
24
- buffers.push(chunk);
25
- }
26
-
27
- const data = Buffer.concat(buffers).toString();
28
-
29
- return data ? JSON.parse(data) : null;
30
- };
31
-
32
- export const parseQuery = (request: IncomingApiRequest): unknown => {
33
- if (request.query) {
34
- return request.query;
35
- }
36
- return urlParse(request.url ?? "", true).query;
37
- };
@@ -1,57 +0,0 @@
1
- import type { ParseInput, ParseReturnType, ZodTypeDef } from "zod";
2
- import {
3
- addIssueToContext, INVALID, ZodIssueCode, ZodParsedType, ZodType,
4
- } from "zod";
5
-
6
- const zodDateInKind = "ZodDateIn";
7
-
8
- // simple regex for ISO date, supports the following formats:
9
- // 2021-01-01T00:00:00.000Z
10
- // 2021-01-01T00:00:00Z
11
- // 2021-01-01T00:00:00
12
- // 2021-01-01
13
- export const isoDateRegex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?)?Z?$/;
14
-
15
- // eslint-disable-next-line unicorn/prevent-abbreviations
16
- export interface ZodDateInDef extends ZodTypeDef {
17
- typeName: typeof zodDateInKind;
18
- }
19
-
20
- export class ZodDateIn extends ZodType<Date, ZodDateInDef, string> {
21
- // eslint-disable-next-line no-underscore-dangle
22
- _parse(input: ParseInput): ParseReturnType<Date> {
23
- // eslint-disable-next-line no-underscore-dangle
24
- const { status, ctx } = this._processInputParams(input);
25
- if (ctx.parsedType !== ZodParsedType.string) {
26
- addIssueToContext(ctx, {
27
- code: ZodIssueCode.invalid_type,
28
- expected: ZodParsedType.string,
29
- received: ctx.parsedType,
30
- });
31
- return INVALID;
32
- }
33
-
34
- if (!isoDateRegex.test(ctx.data as string)) {
35
- addIssueToContext(ctx, {
36
- code: ZodIssueCode.invalid_string,
37
- validation: "regex",
38
- });
39
- status.dirty();
40
- }
41
-
42
- const date = new Date(ctx.data);
43
-
44
- if (Number.isNaN(date.getTime())) {
45
- addIssueToContext(ctx, {
46
- code: ZodIssueCode.invalid_date,
47
- });
48
- return INVALID;
49
- }
50
-
51
- return { status: status.value, value: date };
52
- }
53
-
54
- static create = () => new ZodDateIn({
55
- typeName: zodDateInKind,
56
- });
57
- }
@@ -1,41 +0,0 @@
1
- import type { ParseInput, ParseReturnType, ZodTypeDef } from "zod";
2
- import {
3
- addIssueToContext, INVALID, ZodIssueCode, ZodParsedType, ZodType,
4
- } from "zod";
5
-
6
- const zodDateOutKind = "ZodDateOut";
7
-
8
- // eslint-disable-next-line unicorn/prevent-abbreviations
9
- export interface ZodDateOutDef extends ZodTypeDef {
10
- typeName: typeof zodDateOutKind;
11
- }
12
-
13
- export class ZodDateOut extends ZodType<string, ZodDateOutDef, Date> {
14
- // eslint-disable-next-line no-underscore-dangle
15
- _parse(input: ParseInput): ParseReturnType<string> {
16
- // eslint-disable-next-line no-underscore-dangle
17
- const { status, ctx } = this._processInputParams(input);
18
-
19
- if (ctx.parsedType !== ZodParsedType.date) {
20
- addIssueToContext(ctx, {
21
- code: ZodIssueCode.invalid_type,
22
- expected: ZodParsedType.date,
23
- received: ctx.parsedType,
24
- });
25
- return INVALID;
26
- }
27
-
28
- if (Number.isNaN(ctx.data.getTime())) {
29
- addIssueToContext(ctx, {
30
- code: ZodIssueCode.invalid_date,
31
- });
32
- return INVALID;
33
- }
34
-
35
- return { status: status.value, value: (ctx.data as Date).toISOString() };
36
- }
37
-
38
- static create = () => new ZodDateOut({
39
- typeName: zodDateOutKind,
40
- });
41
- }
package/src/zod/index.ts DELETED
@@ -1,9 +0,0 @@
1
- import { withGetType } from "zod-to-ts";
2
-
3
- import { ZodDateIn } from "./date-in-schema";
4
- import { ZodDateOut } from "./date-out-schema";
5
-
6
- // eslint-disable-next-line max-len
7
- export const dateIn = (...parameters: Parameters<typeof ZodDateIn.create>) => withGetType(ZodDateIn.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
8
- // eslint-disable-next-line max-len
9
- export const dateOut = (...parameters: Parameters<typeof ZodDateOut.create>) => withGetType(ZodDateOut.create(...parameters), (ts) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));