Skip to content

Commit f6e3b24

Browse files
committed
test: update snapshots
1 parent 1cc2f0d commit f6e3b24

File tree

173 files changed

+6756
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+6756
-133
lines changed

packages/codegen-core/src/files/file.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ export class CodegenFile implements ICodegenFile {
217217

218218
relativePathToFile(file: Pick<ICodegenFile, 'path'>): string {
219219
let relativePath = path.posix.relative(
220-
path.posix.dirname(this.path),
221-
file.path,
220+
path.posix.dirname(
221+
this.path.split(path.sep).join('/'), // normalize to posix
222+
),
223+
file.path.split(path.sep).join('/'), // normalize to posix
222224
);
223-
if (!relativePath.startsWith('.')) {
225+
if (!relativePath.startsWith('.') && relativePath !== '') {
224226
relativePath = `./${relativePath}`;
225227
}
226228
return relativePath;
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
import { type Options, FooBazService, BarBazService } from '../sdk.gen';
4+
import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada';
5+
import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen';
6+
import { client } from '../client.gen';
7+
8+
export type QueryKey<TOptions extends Options> = [
9+
Pick<TOptions, 'body' | 'path'> & {
10+
_id: string;
11+
baseUrl?: _JSONValue;
12+
headers?: _JSONValue;
13+
query?: _JSONValue;
14+
tags?: _JSONValue;
15+
}
16+
];
17+
18+
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, tags?: ReadonlyArray<string>): [
19+
QueryKey<TOptions>[0]
20+
] => {
21+
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
22+
if (tags) {
23+
params.tags = tags as unknown as undefined;
24+
}
25+
if (options?.body) {
26+
params.body = options.body;
27+
}
28+
if (options?.headers) {
29+
params.headers = options.headers as unknown as undefined;
30+
}
31+
if (options?.path) {
32+
params.path = options.path;
33+
}
34+
if (options?.query) {
35+
params.query = options.query as unknown as undefined;
36+
}
37+
return [
38+
params
39+
];
40+
};
41+
42+
export const getFooQueryKey = (options?: Options<GetFooData>) => createQueryKey('getFoo', options);
43+
44+
export const getFooQuery = (options?: Options<GetFooData>): UseQueryOptions<GetFooResponse, Error> => {
45+
return {
46+
key: getFooQueryKey(options),
47+
query: async (context) => {
48+
const { data } = await FooBazService.getFoo({
49+
...options,
50+
...context,
51+
throwOnError: true
52+
});
53+
return data;
54+
}
55+
};
56+
};
57+
58+
export const fooPostMutation = (options?: Partial<Options<FooPostData>>): UseMutationOptions<FooPostResponse, Options<FooPostData>, Error> => {
59+
return {
60+
mutation: async (fnOptions) => {
61+
const { data } = await FooBazService.fooService.post({
62+
...options,
63+
...fnOptions,
64+
throwOnError: true
65+
});
66+
return data;
67+
}
68+
};
69+
};
70+
71+
export const fooPutMutation = (options?: Partial<Options<FooPutData>>): UseMutationOptions<FooPutResponse, Options<FooPutData>, Error> => {
72+
return {
73+
mutation: async (fnOptions) => {
74+
const { data } = await FooBazService.fooService.put({
75+
...options,
76+
...fnOptions,
77+
throwOnError: true
78+
});
79+
return data;
80+
}
81+
};
82+
};
83+
84+
export const getFooBarQueryKey = (options?: Options<GetFooBarData>) => createQueryKey('getFooBar', options);
85+
86+
export const getFooBarQuery = (options?: Options<GetFooBarData>): UseQueryOptions<GetFooBarResponse, Error> => {
87+
return {
88+
key: getFooBarQueryKey(options),
89+
query: async (context) => {
90+
const { data } = await BarBazService.getFooBar({
91+
...options,
92+
...context,
93+
throwOnError: true
94+
});
95+
return data;
96+
}
97+
};
98+
};
99+
100+
export const fooBarPostMutation = (options?: Partial<Options<FooBarPostData>>): UseMutationOptions<FooBarPostResponse, Options<FooBarPostData>, Error> => {
101+
return {
102+
mutation: async (fnOptions) => {
103+
const { data } = await FooBazService.fooService.barService.post({
104+
...options,
105+
...fnOptions,
106+
throwOnError: true
107+
});
108+
return data;
109+
}
110+
};
111+
};
112+
113+
export const fooBarPutMutation = (options?: Partial<Options<FooBarPutData>>): UseMutationOptions<FooBarPutResponse, Options<FooBarPutData>, Error> => {
114+
return {
115+
mutation: async (fnOptions) => {
116+
const { data } = await FooBazService.fooService.barService.put({
117+
...options,
118+
...fnOptions,
119+
throwOnError: true
120+
});
121+
return data;
122+
}
123+
};
124+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
import type { ClientOptions } from './types.gen';
4+
import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client';
5+
6+
/**
7+
* The `createClientConfig()` function will be called on client initialization
8+
* and the returned object will become the client's initial configuration.
9+
*
10+
* You may want to initialize your client this way instead of calling
11+
* `setConfig()`. This is useful for example if you're using Next.js
12+
* to ensure your client always has the correct values.
13+
*/
14+
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
15+
16+
export const client = createClient(createConfig<ClientOptions>());

0 commit comments

Comments
 (0)