@visulima/jsdoc-open-api 2.0.91 → 2.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,106 @@
1
- 'use strict';var chunkONOVCJ6W_js=require('./chunk-ONOVCJ6W.js'),fs=require('fs'),path=require('path'),process=require('process');var D=i=>{i&&(console.error(i),process.exit(1));},u=class{assetsPath;ignore;sources;swaggerDefinition;verbose;constructor(t,n,h,s){this.assetsPath=t,this.swaggerDefinition=h,this.sources=n,this.verbose=s.verbose??false,this.ignore=s.ignore??[];}apply(t){let n=new Set([...chunkONOVCJ6W_js.g,...this.ignore]);t.hooks.make.tapAsync("SwaggerCompilerPlugin",async(h,s)=>{console.log("Build paused, switching to swagger build");let o=new chunkONOVCJ6W_js.d(this.swaggerDefinition);for await(let e of this.sources){let a=await chunkONOVCJ6W_js.f(e,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:false,skip:[...n]});this.verbose&&(console.log(`Found ${String(a.length)} files in ${e}`),console.log(a)),a.forEach(l=>{this.verbose&&console.log(`Parsing file ${l}`);try{let p=chunkONOVCJ6W_js.c(l,chunkONOVCJ6W_js.a,this.verbose);o.addData(p.map(c=>c.spec));let x=chunkONOVCJ6W_js.c(l,chunkONOVCJ6W_js.e,this.verbose);o.addData(x.map(c=>c.spec));}catch(p){console.error(p),process.exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(o,null,2))),await chunkONOVCJ6W_js.h(JSON.parse(JSON.stringify(o)));}catch(e){console.error(e.toJSON()),process.exit(1);}let{assetsPath:y}=this;fs.mkdir(path.dirname(y),{recursive:true},e=>{e&&D(e),fs.writeFile(y,JSON.stringify(o,null,2),D);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),s();});}},j=u;Object.defineProperty(exports,"SpecBuilder",{enumerable:true,get:function(){return chunkONOVCJ6W_js.d}});Object.defineProperty(exports,"jsDocumentCommentsToOpenApi",{enumerable:true,get:function(){return chunkONOVCJ6W_js.a}});Object.defineProperty(exports,"parseFile",{enumerable:true,get:function(){return chunkONOVCJ6W_js.c}});Object.defineProperty(exports,"swaggerJsDocumentCommentsToOpenApi",{enumerable:true,get:function(){return chunkONOVCJ6W_js.e}});Object.defineProperty(exports,"yamlLoc",{enumerable:true,get:function(){return chunkONOVCJ6W_js.b}});exports.SwaggerCompilerPlugin=j;//# sourceMappingURL=index.js.map
1
+ 'use strict';
2
+
3
+ var chunkSSKZBPTT_js = require('./chunk-SSKZBPTT.js');
4
+ var fs = require('fs');
5
+ var path = require('path');
6
+ var process = require('process');
7
+
8
+ var errorHandler = (error) => {
9
+ if (error) {
10
+ console.error(error);
11
+ process.exit(1);
12
+ }
13
+ };
14
+ var SwaggerCompilerPlugin = class {
15
+ assetsPath;
16
+ ignore;
17
+ sources;
18
+ swaggerDefinition;
19
+ verbose;
20
+ constructor(assetsPath, sources, swaggerDefinition, options) {
21
+ this.assetsPath = assetsPath;
22
+ this.swaggerDefinition = swaggerDefinition;
23
+ this.sources = sources;
24
+ this.verbose = options.verbose ?? false;
25
+ this.ignore = options.ignore ?? [];
26
+ }
27
+ apply(compiler) {
28
+ const skip = /* @__PURE__ */ new Set([...chunkSSKZBPTT_js.DEFAULT_EXCLUDE, ...this.ignore]);
29
+ compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
30
+ console.log("Build paused, switching to swagger build");
31
+ const spec = new chunkSSKZBPTT_js.spec_builder_default(this.swaggerDefinition);
32
+ for await (const dir of this.sources) {
33
+ const files = await chunkSSKZBPTT_js.collect(dir, {
34
+ extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
35
+ includeDirs: false,
36
+ skip: [...skip]
37
+ });
38
+ if (this.verbose) {
39
+ console.log(`Found ${String(files.length)} files in ${dir}`);
40
+ console.log(files);
41
+ }
42
+ files.forEach((file) => {
43
+ if (this.verbose) {
44
+ console.log(`Parsing file ${file}`);
45
+ }
46
+ try {
47
+ const parsedJsDocumentFile = chunkSSKZBPTT_js.parse_file_default(file, chunkSSKZBPTT_js.comments_to_open_api_default, this.verbose);
48
+ spec.addData(parsedJsDocumentFile.map((item) => item.spec));
49
+ const parsedSwaggerJsDocumentFile = chunkSSKZBPTT_js.parse_file_default(file, chunkSSKZBPTT_js.comments_to_open_api_default2, this.verbose);
50
+ spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));
51
+ } catch (error) {
52
+ console.error(error);
53
+ process.exit(1);
54
+ }
55
+ });
56
+ }
57
+ try {
58
+ if (this.verbose) {
59
+ console.log("Validating swagger spec");
60
+ console.log(JSON.stringify(spec, null, 2));
61
+ }
62
+ await chunkSSKZBPTT_js.validate_default(JSON.parse(JSON.stringify(spec)));
63
+ } catch (error) {
64
+ console.error(error.toJSON());
65
+ process.exit(1);
66
+ }
67
+ const { assetsPath } = this;
68
+ fs.mkdir(path.dirname(assetsPath), { recursive: true }, (error) => {
69
+ if (error) {
70
+ errorHandler(error);
71
+ }
72
+ fs.writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
73
+ });
74
+ if (this.verbose) {
75
+ console.log(`Written swagger spec to "${this.assetsPath}" file`);
76
+ }
77
+ console.log("switching back to normal build");
78
+ callback();
79
+ });
80
+ }
81
+ };
82
+ var swagger_compiler_plugin_default = SwaggerCompilerPlugin;
83
+
84
+ Object.defineProperty(exports, "SpecBuilder", {
85
+ enumerable: true,
86
+ get: function () { return chunkSSKZBPTT_js.spec_builder_default; }
87
+ });
88
+ Object.defineProperty(exports, "jsDocumentCommentsToOpenApi", {
89
+ enumerable: true,
90
+ get: function () { return chunkSSKZBPTT_js.comments_to_open_api_default; }
91
+ });
92
+ Object.defineProperty(exports, "parseFile", {
93
+ enumerable: true,
94
+ get: function () { return chunkSSKZBPTT_js.parse_file_default; }
95
+ });
96
+ Object.defineProperty(exports, "swaggerJsDocumentCommentsToOpenApi", {
97
+ enumerable: true,
98
+ get: function () { return chunkSSKZBPTT_js.comments_to_open_api_default2; }
99
+ });
100
+ Object.defineProperty(exports, "yamlLoc", {
101
+ enumerable: true,
102
+ get: function () { return chunkSSKZBPTT_js.yaml_loc_default; }
103
+ });
104
+ exports.SwaggerCompilerPlugin = swagger_compiler_plugin_default;
105
+ //# sourceMappingURL=index.js.map
2
106
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["errorHandler","error","exit","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","skip","DEFAULT_EXCLUDE","_","callback","spec","spec_builder_default","dir","files","l","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwaggerJsDocumentFile","validate_default","mkdir","dirname","writeFile","swagger_compiler_plugin_default"],"mappings":"sIAeMA,CAAAA,CAAgBC,CAAAA,EAAe,CAC7BA,CAAAA,GAEA,OAAA,CAAQ,KAAA,CAAMA,CAAK,CAAA,CAEnBC,aAAK,CAAC,CAAA,EAEd,CAAA,CAEMC,CAAAA,CAAN,KAA4B,CACP,UAAA,CAEA,MAAA,CAEA,OAAA,CAEA,kBAEA,OAAA,CAEV,WAAA,CACHC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAIF,CACE,IAAA,CAAK,WAAaH,CAAAA,CAClB,IAAA,CAAK,iBAAA,CAAoBE,CAAAA,CACzB,KAAK,OAAA,CAAUD,CAAAA,CACf,IAAA,CAAK,OAAA,CAAUE,EAAQ,OAAA,EAAW,KAAA,CAClC,IAAA,CAAK,MAAA,CAASA,CAAAA,CAAQ,MAAA,EAAU,GACpC,CAEO,KAAA,CAAMC,CAAAA,CAA0B,CACnC,IAAMC,EAAO,IAAI,GAAA,CAAqB,CAAC,GAAGC,mBAAiB,GAAG,IAAA,CAAK,MAAM,CAAC,CAAA,CAE1EF,CAA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AAI,CAAC,EACrE,CAAA,MAASrB,CAAAA,CAAO,CAEZ,OAAA,CAAQ,MAAMA,CAAK,CAAA,CAEnBC,YAAAA,CAAK,CAAC,EACV,CACJ,CAAC,EACL,CAEA,GAAI,CACI,IAAA,CAAK,OAAA,GAEL,QAAQ,GAAA,CAAI,yBAAyB,CAAA,CAErC,OAAA,CAAQ,IAAI,IAAA,CAAK,SAAA,CAAUW,CAAAA,CAAM,IAAA,CAAM,CAAC,CAAC,CAAA,CAAA,CAG7C,MAAMW,kBAAAA,CAAS,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAUX,CAAI,CAAC,CAAC,EACnD,CAAA,MAASZ,EAAY,CAEjB,OAAA,CAAQ,KAAA,CAAMA,CAAAA,CAAM,QAAQ,CAAA,CAE5BC,YAAAA,CAAK,CAAC,EACV,CAEA,GAAM,CAAE,WAAAE,CAAW,CAAA,CAAI,IAAA,CAGvBqB,QAAAA,CAAMC,aAAQtB,CAAU,CAAA,CAAG,CAAE,SAAA,CAAW,IAAK,CAAA,CAAIH,CAAAA,EAAU,CACnDA,CAAAA,EACAD,CAAAA,CAAaC,CAAK,CAAA,CAItB0B,YAAAA,CAAUvB,EAAY,IAAA,CAAK,SAAA,CAAUS,CAAAA,CAAM,IAAA,CAAM,CAAC,CAAA,CAAGb,CAAY,EACrE,CAAC,EAEG,IAAA,CAAK,OAAA,EAEL,OAAA,CAAQ,GAAA,CAAI,CAAA,yBAAA,EAA4B,IAAA,CAAK,UAAU,CAAA,MAAA,CAAQ,EAInE,OAAA,CAAQ,GAAA,CAAI,gCAAgC,CAAA,CAE5CY,IACJ,CAAC,EACL,CACJ,EAEOgB,CAAAA,CAAQzB","file":"index.js","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/fs\";\nimport type { Compiler } from \"webpack\";\n\nimport { DEFAULT_EXCLUDE } from \"../constants\";\nimport type { BaseDefinition } from \"../exported\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: (RegExp | string)[];\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: (RegExp | string)[];\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n const skip = new Set<RegExp | string>([...DEFAULT_EXCLUDE, ...this.ignore]);\n\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files: string[] = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n skip: [...skip],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${String(files.length)} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
1
+ {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["exit","DEFAULT_EXCLUDE","spec_builder_default","collect","parse_file_default","comments_to_open_api_default","validate_default","mkdir","dirname","writeFile"],"mappings":";;;;;;;AAeA,IAAM,YAAA,GAAe,CAAC,KAAA,KAAe;AACjC,EAAA,IAAI,KAAA,EAAO;AAEP,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAEnB,IAAAA,YAAA,CAAK,CAAC,CAAA;AAAA,EACV;AACJ,CAAA;AAEA,IAAM,wBAAN,MAA4B;AAAA,EACP,UAAA;AAAA,EAEA,MAAA;AAAA,EAEA,OAAA;AAAA,EAEA,iBAAA;AAAA,EA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MACV;AAEA,MAAA,MAAM,EAAE,YAAW,GAAI,IAAA;AAGvB,MAAAO,QAAA,CAAMC,YAAA,CAAQ,UAAU,CAAA,EAAG,EAAE,WAAW,IAAA,EAAK,EAAG,CAAC,KAAA,KAAU;AACvD,QAAA,IAAI,KAAA,EAAO;AACP,UAAA,YAAA,CAAa,KAAK,CAAA;AAAA,QACtB;AAGA,QAAAC,YAAA,CAAU,YAAY,IAAA,CAAK,SAAA,CAAU,MAAM,IAAA,EAAM,CAAC,GAAG,YAAY,CAAA;AAAA,MACrE,CAAC,CAAA;AAED,MAAA,IAAI,KAAK,OAAA,EAAS;AAEd,QAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,yBAAA,EAA4B,IAAA,CAAK,UAAU,CAAA,MAAA,CAAQ,CAAA;AAAA,MACnE;AAGA,MAAA,OAAA,CAAQ,IAAI,gCAAgC,CAAA;AAE5C,MAAA,QAAA,EAAS;AAAA,IACb,CAAC,CAAA;AAAA,EACL;AACJ,CAAA;AAEA,IAAO,+BAAA,GAAQ","file":"index.js","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/fs\";\nimport type { Compiler } from \"webpack\";\n\nimport { DEFAULT_EXCLUDE } from \"../constants\";\nimport type { BaseDefinition } from \"../exported\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: (RegExp | string)[];\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: (RegExp | string)[];\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n const skip = new Set<RegExp | string>([...DEFAULT_EXCLUDE, ...this.ignore]);\n\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files: string[] = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n skip: [...skip],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${String(files.length)} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,85 @@
1
- import {g,d,f,c,a,e,h}from'./chunk-4JHXGXFZ.mjs';export{d as SpecBuilder,a as jsDocumentCommentsToOpenApi,c as parseFile,e as swaggerJsDocumentCommentsToOpenApi,b as yamlLoc}from'./chunk-4JHXGXFZ.mjs';import {mkdir,writeFile}from'fs';import {dirname}from'path';import {exit}from'process';var D=i=>{i&&(console.error(i),exit(1));},u=class{assetsPath;ignore;sources;swaggerDefinition;verbose;constructor(t,n,h,s){this.assetsPath=t,this.swaggerDefinition=h,this.sources=n,this.verbose=s.verbose??false,this.ignore=s.ignore??[];}apply(t){let n=new Set([...g,...this.ignore]);t.hooks.make.tapAsync("SwaggerCompilerPlugin",async(h$1,s)=>{console.log("Build paused, switching to swagger build");let o=new d(this.swaggerDefinition);for await(let e$1 of this.sources){let a$1=await f(e$1,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:false,skip:[...n]});this.verbose&&(console.log(`Found ${String(a$1.length)} files in ${e$1}`),console.log(a$1)),a$1.forEach(l=>{this.verbose&&console.log(`Parsing file ${l}`);try{let p=c(l,a,this.verbose);o.addData(p.map(c=>c.spec));let x=c(l,e,this.verbose);o.addData(x.map(c=>c.spec));}catch(p){console.error(p),exit(1);}});}try{this.verbose&&(console.log("Validating swagger spec"),console.log(JSON.stringify(o,null,2))),await h(JSON.parse(JSON.stringify(o)));}catch(e){console.error(e.toJSON()),exit(1);}let{assetsPath:y}=this;mkdir(dirname(y),{recursive:true},e=>{e&&D(e),writeFile(y,JSON.stringify(o,null,2),D);}),this.verbose&&console.log(`Written swagger spec to "${this.assetsPath}" file`),console.log("switching back to normal build"),s();});}},k=u;export{k as SwaggerCompilerPlugin};//# sourceMappingURL=index.mjs.map
1
+ import { DEFAULT_EXCLUDE, spec_builder_default, collect, parse_file_default, comments_to_open_api_default, comments_to_open_api_default2, validate_default } from './chunk-WUINTXB7.mjs';
2
+ export { spec_builder_default as SpecBuilder, comments_to_open_api_default as jsDocumentCommentsToOpenApi, parse_file_default as parseFile, comments_to_open_api_default2 as swaggerJsDocumentCommentsToOpenApi, yaml_loc_default as yamlLoc } from './chunk-WUINTXB7.mjs';
3
+ import { mkdir, writeFile } from 'fs';
4
+ import { dirname } from 'path';
5
+ import { exit } from 'process';
6
+
7
+ var errorHandler = (error) => {
8
+ if (error) {
9
+ console.error(error);
10
+ exit(1);
11
+ }
12
+ };
13
+ var SwaggerCompilerPlugin = class {
14
+ assetsPath;
15
+ ignore;
16
+ sources;
17
+ swaggerDefinition;
18
+ verbose;
19
+ constructor(assetsPath, sources, swaggerDefinition, options) {
20
+ this.assetsPath = assetsPath;
21
+ this.swaggerDefinition = swaggerDefinition;
22
+ this.sources = sources;
23
+ this.verbose = options.verbose ?? false;
24
+ this.ignore = options.ignore ?? [];
25
+ }
26
+ apply(compiler) {
27
+ const skip = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE, ...this.ignore]);
28
+ compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
29
+ console.log("Build paused, switching to swagger build");
30
+ const spec = new spec_builder_default(this.swaggerDefinition);
31
+ for await (const dir of this.sources) {
32
+ const files = await collect(dir, {
33
+ extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
34
+ includeDirs: false,
35
+ skip: [...skip]
36
+ });
37
+ if (this.verbose) {
38
+ console.log(`Found ${String(files.length)} files in ${dir}`);
39
+ console.log(files);
40
+ }
41
+ files.forEach((file) => {
42
+ if (this.verbose) {
43
+ console.log(`Parsing file ${file}`);
44
+ }
45
+ try {
46
+ const parsedJsDocumentFile = parse_file_default(file, comments_to_open_api_default, this.verbose);
47
+ spec.addData(parsedJsDocumentFile.map((item) => item.spec));
48
+ const parsedSwaggerJsDocumentFile = parse_file_default(file, comments_to_open_api_default2, this.verbose);
49
+ spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));
50
+ } catch (error) {
51
+ console.error(error);
52
+ exit(1);
53
+ }
54
+ });
55
+ }
56
+ try {
57
+ if (this.verbose) {
58
+ console.log("Validating swagger spec");
59
+ console.log(JSON.stringify(spec, null, 2));
60
+ }
61
+ await validate_default(JSON.parse(JSON.stringify(spec)));
62
+ } catch (error) {
63
+ console.error(error.toJSON());
64
+ exit(1);
65
+ }
66
+ const { assetsPath } = this;
67
+ mkdir(dirname(assetsPath), { recursive: true }, (error) => {
68
+ if (error) {
69
+ errorHandler(error);
70
+ }
71
+ writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
72
+ });
73
+ if (this.verbose) {
74
+ console.log(`Written swagger spec to "${this.assetsPath}" file`);
75
+ }
76
+ console.log("switching back to normal build");
77
+ callback();
78
+ });
79
+ }
80
+ };
81
+ var swagger_compiler_plugin_default = SwaggerCompilerPlugin;
82
+
83
+ export { swagger_compiler_plugin_default as SwaggerCompilerPlugin };
84
+ //# sourceMappingURL=index.mjs.map
2
85
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["errorHandler","error","exit","SwaggerCompilerPlugin","assetsPath","sources","swaggerDefinition","options","compiler","skip","DEFAULT_EXCLUDE","_","callback","spec","spec_builder_default","dir","files","l","file","parsedJsDocumentFile","parse_file_default","comments_to_open_api_default","item","parsedSwagg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AAM,CAAE,WAAAE,CAAW,CAAA,CAAI,IAAA,CAGvBqB,KAAAA,CAAMC,QAAQtB,CAAU,CAAA,CAAG,CAAE,SAAA,CAAW,IAAK,CAAA,CAAIH,CAAAA,EAAU,CACnDA,CAAAA,EACAD,CAAAA,CAAaC,CAAK,CAAA,CAItB0B,SAAAA,CAAUvB,EAAY,IAAA,CAAK,SAAA,CAAUS,CAAAA,CAAM,IAAA,CAAM,CAAC,CAAA,CAAGb,CAAY,EACrE,CAAC,EAEG,IAAA,CAAK,OAAA,EAEL,OAAA,CAAQ,GAAA,CAAI,CAAA,yBAAA,EAA4B,IAAA,CAAK,UAAU,CAAA,MAAA,CAAQ,EAInE,OAAA,CAAQ,GAAA,CAAI,gCAAgC,CAAA,CAE5CY,IACJ,CAAC,EACL,CACJ,EAEOgB,CAAAA,CAAQzB","file":"index.mjs","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/fs\";\nimport type { Compiler } from \"webpack\";\n\nimport { DEFAULT_EXCLUDE } from \"../constants\";\nimport type { BaseDefinition } from \"../exported\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: (RegExp | string)[];\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: (RegExp | string)[];\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n const skip = new Set<RegExp | string>([...DEFAULT_EXCLUDE, ...this.ignore]);\n\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files: string[] = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n skip: [...skip],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${String(files.length)} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
1
+ {"version":3,"sources":["../src/webpack/swagger-compiler-plugin.ts"],"names":["comments_to_open_api_default"],"mappings":";;;;;;AAeA,IAAM,YAAA,GAAe,CAAC,KAAA,KAAe;AACjC,EAAA,IAAI,KAAA,EAAO;AAEP,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAEnB,IAAA,IAAA,CAAK,CAAC,CAAA;AAAA,EACV;AACJ,CAAA;AAEA,IAAM,wBAAN,MAA4B;AAAA,EACP,UAAA;AAAA,EAEA,MAAA;AAAA,EAEA,OAAA;AAAA,EAEA,iBAAA;AAAA,EAEA,OAAA;AAAA,EAEV,WAAA,CACH,UAAA,EACA,OAAA,EACA,iBAAA,EACA,OAAA,EAIF;AACE,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,iBAAA,GAAoB,iBAAA;AACzB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,QAAQ,OAAA,IAAW,KAAA;AAClC,IAAA,IAAA,CAAK,MAAA,GAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAAA,EACrC;AAAA,EAEO,MAAM,QAAA,EAA0B;AACnC,IAAA,MAAM,IAAA,uBAAW,GAAA,CAAqB,CAAC,GAAG,eAAA,EAAiB,GAAG,IAAA,CAAK,MAAM,CAAC,CAAA;AAE1E,IAAA,QAAA,CAAS,MAAM,IAAA,CAAK,QAAA,CAAS,uBAAA,EAAyB,OAAO,GAAG,QAAA,KAA0C;AAEtG,MAAA,OA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CAAA;AAEA,IAAO,+BAAA,GAAQ","file":"index.mjs","sourcesContent":["import { mkdir, writeFile } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { exit } from \"node:process\";\n\nimport { collect } from \"@visulima/fs\";\nimport type { Compiler } from \"webpack\";\n\nimport { DEFAULT_EXCLUDE } from \"../constants\";\nimport type { BaseDefinition } from \"../exported\";\nimport jsDocumentCommentsToOpenApi from \"../jsdoc/comments-to-open-api\";\nimport parseFile from \"../parse-file\";\nimport SpecBuilder from \"../spec-builder\";\nimport swaggerJsDocumentCommentsToOpenApi from \"../swagger-jsdoc/comments-to-open-api\";\nimport validate from \"../validate\";\n\nconst errorHandler = (error: any) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n};\n\nclass SwaggerCompilerPlugin {\n private readonly assetsPath: string;\n\n private readonly ignore: (RegExp | string)[];\n\n private readonly sources: string[];\n\n private readonly swaggerDefinition: BaseDefinition;\n\n private readonly verbose: boolean;\n\n public constructor(\n assetsPath: string,\n sources: string[],\n swaggerDefinition: BaseDefinition,\n options: {\n ignore?: (RegExp | string)[];\n verbose?: boolean;\n },\n ) {\n this.assetsPath = assetsPath;\n this.swaggerDefinition = swaggerDefinition;\n this.sources = sources;\n this.verbose = options.verbose ?? false;\n this.ignore = options.ignore ?? [];\n }\n\n public apply(compiler: Compiler): void {\n const skip = new Set<RegExp | string>([...DEFAULT_EXCLUDE, ...this.ignore]);\n\n compiler.hooks.make.tapAsync(\"SwaggerCompilerPlugin\", async (_, callback: VoidFunction): Promise<void> => {\n // eslint-disable-next-line no-console\n console.log(\"Build paused, switching to swagger build\");\n\n const spec = new SpecBuilder(this.swaggerDefinition);\n\n // eslint-disable-next-line unicorn/prevent-abbreviations,no-loops/no-loops\n for await (const dir of this.sources) {\n const files: string[] = await collect(dir, {\n extensions: [\".js\", \".cjs\", \".mjs\", \".ts\", \".tsx\", \".jsx\", \".yaml\", \".yml\"],\n includeDirs: false,\n skip: [...skip],\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Found ${String(files.length)} files in ${dir}`);\n // eslint-disable-next-line no-console\n console.log(files);\n }\n\n files.forEach((file) => {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Parsing file ${file}`);\n }\n\n try {\n const parsedJsDocumentFile = parseFile(file, jsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedJsDocumentFile.map((item) => item.spec));\n\n const parsedSwaggerJsDocumentFile = parseFile(file, swaggerJsDocumentCommentsToOpenApi, this.verbose);\n\n spec.addData(parsedSwaggerJsDocumentFile.map((item) => item.spec));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n\n exit(1);\n }\n });\n }\n\n try {\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(\"Validating swagger spec\");\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(spec, null, 2));\n }\n\n await validate(JSON.parse(JSON.stringify(spec)));\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(error.toJSON());\n\n exit(1);\n }\n\n const { assetsPath } = this;\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n mkdir(dirname(assetsPath), { recursive: true }, (error) => {\n if (error) {\n errorHandler(error);\n }\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);\n });\n\n if (this.verbose) {\n // eslint-disable-next-line no-console\n console.log(`Written swagger spec to \"${this.assetsPath}\" file`);\n }\n\n // eslint-disable-next-line no-console\n console.log(\"switching back to normal build\");\n\n callback();\n });\n }\n}\n\nexport default SwaggerCompilerPlugin;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/jsdoc-open-api",
3
- "version": "2.0.91",
3
+ "version": "2.0.92",
4
4
  "description": "Generates swagger doc based on JSDoc.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -1,11 +0,0 @@
1
- import {parse}from'comment-parser';import Ir from'lodash.mergewith';import {readFileSync}from'fs';import Zr from'path';import Kr from'yaml';import {createRequire}from'module';import tn from'@apidevtools/swagger-parser';var Mr=(e,t)=>{if(Array.isArray(e))return [...e,...t]},re=Mr;var Wr=e=>{e.security&&(e.security=Object.keys(e.security).map(t=>({[t]:e.security[t]})));},qr=new Set(["array","boolean","integer","number","object","string"]),Ie={binary:"string",byte:"string",date:"string","date-time":"string",double:"number",float:"number",int32:"integer",int64:"integer",password:"string"},Br=e=>{let t=e.type,n=t.endsWith("[]"),o=t.replace(/\[]$/,""),p=qr.has(o),u=Object.keys(Ie).includes(o),d;if(e.default)switch(o){case "double":case "float":case "number":{d=Number.parseFloat(e.default);break}case "int32":case "int64":case "integer":{d=Number.parseInt(e.default,10);break}default:{d=e.default;break}}let f;p?f={default:d,type:o}:u?f={default:d,format:o,type:Ie[o]}:f={$ref:`#/components/schemas/${o}`};let w=n?{items:{...f},type:"array"}:{...f};o===""&&(w=void 0);let S=e.description.trim().replace(/^- /u,"");return S===""&&(S=void 0),{description:S,name:e.name,rawType:t,required:!e.optional,schema:w}},Nr=(e,t)=>e.map(n=>{let o=Br(n),p="";switch(o.name&&(p+=o.name),o.description&&(p+=` ${o.description.trim()}`),n.tag){case "bodyComponent":return {requestBody:{$ref:`#/components/requestBodies/${o.rawType}`}};case "bodyContent":return {requestBody:{content:{[o.name.replace(String.raw`*\/*`,"*/*")]:{schema:o.schema}}}};case "bodyDescription":return {requestBody:{description:p}};case "bodyExample":{let[u,d]=o.name.split(".");return {requestBody:{content:{[u]:{examples:{[d]:{$ref:`#/components/examples/${o.rawType}`}}}}}}}case "bodyRequired":return {requestBody:{required:true}};case "callback":return {callbacks:{[o.name]:{$ref:`#/components/callbacks/${o.rawType}`}}};case "cookieParam":case "headerParam":case "pathParam":case "queryParam":return {parameters:[{description:o.description,in:n.tag.replace(/Param$/u,""),name:o.name,required:o.required,schema:o.schema}]};case "deprecated":return {deprecated:true};case "description":case "operationId":case "summary":return {[n.tag]:p};case "externalDocs":return {externalDocs:{description:o.description,url:o.name}};case "paramComponent":return {parameters:[{$ref:`#/components/parameters/${o.rawType}`}]};case "response":return {responses:{[o.name]:{description:o.description}}};case "responseComponent":return {responses:{[o.name]:{$ref:`#/components/responses/${o.rawType}`}}};case "responseContent":{let[u,d]=o.name.split(".");return {responses:{[u]:{content:{[d]:{schema:o.schema}}}}}}case "responseExample":{let[u,d,f]=o.name.split(".");return {responses:{[u]:{content:{[d]:{examples:{[f]:{$ref:`#/components/examples/${o.rawType}`}}}}}}}}case "responseHeader":{let[u,d]=o.name.split(".");return {responses:{[u]:{headers:{[d]:{description:o.description,schema:o.schema}}}}}}case "responseHeaderComponent":{let[u,d]=o.name.split(".");return {responses:{[u]:{headers:{[d]:{$ref:`#/components/headers/${o.rawType}`}}}}}}case "responseLink":{let[u,d]=o.name.split(".");return {responses:{[u]:{links:{[d]:{$ref:`#/components/links/${o.rawType}`}}}}}}case "security":{let[u,d]=o.name.split("."),f=[];return d&&(f=[d]),{security:{[u]:f}}}case "server":return {servers:[{description:o.description,url:o.name}]};case "tag":return {tags:[p]};default:return {}}}),Ur=(e,t)=>{let n=/^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/;return parse(e,{spacing:"preserve"}).filter(p=>n.test(p.description.trim())).map(p=>{let u=p.tags.length+1,d=Ir({},...Nr(p.tags),re);Wr(d);let[f,w]=p.description.split(" "),S={[w.trim()]:{[f.toLowerCase().trim()]:{...d}}},T=JSON.parse(JSON.stringify({paths:S}));return {loc:u,spec:T}})},pn=Ur;var Yr=e=>e.split(/\r\n|\r|\n/u).filter(o=>/^\s*(#\s*(?:\S.*)?)?$/u.test(o)?false:o.trim().length>0).length,We=Yr;var qe=new Set(["components","externalDocs","info","openapi","paths","security","servers","tags"]),ue=class extends Error{filePath},Gr=(e,t,n)=>{let o=readFileSync(e,{encoding:"utf8"}),p=Zr.extname(e);if(p===".yaml"||p===".yml"){let u=Kr.parse(o),d=Object.keys(u).filter(f=>!qe.has(f));if(d.length>0){let f=new ue(`Unexpected keys: ${d.join(", ")}`);throw f.filePath=e,f}return Object.keys(u).some(f=>qe.has(f))?[{loc:We(o),spec:u}]:[]}try{return t(o,n)}catch(u){throw u.filePath=e,u}},bn=Gr;var Hr=(e,t)=>{Object.keys(t).forEach(n=>{e[n]===void 0?e[n]={...t[n]}:Object.keys(t[n]).forEach(o=>{e[n][o]={...e[n][o],...t[n][o]};});});},Be=Hr;var fe=class{components;externalDocs;info;openapi;paths;security;servers;tags;constructor(t){this.openapi=t.openapi,this.info=t.info,this.paths=t.paths??{},t.servers&&(this.servers=t.servers),t.components&&(this.components=t.components),t.security&&(this.security=t.security),t.tags&&(this.tags=t.tags),t.externalDocs&&(this.externalDocs=t.externalDocs);}addData(t){t.forEach(n=>{let{components:o,paths:p,...u}=n;Be(this,{components:o??{},paths:p??{}}),Object.entries(u).forEach(([d,f])=>{this[d]=f;});});}},kn=fe;var de=(e,t)=>Ir({},e,t,(n,o)=>o===null?n:void 0),Ne=e=>Object.keys(e).map(t=>e[t]).every(t=>typeof t=="object"&&Object.keys(t).every(n=>!(n in t))),ge=(e,t)=>t.some(n=>e.name===n.name),Ue=e=>{switch(e.tag){case "asyncapi":return "v4";case "openapi":return "v3";case "swagger":return "v2";default:return "v2"}};var Xr=(e,t,n)=>{if(n==="x-webhooks"&&(e[n]=t[n]),n.startsWith("x-"))return;if(["components","consumes","produces","paths","schemas","securityDefinitions","responses","parameters","definitions","channels"].includes(n))Object.keys(t[n]).forEach(p=>{e[n][p]=de(e[n][p],t[n][p]);});else if(n==="tags"){let{tags:p}=t;Array.isArray(p)?p.forEach(u=>{ge(u,e.tags)||e.tags.push(u);}):ge(p,e.tags)||e.tags.push(p);}else if(n==="security"){let{security:p}=t;e.security=p;}else n.startsWith("/")&&(e.paths[n]=de(e.paths[n],t[n]));},Ye=Xr;var rs={v2:["paths","definitions","responses","parameters","securityDefinitions"],v3:["paths","definitions","responses","parameters","securityDefinitions","components"],v4:["components","channels"]},ss=(e,t)=>e.map(n=>{if((n.tag==="openapi"||n.tag==="swagger"||n.tag==="asyncapi")&&n.description!==""){let o=Kr.parseDocument(n.description);if(o.errors.length>0){o.errors.map(f=>{let w=f;return w.annotation=n.description,w});let d="Error parsing YAML in @openapi spec:";throw d+=t?o.errors.map(f=>`${f.toString()}
2
- Imbedded within:
3
- \`\`\`
4
- ${f.annotation?.replaceAll(`
5
- `,`
6
- `)}
7
- \`\`\``).join(`
8
- `):o.errors.map(f=>f.toString()).join(`
9
- `),new Error(d)}let p=o.toJSON(),u={tags:[]};return rs[Ue(n)].forEach(d=>{u[d]=u[d]||{};}),Object.keys(p).forEach(d=>{Ye(u,p,d);}),u}return {}}),ns=(e,t)=>parse(e,{spacing:"preserve"}).map(o=>{let p=o.tags.length+1,u=Ir({},...ss(o.tags,t),re);["definitions","responses","parameters","securityDefinitions","components","tags"].forEach(f=>{u[f]!==void 0&&Ne(u[f])&&delete u[f];});let d=JSON.parse(JSON.stringify(u));return {loc:p,spec:d}}),In=ns;var os=Object.defineProperty,ye=(e,t)=>os(e,"name",{value:t,configurable:true}),as=Object.defineProperty,m=ye((e,t)=>as(e,"name",{value:t,configurable:true}),"u$1"),Je=m(()=>{var e=(()=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,p=Object.prototype.hasOwnProperty,u=m((r,s)=>{for(var a in s)t(r,a,{get:s[a],enumerable:true});},"ne"),d=m((r,s,a,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of o(s))!p.call(r,i)&&i!==a&&t(r,i,{get:m(()=>s[i],"get"),enumerable:!(c=n(s,i))||c.enumerable});return r},"ae"),f=m(r=>d(t({},"__esModule",{value:true}),r),"oe"),w={};u(w,{zeptomatch:m(()=>Ce,"zeptomatch")});var S=m(r=>{let s=new Set,a=[r];for(let c=0;c<a.length;c++){let i=a[c];if(s.has(i))continue;s.add(i);let{children:l}=i;if(l?.length)for(let g=0,b=l.length;g<b;g++)a.push(l[g]);}return Array.from(s)},"M"),T=m(r=>{let s="",a=S(r);for(let c=0,i=a.length;c<i;c++){let l=a[c];if(!l.regex)continue;let g=l.regex.flags;if(s||(s=g),s!==g)throw new Error(`Inconsistent RegExp flags used: "${s}" and "${g}"`)}return s},"se"),y=m((r,s,a)=>{let c=a.get(r);if(c!==void 0)return c;let i=r.partial??s,l="";if(r.regex&&(l+=i?"(?:$|":"",l+=r.regex.source),r.children?.length){let g=ut(r.children.map(b=>y(b,s,a)).filter(Boolean));if(g?.length){let b=r.children.some(J=>!J.regex||!(J.partial??s)),O=g.length>1||i&&(!l.length||b);l+=O?i?"(?:$|":"(?:":"",l+=g.join("|"),l+=O?")":"";}}return r.regex&&(l+=i?")":""),a.set(r,l),l},"O"),z=m((r,s)=>{let a=new Map,c=S(r);for(let i=c.length-1;i>=0;i--){let l=y(c[i],s,a);if(!(i>0))return l}return ""},"ie"),ut=m(r=>Array.from(new Set(r)),"ue"),ae=m((r,s,a)=>ae.compile(r,a).test(s),"R");ae.compile=(r,s)=>{let a=s?.partial??false,c=z(r,a),i=T(r);return new RegExp(`^(?:${c})$`,i)};var ft=ae,dt=m((r,s)=>{let a=ft.compile(r,s),c=`${a.source.slice(0,-1)}[\\\\/]?$`,i=a.flags;return new RegExp(c,i)},"le"),gt=dt,ht=m(r=>{let s=r.map(c=>c.source).join("|")||"$^",a=r[0]?.flags;return new RegExp(s,a)},"ve"),yt=ht,je=m(r=>Array.isArray(r),"j"),U=m(r=>typeof r=="function","_"),bt=m(r=>r.length===0,"he"),xt=(()=>{let{toString:r}=Function.prototype,s=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return a=>(a.length===0||a.length===1)&&s.test(r.call(a))})(),vt=m(r=>typeof r=="number","de"),jt=m(r=>typeof r=="object"&&r!==null,"xe"),wt=m(r=>r instanceof RegExp,"me"),Ot=(()=>{let r=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return s=>r.test(s.source)})(),kt=(()=>{let r=/^[a-zA-Z0-9_-]+$/;return s=>r.test(s.source)&&!s.flags.includes("i")})(),we=m(r=>typeof r=="string","A"),L=m(r=>r===void 0,"f"),St=m(r=>{let s=new Map;return a=>{let c=s.get(a);if(c!==void 0)return c;let i=r(a);return s.set(a,i),i}},"ye"),Oe=m((r,s,a={})=>{let c={cache:{},input:r,index:0,indexBacktrackMax:0,options:a,output:[]},i=D(s)(c),l=Math.max(c.index,c.indexBacktrackMax);if(i&&c.index===r.length)return c.output;throw new Error(`Failed to parse at index ${l}`)},"I"),h=m((r,s)=>je(r)?$t(r,s):we(r)?ke(r,s):At(r,s),"i"),$t=m((r,s)=>{let a={};for(let c of r){if(c.length!==1)throw new Error(`Invalid character: "${c}"`);let i=c.charCodeAt(0);a[i]=true;}return c=>{let i=c.input,l=c.index,g=l;for(;g<i.length&&i.charCodeAt(g)in a;)g+=1;if(g>l){if(!L(s)&&!c.options.silent){let b=i.slice(l,g),O=U(s)?s(b,i,`${l}`):s;L(O)||c.output.push(O);}c.index=g;}return true}},"we"),At=m((r,s)=>{if(kt(r))return ke(r.source,s);{let a=r.source,c=r.flags.replace(/y|$/,"y"),i=new RegExp(a,c);return Ot(r)&&U(s)&&!xt(s)?Et(i,s):Pt(i,s)}},"$e"),Et=m((r,s)=>a=>{let c=a.index,i=a.input;r.lastIndex=c;let l=r.exec(i);if(l){let g=r.lastIndex;if(!a.options.silent){let b=s(...l,i,`${c}`);L(b)||a.output.push(b);}return a.index=g,true}else return false},"Ee"),Pt=m((r,s)=>a=>{let c=a.index,i=a.input;if(r.lastIndex=c,r.test(i)){let l=r.lastIndex;if(!L(s)&&!a.options.silent){let g=U(s)?s(i.slice(c,l),i,`${c}`):s;L(g)||a.output.push(g);}return a.index=l,true}else return false},"Ce"),ke=m((r,s)=>a=>{let c=a.index,i=a.input;if(i.startsWith(r,c)){if(!L(s)&&!a.options.silent){let l=U(s)?s(r,i,`${c}`):s;L(l)||a.output.push(l);}return a.index+=r.length,true}else return false},"F"),ie=m((r,s,a,c)=>{let i=D(r),l=s>1;return pe(ce($e(g=>{let b=0;for(;b<a;){let O=g.index;if(!i(g)||(b+=1,g.index===O))break}return b>=s},l),c))},"k"),Se=m((r,s)=>ie(r,0,1,s),"L"),te=m((r,s)=>ie(r,0,1/0,s),"$"),Tt=m((r,s)=>ie(r,1,1/0,s),"Re"),W=m((r,s)=>{let a=r.map(D);return pe(ce($e(c=>{for(let i=0,l=a.length;i<l;i++)if(!a[i](c))return false;return true}),s))},"x"),A=m((r,s)=>{let a=r.map(D);return pe(ce(c=>{for(let i=0,l=a.length;i<l;i++)if(a[i](c))return true;return false},s))},"p"),$e=m((r,s=true,a=false)=>{let c=D(r);return s?i=>{let l=i.index,g=i.output.length,b=c(i);return !b&&!a&&(i.indexBacktrackMax=Math.max(i.indexBacktrackMax,i.index)),(!b||a)&&(i.index=l,i.output.length!==g&&(i.output.length=g)),b}:c},"q"),ce=m((r,s)=>{let a=D(r);return s?c=>{if(c.options.silent)return a(c);let i=c.output.length;if(a(c)){let l=c.output.splice(i,1/0),g=s(l);return L(g)||c.output.push(g),true}else return false}:a},"B"),pe=(()=>{let r=0;return s=>{let a=D(s),c=r+=1;return i=>{var l;if(i.options.memoization===false)return a(i);let g=i.index,b=(l=i.cache)[c]||(l[c]={indexMax:-1,queue:[]}),O=b.queue;if(g<=b.indexMax){let Z=b.store||(b.store=new Map);if(O.length){for(let B=0,_r=O.length;B<_r;B+=2){let Fr=O[B*2],Rr=O[B*2+1];Z.set(Fr,Rr);}O.length=0;}let E=Z.get(g);if(E===false)return false;if(vt(E))return i.index=E,true;if(E)return i.index=E.index,E.output?.length&&i.output.push(...E.output),true}let J=i.output.length,Dr=a(i);if(b.indexMax=Math.max(b.indexMax,g),Dr){let Z=i.index,E=i.output.length;if(E>J){let B=i.output.slice(J,E);O.push(g,{index:Z,output:B});}else O.push(g,Z);return true}else return O.push(g,false),false}}})(),Ae=m(r=>{let s;return a=>(s||(s=D(r())),s(a))},"G"),D=St(r=>{if(U(r))return bt(r)?Ae(r):r;if(we(r)||wt(r))return h(r);if(je(r))return W(r);if(jt(r))return A(Object.values(r));throw new Error("Invalid rule")}),R=m(r=>r,"d"),zt=m(r=>typeof r=="string","ke"),Lt=m(r=>{let s=new WeakMap,a=new WeakMap;return (c,i)=>{let l=i?.partial?a:s,g=l.get(c);if(g!==void 0)return g;let b=r(c,i);return l.set(c,b),b}},"Be"),Dt=m(r=>{let s={},a={};return (c,i)=>{let l=i?.partial?a:s;return l[c]??(l[c]=r(c,i))}},"Pe"),_t=h(/\\./,R),Ft=h(/./,R),Rt=h(/\*\*\*+/,"*"),Mt=h(/([^/{[(!])\*\*/,(r,s)=>`${s}*`),Ct=h(/(^|.)\*\*(?=[^*/)\]}])/,(r,s)=>`${s}*`),It=te(A([_t,Rt,Mt,Ct,Ft])),Wt=It,qt=m(r=>Oe(r,Wt,{memoization:false}).join(""),"Ie"),Bt=qt,Ee="abcdefghijklmnopqrstuvwxyz",Nt=m(r=>{let s="";for(;r>0;){let a=(r-1)%26;s=Ee[a]+s,r=Math.floor((r-1)/26);}return s},"Le"),Pe=m(r=>{let s=0;for(let a=0,c=r.length;a<c;a++)s=s*26+Ee.indexOf(r[a])+1;return s},"V"),le=m((r,s)=>{if(s<r)return le(s,r);let a=[];for(;r<=s;)a.push(r++);return a},"b"),Ut=m((r,s,a)=>le(r,s).map(c=>String(c).padStart(a,"0")),"qe"),Te=m((r,s)=>le(Pe(r),Pe(s)).map(Nt),"W"),x=m(r=>({partial:false,regex:new RegExp(r,"s"),children:[]}),"c"),Y=m(r=>({children:r}),"y"),q=(()=>{let r=m((s,a,c)=>{if(c.has(s))return;c.add(s);let{children:i}=s;if(!i.length)i.push(a);else for(let l=0,g=i.length;l<g;l++)r(i[l],a,c);},"e");return s=>{if(!s.length)return Y([]);for(let a=s.length-1;a>=1;a--){let c=new Set,i=s[a-1],l=s[a];r(i,l,c);}return s[0]}})(),_=m(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),Yt=h(/\\./,x),Jt=h(/[$.*+?^(){}[\]\|]/,r=>x(`\\${r}`)),Zt=h(/[\\\/]/,_),Kt=h(/[^$.*+?^(){}[\]\|\\\/]+/,x),Gt=h(/^(?:!!)*!(.*)$/,(r,s)=>x(`(?!^${Ce.compile(s).source}$).*?`)),Ht=h(/^(!!)+/),Vt=A([Gt,Ht]),Xt=h(/\/(\*\*\/)+/,()=>Y([q([_(),x(".+?"),_()]),_()])),Qt=h(/^(\*\*\/)+/,()=>Y([x("^"),q([x(".*?"),_()])])),er=h(/\/(\*\*)$/,()=>Y([q([_(),x(".*?")]),x("$")])),tr=h(/\*\*/,()=>x(".*?")),ze=A([Xt,Qt,er,tr]),rr=h(/\*\/(?!\*\*\/|\*$)/,()=>q([x("[^\\\\/]*?"),_()])),sr=h(/\*/,()=>x("[^\\\\/]*")),Le=A([rr,sr]),De=h("?",()=>x("[^\\\\/]")),nr=h("[",R),or=h("]",R),ar=h(/[!^]/,"^\\\\/"),ir=h(/[a-z]-[a-z]|[0-9]-[0-9]/i,R),cr=h(/\\./,R),pr=h(/[$.*+?^(){}[\|]/,r=>`\\${r}`),lr=h(/[\\\/]/,"\\\\/"),mr=h(/[^$.*+?^(){}[\]\|\\\/]+/,R),ur=A([cr,pr,lr,ir,mr]),_e=W([nr,Se(ar),te(ur),or],r=>x(r.join(""))),fr=h("{","(?:"),dr=h("}",")"),gr=h(/(\d+)\.\.(\d+)/,(r,s,a)=>Ut(+s,+a,Math.min(s.length,a.length)).join("|")),hr=h(/([a-z]+)\.\.([a-z]+)/,(r,s,a)=>Te(s,a).join("|")),yr=h(/([A-Z]+)\.\.([A-Z]+)/,(r,s,a)=>Te(s.toLowerCase(),a.toLowerCase()).join("|").toUpperCase()),br=A([gr,hr,yr]),Fe=W([fr,br,dr],r=>x(r.join(""))),xr=h("{"),vr=h("}"),jr=h(","),wr=h(/\\./,x),Or=h(/[$.*+?^(){[\]\|]/,r=>x(`\\${r}`)),kr=h(/[\\\/]/,_),Sr=h(/[^$.*+?^(){}[\]\|\\\/,]+/,x),$r=Ae(()=>Me),Ar=h("",()=>x("(?:)")),Er=Tt(A([ze,Le,De,_e,Fe,$r,wr,Or,kr,Sr]),q),Re=A([Er,Ar]),Me=W([xr,Se(W([Re,te(W([jr,Re]))])),vr],Y),Pr=te(A([Vt,ze,Le,De,_e,Fe,Me,Yt,Jt,Zt,Kt]),q),Tr=Pr,zr=m(r=>Oe(r,Tr,{memoization:false})[0],"kr"),Lr=zr,me=m((r,s,a)=>me.compile(r,a).test(s),"N");me.compile=(()=>{let r=Dt((a,c)=>gt(Lr(Bt(a)),c)),s=Lt((a,c)=>yt(a.map(i=>r(i,c))));return (a,c)=>zt(a)?r(a,c):s(a,c)})();var Ce=me;return f(w)})();return e.default||e},"_lazyMatch"),he,is=m((e,t)=>(he||(he=Je(),Je=null),he(e,t)),"default"),cs=Object.defineProperty,ps=ye((e,t)=>cs(e,"name",{value:t,configurable:true}),"t"),ls=/^[A-Z]:\//i,$=ps((e="")=>e&&e.replaceAll("\\","/").replace(ls,t=>t.toUpperCase()),"normalizeWindowsPath"),ms=Object.defineProperty,k=ye((e,t)=>ms(e,"name",{value:t,configurable:true}),"r"),us=/^[/\\]{2}/,fs=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Ke=/^[A-Z]:$/i,Ze=/^\/([A-Z]:)?$/i,ds=/.(\.[^./]+)$/,gs=/^[/\\]|^[a-z]:[/\\]/i,hs=k(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd");/^win/i.test(globalThis.process?.platform)?";":":";var se=k((e,t)=>{let n="",o=0,p=-1,u=0,d;for(let f=0;f<=e.length;++f){if(f<e.length)d=e[f];else {if(d==="/")break;d="/";}if(d==="/"){if(!(p===f-1||u===1))if(u===2){if(n.length<2||o!==2||!n.endsWith(".")||n.at(-2)!=="."){if(n.length>2){let w=n.lastIndexOf("/");w===-1?(n="",o=0):(n=n.slice(0,w),o=n.length-1-n.lastIndexOf("/")),p=f,u=0;continue}else if(n.length>0){n="",o=0,p=f,u=0;continue}}t&&(n+=n.length>0?"/..":"..",o=2);}else n.length>0?n+=`/${e.slice(p+1,f)}`:n=e.slice(p+1,f),o=f-p-1;p=f,u=0;}else d==="."&&u!==-1?++u:u=-1;}return n},"normalizeString"),M=k(e=>fs.test(e),"isAbsolute"),N=k(function(e){if(e.length===0)return ".";e=$(e);let t=us.exec(e),n=M(e),o=e.at(-1)==="/";return e=se(e,!n),e.length===0?n?"/":o?"./":".":(o&&(e+="/"),Ke.test(e)&&(e+="/"),t?n?`//${e}`:`//./${e}`:n&&!M(e)?`/${e}`:e)},"normalize"),I=k((...e)=>{let t="";for(let n of e)if(n)if(t.length>0){let o=t[t.length-1]==="/",p=n[0]==="/";o&&p?t+=n.slice(1):t+=o||p?n:`/${n}`;}else t+=n;return N(t)},"join"),C=k(function(...e){e=e.map(o=>$(o));let t="",n=false;for(let o=e.length-1;o>=-1&&!n;o--){let p=o>=0?e[o]:hs();!p||p.length===0||(t=`${p}/${t}`,n=M(p));}return t=se(t,!n),n&&!M(t)?`/${t}`:t.length>0?t:"."},"resolve");k(function(e){return $(e)},"toNamespacedPath");var K=k(function(e){return ds.exec($(e))?.[1]??""},"extname");k(function(e,t){let n=C(e).replace(Ze,"$1").split("/"),o=C(t).replace(Ze,"$1").split("/");if(o[0][1]===":"&&n[0][1]===":"&&n[0]!==o[0])return o.join("/");let p=[...n];for(let u of p){if(o[0]!==u)break;n.shift(),o.shift();}return [...n.map(()=>".."),...o].join("/")},"relative");var be=k(e=>{let t=$(e).replace(/\/$/,"").split("/").slice(0,-1);return t.length===1&&Ke.test(t[0])&&(t[0]+="/"),t.join("/")||(M(e)?"/":".")},"dirname");k(function(e){let t=[e.root,e.dir,e.base??e.name+e.ext].filter(Boolean);return $(e.root?C(...t):t.join("/"))},"format");var G=k((e,t)=>{let n=$(e).split("/").pop();return t&&n.endsWith(t)?n.slice(0,-t.length):n},"basename");k(function(e){let t=gs.exec(e)?.[0]?.replaceAll("\\","/")??"",n=G(e),o=K(n);return {base:n,dir:be(e),ext:o,name:n.slice(0,n.length-o.length),root:t}},"parse");k((e,t)=>is(t,N(e)),"matchesGlob");var ys=Object.defineProperty,oe=(e,t)=>ys(e,"name",{value:t,configurable:true}),xs=createRequire(import.meta.url),H=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vs=oe(e=>{if(typeof H<"u"&&H.versions&&H.versions.node){let[t,n]=H.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return H.getBuiltinModule(e)}return xs(e)},"__cjs_getBuiltinModule"),{fileURLToPath:js}=vs("node:url");function ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}oe(ot,"getDefaultExportFromCjs");var rt,st;function at(){return st||(st=1,rt=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),rt}oe(at,"requireBinaryExtensions");var ws=at(),Os=ot(ws),ks=Object.defineProperty,P=oe((e,t)=>ks(e,"name",{value:t,configurable:true}),"r"),Ss=new Set(Os),$s=new Set(["/","\\",void 0]),nt=Symbol.for("pathe:normalizedAlias"),As=/(^|[/\\])([^/\\]+?)(?=(?:\.[^.]+)?$)/,Es=P((e,t)=>t.split("/").length-e.split("/").length,"compareAliases"),ne=P((e="/")=>{let t=e.at(-1);return t==="/"||t==="\\"},"hasTrailingSlash"),it=P(e=>{if(e[nt])return e;let t=Object.fromEntries(Object.entries(e).toSorted(([n],[o])=>Es(n,o)));for(let n in t)for(let o in t)o===n||n.startsWith(o)||t[n].startsWith(o)&&$s.has(t[n][o.length])&&(t[n]=t[o]+t[n].slice(o.length));return Object.defineProperty(t,nt,{enumerable:false,value:true}),t},"normalizeAliases");P((e,t)=>{e=$(e),t=it(t);for(let[n,o]of Object.entries(t)){if(!e.startsWith(n))continue;let p=ne(n)?n.slice(0,-1):n;if(ne(e[p.length]))return I(o,e.slice(n.length))}return e},"resolveAlias");P(e=>As.exec(e)?.[2],"filename");P((e,t)=>{e=$(e),t=it(t);for(let[n,o]of Object.entries(t).toReversed()){if(!e.startsWith(o))continue;let p=ne(o)?o.slice(0,-1):o;if(ne(e[p.length]))return I(n,e.slice(o.length))}return e},"reverseResolveAlias");P(e=>/^(?:\.?\.[/\\]|\.\.\B)/.test(e)||e==="..","isRelative");P(e=>Ss.has(K(e).slice(1).toLowerCase()),"isBinaryPath");var ct=P(e=>$(e instanceof URL?js(e):e),"toPath");P(()=>{if(!globalThis?.process)return false;if(globalThis?.process?.platform==="win32"||globalThis?.process?.platform==="cygwin")return true;let e=globalThis?.process?.env.OSTYPE;return typeof e!="string"?false:/^(?:msys|cygwin)$/.test(e)},"isWindows");var Ps=Object.defineProperty,pt=(e,t)=>Ps(e,"name",{value:t,configurable:true}),Ts=Object.defineProperty,zs=pt((e,t)=>Ts(e,"name",{value:t,configurable:true}),"t"),V=class extends Error{static{pt(this,"i");}static{zs(this,"WalkError");}root;constructor(t,n){super(`${t instanceof Error?t.message:t} for path "${n}"`),this.cause=t,this.root=n;}get name(){return "WalkError"}set name(t){throw new Error("Cannot overwrite name of WalkError")}};var Ls=Object.defineProperty,Ds=(e,t)=>Ls(e,"name",{value:t,configurable:true}),_s=Object.defineProperty,Fs=Ds((e,t)=>_s(e,"name",{value:t,configurable:true}),"n"),lt=Fs(e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},"assertValidFileOrDirectoryPath");var Rs=Object.defineProperty,mt=(e,t)=>Rs(e,"name",{value:t,configurable:true}),Ms=Object.defineProperty,Cs=mt((e,t)=>Ms(e,"name",{value:t,configurable:true}),"g"),xe=Cs(e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`).replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},"globToRegExp"),Is=Object.defineProperty,Ws=mt((e,t)=>Is(e,"name",{value:t,configurable:true}),"n"),X=Ws((e,t,n,o)=>Array.isArray(t)&&t.length>0&&!t.some(p=>e.endsWith(p))||n&&!n.some(p=>p.test(e))?false:!o?.some(p=>p.test(e)),"walkInclude");var qs=Object.defineProperty,ve=(e,t)=>qs(e,"name",{value:t,configurable:true}),Ns=createRequire(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Us=ve(e=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){let[t,n]=Q.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Q.getBuiltinModule(e)}return Ns(e)},"__cjs_getBuiltinModule"),{readdir:Ys,realpath:Js,stat:Zs}=Us("node:fs/promises"),Ks=Object.defineProperty,F=ve((e,t)=>Ks(e,"name",{value:t,configurable:true}),"r"),Gs=F(async e=>{let t=N(e),n=G(t),o=await Zs(t);return {isDirectory:F(()=>o.isDirectory(),"isDirectory"),isFile:F(()=>o.isFile(),"isFile"),isSymbolicLink:F(()=>o.isSymbolicLink(),"isSymbolicLink"),name:n,path:t}},"_createWalkEntry");async function*ee(e,{extensions:t,followSymlinks:n=false,includeDirs:o=true,includeFiles:p=true,includeSymlinks:u=true,match:d,maxDepth:f=Number.POSITIVE_INFINITY,skip:w}={}){if(lt(e),f<0)return;let S=d?d.map(y=>typeof y=="string"?xe(y):y):void 0,T=w?w.map(y=>typeof y=="string"?xe(y):y):void 0;if(e=C(ct(e)),o&&X(e,t,S,T)&&(yield await Gs(e)),!(f<1||!X(e,void 0,void 0,T)))try{for await(let y of await Ys(e,{withFileTypes:!0})){let z=I(e,y.name);if(y.isSymbolicLink())if(n)z=await Js(z);else if(u&&X(z,t,S,T))yield {isDirectory:y.isDirectory,isFile:y.isFile,isSymbolicLink:y.isSymbolicLink,name:y.name,path:z};else continue;y.isSymbolicLink()||y.isDirectory()?yield*ee(z,{extensions:t,followSymlinks:n,includeDirs:o,includeFiles:p,includeSymlinks:u,match:S,maxDepth:f-1,skip:T}):y.isFile()&&p&&X(z,t,S,T)&&(yield {isDirectory:F(()=>y.isDirectory(),"isDirectory"),isFile:F(()=>y.isFile(),"isFile"),isSymbolicLink:F(()=>y.isSymbolicLink(),"isSymbolicLink"),name:y.name,path:z});}}catch(y){throw y instanceof V?y:new V(y,e)}}ve(ee,"d");F(ee,"walk");var Hs=Object.defineProperty,Vs=(e,t)=>Hs(e,"name",{value:t,configurable:true}),Xs=Object.defineProperty,Qs=Vs((e,t)=>Xs(e,"name",{value:t,configurable:true}),"e"),en=Qs(async(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);let n=[];for await(let o of ee(e,t))n.push(o.path);return n},"collect");var So=["coverage/**",".github/**","**/*.d.ts","**/test{,s}/**","**/test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}","**/__tests__/**","**/{ava,babel,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,rollup,webpack}.config.js","**/.{eslint,mocha}rc.{js,cjs}","**/.{travis,yarnrc}.yml","**/{docker-compose,docker}.yml","**/.yamllint.{yaml,yml}","**/node_modules/**","**/{pnpm-workspace,pnpm-lock}.yaml","**/{package,package-lock}.json","**/yarn.lock","**/package.json5","**/.next/**"];var rn=async e=>{await tn.validate(e);},Po=rn;
10
- export{pn as a,We as b,bn as c,kn as d,In as e,en as f,So as g,Po as h};//# sourceMappingURL=chunk-4JHXGXFZ.mjs.map
11
- //# sourceMappingURL=chunk-4JHXGXFZ.mjs.map