@moostjs/swagger 0.5.20 → 0.5.22

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/index.cjs CHANGED
@@ -1,627 +1,541 @@
1
- 'use strict';
1
+ "use strict";
2
+ //#region rolldown:runtime
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
2
23
 
3
- var moost = require('moost');
4
- var eventHttp = require('@moostjs/event-http');
5
- var zod = require('@moostjs/zod');
6
- var eventHttp$1 = require('@wooksjs/event-http');
7
- var httpStatic = require('@wooksjs/http-static');
8
- var Path = require('path');
9
- var swaggerUiDist = require('swagger-ui-dist');
10
- var zodParser = require('zod-parser');
24
+ //#endregion
25
+ const moost = __toESM(require("moost"));
26
+ const __moostjs_event_http = __toESM(require("@moostjs/event-http"));
27
+ const __moostjs_zod = __toESM(require("@moostjs/zod"));
28
+ const __wooksjs_event_http = __toESM(require("@wooksjs/event-http"));
29
+ const __wooksjs_http_static = __toESM(require("@wooksjs/http-static"));
30
+ const path = __toESM(require("path"));
31
+ const swagger_ui_dist = __toESM(require("swagger-ui-dist"));
32
+ const zod_parser = __toESM(require("zod-parser"));
11
33
 
34
+ //#region packages/swagger/src/swagger.mate.ts
12
35
  function getSwaggerMate() {
13
- return moost.getMoostMate();
36
+ return (0, moost.getMoostMate)();
14
37
  }
15
38
 
16
- const SwaggerTag = (tag) => getSwaggerMate().decorate('swaggerTags', tag, true);
17
- const SwaggerExclude = () => getSwaggerMate().decorate('swaggerExclude', true);
18
- const SwaggerDescription = (descr) => getSwaggerMate().decorate('swaggerDescription', descr);
39
+ //#endregion
40
+ //#region packages/swagger/src/decorators.ts
41
+ const SwaggerTag = (tag) => getSwaggerMate().decorate("swaggerTags", tag, true);
42
+ const SwaggerExclude = () => getSwaggerMate().decorate("swaggerExclude", true);
43
+ const SwaggerDescription = (descr) => getSwaggerMate().decorate("swaggerDescription", descr);
19
44
  function SwaggerResponse(code, opts, example) {
20
- return getSwaggerMate().decorate(meta => {
21
- let ex;
22
- if (example) {
23
- ex = example;
24
- }
25
- if (typeof code !== 'number' && opts) {
26
- ex = opts;
27
- }
28
- meta.swaggerResponses = meta.swaggerResponses || {};
29
- const keyCode = typeof code === 'number' ? code : 0;
30
- const opt = typeof code === 'number' ? opts : code;
31
- const contentType = typeof opt.contentType === 'string'
32
- ? opt.contentType
33
- : '*/*';
34
- const response = (['object', 'function'].includes(typeof opt.response)
35
- ? opt.response
36
- : opt);
37
- meta.swaggerResponses[keyCode] = meta.swaggerResponses[keyCode] || {};
38
- meta.swaggerResponses[keyCode][contentType] = { response, example: ex };
39
- return meta;
40
- });
45
+ return getSwaggerMate().decorate((meta) => {
46
+ let ex;
47
+ if (example) ex = example;
48
+ if (typeof code !== "number" && opts) ex = opts;
49
+ meta.swaggerResponses = meta.swaggerResponses || {};
50
+ const keyCode = typeof code === "number" ? code : 0;
51
+ const opt = typeof code === "number" ? opts : code;
52
+ const contentType = typeof opt.contentType === "string" ? opt.contentType : "*/*";
53
+ const response = ["object", "function"].includes(typeof opt.response) ? opt.response : opt;
54
+ meta.swaggerResponses[keyCode] = meta.swaggerResponses[keyCode] || {};
55
+ meta.swaggerResponses[keyCode][contentType] = {
56
+ response,
57
+ example: ex
58
+ };
59
+ return meta;
60
+ });
41
61
  }
42
62
  function SwaggerRequestBody(opt) {
43
- return getSwaggerMate().decorate(meta => {
44
- meta.swaggerRequestBody = meta.swaggerRequestBody || {};
45
- const contentType = typeof opt.contentType === 'string'
46
- ? opt.contentType
47
- : 'application/json';
48
- const response = (typeof opt.contentType === 'string'
49
- ? opt.response
50
- : opt);
51
- meta.swaggerRequestBody[contentType] = response;
52
- return meta;
53
- });
63
+ return getSwaggerMate().decorate((meta) => {
64
+ meta.swaggerRequestBody = meta.swaggerRequestBody || {};
65
+ const contentType = typeof opt.contentType === "string" ? opt.contentType : "application/json";
66
+ const response = typeof opt.contentType === "string" ? opt.response : opt;
67
+ meta.swaggerRequestBody[contentType] = response;
68
+ return meta;
69
+ });
54
70
  }
55
71
  function SwaggerParam(opts) {
56
- return getSwaggerMate().decorate('swaggerParams', opts, true);
72
+ return getSwaggerMate().decorate("swaggerParams", opts, true);
57
73
  }
58
74
  function SwaggerExample(example) {
59
- return getSwaggerMate().decorate('swaggerExample', example);
75
+ return getSwaggerMate().decorate("swaggerExample", example);
60
76
  }
61
77
 
