@elysiajs/openapi 1.3.9 → 1.3.11

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.
@@ -44,74 +44,82 @@ var fromTypes = (targetFilePath, {
44
44
  throw new Error("Only .ts files are supported");
45
45
  if (targetFilePath.startsWith("./"))
46
46
  targetFilePath = targetFilePath.slice(2);
47
- const src = targetFilePath.startsWith("/") ? targetFilePath : (0, import_path.join)(projectRoot, targetFilePath);
47
+ let src = targetFilePath.startsWith("/") ? targetFilePath : (0, import_path.join)(projectRoot, targetFilePath);
48
48
  if (!(0, import_fs.existsSync)(src))
49
49
  throw new Error(
50
50
  `Couldn't find "${targetFilePath}" from ${projectRoot}`
51
51
  );
52
- if ((0, import_fs.existsSync)(tmpRoot))
53
- (0, import_fs.rmSync)(tmpRoot, { recursive: true, force: true });
54
- (0, import_fs.mkdirSync)(tmpRoot, { recursive: true });
55
- const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : (0, import_path.join)(projectRoot, tsconfigPath);
56
- const extendsRef = (0, import_fs.existsSync)(tsconfig) ? `"extends": "${(0, import_path.join)(projectRoot, "tsconfig.json")}",` : "";
57
- (0, import_fs.writeFileSync)(
58
- (0, import_path.join)(tmpRoot, "tsconfig.json"),
59
- `{
60
- ${extendsRef}
61
- "compilerOptions": {
62
- "lib": ["ESNext"],
63
- "module": "ESNext",
64
- "noEmit": false,
65
- "declaration": true,
66
- "emitDeclarationOnly": true,
67
- "moduleResolution": "bundler",
68
- "skipLibCheck": true,
69
- "skipDefaultLibCheck": true,
70
- "outDir": "./dist"
71
- },
72
- "include": ["${src}"]
73
- }`
74
- );
75
- (0, import_child_process.spawnSync)(`tsc`, {
76
- shell: true,
77
- cwd: tmpRoot,
78
- stdio: debug ? "inherit" : void 0
79
- });
80
- const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
81
- let targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : (0, import_path.join)(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? (0, import_path.join)(
82
- tmpRoot,
83
- "dist",
84
- // remove leading like src or something similar
85
- fileName.slice(fileName.indexOf("/") + 1)
86
- );
87
- let existed = (0, import_fs.existsSync)(targetFile);
88
- if (!existed && overrideOutputPath) {
89
- targetFile = (0, import_path.join)(
52
+ let targetFile;
53
+ if (targetFilePath.endsWith(".d.ts")) targetFile = targetFilePath;
54
+ else {
55
+ if ((0, import_fs.existsSync)(tmpRoot))
56
+ (0, import_fs.rmSync)(tmpRoot, { recursive: true, force: true });
57
+ (0, import_fs.mkdirSync)(tmpRoot, { recursive: true });
58
+ const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : (0, import_path.join)(projectRoot, tsconfigPath);
59
+ let extendsRef = (0, import_fs.existsSync)(tsconfig) ? `"extends": "${(0, import_path.join)(projectRoot, "tsconfig.json")}",` : "";
60
+ if (typeof process !== "undefined" && process.platform === "win32") {
61
+ extendsRef = extendsRef.replace(/\\/g, "/");
62
+ src = src.replace(/\\/g, "/");
63
+ }
64
+ (0, import_fs.writeFileSync)(
65
+ (0, import_path.join)(tmpRoot, "tsconfig.json"),
66
+ `{
67
+ ${extendsRef}
68
+ "compilerOptions": {
69
+ "lib": ["ESNext"],
70
+ "module": "ESNext",
71
+ "noEmit": false,
72
+ "declaration": true,
73
+ "emitDeclarationOnly": true,
74
+ "moduleResolution": "bundler",
75
+ "skipLibCheck": true,
76
+ "skipDefaultLibCheck": true,
77
+ "outDir": "./dist"
78
+ },
79
+ "include": ["${src}"]
80
+ }`
81
+ );
82
+ (0, import_child_process.spawnSync)(`tsc`, {
83
+ shell: true,
84
+ cwd: tmpRoot,
85
+ stdio: debug ? "inherit" : void 0
86
+ });
87
+ const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
88
+ targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : (0, import_path.join)(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? (0, import_path.join)(
90
89
  tmpRoot,
91
90
  "dist",
92
- // use original file name as-is eg. in monorepo
93
- fileName
94
- );
95
- existed = (0, import_fs.existsSync)(targetFile);
96
- }
97
- if (!existed) {
98
- (0, import_fs.rmSync)((0, import_path.join)(tmpRoot, "tsconfig.json"));
99
- console.warn(
100
- "[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
91
+ // remove leading like src or something similar
92
+ fileName.slice(fileName.indexOf("/") + 1)
101
93
  );
102
- console.warn("Couldn't find generated declaration file");
103
- if ((0, import_fs.existsSync)((0, import_path.join)(tmpRoot, "dist"))) {
104
- const tempFiles = (0, import_fs.readdirSync)((0, import_path.join)(tmpRoot, "dist"), {
105
- recursive: true
106
- }).filter((x) => x.toString().endsWith(".d.ts")).map((x) => `- ${x}`).join("\n");
107
- if (tempFiles) {
108
- console.warn(
109
- "You can override with `overrideOutputPath` with one of the following:"
110
- );
111
- console.warn(tempFiles);
94
+ let existed = (0, import_fs.existsSync)(targetFile);
95
+ if (!existed && !overrideOutputPath) {
96
+ targetFile = (0, import_path.join)(
97
+ tmpRoot,
98
+ "dist",
99
+ // use original file name as-is eg. in monorepo
100
+ fileName
101
+ );
102
+ existed = (0, import_fs.existsSync)(targetFile);
103
+ }
104
+ if (!existed) {
105
+ (0, import_fs.rmSync)((0, import_path.join)(tmpRoot, "tsconfig.json"));
106
+ console.warn(
107
+ "[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
108
+ );
109
+ console.warn("Couldn't find generated declaration file");
110
+ if ((0, import_fs.existsSync)((0, import_path.join)(tmpRoot, "dist"))) {
111
+ const tempFiles = (0, import_fs.readdirSync)((0, import_path.join)(tmpRoot, "dist"), {
112
+ recursive: true
113
+ }).filter((x) => x.toString().endsWith(".d.ts")).map((x) => `- ${x}`).join("\n");
114
+ if (tempFiles) {
115
+ console.warn(
116
+ "You can override with `overrideOutputPath` with one of the following:"
117
+ );
118
+ console.warn(tempFiles);
119
+ }
112
120
  }
121
+ return;
113
122
  }
114
- return;
115
123
  }
116
124
  const declaration = (0, import_fs.readFileSync)(targetFile, "utf8");
117
125
  if ((0, import_fs.existsSync)(tmpRoot))
@@ -27,74 +27,82 @@ var fromTypes = (targetFilePath, {
27
27
  throw new Error("Only .ts files are supported");
28
28
  if (targetFilePath.startsWith("./"))
29
29
  targetFilePath = targetFilePath.slice(2);
30
- const src = targetFilePath.startsWith("/") ? targetFilePath : join(projectRoot, targetFilePath);
30
+ let src = targetFilePath.startsWith("/") ? targetFilePath : join(projectRoot, targetFilePath);
31
31
  if (!existsSync(src))
32
32
  throw new Error(
33
33
  `Couldn't find "${targetFilePath}" from ${projectRoot}`
34
34
  );
35
- if (existsSync(tmpRoot))
36
- rmSync(tmpRoot, { recursive: true, force: true });
37
- mkdirSync(tmpRoot, { recursive: true });
38
- const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : join(projectRoot, tsconfigPath);
39
- const extendsRef = existsSync(tsconfig) ? `"extends": "${join(projectRoot, "tsconfig.json")}",` : "";
40
- writeFileSync(
41
- join(tmpRoot, "tsconfig.json"),
42
- `{
43
- ${extendsRef}
44
- "compilerOptions": {
45
- "lib": ["ESNext"],
46
- "module": "ESNext",
47
- "noEmit": false,
48
- "declaration": true,
49
- "emitDeclarationOnly": true,
50
- "moduleResolution": "bundler",
51
- "skipLibCheck": true,
52
- "skipDefaultLibCheck": true,
53
- "outDir": "./dist"
54
- },
55
- "include": ["${src}"]
56
- }`
57
- );
58
- spawnSync(`tsc`, {
59
- shell: true,
60
- cwd: tmpRoot,
61
- stdio: debug ? "inherit" : void 0
62
- });
63
- const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
64
- let targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : join(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? join(
65
- tmpRoot,
66
- "dist",
67
- // remove leading like src or something similar
68
- fileName.slice(fileName.indexOf("/") + 1)
69
- );
70
- let existed = existsSync(targetFile);
71
- if (!existed && overrideOutputPath) {
72
- targetFile = join(
35
+ let targetFile;
36
+ if (targetFilePath.endsWith(".d.ts")) targetFile = targetFilePath;
37
+ else {
38
+ if (existsSync(tmpRoot))
39
+ rmSync(tmpRoot, { recursive: true, force: true });
40
+ mkdirSync(tmpRoot, { recursive: true });
41
+ const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : join(projectRoot, tsconfigPath);
42
+ let extendsRef = existsSync(tsconfig) ? `"extends": "${join(projectRoot, "tsconfig.json")}",` : "";
43
+ if (typeof process !== "undefined" && process.platform === "win32") {
44
+ extendsRef = extendsRef.replace(/\\/g, "/");
45
+ src = src.replace(/\\/g, "/");
46
+ }
47
+ writeFileSync(
48
+ join(tmpRoot, "tsconfig.json"),
49
+ `{
50
+ ${extendsRef}
51
+ "compilerOptions": {
52
+ "lib": ["ESNext"],
53
+ "module": "ESNext",
54
+ "noEmit": false,
55
+ "declaration": true,
56
+ "emitDeclarationOnly": true,
57
+ "moduleResolution": "bundler",
58
+ "skipLibCheck": true,
59
+ "skipDefaultLibCheck": true,
60
+ "outDir": "./dist"
61
+ },
62
+ "include": ["${src}"]
63
+ }`
64
+ );
65
+ spawnSync(`tsc`, {
66
+ shell: true,
67
+ cwd: tmpRoot,
68
+ stdio: debug ? "inherit" : void 0
69
+ });
70
+ const fileName = targetFilePath.replace(/.tsx$/, ".ts").replace(/.ts$/, ".d.ts");
71
+ targetFile = (overrideOutputPath ? typeof overrideOutputPath === "string" ? overrideOutputPath.startsWith("/") ? overrideOutputPath : join(tmpRoot, "dist", overrideOutputPath) : overrideOutputPath(tmpRoot) : void 0) ?? join(
73
72
  tmpRoot,
74
73
  "dist",
75
- // use original file name as-is eg. in monorepo
76
- fileName
77
- );
78
- existed = existsSync(targetFile);
79
- }
80
- if (!existed) {
81
- rmSync(join(tmpRoot, "tsconfig.json"));
82
- console.warn(
83
- "[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
74
+ // remove leading like src or something similar
75
+ fileName.slice(fileName.indexOf("/") + 1)
84
76
  );
85
- console.warn("Couldn't find generated declaration file");
86
- if (existsSync(join(tmpRoot, "dist"))) {
87
- const tempFiles = readdirSync(join(tmpRoot, "dist"), {
88
- recursive: true
89
- }).filter((x) => x.toString().endsWith(".d.ts")).map((x) => `- ${x}`).join("\n");
90
- if (tempFiles) {
91
- console.warn(
92
- "You can override with `overrideOutputPath` with one of the following:"
93
- );
94
- console.warn(tempFiles);
77
+ let existed = existsSync(targetFile);
78
+ if (!existed && !overrideOutputPath) {
79
+ targetFile = join(
80
+ tmpRoot,
81
+ "dist",
82
+ // use original file name as-is eg. in monorepo
83
+ fileName
84
+ );
85
+ existed = existsSync(targetFile);
86
+ }
87
+ if (!existed) {
88
+ rmSync(join(tmpRoot, "tsconfig.json"));
89
+ console.warn(
90
+ "[@elysiajs/openapi/gen] Failed to generate OpenAPI schema"
91
+ );
92
+ console.warn("Couldn't find generated declaration file");
93
+ if (existsSync(join(tmpRoot, "dist"))) {
94
+ const tempFiles = readdirSync(join(tmpRoot, "dist"), {
95
+ recursive: true
96
+ }).filter((x) => x.toString().endsWith(".d.ts")).map((x) => `- ${x}`).join("\n");
97
+ if (tempFiles) {
98
+ console.warn(
99
+ "You can override with `overrideOutputPath` with one of the following:"
100
+ );
101
+ console.warn(tempFiles);
102
+ }
95
103
  }
104
+ return;
96
105
  }
97
- return;
98
106
  }
99
107
  const declaration = readFileSync(targetFile, "utf8");
100
108
  if (existsSync(tmpRoot))
package/package.json CHANGED
@@ -1,92 +1,92 @@
1
- {
2
- "name": "@elysiajs/openapi",
3
- "version": "1.3.9",
4
- "description": "Plugin for Elysia to auto-generate API documentation",
5
- "author": {
6
- "name": "saltyAom",
7
- "url": "https://github.com/SaltyAom",
8
- "email": "saltyaom@gmail.com"
9
- },
10
- "main": "./dist/cjs/index.js",
11
- "module": "./dist/index.mjs",
12
- "types": "./dist/index.d.ts",
13
- "exports": {
14
- "./package.json": "./package.json",
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.mjs",
18
- "require": "./dist/cjs/index.js"
19
- },
20
- "./gen": {
21
- "types": "./dist/gen/index.d.ts",
22
- "import": "./dist/gen/index.mjs",
23
- "require": "./dist/cjs/gen/index.js"
24
- },
25
- "./openapi": {
26
- "types": "./dist/openapi.d.ts",
27
- "import": "./dist/openapi.mjs",
28
- "require": "./dist/cjs/openapi.js"
29
- },
30
- "./scalar": {
31
- "types": "./dist/scalar/index.d.ts",
32
- "import": "./dist/scalar/index.mjs",
33
- "require": "./dist/cjs/scalar/index.js"
34
- },
35
- "./scalar/theme": {
36
- "types": "./dist/scalar/theme.d.ts",
37
- "import": "./dist/scalar/theme.mjs",
38
- "require": "./dist/cjs/scalar/theme.js"
39
- },
40
- "./swagger": {
41
- "types": "./dist/swagger/index.d.ts",
42
- "import": "./dist/swagger/index.mjs",
43
- "require": "./dist/cjs/swagger/index.js"
44
- },
45
- "./swagger/types": {
46
- "types": "./dist/swagger/types.d.ts",
47
- "import": "./dist/swagger/types.mjs",
48
- "require": "./dist/cjs/swagger/types.js"
49
- },
50
- "./types": {
51
- "types": "./dist/types.d.ts",
52
- "import": "./dist/types.mjs",
53
- "require": "./dist/cjs/types.js"
54
- }
55
- },
56
- "keywords": [
57
- "elysia",
58
- "openapi",
59
- "swagger",
60
- "scalar"
61
- ],
62
- "homepage": "https://github.com/elysiajs/elysia-openapi",
63
- "repository": {
64
- "type": "git",
65
- "url": "https://github.com/elysiajs/elysia-openapi"
66
- },
67
- "bugs": "https://github.com/elysiajs/elysia-openapi/issues",
68
- "license": "MIT",
69
- "scripts": {
70
- "dev": "bun run --watch example/index.ts",
71
- "test": "bun test && npm run test:node",
72
- "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
73
- "build": "bun build.ts",
74
- "release": "npm run build && npm run test && npm publish --access public"
75
- },
76
- "peerDependencies": {
77
- "elysia": ">= 1.3.0"
78
- },
79
- "devDependencies": {
80
- "@apidevtools/swagger-parser": "^12.0.0",
81
- "@types/bun": "1.2.20",
82
- "@scalar/types": "^0.2.13",
83
- "elysia": "1.3.21",
84
- "eslint": "9.6.0",
85
- "tsup": "^8.5.0",
86
- "typescript": "^5.9.2"
87
- },
88
- "dependencies": {
89
- "@sinclair/typemap": "^0.10.1",
90
- "openapi-types": "^12.1.3"
91
- }
92
- }
1
+ {
2
+ "name": "@elysiajs/openapi",
3
+ "version": "1.3.11",
4
+ "description": "Plugin for Elysia to auto-generate API documentation",
5
+ "author": {
6
+ "name": "saltyAom",
7
+ "url": "https://github.com/SaltyAom",
8
+ "email": "saltyaom@gmail.com"
9
+ },
10
+ "main": "./dist/cjs/index.js",
11
+ "module": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.mjs",
18
+ "require": "./dist/cjs/index.js"
19
+ },
20
+ "./gen": {
21
+ "types": "./dist/gen/index.d.ts",
22
+ "import": "./dist/gen/index.mjs",
23
+ "require": "./dist/cjs/gen/index.js"
24
+ },
25
+ "./openapi": {
26
+ "types": "./dist/openapi.d.ts",
27
+ "import": "./dist/openapi.mjs",
28
+ "require": "./dist/cjs/openapi.js"
29
+ },
30
+ "./scalar": {
31
+ "types": "./dist/scalar/index.d.ts",
32
+ "import": "./dist/scalar/index.mjs",
33
+ "require": "./dist/cjs/scalar/index.js"
34
+ },
35
+ "./scalar/theme": {
36
+ "types": "./dist/scalar/theme.d.ts",
37
+ "import": "./dist/scalar/theme.mjs",
38
+ "require": "./dist/cjs/scalar/theme.js"
39
+ },
40
+ "./swagger": {
41
+ "types": "./dist/swagger/index.d.ts",
42
+ "import": "./dist/swagger/index.mjs",
43
+ "require": "./dist/cjs/swagger/index.js"
44
+ },
45
+ "./swagger/types": {
46
+ "types": "./dist/swagger/types.d.ts",
47
+ "import": "./dist/swagger/types.mjs",
48
+ "require": "./dist/cjs/swagger/types.js"
49
+ },
50
+ "./types": {
51
+ "types": "./dist/types.d.ts",
52
+ "import": "./dist/types.mjs",
53
+ "require": "./dist/cjs/types.js"
54
+ }
55
+ },
56
+ "keywords": [
57
+ "elysia",
58
+ "openapi",
59
+ "swagger",
60
+ "scalar"
61
+ ],
62
+ "homepage": "https://github.com/elysiajs/elysia-openapi",
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "https://github.com/elysiajs/elysia-openapi"
66
+ },
67
+ "bugs": "https://github.com/elysiajs/elysia-openapi/issues",
68
+ "license": "MIT",
69
+ "scripts": {
70
+ "dev": "bun run --watch example/index.ts",
71
+ "test": "bun test && npm run test:node",
72
+ "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
73
+ "build": "bun build.ts",
74
+ "release": "npm run build && npm run test && npm publish --access public"
75
+ },
76
+ "peerDependencies": {
77
+ "elysia": ">= 1.3.0"
78
+ },
79
+ "devDependencies": {
80
+ "@apidevtools/swagger-parser": "^12.0.0",
81
+ "@types/bun": "1.2.20",
82
+ "@scalar/types": "^0.2.13",
83
+ "elysia": "1.3.21",
84
+ "eslint": "9.6.0",
85
+ "tsup": "^8.5.0",
86
+ "typescript": "^5.9.2"
87
+ },
88
+ "dependencies": {
89
+ "@sinclair/typemap": "^0.10.1",
90
+ "openapi-types": "^12.1.3"
91
+ }
92
+ }