Skip to content

Commit cd75207

Browse files
docs: deduplicate type declarations copied from source files
1 parent 107fb96 commit cd75207

File tree

10 files changed

+19
-227
lines changed

10 files changed

+19
-227
lines changed

docs/api/kirby.md

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,6 @@ function $kirby<T = any>(
6969
path: string,
7070
opts: KirbyFetchOptions = {},
7171
): Promise<T>
72-
73-
type KirbyFetchOptions = Pick<
74-
NitroFetchOptions<string>,
75-
| 'onRequest'
76-
| 'onRequestError'
77-
| 'onResponse'
78-
| 'onResponseError'
79-
| 'query'
80-
| 'headers'
81-
| 'method'
82-
| 'body'
83-
| 'retry'
84-
| 'retryDelay'
85-
| 'retryStatusCodes'
86-
| 'timeout'
87-
> & {
88-
/**
89-
* Language code to fetch data for in multi-language Kirby setups.
90-
*/
91-
language?: string
92-
/**
93-
* Cache the response between function calls for the same query.
94-
* @default true
95-
*/
96-
cache?: boolean
97-
}
9872
```
73+
74+
<<< @/../src/runtime/composables/$kirby.ts#options

docs/api/kql.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,6 @@ function $kql<T extends KirbyQueryResponse<any, boolean> = KirbyQueryResponse>(
6969
query: KirbyQueryRequest,
7070
opts: KqlOptions = {}
7171
): Promise<T>
72-
73-
type KqlOptions = Pick<
74-
NitroFetchOptions<string>,
75-
| 'onRequest'
76-
| 'onRequestError'
77-
| 'onResponse'
78-
| 'onResponseError'
79-
| 'headers'
80-
| 'retry'
81-
| 'retryDelay'
82-
| 'retryStatusCodes'
83-
| 'timeout'
84-
> & {
85-
/**
86-
* Language code to fetch data for in multi-language Kirby setups.
87-
*/
88-
language?: string
89-
/**
90-
* Cache the response between function calls for the same query.
91-
* @default true
92-
*/
93-
cache?: boolean
94-
}
9572
```
73+
74+
<<< @/../src/runtime/composables/$kql.ts#options

docs/api/use-kirby-data.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,8 @@ export function useKirbyData<T = any>(
100100
path: MaybeRefOrGetter<string>,
101101
opts: UseKirbyDataOptions<T> = {},
102102
): AsyncData<T | undefined, NuxtError>
103-
104-
type UseKirbyDataOptions<T> = Omit<AsyncDataOptions<T>, 'watch'> & Pick<
105-
NitroFetchOptions<string>,
106-
| 'onRequest'
107-
| 'onRequestError'
108-
| 'onResponse'
109-
| 'onResponseError'
110-
| 'query'
111-
| 'headers'
112-
| 'method'
113-
| 'body'
114-
| 'retry'
115-
| 'retryDelay'
116-
| 'retryStatusCodes'
117-
| 'timeout'
118-
> & {
119-
/**
120-
* Language code to fetch data for in multi-language Kirby setups.
121-
*/
122-
language?: MaybeRefOrGetter<string>
123-
/**
124-
* Cache the response between function calls for the same path.
125-
* @default true
126-
*/
127-
cache?: boolean
128-
/**
129-
* Watch an array of reactive sources and auto-refresh the fetch result when they change.
130-
* Path and language are watched by default. You can completely ignore reactive sources by using `watch: false`.
131-
* @default undefined
132-
*/
133-
watch?: MultiWatchSources | false
134-
}
135103
```
136104

105+
<<< @/../src/runtime/composables/useKirbyData.ts#options
106+
137107
`useKirbyData` infers all of Nuxt's [`useAsyncData` options](https://nuxt.com/docs/api/composables/use-async-data#params).

docs/api/use-kql.md

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,35 +90,8 @@ function useKql<
9090
query: MaybeRefOrGetter<ReqT>,
9191
opts?: UseKqlOptions<ResT>
9292
): AsyncData<ResT | undefined, NuxtError>
93-
94-
type UseKqlOptions<T> = AsyncDataOptions<T> & Pick<
95-
NitroFetchOptions<string>,
96-
| 'onRequest'
97-
| 'onRequestError'
98-
| 'onResponse'
99-
| 'onResponseError'
100-
| 'headers'
101-
| 'retry'
102-
| 'retryDelay'
103-
| 'retryStatusCodes'
104-
| 'timeout'
105-
> & {
106-
/**
107-
* Language code to fetch data for in multi-language Kirby setups.
108-
*/
109-
language?: MaybeRefOrGetter<string>
110-
/**
111-
* Cache the response between function calls for the same query.
112-
* @default true
113-
*/
114-
cache?: boolean
115-
/**
116-
* Watch an array of reactive sources and auto-refresh the fetch result when they change.
117-
* Query and language are watched by default. You can completely ignore reactive sources by using `watch: false`.
118-
* @default undefined
119-
*/
120-
watch?: MultiWatchSources | false
121-
}
12293
```
12394

