@vafast/cli 0.1.6 → 0.1.8

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/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { syncTypes } from "./sync-LIyNoB1P.js";
1
+ import { syncTypes } from "./sync-CroyE4Do.js";
2
2
  import { cac } from "cac";
3
3
 
4
4
  //#region src/cli.ts
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { schemaToType, syncTypes } from "./sync-LIyNoB1P.js";
1
+ import { schemaToType, syncTypes } from "./sync-CroyE4Do.js";
2
2
 
3
3
  export { schemaToType, syncTypes };
@@ -105,6 +105,7 @@ async function syncTypes(options) {
105
105
  */
106
106
  function generateTypeDefinition(contract, stripPrefix) {
107
107
  const lines = [];
108
+ const hasSSE = contract.routes.some((route) => route.sse);
108
109
  lines.push("/**");
109
110
  lines.push(" * 自动生成的 API 类型定义");
110
111
  lines.push(` * 生成时间: ${contract.generatedAt}`);
@@ -113,19 +114,22 @@ function generateTypeDefinition(contract, stripPrefix) {
113
114
  lines.push(" * ⚠️ 请勿手动修改此文件,使用 `vafast sync` 重新生成");
114
115
  lines.push(" */");
115
116
  lines.push("");
116
- lines.push("import type { ApiResponse, RequestConfig, Client, EdenClient, SSESubscription, SSESubscribeOptions } from '@vafast/api-client'");
117
+ if (hasSSE) lines.push("import type { ApiResponse, RequestConfig, Client, EdenClient, SSESubscription, SSESubscribeOptions } from '@vafast/api-client'");
118
+ else lines.push("import type { ApiResponse, RequestConfig, Client, EdenClient } from '@vafast/api-client'");
117
119
  lines.push("import { eden } from '@vafast/api-client'");
118
120
  lines.push("");
119
- lines.push("/** SSE 回调接口 */");
120
- lines.push("interface SSECallbacks<T> {");
121
- lines.push(" onMessage: (data: T) => void");
122
- lines.push(" onError?: (error: { code: number; message: string }) => void");
123
- lines.push(" onOpen?: () => void");
124
- lines.push(" onClose?: () => void");
125
- lines.push(" onReconnect?: (attempt: number, maxAttempts: number) => void");
126
- lines.push(" onMaxReconnects?: () => void");
127
- lines.push("}");
128
- lines.push("");
121
+ if (hasSSE) {
122
+ lines.push("/** SSE 回调接口 */");
123
+ lines.push("interface SSECallbacks<T> {");
124
+ lines.push(" onMessage: (data: T) => void");
125
+ lines.push(" onError?: (error: { code: number; message: string }) => void");
126
+ lines.push(" onOpen?: () => void");
127
+ lines.push(" onClose?: () => void");
128
+ lines.push(" onReconnect?: (attempt: number, maxAttempts: number) => void");
129
+ lines.push(" onMaxReconnects?: () => void");
130
+ lines.push("}");
131
+ lines.push("");
132
+ }
129
133
  const routeTree = buildRouteTree(contract.routes, stripPrefix);
130
134
  lines.push("/** API 契约类型 */");
131
135
  lines.push("export type Api = {");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vafast/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Vafast CLI - 类型同步和开发工具",
5
5
  "type": "module",
6
6
  "bin": {