chore(js-sdk): Compatible with nodenext (#1667)

This commit is contained in:
zWing
2025-08-09 08:05:50 +08:00
committed by GitHub
parent 83f4e8e156
commit 2f4291672b
11 changed files with 35 additions and 32 deletions

View File

@@ -12,7 +12,10 @@ await $`bun dev generate > ${dir}/openapi.json`.cwd(path.resolve(dir, "../../ope
await createClient({
input: "./openapi.json",
output: "./src/gen",
output: {
path: "./src/gen",
tsConfigPath: path.join(dir, 'tsconfig.json')
},
plugins: [
{
name: "@hey-api/typescript",

View File

@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { ClientOptions } from "./types.gen"
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from "./client"
import type { ClientOptions } from "./types.gen.js"
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from "./client/index.js"
/**
* The `createClientConfig()` function will be called on client initialization

View File

@@ -1,4 +1,4 @@
import type { Client, Config, RequestOptions } from "./types"
import type { Client, Config, RequestOptions } from "./types.js"
import {
buildUrl,
createConfig,
@@ -7,7 +7,7 @@ import {
mergeConfigs,
mergeHeaders,
setAuthParams,
} from "./utils"
} from "./utils.js"
type ReqInit = Omit<RequestInit, "body" | "headers"> & {
body?: any

View File

@@ -1,8 +1,8 @@
export type { Auth } from "../core/auth"
export type { QuerySerializerOptions } from "../core/bodySerializer"
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer } from "../core/bodySerializer"
export { buildClientParams } from "../core/params"
export { createClient } from "./client"
export type { Auth } from "../core/auth.js"
export type { QuerySerializerOptions } from "../core/bodySerializer.js"
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer } from "../core/bodySerializer.js"
export { buildClientParams } from "../core/params.js"
export { createClient } from "./client.js"
export type {
Client,
ClientOptions,
@@ -14,5 +14,5 @@ export type {
RequestResult,
ResponseStyle,
TDataShape,
} from "./types"
export { createConfig, mergeHeaders } from "./utils"
} from "./types.js"
export { createConfig, mergeHeaders } from "./utils.js"

View File

@@ -1,6 +1,6 @@
import type { Auth } from "../core/auth"
import type { Client as CoreClient, Config as CoreConfig } from "../core/types"
import type { Middleware } from "./utils"
import type { Auth } from "../core/auth.js"
import type { Client as CoreClient, Config as CoreConfig } from "../core/types.js"
import type { Middleware } from "./utils.js"
export type ResponseStyle = "data" | "fields"

View File

@@ -1,8 +1,8 @@
import { getAuthToken } from "../core/auth"
import type { QuerySerializer, QuerySerializerOptions } from "../core/bodySerializer"
import { jsonBodySerializer } from "../core/bodySerializer"
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "../core/pathSerializer"
import type { Client, ClientOptions, Config, RequestOptions } from "./types"
import { getAuthToken } from "../core/auth.js"
import type { QuerySerializer, QuerySerializerOptions } from "../core/bodySerializer.js"
import { jsonBodySerializer } from "../core/bodySerializer.js"
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "../core/pathSerializer.js"
import type { Client, ClientOptions, Config, RequestOptions } from "./types.js"
interface PathSerializer {
path: Record<string, unknown>

View File

@@ -1,4 +1,4 @@
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer"
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.js"
export type QuerySerializer = (query: Record<string, unknown>) => string

View File

@@ -1,5 +1,5 @@
import type { Auth, AuthToken } from "./auth"
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer"
import type { Auth, AuthToken } from "./auth.js"
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.js"
export interface Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> {
/**

View File

@@ -1,6 +1,6 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { Options as ClientOptions, TDataShape, Client } from "./client"
import type { Options as ClientOptions, TDataShape, Client } from "./client/index.js"
import type {
EventSubscribeData,
EventSubscribeResponses,
@@ -73,8 +73,8 @@ import type {
TuiClearPromptResponses,
TuiExecuteCommandData,
TuiExecuteCommandResponses,
} from "./types.gen"
import { client as _heyApiClient } from "./client.gen"
} from "./types.gen.js"
import { client as _heyApiClient } from "./client.gen.js"
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<
TData,

View File

@@ -1,7 +1,7 @@
import { createClient } from "./gen/client/client"
import { type Config } from "./gen/client/types"
import { OpencodeClient } from "./gen/sdk.gen"
export * from "./gen/types.gen"
import { createClient } from "./gen/client/client.js"
import { type Config } from "./gen/client/types.js"
import { OpencodeClient } from "./gen/sdk.gen.js"
export * from "./gen/types.gen.js"
export function createOpencodeClient(config?: Config) {
const client = createClient(config)

View File

@@ -3,9 +3,9 @@
"extends": "@tsconfig/node22/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "preserve",
"module": "nodenext",
"declaration": true,
"moduleResolution": "bundler",
"moduleResolution": "nodenext",
"lib": [
"es2022",
"dom",