95+
<<< @/../src/runtime/composables/useKql.ts#options
96+
12497
`useKql` infers all of Nuxt's [`useAsyncData` options](https://nuxt.com/docs/api/composables/use-async-data#params).

docs/config/index.md

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -19,120 +19,4 @@ export default defineNuxtConfig({
1919

2020
See the types below for a complete list of options.
2121

22-
```ts
23-
interface ModuleOptions {
24-
/**
25-
* Kirby base URL, like `https://kirby.example.com`
26-
*
27-
* @default process.env.KIRBY_BASE_URL
28-
*/
29-
url?: string
30-
31-
/**
32-
* Kirby KQL API route path
33-
*
34-
* @default 'api/query' // for `basic` authentication
35-
* @default 'api/kql' // for `bearer` authentication
36-
*/
37-
prefix?: string
38-
39-
/**
40-
* Kirby API authentication method
41-
*
42-
* @remarks
43-
* Set to `none` to disable authentication
44-
*
45-
* @default 'basic'
46-
*/
47-
auth?: 'basic' | 'bearer' | 'none'
48-
49-
/**
50-
* Token for bearer authentication
51-
*
52-
* @default process.env.KIRBY_API_TOKEN
53-
*/
54-
token?: string
55-
56-
/**
57-
* Username/password pair for basic authentication
58-
*
59-
* @default { username: process.env.KIRBY_API_USERNAME, password: process.env.KIRBY_API_PASSWORD }
60-
*/
61-
credentials?: {
62-
username: string
63-
password: string
64-
}
65-
66-
/**
67-
* Send client-side requests instead of using the server-side proxy
68-
*
69-
* @remarks
70-
* By default, KQL data is fetched safely with a server-side proxy.
71-
* If enabled, query requests will be be sent directly from the client.
72-
* Note: This means your token or user credentials will be publicly visible.
73-
* If Nuxt SSR is disabled, this option is enabled by default.
74-
*
75-
* @default false
76-
*/
77-
client?: boolean
78-
79-
/**
80-
* Prefetch custom KQL queries at build-time
81-
*
82-
* @remarks
83-
* The queries will be fully typed and importable from `#nuxt-kql`.
84-
*
85-
* @default {}
86-
*/
87-
prefetch?: Record<
88-
string,
89-
KirbyQueryRequest | { query: KirbyQueryRequest, language: string }
90-
>
91-
92-
/**
93-
* Server-side features
94-
*/
95-
server?: {
96-
/**
97-
* Enable server-side caching of queries using the Nitro cache API
98-
*
99-
* @see https://nitro.unjs.io/guide/cache
100-
*/
101-
cache?: boolean
102-
103-
/**
104-
* Name of the storage mountpoint to use for caching
105-
*
106-
* @see https://nitro.unjs.io/guide/cache
107-
* @default 'cache'
108-
*/
109-
storage?: string
110-
111-
/**
112-
* Enable stale-while-revalidate behavior (cache is returned while it is being updated)
113-
*
114-
* @see https://nitro.unjs.io/guide/cache#options
115-
* @default false
116-
*/
117-
swr?: boolean
118-
119-
/**
120-
* Number of seconds to cache the query response
121-
*
122-
* @see https://nitro.unjs.io/guide/cache#options
123-
* @default 1
124-
*/
125-
maxAge?: number
126-
127-
/**
128-
* Log verbose errors to the console if a query fails
129-
*
130-
* @remarks
131-
* This will log the full query to the console. Depending on the content of the query, this could be a security risk.
132-
*
133-
* @default false
134-
*/
135-
verboseErrors?: boolean
136-
}
137-
}
138-
```
22+
<<< @/../src/module.ts#options

src/module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const KIRBY_TYPES_PKG_EXPORT_NAMES = [
2424
'KirbyQuerySchema',
2525
]
2626

27+
// #region options
2728
export interface ModuleOptions {
2829
/**
2930
* Kirby base URL, like `https://kirby.example.com`
@@ -139,6 +140,7 @@ export interface ModuleOptions {
139140
verboseErrors?: boolean
140141
}
141142
}
143+
// #endregion options
142144