62
- /******************************************************************************
63
- Copyright (c) Microsoft Corporation.
64
-
65
- Permission to use, copy, modify, and/or distribute this software for any
66
- purpose with or without fee is hereby granted.
67
-
68
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
69
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
70
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
71
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
72
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
73
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
74
- PERFORMANCE OF THIS SOFTWARE.
75
- ***************************************************************************** */
76
- /* global Reflect, Promise, SuppressedError, Symbol */
77
-
78
-
79
- function __decorate(decorators, target, key, desc) {
80
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
81
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
82
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
83
- return c > 3 && r && Object.defineProperty(target, key, r), r;
84
- }
85
-
86
- function __param(paramIndex, decorator) {
87
- return function (target, key) { decorator(target, key, paramIndex); }
88
- }
89
-
90
- function __metadata(metadataKey, metadataValue) {
91
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
92
- }
93
-
94
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
95
- var e = new Error(message);
96
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
97
- };
98
-
78
+ //#endregion
79
+ //#region packages/swagger/src/mapping.ts
99
80
  function mapToSwaggerSpec(metadata, options, logger) {
100
- const swaggerSpec = {
101
- openapi: '3.0.0',
102
- info: {
103
- title: options?.title || 'API Documentation',
104
- version: options?.version || '1.0.0',
105
- },
106
- paths: {},
107
- tags: [],
108
- components: {
109
- schemas: globalSchemas,
110
- },
111
- };
112
- for (const controller of metadata) {
113
- const cmeta = controller.meta;
114
- if (cmeta?.swaggerExclude) {
115
- continue;
116
- }
117
- const controllerTags = cmeta?.swaggerTags || [];
118
- for (const handler of controller.handlers) {
119
- const hmeta = handler.meta;
120
- const hh = handler.handler;
121
- if (hh.type !== 'HTTP' || hmeta?.swaggerExclude || handler.registeredAs.length === 0) {
122
- continue;
123
- }
124
- const uniqueParams = {};
125
- const handlerPath = handler.registeredAs[0].path;
126
- const handlerMethod = hh.method?.toLowerCase() || 'get';
127
- const handlerDescription = hmeta?.description;
128
- const handlerTags = [...controllerTags, ...(hmeta?.swaggerTags || [])];
129
- if (!swaggerSpec.paths[handlerPath]) {
130
- swaggerSpec.paths[handlerPath] = {};
131
- }
132
- let responses;
133
- if (hmeta?.swaggerResponses) {
134
- for (const [code, responseConfigs] of Object.entries(hmeta.swaggerResponses)) {
135
- const newCode = code === '0' ? getDefaultStatusCode(handlerMethod) : code;
136
- for (const [contentType, conf] of Object.entries(responseConfigs)) {
137
- const { response, example } = conf;
138
- const schema = getSwaggerSchemaFromSwaggerConfigType(response);
139
- if (schema) {
140
- responses = responses || {};
141
- responses[newCode] = {
142
- content: {
143
- [contentType]: { schema: { ...schema, example: example || schema.example } },
144
- },
145
- };
146
- }
147
- }
148
- }
149
- }
150
- else if (hmeta?.returnType) {
151
- const parsed = myParseZod(zod.getZodType({
152
- type: hmeta.returnType,
153
- }));
154
- if (['ZodString', 'ZodNumber', 'ZodObject', 'ZodArray', 'ZodBoolean'].includes(parsed.$type)) {
155
- const schema = getSwaggerSchema(parsed);
156
- if (schema) {
157
- responses = responses || {};
158
- responses[getDefaultStatusCode(handlerMethod)] = {
159
- content: {
160
- '*/*': {
161
- schema,
162
- },
163
- },
164
- };
165
- }
166
- }
167
- }
168
- let reqBodyRequired = true;
169
- const bodyConfig = {};
170
- if (hmeta?.swaggerRequestBody) {
171
- for (const [contentType, type] of Object.entries(hmeta.swaggerRequestBody)) {
172
- let zt;
173
- let schema;
174
- if (type instanceof zod.z.ZodType) {
175
- zt = type;
176
- }
177
- else if (typeof type === 'function') {
178
- zt = zod.getZodType({
179
- type,
180
- });
181
- }
182
- if (zt) {
183
- const parsed = myParseZod(zt);
184
- if (['ZodString', 'ZodNumber', 'ZodObject', 'ZodArray', 'ZodBoolean'].includes(parsed.$type)) {
185
- schema = getSwaggerSchema(parsed);
186
- }
187
- }
188
- bodyConfig[contentType] = { schema };
189
- }
190
- }
191
- swaggerSpec.paths[handlerPath][handlerMethod] = {
192
- summary: handlerDescription,
193
- operationId: `${handlerMethod.toUpperCase()}_${handlerPath
194
- .replace(/\//g, '_')
195
- .replace(/[{}]/g, '__')
196
- .replace(/[^\dA-Za-z]/g, '_')}`,
197
- tags: handlerTags,
198
- parameters: [],
199
- responses,
200
- };
201
- const endpointSpec = swaggerSpec.paths[handlerPath][handlerMethod];
202
- function addParam(param) {
203
- const key = `${param.in}//${param.name}`;
204
- if (uniqueParams[key]) {
205
- uniqueParams[key].description = param.description ?? uniqueParams[key].description;
206
- uniqueParams[key].required = param.required;
207
- uniqueParams[key].schema = param.schema ?? uniqueParams[key].schema;
208
- }
209
- else {
210
- uniqueParams[key] = param;
211
- endpointSpec.parameters.push(param);
212
- }
213
- }
214
- for (const param of cmeta?.swaggerParams || []) {
215
- addParam({
216
- name: param.name,
217
- in: param.in,
218
- description: param.description,
219
- required: !!param.required,
220
- schema: getSwaggerSchemaFromSwaggerConfigType(param.type) || { type: 'string' },
221
- });
222
- }
223
- for (const param of hmeta?.swaggerParams || []) {
224
- addParam({
225
- name: param.name,
226
- in: param.in,
227
- description: param.description,
228
- required: !!param.required,
229
- schema: getSwaggerSchemaFromSwaggerConfigType(param.type) || { type: 'string' },
230
- });
231
- }
232
- for (const paramName of handler.registeredAs[0].args) {
233
- const paramIndex = handler.meta.params.findIndex(param => param.paramSource === 'ROUTE' && param.paramName === paramName);
234
- const paramMeta = handler.meta.params[paramIndex];
235
- let schema;
236
- let parsed;
237
- if (paramMeta) {
238
- const zodType = zod.getZodTypeForProp({
239
- type: controller.type,
240
- key: handler.method,
241
- index: paramIndex,
242
- }, {
243
- type: paramMeta.type,
244
- additionalMeta: paramMeta,
245
- }, undefined, logger);
246
- parsed = myParseZod(zodType);
247
- schema = getSwaggerSchema(parsed, true);
248
- }
249
- addParam({
250
- name: paramName,
251
- in: 'path',
252
- description: paramMeta ? paramMeta.description : undefined,
253
- required: !paramMeta.optional && !parsed?.$optional,
254
- schema: schema || { type: 'string' },
255
- });
256
- }
257
- for (let i = 0; i < handler.meta.params.length; i++) {
258
- const paramMeta = handler.meta.params[i];
259
- if (paramMeta.paramSource && ['QUERY_ITEM', 'QUERY'].includes(paramMeta.paramSource)) {
260
- const zodType = zod.getZodTypeForProp({
261
- type: controller.type,
262
- key: handler.method,
263
- index: i,
264
- }, {
265
- type: paramMeta.type,
266
- additionalMeta: paramMeta,
267
- }, undefined, logger);
268
- const parsed = myParseZod(zodType);
269
- const schema = getSwaggerSchema(parsed, true);
270
- if (paramMeta.paramSource === 'QUERY_ITEM') {
271
- endpointSpec.parameters.push({
272
- name: paramMeta.paramName || '',
273
- in: 'query',
274
- description: paramMeta.description,
275
- required: !paramMeta.optional && !parsed.$optional,
276
- schema: schema || { type: 'string' },
277
- });
278
- }
279
- else if (paramMeta.paramSource === 'QUERY' && parsed.$type === 'ZodObject') {
280
- for (const [key, value] of Object.entries(parsed.$inner)) {
281
- const schema = getSwaggerSchema(value, true);
282
- if (schema) {
283
- const swaggerSchema = {
284
- name: key,
285
- in: 'query',
286
- description: value.description,
287
- required: !parsed.$optional && !value.$optional,
288
- schema,
289
- };
290
- endpointSpec.parameters.push(swaggerSchema);
291
- }
292
- }
293
- }
294
- }
295
- if (paramMeta.paramSource === 'BODY') {
296
- const zodType = zod.getZodTypeForProp({
297
- type: controller.type,
298
- key: handler.method,
299
- index: i,
300
- }, {
301
- type: paramMeta.type,
302
- additionalMeta: paramMeta,
303
- }, undefined, logger);
304
- const parsed = myParseZod(zodType);
305
- let contentType = '';
306
- switch (parsed.$type) {
307
- case 'ZodString':
308
- case 'ZodNumber':
309
- case 'ZodBigInt':
310
- case 'ZodBoolean':
311
- case 'ZodDate':
312
- case 'ZodEnum':
313
- case 'ZodNativeEnum':
314
- case 'ZodLiteral': {
315
- contentType = 'text/plan';
316
- break;
317
- }
318
- default: {
319
- contentType = 'application/json';
320
- }
321
- }
322
- if (!bodyConfig[contentType]) {
323
- bodyConfig[contentType] = { schema: getSwaggerSchema(parsed) };
324
- }
325
- reqBodyRequired = !zodType.isOptional() && !paramMeta.optional;
326
- }
327
- }
328
- if (Object.entries(bodyConfig).some(e => !!e[1])) {
329
- swaggerSpec.paths[handlerPath][handlerMethod].requestBody = {
330
- content: bodyConfig,
331
- required: reqBodyRequired,
332
- };
333
- }
334
- }
335
- }
336
- return swaggerSpec;
81
+ const swaggerSpec = {
82
+ openapi: "3.0.0",
83
+ info: {
84
+ title: options?.title || "API Documentation",
85
+ version: options?.version || "1.0.0"
86
+ },
87
+ paths: {},
88
+ tags: [],
89
+ components: { schemas: globalSchemas }
90
+ };
91
+ for (const controller of metadata) {
92
+ const cmeta = controller.meta;
93
+ if (cmeta?.swaggerExclude) continue;
94
+ const controllerTags = cmeta?.swaggerTags || [];
95
+ for (const handler of controller.handlers) {
96
+ const hmeta = handler.meta;
97
+ const hh = handler.handler;
98
+ if (hh.type !== "HTTP" || hmeta?.swaggerExclude || handler.registeredAs.length === 0) continue;
99
+ const uniqueParams = {};
100
+ const handlerPath = handler.registeredAs[0].path;
101
+ const handlerMethod = hh.method?.toLowerCase() || "get";
102
+ const handlerDescription = hmeta?.description;
103
+ const handlerTags = [...controllerTags, ...hmeta?.swaggerTags || []];
104
+ if (!swaggerSpec.paths[handlerPath]) swaggerSpec.paths[handlerPath] = {};
105
+ let responses;
106
+ if (hmeta?.swaggerResponses) for (const [code, responseConfigs] of Object.entries(hmeta.swaggerResponses)) {
107
+ const newCode = code === "0" ? getDefaultStatusCode(handlerMethod) : code;
108
+ for (const [contentType, conf] of Object.entries(responseConfigs)) {
109
+ const { response, example } = conf;
110
+ const schema = getSwaggerSchemaFromSwaggerConfigType(response);
111
+ if (schema) {
112
+ responses = responses || {};
113
+ responses[newCode] = { content: { [contentType]: { schema: {
114
+ ...schema,
115
+ example: example || schema.example
116
+ } } } };
117
+ }
118
+ }
119
+ }
120
+ else if (hmeta?.returnType) {
121
+ const parsed = myParseZod((0, __moostjs_zod.getZodType)({ type: hmeta.returnType }));
122
+ if ([
123
+ "ZodString",
124
+ "ZodNumber",
125
+ "ZodObject",
126
+ "ZodArray",
127
+ "ZodBoolean"
128
+ ].includes(parsed.$type)) {
129
+ const schema = getSwaggerSchema(parsed);
130
+ if (schema) {
131
+ responses = responses || {};
132
+ responses[getDefaultStatusCode(handlerMethod)] = { content: { "*/*": { schema } } };
133
+ }
134
+ }
135
+ }
136
+ let reqBodyRequired = true;
137
+ const bodyConfig = {};
138
+ if (hmeta?.swaggerRequestBody) for (const [contentType, type] of Object.entries(hmeta.swaggerRequestBody)) {
139
+ let zt;
140
+ let schema;
141
+ if (type instanceof __moostjs_zod.z.ZodType) zt = type;
142
+ else if (typeof type === "function") zt = (0, __moostjs_zod.getZodType)({ type });
143
+ if (zt) {
144
+ const parsed = myParseZod(zt);
145
+ if ([
146
+ "ZodString",
147
+ "ZodNumber",
148
+ "ZodObject",
149
+ "ZodArray",
150
+ "ZodBoolean"
151
+ ].includes(parsed.$type)) schema = getSwaggerSchema(parsed);
152
+ }
153
+ bodyConfig[contentType] = { schema };
154
+ }
155
+ swaggerSpec.paths[handlerPath][handlerMethod] = {
156
+ summary: handlerDescription,
157
+ operationId: `${handlerMethod.toUpperCase()}_${handlerPath.replace(/\//g, "_").replace(/[{}]/g, "__").replace(/[^\dA-Za-z]/g, "_")}`,
158
+ tags: handlerTags,
159
+ parameters: [],
160
+ responses
161
+ };
162
+ const endpointSpec = swaggerSpec.paths[handlerPath][handlerMethod];
163
+ function addParam(param) {
164
+ const key = `${param.in}//${param.name}`;
165
+ if (uniqueParams[key]) {
166
+ uniqueParams[key].description = param.description ?? uniqueParams[key].description;
167
+ uniqueParams[key].required = param.required;
168
+ uniqueParams[key].schema = param.schema ?? uniqueParams[key].schema;
169
+ } else {
170
+ uniqueParams[key] = param;
171
+ endpointSpec.parameters.push(param);
172
+ }
173
+ }
174
+ for (const param of cmeta?.swaggerParams || []) addParam({
175
+ name: param.name,
176
+ in: param.in,
177
+ description: param.description,
178
+ required: !!param.required,
179
+ schema: getSwaggerSchemaFromSwaggerConfigType(param.type) || { type: "string" }
180
+ });
181
+ for (const param of hmeta?.swaggerParams || []) addParam({
182
+ name: param.name,
183
+ in: param.in,
184
+ description: param.description,
185
+ required: !!param.required,
186
+ schema: getSwaggerSchemaFromSwaggerConfigType(param.type) || { type: "string" }
187
+ });
188
+ for (const paramName of handler.registeredAs[0].args) {
189
+ const paramIndex = handler.meta.params.findIndex((param) => param.paramSource === "ROUTE" && param.paramName === paramName);
190
+ const paramMeta = handler.meta.params[paramIndex];
191
+ let schema;
192
+ let parsed;
193
+ if (paramMeta) {
194
+ const zodType = (0, __moostjs_zod.getZodTypeForProp)({
195
+ type: controller.type,
196
+ key: handler.method,
197
+ index: paramIndex
198
+ }, {
199
+ type: paramMeta.type,
200
+ additionalMeta: paramMeta
201
+ }, undefined, logger);
202
+ parsed = myParseZod(zodType);
203
+ schema = getSwaggerSchema(parsed, true);
204
+ }
205
+ addParam({
206
+ name: paramName,
207
+ in: "path",
208
+ description: paramMeta ? paramMeta.description : undefined,
209
+ required: !paramMeta.optional && !parsed?.$optional,
210
+ schema: schema || { type: "string" }
211
+ });
212
+ }
213
+ for (let i = 0; i < handler.meta.params.length; i++) {
214
+ const paramMeta = handler.meta.params[i];
215
+ if (paramMeta.paramSource && ["QUERY_ITEM", "QUERY"].includes(paramMeta.paramSource)) {
216
+ const zodType = (0, __moostjs_zod.getZodTypeForProp)({
217
+ type: controller.type,
218
+ key: handler.method,
219
+ index: i
220
+ }, {
221
+ type: paramMeta.type,
222
+ additionalMeta: paramMeta
223
+ }, undefined, logger);
224
+ const parsed = myParseZod(zodType);
225
+ const schema = getSwaggerSchema(parsed, true);
226
+ if (paramMeta.paramSource === "QUERY_ITEM") endpointSpec.parameters.push({
227
+ name: paramMeta.paramName || "",
228
+ in: "query",
229
+ description: paramMeta.description,
230
+ required: !paramMeta.optional && !parsed.$optional,
231
+ schema: schema || { type: "string" }
232
+ });
233
+ else if (paramMeta.paramSource === "QUERY" && parsed.$type === "ZodObject") for (const [key, value] of Object.entries(parsed.$inner)) {
234
+ const schema$1 = getSwaggerSchema(value, true);
235
+ if (schema$1) {
236
+ const swaggerSchema = {
237
+ name: key,
238
+ in: "query",
239
+ description: value.description,
240
+ required: !parsed.$optional && !value.$optional,
241
+ schema: schema$1
242
+ };
243
+ endpointSpec.parameters.push(swaggerSchema);
244
+ }
245
+ }
246
+ }
247
+ if (paramMeta.paramSource === "BODY") {
248
+ const zodType = (0, __moostjs_zod.getZodTypeForProp)({
249
+ type: controller.type,
250
+ key: handler.method,
251
+ index: i
252
+ }, {
253
+ type: paramMeta.type,
254
+ additionalMeta: paramMeta
255
+ }, undefined, logger);
256
+ const parsed = myParseZod(zodType);
257
+ let contentType = "";
258
+ switch (parsed.$type) {
259
+ case "ZodString":
260
+ case "ZodNumber":
261
+ case "ZodBigInt":
262
+ case "ZodBoolean":
263
+ case "ZodDate":
264
+ case "ZodEnum":
265
+ case "ZodNativeEnum":
266
+ case "ZodLiteral": {
267
+ contentType = "text/plan";
268
+ break;
269
+ }
270
+ default: contentType = "application/json";
271
+ }
272
+ if (!bodyConfig[contentType]) bodyConfig[contentType] = { schema: getSwaggerSchema(parsed) };
273
+ reqBodyRequired = !zodType.isOptional() && !paramMeta.optional;
274
+ }
275
+ }
276
+ if (bodyConfig && Object.entries(bodyConfig).some((e) => !!e[1])) swaggerSpec.paths[handlerPath][handlerMethod].requestBody = {
277
+ content: bodyConfig,
278
+ required: reqBodyRequired
279
+ };
280
+ }
281
+ }
282
+ return swaggerSpec;
337
283
  }
