Skip to content

Commit 765ab22

Browse files
authored
Merge pull request #3012 from hey-api/renovate/tsdown-0.x
chore(deps): update dependency tsdown to v0.16.6
2 parents ac3c026 + 3ae8d23 commit 765ab22

File tree

14 files changed

+473
-165
lines changed

14 files changed

+473
-165
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"rollup": "4.31.0",
6868
"rollup-plugin-dts": "6.1.1",
6969
"ts-node": "10.9.2",
70-
"tsdown": "0.15.12",
70+
"tsdown": "0.16.6",
7171
"turbo": "2.6.1",
7272
"typescript": "5.9.3",
7373
"typescript-eslint": "8.29.1",

packages/codegen-core/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
],
2727
"type": "module",
2828
"main": "./dist/index.cjs",
29-
"module": "./dist/index.js",
30-
"types": "./dist/index.d.ts",
29+
"module": "./dist/index.mjs",
30+
"types": "./dist/index.d.mts",
3131
"exports": {
3232
".": {
3333
"import": {
34-
"types": "./dist/index.d.ts",
35-
"default": "./dist/index.js"
34+
"types": "./dist/index.d.mts",
35+
"default": "./dist/index.mjs"
3636
},
3737
"require": {
3838
"types": "./dist/index.d.cts",

packages/codegen-core/tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default defineConfig((options) => ({
88
*/
99
if (ctx.format === 'esm') {
1010
return {
11-
js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);",
11+
js: `import { createRequire } from 'module'; const require = createRequire(import.${'meta'}.url);`,
1212
};
1313
}
1414

packages/config-vite-base/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "@config/vite-base",
33
"version": "0.0.1",
44
"description": "Base configuration for Vite and Vitest",
5-
"main": "dist/index.js",
6-
"module": "dist/index.js",
7-
"types": "dist/index.d.ts",
5+
"main": "dist/index.mjs",
6+
"module": "dist/index.mjs",
7+
"types": "dist/index.d.mts",
88
"license": "MIT",
99
"type": "module",
1010
"scripts": {

packages/custom-client/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
"funding": "https://github.com/sponsors/hey-api",
2121
"type": "module",
2222
"main": "./dist/index.cjs",
23-
"module": "./dist/index.js",
24-
"types": "./dist/index.d.ts",
23+
"module": "./dist/index.mjs",
24+
"types": "./dist/index.d.mts",
2525
"exports": {
2626
".": {
2727
"import": {
28-
"types": "./dist/index.d.ts",
29-
"default": "./dist/index.js"
28+
"types": "./dist/index.d.mts",
29+
"default": "./dist/index.mjs"
3030
},
3131
"require": {
3232
"types": "./dist/index.d.cts",
@@ -35,8 +35,8 @@
3535
},
3636
"./plugin": {
3737
"import": {
38-
"types": "./dist/plugin.d.ts",
39-
"default": "./dist/plugin.js"
38+
"types": "./dist/plugin.d.mts",
39+
"default": "./dist/plugin.mjs"
4040
},
4141
"require": {
4242
"types": "./dist/plugin.d.cts",

packages/custom-client/rollup.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path';
33
import { defineConfig } from 'rollup';
44
import dts from 'rollup-plugin-dts';
55

6-
const files = ['index.d.ts', 'index.d.cts', 'plugin.d.ts', 'plugin.d.cts'];
6+
const files = ['index.d.mts', 'index.d.cts', 'plugin.d.mts', 'plugin.d.cts'];
77

88
export default files.map((file) =>
99
defineConfig({
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
//#region src/core/auth.d.ts
2+
type AuthToken = string | undefined;
3+
interface Auth {
4+
/**
5+
* Which part of the request do we use to send the auth?
6+
*
7+
* @default 'header'
8+
*/
9+
in?: 'header' | 'query' | 'cookie';
10+
/**
11+
* Header or query parameter name.
12+
*
13+
* @default 'Authorization'
14+
*/
15+
name?: string;
16+
scheme?: 'basic' | 'bearer';
17+
type: 'apiKey' | 'http';
18+
}
19+
//#endregion
20+
//#region src/core/pathSerializer.d.ts
21+
interface SerializerOptions<T> {
22+
/**
23+
* @default true
24+
*/
25+
explode: boolean;
26+
style: T;
27+
}
28+
type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
29+
type ObjectStyle = 'form' | 'deepObject';
30+
//#endregion
31+
//#region src/core/bodySerializer.d.ts
32+
type QuerySerializer = (query: Record<string, unknown>) => string;
33+
type BodySerializer = (body: any) => any;
34+
type QuerySerializerOptionsObject = {
35+
allowReserved?: boolean;
36+
array?: Partial<SerializerOptions<ArrayStyle>>;
37+
object?: Partial<SerializerOptions<ObjectStyle>>;
38+
};
39+
type QuerySerializerOptions = QuerySerializerOptionsObject & {
40+
/**
41+
* Per-parameter serialization overrides. When provided, these settings
42+
* override the global array/object settings for specific parameter names.
43+
*/
44+
parameters?: Record<string, QuerySerializerOptionsObject>;
45+
};
46+
declare const formDataBodySerializer: {
47+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => FormData;
48+
};
49+
declare const jsonBodySerializer: {
50+
bodySerializer: <T>(body: T) => string;
51+
};
52+
declare const urlSearchParamsBodySerializer: {
53+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string;
54+
};
55+
//#endregion
56+
//#region src/core/types.d.ts
57+
interface Client$1<RequestFn$1 = never, Config$2 = unknown, MethodFn$1 = never, BuildUrlFn$1 = never> {
58+
/**
59+
* Returns the final request URL.
60+
*/
61+
buildUrl: BuildUrlFn$1;
62+
connect: MethodFn$1;
63+
delete: MethodFn$1;
64+
get: MethodFn$1;
65+
getConfig: () => Config$2;
66+
head: MethodFn$1;
67+
options: MethodFn$1;
68+
patch: MethodFn$1;
69+
post: MethodFn$1;
70+
put: MethodFn$1;
71+
request: RequestFn$1;
72+
setConfig: (config: Config$2) => Config$2;
73+
trace: MethodFn$1;
74+
}
75+
interface Config$1 {
76+
/**
77+
* Auth token or a function returning auth token. The resolved value will be
78+
* added to the request payload as defined by its `security` array.
79+
*/
80+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
81+
/**
82+
* A function for serializing request body parameter. By default,
83+
* {@link JSON.stringify()} will be used.
84+
*/
85+
bodySerializer?: BodySerializer | null;
86+
/**
87+
* An object containing any HTTP headers that you want to pre-populate your
88+
* `Headers` object with.
89+
*
90+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
91+
*/
92+
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
93+
/**
94+
* The request method.
95+
*
96+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
97+
*/
98+
method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
99+
/**
100+
* A function for serializing request query parameters. By default, arrays
101+
* will be exploded in form style, objects will be exploded in deepObject
102+
* style, and reserved characters are percent-encoded.
103+
*
104+
* This method will have no effect if the native `paramsSerializer()` Axios
105+
* API function is used.
106+
*
107+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
108+
*/
109+
querySerializer?: QuerySerializer | QuerySerializerOptions;
110+
/**
111+
* A function validating request data. This is useful if you want to ensure
112+
* the request conforms to the desired shape, so it can be safely sent to
113+
* the server.
114+
*/
115+
requestValidator?: (data: unknown) => Promise<unknown>;
116+
/**
117+
* A function transforming response data before it's returned. This is useful
118+
* for post-processing data, e.g. converting ISO strings into Date objects.
119+
*/
120+
responseTransformer?: (data: unknown) => Promise<unknown>;
121+
/**
122+
* A function validating response data. This is useful if you want to ensure
123+
* the response conforms to the desired shape, so it can be safely passed to
124+
* the transformers and returned to the user.
125+
*/
126+
responseValidator?: (data: unknown) => Promise<unknown>;
127+
}
128+
//#endregion
129+
//#region src/utils.d.ts
130+
type ErrInterceptor<Err, Res, Req, Options$1> = (error: Err, response: Res, request: Req, options: Options$1) => Err | Promise<Err>;
131+
type ReqInterceptor<Req, Options$1> = (request: Req, options: Options$1) => Req | Promise<Req>;
132+
type ResInterceptor<Res, Req, Options$1> = (response: Res, request: Req, options: Options$1) => Res | Promise<Res>;
133+
declare class Interceptors<Interceptor> {
134+
fns: Array<Interceptor | null>;
135+
clear(): void;
136+
eject(id: number | Interceptor): void;
137+
exists(id: number | Interceptor): boolean;
138+
getInterceptorIndex(id: number | Interceptor): number;
139+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
140+
use(fn: Interceptor): number;
141+
}
142+
interface Middleware<Req, Res, Err, Options$1> {
143+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options$1>>;
144+
request: Interceptors<ReqInterceptor<Req, Options$1>>;
145+
response: Interceptors<ResInterceptor<Res, Req, Options$1>>;
146+
}
147+
declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
148+
//#endregion
149+
//#region src/types.d.ts
150+
interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
151+
/**
152+
* Base URL for all requests made by this client.
153+
*/
154+
baseUrl?: T['baseUrl'];
155+
/**
156+
* Fetch API implementation. You can use this option to provide a custom
157+
* fetch instance.
158+
*
159+
* @default globalThis.fetch
160+
*/
161+
fetch?: (request: Request) => ReturnType<typeof fetch>;
162+
/**
163+
* Return the response data parsed in a specified format. By default, `auto`
164+
* will infer the appropriate method from the `Content-Type` response header.
165+
* You can override this behavior with any of the {@link Body} methods.
166+
* Select `stream` if you don't want to parse response data at all.
167+
*
168+
* @default 'auto'
169+
*/
170+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
171+
/**
172+
* Throw an error instead of returning it in the response?
173+
*
174+
* @default false
175+
*/
176+
throwOnError?: T['throwOnError'];
177+
}
178+
interface RequestOptions<ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
179+
throwOnError: ThrowOnError;
180+
}> {
181+
/**
182+
* Any body that you want to add to your request.
183+
*
184+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
185+
*/
186+
body?: unknown;
187+
path?: Record<string, unknown>;
188+
query?: Record<string, unknown>;
189+
/**
190+
* Security mechanism(s) to use for the request.
191+
*/
192+
security?: ReadonlyArray<Auth>;
193+
url: Url;
194+
}
195+
type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<{
196+
data: TData;
197+
request: Request;
198+
response: Response;
199+
}> : Promise<({
200+
data: TData;
201+
error: undefined;
202+
} | {
203+
data: undefined;
204+
error: TError;
205+
}) & {
206+
request: Request;
207+
response: Response;
208+
}>;
209+
interface ClientOptions {
210+
baseUrl?: string;
211+
throwOnError?: boolean;
212+
}
213+
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError>;
214+
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<ThrowOnError>, 'method'> & Pick<Required<RequestOptions<ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError>;
215+
type BuildUrlFn = <TData extends {
216+
body?: unknown;
217+
path?: Record<string, unknown>;
218+
query?: Record<string, unknown>;
219+
url: string;
220+
}>(options: Pick<TData, 'url'> & Options<TData>) => string;
221+
type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn> & {
222+
interceptors: Middleware<Request, Response, unknown, RequestOptions>;
223+
};
224+
/**
225+
* The `createClientConfig()` function will be called on client initialization
226+
* and the returned object will become the client's initial configuration.
227+
*
228+
* You may want to initialize your client this way instead of calling
229+
* `setConfig()`. This is useful for example if you're using Next.js
230+
* to ensure your client always has the correct values.
231+
*/
232+
type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
233+
interface TDataShape {
234+
body?: unknown;
235+
headers?: unknown;
236+
path?: unknown;
237+
query?: unknown;
238+
url: string;
239+
}
240+
type OmitKeys<T, K$1> = Pick<T, Exclude<keyof T, K$1>>;
241+
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'>;
242+
//#endregion
243+
//#region src/client.d.ts
244+
declare const createClient: (config?: Config) => Client;
245+
//#endregion
246+
//#region src/core/params.d.ts
247+
type Slot = 'body' | 'headers' | 'path' | 'query';
248+
type Field = {
249+
in: Exclude<Slot, 'body'>;
250+
key: string;
251+
map?: string;
252+
} | {
253+
in: Extract<Slot, 'body'>;
254+
key?: string;
255+
map?: string;
256+
};
257+
interface Fields {
258+
allowExtra?: Partial<Record<Slot, boolean>>;
259+
args?: ReadonlyArray<Field>;
260+
}
261+
type FieldsConfig = ReadonlyArray<Field | Fields>;
262+
interface Params {
263+
body: unknown;
264+
headers: Record<string, unknown>;
265+
path: Record<string, unknown>;
266+
query: Record<string, unknown>;
267+
}
268+
declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params;
269+
//# sourceMappingURL=index.d.mts.map
270+
271+
export { type Auth, type Client, type ClientOptions, type Config, type CreateClientConfig, type Options, type QuerySerializerOptions, type RequestOptions, type RequestResult, type TDataShape, buildClientParams, createClient, createConfig, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };

packages/openapi-ts/bin/run.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import path from 'node:path';
55
import { fileURLToPath } from 'node:url';
66

77
const __dirname = path.dirname(fileURLToPath(import.meta.url));
8-
const target = path.join(__dirname, '..', 'dist', 'run.js');
8+
const target = path.join(__dirname, '..', 'dist', 'run.mjs');
99

1010
if (!fs.existsSync(target)) {
11-
console.error('openapi-ts not built (expect dist/run.js)');
11+
console.error('openapi-ts not built (expect dist/run.mjs)');
1212
process.exit(1);
1313
}
1414

0 commit comments

Comments
 (0)