143145
declare module '@nuxt/schema' {
144146
interface RuntimeConfig {

src/runtime/composables/$kirby.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { hash } from 'ohash'
66
import { joinURL } from 'ufo'
77
import { createAuthHeader, getProxyPath, headersToObject } from '../utils'
88

9+
// #region options
910
export type KirbyFetchOptions = Pick<
1011
NitroFetchOptions<string>,
1112
| 'onRequest'
@@ -31,6 +32,7 @@ export type KirbyFetchOptions = Pick<
3132
*/
3233
cache?: boolean
3334
}
35+
// #endregion options
3436

3537
export function $kirby<T = any>(
3638
path: string,

src/runtime/composables/$kql.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useNuxtApp, useRequestFetch, useRuntimeConfig } from '#imports'
66
import { hash } from 'ohash'
77
import { createAuthHeader, getProxyPath, headersToObject } from '../utils'
88

9+
// #region options
910
export type KqlOptions = Pick<
1011
NitroFetchOptions<string>,
1112
| 'onRequest'
@@ -28,6 +29,7 @@ export type KqlOptions = Pick<
2829
*/
2930
cache?: boolean
3031
}
32+
// #endregion options
3133

3234
export function $kql<T extends KirbyQueryResponse<any, boolean> = KirbyQueryResponse>(
3335
query: KirbyQueryRequest,

src/runtime/composables/useKirbyData.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { joinURL } from 'ufo'
88
import { computed, toValue } from 'vue'
99
import { createAuthHeader, getProxyPath, headersToObject } from '../utils'
1010

11+
// #region options
1112
type UseKirbyDataOptions<T> = Omit<AsyncDataOptions<T>, 'watch'> & Pick<
1213
NitroFetchOptions<string>,
1314
| 'onRequest'
@@ -39,6 +40,7 @@ type UseKirbyDataOptions<T> = Omit<AsyncDataOptions<T>, 'watch'> & Pick<
3940
*/
4041
watch?: MultiWatchSources | false
4142
}
43+
// #endregion options
4244

4345
export function useKirbyData<T = any>(
4446
path: MaybeRefOrGetter<string>,

src/runtime/composables/useKql.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { hash } from 'ohash'
88
import { computed, toValue } from 'vue'
99
import { createAuthHeader, getProxyPath, headersToObject } from '../utils'
1010

11+
// #region options
1112
export type UseKqlOptions<T> = Omit<AsyncDataOptions<T>, 'watch'> & Pick<
1213
NitroFetchOptions<string>,
1314
| 'onRequest'
@@ -36,6 +37,7 @@ export type UseKqlOptions<T> = Omit<AsyncDataOptions<T>, 'watch'> & Pick<
3637
*/
3738
watch?: MultiWatchSources | false
3839
}
40+
// #endregion options
3941

4042
export function useKql<
4143
ResT extends KirbyQueryResponse<any, boolean> = KirbyQueryResponse,

0 commit comments

Comments
 (0)