338
284
  const globalSchemas = {};
339
285
  function getSwaggerSchema(parsed, forParam) {
340
- const zodType = parsed.$ref;
341
- const meta = zodType.__type_ref ? getSwaggerMate().read(zodType.__type_ref) : undefined;
342
- if (!forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) {
343
- return { $ref: `#/components/schemas/${zodType.__type_ref.name}` };
344
- }
345
- if (forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) {
346
- return globalSchemas[zodType.__type_ref.name];
347
- }
348
- const schema = {};
349
- if (meta) {
350
- if (meta.swaggerExample) {
351
- schema.example = meta.swaggerExample;
352
- }
353
- if (meta.label || meta.id) {
354
- schema.title = meta.label || meta.id;
355
- }
356
- if (meta.description) {
357
- schema.description = meta.description;
358
- }
359
- }
360
- if (!forParam && zodType.__type_ref) {
361
- globalSchemas[zodType.__type_ref.name] = schema;
362
- }
363
- function asString() {
364
- schema.type = 'string';
365
- if (parsed.$checks) {
366
- const { regex } = parsed.$checks;
367
- if (regex) {
368
- schema.pattern = regex.source;
369
- }
370
- }
371
- }
372
- function asLiteral() {
373
- if (parsed.$type === 'ZodLiteral') {
374
- schema.type = 'string';
375
- schema.enum = [parsed.$value];
376
- }
377
- }
378
- function asEnum() {
379
- if (parsed.$type === 'ZodEnum') {
380
- schema.type = 'string';
381
- schema.enum = parsed.$value;
382
- }
383
- }
384
- function asNativeEnum() {
385
- if (parsed.$type === 'ZodNativeEnum') {
386
- schema.type = 'string';
387
- schema.enum = Object.keys(parsed.$value);
388
- }
389
- }
390
- if (forParam) {
391
- switch (parsed.$type) {
392
- case 'ZodAny':
393
- case 'ZodUnknown':
394
- case 'ZodString': {
395
- asString();
396
- break;
397
- }
398
- case 'ZodNumber': {
399
- schema.type = 'number';
400
- break;
401
- }
402
- case 'ZodBigInt': {
403
- schema.type = 'integer';
404
- break;
405
- }
406
- case 'ZodBoolean': {
407
- schema.type = 'boolean';
408
- break;
409
- }
410
- case 'ZodLiteral': {
411
- asLiteral();
412
- break;
413
- }
414
- case 'ZodEnum': {
415
- asEnum();
416
- break;
417
- }
418
- case 'ZodNativeEnum': {
419
- asNativeEnum();
420
- break;
421
- }
422
- case 'ZodDate': {
423
- schema.type = 'string';
424
- break;
425
- }
426
- case 'ZodNull': {
427
- schema.type = 'null';
428
- break;
429
- }
430
- default: {
431
- return undefined;
432
- }
433
- }
434
- }
435
- else {
436
- switch (parsed.$type) {
437
- case 'ZodString': {
438
- asString();
439
- break;
440
- }
441
- case 'ZodNumber': {
442
- schema.type = 'number';
443
- break;
444
- }
445
- case 'ZodBigInt': {
446
- schema.type = 'integer';
447
- break;
448
- }
449
- case 'ZodBoolean': {
450
- schema.type = 'boolean';
451
- break;
452
- }
453
- case 'ZodLiteral': {
454
- asLiteral();
455
- break;
456
- }
457
- case 'ZodEnum': {
458
- asEnum();
459
- break;
460
- }
461
- case 'ZodNativeEnum': {
462
- asNativeEnum();
463
- break;
464
- }
465
- case 'ZodDate': {
466
- schema.type = 'string';
467
- break;
468
- }
469
- case 'ZodNull': {
470
- schema.type = 'null';
471
- break;
472
- }
473
- case 'ZodFunction':
474
- case 'ZodSymbol':
475
- case 'ZodUndefined':
476
- case 'ZodUnknown':
477
- case 'ZodNever':
478
- case 'ZodVoid':
479
- case 'ZodNaN': {
480
- return undefined;
481
- }
482
- case 'ZodArray': {
483
- schema.type = 'array';
484
- schema.minItems = parsed.$checks?.minLength || undefined;
485
- schema.maxItems = parsed.$checks?.maxLength || undefined;
486
- schema.items = getSwaggerSchema(parsed.$inner);
487
- break;
488
- }
489
- case 'ZodTuple': {
490
- schema.type = 'array';
491
- schema.items = parsed.$inner
492
- .map(t => getSwaggerSchema(t))
493
- .filter(t => !!t);
494
- break;
495
- }
496
- case 'ZodObject': {
497
- schema.type = 'object';
498
- schema.properties = {};
499
- schema.required = [];
500
- if (zodType._def.unknownKeys === 'passthrough') {
501
- schema.additionalProperties = {};
502
- }
503
- for (const [key, val] of Object.entries(parsed.$inner)) {
504
- const prop = getSwaggerSchema(val);
505
- if (prop) {
506
- schema.properties[key] = prop;
507
- if (!val.$optional) {
508
- schema.required.push(key);
509
- }
510
- }
511
- }
512
- break;
513
- }
514
- case 'ZodPromise':
515
- case 'ZodRecord':
516
- case 'ZodMap':
517
- case 'ZodSet': {
518
- schema.type = 'object';
519
- schema.properties = {};
520
- schema.additionalProperties = parsed.$type === 'ZodRecord' ? {} : undefined;
521
- break;
522
- }
523
- case 'ZodUnion':
524
- case 'ZodDiscriminatedUnion': {
525
- schema.oneOf = parsed.$inner
526
- .map(t => getSwaggerSchema(t))
527
- .filter(t => !!t);
528
- break;
529
- }
530
- case 'ZodIntersection': {
531
- schema.allOf = parsed.$inner
532
- .map(t => getSwaggerSchema(t))
533
- .filter(t => !!t);
534
- break;
535
- }
536
- case 'ZodLazy': {
537
- return getSwaggerSchema(parsed.$get());
538
- }
539
- }
540
- }
541
- if (parsed.$nullable) {
542
- schema.nullable = parsed.$nullable;
543
- }
544
- if (parsed.$ref._def.description) {
545
- schema.description = parsed.$ref._def.description;
546
- }
547
- if (parsed.$checks) {
548
- const checks = parsed.$checks;
549
- if (parsed.$type === 'ZodString') {
550
- if (typeof checks.min === 'number') {
551
- schema.minLength = checks.min;
552
- }
553
- if (typeof checks.max === 'number') {
554
- schema.maxLength = checks.max;
555
- }
556
- }
557
- else {
558
- if (typeof checks.min === 'number') {
559
- schema.minimum = checks.min;
560
- }
561
- if (typeof checks.max === 'number') {
562
- schema.maximum = checks.max;
563
- }
564
- }
565
- }
566
- if (!forParam && zodType.__type_ref) {
567
- return { $ref: `#/components/schemas/${zodType.__type_ref.name}` };
568
- }
569
- return schema;
286
+ const zodType = parsed.$ref;
287
+ const meta = zodType.__type_ref ? getSwaggerMate().read(zodType.__type_ref) : undefined;
288
+ if (!forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) return { $ref: `#/components/schemas/${zodType.__type_ref.name}` };
289
+ if (forParam && zodType.__type_ref && globalSchemas[zodType.__type_ref.name]) return globalSchemas[zodType.__type_ref.name];
290
+ const schema = {};
291
+ if (meta) {
292
+ if (meta.swaggerExample) schema.example = meta.swaggerExample;
293
+ if (meta.label || meta.id) schema.title = meta.label || meta.id;
294
+ if (meta.description) schema.description = meta.description;
295
+ }
296
+ if (!forParam && zodType.__type_ref) globalSchemas[zodType.__type_ref.name] = schema;
297
+ function asString() {
298
+ schema.type = "string";
299
+ if (parsed.$checks) {
300
+ const { regex } = parsed.$checks;
301
+ if (regex) schema.pattern = regex.source;
302
+ }
303
+ }
304
+ function asLiteral() {
305
+ if (parsed.$type === "ZodLiteral") {
306
+ schema.type = "string";
307
+ schema.enum = [parsed.$value];
308
+ }
309
+ }
310
+ function asEnum() {
311
+ if (parsed.$type === "ZodEnum") {
312
+ schema.type = "string";
313
+ schema.enum = parsed.$value;
314
+ }
315
+ }
316
+ function asNativeEnum() {
317
+ if (parsed.$type === "ZodNativeEnum") {
318
+ schema.type = "string";
319
+ schema.enum = Object.keys(parsed.$value);
320
+ }
321
+ }
322
+ if (forParam) switch (parsed.$type) {
323
+ case "ZodAny":
324
+ case "ZodUnknown":
325
+ case "ZodString": {
326
+ asString();
327
+ break;
328
+ }
329
+ case "ZodNumber": {
330
+ schema.type = "number";
331
+ break;
332
+ }
333
+ case "ZodBigInt": {
334
+ schema.type = "integer";
335
+ break;
336
+ }
337
+ case "ZodBoolean": {
338
+ schema.type = "boolean";
339
+ break;
340
+ }
341
+ case "ZodLiteral": {
342
+ asLiteral();
343
+ break;
344
+ }
345
+ case "ZodEnum": {
346
+ asEnum();
347
+ break;
348
+ }
349
+ case "ZodNativeEnum": {
350
+ asNativeEnum();
351
+ break;
352
+ }
353
+ case "ZodDate": {
354
+ schema.type = "string";
355
+ break;
356
+ }
357
+ case "ZodNull": {
358
+ schema.type = "null";
359
+ break;
360
+ }
361
+ default: return undefined;
362
+ }
363
+ else switch (parsed.$type) {
364
+ case "ZodString": {
365
+ asString();
366
+ break;
367
+ }
368
+ case "ZodNumber": {
369
+ schema.type = "number";
370
+ break;
371
+ }
372
+ case "ZodBigInt": {
373
+ schema.type = "integer";
374
+ break;
375
+ }
376
+ case "ZodBoolean": {
377
+ schema.type = "boolean";
378
+ break;
379
+ }
380
+ case "ZodLiteral": {
381
+ asLiteral();
382
+ break;
383
+ }
384
+ case "ZodEnum": {
385
+ asEnum();
386
+ break;
387
+ }
388
+ case "ZodNativeEnum": {
389
+ asNativeEnum();
390
+ break;
391
+ }
392
+ case "ZodDate": {
393
+ schema.type = "string";
394
+ break;
395
+ }
396
+ case "ZodNull": {
397
+ schema.type = "null";
398
+ break;
399
+ }
400
+ case "ZodFunction":
401
+ case "ZodSymbol":
402
+ case "ZodUndefined":
403
+ case "ZodUnknown":
404
+ case "ZodNever":
405
+ case "ZodVoid":
406
+ case "ZodNaN": return undefined;
407
+ case "ZodArray": {
408
+ schema.type = "array";
409
+ schema.minItems = parsed.$checks?.minLength || undefined;
410
+ schema.maxItems = parsed.$checks?.maxLength || undefined;
411
+ schema.items = getSwaggerSchema(parsed.$inner);
412
+ break;
413
+ }
414
+ case "ZodTuple": {
415
+ schema.type = "array";
416
+ schema.items = parsed.$inner.map((t) => getSwaggerSchema(t)).filter((t) => !!t);
417
+ break;
418
+ }
419
+ case "ZodObject": {
420
+ schema.type = "object";
421
+ schema.properties = {};
422
+ schema.required = [];
423
+ if (zodType._def.unknownKeys === "passthrough") schema.additionalProperties = {};
424
+ for (const [key, val] of Object.entries(parsed.$inner)) {
425
+ const prop = getSwaggerSchema(val);
426
+ if (prop) {
427
+ schema.properties[key] = prop;
428
+ if (!val.$optional) schema.required.push(key);
429
+ }
430
+ }
431
+ break;
432
+ }
433
+ case "ZodPromise":
434
+ case "ZodRecord":
435
+ case "ZodMap":
436
+ case "ZodSet": {
437
+ schema.type = "object";
438
+ schema.properties = {};
439
+ schema.additionalProperties = parsed.$type === "ZodRecord" ? {} : undefined;
440
+ break;
441
+ }
442
+ case "ZodUnion":
443
+ case "ZodDiscriminatedUnion": {
444
+ schema.oneOf = parsed.$inner.map((t) => getSwaggerSchema(t)).filter((t) => !!t);
445
+ break;
446
+ }
447
+ case "ZodIntersection": {
448
+ schema.allOf = parsed.$inner.map((t) => getSwaggerSchema(t)).filter((t) => !!t);
449
+ break;
450
+ }
451
+ case "ZodLazy": return getSwaggerSchema(parsed.$get());
452
+ }
453
+ if (parsed.$nullable) schema.nullable = parsed.$nullable;
454
+ if (parsed.$ref._def.description) schema.description = parsed.$ref._def.description;
455
+ if (parsed.$checks) {
456
+ const checks = parsed.$checks;
457
+ if (parsed.$type === "ZodString") {
458
+ if (typeof checks.min === "number") schema.minLength = checks.min;
459
+ if (typeof checks.max === "number") schema.maxLength = checks.max;
460
+ } else {
461
+ if (typeof checks.min === "number") schema.minimum = checks.min;
462
+ if (typeof checks.max === "number") schema.maximum = checks.max;
463
+ }
464
+ }
465
+ if (!forParam && zodType.__type_ref) return { $ref: `#/components/schemas/${zodType.__type_ref.name}` };
466
+ return schema;
570
467
  }
