Skip to content

Conversation

@vitrivdolkom
Copy link
Contributor

No description provided.

const instanceFile = plugin.createFile({
id: 'fetchesInstance',
path: normalizePath(`${plugin.output}/instance`)
path: nodePath.normalize(`${plugin.output}/instance`)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ρƒ Π½ΠΎΠ΄Ρ‹ Π΅ΡΡ‚ΡŒ ΡƒΠ΄ΠΎΠ±Π½Ρ‹ΠΉ ΠΌΠ΅Ρ‚ΠΎΠ΄ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π΄Π΅Π»Π°Π΅Ρ‚ Ρ‚ΠΎΠΆΠ΅ самоС ΠΈ Π΄Π°ΠΆΠ΅ большС

),
undefined
!requestHasRequiredParams
? ts.factory.createObjectLiteralExpression([], false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ссли Π² запросС Π½Π΅Ρ‚ ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ² Ρ‚ΠΎ Π΄Π΅Π»Π°Π΅ΠΌ ΠΏΠΎ Π΄Π΅Ρ„ΠΎΠ»Ρ‚Ρƒ пустой ΠΊΠΎΠ½Ρ„ΠΈΠ³ Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΌΠΎΠΆΠ½ΠΎ Π±Ρ‹Π»ΠΎ Π²Ρ‹Π·Ρ‹Π²Π°Ρ‚ΡŒ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΡŽ Π±Π΅Π· прокидывания ΠΊΠΎΠ½Ρ„ΠΈΠ³Π° getUsers()


requestFilePaths.forEach((requestFilePath) => {
generateQueryHookFile({ plugin, requestFilePath, request, requestName });
generateMutationHookFile({ plugin, requestFilePath, request, requestName });
Copy link
Contributor Author

@vitrivdolkom vitrivdolkom Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

довольно ΠΌΠ½ΠΎΠ³ΠΎ появляСтся условий ΠΈ нСкрасивых Ρ‚Π΅Ρ€Π½Π°Ρ€Π½ΠΈΠΊΠΎΠ² Ссли ΠΏΡ‹Ρ‚Π°Ρ‚ΡŒΡΡ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΡŽ сразу Π½Π° Π΄Π²Π° кСйса поэтому разнСс Π½Π° Π΄Π²Π΅ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ. Плюс Π΅Ρ‰Π΅ появится infinite query ΠΈ Ρ‚Π°ΠΌ Π²ΠΎΠΎΠ±Ρ‰Π΅ Π±ΡƒΠ΄ΡƒΡ‚ Π΄Ρ€ΡƒΠ³ΠΈΠ΅ поля

Для ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ запросы Π³Π΅Π½Π΅Ρ€ΠΈΠΌ сразу ΠΈ ΠΊΠ²Π΅Ρ€ΠΈ ΠΈ ΠΌΡƒΡ‚Π°Ρ†ΠΈΡŽ, я Π²ΠΈΠ΄Π΅Π» ΠΌΠ½ΠΎΠ³ΠΎ вопросов ΠΊ orval ΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠΌ Π³Π΅Π½Π΅Ρ€Π°Ρ‚ΠΎΡ€Π°ΠΌ ΠΏΠΎΡ‡Π΅ΠΌΡƒ ΠΌΠΎΠ» нСльзя ΡΠ³Π΅Π½Π΅Ρ€ΠΈΡ‚ΡŒ ΠΊΠ²Π΅Ρ€ΠΈ для post запроса ΠΈΠ»ΠΈ ΠΌΡƒΡ‚Π°Ρ†ΠΈΡŽ для get (Ρ‚Π°ΠΊΠΈΠ΅ кСйсы Π΅ΡΡ‚ΡŒ Π±ΡƒΠΊΠ²Π°Π»ΡŒΠ½ΠΎ Π½Π° ΠΊΠΏΠΊ). ΠŸΠΎΡΡ‚ΠΎΠΌΡƒ Π½Π°Π΄ΠΎ ΠΏΠΎΠ΄Π΄Π΅ΠΆΡ€Π°Ρ‚ΡŒ ΠΈ Ρ‚ΠΎ ΠΈ Ρ‚ΠΎ, ΠΌΠ± Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³ вынСсти настройку для этого Π»ΠΈΠ±ΠΎ просто всСгда Π³Π΅Ρ€Π΅Π½ΠΈΡ‚ΡŒ ΠΈ Ρ‚ΠΎ ΠΈ Ρ‚ΠΎ

query?: Omit<UseQueryOptions<Awaited<ReturnType<TFunc>>, never>, 'queryKey'>;
} & (IsParamsRequired<TFunc> extends true
? { request: NonNullable<Parameters<TFunc>[0]> }
: { request?: NonNullable<Parameters<TFunc>[0]> });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΠ» Π²Π°Ρ€ΠΈΠ°Π½Ρ‚ с ΠΊΠΏΠΊ, Ρ‚Π°ΠΌ Π½Π΅ Π±Ρ‹Π»ΠΎ ΡƒΡ‡Ρ‚Π΅Π½ΠΎ Ρ‡Ρ‚ΠΎ запрос ΠΌΠΎΠΆΠ΅Ρ‚ ΠΈΠΌΠ΅Ρ‚ΡŒ/Π½Π΅ ΠΈΠΌΠ΅Ρ‚ΡŒ ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ ΠΈ ΠΎΡ‚ этого Π΄ΠΎΠ»ΠΆΠ½Π° ΠΌΠ΅Π½ΡΡ‚ΡŒΡΡ типизация

queryKey: ['getUserByUsername', settings.request.path?.username],
queryFn: async () => getUserByUsername({ ...settings.request }),
...settings.query
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ΠΏΡ€ΠΈΠΌΠ΅Ρ€ ΠΊΠ°ΠΊ выглядит гСнСрация

@vitrivdolkom vitrivdolkom marked this pull request as ready for review November 6, 2025 15:03
Comment on lines 210 to +211
# Card standard
generated
!generated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

card стандар ΠΌΠΎΠΆΠ½ΠΎ ΠΈ Π²Ρ‹ΠΏΠΈΠ»ΠΈΡ‚ΡŒ )))

