arkos 1.2.15-test → 1.2.16-test
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/README.md +22 -14
- package/cli.js +2 -11
- package/dist/cjs/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/modules/base/base.controller.js +11 -12
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.router.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +41 -27
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/swagger/swagger.router.js +14 -56
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +250 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +66 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +41 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +22 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +30 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +442 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +165 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +93 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
- package/dist/cjs/paths.js +1 -1
- package/dist/cjs/server.js +2 -2
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/utils/cli/build.js +2 -19
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +13 -28
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +6 -6
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +10 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/fs.helpers.js +12 -5
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/global.helpers.js +38 -2
- package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/models.helpers.js +20 -43
- package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
- package/dist/cjs/utils/sheu.js +143 -0
- package/dist/cjs/utils/sheu.js.map +1 -0
- package/dist/esm/app.js +1 -0
- package/dist/esm/app.js.map +1 -0
- package/dist/{es2020 → esm}/exports/auth/index.js +1 -1
- package/dist/{es2020 → esm}/exports/controllers/index.js +2 -2
- package/dist/{es2020 → esm}/exports/error-handler/index.js +2 -2
- package/dist/{es2020 → esm}/exports/index.js +2 -2
- package/dist/{es2020 → esm}/exports/middlewares/index.js +1 -1
- package/dist/esm/exports/prisma/index.js +3 -0
- package/dist/{es2020 → esm}/exports/services/index.js +4 -4
- package/dist/esm/exports/utils/index.js +4 -0
- package/dist/esm/exports/validation/index.js +4 -0
- package/dist/{es2020 → esm}/modules/auth/auth.controller.js +7 -7
- package/dist/{es2020 → esm}/modules/auth/auth.router.js +6 -6
- package/dist/{es2020 → esm}/modules/auth/auth.service.js +6 -6
- package/dist/{es2020 → esm}/modules/auth/utils/helpers/auth.controller.helpers.js +2 -2
- package/dist/{es2020 → esm}/modules/base/base.controller.js +18 -19
- package/dist/esm/modules/base/base.controller.js.map +1 -0
- package/dist/{es2020 → esm}/modules/base/base.middlewares.js +6 -6
- package/dist/{es2020 → esm}/modules/base/base.router.js +4 -4
- package/dist/esm/modules/base/base.router.js.map +1 -0
- package/dist/{es2020 → esm}/modules/base/base.service.js +6 -6
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.controller.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.middlewares.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.router.helpers.js +45 -33
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.service.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/email/email.service.js +2 -2
- package/dist/{es2020 → esm}/modules/error-handler/error-handler.controller.js +3 -3
- package/dist/{es2020 → esm}/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/{es2020 → esm}/modules/error-handler/utils/error-handler.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/file-upload/file-upload.controller.js +7 -7
- package/dist/{es2020 → esm}/modules/file-upload/file-upload.router.js +5 -5
- package/dist/{es2020 → esm}/modules/file-upload/file-upload.service.js +5 -5
- package/dist/{es2020 → esm}/modules/file-upload/utils/helpers/file-upload.helpers.js +2 -2
- package/dist/{es2020 → esm}/modules/swagger/swagger.router.js +15 -57
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +247 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +63 -0
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +38 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +19 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +24 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +436 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +159 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +83 -0
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
- package/dist/esm/server.js +3 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/types/arkos-config.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/build.js +4 -21
- package/dist/esm/utils/cli/build.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/dev.js +17 -32
- package/dist/esm/utils/cli/dev.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/generate.js +10 -10
- package/dist/{es2020 → esm}/utils/cli/generate.js.map +1 -1
- package/dist/{es2020 → esm}/utils/cli/index.js +5 -5
- package/dist/{es2020 → esm}/utils/cli/start.js +4 -4
- package/dist/esm/utils/cli/utils/cli.helpers.js +27 -0
- package/dist/esm/utils/cli/utils/cli.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +1 -1
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-middlewares.js +1 -1
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +2 -2
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-router-template.js +1 -1
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-service-template.js +2 -2
- package/dist/{es2020 → esm}/utils/cli/utils/template-generators.js +6 -6
- package/dist/{es2020 → esm}/utils/features/api.features.js +4 -4
- package/dist/{es2020 → esm}/utils/features/change-case.features.js +1 -1
- package/dist/{es2020 → esm}/utils/helpers/fs.helpers.js +12 -5
- package/dist/esm/utils/helpers/fs.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/global.helpers.js +35 -0
- package/dist/esm/utils/helpers/global.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/utils/helpers/models.helpers.js +21 -11
- package/dist/esm/utils/helpers/models.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/utils/helpers/prisma.helpers.js +4 -4
- package/dist/esm/utils/sheu.js +141 -0
- package/dist/esm/utils/sheu.js.map +1 -0
- package/dist/{es2020 → esm}/utils/validate-dto.js +1 -1
- package/dist/{es2020 → esm}/utils/validate-schema.js +1 -1
- package/dist/types/modules/auth/auth.controller.d.ts +7 -7
- package/dist/types/modules/auth/auth.service.d.ts +1 -1
- package/dist/types/modules/base/base.controller.d.ts +9 -9
- package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +4 -1
- package/dist/types/modules/error-handler/utils/catch-async.d.ts +1 -1
- package/dist/types/modules/file-upload/file-upload.controller.d.ts +4 -4
- package/dist/types/modules/swagger/swagger.router.d.ts +1 -1
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/get-system-json-schema-paths.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +7 -0
- package/dist/types/types/arkos-config.d.ts +7 -4
- package/dist/types/utils/helpers/global.helpers.d.ts +5 -1
- package/dist/types/utils/helpers/models.helpers.d.ts +10 -1
- package/dist/types/utils/helpers/prisma.helpers.d.ts +1 -1
- package/dist/types/utils/sheu.d.ts +25 -0
- package/package.json +25 -19
- package/dist/es2020/app.js +0 -1
- package/dist/es2020/app.js.map +0 -1
- package/dist/es2020/exports/prisma/index.js +0 -3
- package/dist/es2020/exports/utils/index.js +0 -4
- package/dist/es2020/exports/validation/index.js +0 -4
- package/dist/es2020/modules/base/base.controller.js.map +0 -1
- package/dist/es2020/modules/base/base.router.js.map +0 -1
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
- package/dist/es2020/modules/swagger/swagger.router.js.map +0 -1
- package/dist/es2020/server.js +0 -3
- package/dist/es2020/server.js.map +0 -1
- package/dist/es2020/types/arkos-config.js.map +0 -1
- package/dist/es2020/utils/cli/build.js.map +0 -1
- package/dist/es2020/utils/cli/dev.js.map +0 -1
- package/dist/es2020/utils/cli/utils/cli.helpers.js +0 -18
- package/dist/es2020/utils/cli/utils/cli.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/fs.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/global.helpers.js +0 -4
- package/dist/es2020/utils/helpers/global.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/models.helpers.js.map +0 -1
- /package/dist/{es2020 → esm}/exports/auth/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/controllers/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/error-handler/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/middlewares/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/prisma/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/services/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/utils/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/validation/index.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/auth.controller.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/auth.router.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/auth.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/utils/helpers/auth.controller.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/base.middlewares.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/base.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.controller.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.middlewares.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.service.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/email/email.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/app-error.js +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/app-error.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/catch-async.js +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/catch-async.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/error-handler.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.controller.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.router.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/utils/helpers/file-upload.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/paths.js +0 -0
- /package/dist/{es2020 → esm}/paths.js.map +0 -0
- /package/dist/{es2020 → esm}/types/arkos-config.js +0 -0
- /package/dist/{es2020 → esm}/types/auth.js +0 -0
- /package/dist/{es2020 → esm}/types/auth.js.map +0 -0
- /package/dist/{es2020 → esm}/types/index.js +0 -0
- /package/dist/{es2020 → esm}/types/index.js.map +0 -0
- /package/dist/{es2020 → esm}/types/router-config.js +0 -0
- /package/dist/{es2020 → esm}/types/router-config.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/arkos-env.js +0 -0
- /package/dist/{es2020 → esm}/utils/arkos-env.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/index.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/start.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-service-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generators.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/dotenv.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/dotenv.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/features/api.features.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/features/change-case.features.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/api.features.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/api.features.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/change-case.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/change-case.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/deepmerge.helper.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/deepmerge.helper.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/prisma.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/query-parser.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/query-parser.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/text.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/text.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/validate-dto.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/validate-schema.js.map +0 -0
|
@@ -2,9 +2,9 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import sharp from "sharp";
|
|
4
4
|
import { promisify } from "util";
|
|
5
|
-
import { getArkosConfig } from "../../../../server";
|
|
5
|
+
import { getArkosConfig } from "../../../../server.js";
|
|
6
6
|
import mimetype from "mimetype";
|
|
7
|
-
import { fullCleanCwd } from "../../../../utils/helpers/fs.helpers";
|
|
7
|
+
import { fullCleanCwd } from "../../../../utils/helpers/fs.helpers.js";
|
|
8
8
|
export function extractRequestInfo(req) {
|
|
9
9
|
const { fileUpload } = getArkosConfig();
|
|
10
10
|
const protocol = req.headers["x-forwarded-proto"] === "https" ? "https" : "http";
|
|
@@ -1,54 +1,38 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
2
|
import swaggerUi from "swagger-ui-express";
|
|
3
3
|
import swaggerJsdoc from "swagger-jsdoc";
|
|
4
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
4
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
5
|
+
import { generatePathsForModels, getOpenAPIJsonSchemasByConfigMode, } from "./utils/helpers/swagger.router.helpers.js";
|
|
5
6
|
const swaggerRouter = Router();
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
case "prisma":
|
|
10
|
-
break;
|
|
11
|
-
case "class-validator":
|
|
12
|
-
break;
|
|
13
|
-
case "zod":
|
|
14
|
-
break;
|
|
15
|
-
case "json-schema":
|
|
16
|
-
default:
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
return schemas;
|
|
20
|
-
}
|
|
21
|
-
export function getSwaggerRouter(arkosConfig) {
|
|
7
|
+
export async function getSwaggerRouter(arkosConfig) {
|
|
8
|
+
const defaultJsonSchemas = await getOpenAPIJsonSchemasByConfigMode(arkosConfig.swagger);
|
|
9
|
+
const defaultModelsPaths = await generatePathsForModels(arkosConfig.swagger);
|
|
22
10
|
const defaultSwaggerConfig = {
|
|
23
|
-
endpoint: "/docs",
|
|
24
|
-
mode: "
|
|
11
|
+
endpoint: "/api-docs",
|
|
12
|
+
mode: "prisma",
|
|
25
13
|
options: {
|
|
26
14
|
definition: {
|
|
27
15
|
openapi: "3.0.0",
|
|
28
16
|
info: {
|
|
29
|
-
title: "
|
|
17
|
+
title: "Powered By Arkos.js",
|
|
30
18
|
version: "1.0.0",
|
|
31
|
-
description: "This API was automatically generated by Arkos.js read more about at www.arkosjs.com",
|
|
19
|
+
description: "This API was automatically generated by Arkos.js, read more about at www.arkosjs.com",
|
|
32
20
|
},
|
|
33
21
|
servers: [
|
|
34
22
|
{
|
|
35
23
|
url: `http://${arkosConfig.host}:${arkosConfig.port}`,
|
|
36
|
-
description: "
|
|
24
|
+
description: "Development server",
|
|
37
25
|
},
|
|
38
26
|
],
|
|
27
|
+
paths: defaultModelsPaths,
|
|
39
28
|
components: {
|
|
40
|
-
schemas: {},
|
|
29
|
+
schemas: defaultJsonSchemas || {},
|
|
41
30
|
securitySchemes: {
|
|
42
31
|
BearerAuth: {
|
|
43
32
|
type: "http",
|
|
44
33
|
scheme: "bearer",
|
|
45
34
|
bearerFormat: "JWT",
|
|
46
35
|
},
|
|
47
|
-
ApiKeyAuth: {
|
|
48
|
-
type: "apiKey",
|
|
49
|
-
in: "header",
|
|
50
|
-
name: "X-API-Key",
|
|
51
|
-
},
|
|
52
36
|
},
|
|
53
37
|
},
|
|
54
38
|
security: [],
|
|
@@ -59,10 +43,6 @@ export function getSwaggerRouter(arkosConfig) {
|
|
|
59
43
|
],
|
|
60
44
|
swaggerUiOptions: {
|
|
61
45
|
explorer: true,
|
|
62
|
-
customCss: `
|
|
63
|
-
.swagger-ui .topbar { display: none; }
|
|
64
|
-
.swagger-ui .info { margin: 20px 0; }
|
|
65
|
-
`,
|
|
66
46
|
swaggerOptions: {
|
|
67
47
|
filter: true,
|
|
68
48
|
displayRequestDuration: true,
|
|
@@ -76,11 +56,9 @@ export function getSwaggerRouter(arkosConfig) {
|
|
|
76
56
|
},
|
|
77
57
|
};
|
|
78
58
|
const swaggerConfigs = deepmerge(defaultSwaggerConfig, arkosConfig.swagger || {});
|
|
79
|
-
|
|
80
|
-
if (swaggerConfigs.options.definition.components?.schemas) {
|
|
59
|
+
if (swaggerConfigs?.options?.definition?.components?.schemas) {
|
|
81
60
|
swaggerConfigs.options.definition.components.schemas = {
|
|
82
|
-
...swaggerConfigs
|
|
83
|
-
...modeSchemas,
|
|
61
|
+
...swaggerConfigs?.options?.definition?.components.schemas,
|
|
84
62
|
};
|
|
85
63
|
}
|
|
86
64
|
const swaggerSpecification = swaggerJsdoc({
|
|
@@ -92,7 +70,7 @@ export function getSwaggerRouter(arkosConfig) {
|
|
|
92
70
|
explorer: swaggerConfigs.options.swaggerUiOptions?.explorer ?? true,
|
|
93
71
|
customCss: swaggerConfigs.options.swaggerUiOptions?.customCss,
|
|
94
72
|
customSiteTitle: swaggerConfigs.options.swaggerUiOptions?.customSiteTitle ||
|
|
95
|
-
"API Documentation",
|
|
73
|
+
"Arkos.js API Documentation",
|
|
96
74
|
customfavIcon: swaggerConfigs.options.swaggerUiOptions?.customfavIcon,
|
|
97
75
|
swaggerOptions: {
|
|
98
76
|
filter: swaggerConfigs.options.swaggerUiOptions?.swaggerOptions?.filter ?? true,
|
|
@@ -110,26 +88,6 @@ export function getSwaggerRouter(arkosConfig) {
|
|
|
110
88
|
};
|
|
111
89
|
swaggerRouter.use(swaggerConfigs.endpoint, swaggerUi.serve);
|
|
112
90
|
swaggerRouter.get(swaggerConfigs.endpoint, swaggerUi.setup(swaggerSpecification, swaggerUiOptions));
|
|
113
|
-
swaggerRouter.get(`${swaggerConfigs.endpoint}/json`, (req, res) => {
|
|
114
|
-
res.setHeader("Content-Type", "application/json");
|
|
115
|
-
res.json(swaggerSpecification);
|
|
116
|
-
});
|
|
117
|
-
swaggerRouter.get(`${swaggerConfigs.endpoint}/yaml`, (req, res) => {
|
|
118
|
-
const yaml = require("js-yaml");
|
|
119
|
-
res.setHeader("Content-Type", "text/yaml");
|
|
120
|
-
res.send(yaml.dump(swaggerSpecification));
|
|
121
|
-
});
|
|
122
|
-
swaggerRouter.get(`${swaggerConfigs.endpoint}/health`, (req, res) => {
|
|
123
|
-
res.json({
|
|
124
|
-
status: "ok",
|
|
125
|
-
swagger: {
|
|
126
|
-
version: swaggerConfigs.options.definition.openapi,
|
|
127
|
-
title: swaggerConfigs.options.definition.info?.title,
|
|
128
|
-
endpoint: swaggerConfigs.endpoint,
|
|
129
|
-
mode: swaggerConfigs.mode,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
91
|
return swaggerRouter;
|
|
134
92
|
}
|
|
135
93
|
//# sourceMappingURL=swagger.router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger.router.js","sourceRoot":"","sources":["../../../../src/modules/swagger/swagger.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,SAAS,MAAM,sCAAsC,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,wCAAwC,CAAC;AAEhD,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAwB;IAExB,MAAM,kBAAkB,GAAG,MAAM,iCAAiC,CAChE,WAAW,CAAC,OAAO,CACpB,CAAC;IACF,MAAM,kBAAkB,GAAG,MAAM,sBAAsB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAE7E,MAAM,oBAAoB,GAA2B;QACnD,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,UAAU,EAAE;gBACV,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE;oBACJ,KAAK,EAAE,qBAAqB;oBAC5B,OAAO,EAAE,OAAO;oBAChB,WAAW,EACT,sFAAsF;iBACzF;gBACD,OAAO,EAAE;oBACP;wBACE,GAAG,EAAE,UAAU,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,EAAE;wBACrD,WAAW,EAAE,oBAAoB;qBAClC;iBACF;gBACD,KAAK,EAAE,kBAAkB;gBACzB,UAAU,EAAE;oBACV,OAAO,EAAE,kBAAkB,IAAI,EAAE;oBACjC,eAAe,EAAE;wBACf,UAAU,EAAE;4BACV,IAAI,EAAE,MAAM;4BACZ,MAAM,EAAE,QAAQ;4BAChB,YAAY,EAAE,KAAK;yBACpB;qBACF;iBACF;gBACD,QAAQ,EAAE,EAAE;aACb;YACD,IAAI,EAAE;gBACJ,gCAAgC;gBAChC,mCAAmC;aACpC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BAAgB,EAAE,cAAc;gBACrD,EAAE,sBAAsB,IAAI,IAAI;YACpC,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI;YACvD,eAAe,EAAE,cAAc,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI;YAC/D,oBAAoB,EAClB,cAAc,CAAC,OAAO,CAAC,oBAAoB,IAAI,KAAK;YACtD,cAAc,EACZ,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE,cAAc;gBACrD,EAAE,cAAc,IAAI,IAAI;YAC5B,oBAAoB,EAClB,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE,cAAc;gBACrD,EAAE,oBAAoB,IAAI,IAAI;YAClC,GAAG,cAAc,CAAC,OAAO,CAAC,gBAAgB,EAAE,cAAc;SAC3D;KACF,CAAC;IAGF,aAAa,CAAC,GAAG,CAAC,cAAc,CAAC,QAAS,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAG7D,aAAa,CAAC,GAAG,CACf,cAAc,CAAC,QAAS,EACxB,SAAS,CAAC,KAAK,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CACxD,CAAC;IA4BF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { Router } from \"express\";\nimport swaggerUi from \"swagger-ui-express\";\nimport swaggerJsdoc from \"swagger-jsdoc\";\nimport { ArkosConfig } from \"../../types/arkos-config\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport {\n generatePathsForModels,\n getOpenAPIJsonSchemasByConfigMode,\n} from \"./utils/helpers/swagger.router.helpers\";\n\nconst swaggerRouter = Router();\n\nexport async function getSwaggerRouter(\n arkosConfig: ArkosConfig\n): Promise<Router> {\n const defaultJsonSchemas = await getOpenAPIJsonSchemasByConfigMode(\n arkosConfig.swagger\n );\n const defaultModelsPaths = await generatePathsForModels(arkosConfig.swagger);\n\n const defaultSwaggerConfig: ArkosConfig[\"swagger\"] = {\n endpoint: \"/api-docs\",\n mode: \"prisma\",\n options: {\n definition: {\n openapi: \"3.0.0\",\n info: {\n title: \"Powered By Arkos.js\",\n version: \"1.0.0\",\n description:\n \"This API was automatically generated by Arkos.js, read more about at www.arkosjs.com\",\n },\n servers: [\n {\n url: `http://${arkosConfig.host}:${arkosConfig.port}`,\n description: \"Development server\",\n },\n ],\n paths: defaultModelsPaths,\n components: {\n schemas: defaultJsonSchemas || {},\n securitySchemes: {\n BearerAuth: {\n type: \"http\",\n scheme: \"bearer\",\n bearerFormat: \"JWT\",\n },\n },\n },\n security: [],\n },\n apis: [\n \"./src/routers/*.router.{ts,js}\",\n \"./src/modules/**/*.router.{ts,js}\",\n ],\n swaggerUiOptions: {\n explorer: true,\n swaggerOptions: {\n filter: true,\n displayRequestDuration: true,\n showExtensions: true,\n showCommonExtensions: true,\n },\n },\n deepLinking: true,\n tryItOutEnabled: true,\n persistAuthorization: false,\n },\n };\n\n // Merge default config with user config\n const swaggerConfigs = deepmerge(\n defaultSwaggerConfig,\n arkosConfig.swagger || {}\n );\n\n // Merge mode-generated schemas with existing schemas\n if (swaggerConfigs?.options?.definition?.components?.schemas) {\n swaggerConfigs.options.definition.components.schemas = {\n ...swaggerConfigs?.options?.definition?.components.schemas,\n };\n }\n\n // Generate OpenAPI specification using swagger-jsdoc\n const swaggerSpecification = swaggerJsdoc({\n definition: swaggerConfigs.options\n .definition as swaggerJsdoc.SwaggerDefinition,\n apis: swaggerConfigs.options.apis || [],\n });\n\n // Setup Swagger UI options\n const swaggerUiOptions = {\n explorer: swaggerConfigs.options.swaggerUiOptions?.explorer ?? true,\n customCss: swaggerConfigs.options.swaggerUiOptions?.customCss,\n customSiteTitle:\n swaggerConfigs.options.swaggerUiOptions?.customSiteTitle ||\n \"Arkos.js API Documentation\",\n customfavIcon: swaggerConfigs.options.swaggerUiOptions?.customfavIcon,\n swaggerOptions: {\n filter:\n swaggerConfigs.options.swaggerUiOptions?.swaggerOptions?.filter ?? true,\n displayRequestDuration:\n swaggerConfigs.options.swaggerUiOptions?.swaggerOptions\n ?.displayRequestDuration ?? true,\n deepLinking: swaggerConfigs.options.deepLinking ?? true,\n tryItOutEnabled: swaggerConfigs.options.tryItOutEnabled ?? true,\n persistAuthorization:\n swaggerConfigs.options.persistAuthorization ?? false,\n showExtensions:\n swaggerConfigs.options.swaggerUiOptions?.swaggerOptions\n ?.showExtensions ?? true,\n showCommonExtensions:\n swaggerConfigs.options.swaggerUiOptions?.swaggerOptions\n ?.showCommonExtensions ?? true,\n ...swaggerConfigs.options.swaggerUiOptions?.swaggerOptions,\n },\n };\n\n // Serve Swagger UI static assets\n swaggerRouter.use(swaggerConfigs.endpoint!, swaggerUi.serve);\n\n // Serve Swagger documentation\n swaggerRouter.get(\n swaggerConfigs.endpoint!,\n swaggerUi.setup(swaggerSpecification, swaggerUiOptions)\n );\n\n // Serve raw OpenAPI spec as JSON\n // swaggerRouter.get(`${swaggerConfigs.endpoint}/json`, (req, res) => {\n // res.setHeader(\"Content-Type\", \"application/json\");\n // res.json(swaggerSpecification);\n // });\n\n // // Serve raw OpenAPI spec as YAML (optional)\n // swaggerRouter.get(`${swaggerConfigs.endpoint}/yaml`, (req, res) => {\n // const yaml = require(\"js-yaml\");\n // res.setHeader(\"Content-Type\", \"text/yaml\");\n // res.send(yaml.dump(swaggerSpecification));\n // });\n\n // // Health check endpoint for Swagger itself\n // swaggerRouter.get(`${swaggerConfigs.endpoint}/health`, (req, res) => {\n // res.json({\n // status: \"ok\",\n // swagger: {\n // version: swaggerConfigs?.options?.definition?.openapi,\n // title: swaggerConfigs?.options?.definition?.info?.title,\n // endpoint: swaggerConfigs.endpoint,\n // mode: swaggerConfigs.mode,\n // },\n // });\n // });\n\n return swaggerRouter;\n}\n"]}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { getSchemaRef } from "./swagger.router.helpers.js";
|
|
2
|
+
import { getArkosConfig } from "../../../../server.js";
|
|
3
|
+
export function getAuthenticationJsonSchemaPaths() {
|
|
4
|
+
const mode = getArkosConfig().swagger?.mode;
|
|
5
|
+
const paths = {};
|
|
6
|
+
if (!mode)
|
|
7
|
+
return paths;
|
|
8
|
+
paths["/api/auth/login"] = {
|
|
9
|
+
post: {
|
|
10
|
+
tags: ["Authentication"],
|
|
11
|
+
summary: "Login to the system",
|
|
12
|
+
description: "Authenticates a user and returns an access token",
|
|
13
|
+
operationId: "login",
|
|
14
|
+
requestBody: {
|
|
15
|
+
description: "User credentials",
|
|
16
|
+
required: true,
|
|
17
|
+
content: {
|
|
18
|
+
"application/json": {
|
|
19
|
+
schema: {
|
|
20
|
+
$ref: getSchemaRef("Login", mode),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
responses: {
|
|
26
|
+
"200": {
|
|
27
|
+
description: "Login successful",
|
|
28
|
+
content: {
|
|
29
|
+
"application/json": {
|
|
30
|
+
schema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {
|
|
33
|
+
accessToken: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "JWT access token",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
"400": {
|
|
43
|
+
description: "Invalid input data",
|
|
44
|
+
},
|
|
45
|
+
"401": {
|
|
46
|
+
description: "Invalid credentials",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
paths["/api/auth/logout"] = {
|
|
52
|
+
delete: {
|
|
53
|
+
tags: ["Authentication"],
|
|
54
|
+
summary: "Logout from the system",
|
|
55
|
+
description: "Invalidates the current user's JWT token",
|
|
56
|
+
operationId: "logout",
|
|
57
|
+
security: [{ BearerAuth: [] }],
|
|
58
|
+
responses: {
|
|
59
|
+
"204": {
|
|
60
|
+
description: "Logout successful",
|
|
61
|
+
},
|
|
62
|
+
"401": {
|
|
63
|
+
description: "Authentication required",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
paths["/api/auth/signup"] = {
|
|
69
|
+
post: {
|
|
70
|
+
tags: ["Authentication"],
|
|
71
|
+
summary: "Register a new user",
|
|
72
|
+
description: "Creates a new user account",
|
|
73
|
+
operationId: "signup",
|
|
74
|
+
requestBody: {
|
|
75
|
+
description: "User registration data",
|
|
76
|
+
required: true,
|
|
77
|
+
content: {
|
|
78
|
+
"application/json": {
|
|
79
|
+
schema: {
|
|
80
|
+
$ref: getSchemaRef("Signup", mode),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
responses: {
|
|
86
|
+
"201": {
|
|
87
|
+
description: "User created successfully",
|
|
88
|
+
content: {
|
|
89
|
+
"application/json": {
|
|
90
|
+
schema: {
|
|
91
|
+
$ref: getSchemaRef("User", mode),
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
"400": {
|
|
97
|
+
description: "Invalid input data",
|
|
98
|
+
},
|
|
99
|
+
"409": {
|
|
100
|
+
description: "User already exists",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
paths["/api/auth/update-password"] = {
|
|
106
|
+
post: {
|
|
107
|
+
tags: ["Authentication"],
|
|
108
|
+
summary: "Update user password",
|
|
109
|
+
description: "Changes the password for the authenticated user",
|
|
110
|
+
operationId: "updatePassword",
|
|
111
|
+
security: [{ BearerAuth: [] }],
|
|
112
|
+
requestBody: {
|
|
113
|
+
description: "Current and new password",
|
|
114
|
+
required: true,
|
|
115
|
+
content: {
|
|
116
|
+
"application/json": {
|
|
117
|
+
schema: {
|
|
118
|
+
$ref: getSchemaRef("UpdatePassword", mode),
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
responses: {
|
|
124
|
+
"200": {
|
|
125
|
+
description: "Password updated successfully",
|
|
126
|
+
content: {
|
|
127
|
+
"application/json": {
|
|
128
|
+
schema: {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
status: {
|
|
132
|
+
type: "string",
|
|
133
|
+
example: "success",
|
|
134
|
+
},
|
|
135
|
+
message: {
|
|
136
|
+
type: "string",
|
|
137
|
+
example: "Password updated successfully!",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
"400": {
|
|
145
|
+
description: "Invalid input data or current password incorrect",
|
|
146
|
+
},
|
|
147
|
+
"401": {
|
|
148
|
+
description: "Authentication required",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
paths["/users/me"] = {
|
|
154
|
+
get: {
|
|
155
|
+
tags: ["Users"],
|
|
156
|
+
summary: "Get current user information",
|
|
157
|
+
description: "Retrieves information about the currently authenticated user",
|
|
158
|
+
operationId: "getCurrentUser",
|
|
159
|
+
security: [{ BearerAuth: [] }],
|
|
160
|
+
responses: {
|
|
161
|
+
"200": {
|
|
162
|
+
description: "User information retrieved successfully",
|
|
163
|
+
content: {
|
|
164
|
+
"application/json": {
|
|
165
|
+
schema: {
|
|
166
|
+
$ref: getSchemaRef("FindMe", mode),
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
"401": {
|
|
172
|
+
description: "Authentication required",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
paths["/users/me"] = {
|
|
178
|
+
patch: {
|
|
179
|
+
tags: ["Users"],
|
|
180
|
+
summary: "Update current user information",
|
|
181
|
+
description: "Updates information for the currently authenticated user",
|
|
182
|
+
operationId: "updateCurrentUser",
|
|
183
|
+
security: [{ BearerAuth: [] }],
|
|
184
|
+
requestBody: {
|
|
185
|
+
description: "User data to update",
|
|
186
|
+
required: true,
|
|
187
|
+
content: {
|
|
188
|
+
"application/json": {
|
|
189
|
+
schema: {
|
|
190
|
+
$ref: getSchemaRef("UpdateMe", mode),
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
responses: {
|
|
196
|
+
"200": {
|
|
197
|
+
description: "User updated successfully",
|
|
198
|
+
content: {
|
|
199
|
+
"application/json": {
|
|
200
|
+
schema: {
|
|
201
|
+
$ref: getSchemaRef("User", mode),
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
"400": {
|
|
207
|
+
description: "Invalid input data",
|
|
208
|
+
},
|
|
209
|
+
"401": {
|
|
210
|
+
description: "Authentication required",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
paths["/users/me"] = {
|
|
216
|
+
delete: {
|
|
217
|
+
tags: ["Users"],
|
|
218
|
+
summary: "Delete current user account",
|
|
219
|
+
description: "Marks the current user's account as deleted",
|
|
220
|
+
operationId: "deleteCurrentUser",
|
|
221
|
+
security: [{ BearerAuth: [] }],
|
|
222
|
+
responses: {
|
|
223
|
+
"200": {
|
|
224
|
+
description: "Account deleted successfully",
|
|
225
|
+
content: {
|
|
226
|
+
"application/json": {
|
|
227
|
+
schema: {
|
|
228
|
+
type: "object",
|
|
229
|
+
properties: {
|
|
230
|
+
message: {
|
|
231
|
+
type: "string",
|
|
232
|
+
example: "Account deleted successfully",
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
"401": {
|
|
240
|
+
description: "Authentication required",
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
return paths;
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=get-authentication-json-schema-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-authentication-json-schema-paths.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/get-authentication-json-schema-paths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,UAAU,gCAAgC;IAC9C,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;IAC5C,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAExB,KAAK,CAAC,iBAAiB,CAAC,GAAG;QACzB,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC,gBAAgB,CAAC;YACxB,OAAO,EAAE,qBAAqB;YAC9B,WAAW,EAAE,kDAAkD;YAC/D,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE;gBACX,WAAW,EAAE,kBAAkB;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE;oBACP,kBAAkB,EAAE;wBAClB,MAAM,EAAE;4BACN,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC;yBAClC;qBACF;iBACF;aACF;YACD,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,WAAW,EAAE,kBAAkB;oBAC/B,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,WAAW,EAAE;wCACX,IAAI,EAAE,QAAQ;wCACd,WAAW,EAAE,kBAAkB;qCAChC;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,oBAAoB;iBAClC;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,qBAAqB;iBACnC;aACF;SACF;KACF,CAAC;IAGF,KAAK,CAAC,kBAAkB,CAAC,GAAG;QAC1B,MAAM,EAAE;YACN,IAAI,EAAE,CA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BACF;gBACD,KAAK,EAAE;oBACL,WAAW,EAAE,yBAAyB;iBACvC;aACF;SACF;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\nimport { getSchemaRef } from \"./swagger.router.helpers\";\nimport { getArkosConfig } from \"../../../../server\";\n\nexport function getAuthenticationJsonSchemaPaths() {\n const mode = getArkosConfig().swagger?.mode;\n const paths: OpenAPIV3.PathsObject = {};\n\n if (!mode) return paths;\n // Add login endpoint\n paths[\"/api/auth/login\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Login to the system\",\n description: \"Authenticates a user and returns an access token\",\n operationId: \"login\",\n requestBody: {\n description: \"User credentials\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"Login\", mode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Login successful\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n accessToken: {\n type: \"string\",\n description: \"JWT access token\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"401\": {\n description: \"Invalid credentials\",\n },\n },\n },\n };\n\n // Add logout endpoint\n paths[\"/api/auth/logout\"] = {\n delete: {\n tags: [\"Authentication\"],\n summary: \"Logout from the system\",\n description: \"Invalidates the current user's JWT token\",\n operationId: \"logout\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"204\": {\n description: \"Logout successful\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n\n // Add signup endpoint\n paths[\"/api/auth/signup\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Register a new user\",\n description: \"Creates a new user account\",\n operationId: \"signup\",\n requestBody: {\n description: \"User registration data\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"Signup\", mode),\n },\n },\n },\n },\n responses: {\n \"201\": {\n description: \"User created successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"User\", mode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"409\": {\n description: \"User already exists\",\n },\n },\n },\n };\n\n // Add update password endpoint\n paths[\"/api/auth/update-password\"] = {\n post: {\n tags: [\"Authentication\"],\n summary: \"Update user password\",\n description: \"Changes the password for the authenticated user\",\n operationId: \"updatePassword\",\n security: [{ BearerAuth: [] }],\n requestBody: {\n description: \"Current and new password\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"UpdatePassword\", mode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Password updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n status: {\n type: \"string\",\n example: \"success\",\n },\n message: {\n type: \"string\",\n example: \"Password updated successfully!\",\n },\n },\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data or current password incorrect\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n\n // Add get current user endpoint\n paths[\"/users/me\"] = {\n get: {\n tags: [\"Users\"],\n summary: \"Get current user information\",\n description:\n \"Retrieves information about the currently authenticated user\",\n operationId: \"getCurrentUser\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"User information retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"FindMe\", mode),\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n\n // Add update current user endpoint\n paths[\"/users/me\"] = {\n patch: {\n tags: [\"Users\"],\n summary: \"Update current user information\",\n description: \"Updates information for the currently authenticated user\",\n operationId: \"updateCurrentUser\",\n security: [{ BearerAuth: [] }],\n requestBody: {\n description: \"User data to update\",\n required: true,\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"UpdateMe\", mode),\n },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"User updated successfully\",\n content: {\n \"application/json\": {\n schema: {\n $ref: getSchemaRef(\"User\", mode),\n },\n },\n },\n },\n \"400\": {\n description: \"Invalid input data\",\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n\n // Add delete current user endpoint\n paths[\"/users/me\"] = {\n delete: {\n tags: [\"Users\"],\n summary: \"Delete current user account\",\n description: \"Marks the current user's account as deleted\",\n operationId: \"deleteCurrentUser\",\n security: [{ BearerAuth: [] }],\n responses: {\n \"200\": {\n description: \"Account deleted successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n message: {\n type: \"string\",\n example: \"Account deleted successfully\",\n },\n },\n },\n },\n },\n },\n \"401\": {\n description: \"Authentication required\",\n },\n },\n },\n };\n\n return paths;\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export function getSystemJsonSchemaPaths() {
|
|
2
|
+
const paths = {};
|
|
3
|
+
paths["/api/available-resources"] = {
|
|
4
|
+
get: {
|
|
5
|
+
tags: ["System"],
|
|
6
|
+
summary: "Get available resources",
|
|
7
|
+
description: "Returns a comprehensive list of all available API resource endpoints",
|
|
8
|
+
operationId: "getAvailableResources",
|
|
9
|
+
responses: {
|
|
10
|
+
"200": {
|
|
11
|
+
description: "List of available resources retrieved successfully",
|
|
12
|
+
content: {
|
|
13
|
+
"application/json": {
|
|
14
|
+
schema: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
data: {
|
|
18
|
+
type: "array",
|
|
19
|
+
items: {
|
|
20
|
+
type: "string",
|
|
21
|
+
},
|
|
22
|
+
description: "Array of available resource endpoints",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
paths["/api/available-routes"] = {
|
|
33
|
+
get: {
|
|
34
|
+
tags: ["System"],
|
|
35
|
+
summary: "Get available routes",
|
|
36
|
+
description: "Returns a comprehensive list of all registered API routes and their methods",
|
|
37
|
+
operationId: "getAvailableRoutes",
|
|
38
|
+
responses: {
|
|
39
|
+
"200": {
|
|
40
|
+
description: "List of available routes retrieved successfully",
|
|
41
|
+
content: {
|
|
42
|
+
"application/json": {
|
|
43
|
+
schema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
routes: {
|
|
47
|
+
type: "array",
|
|
48
|
+
items: {
|
|
49
|
+
type: "string",
|
|
50
|
+
},
|
|
51
|
+
description: "Array of available API routes",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
return paths;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=get-system-json-schema-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-system-json-schema-paths.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/get-system-json-schema-paths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB;IACtC,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,KAAK,CAAC,0BAA0B,CAAC,GAAG;QAClC,GAAG,EAAE;YACH,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,OAAO,EAAE,yBAAyB;YAClC,WAAW,EACT,sEAAsE;YACxE,WAAW,EAAE,uBAAuB;YACpC,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,WAAW,EAAE,oDAAoD;oBACjE,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,IAAI,EAAE;wCACJ,IAAI,EAAE,OAAO;wCACb,KAAK,EAAE;4CACL,IAAI,EAAE,QAAQ;yCACf;wCACD,WAAW,EAAE,uCAAuC;qCACrD;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;IAEF,KAAK,CAAC,uBAAuB,CAAC,GAAG;QAC/B,GAAG,EAAE;YACH,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,OAAO,EAAE,sBAAsB;YAC/B,WAAW,EACT,6EAA6E;YAC/E,WAAW,EAAE,oBAAoB;YACjC,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,WAAW,EAAE,iDAAiD;oBAC9D,OAAO,EAAE;wBACP,kBAAkB,EAAE;4BAClB,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,MAAM,EAAE;wCACN,IAAI,EAAE,OAAO;wCACb,KAAK,EAAE;4CACL,IAAI,EAAE,QAAQ;yCACf;wCACD,WAAW,EAAE,+BAA+B;qCAC7C;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { OpenAPIV3 } from \"openapi-types\";\n\nexport function getSystemJsonSchemaPaths() {\n const paths: OpenAPIV3.PathsObject = {};\n\n paths[\"/api/available-resources\"] = {\n get: {\n tags: [\"System\"],\n summary: \"Get available resources\",\n description:\n \"Returns a comprehensive list of all available API resource endpoints\",\n operationId: \"getAvailableResources\",\n responses: {\n \"200\": {\n description: \"List of available resources retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n data: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n description: \"Array of available resource endpoints\",\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n paths[\"/api/available-routes\"] = {\n get: {\n tags: [\"System\"],\n summary: \"Get available routes\",\n description:\n \"Returns a comprehensive list of all registered API routes and their methods\",\n operationId: \"getAvailableRoutes\",\n responses: {\n \"200\": {\n description: \"List of available routes retrieved successfully\",\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n routes: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n description: \"Array of available API routes\",\n },\n },\n },\n },\n },\n },\n },\n },\n };\n\n return paths;\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { validationMetadatasToSchemas } from "class-validator-jsonschema";
|
|
2
|
+
import { importModule } from "../../../../../utils/helpers/global.helpers.js";
|
|
3
|
+
import { getMetadataStorage } from "class-validator";
|
|
4
|
+
import { getModelModules, getModels, } from "../../../../../utils/helpers/models.helpers.js";
|
|
5
|
+
import { getCorrectJsonSchemaName } from "../swagger.router.helpers.js";
|
|
6
|
+
export async function generateClassValidatorJsonSchemas() {
|
|
7
|
+
const models = getModels();
|
|
8
|
+
const schemas = {};
|
|
9
|
+
const { defaultMetadataStorage } = await importModule("class-transformer/cjs/storage.js");
|
|
10
|
+
const jsonSchema = validationMetadatasToSchemas({
|
|
11
|
+
classValidatorMetadataStorage: getMetadataStorage(),
|
|
12
|
+
classTransformerMetadataStorage: defaultMetadataStorage,
|
|
13
|
+
refPointerPrefix: "#/components/schemas/",
|
|
14
|
+
});
|
|
15
|
+
Object.entries(jsonSchema).forEach(([className, schema]) => {
|
|
16
|
+
schemas[className] = schema;
|
|
17
|
+
});
|
|
18
|
+
models.forEach((modelName) => {
|
|
19
|
+
const modelModules = getModelModules(modelName);
|
|
20
|
+
if (modelModules?.dtos) {
|
|
21
|
+
Object.entries(modelModules.dtos).forEach(([dtoType, dtoClass]) => {
|
|
22
|
+
if (dtoClass) {
|
|
23
|
+
try {
|
|
24
|
+
const schemaName = getCorrectJsonSchemaName(dtoType, modelName, "Dto");
|
|
25
|
+
schemas[schemaName] = jsonSchema[dtoClass.name] || {};
|
|
26
|
+
if (schemas[dtoClass.name])
|
|
27
|
+
delete schemas[dtoClass.name];
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.warn(`Failed to generate schema for ${dtoType} ${modelName}:`, error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return schemas;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=generate-class-validator-json-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-class-validator-json-schemas.js","sourceRoot":"","sources":["../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EACL,eAAe,EACf,SAAS,GACV,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,iCAAiC;IACrD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,YAAY,CACnD,kCAAkC,CACnC,CAAC;IAEF,MAAM,UAAU,GAAG,4BAA4B,CAAC;QAC9C,6BAA6B,EAAE,kBAAkB,EAAE;QACnD,+BAA+B,EAAE,sBAAsB;QACvD,gBAAgB,EAAE,uBAAuB;KAC1C,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE;QACzD,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAEhD,IAAI,YAAY,EAAE,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE;gBAChE,IAAI,QAAQ,EAAE,CAAC;oBACb,IAAI,CAAC;wBACH,MAAM,UAAU,GAAG,wBAAwB,CACzC,OAAO,EACP,SAAS,EACT,KAAK,CACN,CAAC;wBACF,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;wBACtD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;4BAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC5D,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,IAAI,CACV,iCAAiC,OAAO,IAAI,SAAS,GAAG,EACxD,KAAK,CACN,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { validationMetadatasToSchemas } from \"class-validator-jsonschema\";\nimport { importModule } from \"../../../../../utils/helpers/global.helpers\";\nimport { getMetadataStorage } from \"class-validator\";\nimport {\n getModelModules,\n getModels,\n} from \"../../../../../utils/helpers/models.helpers\";\nimport { getCorrectJsonSchemaName } from \"../swagger.router.helpers\";\n\nexport async function generateClassValidatorJsonSchemas() {\n const models = getModels();\n const schemas: Record<string, any> = {};\n\n const { defaultMetadataStorage } = await importModule(\n \"class-transformer/cjs/storage.js\"\n );\n\n const jsonSchema = validationMetadatasToSchemas({\n classValidatorMetadataStorage: getMetadataStorage(),\n classTransformerMetadataStorage: defaultMetadataStorage,\n refPointerPrefix: \"#/components/schemas/\",\n });\n\n Object.entries(jsonSchema).forEach(([className, schema]) => {\n schemas[className] = schema;\n });\n\n models.forEach((modelName) => {\n const modelModules = getModelModules(modelName);\n\n if (modelModules?.dtos) {\n Object.entries(modelModules.dtos).forEach(([dtoType, dtoClass]) => {\n if (dtoClass) {\n try {\n const schemaName = getCorrectJsonSchemaName(\n dtoType,\n modelName,\n \"Dto\"\n );\n schemas[schemaName] = jsonSchema[dtoClass.name] || {};\n if (schemas[dtoClass.name]) delete schemas[dtoClass.name];\n } catch (error) {\n console.warn(\n `Failed to generate schema for ${dtoType} ${modelName}:`,\n error\n );\n }\n }\n });\n }\n });\n\n return schemas;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { pascalCase } from "../../../../../exports/utils/index.js";
|
|
2
|
+
import { getModels, getPrismaSchemasContent, } from "../../../../../utils/helpers/models.helpers.js";
|
|
3
|
+
export async function generatePrismaJsonSchemas() {
|
|
4
|
+
const schemas = {};
|
|
5
|
+
const prismaContent = getPrismaSchemasContent();
|
|
6
|
+
const models = getModels();
|
|
7
|
+
models.forEach((modelName) => {
|
|
8
|
+
const pascalModelName = pascalCase(modelName);
|
|
9
|
+
schemas[`Create${pascalModelName}Schema`] = {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {},
|
|
12
|
+
};
|
|
13
|
+
schemas[`Update${pascalModelName}Schema`] = {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {},
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=generate-prisma-json-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-prisma-json-schemas.js","sourceRoot":"","sources":["../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EACL,SAAS,EACT,uBAAuB,GACxB,MAAM,6CAA6C,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,MAAM,OAAO,GAAwB,EAAE,CAAC;IACxC,MAAM,aAAa,GAAG,uBAAuB,EAAE,CAAC;IAChD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QAE9C,OAAO,CAAC,SAAS,eAAe,QAAQ,CAAC,GAAG;YAC1C,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAEX;SACF,CAAC;QAEF,OAAO,CAAC,SAAS,eAAe,QAAQ,CAAC,GAAG;YAC1C,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAEX;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { pascalCase } from \"../../../../../exports/utils\";\nimport {\n getModels,\n getPrismaSchemasContent,\n} from \"../../../../../utils/helpers/models.helpers\";\n\nexport async function generatePrismaJsonSchemas() {\n const schemas: Record<string, any> = {};\n const prismaContent = getPrismaSchemasContent();\n const models = getModels();\n\n models.forEach((modelName) => {\n const pascalModelName = pascalCase(modelName);\n\n schemas[`Create${pascalModelName}Schema`] = {\n type: \"object\",\n properties: {\n // Omit auto-generated fields like id, createdAt, updatedAt\n },\n };\n\n schemas[`Update${pascalModelName}Schema`] = {\n type: \"object\",\n properties: {\n // Make all fields optional for updates\n },\n };\n });\n}\n"]}
|
package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getModelModules, getModels, } from "../../../../../utils/helpers/models.helpers.js";
|
|
2
|
+
import zodToJsonSchema from "zod-to-json-schema";
|
|
3
|
+
import { getCorrectJsonSchemaName } from "../swagger.router.helpers.js";
|
|
4
|
+
export async function generateZodJsonSchemas() {
|
|
5
|
+
const models = [...getModels(), "file-upload", "auth"];
|
|
6
|
+
const schemas = {};
|
|
7
|
+
models.forEach((modelName) => {
|
|
8
|
+
const modelModules = getModelModules(modelName);
|
|
9
|
+
if (modelModules?.schemas)
|
|
10
|
+
Object.entries(modelModules.schemas).forEach(([schemaType, zodSchema]) => {
|
|
11
|
+
if (zodSchema)
|
|
12
|
+
try {
|
|
13
|
+
const jsonSchema = zodToJsonSchema(zodSchema);
|
|
14
|
+
const schemaName = getCorrectJsonSchemaName(schemaType, modelName, "Schema");
|
|
15
|
+
schemas[schemaName] = jsonSchema;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.warn(`Failed to generate schema for ${schemaType} ${modelName}:`, error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return schemas;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=generate-zod-json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-zod-json-schema.js","sourceRoot":"","sources":["../../../../../../../src/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,GACV,MAAM,6CAA6C,CAAC;AACrD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IACvD,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAEhD,IAAI,YAAY,EAAE,OAAO;YACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,OAAO,CAC1C,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE;gBAC1B,IAAI,SAAS;oBACX,IAAI,CAAC;wBACH,MAAM,UAAU,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;wBAC9C,MAAM,UAAU,GAAG,wBAAwB,CACzC,UAAU,EACV,SAAS,EACT,QAAQ,CACT,CAAC;wBACF,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;oBACnC,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,IAAI,CACV,iCAAiC,UAAU,IAAI,SAAS,GAAG,EAC3D,KAAK,CACN,CAAC;oBACJ,CAAC;YACL,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n getModelModules,\n getModels,\n} from \"../../../../../utils/helpers/models.helpers\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport { getCorrectJsonSchemaName } from \"../swagger.router.helpers\";\n\nexport async function generateZodJsonSchemas() {\n const models = [...getModels(), \"file-upload\", \"auth\"];\n const schemas: Record<string, any> = {};\n\n models.forEach((modelName) => {\n const modelModules = getModelModules(modelName);\n\n if (modelModules?.schemas)\n Object.entries(modelModules.schemas).forEach(\n ([schemaType, zodSchema]) => {\n if (zodSchema)\n try {\n const jsonSchema = zodToJsonSchema(zodSchema);\n const schemaName = getCorrectJsonSchemaName(\n schemaType,\n modelName,\n \"Schema\"\n );\n schemas[schemaName] = jsonSchema;\n } catch (error) {\n console.warn(\n `Failed to generate schema for ${schemaType} ${modelName}:`,\n error\n );\n }\n }\n );\n });\n\n return schemas;\n}\n"]}
|