571
468
  function myParseZod(schema) {
572
- return zodParser.parseZodType(schema);
469
+ return (0, zod_parser.parseZodType)(schema);
573
470
  }
574
471
  function getDefaultStatusCode(httpMethod) {
575
- const defaultStatusCodes = {
576
- GET: 200,
577
- PUT: 200,
578
- POST: 201,
579
- DELETE: 204,
580
- };
581
- return defaultStatusCodes[httpMethod.toUpperCase()] || 200;
472
+ const defaultStatusCodes = {
473
+ GET: 200,
474
+ PUT: 200,
475
+ POST: 201,
476
+ DELETE: 204
477
+ };
478
+ return defaultStatusCodes[httpMethod.toUpperCase()] || 200;
582
479
  }
583
480
  function getSwaggerSchemaFromSwaggerConfigType(type) {
584
- let schema;
585
- let zt;
586
- if (type instanceof zod.z.ZodType) {
587
- zt = type;
588
- }
589
- else if (typeof type === 'function') {
590
- zt = zod.getZodType({
591
- type,
592
- });
593
- }
594
- if (zt) {
595
- const parsed = myParseZod(zt);
596
- if (['ZodString', 'ZodNumber', 'ZodObject', 'ZodArray', 'ZodBoolean'].includes(parsed.$type)) {
597
- schema = getSwaggerSchema(parsed);
598
- }
599
- }
600
- else if (type.type || type.$ref) {
601
- schema = type;
602
- }
603
- return schema;
481
+ let schema;
482
+ let zt;
483
+ if (type instanceof __moostjs_zod.z.ZodType) zt = type;
484
+ else if (typeof type === "function") zt = (0, __moostjs_zod.getZodType)({ type });
485
+ if (zt) {
486
+ const parsed = myParseZod(zt);
487
+ if ([
488
+ "ZodString",
489
+ "ZodNumber",
490
+ "ZodObject",
491
+ "ZodArray",
492
+ "ZodBoolean"
493
+ ].includes(parsed.$type)) schema = getSwaggerSchema(parsed);
494
+ } else if (type.type || type.$ref) schema = type;
495
+ return schema;
604
496
  }
