arkos 1.4.0-canary.92 → 1.4.1-canary.2
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/dist/cjs/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/exports/index.js.map +1 -1
- package/dist/cjs/modules/auth/auth.controller.js +1 -1
- package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js +2 -3
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js +50 -8
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +1 -1
- package/dist/cjs/modules/base/base.controller.js +6 -3
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.middlewares.js +8 -4
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/error-handler/error-handler.controller.js +2 -2
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/cjs/modules/swagger/swagger.router.js +6 -4
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js +7 -0
- package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +308 -183
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +357 -288
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -5
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +280 -243
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +8 -6
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/cjs/server.js +17 -15
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/new-arkos-config.js.map +1 -1
- package/dist/cjs/utils/arkos-router/index.js +32 -5
- package/dist/cjs/utils/arkos-router/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js +11 -0
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +12 -53
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/export-auth-action.js +1 -1
- package/dist/cjs/utils/cli/export-auth-action.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +3 -3
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/index.js +1 -1
- package/dist/cjs/utils/cli/index.js.map +1 -1
- package/dist/cjs/utils/cli/start.js +14 -10
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/cli/utils/runtime-cli-commander.js +51 -6
- package/dist/cjs/utils/cli/utils/runtime-cli-commander.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +3 -3
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +3 -3
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js +6 -3
- package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +3 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
- package/dist/cjs/utils/dotenv.helpers.js +10 -6
- package/dist/cjs/utils/dotenv.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/api.features.helpers.js +174 -81
- package/dist/cjs/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +40 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/routers.helpers.js +0 -1
- package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/esm/app.js +1 -1
- package/dist/esm/app.js.map +1 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/modules/auth/auth.controller.js +1 -1
- package/dist/esm/modules/auth/auth.controller.js.map +1 -1
- package/dist/esm/modules/auth/auth.service.js +3 -4
- package/dist/esm/modules/auth/auth.service.js.map +1 -1
- package/dist/esm/modules/auth/utils/services/auth-action.service.js +50 -5
- package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
- package/dist/esm/modules/base/base.controller.js +6 -3
- package/dist/esm/modules/base/base.controller.js.map +1 -1
- package/dist/esm/modules/base/base.middlewares.js +8 -4
- package/dist/esm/modules/base/base.middlewares.js.map +1 -1
- package/dist/esm/modules/error-handler/error-handler.controller.js +2 -2
- package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/esm/modules/swagger/swagger.router.js +6 -4
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
- package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js +5 -0
- package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +308 -183
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +357 -288
- package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -2
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +280 -243
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +8 -6
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/esm/server.js +17 -15
- package/dist/esm/server.js.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/new-arkos-config.js.map +1 -1
- package/dist/esm/utils/arkos-router/index.js +33 -6
- package/dist/esm/utils/arkos-router/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/index.js +10 -0
- package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
- package/dist/esm/utils/cli/dev.js +13 -54
- package/dist/esm/utils/cli/dev.js.map +1 -1
- package/dist/esm/utils/cli/export-auth-action.js +1 -1
- package/dist/esm/utils/cli/export-auth-action.js.map +1 -1
- package/dist/esm/utils/cli/generate.js +3 -3
- package/dist/esm/utils/cli/generate.js.map +1 -1
- package/dist/esm/utils/cli/index.js +1 -1
- package/dist/esm/utils/cli/index.js.map +1 -1
- package/dist/esm/utils/cli/start.js +14 -10
- package/dist/esm/utils/cli/start.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/utils/runtime-cli-commander.js +52 -7
- package/dist/esm/utils/cli/utils/runtime-cli-commander.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +3 -3
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +3 -3
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js +6 -3
- package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +3 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
- package/dist/esm/utils/dotenv.helpers.js +10 -6
- package/dist/esm/utils/dotenv.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/api.features.helpers.js +174 -81
- package/dist/esm/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/prisma.helpers.js +39 -1
- package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/routers.helpers.js +0 -1
- package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/types/exports/index.d.ts +2 -1
- package/dist/types/modules/auth/auth.router.d.ts +1 -1
- package/dist/types/modules/auth/auth.service.d.ts +2 -2
- package/dist/types/modules/base/base.router.d.ts +1 -1
- package/dist/types/modules/swagger/utils/built-in-route-path-object-manager.d.ts +4 -0
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +1 -1
- package/dist/types/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.d.ts +1 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.d.ts +1 -1
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +1 -1
- package/dist/types/types/index.d.ts +5 -5
- package/dist/types/types/new-arkos-config.d.ts +1 -1
- package/dist/types/utils/arkos-router/types/index.d.ts +15 -14
- package/dist/types/utils/arkos-router/utils/helpers/index.d.ts +1 -0
- package/dist/types/utils/helpers/prisma.helpers.d.ts +1 -0
- package/package.json +2 -2
|
@@ -3,6 +3,15 @@ import pluralize from "pluralize";
|
|
|
3
3
|
import { isEndpointDisabled } from "../../../../../base/utils/helpers/base.router.helpers.js";
|
|
4
4
|
import { kebabCase, pascalCase } from "../../../../../../exports/utils/index.js";
|
|
5
5
|
import { getModuleComponents } from "../../../../../../utils/dynamic-loader.js";
|
|
6
|
+
import { isAuthenticationEnabled } from "../../../../../../utils/helpers/arkos-config.helpers.js";
|
|
7
|
+
function getAuthErrorResponses() {
|
|
8
|
+
if (!isAuthenticationEnabled())
|
|
9
|
+
return {};
|
|
10
|
+
return {
|
|
11
|
+
"401": { description: "Authentication required" },
|
|
12
|
+
"403": { description: "Insufficient permissions" },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
6
15
|
export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfig) {
|
|
7
16
|
const modelName = kebabCase(model);
|
|
8
17
|
const routeName = pluralize.plural(modelName);
|
|
@@ -26,15 +35,19 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
26
35
|
return swaggerMode || "prisma";
|
|
27
36
|
};
|
|
28
37
|
if (!isEndpointDisabled(routerConfig, "createOne")) {
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
const pathname = `/api/${routeName}`;
|
|
39
|
+
if (!paths[pathname])
|
|
40
|
+
paths[pathname] = {};
|
|
31
41
|
const createMode = getSchemaMode("create");
|
|
32
|
-
paths[
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const currentPath = paths[pathname].post;
|
|
43
|
+
const defaultSpec = {
|
|
44
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
45
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
46
|
+
? `Create a new ${humanReadableName}`
|
|
47
|
+
: currentPath?.summary,
|
|
35
48
|
description: `Creates a new ${humanReadableName} record in the system`,
|
|
36
49
|
operationId: `create${pascalModelName}`,
|
|
37
|
-
requestBody: {
|
|
50
|
+
requestBody: currentPath?.requestBody || {
|
|
38
51
|
description: `${humanReadableName} data to create`,
|
|
39
52
|
required: true,
|
|
40
53
|
content: {
|
|
@@ -46,7 +59,8 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
46
59
|
},
|
|
47
60
|
},
|
|
48
61
|
responses: {
|
|
49
|
-
|
|
62
|
+
...(currentPath?.responses || {}),
|
|
63
|
+
"201": currentPath?.responses?.["201"] || {
|
|
50
64
|
description: `${humanReadableName} created successfully`,
|
|
51
65
|
content: {
|
|
52
66
|
"application/json": {
|
|
@@ -56,75 +70,70 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
56
70
|
},
|
|
57
71
|
},
|
|
58
72
|
},
|
|
59
|
-
"400": {
|
|
73
|
+
"400": currentPath?.responses?.["400"] || {
|
|
60
74
|
description: "Invalid input data provided",
|
|
61
75
|
},
|
|
62
|
-
|
|
63
|
-
description: "Authentication required",
|
|
64
|
-
},
|
|
65
|
-
"403": {
|
|
66
|
-
description: "Insufficient permissions",
|
|
67
|
-
},
|
|
76
|
+
...getAuthErrorResponses(),
|
|
68
77
|
},
|
|
69
78
|
security: [{ BearerAuth: [] }],
|
|
70
79
|
};
|
|
80
|
+
paths[pathname].post = { ...(currentPath || {}), ...defaultSpec };
|
|
71
81
|
}
|
|
72
82
|
if (!isEndpointDisabled(routerConfig, "findMany")) {
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
const pathname = `/api/${routeName}`;
|
|
84
|
+
if (!paths[pathname])
|
|
85
|
+
paths[pathname] = {};
|
|
75
86
|
const findManyMode = getSchemaMode("findMany");
|
|
76
|
-
paths[
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
const currentPath = paths[pathname].get;
|
|
88
|
+
const defaultParameters = [
|
|
89
|
+
{
|
|
90
|
+
name: "filters",
|
|
91
|
+
in: "query",
|
|
92
|
+
description: "Filter criteria in JSON format",
|
|
93
|
+
schema: { type: "string" },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "sort",
|
|
97
|
+
in: "query",
|
|
98
|
+
description: "Sort field (prefix with '-' for descending order)",
|
|
99
|
+
schema: { type: "string" },
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "page",
|
|
103
|
+
in: "query",
|
|
104
|
+
description: "Page number (starts from 1)",
|
|
105
|
+
schema: { type: "integer", minimum: 1 },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "limit",
|
|
109
|
+
in: "query",
|
|
110
|
+
description: "Number of items per page",
|
|
111
|
+
schema: { type: "integer", minimum: 1, maximum: 100 },
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "fields",
|
|
115
|
+
in: "query",
|
|
116
|
+
description: "Comma-separated list of fields to include in response",
|
|
117
|
+
schema: { type: "string" },
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
const existingParams = currentPath?.parameters || [];
|
|
121
|
+
const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
|
|
122
|
+
const mergedParameters = [
|
|
123
|
+
...existingParams,
|
|
124
|
+
...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
|
|
125
|
+
];
|
|
126
|
+
const defaultSpec = {
|
|
127
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
128
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
129
|
+
? `Get ${humanReadableNamePlural}`
|
|
130
|
+
: currentPath?.summary,
|
|
79
131
|
description: `Retrieves a paginated list of ${humanReadableNamePlural} with optional filtering and sorting`,
|
|
80
132
|
operationId: `find${pluralize.plural(pascalModelName)}`,
|
|
81
|
-
parameters:
|
|
82
|
-
{
|
|
83
|
-
name: "filters",
|
|
84
|
-
in: "query",
|
|
85
|
-
description: "Filter criteria in JSON format",
|
|
86
|
-
schema: {
|
|
87
|
-
type: "string",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: "sort",
|
|
92
|
-
in: "query",
|
|
93
|
-
description: "Sort field (prefix with '-' for descending order)",
|
|
94
|
-
schema: {
|
|
95
|
-
type: "string",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: "page",
|
|
100
|
-
in: "query",
|
|
101
|
-
description: "Page number (starts from 1)",
|
|
102
|
-
schema: {
|
|
103
|
-
type: "integer",
|
|
104
|
-
minimum: 1,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "limit",
|
|
109
|
-
in: "query",
|
|
110
|
-
description: "Number of items per page",
|
|
111
|
-
schema: {
|
|
112
|
-
type: "integer",
|
|
113
|
-
minimum: 1,
|
|
114
|
-
maximum: 100,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: "fields",
|
|
119
|
-
in: "query",
|
|
120
|
-
description: "Comma-separated list of fields to include in response",
|
|
121
|
-
schema: {
|
|
122
|
-
type: "string",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
],
|
|
133
|
+
parameters: mergedParameters,
|
|
126
134
|
responses: {
|
|
127
|
-
|
|
135
|
+
...(currentPath?.responses || {}),
|
|
136
|
+
"200": currentPath?.responses?.["200"] || {
|
|
128
137
|
description: `List of ${humanReadableNamePlural} retrieved successfully`,
|
|
129
138
|
content: {
|
|
130
139
|
"application/json": {
|
|
@@ -150,90 +159,96 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
150
159
|
},
|
|
151
160
|
},
|
|
152
161
|
},
|
|
153
|
-
|
|
154
|
-
description: "Authentication required",
|
|
155
|
-
},
|
|
156
|
-
"403": {
|
|
157
|
-
description: "Insufficient permissions",
|
|
158
|
-
},
|
|
162
|
+
...getAuthErrorResponses(),
|
|
159
163
|
},
|
|
160
164
|
security: [{ BearerAuth: [] }],
|
|
161
165
|
};
|
|
166
|
+
paths[pathname].get = { ...(currentPath || {}), ...defaultSpec };
|
|
162
167
|
}
|
|
163
168
|
if (!isEndpointDisabled(routerConfig, "createMany")) {
|
|
169
|
+
const pathname = `/api/${routeName}/many`;
|
|
170
|
+
if (!paths[pathname])
|
|
171
|
+
paths[pathname] = {};
|
|
164
172
|
const createManyMode = getSchemaMode("createMany");
|
|
165
|
-
paths[
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
const currentPath = paths[pathname].post;
|
|
174
|
+
const defaultSpec = {
|
|
175
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
176
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
177
|
+
? `Create multiple ${humanReadableNamePlural}`
|
|
178
|
+
: currentPath?.summary,
|
|
179
|
+
description: `Creates multiple ${humanReadableNamePlural} records in a single batch operation`,
|
|
180
|
+
operationId: `createMany${pascalModelName}`,
|
|
181
|
+
requestBody: currentPath?.requestBody || {
|
|
182
|
+
description: `Array of ${humanReadableName} data to create`,
|
|
183
|
+
required: true,
|
|
184
|
+
content: {
|
|
185
|
+
"application/json": {
|
|
186
|
+
schema: {
|
|
187
|
+
type: "array",
|
|
188
|
+
items: {
|
|
189
|
+
$ref: getSchemaRef(`CreateMany${pascalModelName}`, createManyMode),
|
|
181
190
|
},
|
|
182
191
|
},
|
|
183
192
|
},
|
|
184
193
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
},
|
|
195
|
+
responses: {
|
|
196
|
+
...(currentPath?.responses || {}),
|
|
197
|
+
"201": currentPath?.responses?.["201"] || {
|
|
198
|
+
description: `${humanReadableNamePlural} created successfully`,
|
|
199
|
+
content: {
|
|
200
|
+
"application/json": {
|
|
201
|
+
schema: {
|
|
202
|
+
type: "object",
|
|
203
|
+
properties: {
|
|
204
|
+
count: {
|
|
205
|
+
type: "integer",
|
|
206
|
+
description: "Number of records created",
|
|
197
207
|
},
|
|
198
208
|
},
|
|
199
209
|
},
|
|
200
210
|
},
|
|
201
211
|
},
|
|
202
|
-
"400": {
|
|
203
|
-
description: "Invalid input data provided",
|
|
204
|
-
},
|
|
205
|
-
"401": {
|
|
206
|
-
description: "Authentication required",
|
|
207
|
-
},
|
|
208
|
-
"403": {
|
|
209
|
-
description: "Insufficient permissions",
|
|
210
|
-
},
|
|
211
212
|
},
|
|
212
|
-
|
|
213
|
+
"400": currentPath?.responses?.["400"] || {
|
|
214
|
+
description: "Invalid input data provided",
|
|
215
|
+
},
|
|
216
|
+
...getAuthErrorResponses(),
|
|
213
217
|
},
|
|
218
|
+
security: [{ BearerAuth: [] }],
|
|
214
219
|
};
|
|
220
|
+
paths[pathname].post = { ...(currentPath || {}), ...defaultSpec };
|
|
215
221
|
}
|
|
216
222
|
if (!isEndpointDisabled(routerConfig, "updateMany")) {
|
|
217
|
-
|
|
218
|
-
|
|
223
|
+
const pathname = `/api/${routeName}/many`;
|
|
224
|
+
if (!paths[pathname])
|
|
225
|
+
paths[pathname] = {};
|
|
219
226
|
const updateManyMode = getSchemaMode("updateMany");
|
|
220
|
-
paths[
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
const currentPath = paths[pathname].patch;
|
|
228
|
+
const defaultParameters = [
|
|
229
|
+
{
|
|
230
|
+
name: "filters",
|
|
231
|
+
in: "query",
|
|
232
|
+
description: "Filter criteria in JSON format (required)",
|
|
233
|
+
required: true,
|
|
234
|
+
schema: { type: "string" },
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
const existingParams = currentPath?.parameters || [];
|
|
238
|
+
const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
|
|
239
|
+
const mergedParameters = [
|
|
240
|
+
...existingParams,
|
|
241
|
+
...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
|
|
242
|
+
];
|
|
243
|
+
const defaultSpec = {
|
|
244
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
245
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
246
|
+
? `Update multiple ${humanReadableNamePlural}`
|
|
247
|
+
: currentPath?.summary,
|
|
223
248
|
description: `Updates multiple ${humanReadableNamePlural} records that match the specified filter criteria`,
|
|
224
249
|
operationId: `updateMany${pascalModelName}`,
|
|
225
|
-
parameters:
|
|
226
|
-
|
|
227
|
-
name: "filters",
|
|
228
|
-
in: "query",
|
|
229
|
-
description: "Filter criteria in JSON format (required)",
|
|
230
|
-
required: true,
|
|
231
|
-
schema: {
|
|
232
|
-
type: "string",
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
requestBody: {
|
|
250
|
+
parameters: mergedParameters,
|
|
251
|
+
requestBody: currentPath?.requestBody || {
|
|
237
252
|
description: `Partial ${humanReadableName} data to update`,
|
|
238
253
|
required: true,
|
|
239
254
|
content: {
|
|
@@ -245,7 +260,8 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
245
260
|
},
|
|
246
261
|
},
|
|
247
262
|
responses: {
|
|
248
|
-
|
|
263
|
+
...(currentPath?.responses || {}),
|
|
264
|
+
"200": currentPath?.responses?.["200"] || {
|
|
249
265
|
description: `${humanReadableNamePlural} updated successfully`,
|
|
250
266
|
content: {
|
|
251
267
|
"application/json": {
|
|
@@ -261,40 +277,46 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
261
277
|
},
|
|
262
278
|
},
|
|
263
279
|
},
|
|
264
|
-
"400": {
|
|
280
|
+
"400": currentPath?.responses?.["400"] || {
|
|
265
281
|
description: "Invalid input data or missing filter criteria",
|
|
266
282
|
},
|
|
267
|
-
|
|
268
|
-
description: "Authentication required",
|
|
269
|
-
},
|
|
270
|
-
"403": {
|
|
271
|
-
description: "Insufficient permissions",
|
|
272
|
-
},
|
|
283
|
+
...getAuthErrorResponses(),
|
|
273
284
|
},
|
|
274
285
|
security: [{ BearerAuth: [] }],
|
|
275
286
|
};
|
|
287
|
+
paths[pathname].patch = { ...(currentPath || {}), ...defaultSpec };
|
|
276
288
|
}
|
|
277
289
|
if (!isEndpointDisabled(routerConfig, "deleteMany")) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
290
|
+
const pathname = `/api/${routeName}/many`;
|
|
291
|
+
if (!paths[pathname])
|
|
292
|
+
paths[pathname] = {};
|
|
293
|
+
const currentPath = paths[pathname].delete;
|
|
294
|
+
const defaultParameters = [
|
|
295
|
+
{
|
|
296
|
+
name: "filters",
|
|
297
|
+
in: "query",
|
|
298
|
+
description: "Filter criteria in JSON format (required)",
|
|
299
|
+
required: true,
|
|
300
|
+
schema: { type: "string" },
|
|
301
|
+
},
|
|
302
|
+
];
|
|
303
|
+
const existingParams = currentPath?.parameters || [];
|
|
304
|
+
const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
|
|
305
|
+
const mergedParameters = [
|
|
306
|
+
...existingParams,
|
|
307
|
+
...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
|
|
308
|
+
];
|
|
309
|
+
const defaultSpec = {
|
|
310
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
311
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
312
|
+
? `Delete multiple ${humanReadableNamePlural}`
|
|
313
|
+
: currentPath?.summary,
|
|
283
314
|
description: `Deletes multiple ${humanReadableNamePlural} records that match the specified filter criteria`,
|
|
284
315
|
operationId: `deleteMany${pascalModelName}`,
|
|
285
|
-
parameters:
|
|
286
|
-
{
|
|
287
|
-
name: "filters",
|
|
288
|
-
in: "query",
|
|
289
|
-
description: "Filter criteria in JSON format (required)",
|
|
290
|
-
required: true,
|
|
291
|
-
schema: {
|
|
292
|
-
type: "string",
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
],
|
|
316
|
+
parameters: mergedParameters,
|
|
296
317
|
responses: {
|
|
297
|
-
|
|
318
|
+
...(currentPath?.responses || {}),
|
|
319
|
+
"200": currentPath?.responses?.["200"] || {
|
|
298
320
|
description: `${humanReadableNamePlural} deleted successfully`,
|
|
299
321
|
content: {
|
|
300
322
|
"application/json": {
|
|
@@ -310,84 +332,95 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
310
332
|
},
|
|
311
333
|
},
|
|
312
334
|
},
|
|
313
|
-
"400": {
|
|
335
|
+
"400": currentPath?.responses?.["400"] || {
|
|
314
336
|
description: "Missing filter criteria",
|
|
315
337
|
},
|
|
316
|
-
|
|
317
|
-
description: "Authentication required",
|
|
318
|
-
},
|
|
319
|
-
"403": {
|
|
320
|
-
description: "Insufficient permissions",
|
|
321
|
-
},
|
|
338
|
+
...getAuthErrorResponses(),
|
|
322
339
|
},
|
|
323
340
|
security: [{ BearerAuth: [] }],
|
|
324
341
|
};
|
|
342
|
+
paths[pathname].delete = { ...(currentPath || {}), ...defaultSpec };
|
|
325
343
|
}
|
|
326
344
|
if (!isEndpointDisabled(routerConfig, "findOne")) {
|
|
345
|
+
const pathname = `/api/${routeName}/{id}`;
|
|
346
|
+
if (!paths[pathname])
|
|
347
|
+
paths[pathname] = {};
|
|
327
348
|
const findOneMode = getSchemaMode("findOne");
|
|
328
|
-
paths[
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
349
|
+
const currentPath = paths[pathname].get;
|
|
350
|
+
const defaultParameters = [
|
|
351
|
+
{
|
|
352
|
+
name: "id",
|
|
353
|
+
in: "path",
|
|
354
|
+
description: `Unique identifier of the ${humanReadableName}`,
|
|
355
|
+
required: true,
|
|
356
|
+
schema: { type: "string" },
|
|
357
|
+
},
|
|
358
|
+
];
|
|
359
|
+
const existingParams = currentPath?.parameters || [];
|
|
360
|
+
const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
|
|
361
|
+
const mergedParameters = [
|
|
362
|
+
...existingParams,
|
|
363
|
+
...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
|
|
364
|
+
];
|
|
365
|
+
const defaultSpec = {
|
|
366
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
367
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
368
|
+
? `Get ${humanReadableName} by ID`
|
|
369
|
+
: currentPath?.summary,
|
|
370
|
+
description: `Retrieves a single ${humanReadableName} record by its unique identifier`,
|
|
371
|
+
operationId: `find${pascalModelName}ById`,
|
|
372
|
+
parameters: mergedParameters,
|
|
373
|
+
responses: {
|
|
374
|
+
...(currentPath?.responses || {}),
|
|
375
|
+
"200": currentPath?.responses?.["200"] || {
|
|
376
|
+
description: `${humanReadableName} retrieved successfully`,
|
|
377
|
+
content: {
|
|
378
|
+
"application/json": {
|
|
379
|
+
schema: {
|
|
380
|
+
$ref: getSchemaRef(`FindOne${pascalModelName}`, findOneMode),
|
|
353
381
|
},
|
|
354
382
|
},
|
|
355
383
|
},
|
|
356
|
-
"401": {
|
|
357
|
-
description: "Authentication required",
|
|
358
|
-
},
|
|
359
|
-
"403": {
|
|
360
|
-
description: "Insufficient permissions",
|
|
361
|
-
},
|
|
362
|
-
"404": {
|
|
363
|
-
description: `${humanReadableName} not found`,
|
|
364
|
-
},
|
|
365
384
|
},
|
|
366
|
-
|
|
385
|
+
...getAuthErrorResponses(),
|
|
386
|
+
"404": currentPath?.responses?.["404"] || {
|
|
387
|
+
description: `${humanReadableName} not found`,
|
|
388
|
+
},
|
|
367
389
|
},
|
|
390
|
+
security: [{ BearerAuth: [] }],
|
|
368
391
|
};
|
|
392
|
+
paths[pathname].get = { ...(currentPath || {}), ...defaultSpec };
|
|
369
393
|
}
|
|
370
394
|
if (!isEndpointDisabled(routerConfig, "updateOne")) {
|
|
371
|
-
|
|
372
|
-
|
|
395
|
+
const pathname = `/api/${routeName}/{id}`;
|
|
396
|
+
if (!paths[pathname])
|
|
397
|
+
paths[pathname] = {};
|
|
373
398
|
const updateMode = getSchemaMode("update");
|
|
374
|
-
paths[
|
|
375
|
-
|
|
376
|
-
|
|
399
|
+
const currentPath = paths[pathname].patch;
|
|
400
|
+
const defaultParameters = [
|
|
401
|
+
{
|
|
402
|
+
name: "id",
|
|
403
|
+
in: "path",
|
|
404
|
+
description: `Unique identifier of the ${humanReadableName}`,
|
|
405
|
+
required: true,
|
|
406
|
+
schema: { type: "string" },
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
const existingParams = currentPath?.parameters || [];
|
|
410
|
+
const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
|
|
411
|
+
const mergedParameters = [
|
|
412
|
+
...existingParams,
|
|
413
|
+
...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
|
|
414
|
+
];
|
|
415
|
+
const defaultSpec = {
|
|
416
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
417
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
418
|
+
? `Update ${humanReadableName} by ID`
|
|
419
|
+
: currentPath?.summary,
|
|
377
420
|
description: `Updates a single ${humanReadableName} record by its unique identifier`,
|
|
378
421
|
operationId: `update${pascalModelName}`,
|
|
379
|
-
parameters:
|
|
380
|
-
|
|
381
|
-
name: "id",
|
|
382
|
-
in: "path",
|
|
383
|
-
description: `Unique identifier of the ${humanReadableName}`,
|
|
384
|
-
required: true,
|
|
385
|
-
schema: {
|
|
386
|
-
type: "string",
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
],
|
|
390
|
-
requestBody: {
|
|
422
|
+
parameters: mergedParameters,
|
|
423
|
+
requestBody: currentPath?.requestBody || {
|
|
391
424
|
description: `Partial ${humanReadableName} data to update`,
|
|
392
425
|
required: true,
|
|
393
426
|
content: {
|
|
@@ -399,7 +432,8 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
399
432
|
},
|
|
400
433
|
},
|
|
401
434
|
responses: {
|
|
402
|
-
|
|
435
|
+
...(currentPath?.responses || {}),
|
|
436
|
+
"200": currentPath?.responses?.["200"] || {
|
|
403
437
|
description: `${humanReadableName} updated successfully`,
|
|
404
438
|
content: {
|
|
405
439
|
"application/json": {
|
|
@@ -409,57 +443,60 @@ export function generatePrismaModelMainRoutesPaths(model, paths = {}, arkosConfi
|
|
|
409
443
|
},
|
|
410
444
|
},
|
|
411
445
|
},
|
|
412
|
-
"400": {
|
|
446
|
+
"400": currentPath?.responses?.["400"] || {
|
|
413
447
|
description: "Invalid input data provided",
|
|
414
448
|
},
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
},
|
|
418
|
-
"403": {
|
|
419
|
-
description: "Insufficient permissions",
|
|
420
|
-
},
|
|
421
|
-
"404": {
|
|
449
|
+
...getAuthErrorResponses(),
|
|
450
|
+
"404": currentPath?.responses?.["404"] || {
|
|
422
451
|
description: `${humanReadableName} not found`,
|
|
423
452
|
},
|
|
424
453
|
},
|
|
425
454
|
security: [{ BearerAuth: [] }],
|
|
426
455
|
};
|
|
456
|
+
paths[pathname].patch = { ...(currentPath || {}), ...defaultSpec };
|
|
427
457
|
}
|
|
428
458
|
if (!isEndpointDisabled(routerConfig, "deleteOne")) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
459
|
+
const pathname = `/api/${routeName}/{id}`;
|
|
460
|
+
if (!paths[pathname])
|
|
461
|
+
paths[pathname] = {};
|
|
462
|
+
const currentPath = paths[pathname].delete;
|
|
463
|
+
const defaultParameters = [
|
|
464
|
+
{
|
|
465
|
+
name: "id",
|
|
466
|
+
in: "path",
|
|
467
|
+
description: `Unique identifier of the ${humanReadableName}`,
|
|
468
|
+
required: true,
|
|
469
|
+
schema: { type: "string" },
|
|
470
|
+
},
|
|
471
|
+
];
|
|
472
|
+
const existingParams = currentPath?.parameters || [];
|
|
473
|
+
const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
|
|
474
|
+
const mergedParameters = [
|
|
475
|
+
...existingParams,
|
|
476
|
+
...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
|
|
477
|
+
];
|
|
478
|
+
const defaultSpec = {
|
|
479
|
+
tags: [humanReadableNamePlural, ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
|
|
480
|
+
summary: currentPath?.summary === pathname || !currentPath?.summary
|
|
481
|
+
? `Delete ${humanReadableName} by ID`
|
|
482
|
+
: currentPath?.summary,
|
|
434
483
|
description: `Permanently deletes a single ${humanReadableName} record by its unique identifier`,
|
|
435
484
|
operationId: `delete${pascalModelName}`,
|
|
436
|
-
parameters:
|
|
437
|
-
{
|
|
438
|
-
name: "id",
|
|
439
|
-
in: "path",
|
|
440
|
-
description: `Unique identifier of the ${humanReadableName}`,
|
|
441
|
-
required: true,
|
|
442
|
-
schema: {
|
|
443
|
-
type: "string",
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
],
|
|
485
|
+
parameters: mergedParameters,
|
|
447
486
|
responses: {
|
|
448
|
-
|
|
487
|
+
...(currentPath?.responses || {}),
|
|
488
|
+
"204": currentPath?.responses?.["204"] || {
|
|
449
489
|
description: `${humanReadableName} deleted successfully`,
|
|
450
490
|
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
},
|
|
454
|
-
"403": {
|
|
455
|
-
description: "Insufficient permissions",
|
|
456
|
-
},
|
|
457
|
-
"404": {
|
|
491
|
+
...getAuthErrorResponses(),
|
|
492
|
+
"404": currentPath?.responses?.["404"] || {
|
|
458
493
|
description: `${humanReadableName} not found`,
|
|
459
494
|
},
|
|
460
495
|
},
|
|
461
496
|
security: [{ BearerAuth: [] }],
|
|
462
497
|
};
|
|
498
|
+
paths[pathname].delete = { ...(currentPath || {}), ...defaultSpec };
|
|
463
499
|
}
|
|
500
|
+
return paths;
|
|
464
501
|
}
|
|
465
502
|
//# sourceMappingURL=generate-prisma-model-main-routes-paths.js.map
|