nameBy: z.enum(['path', 'operationId']).optional(),
groupBy: z.enum(['path', 'tag']).optional()
groupBy: z.enum(['path', 'tag']).optional(),
hooks: z.enum(['tanstack']).optional()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Π²ΠΎΡ‚ Ρ‚ΡƒΡ‚ ΡƒΠΆΠ΅ tanstack я Π΄ΡƒΠΌΠ°ΡŽ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠΌ, Π° Π½Π΅ Ρ‡Π΅Ρ€Π΅Π· ΠΏΠΎΠ»Π΅ hooks

normalizePath(`${plugin.output}/requests/${request.path}/${request.method.toLowerCase()}`)
);
}
const requestFilePaths = getRequestFilePaths({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requestFilePath = getRequestFilePath

Comment on lines +132 to +133
const requestHasPathParam = !!Object.keys(request.parameters?.path ?? {}).length;
const requestHasRequiredParam = checkRequestHasRequiredParam(request);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

МоТно Ρ„ΡƒΠ½ΠΊΡ†ΠΈΡŽ Π΄ΠΎΡ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ< Ρ‡Ρ‚ΠΎ ΠΎΠ½Π° Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π»Π° ΠΌΠ½ΠΎΠ³ΠΎ ΠΊΠ»ΡŽΡ‡Π΅ΠΉ ΠΈ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΡƒΠΆΠ΅ ΠΈΡ…, Π° Ρ‚ΠΎ ΠΎΠ΄Π½Π° ΠΈ Ρ‚Π°ΠΆΠ΅ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ°

const result.hasParams result.hasQuery ΠΈ Ρ‚Π΄


export const handler: TanstackPlugin['Handler'] = ({ plugin }) => {
plugin.forEach('operation', (event) => {
if (event.type !== 'operation') return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ρ‚ΡƒΠΏΠΎΠΉ вопрос, Π½ΠΎ Ρ‚Π°ΠΊΠΎΠ΅ Ρ€Π΅Π°Π»ΡŒΠ½ΠΎ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ?

ts.factory.createStringLiteral('@siberiacancode/apicraft')
);

// import type { getUserByUsername } from './getUserByUsername.gen';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getUserByUsername -> requestName

const requestPathParams = getRequestPathParams(request);
const requestHasRequiredParam = checkRequestHasRequiredParam(request);

// const useGetUserByUsernameQuery = (settings: TanstackQuerySettings<typeof getUserByUsername>) => useQuery
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useMethodRequestNameQuery

ts.factory.createCallExpression(ts.factory.createIdentifier('useQuery'), undefined, [
ts.factory.createObjectLiteralExpression(
[
// queryKey: ['getUserByUsername', settings.request.path.username]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['methodRequestName', ...settings.request.path]

ts.factory.createArrayLiteralExpression(
[
ts.factory.createStringLiteral(requestName),
...requestPathParams.map((requestPathParam) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Π½Π΅ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ path, Π΅Ρ‰Π΅ query Тишь аля Π»ΠΈΠΌΠΈΡ‚ ΠΈ Ρ‚Π΄


import { getUserByUsername } from '../../../requests/users/{username}/get.gen';

export const useGetUserByUsernameQuery = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ΠΏΠΎ Ρ‚ΠΈΠΏΠΈΠ·Π°Ρ†ΠΈΠΈ Π΅Ρ‰Π΅ Π½Π΅ понял, Π° Π² ΠΈΡ‚ΠΎΠ³Π΅ Π΅ΡΡ‚ΡŒ поля query request ΠΈΠ»ΠΈ ΠΊΠ°ΠΊ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants