hono-takibi 0.9.9998 → 0.9.99991

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/README.md CHANGED
@@ -4,12 +4,6 @@
4
4
 
5
5
  ![img](https://raw.githubusercontent.com/nakita628/hono-takibi/refs/heads/main/assets/img/hono-takibi.png)
6
6
 
7
- ```bash
8
- npm install -D hono-takibi
9
- ```
10
-
11
- ## OpenAPI to Hono Code Generator
12
-
13
7
  **[Hono Takibi](https://www.npmjs.com/package/hono-takibi)** generates type-safe [Hono](https://hono.dev/) code from [OpenAPI](https://www.openapis.org/) / [TypeSpec](https://typespec.io/) specifications.
14
8
 
15
9
  - OpenAPI schemas to [Zod](https://zod.dev/) schemas
@@ -19,6 +13,10 @@ npm install -D hono-takibi
19
13
  - RPC client, mock server, TypeScript types
20
14
  - API reference docs with [hono-cli](https://github.com/honojs/cli) commands
21
15
 
16
+ ```bash
17
+ npm install -D hono-takibi
18
+ ```
19
+
22
20
  ## Quick Start
23
21
 
24
22
  ### CLI
@@ -278,7 +276,7 @@ export default defineConfig({
278
276
  })
279
277
  ```
280
278
 
281
- ### API Reference Docs
279
+ ## API Reference Docs
282
280
 
283
281
  Generate API reference Markdown with [hono-cli](https://github.com/honojs/cli) `hono request` commands:
284
282
 
@@ -314,11 +312,11 @@ import { defineConfig } from 'hono-takibi/config'
314
312
 
315
313
  export default defineConfig({
316
314
  input: 'openapi.yaml',
317
- basePath: '/api',
318
- // format: {}, // oxfmt FormatConfig
319
315
 
320
316
  output: './src/routes.ts', // single-file mode; with template.define, the app entry (required)
317
+ basePath: '/api',
321
318
  readonly: true,
319
+ // format: {}, // oxfmt FormatConfig
322
320
 
323
321
  template: {
324
322
  test: true,
@@ -499,7 +497,11 @@ export default defineConfig({
499
497
  })
500
498
  ```
501
499
 
502
- ## Custom Validation Error Messages
500
+ ## Vendor Extensions (x-\*)
501
+
502
+ hono-takibi reads `x-*` vendor extensions on your OpenAPI / JSON Schema to customize the generated Zod. Each extension maps 1:1 to a Zod feature.
503
+
504
+ ### Custom Validation Error Messages
503
505
 
504
506
  Use `x-*` vendor extensions to attach custom Zod error messages, with **one extension per JSON Schema keyword** (1:1 mapping). The extension name follows the pattern `x-<jsonSchemaKeyword>-message` (e.g. `x-minLength-message`, `x-pattern-message`), plus four generic forms: `x-error-message`, `x-required-message`, `x-const-message`, `x-enum-message`.
505
507
 
@@ -519,8 +521,6 @@ z.string({ error: 'Name must be a string' })
519
521
  .max(50, { error: 'Name must be at most 50 characters' })
520
522
  ```
521
523
 
522
- ### Extension Reference
523
-
524
524
  All custom message extensions follow the `x-<keyword>-message` naming convention and map directly to Zod validator error messages.
525
525
 
526
526
  #### Common (any schema type)
@@ -602,9 +602,9 @@ All custom message extensions follow the `x-<keyword>-message` naming convention
602
602
  | `x-unevaluatedProperties-message` | `unevaluatedProperties` |
603
603
  | `x-unevaluatedItems-message` | `unevaluatedItems` |
604
604
 
605
- ## Behavior Extensions
605
+ ### Behavior Extensions
606
606
 
607
- ### String Pre-validation Transforms
607
+ #### String Pre-validation Transforms
608
608
 
609
609
  | Extension | Generated | Value |
610
610
  | --------------- | ----------------------------- | --------------------------------------- |
@@ -624,7 +624,7 @@ homepage:
624
624
  z.string().trim().pipe(z.url())
625
625
  ```
626
626
 
627
- ### String Validation Checks
627
+ #### String Validation Checks
628
628
 
629
629
  | Extension | Generated | Value |
630
630
  | ------------- | ------------------------ | ------ |
@@ -641,9 +641,9 @@ slug:
641
641
  z.string().lowercase()
642
642
  ```
643
643
 
644
- ### Preprocess (Input Normalization)
644
+ #### Preprocess
645
645
 
646
- #### `x-preprocess`
646
+ **`x-preprocess`**
647
647
 
648
648
  ```yaml
649
649
  username:
@@ -655,9 +655,9 @@ username:
655
655
  z.preprocess((val) => (typeof val === 'string' ? val.trim() : val), z.string())
656
656
  ```
657
657
 
658
- ### Type Coercion
658
+ #### Type Coercion
659
659
 
660
- #### `x-coerce`
660
+ **`x-coerce`**
661
661
 
662
662
  ```yaml
663
663
  asNumber:
@@ -674,7 +674,7 @@ z.coerce.number()
674
674
  z.coerce.date()
675
675
  ```
676
676
 
677
- #### `x-stringbool`
677
+ **`x-stringbool`**
678
678
 
679
679
  ```yaml
680
680
  notify:
@@ -699,27 +699,27 @@ notify:
699
699
  z.stringbool({ truthy: ['yes', 'on'], falsy: ['no', 'off'], case: 'sensitive' })
700
700
  ```
701
701
 
702
- ### Codec (Bidirectional Transform)
702
+ #### Codec
703
703
 
704
- #### `x-codec`
704
+ **`x-codec`**
705
705
 
706
706
  ```yaml
707
707
  updatedAt:
708
708
  type: string
709
709
  format: date-time
710
- x-codec: 'z.codec(z.iso.datetime(), z.date(), { decode: (val) => new Date(val), encode: (val) => val.toISOString() })'
710
+ x-codec: 'z.codec(z.iso.datetime(), z.date(), { decode: (isoString) => new Date(isoString), encode: (date) => date.toISOString() })'
711
711
  ```
712
712
 
713
713
  ```ts
714
714
  z.codec(z.iso.datetime(), z.date(), {
715
- decode: (val) => new Date(val),
716
- encode: (val) => val.toISOString(),
715
+ decode: (isoString) => new Date(isoString),
716
+ encode: (date) => date.toISOString(),
717
717
  })
718
718
  ```
719
719
 
720
- ### Custom Validation
720
+ #### Custom Validation
721
721
 
722
- #### `x-refine`
722
+ **`x-refine`**
723
723
 
724
724
  ```yaml
725
725
  password:
@@ -733,7 +733,7 @@ z.string()
733
733
  .refine((val) => /[A-Z]/.test(val), { message: 'Password must contain an uppercase letter' })
734
734
  ```
735
735
 
736
- #### `x-superRefine`
736
+ **`x-superRefine`**
737
737
 
738
738
  ```yaml
739
739
  normalizedEmail:
@@ -750,9 +750,9 @@ z.email().superRefine((val, ctx) => {
750
750
  })
751
751
  ```
752
752
 
753
- ### Transform & Pipe
753
+ #### Transform & Pipe
754
754
 
755
- #### `x-transform`
755
+ **`x-transform`**
756
756
 
757
757
  ```yaml
758
758
  code:
@@ -764,7 +764,7 @@ code:
764
764
  z.string().transform((val) => val.toUpperCase())
765
765
  ```
766
766
 
767
- #### `x-pipe`
767
+ **`x-pipe`**
768
768
 
769
769
  ```yaml
770
770
  port:
@@ -776,9 +776,9 @@ port:
776
776
  z.string().pipe(z.number().int().positive())
777
777
  ```
778
778
 
779
- ### Default & Fallback Values
779
+ #### Default & Fallback Values
780
780
 
781
- #### `x-prefault`
781
+ **`x-prefault`**
782
782
 
783
783
  ```yaml
784
784
  greeting:
@@ -790,7 +790,7 @@ greeting:
790
790
  z.string().prefault('hello')
791
791
  ```
792
792
 
793
- #### `x-catch`
793
+ **`x-catch`**
794
794
 
795
795
  ```yaml
796
796
  retries:
@@ -802,9 +802,9 @@ retries:
802
802
  z.int().catch(0)
803
803
  ```
804
804
 
805
- ### Immutability
805
+ #### Immutability
806
806
 
807
- #### `x-readonly`
807
+ **`x-readonly`**
808
808
 
809
809
  ```yaml
810
810
  config:
@@ -819,9 +819,9 @@ config:
819
819
  z.object({ name: z.string() }).readonly()
820
820
  ```
821
821
 
822
- ### String Content Checks
822
+ #### String Content Checks
823
823
 
824
- #### `x-startsWith` / `x-endsWith` / `x-includes`
824
+ **`x-startsWith` / `x-endsWith` / `x-includes`**
825
825
 
826
826
  ```yaml
827
827
  url:
@@ -838,7 +838,7 @@ z.string().startsWith('https://').endsWith('.com')
838
838
  z.string().includes('/api/')
839
839
  ```
840
840
 
841
- ### Format-Specific Options
841
+ #### Format-Specific Options
842
842
 
843
843
  ```yaml
844
844
  htmlEmail:
@@ -861,23 +861,23 @@ preciseDatetime:
861
861
  x-isoOffset: true
862
862
  ```
863
863
 
864
- | Extension | Maps to | Values |
865
- | ---------------- | ------------------------------- | -------------------------------- |
866
- | `x-emailPattern` | `z.email({ pattern })` | `html5` / `browser` / `unicode` |
867
- | `x-emailRegex` | `z.email({ pattern: /.../ })` | custom regex string |
868
- | `x-uuidVersion` | `z.uuid({ version })` | `v1` / `v4` / `v6` / `v7` / `v8` |
869
- | `x-urlProtocol` | `z.url({ protocol: /.../ })` | regex string |
870
- | `x-urlHostname` | `z.url({ hostname: /.../ })` | regex string |
871
- | `x-urlNormalize` | `z.url({ normalize })` | `true` / `false` |
872
- | `x-isoPrecision` | `z.iso.datetime({ precision })` | fractional second digits |
873
- | `x-isoOffset` | `z.iso.datetime({ offset })` | `true` / `false` |
874
- | `x-isoLocal` | `z.iso.datetime({ local })` | `true` / `false` |
875
- | `x-macDelimiter` | `z.mac({ delimiter })` | `:` / `-` / `.` |
876
- | `x-jwtAlg` | `z.jwt({ alg })` | `HS256` etc. |
877
- | `x-hashAlg` | `z.hash(alg, ...)` | `sha256` etc. |
878
- | `x-hashEnc` | `z.hash(alg, { enc })` | `hex` / `base64` / `base64url` |
879
-
880
- ## Branded Types
864
+ | Extension | Maps to | Values |
865
+ | ---------------- | ------------------------------- | ----------------------------------------------------- |
866
+ | `x-emailPattern` | `z.email({ pattern })` | `html5` / `rfc5322` / `unicode` |
867
+ | `x-emailRegex` | `z.email({ pattern: /.../ })` | custom regex string |
868
+ | `x-uuidVersion` | `z.uuid({ version })` | `v1` / `v2` / `v3` / `v4` / `v5` / `v6` / `v7` / `v8` |
869
+ | `x-urlProtocol` | `z.url({ protocol: /.../ })` | regex string |
870
+ | `x-urlHostname` | `z.url({ hostname: /.../ })` | regex string |
871
+ | `x-urlNormalize` | `z.url({ normalize })` | `true` / `false` |
872
+ | `x-isoPrecision` | `z.iso.datetime({ precision })` | fractional second digits |
873
+ | `x-isoOffset` | `z.iso.datetime({ offset })` | `true` / `false` |
874
+ | `x-isoLocal` | `z.iso.datetime({ local })` | `true` / `false` |
875
+ | `x-macDelimiter` | `z.mac({ delimiter })` | `:` / `-` / `.` |
876
+ | `x-jwtAlg` | `z.jwt({ alg })` | `HS256` etc. |
877
+ | `x-hashAlg` | `z.hash(alg, ...)` | `sha256` etc. |
878
+ | `x-hashEnc` | `z.hash(alg, { enc })` | `hex` / `base64` / `base64url` |
879
+
880
+ ### Branded Types (x-brand)
881
881
 
882
882
  Use the `x-brand` vendor extension to generate [Zod branded types](https://zod.dev/api?id=branded-types), creating nominal types that are structurally identical but semantically distinct:
883
883
 
@@ -1,2 +1,2 @@
1
- import { t as hooks } from "../../hooks-Dk7Z5hMb.js";
1
+ import { t as hooks } from "../../hooks-CkiatAe9.js";
2
2
  export { hooks };
@@ -77,17 +77,21 @@ function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, a
77
77
  }
78
78
  function makeInfiniteQueryOptionsGetterCode(optionsGetterName, infiniteKeyGetterName, hasArgs, argsType, runtimeAccess, responseType, config) {
79
79
  const queryKeyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
80
+ const queryFnSig = `{pageParam,signal}:QueryFunctionContext<${`ReturnType<typeof ${infiniteKeyGetterName}>`},TPageParam>`;
81
+ const getRequestArgsField = hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
82
+ const requestArgsCall = (argsExpr) => hasArgs ? `pagination.getRequestArgs(${argsExpr},pageParam)` : `pagination.getRequestArgs(pageParam)`;
80
83
  if (config.hasInfiniteQueryOptionsHelper) {
81
- const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null}`;
82
- if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${`queryKey:${queryKeyCall},queryFn({signal}:QueryFunctionContext){return ${`parseResponse(${runtimeAccess}(toValue(args),{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`}})}`;
83
- const body = `queryKey:${queryKeyCall},queryFn({signal}:QueryFunctionContext){return ${hasArgs ? `parseResponse(${runtimeAccess}(args,{...options,init:{...options?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`;
84
+ const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null;${getRequestArgsField}}`;
85
+ if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${`queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`}})}`;
86
+ const body = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`;
84
87
  if (hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:${argsType},${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${body}})}`;
85
88
  return `export function ${optionsGetterName}<TPageParam=unknown>(${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${body}})}`;
86
89
  }
87
- if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}(args:MaybeRefOrGetter<${argsType}>,options?:ClientRequestOptions){return {${`queryKey:${queryKeyCall},queryFn({signal}:QueryFunctionContext){return ${`parseResponse(${runtimeAccess}(toValue(args),{...options,init:{...options?.init,signal}}))`}}`}}}`;
88
- const bodyContent = `queryKey:${queryKeyCall},queryFn({signal}:QueryFunctionContext){return ${hasArgs ? `parseResponse(${runtimeAccess}(args,{...options,init:{...options?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...options,init:{...options?.init,signal}}))`}}`;
89
- if (hasArgs) return `export function ${optionsGetterName}(args:${argsType},options?:ClientRequestOptions){return {${bodyContent}}}`;
90
- return `export function ${optionsGetterName}(options?:ClientRequestOptions){return {${bodyContent}}}`;
90
+ const vuePaginationParam = `pagination:{${getRequestArgsField}}`;
91
+ if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${vuePaginationParam},options?:ClientRequestOptions){return {${`queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...options,init:{...options?.init,signal}}))`}}`}}}`;
92
+ const bodyContent = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}}`;
93
+ if (hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:${argsType},${vuePaginationParam},options?:ClientRequestOptions){return {${bodyContent}}}`;
94
+ return `export function ${optionsGetterName}<TPageParam=unknown>(${vuePaginationParam},options?:ClientRequestOptions){return {${bodyContent}}}`;
91
95
  }
92
96
  function makeMutationOptionsGetterCode(optionsGetterName, hasArgs, argsType, runtimeAccess, method, honoPath, responseType, hasNoContent, config) {
93
97
  const methodUpper = method.toUpperCase();
@@ -123,7 +127,10 @@ function makeSWRQueryHookCode(hookName, keyGetterName, hasArgs, argsType, runtim
123
127
  */
124
128
  function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, errorType = "unknown") {
125
129
  const argsSig = hasArgs ? `args:${argsType},` : "";
126
- return `export function ${hookName}${`<TError=${errorType}>`}(${argsSig}${`options:{swr?:${`SWRInfiniteConfiguration<${responseType},TError>&{swrKey?:SWRInfiniteKeyLoader}`};options?:ClientRequestOptions}`}){const{swr:swrOptions,options:clientOptions}=options??{};const{swrKey:customKeyLoader,...restSwrOptions}=swrOptions??{};const keyLoader=customKeyLoader??((index:number)=>[...${hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`},index]as const);return useSWRInfinite(keyLoader,async()=>${hasArgs ? `parseResponse(${runtimeAccess}(args,clientOptions))` : `parseResponse(${runtimeAccess}(undefined,clientOptions))`},restSwrOptions)}`;
130
+ const tErrorGeneric = `<TError=${errorType}>`;
131
+ const keyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
132
+ const loaderKeyType = `readonly[...${`ReturnType<typeof ${infiniteKeyGetterName}>`},number]`;
133
+ return `export function ${hookName}${tErrorGeneric}(${argsSig}${`options:{swr?:${`SWRInfiniteConfiguration<${responseType},TError>&{swrKey?:(index:number,previousPageData:${responseType}|null)=>${loaderKeyType}}`};options?:ClientRequestOptions;pagination:{${hasArgs ? `getRequestArgs:(args:${argsType},index:number)=>${argsType}` : `getRequestArgs:(index:number)=>${argsType}`}}}`}){const{swr:swrOptions,options:clientOptions,pagination}=options;const{swrKey:customKeyLoader,...restSwrOptions}=swrOptions??{};const keyLoader=customKeyLoader??((index:number)=>[...${keyCall},index]as const);return useSWRInfinite(keyLoader,(${`[${",".repeat(hasArgs ? 4 : 3)}index]:${loaderKeyType}`})=>parseResponse(${runtimeAccess}(${hasArgs ? `pagination.getRequestArgs(args,index)` : `pagination.getRequestArgs(index)`},clientOptions)),restSwrOptions)}`;
127
134
  }
128
135
  /**
129
136
  * Generates a query hook with inline queryKey + queryFn. The hook builds its own
@@ -194,8 +201,8 @@ function makeSuspenseQueryHookCode(hookName, keyGetterName, runtimeAccess, hasAr
194
201
  * contextual typing for `signal: AbortSignal`, so the annotation is redundant and breaks
195
202
  * Vue Query's narrow per-call queryKey inference.
196
203
  */
197
- function makeInfiniteHookBody(keyCall, fetcherCall, useHelper, isVueQuery = false) {
198
- const base = `queryKey:${keyCall},queryFn(${isVueQuery ? "{signal}" : "{signal}:QueryFunctionContext"}){return ${fetcherCall}}`;
204
+ function makeInfiniteHookBody(keyCall, fetcherCall, useHelper, queryKeyType, isVueQuery = false) {
205
+ const base = `queryKey:${keyCall},queryFn(${isVueQuery ? "{pageParam,signal}" : `{pageParam,signal}:QueryFunctionContext<${queryKeyType},TPageParam>`}){return ${fetcherCall}}`;
199
206
  return useHelper ? `${base},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam` : base;
200
207
  }
201
208
  function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterName, infiniteOptionsGetterName, hasArgs, argsType, responseType, config) {
@@ -205,8 +212,11 @@ function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterNam
205
212
  const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
206
213
  const queryOptionsType = `${config.useInfiniteQueryOptionsType}<${responseType},TError,TData,${queryKeyType},TPageParam>`;
207
214
  const optionsType = useHelper ? `{query?:${queryOptionsType};options?:ClientRequestOptions}` : `{query:${queryOptionsType};options?:ClientRequestOptions}`;
208
- const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null}`;
215
+ const getRequestArgsField = hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
216
+ const requestArgsCall = (argsExpr) => hasArgs ? `pagination.getRequestArgs(${argsExpr},pageParam)` : `pagination.getRequestArgs(pageParam)`;
217
+ const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null;${getRequestArgsField}}`;
209
218
  const paginationSig = useHelper ? `${paginationParam},` : "";
219
+ const vuePaginationParam = `pagination:{${getRequestArgsField}}`;
210
220
  if (config.isVueQuery && useHelper) {
211
221
  const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
212
222
  const optionsCall = hasArgs ? `${infiniteOptionsGetterName}(args,pagination,clientOptions)` : `${infiniteOptionsGetterName}(pagination,clientOptions)`;
@@ -214,18 +224,18 @@ function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterNam
214
224
  }
215
225
  if (config.useThunk) {
216
226
  const argsSig = hasArgs ? `args:()=>${argsType},` : "";
217
- const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, hasArgs ? `parseResponse(${runtimeAccess}(args(),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper);
227
+ const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args()")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
218
228
  const optionsTypeSig = useHelper ? `options?:()=>${optionsType}` : `options:()=>${optionsType}`;
219
229
  const destructure = useHelper ? `options?.()??{}` : "options()";
220
230
  return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}){return ${config.infiniteQueryFn}(()=>{const{query,options:clientOptions}=${destructure};return{...query,${body}}})}`;
221
231
  }
222
232
  if (config.isVueQuery) {
223
233
  const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
224
- const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, hasArgs ? `parseResponse(${runtimeAccess}(toValue(args),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, true);
225
- return `export function ${hookName}${generics}(${argsSig}options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
234
+ const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType, true);
235
+ return `export function ${hookName}${generics}(${argsSig}${vuePaginationParam},options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
226
236
  }
227
237
  const argsSig = hasArgs ? `args:${argsType},` : "";
228
- const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, hasArgs ? `parseResponse(${runtimeAccess}(args,{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper);
238
+ const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
229
239
  return `export function ${hookName}${generics}(${argsSig}${paginationSig}${useHelper ? `options?:${optionsType}` : `options:${optionsType}`}){const{query:queryOptions,options:clientOptions}=${useHelper ? "options??{}" : "options"};return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
230
240
  }
231
241
  function makeSuspenseInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterName, infiniteOptionsGetterName, hasArgs, argsType, responseType, config) {
@@ -235,8 +245,11 @@ function makeSuspenseInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyG
235
245
  const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
236
246
  const queryOptionsType = `${config.useSuspenseInfiniteQueryOptionsType}<${responseType},TError,TData,${queryKeyType},TPageParam>`;
237
247
  const optionsType = useHelper ? `{query?:${queryOptionsType};options?:ClientRequestOptions}` : `{query:${queryOptionsType};options?:ClientRequestOptions}`;
238
- const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null}`;
248
+ const getRequestArgsField = hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
249
+ const requestArgsCall = (argsExpr) => hasArgs ? `pagination.getRequestArgs(${argsExpr},pageParam)` : `pagination.getRequestArgs(pageParam)`;
250
+ const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null;${getRequestArgsField}}`;
239
251
  const paginationSig = useHelper ? `${paginationParam},` : "";
252
+ const vuePaginationParam = `pagination:{${getRequestArgsField}}`;
240
253
  if (config.isVueQuery && useHelper) {
241
254
  const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
242
255
  const optionsCall = hasArgs ? `${infiniteOptionsGetterName}(args,pagination,clientOptions)` : `${infiniteOptionsGetterName}(pagination,clientOptions)`;
@@ -244,18 +257,18 @@ function makeSuspenseInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyG
244
257
  }
245
258
  if (config.useThunk) {
246
259
  const argsSig = hasArgs ? `args:()=>${argsType},` : "";
247
- const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, hasArgs ? `parseResponse(${runtimeAccess}(args(),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper);
260
+ const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args()")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
248
261
  const optionsTypeSig = useHelper ? `options?:()=>${optionsType}` : `options:()=>${optionsType}`;
249
262
  const destructure = useHelper ? `options?.()??{}` : "options()";
250
263
  return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}){return ${config.suspenseInfiniteQueryFn}(()=>{const{query,options:clientOptions}=${destructure};return{...query,${body}}})}`;
251
264
  }
252
265
  if (config.isVueQuery) {
253
266
  const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
254
- const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, hasArgs ? `parseResponse(${runtimeAccess}(toValue(args),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, true);
255
- return `export function ${hookName}${generics}(${argsSig}options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.suspenseInfiniteQueryFn}({...queryOptions,${body}})}`;
267
+ const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType, true);
268
+ return `export function ${hookName}${generics}(${argsSig}${vuePaginationParam},options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.suspenseInfiniteQueryFn}({...queryOptions,${body}})}`;
256
269
  }
257
270
  const argsSig = hasArgs ? `args:${argsType},` : "";
258
- const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, hasArgs ? `parseResponse(${runtimeAccess}(args,{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper);
271
+ const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
259
272
  return `export function ${hookName}${generics}(${argsSig}${paginationSig}${useHelper ? `options?:${optionsType}` : `options:${optionsType}`}){const{query:queryOptions,options:clientOptions}=${useHelper ? "options??{}" : "options"};return ${config.suspenseInfiniteQueryFn}({...queryOptions,${body}})}`;
260
273
  }
261
274
  /**
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { readConfig } from "./config/index.js";
3
3
  import { r as setFormatOptions } from "./emit-CFR63U4L.js";
4
- import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-siQoLLJc.js";
4
+ import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-B8mI7vUM.js";
5
5
  import { existsSync } from "node:fs";
6
6
  import { resolve } from "node:path";
7
7
  //#region src/cli/index.ts
@@ -88,8 +88,8 @@ async function honoTakibi() {
88
88
  const openAPI = openAPIResult.value;
89
89
  const jobs = makeJob(openAPI, config);
90
90
  const results = await Promise.all(jobs.map((job) => job.run(job.output)));
91
- const failure = results.find((result) => !result.ok);
92
- if (failure) return failure;
91
+ const e = results.find((result) => !result.ok);
92
+ if (e) return e;
93
93
  return {
94
94
  ok: true,
95
95
  value: results.map((result) => result.ok ? result.value : "").filter((v) => v !== "").join("\n")
@@ -2,7 +2,7 @@ import { n as fmt, t as emit } from "./emit-CFR63U4L.js";
2
2
  import { a as writeFile, i as unlink, n as readFile, r as readdir, t as mkdir } from "./fsp-BXry-Hx5.js";
3
3
  import { I as statusCodeToNumber, L as toIdentifierPascalCase, M as methodPath, O as escapeRegexLiteral, P as renderNamedImport, R as uncapitalize, T as ensureSuffix, b as isSecurityScheme, i as isMediaWithSchema, k as makeBarrel, l as isParameter, n as isHttpMethod, p as isRefObject, s as isOperation, t as isContentBody, y as isSecurityArray, z as zodToOpenAPISchema } from "./guard-zvkMUVYD.js";
4
4
  import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-Lc8kequ9.js";
5
- import { t as hooks } from "./hooks-Dk7Z5hMb.js";
5
+ import { t as hooks } from "./hooks-CkiatAe9.js";
6
6
  import { t as docs } from "./docs-380Wcu6a.js";
7
7
  import { rpc } from "./core/rpc/index.js";
8
8
  import { type } from "./core/type/index.js";
@@ -1,7 +1,7 @@
1
1
  import { parseConfig } from "../config/index.js";
2
2
  import { r as setFormatOptions } from "../emit-CFR63U4L.js";
3
3
  import { f as isRecord } from "../guard-zvkMUVYD.js";
4
- import { n as parseOpenAPI, t as makeJob } from "../shared-siQoLLJc.js";
4
+ import { n as parseOpenAPI, t as makeJob } from "../shared-B8mI7vUM.js";
5
5
  import path from "node:path";
6
6
  import fsp from "node:fs/promises";
7
7
  //#region src/vite-plugin/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.9.9998",
3
+ "version": "0.9.99991",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",