@navios/openapi 0.7.0 → 0.9.1

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 (67) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/legacy-compat/__type-tests__/legacy-decorators.spec-d.d.mts +2 -0
  3. package/dist/legacy-compat/__type-tests__/legacy-decorators.spec-d.d.mts.map +1 -0
  4. package/dist/legacy-compat/__type-tests__/tsconfig.tsbuildinfo +1 -0
  5. package/dist/src/legacy-compat/decorators/api-deprecated.decorator.d.mts +35 -0
  6. package/dist/src/legacy-compat/decorators/api-deprecated.decorator.d.mts.map +1 -0
  7. package/dist/src/legacy-compat/decorators/api-exclude.decorator.d.mts +28 -0
  8. package/dist/src/legacy-compat/decorators/api-exclude.decorator.d.mts.map +1 -0
  9. package/dist/src/legacy-compat/decorators/api-operation.decorator.d.mts +60 -0
  10. package/dist/src/legacy-compat/decorators/api-operation.decorator.d.mts.map +1 -0
  11. package/dist/src/legacy-compat/decorators/api-security.decorator.d.mts +38 -0
  12. package/dist/src/legacy-compat/decorators/api-security.decorator.d.mts.map +1 -0
  13. package/dist/src/legacy-compat/decorators/api-stream.decorator.d.mts +52 -0
  14. package/dist/src/legacy-compat/decorators/api-stream.decorator.d.mts.map +1 -0
  15. package/dist/src/legacy-compat/decorators/api-summary.decorator.d.mts +26 -0
  16. package/dist/src/legacy-compat/decorators/api-summary.decorator.d.mts.map +1 -0
  17. package/dist/src/legacy-compat/decorators/api-tag.decorator.d.mts +44 -0
  18. package/dist/src/legacy-compat/decorators/api-tag.decorator.d.mts.map +1 -0
  19. package/dist/src/legacy-compat/decorators/index.d.mts +8 -0
  20. package/dist/src/legacy-compat/decorators/index.d.mts.map +1 -0
  21. package/dist/src/legacy-compat/index.d.mts +24 -0
  22. package/dist/src/legacy-compat/index.d.mts.map +1 -0
  23. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  24. package/dist/tsconfig.spec.tsbuildinfo +1 -1
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/dist/vitest.config.d.mts.map +1 -1
  27. package/lib/index-BYd1gzJQ.d.cts +594 -0
  28. package/lib/index-BYd1gzJQ.d.cts.map +1 -0
  29. package/lib/index-KzCwlPFD.d.mts +594 -0
  30. package/lib/index-KzCwlPFD.d.mts.map +1 -0
  31. package/lib/index.cjs +20 -1840
  32. package/lib/index.cjs.map +1 -1
  33. package/lib/index.d.cts +2 -594
  34. package/lib/index.d.mts +2 -594
  35. package/lib/index.mjs +2 -1822
  36. package/lib/index.mjs.map +1 -1
  37. package/lib/legacy-compat/index.cjs +314 -0
  38. package/lib/legacy-compat/index.cjs.map +1 -0
  39. package/lib/legacy-compat/index.d.cts +285 -0
  40. package/lib/legacy-compat/index.d.cts.map +1 -0
  41. package/lib/legacy-compat/index.d.mts +285 -0
  42. package/lib/legacy-compat/index.d.mts.map +1 -0
  43. package/lib/legacy-compat/index.mjs +271 -0
  44. package/lib/legacy-compat/index.mjs.map +1 -0
  45. package/lib/services-MFCyRMd8.mjs +1825 -0
  46. package/lib/services-MFCyRMd8.mjs.map +1 -0
  47. package/lib/services-kEHEZqLZ.cjs +1896 -0
  48. package/lib/services-kEHEZqLZ.cjs.map +1 -0
  49. package/package.json +15 -5
  50. package/src/__tests__/metadata.spec.mts +5 -7
  51. package/src/__tests__/services.spec.mts +6 -7
  52. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +347 -0
  53. package/src/legacy-compat/__type-tests__/tsconfig.json +15 -0
  54. package/src/legacy-compat/decorators/api-deprecated.decorator.mts +46 -0
  55. package/src/legacy-compat/decorators/api-exclude.decorator.mts +31 -0
  56. package/src/legacy-compat/decorators/api-operation.decorator.mts +60 -0
  57. package/src/legacy-compat/decorators/api-security.decorator.mts +45 -0
  58. package/src/legacy-compat/decorators/api-stream.decorator.mts +56 -0
  59. package/src/legacy-compat/decorators/api-summary.decorator.mts +34 -0
  60. package/src/legacy-compat/decorators/api-tag.decorator.mts +52 -0
  61. package/src/legacy-compat/decorators/index.mts +7 -0
  62. package/src/legacy-compat/index.mts +58 -0
  63. package/tsconfig.spec.json +4 -1
  64. package/tsdown.config.mts +2 -2
  65. package/vitest.config.mts +5 -1
  66. package/lib/index.d.cts.map +0 -1
  67. package/lib/index.d.mts.map +0 -1
