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.
Files changed (151) hide show
  1. package/dist/cjs/app.js +1 -1
  2. package/dist/cjs/app.js.map +1 -1
  3. package/dist/cjs/exports/index.js.map +1 -1
  4. package/dist/cjs/modules/auth/auth.controller.js +1 -1
  5. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  6. package/dist/cjs/modules/auth/auth.service.js +2 -3
  7. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  8. package/dist/cjs/modules/auth/utils/services/auth-action.service.js +50 -8
  9. package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +1 -1
  10. package/dist/cjs/modules/base/base.controller.js +6 -3
  11. package/dist/cjs/modules/base/base.controller.js.map +1 -1
  12. package/dist/cjs/modules/base/base.middlewares.js +8 -4
  13. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  14. package/dist/cjs/modules/error-handler/error-handler.controller.js +2 -2
  15. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  16. package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
  17. package/dist/cjs/modules/swagger/swagger.router.js +6 -4
  18. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  19. package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js +7 -0
  20. package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js.map +1 -0
  21. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +308 -183
  22. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  23. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +357 -288
  24. package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -1
  25. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -5
  26. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
  27. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +280 -243
  28. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
  29. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +8 -6
  30. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  31. package/dist/cjs/server.js +17 -15
  32. package/dist/cjs/server.js.map +1 -1
  33. package/dist/cjs/types/index.js.map +1 -1
  34. package/dist/cjs/types/new-arkos-config.js.map +1 -1
  35. package/dist/cjs/utils/arkos-router/index.js +32 -5
  36. package/dist/cjs/utils/arkos-router/index.js.map +1 -1
  37. package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
  38. package/dist/cjs/utils/arkos-router/utils/helpers/index.js +11 -0
  39. package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
  40. package/dist/cjs/utils/cli/dev.js +12 -53
  41. package/dist/cjs/utils/cli/dev.js.map +1 -1
  42. package/dist/cjs/utils/cli/export-auth-action.js +1 -1
  43. package/dist/cjs/utils/cli/export-auth-action.js.map +1 -1
  44. package/dist/cjs/utils/cli/generate.js +3 -3
  45. package/dist/cjs/utils/cli/generate.js.map +1 -1
  46. package/dist/cjs/utils/cli/index.js +1 -1
  47. package/dist/cjs/utils/cli/index.js.map +1 -1
  48. package/dist/cjs/utils/cli/start.js +14 -10
  49. package/dist/cjs/utils/cli/start.js.map +1 -1
  50. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  51. package/dist/cjs/utils/cli/utils/runtime-cli-commander.js +51 -6
  52. package/dist/cjs/utils/cli/utils/runtime-cli-commander.js.map +1 -1
  53. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +3 -3
  54. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
  55. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +3 -3
  56. package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
  57. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js +6 -3
  58. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
  59. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +3 -1
  60. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
  61. package/dist/cjs/utils/dotenv.helpers.js +10 -6
  62. package/dist/cjs/utils/dotenv.helpers.js.map +1 -1
  63. package/dist/cjs/utils/helpers/api.features.helpers.js +174 -81
  64. package/dist/cjs/utils/helpers/api.features.helpers.js.map +1 -1
  65. package/dist/cjs/utils/helpers/prisma.helpers.js +40 -1
  66. package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
  67. package/dist/cjs/utils/helpers/routers.helpers.js +0 -1
  68. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
  69. package/dist/esm/app.js +1 -1
  70. package/dist/esm/app.js.map +1 -1
  71. package/dist/esm/exports/index.js.map +1 -1
  72. package/dist/esm/modules/auth/auth.controller.js +1 -1
  73. package/dist/esm/modules/auth/auth.controller.js.map +1 -1
  74. package/dist/esm/modules/auth/auth.service.js +3 -4
  75. package/dist/esm/modules/auth/auth.service.js.map +1 -1
  76. package/dist/esm/modules/auth/utils/services/auth-action.service.js +50 -5
  77. package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
  78. package/dist/esm/modules/base/base.controller.js +6 -3
  79. package/dist/esm/modules/base/base.controller.js.map +1 -1
  80. package/dist/esm/modules/base/base.middlewares.js +8 -4
  81. package/dist/esm/modules/base/base.middlewares.js.map +1 -1
  82. package/dist/esm/modules/error-handler/error-handler.controller.js +2 -2
  83. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  84. package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -1
  85. package/dist/esm/modules/swagger/swagger.router.js +6 -4
  86. package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
  87. package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js +5 -0
  88. package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js.map +1 -0
  89. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +308 -183
  90. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
  91. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +357 -288
  92. package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +1 -1
  93. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -2
  94. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
  95. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +280 -243
  96. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
  97. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +8 -6
  98. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  99. package/dist/esm/server.js +17 -15
  100. package/dist/esm/server.js.map +1 -1
  101. package/dist/esm/types/index.js.map +1 -1
  102. package/dist/esm/types/new-arkos-config.js.map +1 -1
  103. package/dist/esm/utils/arkos-router/index.js +33 -6
  104. package/dist/esm/utils/arkos-router/index.js.map +1 -1
  105. package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
  106. package/dist/esm/utils/arkos-router/utils/helpers/index.js +10 -0
  107. package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
  108. package/dist/esm/utils/cli/dev.js +13 -54
  109. package/dist/esm/utils/cli/dev.js.map +1 -1
  110. package/dist/esm/utils/cli/export-auth-action.js +1 -1
  111. package/dist/esm/utils/cli/export-auth-action.js.map +1 -1
  112. package/dist/esm/utils/cli/generate.js +3 -3
  113. package/dist/esm/utils/cli/generate.js.map +1 -1
  114. package/dist/esm/utils/cli/index.js +1 -1
  115. package/dist/esm/utils/cli/index.js.map +1 -1
  116. package/dist/esm/utils/cli/start.js +14 -10
  117. package/dist/esm/utils/cli/start.js.map +1 -1
  118. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  119. package/dist/esm/utils/cli/utils/runtime-cli-commander.js +52 -7
  120. package/dist/esm/utils/cli/utils/runtime-cli-commander.js.map +1 -1
  121. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +3 -3
  122. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
  123. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +3 -3
  124. package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
  125. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js +6 -3
  126. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js.map +1 -1
  127. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +3 -1
  128. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
  129. package/dist/esm/utils/dotenv.helpers.js +10 -6
  130. package/dist/esm/utils/dotenv.helpers.js.map +1 -1
  131. package/dist/esm/utils/helpers/api.features.helpers.js +174 -81
  132. package/dist/esm/utils/helpers/api.features.helpers.js.map +1 -1
  133. package/dist/esm/utils/helpers/prisma.helpers.js +39 -1
  134. package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
  135. package/dist/esm/utils/helpers/routers.helpers.js +0 -1
  136. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
  137. package/dist/types/exports/index.d.ts +2 -1
  138. package/dist/types/modules/auth/auth.router.d.ts +1 -1
  139. package/dist/types/modules/auth/auth.service.d.ts +2 -2
  140. package/dist/types/modules/base/base.router.d.ts +1 -1
  141. package/dist/types/modules/swagger/utils/built-in-route-path-object-manager.d.ts +4 -0
  142. package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +1 -1
  143. package/dist/types/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.d.ts +1 -1
  144. package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.d.ts +1 -1
  145. package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +1 -1
  146. package/dist/types/types/index.d.ts +5 -5
  147. package/dist/types/types/new-arkos-config.d.ts +1 -1
  148. package/dist/types/utils/arkos-router/types/index.d.ts +15 -14
  149. package/dist/types/utils/arkos-router/utils/helpers/index.d.ts +1 -0
  150. package/dist/types/utils/helpers/prisma.helpers.d.ts +1 -0
  151. package/package.json +2 -2