605
497
 
606
- exports.SwaggerController = class SwaggerController {
607
- constructor(opts = { title: 'Moost API' }) {
608
- this.opts = opts;
609
- this['assetPath'] = swaggerUiDist.getAbsoluteFSPath();
610
- }
611
- 'processCors'() {
612
- if (this.opts.cors) {
613
- const { enableCors } = eventHttp$1.useSetHeaders();
614
- enableCors(this.opts.cors === true ? undefined : this.opts.cors);
615
- }
616
- }
617
- 'serveIndex'(url, location, status) {
618
- this.processCors();
619
- if (!url.endsWith('index.html') && !url.endsWith('/')) {
620
- status.value = 302;
621
- location.value = Path.join(url, '/');
622
- return '';
623
- }
624
- return `<!DOCTYPE html>
498
+ //#endregion
499
+ //#region packages/swagger/src/swagger.controller.ts
500
+ function _define_property(obj, key, value) {
501
+ if (key in obj) Object.defineProperty(obj, key, {
502
+ value,
503
+ enumerable: true,
504
+ configurable: true,
505
+ writable: true
506
+ });
507
+ else obj[key] = value;
508
+ return obj;
509
+ }
510
+ function _ts_decorate(decorators, target, key, desc) {
511
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
512
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
513
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
514
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
515
+ }
516
+ function _ts_metadata(k, v) {
517
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
518
+ }
519
+ function _ts_param(paramIndex, decorator) {
520
+ return function(target, key) {
521
+ decorator(target, key, paramIndex);
522
+ };
523
+ }
524
+ var SwaggerController = class {
525
+ "processCors"() {
526
+ if (this.opts.cors) {
527
+ const { enableCors } = (0, __wooksjs_event_http.useSetHeaders)();
528
+ enableCors(this.opts.cors === true ? undefined : this.opts.cors);
529
+ }
530
+ }
531
+ "serveIndex"(url, location, status) {
532
+ this.processCors();
533
+ if (!url.endsWith("index.html") && !url.endsWith("/")) {
534
+ status.value = 302;
535
+ location.value = path.default.join(url, "/");
536
+ return "";
537
+ }
538
+ return `<!DOCTYPE html>
625
539
  <html lang="en">
626
540
  <head>
627
541
  <meta charset="UTF-8">
@@ -639,10 +553,10 @@ exports.SwaggerController = class SwaggerController {
639
553
  <script src="./swagger-initializer.js" charset="UTF-8"> </script>
640
554
  </body>
641
555
  </html>`;
642
- }
643
- 'swagger-initializer.js'() {
644
- this.processCors();
645
- return `window.onload = function() {
556
+ }
557
+ "swagger-initializer.js"() {
558
+ this.processCors();
559
+ return `window.onload = function() {
646
560
  window.ui = SwaggerUIBundle({
647
561
  url: "./spec.json",
648
562
  dom_id: '#swagger-ui',
@@ -657,79 +571,98 @@ exports.SwaggerController = class SwaggerController {
657
571
  layout: "BaseLayout"
658
572
  });
659
573
  };`;
660
- }
661
- async 'spec.json'() {
662
- this.processCors();
663
- const logger = moost.useEventLogger('@moostjs/zod');
664
- if (!this.spec) {
665
- const { instantiate } = moost.useControllerContext();
666
- const moost$1 = await instantiate(moost.Moost);
667
- this.spec = mapToSwaggerSpec(moost$1.getControllersOverview(), this.opts, logger);
668
- }
669
- return this.spec;
670
- }
671
- 'files'(url) {
672
- this.processCors();
673
- return this.serve(url.split('/').pop());
674
- }
675
- 'serve'(path) {
676
- return httpStatic.serveFile(path, {
677
- baseDir: this.assetPath,
678
- cacheControl: {
679
- public: true,
680
- maxAge: '1w',
681
- },
682
- });
683
- }
574
+ }
575
+ async "spec.json"() {
576
+ this.processCors();
577
+ const logger = (0, moost.useEventLogger)("@moostjs/zod");
578
+ if (!this.spec) {
579
+ const { instantiate } = (0, moost.useControllerContext)();
580
+ const moost$1 = await instantiate(moost.Moost);
581
+ this.spec = mapToSwaggerSpec(moost$1.getControllersOverview(), this.opts, logger);
582
+ }
583
+ return this.spec;
584
+ }
585
+ "files"(url) {
586
+ this.processCors();
587
+ return this.serve(url.split("/").pop());
588
+ }
589
+ "serve"(path$1) {
590
+ return (0, __wooksjs_http_static.serveFile)(path$1, {
591
+ baseDir: this.assetPath,
592
+ cacheControl: {
593
+ public: true,
594
+ maxAge: "1w"
595
+ }
596
+ });
597
+ }
598
+ constructor(opts = { title: "Moost API" }) {
599
+ _define_property(this, "opts", void 0);
600
+ _define_property(this, "assetPath", void 0);
601
+ _define_property(this, "spec", void 0);
602
+ this.opts = opts;
603
+ this["assetPath"] = (0, swagger_ui_dist.getAbsoluteFSPath)();
604
+ }
684
605
  };
685
- __decorate([
686
- eventHttp.Get(''),
687
- eventHttp.Get('//'),
688
- eventHttp.Get('index.html'),
689
- eventHttp.SetHeader('content-type', 'text/html'),
690
- __param(0, eventHttp.Url()),
691
- __param(1, eventHttp.HeaderHook('location')),
692
- __param(2, eventHttp.StatusHook()),
693
- __metadata("design:type", Function),
694
- __metadata("design:paramtypes", [String, Object, Object]),
695
- __metadata("design:returntype", void 0)
696
- ], exports.SwaggerController.prototype, "serveIndex", null);
697
- __decorate([
698
- eventHttp.Get(),
699
- eventHttp.SetHeader('content-type', 'application/javascript'),
700
- __metadata("design:type", Function),
701
- __metadata("design:paramtypes", []),
702
- __metadata("design:returntype", void 0)
703
- ], exports.SwaggerController.prototype, "swagger-initializer.js", null);
704
- __decorate([
705
- eventHttp.Get(),
706
- __metadata("design:type", Function),
707
- __metadata("design:paramtypes", []),
708
- __metadata("design:returntype", Promise)
709
- ], exports.SwaggerController.prototype, "spec.json", null);
710
- __decorate([
711
- eventHttp.Get('swagger-ui-bundle.*(js|js\\.map)'),
712
- eventHttp.Get('swagger-ui-standalone-preset.*(js|js\\.map)'),
713
- eventHttp.Get('swagger-ui.*(css|css\\.map)'),
714
- eventHttp.Get('index.*(css|css\\.map)'),
715
- __param(0, eventHttp.Url()),
716
- __metadata("design:type", Function),
717
- __metadata("design:paramtypes", [String]),
718
- __metadata("design:returntype", void 0)
719
- ], exports.SwaggerController.prototype, "files", null);
720
- exports.SwaggerController = __decorate([
721
- SwaggerExclude(),
722
- zod.ZodSkip(),
723
- moost.Controller('api-docs'),
724
- __param(0, moost.Const({ title: 'Moost API' })),
725
- __metadata("design:paramtypes", [Object])
726
- ], exports.SwaggerController);
606
+ _ts_decorate([
607
+ (0, __moostjs_event_http.Get)(""),
608
+ (0, __moostjs_event_http.Get)("//"),
609
+ (0, __moostjs_event_http.Get)("index.html"),
610
+ (0, __moostjs_event_http.SetHeader)("content-type", "text/html"),
611
+ _ts_param(0, (0, __moostjs_event_http.Url)()),
612
+ _ts_param(1, (0, __moostjs_event_http.HeaderHook)("location")),
613
+ _ts_param(2, (0, __moostjs_event_http.StatusHook)()),
614
+ _ts_metadata("design:type", Function),
615
+ _ts_metadata("design:paramtypes", [
616
+ String,
617
+ typeof __wooksjs_event_http.THeaderHook === "undefined" ? Object : __wooksjs_event_http.THeaderHook,
618
+ typeof TStatusHook === "undefined" ? Object : TStatusHook
619
+ ]),
620
+ _ts_metadata("design:returntype", void 0)
621
+ ], SwaggerController.prototype, "serveIndex", null);
622
+ _ts_decorate([
623
+ (0, __moostjs_event_http.Get)(),
624
+ (0, __moostjs_event_http.SetHeader)("content-type", "application/javascript"),
625
+ _ts_metadata("design:type", Function),
626
+ _ts_metadata("design:paramtypes", []),
627
+ _ts_metadata("design:returntype", void 0)
628
+ ], SwaggerController.prototype, "swagger-initializer.js", null);
629
+ _ts_decorate([
630
+ (0, __moostjs_event_http.Get)(),
631
+ _ts_metadata("design:type", Function),
632
+ _ts_metadata("design:paramtypes", []),
633
+ _ts_metadata("design:returntype", Promise)
634
+ ], SwaggerController.prototype, "spec.json", null);
635
+ _ts_decorate([
636
+ (0, __moostjs_event_http.Get)("swagger-ui-bundle.*(js|js\\.map)"),
637
+ (0, __moostjs_event_http.Get)("swagger-ui-standalone-preset.*(js|js\\.map)"),
638
+ (0, __moostjs_event_http.Get)("swagger-ui.*(css|css\\.map)"),
639
+ (0, __moostjs_event_http.Get)("index.*(css|css\\.map)"),
640
+ _ts_param(0, (0, __moostjs_event_http.Url)()),
641
+ _ts_metadata("design:type", Function),
642
+ _ts_metadata("design:paramtypes", [String]),
643
+ _ts_metadata("design:returntype", void 0)
644
+ ], SwaggerController.prototype, "files", null);
645
+ SwaggerController = _ts_decorate([
646
+ SwaggerExclude(),
647
+ (0, __moostjs_zod.ZodSkip)(),
648
+ (0, moost.Controller)("api-docs"),
649
+ _ts_param(0, (0, moost.Const)({ title: "Moost API" })),
650
+ _ts_metadata("design:type", Function),
651
+ _ts_metadata("design:paramtypes", [typeof TSwaggerOptions === "undefined" ? Object : TSwaggerOptions])
652
+ ], SwaggerController);
727
653
 
728
- exports.SwaggerDescription = SwaggerDescription;
729
- exports.SwaggerExample = SwaggerExample;
730
- exports.SwaggerExclude = SwaggerExclude;
731
- exports.SwaggerParam = SwaggerParam;
732
- exports.SwaggerRequestBody = SwaggerRequestBody;
733
- exports.SwaggerResponse = SwaggerResponse;
734
- exports.SwaggerTag = SwaggerTag;
735
- exports.getSwaggerMate = getSwaggerMate;
654
+ //#endregion
655
+ Object.defineProperty(exports, 'SwaggerController', {
656
+ enumerable: true,
657
+ get: function () {
658
+ return SwaggerController;
659
+ }
660
+ });
661
+ exports.SwaggerDescription = SwaggerDescription
662
+ exports.SwaggerExample = SwaggerExample
663
+ exports.SwaggerExclude = SwaggerExclude
664
+ exports.SwaggerParam = SwaggerParam
665
+ exports.SwaggerRequestBody = SwaggerRequestBody
666
+ exports.SwaggerResponse = SwaggerResponse
667
+ exports.SwaggerTag = SwaggerTag
668
+ exports.getSwaggerMate = getSwaggerMate