@nestia/sdk 2.0.0-dev.20230831-4 → 2.0.0-dev.20230991

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 (56) hide show
  1. package/assets/bundle/api/utils/NestiaSimulator.ts +1 -23
  2. package/lib/NestiaSdkApplication.js +1 -1
  3. package/lib/NestiaSdkApplication.js.map +1 -1
  4. package/lib/analyses/ControllerAnalyzer.js +11 -5
  5. package/lib/analyses/ControllerAnalyzer.js.map +1 -1
  6. package/lib/analyses/ExceptionAnalyzer.js +7 -2
  7. package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
  8. package/lib/analyses/ImportAnalyzer.js +1 -1
  9. package/lib/analyses/ImportAnalyzer.js.map +1 -1
  10. package/lib/analyses/ReflectAnalyzer.js +0 -10
  11. package/lib/analyses/ReflectAnalyzer.js.map +1 -1
  12. package/lib/executable/internal/NestiaSdkConfig.js +37 -46
  13. package/lib/executable/internal/NestiaSdkConfig.js.map +1 -1
  14. package/lib/generates/SwaggerGenerator.d.ts +10 -0
  15. package/lib/generates/SwaggerGenerator.js +29 -497
  16. package/lib/generates/SwaggerGenerator.js.map +1 -1
  17. package/lib/generates/internal/E2eFileProgrammer.js +5 -44
  18. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  19. package/lib/generates/internal/SdkFunctionProgrammer.js +12 -10
  20. package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
  21. package/lib/generates/internal/SdkSimulationProgrammer.js +4 -4
  22. package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
  23. package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +19 -0
  24. package/lib/generates/internal/SwaggerSchemaGenerator.js +301 -0
  25. package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -0
  26. package/lib/generates/internal/SwaggerSchemaValidator.d.ts +7 -0
  27. package/lib/generates/internal/SwaggerSchemaValidator.js +200 -0
  28. package/lib/generates/internal/SwaggerSchemaValidator.js.map +1 -0
  29. package/lib/structures/IController.d.ts +0 -4
  30. package/lib/structures/IRoute.d.ts +6 -3
  31. package/lib/structures/ISwaggerError.d.ts +6 -0
  32. package/lib/structures/ISwaggerError.js +3 -0
  33. package/lib/structures/ISwaggerError.js.map +1 -0
  34. package/lib/structures/ISwaggerRoute.d.ts +2 -1
  35. package/lib/structures/ISwaggerSchemaTuple.d.ts +6 -0
  36. package/lib/structures/ISwaggerSchemaTuple.js +3 -0
  37. package/lib/structures/ISwaggerSchemaTuple.js.map +1 -0
  38. package/lib/structures/ITypeTuple.d.ts +1 -1
  39. package/package.json +5 -5
  40. package/src/NestiaSdkApplication.ts +1 -1
  41. package/src/analyses/ControllerAnalyzer.ts +13 -4
  42. package/src/analyses/ExceptionAnalyzer.ts +3 -2
  43. package/src/analyses/ImportAnalyzer.ts +1 -1
  44. package/src/analyses/ReflectAnalyzer.ts +0 -10
  45. package/src/generates/SwaggerGenerator.ts +86 -478
  46. package/src/generates/internal/E2eFileProgrammer.ts +7 -49
  47. package/src/generates/internal/SdkFunctionProgrammer.ts +13 -11
  48. package/src/generates/internal/SdkSimulationProgrammer.ts +5 -5
  49. package/src/generates/internal/SwaggerSchemaGenerator.ts +433 -0
  50. package/src/generates/internal/SwaggerSchemaValidator.ts +222 -0
  51. package/src/structures/IController.ts +0 -4
  52. package/src/structures/IRoute.ts +6 -3
  53. package/src/structures/ISwaggerError.ts +8 -0
  54. package/src/structures/ISwaggerRoute.ts +2 -1
  55. package/src/structures/ISwaggerSchemaTuple.ts +7 -0
  56. package/src/structures/ITypeTuple.ts +1 -1
@@ -16,13 +16,12 @@ exports.SwaggerGenerator = void 0;
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const Singleton_1 = require("tstl/thread/Singleton");
19
- const typescript_1 = __importDefault(require("typescript"));
20
19
  const typia_1 = __importDefault(require("typia"));
21
20
  const MetadataCollection_1 = require("typia/lib/factories/MetadataCollection");
22
- const MetadataFactory_1 = require("typia/lib/factories/MetadataFactory");
23
- const ApplicationProgrammer_1 = require("typia/lib/programmers/ApplicationProgrammer");
21
+ const JsonApplicationProgrammer_1 = require("typia/lib/programmers/json/JsonApplicationProgrammer");
24
22
  const FileRetriever_1 = require("../utils/FileRetriever");
25
23
  const MapUtil_1 = require("../utils/MapUtil");
24
+ const SwaggerSchemaGenerator_1 = require("./internal/SwaggerSchemaGenerator");
26
25
  var SwaggerGenerator;