@@ -0,0 +1,1825 @@
1
+ import { Injectable, Logger, MultipartAdapterToken, StreamAdapterToken, extractControllerMetadata, inject } from "@navios/core";
2
+ import { createSchema } from "zod-openapi";
3
+
4
+ //#region src/tokens/index.mts
5
+ /**
6
+ * Tokens for OpenAPI metadata attributes
7
+ */
8
+ /** Token for @ApiTag decorator */ const ApiTagToken = Symbol.for("navios:openapi:tag");
9
+ /** Token for @ApiOperation decorator */ const ApiOperationToken = Symbol.for("navios:openapi:operation");
10
+ /** Token for @ApiSummary decorator */ const ApiSummaryToken = Symbol.for("navios:openapi:summary");
11
+ /** Token for @ApiDeprecated decorator */ const ApiDeprecatedToken = Symbol.for("navios:openapi:deprecated");
12
+ /** Token for @ApiSecurity decorator */ const ApiSecurityToken = Symbol.for("navios:openapi:security");
13
+ /** Token for @ApiExclude decorator */ const ApiExcludeToken = Symbol.for("navios:openapi:exclude");
14
+ /** Token for @ApiStream decorator */ const ApiStreamToken = Symbol.for("navios:openapi:stream");
15
+
16
+ //#endregion
17
+ //#region src/services/metadata-extractor.service.mts
18
+ function applyDecs2203RFactory$4() {
19
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
20
+ return function addInitializer(initializer) {
21
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
22
+ assertCallable(initializer, "An initializer");
23
+ initializers.push(initializer);
24
+ };
25
+ }
26
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
27
+ var kindStr;
28
+ switch (kind) {
29
+ case 1:
30
+ kindStr = "accessor";
31
+ break;
32
+ case 2:
33
+ kindStr = "method";
34
+ break;
35
+ case 3:
36
+ kindStr = "getter";
37
+ break;
38
+ case 4:
39
+ kindStr = "setter";
40
+ break;
41
+ default: kindStr = "field";
42
+ }
43
+ var ctx = {
44
+ kind: kindStr,
45
+ name: isPrivate ? "#" + name : name,
46
+ static: isStatic,
47
+ private: isPrivate,
48
+ metadata
49
+ };
50
+ var decoratorFinishedRef = { v: false };
51
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
52
+ var get, set;
53
+ if (kind === 0) if (isPrivate) {
54
+ get = desc.get;
55
+ set = desc.set;
56
+ } else {
57
+ get = function() {
58
+ return this[name];
59
+ };
60
+ set = function(v) {
61
+ this[name] = v;
62
+ };
63
+ }
64
+ else if (kind === 2) get = function() {
65
+ return desc.value;
66
+ };
67
+ else {
68
+ if (kind === 1 || kind === 3) get = function() {
69
+ return desc.get.call(this);
70
+ };
71
+ if (kind === 1 || kind === 4) set = function(v) {
72
+ desc.set.call(this, v);
73
+ };
74
+ }
75
+ ctx.access = get && set ? {
76
+ get,
77
+ set
78
+ } : get ? { get } : { set };
79
+ try {
80
+ return dec(value, ctx);
81
+ } finally {
82
+ decoratorFinishedRef.v = true;
83
+ }
84
+ }
85
+ function assertNotFinished(decoratorFinishedRef, fnName) {
86
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
87
+ }
88
+ function assertCallable(fn, hint) {
89
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
90
+ }
91
+ function assertValidReturnValue(kind, value) {
92
+ var type = typeof value;
93
+ if (kind === 1) {
94
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
95
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
96
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
97
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
98
+ } else if (type !== "function") {
99
+ var hint;
100
+ if (kind === 0) hint = "field";
101
+ else if (kind === 10) hint = "class";
102
+ else hint = "method";
103
+ throw new TypeError(hint + " decorators must return a function or void 0");
104
+ }
105
+ }
106
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
107
+ var decs = decInfo[0];
108
+ var desc, init, value;
109
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
110
+ get: decInfo[3],
111
+ set: decInfo[4]
112
+ };
113
+ else if (kind === 3) desc = { get: decInfo[3] };
114
+ else if (kind === 4) desc = { set: decInfo[3] };
115
+ else desc = { value: decInfo[3] };
116
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
117
+ if (kind === 1) value = {
118
+ get: desc.get,
119
+ set: desc.set
120
+ };
121
+ else if (kind === 2) value = desc.value;
122
+ else if (kind === 3) value = desc.get;
123
+ else if (kind === 4) value = desc.set;
124
+ var newValue, get, set;
125
+ if (typeof decs === "function") {
126
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
127
+ if (newValue !== void 0) {
128
+ assertValidReturnValue(kind, newValue);
129
+ if (kind === 0) init = newValue;
130
+ else if (kind === 1) {
131
+ init = newValue.init;
132
+ get = newValue.get || value.get;
133
+ set = newValue.set || value.set;
134
+ value = {
135
+ get,
136
+ set
137
+ };
138
+ } else value = newValue;
139
+ }
140
+ } else for (var i = decs.length - 1; i >= 0; i--) {
141
+ var dec = decs[i];
142
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
143
+ if (newValue !== void 0) {
144
+ assertValidReturnValue(kind, newValue);
145
+ var newInit;
146
+ if (kind === 0) newInit = newValue;
147
+ else if (kind === 1) {
148
+ newInit = newValue.init;
149
+ get = newValue.get || value.get;
150
+ set = newValue.set || value.set;
151
+ value = {
152
+ get,
153
+ set
154
+ };
155
+ } else value = newValue;
156
+ if (newInit !== void 0) if (init === void 0) init = newInit;
157
+ else if (typeof init === "function") init = [init, newInit];
158
+ else init.push(newInit);
159
+ }
160
+ }
161
+ if (kind === 0 || kind === 1) {
162
+ if (init === void 0) init = function(instance, init$1) {
163
+ return init$1;
164
+ };
165
+ else if (typeof init !== "function") {
166
+ var ownInitializers = init;
167
+ init = function(instance, init$1) {
168
+ var value$1 = init$1;
169
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
170
+ return value$1;
171
+ };
172
+ } else {
173
+ var originalInitializer = init;
174
+ init = function(instance, init$1) {
175
+ return originalInitializer.call(instance, init$1);
176
+ };
177
+ }
178
+ ret.push(init);
179
+ }
180
+ if (kind !== 0) {
181
+ if (kind === 1) {
182
+ desc.get = value.get;
183
+ desc.set = value.set;
184
+ } else if (kind === 2) desc.value = value;
185
+ else if (kind === 3) desc.get = value;
186
+ else if (kind === 4) desc.set = value;
187
+ if (isPrivate) if (kind === 1) {
188
+ ret.push(function(instance, args) {
189
+ return value.get.call(instance, args);
190
+ });
191
+ ret.push(function(instance, args) {
192
+ return value.set.call(instance, args);
193
+ });
194
+ } else if (kind === 2) ret.push(value);
195
+ else ret.push(function(instance, args) {
196
+ return value.call(instance, args);
197
+ });
198
+ else Object.defineProperty(base, name, desc);
199
+ }
200
+ }
201
+ function applyMemberDecs(Class, decInfos, metadata) {
202
+ var ret = [];
203
+ var protoInitializers;
204
+ var staticInitializers;
205
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
206
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
207
+ for (var i = 0; i < decInfos.length; i++) {
208
+ var decInfo = decInfos[i];
209
+ if (!Array.isArray(decInfo)) continue;
210
+ var kind = decInfo[1];
211
+ var name = decInfo[2];
212
+ var isPrivate = decInfo.length > 3;
213
+ var isStatic = kind >= 5;
214
+ var base;
215
+ var initializers;
216
+ if (isStatic) {
217
+ base = Class;
218
+ kind = kind - 5;
219
+ staticInitializers = staticInitializers || [];
220
+ initializers = staticInitializers;
221
+ } else {
222
+ base = Class.prototype;
223
+ protoInitializers = protoInitializers || [];
224
+ initializers = protoInitializers;
225
+ }
226
+ if (kind !== 0 && !isPrivate) {
227
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
228
+ var existingKind = existingNonFields.get(name) || 0;
229
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
230
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
231
+ else existingNonFields.set(name, true);
232
+ }
233
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
234
+ }
235
+ pushInitializers(ret, protoInitializers);
236
+ pushInitializers(ret, staticInitializers);
237
+ return ret;
238
+ }
239
+ function pushInitializers(ret, initializers) {
240
+ if (initializers) ret.push(function(instance) {
241
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
242
+ return instance;
243
+ });
244
+ }
245
+ function applyClassDecs(targetClass, classDecs, metadata) {
246
+ if (classDecs.length > 0) {
247
+ var initializers = [];
248
+ var newClass = targetClass;
249
+ var name = targetClass.name;
250
+ for (var i = classDecs.length - 1; i >= 0; i--) {
251
+ var decoratorFinishedRef = { v: false };
252
+ try {
253
+ var nextNewClass = classDecs[i](newClass, {
254
+ kind: "class",
255
+ name,
256
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
257
+ metadata
258
+ });
259
+ } finally {
260
+ decoratorFinishedRef.v = true;
261
+ }
262
+ if (nextNewClass !== void 0) {
263
+ assertValidReturnValue(10, nextNewClass);
264
+ newClass = nextNewClass;
265
+ }
266
+ }
267
+ return [defineMetadata(newClass, metadata), function() {
268
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
269
+ }];
270
+ }
271
+ }
272
+ function defineMetadata(Class, metadata) {
273
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
274
+ configurable: true,
275
+ enumerable: true,
276
+ value: metadata
277
+ });
278
+ }
279
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
280
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
281
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
282
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
283
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
284
+ return {
285
+ e,
286
+ get c() {
287
+ return applyClassDecs(targetClass, classDecs, metadata);
288
+ }
289
+ };
290
+ };
291
+ }
292
+ function _apply_decs_2203_r$4(targetClass, memberDecs, classDecs, parentClass) {
293
+ return (_apply_decs_2203_r$4 = applyDecs2203RFactory$4())(targetClass, memberDecs, classDecs, parentClass);
294
+ }
295
+ var _dec$4, _initClass$4;
296
+ let _MetadataExtractorService;
297
+ _dec$4 = Injectable();
298
+ var MetadataExtractorService = class {
299
+ static {
300
+ ({c: [_MetadataExtractorService, _initClass$4]} = _apply_decs_2203_r$4(this, [], [_dec$4]));
301
+ }
302
+ /**
303
+ * Extracts and merges OpenAPI metadata from controller and handler.
304
+ *
305
+ * @param controller - Controller metadata
306
+ * @param handler - Handler metadata
307
+ * @returns Merged OpenAPI metadata
308
+ */ extract(controller, handler) {
309
+ const controllerTag = controller.customAttributes.get(ApiTagToken);
310
+ const handlerTag = handler.customAttributes.get(ApiTagToken);
311
+ const operation = handler.customAttributes.get(ApiOperationToken);
312
+ const summary = handler.customAttributes.get(ApiSummaryToken);
313
+ const deprecated = handler.customAttributes.get(ApiDeprecatedToken);
314
+ const security = handler.customAttributes.get(ApiSecurityToken);
315
+ const excluded = handler.customAttributes.get(ApiExcludeToken);
316
+ const stream = handler.customAttributes.get(ApiStreamToken);
317
+ const tags = [];
318
+ if (controllerTag?.name) tags.push(controllerTag.name);
319
+ if (handlerTag?.name && handlerTag.name !== controllerTag?.name) tags.push(handlerTag.name);
320
+ return {
321
+ tags,
322
+ summary: operation?.summary ?? summary,
323
+ description: operation?.description,
324
+ operationId: operation?.operationId,
325
+ deprecated: deprecated !== void 0 || operation?.deprecated === true,
326
+ externalDocs: operation?.externalDocs,
327
+ security: security ? [security] : void 0,
328
+ excluded: excluded === true,
329
+ stream
330
+ };
331
+ }
332
+ static {
333
+ _initClass$4();
334
+ }
335
+ };
336
+
337
+ //#endregion
338
+ //#region src/services/endpoint-scanner.service.mts
339
+ function applyDecs2203RFactory$3() {
340
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
341
+ return function addInitializer(initializer) {
342
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
343
+ assertCallable(initializer, "An initializer");
344
+ initializers.push(initializer);
345
+ };
346
+ }
347
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
348
+ var kindStr;
349
+ switch (kind) {
350
+ case 1:
351
+ kindStr = "accessor";
352
+ break;
353
+ case 2:
354
+ kindStr = "method";
355
+ break;
356
+ case 3:
357
+ kindStr = "getter";
358
+ break;
359
+ case 4:
360
+ kindStr = "setter";
361
+ break;
362
+ default: kindStr = "field";
363
+ }
364
+ var ctx = {
365
+ kind: kindStr,
366
+ name: isPrivate ? "#" + name : name,
367
+ static: isStatic,
368
+ private: isPrivate,
369
+ metadata
370
+ };
371
+ var decoratorFinishedRef = { v: false };
372
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
373
+ var get, set;
374
+ if (kind === 0) if (isPrivate) {
375
+ get = desc.get;
376
+ set = desc.set;
377
+ } else {
378
+ get = function() {
379
+ return this[name];
380
+ };
381
+ set = function(v) {
382
+ this[name] = v;
383
+ };
384
+ }
385
+ else if (kind === 2) get = function() {
386
+ return desc.value;
387
+ };
388
+ else {
389
+ if (kind === 1 || kind === 3) get = function() {
390
+ return desc.get.call(this);
391
+ };
392
+ if (kind === 1 || kind === 4) set = function(v) {
393
+ desc.set.call(this, v);
394
+ };
395
+ }
396
+ ctx.access = get && set ? {
397
+ get,
398
+ set
399
+ } : get ? { get } : { set };
400
+ try {
401
+ return dec(value, ctx);
402
+ } finally {
403
+ decoratorFinishedRef.v = true;
404
+ }
405
+ }
406
+ function assertNotFinished(decoratorFinishedRef, fnName) {
407
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
408
+ }
409
+ function assertCallable(fn, hint) {
410
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
411
+ }
412
+ function assertValidReturnValue(kind, value) {
413
+ var type = typeof value;
414
+ if (kind === 1) {
415
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
416
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
417
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
418
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
419
+ } else if (type !== "function") {
420
+ var hint;
421
+ if (kind === 0) hint = "field";
422
+ else if (kind === 10) hint = "class";
423
+ else hint = "method";
424
+ throw new TypeError(hint + " decorators must return a function or void 0");
425
+ }
426
+ }
427
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
428
+ var decs = decInfo[0];
429
+ var desc, init, value;
430
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
431
+ get: decInfo[3],
432
+ set: decInfo[4]
433
+ };
434
+ else if (kind === 3) desc = { get: decInfo[3] };
435
+ else if (kind === 4) desc = { set: decInfo[3] };
436
+ else desc = { value: decInfo[3] };
437
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
438
+ if (kind === 1) value = {
439
+ get: desc.get,
440
+ set: desc.set
441
+ };
442
+ else if (kind === 2) value = desc.value;
443
+ else if (kind === 3) value = desc.get;
444
+ else if (kind === 4) value = desc.set;
445
+ var newValue, get, set;
446
+ if (typeof decs === "function") {
447
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
448
+ if (newValue !== void 0) {
449
+ assertValidReturnValue(kind, newValue);
450
+ if (kind === 0) init = newValue;
451
+ else if (kind === 1) {
452
+ init = newValue.init;
453
+ get = newValue.get || value.get;
454
+ set = newValue.set || value.set;
455
+ value = {
456
+ get,
457
+ set
458
+ };
459
+ } else value = newValue;
460
+ }
461
+ } else for (var i = decs.length - 1; i >= 0; i--) {
462
+ var dec = decs[i];
463
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
464
+ if (newValue !== void 0) {
465
+ assertValidReturnValue(kind, newValue);
466
+ var newInit;
467
+ if (kind === 0) newInit = newValue;
468
+ else if (kind === 1) {
469
+ newInit = newValue.init;
470
+ get = newValue.get || value.get;
471
+ set = newValue.set || value.set;
472
+ value = {
473
+ get,
474
+ set
475
+ };
476
+ } else value = newValue;
477
+ if (newInit !== void 0) if (init === void 0) init = newInit;
478
+ else if (typeof init === "function") init = [init, newInit];
479
+ else init.push(newInit);
480
+ }
481
+ }
482
+ if (kind === 0 || kind === 1) {
483
+ if (init === void 0) init = function(instance, init$1) {
484
+ return init$1;
485
+ };
486
+ else if (typeof init !== "function") {
487
+ var ownInitializers = init;
488
+ init = function(instance, init$1) {
489
+ var value$1 = init$1;
490
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
491
+ return value$1;
492
+ };
493
+ } else {
494
+ var originalInitializer = init;
495
+ init = function(instance, init$1) {
496
+ return originalInitializer.call(instance, init$1);
497
+ };
498
+ }
499
+ ret.push(init);
500
+ }
501
+ if (kind !== 0) {
502
+ if (kind === 1) {
503
+ desc.get = value.get;
504
+ desc.set = value.set;
505
+ } else if (kind === 2) desc.value = value;
506
+ else if (kind === 3) desc.get = value;
507
+ else if (kind === 4) desc.set = value;
508
+ if (isPrivate) if (kind === 1) {
509
+ ret.push(function(instance, args) {
510
+ return value.get.call(instance, args);
511
+ });
512
+ ret.push(function(instance, args) {
513
+ return value.set.call(instance, args);
514
+ });
515
+ } else if (kind === 2) ret.push(value);
516
+ else ret.push(function(instance, args) {
517
+ return value.call(instance, args);
518
+ });
519
+ else Object.defineProperty(base, name, desc);
520
+ }
521
+ }
522
+ function applyMemberDecs(Class, decInfos, metadata) {
523
+ var ret = [];
524
+ var protoInitializers;
525
+ var staticInitializers;
526
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
527
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
528
+ for (var i = 0; i < decInfos.length; i++) {
529
+ var decInfo = decInfos[i];
530
+ if (!Array.isArray(decInfo)) continue;
531
+ var kind = decInfo[1];
532
+ var name = decInfo[2];
533
+ var isPrivate = decInfo.length > 3;
534
+ var isStatic = kind >= 5;
535
+ var base;
536
+ var initializers;
537
+ if (isStatic) {
538
+ base = Class;
539
+ kind = kind - 5;
540
+ staticInitializers = staticInitializers || [];
541
+ initializers = staticInitializers;
542
+ } else {
543
+ base = Class.prototype;
544
+ protoInitializers = protoInitializers || [];
545
+ initializers = protoInitializers;
546
+ }
547
+ if (kind !== 0 && !isPrivate) {
548
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
549
+ var existingKind = existingNonFields.get(name) || 0;
550
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
551
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
552
+ else existingNonFields.set(name, true);
553
+ }
554
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
555
+ }
556
+ pushInitializers(ret, protoInitializers);
557
+ pushInitializers(ret, staticInitializers);
558
+ return ret;
559
+ }
560
+ function pushInitializers(ret, initializers) {
561
+ if (initializers) ret.push(function(instance) {
562
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
563
+ return instance;
564
+ });
565
+ }
566
+ function applyClassDecs(targetClass, classDecs, metadata) {
567
+ if (classDecs.length > 0) {
568
+ var initializers = [];
569
+ var newClass = targetClass;
570
+ var name = targetClass.name;
571
+ for (var i = classDecs.length - 1; i >= 0; i--) {
572
+ var decoratorFinishedRef = { v: false };
573
+ try {
574
+ var nextNewClass = classDecs[i](newClass, {
575
+ kind: "class",
576
+ name,
577
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
578
+ metadata
579
+ });
580
+ } finally {
581
+ decoratorFinishedRef.v = true;
582
+ }
583
+ if (nextNewClass !== void 0) {
584
+ assertValidReturnValue(10, nextNewClass);
585
+ newClass = nextNewClass;
586
+ }
587
+ }
588
+ return [defineMetadata(newClass, metadata), function() {
589
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
590
+ }];
591
+ }
592
+ }
593
+ function defineMetadata(Class, metadata) {
594
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
595
+ configurable: true,
596
+ enumerable: true,
597
+ value: metadata
598
+ });
599
+ }
600
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
601
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
602
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
603
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
604
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
605
+ return {
606
+ e,
607
+ get c() {
608
+ return applyClassDecs(targetClass, classDecs, metadata);
609
+ }
610
+ };
611
+ };
612
+ }
613
+ function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
614
+ return (_apply_decs_2203_r$3 = applyDecs2203RFactory$3())(targetClass, memberDecs, classDecs, parentClass);
615
+ }
616
+ var _dec$3, _initClass$3;
617
+ let _EndpointScannerService;
618
+ _dec$3 = Injectable();
619
+ var EndpointScannerService = class {
620
+ static {
621
+ ({c: [_EndpointScannerService, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
622
+ }
623
+ logger = inject(Logger, { context: _EndpointScannerService.name });
624
+ metadataExtractor = inject(_MetadataExtractorService);
625
+ /**
626
+ * Scans all loaded modules and discovers endpoints.
627
+ *
628
+ * @param modules - Map of loaded modules from NaviosApplication
629
+ * @returns Array of discovered endpoints
630
+ */ scan(modules) {
631
+ const endpoints = [];
632
+ for (const [moduleName, moduleMetadata] of modules) {
633
+ if (!moduleMetadata.controllers || moduleMetadata.controllers.size === 0) continue;
634
+ this.logger.debug(`Scanning module: ${moduleName}`);
635
+ for (const controllerClass of moduleMetadata.controllers) {
636
+ const controllerMeta = extractControllerMetadata(controllerClass);
637
+ const controllerEndpoints = this.scanController(moduleMetadata, controllerClass, controllerMeta);
638
+ endpoints.push(...controllerEndpoints);
639
+ }
640
+ }
641
+ this.logger.debug(`Discovered ${endpoints.length} endpoints`);
642
+ return endpoints;
643
+ }
644
+ /**
645
+ * Scans a controller and returns its endpoints
646
+ */ scanController(module, controllerClass, controllerMeta) {
647
+ const endpoints = [];
648
+ for (const handler of controllerMeta.endpoints) {
649
+ if (!handler.config) continue;
650
+ const openApiMetadata = this.metadataExtractor.extract(controllerMeta, handler);
651
+ if (openApiMetadata.excluded) {
652
+ this.logger.debug(`Skipping excluded endpoint: ${handler.classMethod}`);
653
+ continue;
654
+ }
655
+ endpoints.push({
656
+ module,
657
+ controllerClass,
658
+ controller: controllerMeta,
659
+ handler,
660
+ config: handler.config,
661
+ openApiMetadata
662
+ });
663
+ }
664
+ return endpoints;
665
+ }
666
+ static {
667
+ _initClass$3();
668
+ }
669
+ };
670
+
671
+ //#endregion
672
+ //#region src/services/schema-converter.service.mts
673
+ function applyDecs2203RFactory$2() {
674
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
675
+ return function addInitializer(initializer) {
676
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
677
+ assertCallable(initializer, "An initializer");
678
+ initializers.push(initializer);
679
+ };
680
+ }
681
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
682
+ var kindStr;
683
+ switch (kind) {
684
+ case 1:
685
+ kindStr = "accessor";
686
+ break;
687
+ case 2:
688
+ kindStr = "method";
689
+ break;
690
+ case 3:
691
+ kindStr = "getter";
692
+ break;
693
+ case 4:
694
+ kindStr = "setter";
695
+ break;
696
+ default: kindStr = "field";
697
+ }
698
+ var ctx = {
699
+ kind: kindStr,
700
+ name: isPrivate ? "#" + name : name,
701
+ static: isStatic,
702
+ private: isPrivate,
703
+ metadata
704
+ };
705
+ var decoratorFinishedRef = { v: false };
706
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
707
+ var get, set;
708
+ if (kind === 0) if (isPrivate) {
709
+ get = desc.get;
710
+ set = desc.set;
711
+ } else {
712
+ get = function() {
713
+ return this[name];
714
+ };
715
+ set = function(v) {
716
+ this[name] = v;
717
+ };
718
+ }
719
+ else if (kind === 2) get = function() {
720
+ return desc.value;
721
+ };
722
+ else {
723
+ if (kind === 1 || kind === 3) get = function() {
724
+ return desc.get.call(this);
725
+ };
726
+ if (kind === 1 || kind === 4) set = function(v) {
727
+ desc.set.call(this, v);
728
+ };
729
+ }
730
+ ctx.access = get && set ? {
731
+ get,
732
+ set
733
+ } : get ? { get } : { set };
734
+ try {
735
+ return dec(value, ctx);
736
+ } finally {
737
+ decoratorFinishedRef.v = true;
738
+ }
739
+ }
740
+ function assertNotFinished(decoratorFinishedRef, fnName) {
741
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
742
+ }
743
+ function assertCallable(fn, hint) {
744
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
745
+ }
746
+ function assertValidReturnValue(kind, value) {
747
+ var type = typeof value;
748
+ if (kind === 1) {
749
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
750
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
751
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
752
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
753
+ } else if (type !== "function") {
754
+ var hint;
755
+ if (kind === 0) hint = "field";
756
+ else if (kind === 10) hint = "class";
757
+ else hint = "method";
758
+ throw new TypeError(hint + " decorators must return a function or void 0");
759
+ }
760
+ }
761
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
762
+ var decs = decInfo[0];
763
+ var desc, init, value;
764
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
765
+ get: decInfo[3],
766
+ set: decInfo[4]
767
+ };
768
+ else if (kind === 3) desc = { get: decInfo[3] };
769
+ else if (kind === 4) desc = { set: decInfo[3] };
770
+ else desc = { value: decInfo[3] };
771
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
772
+ if (kind === 1) value = {
773
+ get: desc.get,
774
+ set: desc.set
775
+ };
776
+ else if (kind === 2) value = desc.value;
777
+ else if (kind === 3) value = desc.get;
778
+ else if (kind === 4) value = desc.set;
779
+ var newValue, get, set;
780
+ if (typeof decs === "function") {
781
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
782
+ if (newValue !== void 0) {
783
+ assertValidReturnValue(kind, newValue);
784
+ if (kind === 0) init = newValue;
785
+ else if (kind === 1) {
786
+ init = newValue.init;
787
+ get = newValue.get || value.get;
788
+ set = newValue.set || value.set;
789
+ value = {
790
+ get,
791
+ set
792
+ };
793
+ } else value = newValue;
794
+ }
795
+ } else for (var i = decs.length - 1; i >= 0; i--) {
796
+ var dec = decs[i];
797
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
798
+ if (newValue !== void 0) {
799
+ assertValidReturnValue(kind, newValue);
800
+ var newInit;
801
+ if (kind === 0) newInit = newValue;
802
+ else if (kind === 1) {
803
+ newInit = newValue.init;
804
+ get = newValue.get || value.get;
805
+ set = newValue.set || value.set;
806
+ value = {
807
+ get,
808
+ set
809
+ };
810
+ } else value = newValue;
811
+ if (newInit !== void 0) if (init === void 0) init = newInit;
812
+ else if (typeof init === "function") init = [init, newInit];
813
+ else init.push(newInit);
814
+ }
815
+ }
816
+ if (kind === 0 || kind === 1) {
817
+ if (init === void 0) init = function(instance, init$1) {
818
+ return init$1;
819
+ };
820
+ else if (typeof init !== "function") {
821
+ var ownInitializers = init;
822
+ init = function(instance, init$1) {
823
+ var value$1 = init$1;
824
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
825
+ return value$1;
826
+ };
827
+ } else {
828
+ var originalInitializer = init;
829
+ init = function(instance, init$1) {
830
+ return originalInitializer.call(instance, init$1);
831
+ };
832
+ }
833
+ ret.push(init);
834
+ }
835
+ if (kind !== 0) {
836
+ if (kind === 1) {
837
+ desc.get = value.get;
838
+ desc.set = value.set;
839
+ } else if (kind === 2) desc.value = value;
840
+ else if (kind === 3) desc.get = value;
841
+ else if (kind === 4) desc.set = value;
842
+ if (isPrivate) if (kind === 1) {
843
+ ret.push(function(instance, args) {
844
+ return value.get.call(instance, args);
845
+ });
846
+ ret.push(function(instance, args) {
847
+ return value.set.call(instance, args);
848
+ });
849
+ } else if (kind === 2) ret.push(value);
850
+ else ret.push(function(instance, args) {
851
+ return value.call(instance, args);
852
+ });
853
+ else Object.defineProperty(base, name, desc);
854
+ }
855
+ }
856
+ function applyMemberDecs(Class, decInfos, metadata) {
857
+ var ret = [];
858
+ var protoInitializers;
859
+ var staticInitializers;
860
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
861
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
862
+ for (var i = 0; i < decInfos.length; i++) {
863
+ var decInfo = decInfos[i];
864
+ if (!Array.isArray(decInfo)) continue;
865
+ var kind = decInfo[1];
866
+ var name = decInfo[2];
867
+ var isPrivate = decInfo.length > 3;
868
+ var isStatic = kind >= 5;
869
+ var base;
870
+ var initializers;
871
+ if (isStatic) {
872
+ base = Class;
873
+ kind = kind - 5;
874
+ staticInitializers = staticInitializers || [];
875
+ initializers = staticInitializers;
876
+ } else {
877
+ base = Class.prototype;
878
+ protoInitializers = protoInitializers || [];
879
+ initializers = protoInitializers;
880
+ }
881
+ if (kind !== 0 && !isPrivate) {
882
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
883
+ var existingKind = existingNonFields.get(name) || 0;
884
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
885
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
886
+ else existingNonFields.set(name, true);
887
+ }
888
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
889
+ }
890
+ pushInitializers(ret, protoInitializers);
891
+ pushInitializers(ret, staticInitializers);
892
+ return ret;
893
+ }
894
+ function pushInitializers(ret, initializers) {
895
+ if (initializers) ret.push(function(instance) {
896
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
897
+ return instance;
898
+ });
899
+ }
900
+ function applyClassDecs(targetClass, classDecs, metadata) {
901
+ if (classDecs.length > 0) {
902
+ var initializers = [];
903
+ var newClass = targetClass;
904
+ var name = targetClass.name;
905
+ for (var i = classDecs.length - 1; i >= 0; i--) {
906
+ var decoratorFinishedRef = { v: false };
907
+ try {
908
+ var nextNewClass = classDecs[i](newClass, {
909
+ kind: "class",
910
+ name,
911
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
912
+ metadata
913
+ });
914
+ } finally {
915
+ decoratorFinishedRef.v = true;
916
+ }
917
+ if (nextNewClass !== void 0) {
918
+ assertValidReturnValue(10, nextNewClass);
919
+ newClass = nextNewClass;
920
+ }
921
+ }
922
+ return [defineMetadata(newClass, metadata), function() {
923
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
924
+ }];
925
+ }
926
+ }
927
+ function defineMetadata(Class, metadata) {
928
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
929
+ configurable: true,
930
+ enumerable: true,
931
+ value: metadata
932
+ });
933
+ }
934
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
935
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
936
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
937
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
938
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
939
+ return {
940
+ e,
941
+ get c() {
942
+ return applyClassDecs(targetClass, classDecs, metadata);
943
+ }
944
+ };
945
+ };
946
+ }
947
+ function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
948
+ return (_apply_decs_2203_r$2 = applyDecs2203RFactory$2())(targetClass, memberDecs, classDecs, parentClass);
949
+ }
950
+ var _dec$2, _initClass$2;
951
+ let _SchemaConverterService;
952
+ _dec$2 = Injectable();
953
+ var SchemaConverterService = class {
954
+ static {
955
+ ({c: [_SchemaConverterService, _initClass$2]} = _apply_decs_2203_r$2(this, [], [_dec$2]));
956
+ }
957
+ /**
958
+ * Converts a Zod schema to an OpenAPI schema object.
959
+ *
960
+ * @param schema - Zod schema to convert
961
+ * @returns OpenAPI schema object with any component schemas
962
+ *
963
+ * @example
964
+ * ```typescript
965
+ * const userSchema = z.object({
966
+ * id: z.string().meta({ openapi: { example: 'usr_123' } }),
967
+ * name: z.string(),
968
+ * })
969
+ *
970
+ * const result = schemaConverter.convert(userSchema)
971
+ * // { schema: { type: 'object', properties: { ... } }, components: {} }
972
+ * ```
973
+ */ convert(schema) {
974
+ return createSchema(schema);
975
+ }
976
+ /**
977
+ * Checks if a schema property represents a File type.
978
+ *
979
+ * Used for multipart form handling to convert File types to binary format.
980
+ *
981
+ * @param schema - Schema object to check
982
+ * @returns true if the schema represents a file
983
+ */ isFileSchema(schema) {
984
+ return schema.type === "string" && schema.format === "binary";
985
+ }
986
+ /**
987
+ * Transforms schema properties to handle File/Blob types for multipart.
988
+ *
989
+ * Converts File types to OpenAPI binary format and handles arrays of files.
990
+ *
991
+ * @param properties - Schema properties object
992
+ * @returns Transformed properties with file types as binary
993
+ */ transformFileProperties(properties) {
994
+ const result = {};
995
+ for (const [key, prop] of Object.entries(properties)) if (this.isFileSchema(prop)) result[key] = {
996
+ type: "string",
997
+ format: "binary",
998
+ description: prop.description
999
+ };
1000
+ else if (prop.type === "array" && prop.items && this.isFileSchema(prop.items)) result[key] = {
1001
+ type: "array",
1002
+ items: {
1003
+ type: "string",
1004
+ format: "binary"
1005
+ },
1006
+ description: prop.description
1007
+ };
1008
+ else result[key] = prop;
1009
+ return result;
1010
+ }
1011
+ static {
1012
+ _initClass$2();
1013
+ }
1014
+ };
1015
+
1016
+ //#endregion
1017
+ //#region src/services/path-builder.service.mts
1018
+ function applyDecs2203RFactory$1() {
1019
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1020
+ return function addInitializer(initializer) {
1021
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
1022
+ assertCallable(initializer, "An initializer");
1023
+ initializers.push(initializer);
1024
+ };
1025
+ }
1026
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1027
+ var kindStr;
1028
+ switch (kind) {
1029
+ case 1:
1030
+ kindStr = "accessor";
1031
+ break;
1032
+ case 2:
1033
+ kindStr = "method";
1034
+ break;
1035
+ case 3:
1036
+ kindStr = "getter";
1037
+ break;
1038
+ case 4:
1039
+ kindStr = "setter";
1040
+ break;
1041
+ default: kindStr = "field";
1042
+ }
1043
+ var ctx = {
1044
+ kind: kindStr,
1045
+ name: isPrivate ? "#" + name : name,
1046
+ static: isStatic,
1047
+ private: isPrivate,
1048
+ metadata
1049
+ };
1050
+ var decoratorFinishedRef = { v: false };
1051
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1052
+ var get, set;
1053
+ if (kind === 0) if (isPrivate) {
1054
+ get = desc.get;
1055
+ set = desc.set;
1056
+ } else {
1057
+ get = function() {
1058
+ return this[name];
1059
+ };
1060
+ set = function(v) {
1061
+ this[name] = v;
1062
+ };
1063
+ }
1064
+ else if (kind === 2) get = function() {
1065
+ return desc.value;
1066
+ };
1067
+ else {
1068
+ if (kind === 1 || kind === 3) get = function() {
1069
+ return desc.get.call(this);
1070
+ };
1071
+ if (kind === 1 || kind === 4) set = function(v) {
1072
+ desc.set.call(this, v);
1073
+ };
1074
+ }
1075
+ ctx.access = get && set ? {
1076
+ get,
1077
+ set
1078
+ } : get ? { get } : { set };
1079
+ try {
1080
+ return dec(value, ctx);
1081
+ } finally {
1082
+ decoratorFinishedRef.v = true;
1083
+ }
1084
+ }
1085
+ function assertNotFinished(decoratorFinishedRef, fnName) {
1086
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1087
+ }
1088
+ function assertCallable(fn, hint) {
1089
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1090
+ }
1091
+ function assertValidReturnValue(kind, value) {
1092
+ var type = typeof value;
1093
+ if (kind === 1) {
1094
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1095
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1096
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1097
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1098
+ } else if (type !== "function") {
1099
+ var hint;
1100
+ if (kind === 0) hint = "field";
1101
+ else if (kind === 10) hint = "class";
1102
+ else hint = "method";
1103
+ throw new TypeError(hint + " decorators must return a function or void 0");
1104
+ }
1105
+ }
1106
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1107
+ var decs = decInfo[0];
1108
+ var desc, init, value;
1109
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
1110
+ get: decInfo[3],
1111
+ set: decInfo[4]
1112
+ };
1113
+ else if (kind === 3) desc = { get: decInfo[3] };
1114
+ else if (kind === 4) desc = { set: decInfo[3] };
1115
+ else desc = { value: decInfo[3] };
1116
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1117
+ if (kind === 1) value = {
1118
+ get: desc.get,
1119
+ set: desc.set
1120
+ };
1121
+ else if (kind === 2) value = desc.value;
1122
+ else if (kind === 3) value = desc.get;
1123
+ else if (kind === 4) value = desc.set;
1124
+ var newValue, get, set;
1125
+ if (typeof decs === "function") {
1126
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1127
+ if (newValue !== void 0) {
1128
+ assertValidReturnValue(kind, newValue);
1129
+ if (kind === 0) init = newValue;
1130
+ else if (kind === 1) {
1131
+ init = newValue.init;
1132
+ get = newValue.get || value.get;
1133
+ set = newValue.set || value.set;
1134
+ value = {
1135
+ get,
1136
+ set
1137
+ };
1138
+ } else value = newValue;
1139
+ }
1140
+ } else for (var i = decs.length - 1; i >= 0; i--) {
1141
+ var dec = decs[i];
1142
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1143
+ if (newValue !== void 0) {
1144
+ assertValidReturnValue(kind, newValue);
1145
+ var newInit;
1146
+ if (kind === 0) newInit = newValue;
1147
+ else if (kind === 1) {
1148
+ newInit = newValue.init;
1149
+ get = newValue.get || value.get;
1150
+ set = newValue.set || value.set;
1151
+ value = {
1152
+ get,
1153
+ set
1154
+ };
1155
+ } else value = newValue;
1156
+ if (newInit !== void 0) if (init === void 0) init = newInit;
1157
+ else if (typeof init === "function") init = [init, newInit];
1158
+ else init.push(newInit);
1159
+ }
1160
+ }
1161
+ if (kind === 0 || kind === 1) {
1162
+ if (init === void 0) init = function(instance, init$1) {
1163
+ return init$1;
1164
+ };
1165
+ else if (typeof init !== "function") {
1166
+ var ownInitializers = init;
1167
+ init = function(instance, init$1) {
1168
+ var value$1 = init$1;
1169
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
1170
+ return value$1;
1171
+ };
1172
+ } else {
1173
+ var originalInitializer = init;
1174
+ init = function(instance, init$1) {
1175
+ return originalInitializer.call(instance, init$1);
1176
+ };
1177
+ }
1178
+ ret.push(init);
1179
+ }
1180
+ if (kind !== 0) {
1181
+ if (kind === 1) {
1182
+ desc.get = value.get;
1183
+ desc.set = value.set;
1184
+ } else if (kind === 2) desc.value = value;
1185
+ else if (kind === 3) desc.get = value;
1186
+ else if (kind === 4) desc.set = value;
1187
+ if (isPrivate) if (kind === 1) {
1188
+ ret.push(function(instance, args) {
1189
+ return value.get.call(instance, args);
1190
+ });
1191
+ ret.push(function(instance, args) {
1192
+ return value.set.call(instance, args);
1193
+ });
1194
+ } else if (kind === 2) ret.push(value);
1195
+ else ret.push(function(instance, args) {
1196
+ return value.call(instance, args);
1197
+ });
1198
+ else Object.defineProperty(base, name, desc);
1199
+ }
1200
+ }
1201
+ function applyMemberDecs(Class, decInfos, metadata) {
1202
+ var ret = [];
1203
+ var protoInitializers;
1204
+ var staticInitializers;
1205
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
1206
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
1207
+ for (var i = 0; i < decInfos.length; i++) {
1208
+ var decInfo = decInfos[i];
1209
+ if (!Array.isArray(decInfo)) continue;
1210
+ var kind = decInfo[1];
1211
+ var name = decInfo[2];
1212
+ var isPrivate = decInfo.length > 3;
1213
+ var isStatic = kind >= 5;
1214
+ var base;
1215
+ var initializers;
1216
+ if (isStatic) {
1217
+ base = Class;
1218
+ kind = kind - 5;
1219
+ staticInitializers = staticInitializers || [];
1220
+ initializers = staticInitializers;
1221
+ } else {
1222
+ base = Class.prototype;
1223
+ protoInitializers = protoInitializers || [];
1224
+ initializers = protoInitializers;
1225
+ }
1226
+ if (kind !== 0 && !isPrivate) {
1227
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1228
+ var existingKind = existingNonFields.get(name) || 0;
1229
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
1230
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1231
+ else existingNonFields.set(name, true);
1232
+ }
1233
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1234
+ }
1235
+ pushInitializers(ret, protoInitializers);
1236
+ pushInitializers(ret, staticInitializers);
1237
+ return ret;
1238
+ }
1239
+ function pushInitializers(ret, initializers) {
1240
+ if (initializers) ret.push(function(instance) {
1241
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1242
+ return instance;
1243
+ });
1244
+ }
1245
+ function applyClassDecs(targetClass, classDecs, metadata) {
1246
+ if (classDecs.length > 0) {
1247
+ var initializers = [];
1248
+ var newClass = targetClass;
1249
+ var name = targetClass.name;
1250
+ for (var i = classDecs.length - 1; i >= 0; i--) {
1251
+ var decoratorFinishedRef = { v: false };
1252
+ try {
1253
+ var nextNewClass = classDecs[i](newClass, {
1254
+ kind: "class",
1255
+ name,
1256
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1257
+ metadata
1258
+ });
1259
+ } finally {
1260
+ decoratorFinishedRef.v = true;
1261
+ }
1262
+ if (nextNewClass !== void 0) {
1263
+ assertValidReturnValue(10, nextNewClass);
1264
+ newClass = nextNewClass;
1265
+ }
1266
+ }
1267
+ return [defineMetadata(newClass, metadata), function() {
1268
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
1269
+ }];
1270
+ }
1271
+ }
1272
+ function defineMetadata(Class, metadata) {
1273
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1274
+ configurable: true,
1275
+ enumerable: true,
1276
+ value: metadata
1277
+ });
1278
+ }
1279
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1280
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1281
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1282
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
1283
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
1284
+ return {
1285
+ e,
1286
+ get c() {
1287
+ return applyClassDecs(targetClass, classDecs, metadata);
1288
+ }
1289
+ };
1290
+ };
1291
+ }
1292
+ function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
1293
+ return (_apply_decs_2203_r$1 = applyDecs2203RFactory$1())(targetClass, memberDecs, classDecs, parentClass);
1294
+ }
1295
+ var _dec$1, _initClass$1;
1296
+ let _PathBuilderService;
1297
+ _dec$1 = Injectable();
1298
+ var PathBuilderService = class {
1299
+ static {
1300
+ ({c: [_PathBuilderService, _initClass$1]} = _apply_decs_2203_r$1(this, [], [_dec$1]));
1301
+ }
1302
+ schemaConverter = inject(_SchemaConverterService);
1303
+ /**
1304
+ * Generates an OpenAPI path item for a discovered endpoint.
1305
+ *
1306
+ * @param endpoint - Discovered endpoint with metadata
1307
+ * @returns Path string and path item object
1308
+ */ build(endpoint) {
1309
+ const { config, handler, openApiMetadata } = endpoint;
1310
+ const path = this.convertUrlParams(config.url);
1311
+ const operation = {
1312
+ tags: openApiMetadata.tags.length > 0 ? openApiMetadata.tags : void 0,
1313
+ summary: openApiMetadata.summary,
1314
+ description: openApiMetadata.description,
1315
+ operationId: openApiMetadata.operationId,
1316
+ deprecated: openApiMetadata.deprecated || void 0,
1317
+ externalDocs: openApiMetadata.externalDocs,
1318
+ security: openApiMetadata.security,
1319
+ parameters: this.buildParameters(config),
1320
+ requestBody: this.buildRequestBody(config, handler),
1321
+ responses: this.buildResponses(endpoint)
1322
+ };
1323
+ const cleanOperation = Object.fromEntries(Object.entries(operation).filter(([, v]) => v !== void 0));
1324
+ return {
1325
+ path,
1326
+ pathItem: { [config.method.toLowerCase()]: cleanOperation }
1327
+ };
1328
+ }
1329
+ /**
1330
+ * Converts Navios URL param format ($param) to OpenAPI format ({param})
1331
+ */ convertUrlParams(url) {
1332
+ return url.replace(/\$(\w+)/g, "{$1}");
1333
+ }
1334
+ /**
1335
+ * Extracts URL parameter names from a URL pattern
1336
+ */ extractUrlParamNames(url) {
1337
+ const matches = url.matchAll(/\$(\w+)/g);
1338
+ return Array.from(matches, (m) => m[1]);
1339
+ }
1340
+ /**
1341
+ * Gets the endpoint type based on the adapter token
1342
+ */ getEndpointType(handler) {
1343
+ if (handler.adapterToken === MultipartAdapterToken) return "multipart";
1344
+ if (handler.adapterToken === StreamAdapterToken) return "stream";
1345
+ return "endpoint";
1346
+ }
1347
+ /**
1348
+ * Builds OpenAPI parameters from endpoint config
1349
+ */ buildParameters(config) {
1350
+ const params = [];
1351
+ const urlParams = this.extractUrlParamNames(config.url);
1352
+ for (const param of urlParams) params.push({
1353
+ name: param,
1354
+ in: "path",
1355
+ required: true,
1356
+ schema: { type: "string" }
1357
+ });
1358
+ if (config.querySchema) {
1359
+ const { schema: querySchema } = this.schemaConverter.convert(config.querySchema);
1360
+ const schemaObj = querySchema;
1361
+ if (schemaObj.properties) for (const [name, schema] of Object.entries(schemaObj.properties)) params.push({
1362
+ name,
1363
+ in: "query",
1364
+ required: schemaObj.required?.includes(name) ?? false,
1365
+ schema,
1366
+ description: schema.description
1367
+ });
1368
+ }
1369
+ return params;
1370
+ }
1371
+ /**
1372
+ * Builds request body based on endpoint type
1373
+ */ buildRequestBody(config, handler) {
1374
+ switch (this.getEndpointType(handler)) {
1375
+ case "multipart": return this.buildMultipartRequestBody(config);
1376
+ case "stream": return;
1377
+ case "endpoint":
1378
+ default: return this.buildJsonRequestBody(config);
1379
+ }
1380
+ }
1381
+ /**
1382
+ * Builds request body for JSON endpoints
1383
+ */ buildJsonRequestBody(config) {
1384
+ if (!config.requestSchema) return;
1385
+ const { schema } = this.schemaConverter.convert(config.requestSchema);
1386
+ return {
1387
+ required: true,
1388
+ content: { "application/json": { schema } }
1389
+ };
1390
+ }
1391
+ /**
1392
+ * Builds request body for multipart endpoints
1393
+ */ buildMultipartRequestBody(config) {
1394
+ if (!config.requestSchema) return {
1395
+ required: true,
1396
+ content: { "multipart/form-data": { schema: { type: "object" } } }
1397
+ };
1398
+ const schema = this.schemaConverter.convert(config.requestSchema).schema;
1399
+ const properties = this.schemaConverter.transformFileProperties(schema.properties || {});
1400
+ return {
1401
+ required: true,
1402
+ content: { "multipart/form-data": { schema: {
1403
+ type: "object",
1404
+ properties,
1405
+ required: schema.required
1406
+ } } }
1407
+ };
1408
+ }
1409
+ /**
1410
+ * Builds responses based on endpoint type
1411
+ */ buildResponses(endpoint) {
1412
+ const { config, handler } = endpoint;
1413
+ switch (this.getEndpointType(handler)) {
1414
+ case "stream": return this.buildStreamResponses(endpoint);
1415
+ case "multipart":
1416
+ case "endpoint":
1417
+ default: return this.buildJsonResponses(config, handler);
1418
+ }
1419
+ }
1420
+ /**
1421
+ * Builds responses for JSON endpoints
1422
+ */ buildJsonResponses(config, handler) {
1423
+ const successCode = handler.successStatusCode?.toString() ?? "200";
1424
+ if (!config.responseSchema) return { [successCode]: { description: "Successful response" } };
1425
+ const { schema } = this.schemaConverter.convert(config.responseSchema);
1426
+ return { [successCode]: {
1427
+ description: "Successful response",
1428
+ content: { "application/json": { schema } }
1429
+ } };
1430
+ }
1431
+ /**
1432
+ * Builds responses for stream endpoints
1433
+ */ buildStreamResponses(endpoint) {
1434
+ const { openApiMetadata, handler } = endpoint;
1435
+ const successCode = handler.successStatusCode?.toString() ?? "200";
1436
+ const contentType = openApiMetadata.stream?.contentType ?? "application/octet-stream";
1437
+ const description = openApiMetadata.stream?.description ?? "Stream response";
1438
+ const content = this.getStreamContent(contentType);
1439
+ return { [successCode]: {
1440
+ description,
1441
+ content
1442
+ } };
1443
+ }
1444
+ /**
1445
+ * Gets content object for different stream types
1446
+ */ getStreamContent(contentType) {
1447
+ switch (contentType) {
1448
+ case "text/event-stream": return { "text/event-stream": { schema: {
1449
+ type: "string",
1450
+ description: "Server-Sent Events stream"
1451
+ } } };
1452
+ case "application/octet-stream": return { "application/octet-stream": { schema: {
1453
+ type: "string",
1454
+ format: "binary",
1455
+ description: "Binary file download"
1456
+ } } };
1457
+ case "application/json": return { "application/json": { schema: {
1458
+ type: "string",
1459
+ description: "Newline-delimited JSON stream"
1460
+ } } };
1461
+ default: return { [contentType]: { schema: {
1462
+ type: "string",
1463
+ format: "binary"
1464
+ } } };
1465
+ }
1466
+ }
1467
+ static {
1468
+ _initClass$1();
1469
+ }
1470
+ };
1471
+
1472
+ //#endregion
1473
+ //#region src/services/openapi-generator.service.mts
1474
+ function applyDecs2203RFactory() {
1475
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1476
+ return function addInitializer(initializer) {
1477
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
1478
+ assertCallable(initializer, "An initializer");
1479
+ initializers.push(initializer);
1480
+ };
1481
+ }
1482
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1483
+ var kindStr;
1484
+ switch (kind) {
1485
+ case 1:
1486
+ kindStr = "accessor";
1487
+ break;
1488
+ case 2:
1489
+ kindStr = "method";
1490
+ break;
1491
+ case 3:
1492
+ kindStr = "getter";
1493
+ break;
1494
+ case 4:
1495
+ kindStr = "setter";
1496
+ break;
1497
+ default: kindStr = "field";
1498
+ }
1499
+ var ctx = {
1500
+ kind: kindStr,
1501
+ name: isPrivate ? "#" + name : name,
1502
+ static: isStatic,
1503
+ private: isPrivate,
1504
+ metadata
1505
+ };
1506
+ var decoratorFinishedRef = { v: false };
1507
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1508
+ var get, set;
1509
+ if (kind === 0) if (isPrivate) {
1510
+ get = desc.get;
1511
+ set = desc.set;
1512
+ } else {
1513
+ get = function() {
1514
+ return this[name];
1515
+ };
1516
+ set = function(v) {
1517
+ this[name] = v;
1518
+ };
1519
+ }
1520
+ else if (kind === 2) get = function() {
1521
+ return desc.value;
1522
+ };
1523
+ else {
1524
+ if (kind === 1 || kind === 3) get = function() {
1525
+ return desc.get.call(this);
1526
+ };
1527
+ if (kind === 1 || kind === 4) set = function(v) {
1528
+ desc.set.call(this, v);
1529
+ };
1530
+ }
1531
+ ctx.access = get && set ? {
1532
+ get,
1533
+ set
1534
+ } : get ? { get } : { set };
1535
+ try {
1536
+ return dec(value, ctx);
1537
+ } finally {
1538
+ decoratorFinishedRef.v = true;
1539
+ }
1540
+ }
1541
+ function assertNotFinished(decoratorFinishedRef, fnName) {
1542
+ if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1543
+ }
1544
+ function assertCallable(fn, hint) {
1545
+ if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1546
+ }
1547
+ function assertValidReturnValue(kind, value) {
1548
+ var type = typeof value;
1549
+ if (kind === 1) {
1550
+ if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1551
+ if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1552
+ if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1553
+ if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1554
+ } else if (type !== "function") {
1555
+ var hint;
1556
+ if (kind === 0) hint = "field";
1557
+ else if (kind === 10) hint = "class";
1558
+ else hint = "method";
1559
+ throw new TypeError(hint + " decorators must return a function or void 0");
1560
+ }
1561
+ }
1562
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1563
+ var decs = decInfo[0];
1564
+ var desc, init, value;
1565
+ if (isPrivate) if (kind === 0 || kind === 1) desc = {
1566
+ get: decInfo[3],
1567
+ set: decInfo[4]
1568
+ };
1569
+ else if (kind === 3) desc = { get: decInfo[3] };
1570
+ else if (kind === 4) desc = { set: decInfo[3] };
1571
+ else desc = { value: decInfo[3] };
1572
+ else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1573
+ if (kind === 1) value = {
1574
+ get: desc.get,
1575
+ set: desc.set
1576
+ };
1577
+ else if (kind === 2) value = desc.value;
1578
+ else if (kind === 3) value = desc.get;
1579
+ else if (kind === 4) value = desc.set;
1580
+ var newValue, get, set;
1581
+ if (typeof decs === "function") {
1582
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1583
+ if (newValue !== void 0) {
1584
+ assertValidReturnValue(kind, newValue);
1585
+ if (kind === 0) init = newValue;
1586
+ else if (kind === 1) {
1587
+ init = newValue.init;
1588
+ get = newValue.get || value.get;
1589
+ set = newValue.set || value.set;
1590
+ value = {
1591
+ get,
1592
+ set
1593
+ };
1594
+ } else value = newValue;
1595
+ }
1596
+ } else for (var i = decs.length - 1; i >= 0; i--) {
1597
+ var dec = decs[i];
1598
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1599
+ if (newValue !== void 0) {
1600
+ assertValidReturnValue(kind, newValue);
1601
+ var newInit;
1602
+ if (kind === 0) newInit = newValue;
1603
+ else if (kind === 1) {
1604
+ newInit = newValue.init;
1605
+ get = newValue.get || value.get;
1606
+ set = newValue.set || value.set;
1607
+ value = {
1608
+ get,
1609
+ set
1610
+ };
1611
+ } else value = newValue;
1612
+ if (newInit !== void 0) if (init === void 0) init = newInit;
1613
+ else if (typeof init === "function") init = [init, newInit];
1614
+ else init.push(newInit);
1615
+ }
1616
+ }
1617
+ if (kind === 0 || kind === 1) {
1618
+ if (init === void 0) init = function(instance, init$1) {
1619
+ return init$1;
1620
+ };
1621
+ else if (typeof init !== "function") {
1622
+ var ownInitializers = init;
1623
+ init = function(instance, init$1) {
1624
+ var value$1 = init$1;
1625
+ for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
1626
+ return value$1;
1627
+ };
1628
+ } else {
1629
+ var originalInitializer = init;
1630
+ init = function(instance, init$1) {
1631
+ return originalInitializer.call(instance, init$1);
1632
+ };
1633
+ }
1634
+ ret.push(init);
1635
+ }
1636
+ if (kind !== 0) {
1637
+ if (kind === 1) {
1638
+ desc.get = value.get;
1639
+ desc.set = value.set;
1640
+ } else if (kind === 2) desc.value = value;
1641
+ else if (kind === 3) desc.get = value;
1642
+ else if (kind === 4) desc.set = value;
1643
+ if (isPrivate) if (kind === 1) {
1644
+ ret.push(function(instance, args) {
1645
+ return value.get.call(instance, args);
1646
+ });
1647
+ ret.push(function(instance, args) {
1648
+ return value.set.call(instance, args);
1649
+ });
1650
+ } else if (kind === 2) ret.push(value);
1651
+ else ret.push(function(instance, args) {
1652
+ return value.call(instance, args);
1653
+ });
1654
+ else Object.defineProperty(base, name, desc);
1655
+ }
1656
+ }
1657
+ function applyMemberDecs(Class, decInfos, metadata) {
1658
+ var ret = [];
1659
+ var protoInitializers;
1660
+ var staticInitializers;
1661
+ var existingProtoNonFields = /* @__PURE__ */ new Map();
1662
+ var existingStaticNonFields = /* @__PURE__ */ new Map();
1663
+ for (var i = 0; i < decInfos.length; i++) {
1664
+ var decInfo = decInfos[i];
1665
+ if (!Array.isArray(decInfo)) continue;
1666
+ var kind = decInfo[1];
1667
+ var name = decInfo[2];
1668
+ var isPrivate = decInfo.length > 3;
1669
+ var isStatic = kind >= 5;
1670
+ var base;
1671
+ var initializers;
1672
+ if (isStatic) {
1673
+ base = Class;
1674
+ kind = kind - 5;
1675
+ staticInitializers = staticInitializers || [];
1676
+ initializers = staticInitializers;
1677
+ } else {
1678
+ base = Class.prototype;
1679
+ protoInitializers = protoInitializers || [];
1680
+ initializers = protoInitializers;
1681
+ }
1682
+ if (kind !== 0 && !isPrivate) {
1683
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1684
+ var existingKind = existingNonFields.get(name) || 0;
1685
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
1686
+ else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1687
+ else existingNonFields.set(name, true);
1688
+ }
1689
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1690
+ }
1691
+ pushInitializers(ret, protoInitializers);
1692
+ pushInitializers(ret, staticInitializers);
1693
+ return ret;
1694
+ }
1695
+ function pushInitializers(ret, initializers) {
1696
+ if (initializers) ret.push(function(instance) {
1697
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1698
+ return instance;
1699
+ });
1700
+ }
1701
+ function applyClassDecs(targetClass, classDecs, metadata) {
1702
+ if (classDecs.length > 0) {
1703
+ var initializers = [];
1704
+ var newClass = targetClass;
1705
+ var name = targetClass.name;
1706
+ for (var i = classDecs.length - 1; i >= 0; i--) {
1707
+ var decoratorFinishedRef = { v: false };
1708
+ try {
1709
+ var nextNewClass = classDecs[i](newClass, {
1710
+ kind: "class",
1711
+ name,
1712
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1713
+ metadata
1714
+ });
1715
+ } finally {
1716
+ decoratorFinishedRef.v = true;
1717
+ }
1718
+ if (nextNewClass !== void 0) {
1719
+ assertValidReturnValue(10, nextNewClass);
1720
+ newClass = nextNewClass;
1721
+ }
1722
+ }
1723
+ return [defineMetadata(newClass, metadata), function() {
1724
+ for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
1725
+ }];
1726
+ }
1727
+ }
1728
+ function defineMetadata(Class, metadata) {
1729
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1730
+ configurable: true,
1731
+ enumerable: true,
1732
+ value: metadata
1733
+ });
1734
+ }
1735
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1736
+ if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1737
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1738
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
1739
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
1740
+ return {
1741
+ e,
1742
+ get c() {
1743
+ return applyClassDecs(targetClass, classDecs, metadata);
1744
+ }
1745
+ };
1746
+ };
1747
+ }
1748
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
1749
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
1750
+ }
1751
+ var _dec, _initClass;
1752
+ let _OpenApiGeneratorService;
1753
+ _dec = Injectable();
1754
+ var OpenApiGeneratorService = class {
1755
+ static {
1756
+ ({c: [_OpenApiGeneratorService, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
1757
+ }
1758
+ logger = inject(Logger, { context: _OpenApiGeneratorService.name });
1759
+ scanner = inject(_EndpointScannerService);
1760
+ pathBuilder = inject(_PathBuilderService);
1761
+ /**
1762
+ * Generates an OpenAPI document from loaded modules.
1763
+ *
1764
+ * @param modules - Map of loaded modules
1765
+ * @param options - OpenAPI generation options
1766
+ * @returns Complete OpenAPI document
1767
+ */ generate(modules, options) {
1768
+ this.logger.debug("Generating OpenAPI document");
1769
+ const endpoints = this.scanner.scan(modules);
1770
+ const paths = this.buildPaths(endpoints);
1771
+ const discoveredTags = this.collectTags(endpoints);
1772
+ const tags = this.mergeTags(discoveredTags, options.tags);
1773
+ const document = {
1774
+ openapi: "3.1.0",
1775
+ info: options.info,
1776
+ paths
1777
+ };
1778
+ if (options.servers && options.servers.length > 0) document.servers = options.servers;
1779
+ if (options.externalDocs) document.externalDocs = options.externalDocs;
1780
+ if (tags.length > 0) document.tags = tags;
1781
+ if (options.security) document.security = options.security;
1782
+ if (options.securitySchemes) document.components = {
1783
+ ...document.components,
1784
+ securitySchemes: options.securitySchemes
1785
+ };
1786
+ this.logger.debug(`Generated OpenAPI document with ${Object.keys(paths).length} paths`);
1787
+ return document;
1788
+ }
1789
+ /**
1790
+ * Builds paths object from discovered endpoints
1791
+ */ buildPaths(endpoints) {
1792
+ const paths = {};
1793
+ for (const endpoint of endpoints) {
1794
+ const { path, pathItem } = this.pathBuilder.build(endpoint);
1795
+ if (paths[path]) paths[path] = {
1796
+ ...paths[path],
1797
+ ...pathItem
1798
+ };
1799
+ else paths[path] = pathItem;
1800
+ }
1801
+ return paths;
1802
+ }
1803
+ /**
1804
+ * Collects unique tags from endpoints
1805
+ */ collectTags(endpoints) {
1806
+ const tags = /* @__PURE__ */ new Set();
1807
+ for (const endpoint of endpoints) for (const tag of endpoint.openApiMetadata.tags) tags.add(tag);
1808
+ return tags;
1809
+ }
1810
+ /**
1811
+ * Merges discovered tags with configured tags
1812
+ */ mergeTags(discoveredTags, configuredTags) {
1813
+ const tagMap = /* @__PURE__ */ new Map();
1814
+ if (configuredTags) for (const tag of configuredTags) tagMap.set(tag.name, tag);
1815
+ for (const tagName of discoveredTags) if (!tagMap.has(tagName)) tagMap.set(tagName, { name: tagName });
1816
+ return Array.from(tagMap.values());
1817
+ }
1818
+ static {
1819
+ _initClass();
1820
+ }
1821
+ };
1822
+
1823
+ //#endregion
1824
+ export { _MetadataExtractorService as a, ApiOperationToken as c, ApiSummaryToken as d, ApiTagToken as f, _EndpointScannerService as i, ApiSecurityToken as l, _PathBuilderService as n, ApiDeprecatedToken as o, _SchemaConverterService as r, ApiExcludeToken as s, _OpenApiGeneratorService as t, ApiStreamToken as u };
1825
+ //# sourceMappingURL=services-MFCyRMd8.mjs.map