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