27
26
  (function (SwaggerGenerator) {
28
27
  SwaggerGenerator.generate = (checker) => (config) => (routeList) => __awaiter(this, void 0, void 0, function* () {
@@ -47,25 +46,32 @@ var SwaggerGenerator;
47
46
  replace: MetadataCollection_1.MetadataCollection.replace,
48
47
  });
49
48
  // CONSTRUCT SWAGGER DOCUMENTS
50
- const tupleList = [];
49
+ const errors = [];
50
+ const tuples = [];
51
51
  const swagger = yield initialize(config);
52
52
  const pathDict = new Map();
53
53
  for (const route of routeList) {
54
54
  if (route.tags.find((tag) => tag.name === "internal"))
55
55
  continue;
56
56
  const path = MapUtil_1.MapUtil.take(pathDict, get_path(route.path, route.parameters), () => ({}));
57
- path[route.method.toLowerCase()] = generate_route(config, checker, collection, tupleList, route);
57
+ path[route.method.toLowerCase()] = generate_route({
58
+ config,
59
+ checker,
60
+ collection,
61
+ tuples,
62
+ errors,
63
+ })(route);
58
64
  }
59
65
  swagger.paths = {};
60
66
  for (const [path, routes] of pathDict) {
61
67
  swagger.paths[path] = routes;
62
68
  }
63
69
  // FILL JSON-SCHEMAS
64
- const application = ApplicationProgrammer_1.ApplicationProgrammer.write({
70
+ const application = JsonApplicationProgrammer_1.JsonApplicationProgrammer.write({
65
71
  purpose: "swagger",
66
- })(tupleList.map(({ metadata }) => metadata));
72
+ })(tuples.map(({ metadata }) => metadata));
67
73
  swagger.components = Object.assign(Object.assign({}, ((_a = swagger.components) !== null && _a !== void 0 ? _a : {})), ((_b = application.components) !== null && _b !== void 0 ? _b : {}));
68
- tupleList.forEach(({ schema }, index) => {
74
+ tuples.forEach(({ schema }, index) => {
69
75
  Object.assign(schema, application.schemas[index]);
70
76
  });
71
77
  // CONFIGURE SECURITY
@@ -125,15 +131,13 @@ var SwaggerGenerator;
125
131
  const content = yield fs_1.default.promises.readFile(location, "utf8");
126
132
  const data = (input => { const assert = input => {
127
133
  const __is = input => {
128
- const $is_url = typia_1.default.assertParse.is_url;
129
134
  const $io0 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.version || "string" === typeof input.version) && (undefined === input.description || "string" === typeof input.description) && (null !== input.license && (undefined === input.license || "string" === typeof input.license || "object" === typeof input.license && null !== input.license && $io1(input.license)));
130
- const $io1 = input => "string" === typeof input.type && ("string" === typeof input.url && $is_url(input.url));
135
+ const $io1 = input => "string" === typeof input.type && ("string" === typeof input.url && /^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/.test(input.url));
131
136
  return "object" === typeof input && null !== input && false === Array.isArray(input) && $io0(input);
132
137
  };
133
138
  if (false === __is(input))
134
139
  ((input, _path, _exceptionable = true) => {
135
- const $guard = typia_1.default.assertParse.guard;
136
- const $is_url = typia_1.default.assertParse.is_url;
140
+ const $guard = typia_1.default.json.assertParse.guard;
137
141
  const $ao0 = (input, _path, _exceptionable = true) => (undefined === input.name || "string" === typeof input.name || $guard(_exceptionable, {
138
142
  path: _path + ".name",
139
143
  expected: "(string | undefined)",
@@ -163,13 +167,13 @@ var SwaggerGenerator;
163
167
  path: _path + ".type",
164
168
  expected: "string",
165
169
  value: input.type
166
- })) && ("string" === typeof input.url && ($is_url(input.url) || $guard(_exceptionable, {
170
+ })) && ("string" === typeof input.url && (/^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/.test(input.url) || $guard(_exceptionable, {
167
171
  path: _path + ".url",
168
- expected: "string (@format url)",
172
+ expected: "string & Format<url>",
169
173
  value: input.url
170
174
  })) || $guard(_exceptionable, {
171
175
  path: _path + ".url",
172
- expected: "string",
176
+ expected: "(string & Format<url>)",
173
177
  value: input.url
174
178
  }));
175
179
  return ("object" === typeof input && null !== input && false === Array.isArray(input) || $guard(true, {
@@ -223,14 +227,15 @@ var SwaggerGenerator;
223
227
  path = path.replace(`:${param.field}`, `{${param.field}}`);
224
228
  return path;
225
229
  }
226
- function generate_route(config, checker, collection, tupleList, route) {
230
+ const generate_route = (props) => (route) => {
227
231
  var _a;
228
- const bodyParam = route.parameters.find((param) => param.category === "body");
232
+ const body = route.parameters.find((param) => param.category === "body");
229
233
  const getTagTexts = (name) => route.tags
230
234
  .filter((tag) => tag.name === name &&
231
235
  tag.text &&
232
236
  tag.text.find((elem) => elem.kind === "text" && elem.text.length) !== undefined)
233
- .map((tag) => tag.text.find((elem) => elem.kind === "text").text);
237
+ .map((tag) => tag.text.find((elem) => elem.kind === "text")
238
+ .text);
234
239
  const description = ((_a = route.description) === null || _a === void 0 ? void 0 : _a.length)
235
240
  ? route.description
236
241
  : undefined;
@@ -250,14 +255,14 @@ var SwaggerGenerator;
250
255
  return {
251
256
  deprecated: deprecated ? true : undefined,
252
257
  tags: getTagTexts("tag"),
258
+ operationId: route.operationId,
253
259
  parameters: route.parameters
254
260
  .filter((param) => param.category !== "body")
255
- .map((param) => generate_parameter(config, checker, collection, tupleList, route, param))
256
- .flat(),
257
- requestBody: bodyParam
258
- ? generate_request_body(checker, collection, tupleList, route, bodyParam)
261
+ .map((param) => SwaggerSchemaGenerator_1.SwaggerSchemaGenerator.parameter(props)(route)(param)),
262
+ requestBody: body
263
+ ? SwaggerSchemaGenerator_1.SwaggerSchemaGenerator.body(props)(route)(body)
259
264
  : undefined,
260
- responses: generate_response_body(checker, collection, tupleList, route),
265
+ responses: SwaggerSchemaGenerator_1.SwaggerSchemaGenerator.response(props)(route),
261
266
  summary,
262
267
  description,
263
268
  security: route.security.length ? route.security : undefined,
@@ -270,7 +275,7 @@ var SwaggerGenerator;
270
275
  "x-nestia-jsDocTags": route.tags,
271
276
  "x-nestia-method": route.method,
272
277
  };
273
- }
278
+ };
274
279
  function fill_security(security, swagger) {
275
280
  swagger.components.securitySchemes = {};
276
281
  for (const [key, value] of Object.entries(security))
@@ -282,478 +287,5 @@ var SwaggerGenerator;
282
287
  return Object.assign(Object.assign({}, input), { in: (_a = input.in) !== null && _a !== void 0 ? _a : "header", name: (_b = input.name) !== null && _b !== void 0 ? _b : "Authorization" });
283
288
  return input;
284
289
  }
285
- /* ---------------------------------------------------------
286
- REQUEST & RESPONSE
287
- --------------------------------------------------------- */
288
- function generate_parameter(config, checker, collection, tupleList, route, parameter) {
289
- var _a, _b, _c;
290
- const schema = generate_schema(checker, collection, tupleList, parameter.type.type);
291
- if (schema === null)
292
- throw new Error(`Error on NestiaApplication.swagger(): invalid parameter type on ${route.symbol}#${parameter.name}`);
293
- else if (parameter.custom &&
294
- parameter.category === "param" &&
295
- !!parameter.meta &&
296
- (parameter.meta.type === "date" ||
297
- parameter.meta.type === "uuid") &&
298
- schema !== null) {
299
- const string = schema;
300
- string.format = parameter.meta.type;
301
- }
302
- else if (config.decompose === true &&
303
- parameter.category === "query") {
304
- const metadata = MetadataFactory_1.MetadataFactory.analyze(checker)({
305
- resolve: true,
306
- constant: true,
307
- absorb: true,
308
- validate: (meta) => {
309
- if (meta.atomics.find((str) => str === "bigint"))
310
- throw new Error(NO_BIGIT);
311
- },
312
- })(collection)(parameter.type.type);
313
- if (metadata.size() === 1 &&
314
- metadata.objects.length === 1 &&
315
- metadata.objects[0].properties.every((prop) => prop.key.size() &&
316
- prop.key.constants.length === 1 &&
317
- prop.key.constants[0].type === "string" &&
318
- route.parameters.every((param) => param.name !== prop.key.constants[0].values[0]))) {
319
- const app = ApplicationProgrammer_1.ApplicationProgrammer.write({
320
- purpose: "swagger",
321
- })([metadata]);
322
- const top = Object.values((_a = app.components.schemas) !== null && _a !== void 0 ? _a : {})[0];
323
- if ((input => {
324
- const $join = typia_1.default.is.join;
325
- const $io0 = input => (undefined === input.$id || "string" === typeof input.$id) && "object" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && ("object" === typeof input.properties && null !== input.properties && false === Array.isArray(input.properties) && $io1(input.properties)) && (undefined === input.patternProperties || "object" === typeof input.patternProperties && null !== input.patternProperties && false === Array.isArray(input.patternProperties) && $io1(input.patternProperties)) && (undefined === input.additionalProperties || "object" === typeof input.additionalProperties && null !== input.additionalProperties && false === Array.isArray(input.additionalProperties) && $iu1(input.additionalProperties)) && (undefined === input.required || Array.isArray(input.required) && input.required.every(elem => "string" === typeof elem)) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-patternProperties"] || "object" === typeof input["x-typia-patternProperties"] && null !== input["x-typia-patternProperties"] && false === Array.isArray(input["x-typia-patternProperties"]) && $io1(input["x-typia-patternProperties"])) && (undefined === input["x-typia-additionalProperties"] || "object" === typeof input["x-typia-additionalProperties"] && null !== input["x-typia-additionalProperties"] && false === Array.isArray(input["x-typia-additionalProperties"]) && $iu1(input["x-typia-additionalProperties"]));
326
- const $io1 = input => Object.keys(input).every(key => {
327
- const value = input[key];
328
- if (undefined === value)
329
- return true;
330
- if (RegExp(/(.*)/).test(key))
331
- return "object" === typeof value && null !== value && false === Array.isArray(value) && $iu1(value);
332
- return true;
333
- });
334
- const $io2 = input => Array.isArray(input["enum"]) && input["enum"].every(elem => "boolean" === typeof elem) && (undefined === input["default"] || "boolean" === typeof input["default"]) && "boolean" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
335
- const $io3 = input => "type" === input.kind && ("int" === input.value || "uint" === input.value || "int32" === input.value || "uint32" === input.value || "int64" === input.value || "uint64" === input.value || "float" === input.value);
336
- const $io4 = input => "minimum" === input.kind && "number" === typeof input.value;
337
- const $io5 = input => "maximum" === input.kind && "number" === typeof input.value;
338
- const $io6 = input => "exclusiveMinimum" === input.kind && "number" === typeof input.value;
339
- const $io7 = input => "exclusiveMaximum" === input.kind && "number" === typeof input.value;
340
- const $io8 = input => "multipleOf" === input.kind && "number" === typeof input.value;
341
- const $io9 = input => "step" === input.kind && "number" === typeof input.value;
342
- const $io10 = input => "format" === input.kind && ("uuid" === input.value || "date" === input.value || "url" === input.value || "email" === input.value || "ipv4" === input.value || "ipv6" === input.value || "datetime" === input.value);
343
- const $io11 = input => "pattern" === input.kind && "string" === typeof input.value;
344
- const $io12 = input => "length" === input.kind && "number" === typeof input.value;
345
- const $io13 = input => "minLength" === input.kind && "number" === typeof input.value;
346
- const $io14 = input => "maxLength" === input.kind && "number" === typeof input.value;
347
- const $io15 = input => "items" === input.kind && "number" === typeof input.value;
348
- const $io16 = input => "minItems" === input.kind && "number" === typeof input.value;
349
- const $io17 = input => "maxItems" === input.kind && "number" === typeof input.value;
350
- const $io18 = input => "string" === typeof input.name && (undefined === input.text || Array.isArray(input.text) && input.text.every(elem => "object" === typeof elem && null !== elem && $io19(elem)));
351
- const $io19 = input => "string" === typeof input.text && "string" === typeof input.kind;
352
- const $io20 = input => Array.isArray(input["enum"]) && input["enum"].every(elem => "number" === typeof elem) && (undefined === input["default"] || "number" === typeof input["default"]) && "number" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
353
- const $io21 = input => Array.isArray(input["enum"]) && input["enum"].every(elem => "string" === typeof elem) && (undefined === input["default"] || "string" === typeof input["default"]) && "string" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
354
- const $io22 = input => (undefined === input["default"] || "boolean" === typeof input["default"]) && "boolean" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
355
- const $io23 = input => (undefined === input.minimum || "number" === typeof input.minimum && Math.floor(input.minimum) === input.minimum && (-2147483648 <= input.minimum && input.minimum <= 2147483647)) && (undefined === input.maximum || "number" === typeof input.maximum && Math.floor(input.maximum) === input.maximum && (-2147483648 <= input.maximum && input.maximum <= 2147483647)) && (undefined === input.exclusiveMinimum || "boolean" === typeof input.exclusiveMinimum) && (undefined === input.exclusiveMaximum || "boolean" === typeof input.exclusiveMaximum) && (undefined === input.multipleOf || "number" === typeof input.multipleOf && Math.floor(input.multipleOf) === input.multipleOf && (-2147483648 <= input.multipleOf && input.multipleOf <= 2147483647)) && (undefined === input["default"] || "number" === typeof input["default"]) && "integer" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
356
- const $io24 = input => (undefined === input.minimum || "number" === typeof input.minimum) && (undefined === input.maximum || "number" === typeof input.maximum) && (undefined === input.exclusiveMinimum || "boolean" === typeof input.exclusiveMinimum) && (undefined === input.exclusiveMaximum || "boolean" === typeof input.exclusiveMaximum) && (undefined === input.multipleOf || "number" === typeof input.multipleOf) && (undefined === input["default"] || "number" === typeof input["default"]) && "number" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
357
- const $io25 = input => (undefined === input.minLength || "number" === typeof input.minLength && Math.floor(input.minLength) === input.minLength && 0 <= input.minLength && input.minLength <= 4294967295) && (undefined === input.maxLength || "number" === typeof input.maxLength && Math.floor(input.maxLength) === input.maxLength && 0 <= input.maxLength && input.maxLength <= 4294967295) && (undefined === input.pattern || "string" === typeof input.pattern) && (undefined === input.format || "string" === typeof input.format) && (undefined === input["default"] || "string" === typeof input["default"]) && "string" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
358
- const $io26 = input => "object" === typeof input.items && null !== input.items && false === Array.isArray(input.items) && $iu1(input.items) && (undefined === input.minItems || "number" === typeof input.minItems && Math.floor(input.minItems) === input.minItems && 0 <= input.minItems && input.minItems <= 4294967295) && (undefined === input.maxItems || "number" === typeof input.maxItems && Math.floor(input.maxItems) === input.maxItems && 0 <= input.maxItems && input.maxItems <= 4294967295) && (undefined === input["x-typia-tuple"] || "object" === typeof input["x-typia-tuple"] && null !== input["x-typia-tuple"] && $io27(input["x-typia-tuple"])) && "array" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
359
- const $io27 = input => Array.isArray(input.items) && input.items.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $iu1(elem)) && ("number" === typeof input.minItems && Math.floor(input.minItems) === input.minItems && 0 <= input.minItems && input.minItems <= 4294967295) && (undefined === input.maxItems || "number" === typeof input.maxItems && Math.floor(input.maxItems) === input.maxItems && 0 <= input.maxItems && input.maxItems <= 4294967295) && "array" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
360
- const $io28 = input => Array.isArray(input.oneOf) && input.oneOf.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $iu1(elem)) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
361
- const $io29 = input => "string" === typeof input.$ref && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
362
- const $io30 = input => "null" === input.type && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
363
- const $io31 = input => null !== input.type && undefined === input.type && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
364
- const $iu0 = input => (() => {
365
- if ("maxItems" === input.kind)
366
- return $io17(input);
367
- if ("minItems" === input.kind)
368
- return $io16(input);
369
- if ("items" === input.kind)
370
- return $io15(input);
371
- if ("maxLength" === input.kind)
372
- return $io14(input);
373
- if ("minLength" === input.kind)
374
- return $io13(input);
375
- if ("length" === input.kind)
376
- return $io12(input);
377
- if ("pattern" === input.kind)
378
- return $io11(input);
379
- if ("format" === input.kind)
380
- return $io10(input);
381
- if ("step" === input.kind)
382
- return $io9(input);
383
- if ("multipleOf" === input.kind)
384
- return $io8(input);
385
- if ("exclusiveMaximum" === input.kind)
386
- return $io7(input);
387
- if ("exclusiveMinimum" === input.kind)
388
- return $io6(input);
389
- if ("maximum" === input.kind)
390
- return $io5(input);
391
- if ("minimum" === input.kind)
392
- return $io4(input);
393
- if ("type" === input.kind)
394
- return $io3(input);
395
- return false;
396
- })();
397
- const $iu1 = input => (() => {
398
- if ("integer" === input.type)
399
- return $io23(input);
400
- if ("object" === typeof input.items && null !== input.items && false === Array.isArray(input.items) && $iu1(input.items))
401
- return $io26(input);
402
- if (Array.isArray(input.items) && input.items.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $iu1(elem)))
403
- return $io27(input);
404
- if (undefined !== input.oneOf)
405
- return $io28(input);
406
- if (undefined !== input.$ref)
407
- return $io29(input);
408
- if ("null" === input.type)
409
- return $io30(input);
410
- return (() => {
411
- if ($io21(input))
412
- return $io21(input);
413
- if ($io20(input))
414
- return $io20(input);
415
- if ($io2(input))
416
- return $io2(input);
417
- if ($io22(input))
418
- return $io22(input);
419
- if ($io24(input))
420
- return $io24(input);
421
- if ($io25(input))
422
- return $io25(input);
423
- if ($io31(input))
424
- return $io31(input);
425
- return false;
426
- })();
427
- })();
428
- return "object" === typeof input && null !== input && $io0(input);
429
- })(top))
430
- return Object.entries(top.properties).map(([key, value]) => {
431
- var _a, _b;
432
- return ({
433
- name: key,
434
- in: "query",
435
- schema: value,
436
- required: (_b = (_a = top.required) === null || _a === void 0 ? void 0 : _a.includes(key)) !== null && _b !== void 0 ? _b : false,
437
- description: value.description,
438
- });
439
- });
440
- }
441
- }
442
- else if (config.decompose === true &&
443
- parameter.category === "headers") {
444
- const metadata = MetadataFactory_1.MetadataFactory.analyze(checker)({
445
- resolve: true,
446
- constant: true,
447
- absorb: true,
448
- validate: (meta) => {
449
- if (meta.atomics.find((str) => str === "bigint"))
450
- throw new Error(NO_BIGIT);
451
- },
452
- })(collection)(parameter.type.type);
453
- if (metadata.size() === 1 &&
454
- metadata.objects.length === 1 &&
455
- metadata.objects[0].properties.every((prop) => prop.key.size() &&
456
- prop.key.constants.length === 1 &&
457
- prop.key.constants[0].type === "string" &&
458
- route.parameters.every((param) => param.name !== prop.key.constants[0].values[0]))) {
459
- const app = ApplicationProgrammer_1.ApplicationProgrammer.write({
460
- purpose: "swagger",
461
- })([metadata]);
462
- const top = Object.values((_b = app.components.schemas) !== null && _b !== void 0 ? _b : {})[0];
463
- if ((input => {
464
- const $join = typia_1.default.is.join;
465
- const $io0 = input => (undefined === input.$id || "string" === typeof input.$id) && "object" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && ("object" === typeof input.properties && null !== input.properties && false === Array.isArray(input.properties) && $io1(input.properties)) && (undefined === input.patternProperties || "object" === typeof input.patternProperties && null !== input.patternProperties && false === Array.isArray(input.patternProperties) && $io1(input.patternProperties)) && (undefined === input.additionalProperties || "object" === typeof input.additionalProperties && null !== input.additionalProperties && false === Array.isArray(input.additionalProperties) && $iu1(input.additionalProperties)) && (undefined === input.required || Array.isArray(input.required) && input.required.every(elem => "string" === typeof elem)) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-patternProperties"] || "object" === typeof input["x-typia-patternProperties"] && null !== input["x-typia-patternProperties"] && false === Array.isArray(input["x-typia-patternProperties"]) && $io1(input["x-typia-patternProperties"])) && (undefined === input["x-typia-additionalProperties"] || "object" === typeof input["x-typia-additionalProperties"] && null !== input["x-typia-additionalProperties"] && false === Array.isArray(input["x-typia-additionalProperties"]) && $iu1(input["x-typia-additionalProperties"]));
466
- const $io1 = input => Object.keys(input).every(key => {
467
- const value = input[key];
468
- if (undefined === value)
469
- return true;
470
- if (RegExp(/(.*)/).test(key))
471
- return "object" === typeof value && null !== value && false === Array.isArray(value) && $iu1(value);
472
- return true;
473
- });
474
- const $io2 = input => Array.isArray(input["enum"]) && input["enum"].every(elem => "boolean" === typeof elem) && (undefined === input["default"] || "boolean" === typeof input["default"]) && "boolean" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
475
- const $io3 = input => "type" === input.kind && ("int" === input.value || "uint" === input.value || "int32" === input.value || "uint32" === input.value || "int64" === input.value || "uint64" === input.value || "float" === input.value);
476
- const $io4 = input => "minimum" === input.kind && "number" === typeof input.value;
477
- const $io5 = input => "maximum" === input.kind && "number" === typeof input.value;
478
- const $io6 = input => "exclusiveMinimum" === input.kind && "number" === typeof input.value;
479
- const $io7 = input => "exclusiveMaximum" === input.kind && "number" === typeof input.value;
480
- const $io8 = input => "multipleOf" === input.kind && "number" === typeof input.value;
481
- const $io9 = input => "step" === input.kind && "number" === typeof input.value;
482
- const $io10 = input => "format" === input.kind && ("uuid" === input.value || "date" === input.value || "url" === input.value || "email" === input.value || "ipv4" === input.value || "ipv6" === input.value || "datetime" === input.value);
483
- const $io11 = input => "pattern" === input.kind && "string" === typeof input.value;
484
- const $io12 = input => "length" === input.kind && "number" === typeof input.value;
485
- const $io13 = input => "minLength" === input.kind && "number" === typeof input.value;
486
- const $io14 = input => "maxLength" === input.kind && "number" === typeof input.value;
487
- const $io15 = input => "items" === input.kind && "number" === typeof input.value;
488
- const $io16 = input => "minItems" === input.kind && "number" === typeof input.value;
489
- const $io17 = input => "maxItems" === input.kind && "number" === typeof input.value;
490
- const $io18 = input => "string" === typeof input.name && (undefined === input.text || Array.isArray(input.text) && input.text.every(elem => "object" === typeof elem && null !== elem && $io19(elem)));
491
- const $io19 = input => "string" === typeof input.text && "string" === typeof input.kind;
492
- const $io20 = input => Array.isArray(input["enum"]) && input["enum"].every(elem => "number" === typeof elem) && (undefined === input["default"] || "number" === typeof input["default"]) && "number" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
493
- const $io21 = input => Array.isArray(input["enum"]) && input["enum"].every(elem => "string" === typeof elem) && (undefined === input["default"] || "string" === typeof input["default"]) && "string" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
494
- const $io22 = input => (undefined === input["default"] || "boolean" === typeof input["default"]) && "boolean" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
495
- const $io23 = input => (undefined === input.minimum || "number" === typeof input.minimum && Math.floor(input.minimum) === input.minimum && (-2147483648 <= input.minimum && input.minimum <= 2147483647)) && (undefined === input.maximum || "number" === typeof input.maximum && Math.floor(input.maximum) === input.maximum && (-2147483648 <= input.maximum && input.maximum <= 2147483647)) && (undefined === input.exclusiveMinimum || "boolean" === typeof input.exclusiveMinimum) && (undefined === input.exclusiveMaximum || "boolean" === typeof input.exclusiveMaximum) && (undefined === input.multipleOf || "number" === typeof input.multipleOf && Math.floor(input.multipleOf) === input.multipleOf && (-2147483648 <= input.multipleOf && input.multipleOf <= 2147483647)) && (undefined === input["default"] || "number" === typeof input["default"]) && "integer" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
496
- const $io24 = input => (undefined === input.minimum || "number" === typeof input.minimum) && (undefined === input.maximum || "number" === typeof input.maximum) && (undefined === input.exclusiveMinimum || "boolean" === typeof input.exclusiveMinimum) && (undefined === input.exclusiveMaximum || "boolean" === typeof input.exclusiveMaximum) && (undefined === input.multipleOf || "number" === typeof input.multipleOf) && (undefined === input["default"] || "number" === typeof input["default"]) && "number" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
497
- const $io25 = input => (undefined === input.minLength || "number" === typeof input.minLength && Math.floor(input.minLength) === input.minLength && 0 <= input.minLength && input.minLength <= 4294967295) && (undefined === input.maxLength || "number" === typeof input.maxLength && Math.floor(input.maxLength) === input.maxLength && 0 <= input.maxLength && input.maxLength <= 4294967295) && (undefined === input.pattern || "string" === typeof input.pattern) && (undefined === input.format || "string" === typeof input.format) && (undefined === input["default"] || "string" === typeof input["default"]) && "string" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
498
- const $io26 = input => "object" === typeof input.items && null !== input.items && false === Array.isArray(input.items) && $iu1(input.items) && (undefined === input.minItems || "number" === typeof input.minItems && Math.floor(input.minItems) === input.minItems && 0 <= input.minItems && input.minItems <= 4294967295) && (undefined === input.maxItems || "number" === typeof input.maxItems && Math.floor(input.maxItems) === input.maxItems && 0 <= input.maxItems && input.maxItems <= 4294967295) && (undefined === input["x-typia-tuple"] || "object" === typeof input["x-typia-tuple"] && null !== input["x-typia-tuple"] && $io27(input["x-typia-tuple"])) && "array" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
499
- const $io27 = input => Array.isArray(input.items) && input.items.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $iu1(elem)) && ("number" === typeof input.minItems && Math.floor(input.minItems) === input.minItems && 0 <= input.minItems && input.minItems <= 4294967295) && (undefined === input.maxItems || "number" === typeof input.maxItems && Math.floor(input.maxItems) === input.maxItems && 0 <= input.maxItems && input.maxItems <= 4294967295) && "array" === input.type && (undefined === input.nullable || "boolean" === typeof input.nullable) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
500
- const $io28 = input => Array.isArray(input.oneOf) && input.oneOf.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $iu1(elem)) && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
501
- const $io29 = input => "string" === typeof input.$ref && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
502
- const $io30 = input => "null" === input.type && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
503
- const $io31 = input => null !== input.type && undefined === input.type && (undefined === input.deprecated || "boolean" === typeof input.deprecated) && (undefined === input.title || "string" === typeof input.title) && (undefined === input.description || "string" === typeof input.description) && (undefined === input["x-typia-metaTags"] || Array.isArray(input["x-typia-metaTags"]) && input["x-typia-metaTags"].every(elem => "object" === typeof elem && null !== elem && $iu0(elem))) && (undefined === input["x-typia-jsDocTags"] || Array.isArray(input["x-typia-jsDocTags"]) && input["x-typia-jsDocTags"].every(elem => "object" === typeof elem && null !== elem && $io18(elem))) && (undefined === input["x-typia-required"] || "boolean" === typeof input["x-typia-required"]) && (undefined === input["x-typia-optional"] || "boolean" === typeof input["x-typia-optional"]) && (undefined === input["x-typia-rest"] || "boolean" === typeof input["x-typia-rest"]);
504
- const $iu0 = input => (() => {
505
- if ("maxItems" === input.kind)
506
- return $io17(input);
507
- if ("minItems" === input.kind)
508
- return $io16(input);
509
- if ("items" === input.kind)
510
- return $io15(input);
511
- if ("maxLength" === input.kind)
512
- return $io14(input);
513
- if ("minLength" === input.kind)
514
- return $io13(input);
515
- if ("length" === input.kind)
516
- return $io12(input);
517
- if ("pattern" === input.kind)
518
- return $io11(input);
519
- if ("format" === input.kind)
520
- return $io10(input);
521
- if ("step" === input.kind)
522
- return $io9(input);
523
- if ("multipleOf" === input.kind)
524
- return $io8(input);
525
- if ("exclusiveMaximum" === input.kind)
526
- return $io7(input);
527
- if ("exclusiveMinimum" === input.kind)
528
- return $io6(input);
529
- if ("maximum" === input.kind)
530
- return $io5(input);
531
- if ("minimum" === input.kind)
532
- return $io4(input);
533
- if ("type" === input.kind)
534
- return $io3(input);
535
- return false;
536
- })();
537
- const $iu1 = input => (() => {
538
- if ("integer" === input.type)
539
- return $io23(input);
540
- if ("object" === typeof input.items && null !== input.items && false === Array.isArray(input.items) && $iu1(input.items))
541
- return $io26(input);
542
- if (Array.isArray(input.items) && input.items.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $iu1(elem)))
543
- return $io27(input);
544
- if (undefined !== input.oneOf)
545
- return $io28(input);
546
- if (undefined !== input.$ref)
547
- return $io29(input);
548
- if ("null" === input.type)
549
- return $io30(input);
550
- return (() => {
551
- if ($io21(input))
552
- return $io21(input);
553
- if ($io20(input))
554
- return $io20(input);
555
- if ($io2(input))
556
- return $io2(input);
557
- if ($io22(input))
558
- return $io22(input);
559
- if ($io24(input))
560
- return $io24(input);
561
- if ($io25(input))
562
- return $io25(input);
563
- if ($io31(input))
564
- return $io31(input);
565
- return false;
566
- })();
567
- })();
568
- return "object" === typeof input && null !== input && $io0(input);
569
- })(top))
570
- return Object.entries(top.properties).map(([key, value]) => {
571
- var _a, _b;
572
- return ({
573
- name: key,
574
- in: "header",
575
- schema: value,
576
- required: (_b = (_a = top.required) === null || _a === void 0 ? void 0 : _a.includes(key)) !== null && _b !== void 0 ? _b : false,
577
- description: value.description,
578
- });
579
- });
580
- }
581
- }
582
- return [
583
- {
584
- name: (_c = parameter.field) !== null && _c !== void 0 ? _c : parameter.name,
585
- in: parameter.category === "param"
586
- ? "path"
587
- : parameter.category === "headers"
588
- ? "header"
589
- : parameter.category,
590
- description: get_parametric_description(route, "param", parameter.name) || "",
591
- schema,
592
- required: required(parameter.type.type),
593
- },
594
- ];
595
- }
596
- function generate_request_body(checker, collection, tupleList, route, parameter) {
597
- const schema = generate_schema(checker, collection, tupleList, parameter.type.type);
598
- if (schema === null)
599
- throw new Error(`Error on NestiaApplication.sdk(): invalid request body type on ${route.symbol}.`);
600
- else if (parameter.category !== "body")
601
- throw new Error("Unreachable code.");
602
- const contentType = parameter.custom
603
- ? parameter.contentType
604
- : "application/json";
605
- const description = get_parametric_description(route, "param", parameter.name);
606
- return {
607
- description: parameter.custom && parameter.encrypted
608
- ? `${warning.get(!!description).get("request")}${description !== null && description !== void 0 ? description : ""}`
609
- : description,
610
- content: {
611
- [contentType]: {
612
- schema,
613
- },
614
- },
615
- required: true,
616
- "x-nestia-encrypted": parameter.custom && parameter.encrypted,
617
- };
618
- }
619
- function generate_response_body(checker, collection, tupleList, route) {
620
- var _a, _b, _c, _d;
621
- const output = {};
622
- //----
623
- // EXCEPTION STATUSES
624
- //----
625
- // FROM DECORATOR
626
- for (const [status, exp] of Object.entries(route.exceptions)) {
627
- const schema = generate_schema(checker, collection, tupleList, exp.type);
628
- if (schema !== null)
629
- output[status] = {
630
- description: (_a = exp.description) !== null && _a !== void 0 ? _a : "",
631
- content: {
632
- "application/json": { schema },
633
- },
634
- };
635
- }
636
- // FROM COMMENT TAGS
637
- for (const tag of route.tags) {
638
- if (tag.name !== "throw" && tag.name !== "throws")
639
- continue;
640
- const text = (_c = (_b = tag.text) === null || _b === void 0 ? void 0 : _b.find((elem) => elem.kind === "text")) === null || _c === void 0 ? void 0 : _c.text;
641
- if (text === undefined)
642
- continue;
643
- const elements = text.split(" ").map((str) => str.trim());
644
- const status = elements[0];
645
- if (isNaN(Number(status)) &&
646
- status !== "2XX" &&
647
- status !== "3XX" &&
648
- status !== "4XX" &&
649
- status !== "5XX")
650
- continue;
651
- const description = elements.length === 1 ? undefined : elements.slice(1).join(" ");
652
- const oldbie = output[status];
653
- if (description && oldbie !== undefined)
654
- oldbie.description = description;
655
- else if (oldbie === undefined)
656
- output[status] = {
657
- description: description !== null && description !== void 0 ? description : "",
658
- content: {
659
- "application/json": {
660
- schema: {},
661
- },
662
- },
663
- };
664
- }
665
- //----
666
- // SUCCESS
667
- //----
668
- // STATUS & SCHEMA
669
- const status = route.status !== undefined
670
- ? String(route.status)
671
- : route.method === "GET" ||
672
- route.method === "HEAD" ||
673
- route.method === "DELETE"
674
- ? "200"
675
- : "201";
676
- const schema = generate_schema(checker, collection, tupleList, route.output.type);
677
- // DO ASSIGN
678
- const description = (_d = get_parametric_description(route, "return")) !== null && _d !== void 0 ? _d : get_parametric_description(route, "returns");
679
- output[status] = {
680
- description: route.encrypted
681
- ? `${warning.get(!!description).get("response", route.method)}${description !== null && description !== void 0 ? description : ""}`
682
- : description !== null && description !== void 0 ? description : "",
683
- content: schema === null || route.output.name === "void"
684
- ? undefined
685
- : {
686
- [route.output.contentType]: {
687
- schema,
688
- },
689
- },
690
- "x-nestia-encrypted": route.encrypted,
691
- };
692
- return output;
693
- }
694
- /* ---------------------------------------------------------
695
- UTILS
696
- --------------------------------------------------------- */
697
- function generate_schema(checker, collection, tupleList, type) {
698
- const metadata = MetadataFactory_1.MetadataFactory.analyze(checker)({
699
- resolve: true,
700
- constant: true,
701
- absorb: false,
702
- validate: (meta) => {
703
- if (meta.atomics.find((str) => str === "bigint"))
704
- throw new Error(NO_BIGIT);
705
- },
706
- })(collection)(type);
707
- if (metadata.empty() && metadata.nullable === false)
708
- return null;
709
- const schema = {};
710
- tupleList.push({ metadata, schema });
711
- return schema;
712
- }
713
- function get_parametric_description(route, tagName, parameterName) {
714
- var _a;
715
- const parametric = parameterName
716
- ? (tag) => tag.text.find((elem) => elem.kind === "parameterName" &&
717
- elem.text === parameterName) !== undefined
718
- : () => true;
719
- const tag = route.tags.find((tag) => tag.name === tagName && tag.text && parametric(tag));
720
- return tag && tag.text
721
- ? (_a = tag.text.find((elem) => elem.kind === "text")) === null || _a === void 0 ? void 0 : _a.text
722
- : undefined;
723
- }
724
290
  })(SwaggerGenerator || (exports.SwaggerGenerator = SwaggerGenerator = {}));
725
- const required = (type) => {
726
- if (type.isUnion())
727
- return type.types.every((type) => required(type));
728
- const obstacle = (other) => (type.getFlags() & other) === 0;
729
- return (obstacle(typescript_1.default.TypeFlags.Undefined) &&
730
- obstacle(typescript_1.default.TypeFlags.Never) &&
731
- obstacle(typescript_1.default.TypeFlags.Void) &&
732
- obstacle(typescript_1.default.TypeFlags.VoidLike));
733
- };
734
- const warning = new Singleton_1.Singleton((described) => {
735
- return new Singleton_1.Singleton((type, method) => {
736
- const summary = type === "request"
737
- ? "Request body must be encrypted."
738
- : "Response data have been encrypted.";
739
- const component = type === "request"
740
- ? "[EncryptedBody](https://github.com/samchon/@nestia/core#encryptedbody)"
741
- : `[EncryptedRoute.${method[0].toUpperCase()}.${method
742
- .substring(1)
743
- .toLowerCase()}](https://github.com/samchon/@nestia/core#encryptedroute)`;
744
- const content = [
745
- "## Warning",
746
- "",
747
- summary,
748
- "",
749
- `The ${type} body data would be encrypted as "AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding", through the ${component} component.`,
750
- "",
751
- `Therefore, just utilize this swagger editor only for referencing. If you need to call the real API, using [SDK](https://github.com/samchon/nestia#software-development-kit) would be much better.`,
752
- ];
753
- if (described === true)
754
- content.push("----------------", "");
755
- return content.join("\n");
756
- });
757
- });
758
- const NO_BIGIT = "Error on typia.application(): does not allow bigint type.";
759
291
  //# sourceMappingURL=SwaggerGenerator.js.map