@@ -8,8 +8,8 @@ const dynamic_loader_1 = require("../../../../utils/dynamic-loader");
8
8
  const base_router_helpers_1 = require("../../../base/utils/helpers/base.router.helpers");
9
9
  const deepmerge_helper_1 = __importDefault(require("../../../../utils/helpers/deepmerge.helper"));
10
10
  const file_upload_service_1 = require("../../../file-upload/file-upload.service");
11
- function getFileUploadJsonSchemaPaths(arkosConfig) {
12
- const paths = {};
11
+ function getFileUploadJsonSchemaPaths(arkosConfig, existingPaths) {
12
+ const paths = { ...existingPaths };
13
13
  if (!arkosConfig.fileUpload)
14
14
  return paths;
15
15
  const FileUploadModuleComponents = (0, dynamic_loader_1.getModuleComponents)("file-upload");
@@ -60,359 +60,428 @@ function getFileUploadJsonSchemaPaths(arkosConfig) {
60
60
  const cleanBasePath = basePathname.endsWith("/")
61
61
  ? basePathname.slice(0, -1)
62
62
  : basePathname;
63
- paths[`${cleanBasePath}/{filePath*}`] = {
64
- get: {
65
- tags: ["File Upload"],
66
- summary: "Retrieve uploaded file",
67
- description: `Serves static files from the upload directory (${baseUploadDir}). This endpoint uses wildcard path matching to serve files from any subdirectory.`,
68
- operationId: "findFile",
69
- ...(shouldIncludeSecurity("View") && {
70
- security: [{ BearerAuth: [] }],
71
- }),
72
- parameters: [
73
- {
74
- name: "filePath",
75
- in: "path",
76
- required: true,
77
- schema: { type: "string" },
78
- description: "Path to the file including file type directory (e.g., images/photo.jpg, videos/clip.mp4)",
79
- },
80
- ],
81
- responses: {
82
- "200": {
83
- description: "File retrieved successfully",
84
- content: {
85
- "application/octet-stream": {
86
- schema: {
87
- type: "string",
88
- format: "binary",
89
- },
63
+ const pathname = `${cleanBasePath}/{filePath*}`;
64
+ if (!paths[pathname])
65
+ paths[pathname] = {};
66
+ const currentPath = paths[pathname].get;
67
+ const defaultParameters = [
68
+ {
69
+ name: "filePath",
70
+ in: "path",
71
+ required: true,
72
+ schema: { type: "string" },
73
+ description: "Path to the file including file type directory (e.g., images/photo.jpg, videos/clip.mp4)",
74
+ },
75
+ ];
76
+ const existingParams = currentPath?.parameters || [];
77
+ const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
78
+ const mergedParameters = [
79
+ ...existingParams,
80
+ ...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
81
+ ];
82
+ const defaultSpec = {
83
+ tags: ["File Upload", ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
84
+ summary: currentPath?.summary === pathname || !currentPath?.summary
85
+ ? "Retrieve uploaded file"
86
+ : currentPath?.summary,
87
+ description: currentPath?.description ||
88
+ `Serves static files from the upload directory (${baseUploadDir}). This endpoint uses wildcard path matching to serve files from any subdirectory.`,
89
+ operationId: currentPath?.operationId || "findFile",
90
+ ...(shouldIncludeSecurity("View") && {
91
+ security: [{ BearerAuth: [] }],
92
+ }),
93
+ parameters: mergedParameters,
94
+ responses: {
95
+ ...(currentPath?.responses || {}),
96
+ "200": currentPath?.responses?.["200"] || {
97
+ description: "File retrieved successfully",
98
+ content: {
99
+ "application/octet-stream": {
100
+ schema: {
101
+ type: "string",
102
+ format: "binary",
90
103
  },
91
104
  },
92
105
  },
93
- "404": {
94
- description: "File not found",
95
- },
96
- ...(shouldIncludeSecurity("View") && {
97
- "401": { description: "Authentication required" },
98
- "403": { description: "Insufficient permissions to view files" },
99
- }),
100
106
  },
107
+ "404": currentPath?.responses?.["404"] || {
108
+ description: "File not found",
109
+ },
110
+ ...(shouldIncludeSecurity("View") && {
111
+ "401": currentPath?.responses?.["401"] || {
112
+ description: "Authentication required",
113
+ },
114
+ "403": currentPath?.responses?.["403"] || {
115
+ description: "Insufficient permissions to view files",
116
+ },
117
+ }),
101
118
  },
102
119
  };
120
+ paths[pathname].get = { ...(currentPath || {}), ...defaultSpec };
103
121
  }
104
122
  if (!isFileUploadEndpointDisabled("uploadFile")) {
105
123
  const cleanBasePath = basePathname.endsWith("/")
106
124
  ? basePathname.slice(0, -1)
107
125
  : basePathname;
108
- paths[`${cleanBasePath}/{fileType}`] = {
109
- post: {
110
- tags: ["File Upload"],
111
- summary: "Upload file(s)",
112
- description: "Upload one or multiple files. Supports image processing options for image uploads.",
113
- operationId: "uploadFile",
114
- ...(shouldIncludeSecurity("Create") && {
115
- security: [{ BearerAuth: [] }],
116
- }),
117
- parameters: [
118
- {
119
- name: "fileType",
120
- in: "path",
121
- required: true,
122
- schema: {
123
- type: "string",
124
- enum: ["images", "videos", "documents", "files"],
125
- },
126
- description: "Type of file being uploaded",
127
- },
128
- {
129
- name: "format",
130
- in: "query",
131
- required: false,
132
- schema: {
133
- type: "string",
134
- enum: ["jpeg", "jpg", "png", "webp", "gif", "avif"],
135
- },
136
- description: "Image format for conversion (only applicable for fileType=images)",
137
- },
138
- {
139
- name: "width",
140
- in: "query",
141
- required: false,
142
- schema: { type: "integer", minimum: 1 },
143
- description: "Target width for image resize (only applicable for fileType=images)",
144
- },
145
- {
146
- name: "height",
147
- in: "query",
148
- required: false,
149
- schema: { type: "integer", minimum: 1 },
150
- description: "Target height for image resize (only applicable for fileType=images)",
151
- },
152
- {
153
- name: "resizeTo",
154
- in: "query",
155
- required: false,
126
+ const pathname = `${cleanBasePath}/{fileType}`;
127
+ if (!paths[pathname])
128
+ paths[pathname] = {};
129
+ const currentPath = paths[pathname].post;
130
+ const defaultParameters = [
131
+ {
132
+ name: "fileType",
133
+ in: "path",
134
+ required: true,
135
+ schema: {
136
+ type: "string",
137
+ enum: ["images", "videos", "documents", "files"],
138
+ },
139
+ description: "Type of file being uploaded",
140
+ },
141
+ {
142
+ name: "format",
143
+ in: "query",
144
+ required: false,
145
+ schema: {
146
+ type: "string",
147
+ enum: ["jpeg", "jpg", "png", "webp", "gif", "avif"],
148
+ },
149
+ description: "Image format for conversion (only applicable for fileType=images)",
150
+ },
151
+ {
152
+ name: "width",
153
+ in: "query",
154
+ required: false,
155
+ schema: { type: "integer", minimum: 1 },
156
+ description: "Target width for image resize (only applicable for fileType=images)",
157
+ },
158
+ {
159
+ name: "height",
160
+ in: "query",
161
+ required: false,
162
+ schema: { type: "integer", minimum: 1 },
163
+ description: "Target height for image resize (only applicable for fileType=images)",
164
+ },
165
+ {
166
+ name: "resizeTo",
167
+ in: "query",
168
+ required: false,
169
+ schema: {
170
+ type: "string",
171
+ enum: ["cover", "contain", "fill", "inside", "outside"],
172
+ },
173
+ description: "Resize strategy (only applicable for fileType=images)",
174
+ },
175
+ ];
176
+ const existingParams = currentPath?.parameters || [];
177
+ const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
178
+ const mergedParameters = [
179
+ ...existingParams,
180
+ ...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
181
+ ];
182
+ const defaultSpec = {
183
+ tags: ["File Upload", ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
184
+ summary: currentPath?.summary === pathname || !currentPath?.summary
185
+ ? "Upload file(s)"
186
+ : currentPath?.summary,
187
+ description: currentPath?.description ||
188
+ "Upload one or multiple files. Supports image processing options for image uploads.",
189
+ operationId: currentPath?.operationId || "uploadFile",
190
+ ...(shouldIncludeSecurity("Create") && {
191
+ security: [{ BearerAuth: [] }],
192
+ }),
193
+ parameters: mergedParameters,
194
+ requestBody: currentPath?.requestBody || {
195
+ required: true,
196
+ content: {
197
+ "multipart/form-data": {
156
198
  schema: {
157
- type: "string",
158
- enum: ["cover", "contain", "fill", "inside", "outside"],
199
+ type: "object",
200
+ properties: {
201
+ images: {
202
+ type: "array",
203
+ items: { type: "string", format: "binary" },
204
+ description: getFileTypeDescription("images"),
205
+ },
206
+ videos: {
207
+ type: "array",
208
+ items: { type: "string", format: "binary" },
209
+ description: getFileTypeDescription("videos"),
210
+ },
211
+ documents: {
212
+ type: "array",
213
+ items: { type: "string", format: "binary" },
214
+ description: getFileTypeDescription("documents"),
215
+ },
216
+ files: {
217
+ type: "array",
218
+ items: { type: "string", format: "binary" },
219
+ description: getFileTypeDescription("files"),
220
+ },
221
+ },
159
222
  },
160
- description: "Resize strategy (only applicable for fileType=images)",
161
223
  },
162
- ],
163
- requestBody: {
164
- required: true,
224
+ },
225
+ },
226
+ responses: {
227
+ ...(currentPath?.responses || {}),
228
+ "200": currentPath?.responses?.["200"] || {
229
+ description: "File(s) uploaded successfully",
165
230
  content: {
166
- "multipart/form-data": {
231
+ "application/json": {
167
232
  schema: {
168
233
  type: "object",
169
234
  properties: {
170
- images: {
171
- type: "array",
172
- items: { type: "string", format: "binary" },
173
- description: getFileTypeDescription("images"),
174
- },
175
- videos: {
176
- type: "array",
177
- items: { type: "string", format: "binary" },
178
- description: getFileTypeDescription("videos"),
179
- },
180
- documents: {
181
- type: "array",
182
- items: { type: "string", format: "binary" },
183
- description: getFileTypeDescription("documents"),
184
- },
185
- files: {
186
- type: "array",
187
- items: { type: "string", format: "binary" },
188
- description: getFileTypeDescription("files"),
235
+ success: { type: "boolean", example: true },
236
+ data: {
237
+ oneOf: [
238
+ { type: "string", description: "URL of uploaded file" },
239
+ {
240
+ type: "array",
241
+ items: { type: "string" },
242
+ description: "URLs of uploaded files",
243
+ },
244
+ ],
189
245
  },
246
+ message: { type: "string" },
190
247
  },
191
248
  },
192
249
  },
193
250
  },
194
251
  },
195
- responses: {
196
- "200": {
197
- description: "File(s) uploaded successfully",
198
- content: {
199
- "application/json": {
200
- schema: {
201
- type: "object",
202
- properties: {
203
- success: { type: "boolean", example: true },
204
- data: {
205
- oneOf: [
206
- { type: "string", description: "URL of uploaded file" },
207
- {
208
- type: "array",
209
- items: { type: "string" },
210
- description: "URLs of uploaded files",
211
- },
212
- ],
213
- },
214
- message: { type: "string" },
215
- },
216
- },
217
- },
218
- },
252
+ "400": currentPath?.responses?.["400"] || {
253
+ description: "Invalid file type, size limit exceeded, or no file uploaded",
254
+ },
255
+ ...(shouldIncludeSecurity("Create") && {
256
+ "401": currentPath?.responses?.["401"] || {
257
+ description: "Authentication required",
219
258
  },
220
- "400": {
221
- description: "Invalid file type, size limit exceeded, or no file uploaded",
259
+ "403": currentPath?.responses?.["403"] || {
260
+ description: "Insufficient permissions to upload files",
222
261
  },
223
- ...(shouldIncludeSecurity("Create") && {
224
- "401": { description: "Authentication required" },
225
- "403": { description: "Insufficient permissions to upload files" },
226
- }),
227
- },
262
+ }),
228
263
  },
229
264
  };
265
+ paths[pathname].post = { ...(currentPath || {}), ...defaultSpec };
230
266
  }
231
267
  if (!isFileUploadEndpointDisabled("updateFile")) {
232
268
  const cleanBasePath = basePathname.endsWith("/")
233
269
  ? basePathname.slice(0, -1)
234
270
  : basePathname;
235
- paths[`${cleanBasePath}/{fileType}/{fileName}`] = {
236
- ...(paths[`${cleanBasePath}/{fileType}/{fileName}`] || {}),
237
- patch: {
238
- tags: ["File Upload"],
239
- summary: "Update existing file",
240
- description: "Replace an existing file with a new one. Deletes the old file and uploads the new one.",
241
- operationId: "updateFile",
242
- ...(shouldIncludeSecurity("Update") && {
243
- security: [{ BearerAuth: [] }],
244
- }),
245
- parameters: [
246
- {
247
- name: "fileType",
248
- in: "path",
249
- required: true,
250
- schema: {
251
- type: "string",
252
- enum: ["images", "videos", "documents", "files"],
253
- },
254
- description: "Type of file being updated",
255
- },
256
- {
257
- name: "fileName",
258
- in: "path",
259
- required: true,
260
- schema: { type: "string" },
261
- description: "Name of the file to update",
262
- },
263
- {
264
- name: "format",
265
- in: "query",
266
- required: false,
267
- schema: {
268
- type: "string",
269
- enum: ["jpeg", "jpg", "png", "webp", "gif", "avif"],
270
- },
271
- description: "Image format for conversion (only applicable for fileType=images)",
272
- },
273
- {
274
- name: "width",
275
- in: "query",
276
- required: false,
277
- schema: { type: "integer", minimum: 1 },
278
- description: "Target width for image resize (only applicable for fileType=images)",
279
- },
280
- {
281
- name: "height",
282
- in: "query",
283
- required: false,
284
- schema: { type: "integer", minimum: 1 },
285
- description: "Target height for image resize (only applicable for fileType=images)",
286
- },
287
- {
288
- name: "resizeTo",
289
- in: "query",
290
- required: false,
271
+ const pathname = `${cleanBasePath}/{fileType}/{fileName}`;
272
+ if (!paths[pathname])
273
+ paths[pathname] = {};
274
+ const currentPath = paths[pathname].patch;
275
+ const defaultParameters = [
276
+ {
277
+ name: "fileType",
278
+ in: "path",
279
+ required: true,
280
+ schema: {
281
+ type: "string",
282
+ enum: ["images", "videos", "documents", "files"],
283
+ },
284
+ description: "Type of file being updated",
285
+ },
286
+ {
287
+ name: "fileName",
288
+ in: "path",
289
+ required: true,
290
+ schema: { type: "string" },
291
+ description: "Name of the file to update",
292
+ },
293
+ {
294
+ name: "format",
295
+ in: "query",
296
+ required: false,
297
+ schema: {
298
+ type: "string",
299
+ enum: ["jpeg", "jpg", "png", "webp", "gif", "avif"],
300
+ },
301
+ description: "Image format for conversion (only applicable for fileType=images)",
302
+ },
303
+ {
304
+ name: "width",
305
+ in: "query",
306
+ required: false,
307
+ schema: { type: "integer", minimum: 1 },
308
+ description: "Target width for image resize (only applicable for fileType=images)",
309
+ },
310
+ {
311
+ name: "height",
312
+ in: "query",
313
+ required: false,
314
+ schema: { type: "integer", minimum: 1 },
315
+ description: "Target height for image resize (only applicable for fileType=images)",
316
+ },
317
+ {
318
+ name: "resizeTo",
319
+ in: "query",
320
+ required: false,
321
+ schema: {
322
+ type: "string",
323
+ enum: ["cover", "contain", "fill", "inside", "outside"],
324
+ },
325
+ description: "Resize strategy (only applicable for fileType=images)",
326
+ },
327
+ ];
328
+ const existingParams = currentPath?.parameters || [];
329
+ const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
330
+ const mergedParameters = [
331
+ ...existingParams,
332
+ ...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
333
+ ];
334
+ const defaultSpec = {
335
+ tags: ["File Upload", ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
336
+ summary: currentPath?.summary === pathname || !currentPath?.summary
337
+ ? "Update existing file"
338
+ : currentPath?.summary,
339
+ description: currentPath?.description ||
340
+ "Replace an existing file with a new one. Deletes the old file and uploads the new one.",
341
+ operationId: currentPath?.operationId || "updateFile",
342
+ ...(shouldIncludeSecurity("Update") && {
343
+ security: [{ BearerAuth: [] }],
344
+ }),
345
+ parameters: mergedParameters,
346
+ requestBody: currentPath?.requestBody || {
347
+ required: true,
348
+ content: {
349
+ "multipart/form-data": {
291
350
  schema: {
292
- type: "string",
293
- enum: ["cover", "contain", "fill", "inside", "outside"],
351
+ type: "object",
352
+ properties: {
353
+ images: {
354
+ type: "array",
355
+ items: { type: "string", format: "binary" },
356
+ description: getFileTypeDescription("images"),
357
+ },
358
+ videos: {
359
+ type: "array",
360
+ items: { type: "string", format: "binary" },
361
+ description: getFileTypeDescription("videos"),
362
+ },
363
+ documents: {
364
+ type: "array",
365
+ items: { type: "string", format: "binary" },
366
+ description: getFileTypeDescription("documents"),
367
+ },
368
+ files: {
369
+ type: "array",
370
+ items: { type: "string", format: "binary" },
371
+ description: getFileTypeDescription("files"),
372
+ },
373
+ },
294
374
  },
295
- description: "Resize strategy (only applicable for fileType=images)",
296
375
  },
297
- ],
298
- requestBody: {
299
- required: true,
376
+ },
377
+ },
378
+ responses: {
379
+ ...(currentPath?.responses || {}),
380
+ "200": currentPath?.responses?.["200"] || {
381
+ description: "File updated successfully",
300
382
  content: {
301
- "multipart/form-data": {
383
+ "application/json": {
302
384
  schema: {
303
385
  type: "object",
304
386
  properties: {
305
- images: {
306
- type: "array",
307
- items: { type: "string", format: "binary" },
308
- description: getFileTypeDescription("images"),
309
- },
310
- videos: {
311
- type: "array",
312
- items: { type: "string", format: "binary" },
313
- description: getFileTypeDescription("videos"),
314
- },
315
- documents: {
316
- type: "array",
317
- items: { type: "string", format: "binary" },
318
- description: getFileTypeDescription("documents"),
319
- },
320
- files: {
321
- type: "array",
322
- items: { type: "string", format: "binary" },
323
- description: getFileTypeDescription("files"),
387
+ success: { type: "boolean", example: true },
388
+ data: {
389
+ oneOf: [
390
+ { type: "string", description: "URL of updated file" },
391
+ {
392
+ type: "array",
393
+ items: { type: "string" },
394
+ description: "URLs of updated files",
395
+ },
396
+ ],
324
397
  },
398
+ message: { type: "string" },
325
399
  },
326
400
  },
327
401
  },
328
402
  },
329
403
  },
330
- responses: {
331
- "200": {
332
- description: "File updated successfully",
333
- content: {
334
- "application/json": {
335
- schema: {
336
- type: "object",
337
- properties: {
338
- success: { type: "boolean", example: true },
339
- data: {
340
- oneOf: [
341
- { type: "string", description: "URL of updated file" },
342
- {
343
- type: "array",
344
- items: { type: "string" },
345
- description: "URLs of updated files",
346
- },
347
- ],
348
- },
349
- message: { type: "string" },
350
- },
351
- },
352
- },
353
- },
354
- },
355
- "400": {
356
- description: "Invalid file type, size limit exceeded, or no file uploaded",
404
+ "400": currentPath?.responses?.["400"] || {
405
+ description: "Invalid file type, size limit exceeded, or no file uploaded",
406
+ },
407
+ "404": currentPath?.responses?.["404"] || {
408
+ description: "Original file not found",
409
+ },
410
+ ...(shouldIncludeSecurity("Update") && {
411
+ "401": currentPath?.responses?.["401"] || {
412
+ description: "Authentication required",
357
413
  },
358
- "404": {
359
- description: "Original file not found",
414
+ "403": currentPath?.responses?.["403"] || {
415
+ description: "Insufficient permissions to update files",
360
416
  },
361
- ...(shouldIncludeSecurity("Update") && {
362
- "401": { description: "Authentication required" },
363
- "403": { description: "Insufficient permissions to update files" },
364
- }),
365
- },
417
+ }),
366
418
  },
367
419
  };
420
+ paths[pathname].patch = { ...(currentPath || {}), ...defaultSpec };
368
421
  }
369
422
  if (!isFileUploadEndpointDisabled("deleteFile")) {
370
423
  const cleanBasePath = basePathname.endsWith("/")
371
424
  ? basePathname.slice(0, -1)
372
425
  : basePathname;
373
- if (!paths[`${cleanBasePath}/{fileType}/{fileName}`]) {
374
- paths[`${cleanBasePath}/{fileType}/{fileName}`] = {};
375
- }
376
- paths[`${cleanBasePath}/{fileType}/{fileName}`].delete = {
377
- tags: ["File Upload"],
378
- summary: "Delete file",
379
- description: "Delete an uploaded file from the server",
380
- operationId: "deleteFile",
426
+ const pathname = `${cleanBasePath}/{fileType}/{fileName}`;
427
+ if (!paths[pathname])
428
+ paths[pathname] = {};
429
+ const currentPath = paths[pathname].delete;
430
+ const defaultParameters = [
431
+ {
432
+ name: "fileType",
433
+ in: "path",
434
+ required: true,
435
+ schema: {
436
+ type: "string",
437
+ enum: ["images", "videos", "documents", "files"],
438
+ },
439
+ description: "Type of file being deleted",
440
+ },
441
+ {
442
+ name: "fileName",
443
+ in: "path",
444
+ required: true,
445
+ schema: { type: "string" },
446
+ description: "Name of the file to delete",
447
+ },
448
+ ];
449
+ const existingParams = currentPath?.parameters || [];
450
+ const existingParamKeys = new Set(existingParams.map((p) => `${p.in}-${p.name}`));
451
+ const mergedParameters = [
452
+ ...existingParams,
453
+ ...defaultParameters.filter((p) => !existingParamKeys.has(`${p.in}-${p.name}`)),
454
+ ];
455
+ const defaultSpec = {
456
+ tags: ["File Upload", ...(currentPath?.tags || [])].filter((tag) => tag !== "Defaults"),
457
+ summary: currentPath?.summary === pathname || !currentPath?.summary
458
+ ? "Delete file"
459
+ : currentPath?.summary,
460
+ description: currentPath?.description || "Delete an uploaded file from the server",
461
+ operationId: currentPath?.operationId || "deleteFile",
381
462
  ...(shouldIncludeSecurity("Delete") && {
382
463
  security: [{ BearerAuth: [] }],
383
464
  }),
384
- parameters: [
385
- {
386
- name: "fileType",
387
- in: "path",
388
- required: true,
389
- schema: {
390
- type: "string",
391
- enum: ["images", "videos", "documents", "files"],
392
- },
393
- description: "Type of file being deleted",
394
- },
395
- {
396
- name: "fileName",
397
- in: "path",
398
- required: true,
399
- schema: { type: "string" },
400
- description: "Name of the file to delete",
401
- },
402
- ],
465
+ parameters: mergedParameters,
403
466
  responses: {
404
- "204": {
467
+ ...(currentPath?.responses || {}),
468
+ "204": currentPath?.responses?.["204"] || {
405
469
  description: "File deleted successfully",
406
470
  },
407
- "404": {
471
+ "404": currentPath?.responses?.["404"] || {
408
472
  description: "File not found",
409
473
  },
410
474
  ...(shouldIncludeSecurity("Delete") && {
411
- "401": { description: "Authentication required" },
412
- "403": { description: "Insufficient permissions to delete files" },
475
+ "401": currentPath?.responses?.["401"] || {
476
+ description: "Authentication required",
477
+ },
478
+ "403": currentPath?.responses?.["403"] || {
479
+ description: "Insufficient permissions to delete files",
480
+ },
413
481
  }),
414
482
  },
415
483
  };
484
+ paths[pathname].delete = { ...(currentPath || {}), ...defaultSpec };
416
485
  }
417
486
  return paths;
418
487
  }