@visulima/jsdoc-open-api 2.0.91 → 2.0.93

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.
@@ -0,0 +1,1205 @@
1
+ import { parse } from 'comment-parser';
2
+ import mergeWith from 'lodash.mergewith';
3
+ import { readFileSync } from 'fs';
4
+ import path from 'path';
5
+ import yaml from 'yaml';
6
+ import { createRequire } from 'module';
7
+ import SwaggerParser from '@apidevtools/swagger-parser';
8
+
9
+ // src/jsdoc/comments-to-open-api.ts
10
+
11
+ // src/util/customizer.ts
12
+ var customizer = (objectValue, sourceValue) => {
13
+ if (Array.isArray(objectValue)) {
14
+ return [...objectValue, ...sourceValue];
15
+ }
16
+ return void 0;
17
+ };
18
+ var customizer_default = customizer;
19
+
20
+ // src/jsdoc/comments-to-open-api.ts
21
+ var fixSecurityObject = (thing) => {
22
+ if (thing.security) {
23
+ thing.security = Object.keys(thing.security).map((s) => {
24
+ return {
25
+ [s]: thing.security[s]
26
+ };
27
+ });
28
+ }
29
+ };
30
+ var primitiveTypes = /* @__PURE__ */ new Set(["array", "boolean", "integer", "number", "object", "string"]);
31
+ var formatMap = {
32
+ binary: "string",
33
+ byte: "string",
34
+ date: "string",
35
+ "date-time": "string",
36
+ double: "number",
37
+ float: "number",
38
+ int32: "integer",
39
+ int64: "integer",
40
+ password: "string"
41
+ };
42
+ var parseDescription = (tag) => {
43
+ const rawType = tag.type;
44
+ const isArray = rawType.endsWith("[]");
45
+ const parsedType = rawType.replace(/\[]$/, "");
46
+ const isPrimitive = primitiveTypes.has(parsedType);
47
+ const isFormat = Object.keys(formatMap).includes(parsedType);
48
+ let defaultValue;
49
+ if (tag.default) {
50
+ switch (parsedType) {
51
+ case "double":
52
+ case "float":
53
+ case "number": {
54
+ defaultValue = Number.parseFloat(tag.default);
55
+ break;
56
+ }
57
+ case "int32":
58
+ case "int64":
59
+ case "integer": {
60
+ defaultValue = Number.parseInt(tag.default, 10);
61
+ break;
62
+ }
63
+ default: {
64
+ defaultValue = tag.default;
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ let rootType;
70
+ if (isPrimitive) {
71
+ rootType = { default: defaultValue, type: parsedType };
72
+ } else if (isFormat) {
73
+ rootType = {
74
+ default: defaultValue,
75
+ format: parsedType,
76
+ type: formatMap[parsedType]
77
+ };
78
+ } else {
79
+ rootType = { $ref: `#/components/schemas/${parsedType}` };
80
+ }
81
+ let schema = isArray ? {
82
+ items: {
83
+ ...rootType
84
+ },
85
+ type: "array"
86
+ } : {
87
+ ...rootType
88
+ };
89
+ if (parsedType === "") {
90
+ schema = void 0;
91
+ }
92
+ let description = tag.description.trim().replace(/^- /u, "");
93
+ if (description === "") {
94
+ description = void 0;
95
+ }
96
+ return {
97
+ description,
98
+ name: tag.name,
99
+ rawType,
100
+ required: !tag.optional,
101
+ schema
102
+ };
103
+ };
104
+ var tagsToObjects = (tags, verbose) => tags.map((tag) => {
105
+ const parsedResponse = parseDescription(tag);
106
+ let nameAndDescription = "";
107
+ if (parsedResponse.name) {
108
+ nameAndDescription += parsedResponse.name;
109
+ }
110
+ if (parsedResponse.description) {
111
+ nameAndDescription += ` ${parsedResponse.description.trim()}`;
112
+ }
113
+ switch (tag.tag) {
114
+ case "bodyComponent": {
115
+ return {
116
+ requestBody: {
117
+ $ref: `#/components/requestBodies/${parsedResponse.rawType}`
118
+ }
119
+ };
120
+ }
121
+ case "bodyContent": {
122
+ return {
123
+ requestBody: {
124
+ content: {
125
+ [parsedResponse.name.replace(String.raw`*\/*`, "*/*")]: {
126
+ schema: parsedResponse.schema
127
+ }
128
+ }
129
+ }
130
+ };
131
+ }
132
+ case "bodyDescription": {
133
+ return { requestBody: { description: nameAndDescription } };
134
+ }
135
+ case "bodyExample": {
136
+ const [contentType, example] = parsedResponse.name.split(".");
137
+ return {
138
+ requestBody: {
139
+ content: {
140
+ [contentType]: {
141
+ examples: {
142
+ [example]: {
143
+ $ref: `#/components/examples/${parsedResponse.rawType}`
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ };
150
+ }
151
+ case "bodyRequired": {
152
+ return { requestBody: { required: true } };
153
+ }
154
+ case "callback": {
155
+ return {
156
+ callbacks: {
157
+ [parsedResponse.name]: {
158
+ $ref: `#/components/callbacks/${parsedResponse.rawType}`
159
+ }
160
+ }
161
+ };
162
+ }
163
+ case "cookieParam":
164
+ case "headerParam":
165
+ case "pathParam":
166
+ case "queryParam": {
167
+ return {
168
+ parameters: [
169
+ {
170
+ description: parsedResponse.description,
171
+ in: tag.tag.replace(/Param$/u, ""),
172
+ name: parsedResponse.name,
173
+ required: parsedResponse.required,
174
+ schema: parsedResponse.schema
175
+ }
176
+ ]
177
+ };
178
+ }
179
+ case "deprecated": {
180
+ return { deprecated: true };
181
+ }
182
+ case "description":
183
+ case "operationId":
184
+ case "summary": {
185
+ return { [tag.tag]: nameAndDescription };
186
+ }
187
+ case "externalDocs": {
188
+ return {
189
+ externalDocs: {
190
+ description: parsedResponse.description,
191
+ url: parsedResponse.name
192
+ }
193
+ };
194
+ }
195
+ case "paramComponent": {
196
+ return {
197
+ parameters: [{ $ref: `#/components/parameters/${parsedResponse.rawType}` }]
198
+ };
199
+ }
200
+ case "response": {
201
+ return {
202
+ responses: {
203
+ [parsedResponse.name]: {
204
+ description: parsedResponse.description
205
+ }
206
+ }
207
+ };
208
+ }
209
+ case "responseComponent": {
210
+ return {
211
+ responses: {
212
+ [parsedResponse.name]: {
213
+ $ref: `#/components/responses/${parsedResponse.rawType}`
214
+ }
215
+ }
216
+ };
217
+ }
218
+ case "responseContent": {
219
+ const [status, contentType] = parsedResponse.name.split(".");
220
+ return {
221
+ responses: {
222
+ [status]: {
223
+ content: {
224
+ [contentType]: {
225
+ schema: parsedResponse.schema
226
+ }
227
+ }
228
+ }
229
+ }
230
+ };
231
+ }
232
+ case "responseExample": {
233
+ const [status, contentType, example] = parsedResponse.name.split(".");
234
+ return {
235
+ responses: {
236
+ [status]: {
237
+ content: {
238
+ [contentType]: {
239
+ examples: {
240
+ [example]: {
241
+ $ref: `#/components/examples/${parsedResponse.rawType}`
242
+ }
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ };
249
+ }
250
+ case "responseHeader": {
251
+ const [status, header] = parsedResponse.name.split(".");
252
+ return {
253
+ responses: {
254
+ [status]: {
255
+ headers: {
256
+ [header]: {
257
+ description: parsedResponse.description,
258
+ schema: parsedResponse.schema
259
+ }
260
+ }
261
+ }
262
+ }
263
+ };
264
+ }
265
+ case "responseHeaderComponent": {
266
+ const [status, header] = parsedResponse.name.split(".");
267
+ return {
268
+ responses: {
269
+ [status]: {
270
+ headers: {
271
+ [header]: {
272
+ $ref: `#/components/headers/${parsedResponse.rawType}`
273
+ }
274
+ }
275
+ }
276
+ }
277
+ };
278
+ }
279
+ case "responseLink": {
280
+ const [status, link] = parsedResponse.name.split(".");
281
+ return {
282
+ responses: {
283
+ [status]: {
284
+ links: {
285
+ [link]: {
286
+ $ref: `#/components/links/${parsedResponse.rawType}`
287
+ }
288
+ }
289
+ }
290
+ }
291
+ };
292
+ }
293
+ case "security": {
294
+ const [security, scopeItem] = parsedResponse.name.split(".");
295
+ let scope = [];
296
+ if (scopeItem) {
297
+ scope = [scopeItem];
298
+ }
299
+ return {
300
+ security: { [security]: scope }
301
+ };
302
+ }
303
+ case "server": {
304
+ return {
305
+ servers: [
306
+ {
307
+ description: parsedResponse.description,
308
+ url: parsedResponse.name
309
+ }
310
+ ]
311
+ };
312
+ }
313
+ case "tag": {
314
+ return { tags: [nameAndDescription] };
315
+ }
316
+ default: {
317
+ return {};
318
+ }
319
+ }
320
+ });
321
+ var commentsToOpenApi = (fileContents, verbose) => {
322
+ const openAPIRegex = /^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/;
323
+ const jsDocumentComments = parse(fileContents, { spacing: "preserve" });
324
+ return jsDocumentComments.filter((comment) => openAPIRegex.test(comment.description.trim())).map((comment) => {
325
+ const loc = comment.tags.length + 1;
326
+ const result = mergeWith({}, ...tagsToObjects(comment.tags), customizer_default);
327
+ fixSecurityObject(result);
328
+ const [method, path2] = comment.description.split(" ");
329
+ const pathsObject = {
330
+ [path2.trim()]: {
331
+ [method.toLowerCase().trim()]: {
332
+ ...result
333
+ }
334
+ }
335
+ };
336
+ const spec = JSON.parse(JSON.stringify({ paths: pathsObject }));
337
+ return {
338
+ loc,
339
+ spec
340
+ };
341
+ });
342
+ };
343
+ var comments_to_open_api_default = commentsToOpenApi;
344
+
345
+ // src/util/yaml-loc.ts
346
+ var yamlLoc = (string) => {
347
+ const split = string.split(/\r\n|\r|\n/u);
348
+ const filtered = split.filter((line) => {
349
+ if (/^\s*(#\s*(?:\S.*)?)?$/u.test(line)) {
350
+ return false;
351
+ }
352
+ return line.trim().length > 0;
353
+ });
354
+ return filtered.length;
355
+ };
356
+ var yaml_loc_default = yamlLoc;
357
+ var ALLOWED_KEYS = /* @__PURE__ */ new Set(["components", "externalDocs", "info", "openapi", "paths", "security", "servers", "tags"]);
358
+ var ParseError = class extends Error {
359
+ filePath;
360
+ };
361
+ var parseFile = (file, commentsToOpenApi3, verbose) => {
362
+ const fileContent = readFileSync(file, { encoding: "utf8" });
363
+ const extension = path.extname(file);
364
+ if (extension === ".yaml" || extension === ".yml") {
365
+ const spec = yaml.parse(fileContent);
366
+ const invalidKeys = Object.keys(spec).filter((key) => !ALLOWED_KEYS.has(key));
367
+ if (invalidKeys.length > 0) {
368
+ const error = new ParseError(`Unexpected keys: ${invalidKeys.join(", ")}`);
369
+ error.filePath = file;
370
+ throw error;
371
+ }
372
+ if (Object.keys(spec).some((key) => ALLOWED_KEYS.has(key))) {
373
+ const loc = yaml_loc_default(fileContent);
374
+ return [{ loc, spec }];
375
+ }
376
+ return [];
377
+ }
378
+ try {
379
+ return commentsToOpenApi3(fileContent, verbose);
380
+ } catch (error) {
381
+ error.filePath = file;
382
+ throw error;
383
+ }
384
+ };
385
+ var parse_file_default = parseFile;
386
+
387
+ // src/util/object-merge.ts
388
+ var objectMerge = (a, b) => {
389
+ Object.keys(b).forEach((key) => {
390
+ if (a[key] === void 0) {
391
+ a[key] = {
392
+ ...b[key]
393
+ };
394
+ } else {
395
+ Object.keys(b[key]).forEach((subKey) => {
396
+ a[key][subKey] = {
397
+ ...a[key][subKey],
398
+ ...b[key][subKey]
399
+ };
400
+ });
401
+ }
402
+ });
403
+ };
404
+ var object_merge_default = objectMerge;
405
+
406
+ // src/spec-builder.ts
407
+ var SpecBuilder = class {
408
+ components;
409
+ externalDocs;
410
+ info;
411
+ openapi;
412
+ paths;
413
+ security;
414
+ servers;
415
+ tags;
416
+ constructor(baseDefinition) {
417
+ this.openapi = baseDefinition.openapi;
418
+ this.info = baseDefinition.info;
419
+ this.paths = baseDefinition.paths ?? {};
420
+ if (baseDefinition.servers) {
421
+ this.servers = baseDefinition.servers;
422
+ }
423
+ if (baseDefinition.components) {
424
+ this.components = baseDefinition.components;
425
+ }
426
+ if (baseDefinition.security) {
427
+ this.security = baseDefinition.security;
428
+ }
429
+ if (baseDefinition.tags) {
430
+ this.tags = baseDefinition.tags;
431
+ }
432
+ if (baseDefinition.externalDocs) {
433
+ this.externalDocs = baseDefinition.externalDocs;
434
+ }
435
+ }
436
+ addData(parsedFile) {
437
+ parsedFile.forEach((file) => {
438
+ const { components, paths, ...rest } = file;
439
+ object_merge_default(this, {
440
+ components: components ?? {},
441
+ paths: paths ?? {}
442
+ });
443
+ Object.entries(rest).forEach(([key, value]) => {
444
+ this[key] = value;
445
+ });
446
+ });
447
+ }
448
+ };
449
+ var spec_builder_default = SpecBuilder;
450
+ var mergeDeep = (first, second) => mergeWith({}, first, second, (a, b) => b === null ? a : void 0);
451
+ var hasEmptyProperty = (object) => Object.keys(object).map((key) => object[key]).every((keyObject) => typeof keyObject === "object" && Object.keys(keyObject).every((key) => !(key in keyObject)));
452
+ var isTagPresentInTags = (tag, tags) => tags.some((targetTag) => tag.name === targetTag.name);
453
+ var getSwaggerVersionFromSpec = (tag) => {
454
+ switch (tag.tag) {
455
+ case "asyncapi": {
456
+ return "v4";
457
+ }
458
+ case "openapi": {
459
+ return "v3";
460
+ }
461
+ case "swagger": {
462
+ return "v2";
463
+ }
464
+ default: {
465
+ return "v2";
466
+ }
467
+ }
468
+ };
469
+
470
+ // src/swagger-jsdoc/organize-swagger-object.ts
471
+ var organizeSwaggerObject = (swaggerObject, annotation, property) => {
472
+ if (property === "x-webhooks") {
473
+ swaggerObject[property] = annotation[property];
474
+ }
475
+ if (property.startsWith("x-")) {
476
+ return;
477
+ }
478
+ const commonProperties = [
479
+ "components",
480
+ "consumes",
481
+ "produces",
482
+ "paths",
483
+ "schemas",
484
+ "securityDefinitions",
485
+ "responses",
486
+ "parameters",
487
+ "definitions",
488
+ "channels"
489
+ ];
490
+ if (commonProperties.includes(property)) {
491
+ Object.keys(annotation[property]).forEach((definition) => {
492
+ swaggerObject[property][definition] = mergeDeep(swaggerObject[property][definition], annotation[property][definition]);
493
+ });
494
+ } else if (property === "tags") {
495
+ const { tags } = annotation;
496
+ if (Array.isArray(tags)) {
497
+ tags.forEach((tag) => {
498
+ if (!isTagPresentInTags(tag, swaggerObject.tags)) {
499
+ swaggerObject.tags.push(tag);
500
+ }
501
+ });
502
+ } else if (!isTagPresentInTags(tags, swaggerObject.tags)) {
503
+ swaggerObject.tags.push(tags);
504
+ }
505
+ } else if (property === "security") {
506
+ const { security } = annotation;
507
+ swaggerObject.security = security;
508
+ } else if (property.startsWith("/")) {
509
+ swaggerObject.paths[property] = mergeDeep(swaggerObject.paths[property], annotation[property]);
510
+ }
511
+ };
512
+ var organize_swagger_object_default = organizeSwaggerObject;
513
+
514
+ // src/swagger-jsdoc/comments-to-open-api.ts
515
+ var specificationTemplate = {
516
+ v2: ["paths", "definitions", "responses", "parameters", "securityDefinitions"],
517
+ v3: ["paths", "definitions", "responses", "parameters", "securityDefinitions", "components"],
518
+ v4: ["components", "channels"]
519
+ };
520
+ var tagsToObjects2 = (specs, verbose) => specs.map((spec) => {
521
+ if ((spec.tag === "openapi" || spec.tag === "swagger" || spec.tag === "asyncapi") && spec.description !== "") {
522
+ const parsed = yaml.parseDocument(spec.description);
523
+ if (parsed.errors.length > 0) {
524
+ parsed.errors.map((error) => {
525
+ const newError = error;
526
+ newError.annotation = spec.description;
527
+ return newError;
528
+ });
529
+ let errorString = "Error parsing YAML in @openapi spec:";
530
+ errorString += verbose ? parsed.errors.map(
531
+ (error) => `${error.toString()}
532
+ Imbedded within:
533
+ \`\`\`
534
+ ${error.annotation?.replaceAll("\n", "\n ")}
535
+ \`\`\``
536
+ ).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
537
+ throw new Error(errorString);
538
+ }
539
+ const parsedDocument = parsed.toJSON();
540
+ const specification = {
541
+ tags: []
542
+ };
543
+ specificationTemplate[getSwaggerVersionFromSpec(spec)].forEach((property) => {
544
+ specification[property] = specification[property] || {};
545
+ });
546
+ Object.keys(parsedDocument).forEach((property) => {
547
+ organize_swagger_object_default(specification, parsedDocument, property);
548
+ });
549
+ return specification;
550
+ }
551
+ return {};
552
+ });
553
+ var commentsToOpenApi2 = (fileContents, verbose) => {
554
+ const jsDocumentComments = parse(fileContents, { spacing: "preserve" });
555
+ return jsDocumentComments.map((comment) => {
556
+ const loc = comment.tags.length + 1;
557
+ const result = mergeWith({}, ...tagsToObjects2(comment.tags, verbose), customizer_default);
558
+ ["definitions", "responses", "parameters", "securityDefinitions", "components", "tags"].forEach((property) => {
559
+ if (result[property] !== void 0 && hasEmptyProperty(result[property])) {
560
+ delete result[property];
561
+ }
562
+ });
563
+ const spec = JSON.parse(JSON.stringify(result));
564
+ return {
565
+ loc,
566
+ spec
567
+ };
568
+ });
569
+ };
570
+ var comments_to_open_api_default2 = commentsToOpenApi2;
571
+
572
+ // ../path/dist/packem_shared/path-CR6YkPXX.js
573
+ var DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
574
+ var normalizeWindowsPath = (input = "") => {
575
+ if (!input) {
576
+ return input;
577
+ }
578
+ return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
579
+ };
580
+ var UNC_REGEX = /^[/\\]{2}/;
581
+ var IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
582
+ var DRIVE_LETTER_RE = /^[A-Z]:$/i;
583
+ var cwd = () => {
584
+ if (typeof process.cwd === "function") {
585
+ return process.cwd().replaceAll("\\", "/");
586
+ }
587
+ return "/";
588
+ };
589
+ /^win/i.test(globalThis.process?.platform) ? ";" : ":";
590
+ var normalizeString = (path2, allowAboveRoot) => {
591
+ let result = "";
592
+ let lastSegmentLength = 0;
593
+ let lastSlash = -1;
594
+ let dots = 0;
595
+ let char;
596
+ for (let index = 0; index <= path2.length; ++index) {
597
+ if (index < path2.length) {
598
+ char = path2[index];
599
+ } else if (char === "/") {
600
+ break;
601
+ } else {
602
+ char = "/";
603
+ }
604
+ if (char === "/") {
605
+ if (lastSlash === index - 1 || dots === 1) ;
606
+ else if (dots === 2) {
607
+ if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
608
+ if (result.length > 2) {
609
+ const lastSlashIndex = result.lastIndexOf("/");
610
+ if (lastSlashIndex === -1) {
611
+ result = "";
612
+ lastSegmentLength = 0;
613
+ } else {
614
+ result = result.slice(0, lastSlashIndex);
615
+ lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
616
+ }
617
+ lastSlash = index;
618
+ dots = 0;
619
+ continue;
620
+ } else if (result.length > 0) {
621
+ result = "";
622
+ lastSegmentLength = 0;
623
+ lastSlash = index;
624
+ dots = 0;
625
+ continue;
626
+ }
627
+ }
628
+ if (allowAboveRoot) {
629
+ result += result.length > 0 ? "/.." : "..";
630
+ lastSegmentLength = 2;
631
+ }
632
+ } else {
633
+ if (result.length > 0) {
634
+ result += `/${path2.slice(lastSlash + 1, index)}`;
635
+ } else {
636
+ result = path2.slice(lastSlash + 1, index);
637
+ }
638
+ lastSegmentLength = index - lastSlash - 1;
639
+ }
640
+ lastSlash = index;
641
+ dots = 0;
642
+ } else if (char === "." && dots !== -1) {
643
+ ++dots;
644
+ } else {
645
+ dots = -1;
646
+ }
647
+ }
648
+ return result;
649
+ };
650
+ var isAbsolute = (path2) => IS_ABSOLUTE_RE.test(path2);
651
+ var normalize = function(path2) {
652
+ if (path2.length === 0) {
653
+ return ".";
654
+ }
655
+ path2 = normalizeWindowsPath(path2);
656
+ const isUNCPath = UNC_REGEX.exec(path2);
657
+ const isPathAbsolute = isAbsolute(path2);
658
+ const trailingSeparator = path2.at(-1) === "/";
659
+ path2 = normalizeString(path2, !isPathAbsolute);
660
+ if (path2.length === 0) {
661
+ if (isPathAbsolute) {
662
+ return "/";
663
+ }
664
+ return trailingSeparator ? "./" : ".";
665
+ }
666
+ if (trailingSeparator) {
667
+ path2 += "/";
668
+ }
669
+ if (DRIVE_LETTER_RE.test(path2)) {
670
+ path2 += "/";
671
+ }
672
+ if (isUNCPath) {
673
+ if (!isPathAbsolute) {
674
+ return `//./${path2}`;
675
+ }
676
+ return `//${path2}`;
677
+ }
678
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
679
+ };
680
+ var join = (...segments) => {
681
+ let path2 = "";
682
+ for (const seg of segments) {
683
+ if (!seg) {
684
+ continue;
685
+ }
686
+ if (path2.length > 0) {
687
+ const pathTrailing = path2[path2.length - 1] === "/";
688
+ const segLeading = seg[0] === "/";
689
+ const both = pathTrailing && segLeading;
690
+ if (both) {
691
+ path2 += seg.slice(1);
692
+ } else {
693
+ path2 += pathTrailing || segLeading ? seg : `/${seg}`;
694
+ }
695
+ } else {
696
+ path2 += seg;
697
+ }
698
+ }
699
+ return normalize(path2);
700
+ };
701
+ var resolve = function(...arguments_) {
702
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
703
+ let resolvedPath = "";
704
+ let resolvedAbsolute = false;
705
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
706
+ const path2 = index >= 0 ? arguments_[index] : cwd();
707
+ if (!path2 || path2.length === 0) {
708
+ continue;
709
+ }
710
+ resolvedPath = `${path2}/${resolvedPath}`;
711
+ resolvedAbsolute = isAbsolute(path2);
712
+ }
713
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
714
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
715
+ return `/${resolvedPath}`;
716
+ }
717
+ return resolvedPath.length > 0 ? resolvedPath : ".";
718
+ };
719
+ var basename = (path2, extension) => {
720
+ const lastSegment = normalizeWindowsPath(path2).split("/").pop();
721
+ return lastSegment;
722
+ };
723
+ var __cjs_require = createRequire(import.meta.url);
724
+ var __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
725
+ var __cjs_getBuiltinModule = (module) => {
726
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
727
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
728
+ if (major > 22 || major === 22 && minor >= 3 || major === 20 && minor >= 16) {
729
+ return __cjs_getProcess.getBuiltinModule(module);
730
+ }
731
+ }
732
+ return __cjs_require(module);
733
+ };
734
+ var {
735
+ fileURLToPath
736
+ } = __cjs_getBuiltinModule("node:url");
737
+ function getDefaultExportFromCjs(x) {
738
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
739
+ }
740
+ var binaryExtensions$1;
741
+ var hasRequiredBinaryExtensions;
742
+ function requireBinaryExtensions() {
743
+ if (hasRequiredBinaryExtensions) return binaryExtensions$1;
744
+ hasRequiredBinaryExtensions = 1;
745
+ binaryExtensions$1 = [
746
+ "3dm",
747
+ "3ds",
748
+ "3g2",
749
+ "3gp",
750
+ "7z",
751
+ "a",
752
+ "aac",
753
+ "adp",
754
+ "afdesign",
755
+ "afphoto",
756
+ "afpub",
757
+ "ai",
758
+ "aif",
759
+ "aiff",
760
+ "alz",
761
+ "ape",
762
+ "apk",
763
+ "appimage",
764
+ "ar",
765
+ "arj",
766
+ "asf",
767
+ "au",
768
+ "avi",
769
+ "bak",
770
+ "baml",
771
+ "bh",
772
+ "bin",
773
+ "bk",
774
+ "bmp",
775
+ "btif",
776
+ "bz2",
777
+ "bzip2",
778
+ "cab",
779
+ "caf",
780
+ "cgm",
781
+ "class",
782
+ "cmx",
783
+ "cpio",
784
+ "cr2",
785
+ "cr3",
786
+ "cur",
787
+ "dat",
788
+ "dcm",
789
+ "deb",
790
+ "dex",
791
+ "djvu",
792
+ "dll",
793
+ "dmg",
794
+ "dng",
795
+ "doc",
796
+ "docm",
797
+ "docx",
798
+ "dot",
799
+ "dotm",
800
+ "dra",
801
+ "DS_Store",
802
+ "dsk",
803
+ "dts",
804
+ "dtshd",
805
+ "dvb",
806
+ "dwg",
807
+ "dxf",
808
+ "ecelp4800",
809
+ "ecelp7470",
810
+ "ecelp9600",
811
+ "egg",
812
+ "eol",
813
+ "eot",
814
+ "epub",
815
+ "exe",
816
+ "f4v",
817
+ "fbs",
818
+ "fh",
819
+ "fla",
820
+ "flac",
821
+ "flatpak",
822
+ "fli",
823
+ "flv",
824
+ "fpx",
825
+ "fst",
826
+ "fvt",
827
+ "g3",
828
+ "gh",
829
+ "gif",
830
+ "graffle",
831
+ "gz",
832
+ "gzip",
833
+ "h261",
834
+ "h263",
835
+ "h264",
836
+ "icns",
837
+ "ico",
838
+ "ief",
839
+ "img",
840
+ "ipa",
841
+ "iso",
842
+ "jar",
843
+ "jpeg",
844
+ "jpg",
845
+ "jpgv",
846
+ "jpm",
847
+ "jxr",
848
+ "key",
849
+ "ktx",
850
+ "lha",
851
+ "lib",
852
+ "lvp",
853
+ "lz",
854
+ "lzh",
855
+ "lzma",
856
+ "lzo",
857
+ "m3u",
858
+ "m4a",
859
+ "m4v",
860
+ "mar",
861
+ "mdi",
862
+ "mht",
863
+ "mid",
864
+ "midi",
865
+ "mj2",
866
+ "mka",
867
+ "mkv",
868
+ "mmr",
869
+ "mng",
870
+ "mobi",
871
+ "mov",
872
+ "movie",
873
+ "mp3",
874
+ "mp4",
875
+ "mp4a",
876
+ "mpeg",
877
+ "mpg",
878
+ "mpga",
879
+ "mxu",
880
+ "nef",
881
+ "npx",
882
+ "numbers",
883
+ "nupkg",
884
+ "o",
885
+ "odp",
886
+ "ods",
887
+ "odt",
888
+ "oga",
889
+ "ogg",
890
+ "ogv",
891
+ "otf",
892
+ "ott",
893
+ "pages",
894
+ "pbm",
895
+ "pcx",
896
+ "pdb",
897
+ "pdf",
898
+ "pea",
899
+ "pgm",
900
+ "pic",
901
+ "png",
902
+ "pnm",
903
+ "pot",
904
+ "potm",
905
+ "potx",
906
+ "ppa",
907
+ "ppam",
908
+ "ppm",
909
+ "pps",
910
+ "ppsm",
911
+ "ppsx",
912
+ "ppt",
913
+ "pptm",
914
+ "pptx",
915
+ "psd",
916
+ "pya",
917
+ "pyc",
918
+ "pyo",
919
+ "pyv",
920
+ "qt",
921
+ "rar",
922
+ "ras",
923
+ "raw",
924
+ "resources",
925
+ "rgb",
926
+ "rip",
927
+ "rlc",
928
+ "rmf",
929
+ "rmvb",
930
+ "rpm",
931
+ "rtf",
932
+ "rz",
933
+ "s3m",
934
+ "s7z",
935
+ "scpt",
936
+ "sgi",
937
+ "shar",
938
+ "snap",
939
+ "sil",
940
+ "sketch",
941
+ "slk",
942
+ "smv",
943
+ "snk",
944
+ "so",
945
+ "stl",
946
+ "suo",
947
+ "sub",
948
+ "swf",
949
+ "tar",
950
+ "tbz",
951
+ "tbz2",
952
+ "tga",
953
+ "tgz",
954
+ "thmx",
955
+ "tif",
956
+ "tiff",
957
+ "tlz",
958
+ "ttc",
959
+ "ttf",
960
+ "txz",
961
+ "udf",
962
+ "uvh",
963
+ "uvi",
964
+ "uvm",
965
+ "uvp",
966
+ "uvs",
967
+ "uvu",
968
+ "viv",
969
+ "vob",
970
+ "war",
971
+ "wav",
972
+ "wax",
973
+ "wbmp",
974
+ "wdp",
975
+ "weba",
976
+ "webm",
977
+ "webp",
978
+ "whl",
979
+ "wim",
980
+ "wm",
981
+ "wma",
982
+ "wmv",
983
+ "wmx",
984
+ "woff",
985
+ "woff2",
986
+ "wrm",
987
+ "wvx",
988
+ "xbm",
989
+ "xif",
990
+ "xla",
991
+ "xlam",
992
+ "xls",
993
+ "xlsb",
994
+ "xlsm",
995
+ "xlsx",
996
+ "xlt",
997
+ "xltm",
998
+ "xltx",
999
+ "xm",
1000
+ "xmind",
1001
+ "xpi",
1002
+ "xpm",
1003
+ "xwd",
1004
+ "xz",
1005
+ "z",
1006
+ "zip",
1007
+ "zipx"
1008
+ ];
1009
+ return binaryExtensions$1;
1010
+ }
1011
+ var binaryExtensionsExports = /* @__PURE__ */ requireBinaryExtensions();
1012
+ var binaryExtensions = /* @__PURE__ */ getDefaultExportFromCjs(binaryExtensionsExports);
1013
+ new Set(binaryExtensions);
1014
+ var toPath = (urlOrPath) => normalizeWindowsPath(urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath);
1015
+
1016
+ // ../fs/dist/packem_shared/WalkError-DUdQd6FT.js
1017
+ var WalkError = class extends Error {
1018
+ /** File path of the root that's being walked. */
1019
+ root;
1020
+ /**
1021
+ * Constructs a new instance.
1022
+ * @param cause The underlying error or reason for the walk failure.
1023
+ * @param root The root directory path where the walk operation started or encountered the error.
1024
+ */
1025
+ constructor(cause, root) {
1026
+ super(`${cause instanceof Error ? cause.message : cause} for path "${root}"`);
1027
+ this.cause = cause;
1028
+ this.root = root;
1029
+ }
1030
+ // eslint-disable-next-line class-methods-use-this
1031
+ get name() {
1032
+ return "WalkError";
1033
+ }
1034
+ // eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
1035
+ set name(_name) {
1036
+ throw new Error("Cannot overwrite name of WalkError");
1037
+ }
1038
+ };
1039
+
1040
+ // ../fs/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js
1041
+ var assertValidFileOrDirectoryPath = (fileOrDirectoryPath) => {
1042
+ if (!fileOrDirectoryPath || !(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== "string") {
1043
+ throw new TypeError("Path must be a non-empty string or URL.");
1044
+ }
1045
+ };
1046
+
1047
+ // ../fs/dist/packem_shared/walk-include-CZco7BvN.js
1048
+ var globToRegExp = (glob) => {
1049
+ const reString = glob.replace(/\.\*/g, ".([^/]*)").replace(/\*\*/g, "(.*)").replace(/(?<!\.)\*(?!\*)/g, "([^/]*)").replace(/\?/g, "[^/]").replace(/\.(?!\*)/g, String.raw`\.`).replace(/\{/g, "(").replace(/\}/g, ")").replace(/,/g, "|").replace(/\[!(.*?)\]/g, "[^$1]");
1050
+ return new RegExp(`^${reString}$`);
1051
+ };
1052
+ var walkInclude = (path2, extensions2, match, skip) => {
1053
+ if (Array.isArray(extensions2) && extensions2.length > 0 && !extensions2.some((extension) => path2.endsWith(extension))) {
1054
+ return false;
1055
+ }
1056
+ if (match && !match.some((pattern) => pattern.test(path2))) {
1057
+ return false;
1058
+ }
1059
+ return !skip?.some((pattern) => pattern.test(path2));
1060
+ };
1061
+
1062
+ // ../fs/dist/packem_shared/walk-BhTbpr3y.js
1063
+ var __cjs_require2 = createRequire(import.meta.url);
1064
+ var __cjs_getProcess2 = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
1065
+ var __cjs_getBuiltinModule2 = (module) => {
1066
+ if (typeof __cjs_getProcess2 !== "undefined" && __cjs_getProcess2.versions && __cjs_getProcess2.versions.node) {
1067
+ const [major, minor] = __cjs_getProcess2.versions.node.split(".").map(Number);
1068
+ if (major > 22 || major === 22 && minor >= 3 || major === 20 && minor >= 16) {
1069
+ return __cjs_getProcess2.getBuiltinModule(module);
1070
+ }
1071
+ }
1072
+ return __cjs_require2(module);
1073
+ };
1074
+ var {
1075
+ readdir,
1076
+ realpath,
1077
+ stat
1078
+ } = __cjs_getBuiltinModule2("node:fs/promises");
1079
+ var _createWalkEntry = async (path2) => {
1080
+ const normalizePath = normalize(path2);
1081
+ const name = basename(normalizePath);
1082
+ const info = await stat(normalizePath);
1083
+ return {
1084
+ isDirectory: () => info.isDirectory(),
1085
+ isFile: () => info.isFile(),
1086
+ isSymbolicLink: () => info.isSymbolicLink(),
1087
+ name,
1088
+ path: normalizePath
1089
+ };
1090
+ };
1091
+ async function* walk(directory, {
1092
+ extensions: extensions2,
1093
+ followSymlinks = false,
1094
+ includeDirs: includeDirectories = true,
1095
+ includeFiles = true,
1096
+ includeSymlinks = true,
1097
+ match,
1098
+ maxDepth = Number.POSITIVE_INFINITY,
1099
+ skip
1100
+ } = {}) {
1101
+ assertValidFileOrDirectoryPath(directory);
1102
+ if (maxDepth < 0) {
1103
+ return;
1104
+ }
1105
+ const mappedMatch = match ? match.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
1106
+ const mappedSkip = skip ? skip.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
1107
+ directory = resolve(toPath(directory));
1108
+ if (includeDirectories && walkInclude(directory, extensions2, mappedMatch, mappedSkip)) {
1109
+ yield await _createWalkEntry(directory);
1110
+ }
1111
+ if (maxDepth < 1 || !walkInclude(directory, void 0, void 0, mappedSkip)) {
1112
+ return;
1113
+ }
1114
+ try {
1115
+ for await (const entry of await readdir(directory, {
1116
+ withFileTypes: true
1117
+ })) {
1118
+ let path2 = join(directory, entry.name);
1119
+ if (entry.isSymbolicLink()) {
1120
+ if (followSymlinks) {
1121
+ path2 = await realpath(path2);
1122
+ } else if (includeSymlinks && walkInclude(path2, extensions2, mappedMatch, mappedSkip)) {
1123
+ yield {
1124
+ isDirectory: entry.isDirectory,
1125
+ isFile: entry.isFile,
1126
+ isSymbolicLink: entry.isSymbolicLink,
1127
+ name: entry.name,
1128
+ path: path2
1129
+ };
1130
+ } else {
1131
+ continue;
1132
+ }
1133
+ }
1134
+ if (entry.isSymbolicLink() || entry.isDirectory()) {
1135
+ yield* walk(path2, {
1136
+ extensions: extensions2,
1137
+ followSymlinks,
1138
+ includeDirs: includeDirectories,
1139
+ includeFiles,
1140
+ includeSymlinks,
1141
+ match: mappedMatch,
1142
+ maxDepth: maxDepth - 1,
1143
+ skip: mappedSkip
1144
+ });
1145
+ } else if (entry.isFile() && includeFiles && walkInclude(path2, extensions2, mappedMatch, mappedSkip)) {
1146
+ yield {
1147
+ isDirectory: () => entry.isDirectory(),
1148
+ isFile: () => entry.isFile(),
1149
+ isSymbolicLink: () => entry.isSymbolicLink(),
1150
+ name: entry.name,
1151
+ path: path2
1152
+ };
1153
+ }
1154
+ }
1155
+ } catch (error) {
1156
+ if (error instanceof WalkError) {
1157
+ throw error;
1158
+ }
1159
+ throw new WalkError(error, directory);
1160
+ }
1161
+ }
1162
+
1163
+ // ../fs/dist/packem_shared/collect-DcBwsYYd.js
1164
+ var collect = async (directory, options = {}) => {
1165
+ if (!Array.isArray(options.extensions)) {
1166
+ options.extensions = ["js", "mjs", "cjs", "ts"];
1167
+ }
1168
+ const entries = [];
1169
+ for await (const entry of walk(directory, options)) {
1170
+ entries.push(entry.path);
1171
+ }
1172
+ return entries;
1173
+ };
1174
+
1175
+ // src/constants.ts
1176
+ var DEFAULT_EXCLUDE = [
1177
+ "coverage/**",
1178
+ ".github/**",
1179
+ "**/*.d.ts",
1180
+ "**/test{,s}/**",
1181
+ "**/test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}",
1182
+ "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}",
1183
+ "**/__tests__/**",
1184
+ "**/{ava,babel,nyc}.config.{js,cjs,mjs}",
1185
+ "**/jest.config.{js,cjs,mjs,ts}",
1186
+ "**/{karma,rollup,webpack}.config.js",
1187
+ "**/.{eslint,mocha}rc.{js,cjs}",
1188
+ "**/.{travis,yarnrc}.yml",
1189
+ "**/{docker-compose,docker}.yml",
1190
+ "**/.yamllint.{yaml,yml}",
1191
+ "**/node_modules/**",
1192
+ "**/{pnpm-workspace,pnpm-lock}.yaml",
1193
+ "**/{package,package-lock}.json",
1194
+ "**/yarn.lock",
1195
+ "**/package.json5",
1196
+ "**/.next/**"
1197
+ ];
1198
+ var validate = async (spec) => {
1199
+ await SwaggerParser.validate(spec);
1200
+ };
1201
+ var validate_default = validate;
1202
+
1203
+ export { DEFAULT_EXCLUDE, collect, comments_to_open_api_default, comments_to_open_api_default2, parse_file_default, spec_builder_default, validate_default, yaml_loc_default };
1204
+ //# sourceMappingURL=chunk-WUINTXB7.mjs.map
1205
+ //# sourceMappingURL=chunk-WUINTXB7.mjs.map