diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index d775075..155eff9 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'vitepress' +import typedocSidebar from '../api/typedoc-sidebar.json' // https://vitepress.dev/reference/site-config export default defineConfig({ @@ -24,14 +25,7 @@ export default defineConfig({ }, sidebar: { - '/api/': [ - { - text: 'API Reference', - items: [ - { text: 'Overview', link: '/api/index' }, - ] - } - ], + '/api/': typedocSidebar, '/': [ { text: 'Getting Started', diff --git a/docs/api/functions/createQueryClient.md b/docs/api/functions/createQueryClient.md new file mode 100644 index 0000000..b4a7502 --- /dev/null +++ b/docs/api/functions/createQueryClient.md @@ -0,0 +1,15 @@ +# Functions: createQueryClient() + +```ts +function createQueryClient(options?): QueryClient; +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `options?` | [`ClientOptions`](../types/ClientOptions.md) | + +## Returns + +[`QueryClient`](../types/QueryClient.md) diff --git a/docs/api/functions/query.md b/docs/api/functions/query.md new file mode 100644 index 0000000..1bf2e25 --- /dev/null +++ b/docs/api/functions/query.md @@ -0,0 +1,5 @@ +# Functions: query + +```ts +const query: QueryFunction; +``` diff --git a/docs/api/functions/tag.md b/docs/api/functions/tag.md new file mode 100644 index 0000000..bad02e7 --- /dev/null +++ b/docs/api/functions/tag.md @@ -0,0 +1,40 @@ +# Functions: tag() + +## Call Signature + +```ts +function tag(): QueryTag; +``` + +### Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TData` | *typeof* `unset` | + +### Returns + +[`QueryTag`](../types/QueryTag.md)\<`TData`\> + +## Call Signature + +```ts +function tag(callback): QueryTagFactory; +``` + +### Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TData` | *typeof* `unset` | +| `TInput` | `unknown` | + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `callback` | [`QueryTagCallback`](../types/QueryTagCallback.md)\<`TInput`\> | + +### Returns + +[`QueryTagFactory`](../types/QueryTagFactory.md)\<`TData`, `TInput`\> diff --git a/docs/api/functions/useQuery.md b/docs/api/functions/useQuery.md new file mode 100644 index 0000000..9bc6011 --- /dev/null +++ b/docs/api/functions/useQuery.md @@ -0,0 +1,5 @@ +# Functions: useQuery + +```ts +const useQuery: QueryComposition; +``` diff --git a/docs/api/index.md b/docs/api/index.md index 5932792..2074071 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -1 +1,58 @@ -# API +# @kitbag/query + +## Functions + +- [createQueryClient](functions/createQueryClient.md) +- [tag](functions/tag.md) + +## Types + +- [AwaitedMutation](types/AwaitedMutation.md) +- [AwaitedQuery](types/AwaitedQuery.md) +- [ClientOptions](types/ClientOptions.md) +- [DefinedMutation](types/DefinedMutation.md) +- [DefinedMutationComposition](types/DefinedMutationComposition.md) +- [DefinedMutationFunction](types/DefinedMutationFunction.md) +- [DefinedQuery](types/DefinedQuery.md) +- [DefinedQueryComposition](types/DefinedQueryComposition.md) +- [DefinedQueryFunction](types/DefinedQueryFunction.md) +- [DefineMutation](types/DefineMutation.md) +- [DefineQuery](types/DefineQuery.md) +- [Mutation](types/Mutation.md) +- [MutationAction](types/MutationAction.md) +- [MutationComposition](types/MutationComposition.md) +- [MutationData](types/MutationData.md) +- [MutationFunction](types/MutationFunction.md) +- [MutationOptions](types/MutationOptions.md) +- [MutationTags](types/MutationTags.md) +- [MutationTagsAfterContext](types/MutationTagsAfterContext.md) +- [MutationTagsBeforeContext](types/MutationTagsBeforeContext.md) +- [MutationTagsContext](types/MutationTagsContext.md) +- [MutationTagsType](types/MutationTagsType.md) +- [OnErrorContext](types/OnErrorContext.md) +- [OnExecuteContext](types/OnExecuteContext.md) +- [OnSuccessContext](types/OnSuccessContext.md) +- [Query](types/Query.md) +- [QueryAction](types/QueryAction.md) +- [QueryActionArgs](types/QueryActionArgs.md) +- [QueryClient](types/QueryClient.md) +- [QueryComposition](types/QueryComposition.md) +- [QueryData](types/QueryData.md) +- [QueryDataSetter](types/QueryDataSetter.md) +- [QueryFunction](types/QueryFunction.md) +- [QueryOptions](types/QueryOptions.md) +- [QueryTag](types/QueryTag.md) +- [QueryTagCallback](types/QueryTagCallback.md) +- [QueryTagFactory](types/QueryTagFactory.md) +- [QueryTags](types/QueryTags.md) +- [QueryTagType](types/QueryTagType.md) +- [RefreshQueryData](types/RefreshQueryData.md) +- [SetQueryData](types/SetQueryData.md) +- [SetQueryDataAfterContext](types/SetQueryDataAfterContext.md) +- [SetQueryDataBeforeContext](types/SetQueryDataBeforeContext.md) +- [UseQueryOptions](types/UseQueryOptions.md) + +## Variables + +- [query](functions/query.md) +- [useQuery](functions/useQuery.md) diff --git a/docs/api/typedoc-sidebar.json b/docs/api/typedoc-sidebar.json new file mode 100644 index 0000000..6906d38 --- /dev/null +++ b/docs/api/typedoc-sidebar.json @@ -0,0 +1,212 @@ +[ + { + "text": "Functions", + "collapsed": true, + "items": [ + { + "text": "createQueryClient", + "link": "/api/functions/createQueryClient.md" + }, + { + "text": "tag", + "link": "/api/functions/tag.md" + } + ] + }, + { + "text": "Types", + "collapsed": true, + "items": [ + { + "text": "AwaitedMutation", + "link": "/api/types/AwaitedMutation.md" + }, + { + "text": "AwaitedQuery", + "link": "/api/types/AwaitedQuery.md" + }, + { + "text": "ClientOptions", + "link": "/api/types/ClientOptions.md" + }, + { + "text": "DefinedMutation", + "link": "/api/types/DefinedMutation.md" + }, + { + "text": "DefinedMutationComposition", + "link": "/api/types/DefinedMutationComposition.md" + }, + { + "text": "DefinedMutationFunction", + "link": "/api/types/DefinedMutationFunction.md" + }, + { + "text": "DefinedQuery", + "link": "/api/types/DefinedQuery.md" + }, + { + "text": "DefinedQueryComposition", + "link": "/api/types/DefinedQueryComposition.md" + }, + { + "text": "DefinedQueryFunction", + "link": "/api/types/DefinedQueryFunction.md" + }, + { + "text": "DefineMutation", + "link": "/api/types/DefineMutation.md" + }, + { + "text": "DefineQuery", + "link": "/api/types/DefineQuery.md" + }, + { + "text": "Mutation", + "link": "/api/types/Mutation.md" + }, + { + "text": "MutationAction", + "link": "/api/types/MutationAction.md" + }, + { + "text": "MutationComposition", + "link": "/api/types/MutationComposition.md" + }, + { + "text": "MutationData", + "link": "/api/types/MutationData.md" + }, + { + "text": "MutationFunction", + "link": "/api/types/MutationFunction.md" + }, + { + "text": "MutationOptions", + "link": "/api/types/MutationOptions.md" + }, + { + "text": "MutationTags", + "link": "/api/types/MutationTags.md" + }, + { + "text": "MutationTagsAfterContext", + "link": "/api/types/MutationTagsAfterContext.md" + }, + { + "text": "MutationTagsBeforeContext", + "link": "/api/types/MutationTagsBeforeContext.md" + }, + { + "text": "MutationTagsContext", + "link": "/api/types/MutationTagsContext.md" + }, + { + "text": "MutationTagsType", + "link": "/api/types/MutationTagsType.md" + }, + { + "text": "OnErrorContext", + "link": "/api/types/OnErrorContext.md" + }, + { + "text": "OnExecuteContext", + "link": "/api/types/OnExecuteContext.md" + }, + { + "text": "OnSuccessContext", + "link": "/api/types/OnSuccessContext.md" + }, + { + "text": "Query", + "link": "/api/types/Query.md" + }, + { + "text": "QueryAction", + "link": "/api/types/QueryAction.md" + }, + { + "text": "QueryActionArgs", + "link": "/api/types/QueryActionArgs.md" + }, + { + "text": "QueryClient", + "link": "/api/types/QueryClient.md" + }, + { + "text": "QueryComposition", + "link": "/api/types/QueryComposition.md" + }, + { + "text": "QueryData", + "link": "/api/types/QueryData.md" + }, + { + "text": "QueryDataSetter", + "link": "/api/types/QueryDataSetter.md" + }, + { + "text": "QueryFunction", + "link": "/api/types/QueryFunction.md" + }, + { + "text": "QueryOptions", + "link": "/api/types/QueryOptions.md" + }, + { + "text": "QueryTag", + "link": "/api/types/QueryTag.md" + }, + { + "text": "QueryTagCallback", + "link": "/api/types/QueryTagCallback.md" + }, + { + "text": "QueryTagFactory", + "link": "/api/types/QueryTagFactory.md" + }, + { + "text": "QueryTags", + "link": "/api/types/QueryTags.md" + }, + { + "text": "QueryTagType", + "link": "/api/types/QueryTagType.md" + }, + { + "text": "RefreshQueryData", + "link": "/api/types/RefreshQueryData.md" + }, + { + "text": "SetQueryData", + "link": "/api/types/SetQueryData.md" + }, + { + "text": "SetQueryDataAfterContext", + "link": "/api/types/SetQueryDataAfterContext.md" + }, + { + "text": "SetQueryDataBeforeContext", + "link": "/api/types/SetQueryDataBeforeContext.md" + }, + { + "text": "UseQueryOptions", + "link": "/api/types/UseQueryOptions.md" + } + ] + }, + { + "text": "Variables", + "collapsed": true, + "items": [ + { + "text": "query", + "link": "/api/functions/query.md" + }, + { + "text": "useQuery", + "link": "/api/functions/useQuery.md" + } + ] + } +] \ No newline at end of file diff --git a/docs/api/types/AwaitedMutation.md b/docs/api/types/AwaitedMutation.md new file mode 100644 index 0000000..05bace4 --- /dev/null +++ b/docs/api/types/AwaitedMutation.md @@ -0,0 +1,21 @@ +# Types: AwaitedMutation\ + +```ts +type AwaitedMutation = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `data` | [`MutationData`](MutationData.md)\<`TAction`\> | +| `error` | `unknown` | +| `errored` | `boolean` | +| `executed` | `boolean` | +| `executing` | `boolean` | diff --git a/docs/api/types/AwaitedQuery.md b/docs/api/types/AwaitedQuery.md new file mode 100644 index 0000000..7cbe8b7 --- /dev/null +++ b/docs/api/types/AwaitedQuery.md @@ -0,0 +1,24 @@ +# Types: AwaitedQuery\ + +```ts +type AwaitedQuery = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `[dispose]` | () => `void` | +| `data` | [`QueryData`](QueryData.md)\<`TAction`\> | +| `dispose` | () => `void` | +| `error` | `unknown` | +| `errored` | `boolean` | +| `execute` | () => `Promise`\<`AwaitedQuery`\<`TAction`\>\> | +| `executed` | `boolean` | +| `executing` | `boolean` | diff --git a/docs/api/types/ClientOptions.md b/docs/api/types/ClientOptions.md new file mode 100644 index 0000000..eb4f66b --- /dev/null +++ b/docs/api/types/ClientOptions.md @@ -0,0 +1,13 @@ +# Types: ClientOptions + +```ts +type ClientOptions = QueryGroupOptions & object; +``` + +## Type Declaration + +### pauseActionsInBackground? + +```ts +optional pauseActionsInBackground: boolean; +``` diff --git a/docs/api/types/DefineMutation.md b/docs/api/types/DefineMutation.md new file mode 100644 index 0000000..14ee68b --- /dev/null +++ b/docs/api/types/DefineMutation.md @@ -0,0 +1,24 @@ +# Types: DefineMutation() + +```ts +type DefineMutation = (action, options?) => DefinedMutation; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | +| `TPlaceholder` | +| `TTags` *extends* [`MutationTags`](MutationTags.md)\<`TAction`\> | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `options?` | [`MutationOptions`](MutationOptions.md)\<`TAction`, `TPlaceholder`, `TTags`\> | + +## Returns + +[`DefinedMutation`](DefinedMutation.md)\<`TAction`, `TPlaceholder`\> diff --git a/docs/api/types/DefineQuery.md b/docs/api/types/DefineQuery.md new file mode 100644 index 0000000..db53864 --- /dev/null +++ b/docs/api/types/DefineQuery.md @@ -0,0 +1,23 @@ +# Types: DefineQuery() + +```ts +type DefineQuery = (action, options?) => DefinedQuery; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `TPlaceholder` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `options?` | [`QueryOptions`](QueryOptions.md)\<`TAction`, `TPlaceholder`\> | + +## Returns + +[`DefinedQuery`](DefinedQuery.md)\<`TAction`, `TPlaceholder`\> diff --git a/docs/api/types/DefinedMutation.md b/docs/api/types/DefinedMutation.md new file mode 100644 index 0000000..df10b12 --- /dev/null +++ b/docs/api/types/DefinedMutation.md @@ -0,0 +1,19 @@ +# Types: DefinedMutation\ + +```ts +type DefinedMutation = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | +| `TPlaceholder` | + +## Properties + +| Property | Type | +| ------ | ------ | +| `mutate` | [`DefinedMutationFunction`](DefinedMutationFunction.md)\<`TAction`, `TPlaceholder`\> | +| `useMutation` | [`DefinedMutationComposition`](DefinedMutationComposition.md)\<`TAction`, `TPlaceholder`\> | diff --git a/docs/api/types/DefinedMutationComposition.md b/docs/api/types/DefinedMutationComposition.md new file mode 100644 index 0000000..87982a5 --- /dev/null +++ b/docs/api/types/DefinedMutationComposition.md @@ -0,0 +1,29 @@ +# Types: DefinedMutationComposition()\ + +```ts +type DefinedMutationComposition = (options?) => Mutation>; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TDefinedAction` *extends* [`MutationAction`](MutationAction.md) | +| `TDefinedPlaceholder` | + +## Type Parameters + +| Type Parameter | +| ------ | +| `TPlaceholder` | +| `TTags` *extends* [`MutationTags`](MutationTags.md)\<`TDefinedAction`\> | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `options?` | [`MutationOptions`](MutationOptions.md)\<`TDefinedAction`, `TPlaceholder`, `TTags`\> | + +## Returns + +[`Mutation`](Mutation.md)\<`TDefinedAction`, `DefaultValue`\<`TPlaceholder`, `TDefinedPlaceholder`\>\> diff --git a/docs/api/types/DefinedMutationFunction.md b/docs/api/types/DefinedMutationFunction.md new file mode 100644 index 0000000..307ccd3 --- /dev/null +++ b/docs/api/types/DefinedMutationFunction.md @@ -0,0 +1,30 @@ +# Types: DefinedMutationFunction()\ + +```ts +type DefinedMutationFunction = (args, options?) => Mutation>; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TDefinedAction` *extends* [`MutationAction`](MutationAction.md) | +| `TDefinedPlaceholder` | + +## Type Parameters + +| Type Parameter | +| ------ | +| `TPlaceholder` | +| `TTags` *extends* [`MutationTags`](MutationTags.md)\<`TDefinedAction`\> | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `args` | `Parameters`\<`TDefinedAction`\> | +| `options?` | [`MutationOptions`](MutationOptions.md)\<`TDefinedAction`, `TPlaceholder`, `TTags`\> | + +## Returns + +[`Mutation`](Mutation.md)\<`TDefinedAction`, `DefaultValue`\<`TPlaceholder`, `TDefinedPlaceholder`\>\> diff --git a/docs/api/types/DefinedQuery.md b/docs/api/types/DefinedQuery.md new file mode 100644 index 0000000..e2f5623 --- /dev/null +++ b/docs/api/types/DefinedQuery.md @@ -0,0 +1,19 @@ +# Types: DefinedQuery\ + +```ts +type DefinedQuery = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `TPlaceholder` | + +## Properties + +| Property | Type | +| ------ | ------ | +| `query` | [`DefinedQueryFunction`](DefinedQueryFunction.md)\<`TAction`, `TPlaceholder`\> | +| `useQuery` | [`DefinedQueryComposition`](DefinedQueryComposition.md)\<`TAction`, `TPlaceholder`\> | diff --git a/docs/api/types/DefinedQueryComposition.md b/docs/api/types/DefinedQueryComposition.md new file mode 100644 index 0000000..08c9c79 --- /dev/null +++ b/docs/api/types/DefinedQueryComposition.md @@ -0,0 +1,29 @@ +# Types: DefinedQueryComposition()\ + +```ts +type DefinedQueryComposition = (args, options?) => Query>; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `TDefinedPlaceholder` | + +## Type Parameters + +| Type Parameter | +| ------ | +| `TPlaceholder` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `args` | [`QueryActionArgs`](QueryActionArgs.md)\<`TAction`\> | +| `options?` | [`QueryOptions`](QueryOptions.md)\<`TAction`, `TPlaceholder`\> | + +## Returns + +[`Query`](Query.md)\<`TAction`, `DefaultValue`\<`TPlaceholder`, `TDefinedPlaceholder`\>\> diff --git a/docs/api/types/DefinedQueryFunction.md b/docs/api/types/DefinedQueryFunction.md new file mode 100644 index 0000000..9ec2783 --- /dev/null +++ b/docs/api/types/DefinedQueryFunction.md @@ -0,0 +1,29 @@ +# Types: DefinedQueryFunction()\ + +```ts +type DefinedQueryFunction = (args, options?) => Query>; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `TDefinedPlaceholder` | + +## Type Parameters + +| Type Parameter | +| ------ | +| `TPlaceholder` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `args` | `Parameters`\<`TAction`\> | +| `options?` | [`QueryOptions`](QueryOptions.md)\<`TAction`, `TPlaceholder`\> | + +## Returns + +[`Query`](Query.md)\<`TAction`, `DefaultValue`\<`TPlaceholder`, `TDefinedPlaceholder`\>\> diff --git a/docs/api/types/Mutation.md b/docs/api/types/Mutation.md new file mode 100644 index 0000000..8fc0e30 --- /dev/null +++ b/docs/api/types/Mutation.md @@ -0,0 +1,62 @@ +# Types: Mutation\ + +```ts +type Mutation = PromiseLike> & object; +``` + +## Type Declaration + +### data + +```ts +data: + | MutationData +| DefaultValue; +``` + +### error + +```ts +error: unknown; +``` + +### errored + +```ts +errored: boolean; +``` + +### executed + +```ts +executed: boolean; +``` + +### executing + +```ts +executing: boolean; +``` + +### mutate() + +```ts +mutate: (...args) => Promise>; +``` + +#### Parameters + +| Parameter | Type | +| ------ | ------ | +| ...`args` | `Parameters`\<`TAction`\> | + +#### Returns + +`Promise`\<[`MutationData`](MutationData.md)\<`TAction`\>\> + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | +| `TPlaceholder` | diff --git a/docs/api/types/MutationAction.md b/docs/api/types/MutationAction.md new file mode 100644 index 0000000..c52a6e1 --- /dev/null +++ b/docs/api/types/MutationAction.md @@ -0,0 +1,15 @@ +# Types: MutationAction() + +```ts +type MutationAction = (...args) => any; +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| ...`args` | `any`[] | + +## Returns + +`any` diff --git a/docs/api/types/MutationComposition.md b/docs/api/types/MutationComposition.md new file mode 100644 index 0000000..0e91346 --- /dev/null +++ b/docs/api/types/MutationComposition.md @@ -0,0 +1,24 @@ +# Types: MutationComposition() + +```ts +type MutationComposition = (action, options?) => Mutation; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | +| `TPlaceholder` | +| `TTags` *extends* [`MutationTags`](MutationTags.md)\<`TAction`\> | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `options?` | [`MutationOptions`](MutationOptions.md)\<`TAction`, `TPlaceholder`, `TTags`\> | + +## Returns + +[`Mutation`](Mutation.md)\<`TAction`, `TPlaceholder`\> diff --git a/docs/api/types/MutationData.md b/docs/api/types/MutationData.md new file mode 100644 index 0000000..80e9df2 --- /dev/null +++ b/docs/api/types/MutationData.md @@ -0,0 +1,11 @@ +# Types: MutationData\ + +```ts +type MutationData = Awaited>; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | diff --git a/docs/api/types/MutationFunction.md b/docs/api/types/MutationFunction.md new file mode 100644 index 0000000..a49a86f --- /dev/null +++ b/docs/api/types/MutationFunction.md @@ -0,0 +1,25 @@ +# Types: MutationFunction() + +```ts +type MutationFunction = (action, args, options?) => PromiseLike> & Mutation; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | +| `TPlaceholder` | +| `TTags` *extends* [`MutationTags`](MutationTags.md)\<`TAction`\> | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `args` | `Parameters`\<`TAction`\> | +| `options?` | [`MutationOptions`](MutationOptions.md)\<`TAction`, `TPlaceholder`, `TTags`\> | + +## Returns + +`PromiseLike`\<[`AwaitedMutation`](AwaitedMutation.md)\<`TAction`\>\> & [`Mutation`](Mutation.md)\<`TAction`, `TPlaceholder`\> diff --git a/docs/api/types/MutationOptions.md b/docs/api/types/MutationOptions.md new file mode 100644 index 0000000..73231b3 --- /dev/null +++ b/docs/api/types/MutationOptions.md @@ -0,0 +1,27 @@ +# Types: MutationOptions\ + +```ts +type MutationOptions = object; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | [`MutationAction`](MutationAction.md) | +| `TPlaceholder` | `unknown` | +| `TTags` *extends* [`MutationTags`](MutationTags.md)\<`TAction`\> | [`MutationTags`](MutationTags.md)\<`TAction`\> | + +## Properties + +| Property | Type | +| ------ | ------ | +| `onError?` | (`context`) => `void` | +| `onExecute?` | (`context`) => `void` | +| `onSuccess?` | (`context`) => `void` | +| `placeholder?` | `TPlaceholder` | +| `refreshQueryData?` | `boolean` | +| `retries?` | `number` \| `Partial`\<`RetryOptions`\> | +| `setQueryDataAfter?` | (`queryData`, `context`) => [`MutationTagsType`](MutationTagsType.md)\<`TTags`\> | +| `setQueryDataBefore?` | (`queryData`, `context`) => [`MutationTagsType`](MutationTagsType.md)\<`TTags`\> | +| `tags?` | `TTags` | diff --git a/docs/api/types/MutationTags.md b/docs/api/types/MutationTags.md new file mode 100644 index 0000000..928820f --- /dev/null +++ b/docs/api/types/MutationTags.md @@ -0,0 +1,11 @@ +# Types: MutationTags\ + +```ts +type MutationTags = QueryTag[] | (value) => QueryTag[]; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | [`MutationAction`](MutationAction.md) | diff --git a/docs/api/types/MutationTagsAfterContext.md b/docs/api/types/MutationTagsAfterContext.md new file mode 100644 index 0000000..77bf5c1 --- /dev/null +++ b/docs/api/types/MutationTagsAfterContext.md @@ -0,0 +1,19 @@ +# Types: MutationTagsAfterContext\ + +```ts +type MutationTagsAfterContext = object; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `data` | [`MutationData`](MutationData.md)\<`TAction`\> | +| `lifecycle` | `"after"` | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/MutationTagsBeforeContext.md b/docs/api/types/MutationTagsBeforeContext.md new file mode 100644 index 0000000..e7261ab --- /dev/null +++ b/docs/api/types/MutationTagsBeforeContext.md @@ -0,0 +1,18 @@ +# Types: MutationTagsBeforeContext\ + +```ts +type MutationTagsBeforeContext = object; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `lifecycle` | `"before"` | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/MutationTagsContext.md b/docs/api/types/MutationTagsContext.md new file mode 100644 index 0000000..d917888 --- /dev/null +++ b/docs/api/types/MutationTagsContext.md @@ -0,0 +1,13 @@ +# Types: MutationTagsContext\ + +```ts +type MutationTagsContext = + | MutationTagsBeforeContext +| MutationTagsAfterContext; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | [`MutationAction`](MutationAction.md) | diff --git a/docs/api/types/MutationTagsType.md b/docs/api/types/MutationTagsType.md new file mode 100644 index 0000000..b38aceb --- /dev/null +++ b/docs/api/types/MutationTagsType.md @@ -0,0 +1,11 @@ +# Types: MutationTagsType\ + +```ts +type MutationTagsType = TTags extends QueryTag[] ? QueryTagType : TTags extends (value) => QueryTag[] ? QueryTagType[number]> : never; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TTags` *extends* [`MutationTags`](MutationTags.md) | diff --git a/docs/api/types/OnErrorContext.md b/docs/api/types/OnErrorContext.md new file mode 100644 index 0000000..a9b2727 --- /dev/null +++ b/docs/api/types/OnErrorContext.md @@ -0,0 +1,18 @@ +# Types: OnErrorContext\ + +```ts +type OnErrorContext = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `error` | `unknown` | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/OnExecuteContext.md b/docs/api/types/OnExecuteContext.md new file mode 100644 index 0000000..cee4424 --- /dev/null +++ b/docs/api/types/OnExecuteContext.md @@ -0,0 +1,17 @@ +# Types: OnExecuteContext\ + +```ts +type OnExecuteContext = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/OnSuccessContext.md b/docs/api/types/OnSuccessContext.md new file mode 100644 index 0000000..1083187 --- /dev/null +++ b/docs/api/types/OnSuccessContext.md @@ -0,0 +1,18 @@ +# Types: OnSuccessContext\ + +```ts +type OnSuccessContext = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `data` | [`MutationData`](MutationData.md)\<`TAction`\> | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/Query.md b/docs/api/types/Query.md new file mode 100644 index 0000000..a02e56c --- /dev/null +++ b/docs/api/types/Query.md @@ -0,0 +1,76 @@ +# Types: Query\ + +```ts +type Query = PromiseLike> & object; +``` + +## Type Declaration + +### \[dispose\]() + +```ts +[dispose]: () => void; +``` + +#### Returns + +`void` + +### data + +```ts +data: + | QueryData +| DefaultValue; +``` + +### dispose() + +```ts +dispose: () => void; +``` + +#### Returns + +`void` + +### error + +```ts +error: unknown; +``` + +### errored + +```ts +errored: boolean; +``` + +### execute() + +```ts +execute: () => Promise>; +``` + +#### Returns + +`Promise`\<[`AwaitedQuery`](AwaitedQuery.md)\<`TAction`\>\> + +### executed + +```ts +executed: boolean; +``` + +### executing + +```ts +executing: boolean; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `TPlaceholder` | diff --git a/docs/api/types/QueryAction.md b/docs/api/types/QueryAction.md new file mode 100644 index 0000000..90c85cb --- /dev/null +++ b/docs/api/types/QueryAction.md @@ -0,0 +1,15 @@ +# Types: QueryAction() + +```ts +type QueryAction = (...args) => any; +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| ...`args` | `any`[] | + +## Returns + +`any` diff --git a/docs/api/types/QueryActionArgs.md b/docs/api/types/QueryActionArgs.md new file mode 100644 index 0000000..2091b52 --- /dev/null +++ b/docs/api/types/QueryActionArgs.md @@ -0,0 +1,14 @@ +# Types: QueryActionArgs\ + +```ts +type QueryActionArgs = + | MaybeGetter> + | Getter | null> +| Getter; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | diff --git a/docs/api/types/QueryClient.md b/docs/api/types/QueryClient.md new file mode 100644 index 0000000..57aa1b2 --- /dev/null +++ b/docs/api/types/QueryClient.md @@ -0,0 +1,18 @@ +# Types: QueryClient + +```ts +type QueryClient = object; +``` + +## Properties + +| Property | Type | +| ------ | ------ | +| `defineMutation` | [`DefineMutation`](DefineMutation.md) | +| `defineQuery` | [`DefineQuery`](DefineQuery.md) | +| `mutate` | [`MutationFunction`](MutationFunction.md) | +| `query` | [`QueryFunction`](QueryFunction.md) | +| `refreshQueryData` | [`RefreshQueryData`](RefreshQueryData.md) | +| `setQueryData` | [`SetQueryData`](SetQueryData.md) | +| `useMutation` | [`MutationComposition`](MutationComposition.md) | +| `useQuery` | [`QueryComposition`](QueryComposition.md) | diff --git a/docs/api/types/QueryComposition.md b/docs/api/types/QueryComposition.md new file mode 100644 index 0000000..0fb4690 --- /dev/null +++ b/docs/api/types/QueryComposition.md @@ -0,0 +1,25 @@ +# Types: QueryComposition() + +```ts +type QueryComposition = (action, args, options?) => Query; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `Args` *extends* [`QueryActionArgs`](QueryActionArgs.md)\<`TAction`\> | +| `TPlaceholder` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `args` | `Args` | +| `options?` | [`UseQueryOptions`](UseQueryOptions.md)\<`TAction`, `TPlaceholder`\> | + +## Returns + +[`Query`](Query.md)\<`TAction`, `TPlaceholder`\> diff --git a/docs/api/types/QueryData.md b/docs/api/types/QueryData.md new file mode 100644 index 0000000..d0a636e --- /dev/null +++ b/docs/api/types/QueryData.md @@ -0,0 +1,11 @@ +# Types: QueryData\ + +```ts +type QueryData = Awaited>; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | [`QueryAction`](QueryAction.md) | diff --git a/docs/api/types/QueryDataSetter.md b/docs/api/types/QueryDataSetter.md new file mode 100644 index 0000000..799ef28 --- /dev/null +++ b/docs/api/types/QueryDataSetter.md @@ -0,0 +1,21 @@ +# Types: QueryDataSetter()\ + +```ts +type QueryDataSetter = (data) => T; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `T` | `unknown` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `data` | `T` | + +## Returns + +`T` diff --git a/docs/api/types/QueryFunction.md b/docs/api/types/QueryFunction.md new file mode 100644 index 0000000..948d070 --- /dev/null +++ b/docs/api/types/QueryFunction.md @@ -0,0 +1,24 @@ +# Types: QueryFunction() + +```ts +type QueryFunction = (action, args, options?) => Query; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | +| `TPlaceholder` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `args` | `Parameters`\<`TAction`\> | +| `options?` | [`QueryOptions`](QueryOptions.md)\<`TAction`, `TPlaceholder`\> | + +## Returns + +[`Query`](Query.md)\<`TAction`, `TPlaceholder`\> diff --git a/docs/api/types/QueryOptions.md b/docs/api/types/QueryOptions.md new file mode 100644 index 0000000..75ee687 --- /dev/null +++ b/docs/api/types/QueryOptions.md @@ -0,0 +1,23 @@ +# Types: QueryOptions\ + +```ts +type QueryOptions = object; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | [`QueryAction`](QueryAction.md) | +| `TPlaceholder` | `unknown` | + +## Properties + +| Property | Type | +| ------ | ------ | +| `interval?` | `number` | +| `onError?` | (`error`) => `void` | +| `onSuccess?` | (`value`) => `void` | +| `placeholder?` | `TPlaceholder` | +| `retries?` | `number` \| `Partial`\<`RetryOptions`\> | +| `tags?` | [`QueryTags`](QueryTags.md)\<`TAction`\> | diff --git a/docs/api/types/QueryTag.md b/docs/api/types/QueryTag.md new file mode 100644 index 0000000..84c8660 --- /dev/null +++ b/docs/api/types/QueryTag.md @@ -0,0 +1,17 @@ +# Types: QueryTag\ + +```ts +type QueryTag = object; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TData` | `unknown` | + +## Properties + +| Property | Type | +| ------ | ------ | +| `key` | `TagKey` | diff --git a/docs/api/types/QueryTagCallback.md b/docs/api/types/QueryTagCallback.md new file mode 100644 index 0000000..a51408b --- /dev/null +++ b/docs/api/types/QueryTagCallback.md @@ -0,0 +1,21 @@ +# Types: QueryTagCallback()\ + +```ts +type QueryTagCallback = (input) => any; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TInput` | `unknown` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `input` | `TInput` | + +## Returns + +`any` diff --git a/docs/api/types/QueryTagFactory.md b/docs/api/types/QueryTagFactory.md new file mode 100644 index 0000000..cbc1e5c --- /dev/null +++ b/docs/api/types/QueryTagFactory.md @@ -0,0 +1,22 @@ +# Types: QueryTagFactory()\ + +```ts +type QueryTagFactory = (value) => QueryTag; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TData` | `unknown` | +| `TInput` | `unknown` | + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `value` | `TInput` | + +## Returns + +[`QueryTag`](QueryTag.md)\<`TData`\> diff --git a/docs/api/types/QueryTagType.md b/docs/api/types/QueryTagType.md new file mode 100644 index 0000000..8216dea --- /dev/null +++ b/docs/api/types/QueryTagType.md @@ -0,0 +1,11 @@ +# Types: QueryTagType\ + +```ts +type QueryTagType = TQueryTag extends QueryTag ? TData extends Unset ? unknown : TData : never; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TQueryTag` *extends* [`QueryTag`](QueryTag.md) | diff --git a/docs/api/types/QueryTags.md b/docs/api/types/QueryTags.md new file mode 100644 index 0000000..7bec042 --- /dev/null +++ b/docs/api/types/QueryTags.md @@ -0,0 +1,13 @@ +# Types: QueryTags\ + +```ts +type QueryTags = + | QueryTag | Unset>[] + | (value) => QueryTag | Unset>[]; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | [`QueryAction`](QueryAction.md) | diff --git a/docs/api/types/RefreshQueryData.md b/docs/api/types/RefreshQueryData.md new file mode 100644 index 0000000..acb849e --- /dev/null +++ b/docs/api/types/RefreshQueryData.md @@ -0,0 +1,70 @@ +# Types: RefreshQueryData() + +```ts +type RefreshQueryData = { + (tag): void; + (action): void; + (action, parameters): void; +}; +``` + +## Call Signature + +```ts +(tag): void; +``` + +### Type Parameters + +| Type Parameter | +| ------ | +| `TQueryTag` *extends* [`QueryTag`](QueryTag.md)\<`unknown`\> | + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `tag` | `TQueryTag` \| `TQueryTag`[] | + +### Returns + +`void` + +## Call Signature + +```ts +(action): void; +``` + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | [`QueryAction`](QueryAction.md) | + +### Returns + +`void` + +## Call Signature + +```ts +(action, parameters): void; +``` + +### Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `parameters` | `Parameters`\<`TAction`\> | + +### Returns + +`void` diff --git a/docs/api/types/SetQueryData.md b/docs/api/types/SetQueryData.md new file mode 100644 index 0000000..5f5d27a --- /dev/null +++ b/docs/api/types/SetQueryData.md @@ -0,0 +1,82 @@ +# Types: SetQueryData() + +```ts +type SetQueryData = { + (tag, setter): void; + (action, setter): void; + (action, parameters, setter): void; +}; +``` + +## Call Signature + +```ts +(tag, setter): void; +``` + +### Type Parameters + +| Type Parameter | +| ------ | +| `TQueryTag` *extends* [`QueryTag`](QueryTag.md)\<`unknown`\> | + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `tag` | `TQueryTag` \| `TQueryTag`[] | +| `setter` | [`QueryDataSetter`](QueryDataSetter.md)\<[`QueryTagType`](QueryTagType.md)\<`TQueryTag`\>\> | + +### Returns + +`void` + +## Call Signature + +```ts +(action, setter): void; +``` + +### Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `setter` | [`QueryDataSetter`](QueryDataSetter.md)\<`Awaited`\<`ReturnType`\<`TAction`\>\>\> | + +### Returns + +`void` + +## Call Signature + +```ts +( + action, + parameters, + setter): void; +``` + +### Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `action` | `TAction` | +| `parameters` | `Parameters`\<`TAction`\> | +| `setter` | [`QueryDataSetter`](QueryDataSetter.md)\<`Awaited`\<`ReturnType`\<`TAction`\>\>\> | + +### Returns + +`void` diff --git a/docs/api/types/SetQueryDataAfterContext.md b/docs/api/types/SetQueryDataAfterContext.md new file mode 100644 index 0000000..63adbec --- /dev/null +++ b/docs/api/types/SetQueryDataAfterContext.md @@ -0,0 +1,18 @@ +# Types: SetQueryDataAfterContext\ + +```ts +type SetQueryDataAfterContext = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `data` | [`MutationData`](MutationData.md)\<`TAction`\> | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/SetQueryDataBeforeContext.md b/docs/api/types/SetQueryDataBeforeContext.md new file mode 100644 index 0000000..d03e2ab --- /dev/null +++ b/docs/api/types/SetQueryDataBeforeContext.md @@ -0,0 +1,17 @@ +# Types: SetQueryDataBeforeContext\ + +```ts +type SetQueryDataBeforeContext = object; +``` + +## Type Parameters + +| Type Parameter | +| ------ | +| `TAction` *extends* [`MutationAction`](MutationAction.md) | + +## Properties + +| Property | Type | +| ------ | ------ | +| `payload` | `Parameters`\<`TAction`\> | diff --git a/docs/api/types/UseQueryOptions.md b/docs/api/types/UseQueryOptions.md new file mode 100644 index 0000000..3961003 --- /dev/null +++ b/docs/api/types/UseQueryOptions.md @@ -0,0 +1,20 @@ +# Types: UseQueryOptions\ + +```ts +type UseQueryOptions = QueryOptions & object; +``` + +## Type Declaration + +### immediate? + +```ts +optional immediate: boolean; +``` + +## Type Parameters + +| Type Parameter | Default type | +| ------ | ------ | +| `TAction` *extends* [`QueryAction`](QueryAction.md) | [`QueryAction`](QueryAction.md) | +| `TPlaceholder` | `unknown` | diff --git a/package-lock.json b/package-lock.json index 8fd8bd5..9de2e14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,9 @@ "@vitejs/plugin-vue": "^6.0.1", "@vue/test-utils": "^2.4.6", "eslint": "^9.38.0", + "typedoc": "^0.28.12", + "typedoc-plugin-markdown": "^4.8.1", + "typedoc-vitepress-theme": "^1.1.2", "typescript": "^5.9.3", "vite": "^7.1.12", "vite-plugin-dts": "^4.5.4", @@ -1036,6 +1039,62 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@gerrit0/mini-shiki": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@gerrit0/mini-shiki/-/mini-shiki-3.14.0.tgz", + "integrity": "sha512-c5X8fwPLOtUS8TVdqhynz9iV0GlOtFUT1ppXYzUUlEXe4kbZ/mvMT8wXoT8kCwUka+zsiloq7sD3pZ3+QVTuNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/engine-oniguruma": "^3.14.0", + "@shikijs/langs": "^3.14.0", + "@shikijs/themes": "^3.14.0", + "@shikijs/types": "^3.14.0", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, + "node_modules/@gerrit0/mini-shiki/node_modules/@shikijs/engine-oniguruma": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.14.0.tgz", + "integrity": "sha512-TNcYTYMbJyy+ZjzWtt0bG5y4YyMIWC2nyePz+CFMWqm+HnZZyy9SWMgo8Z6KBJVIZnx8XUXS8U2afO6Y0g1Oug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, + "node_modules/@gerrit0/mini-shiki/node_modules/@shikijs/langs": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-3.14.0.tgz", + "integrity": "sha512-DIB2EQY7yPX1/ZH7lMcwrK5pl+ZkP/xoSpUzg9YC8R+evRCCiSQ7yyrvEyBsMnfZq4eBzLzBlugMyTAf13+pzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0" + } + }, + "node_modules/@gerrit0/mini-shiki/node_modules/@shikijs/themes": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-3.14.0.tgz", + "integrity": "sha512-fAo/OnfWckNmv4uBoUu6dSlkcBc+SA1xzj5oUSaz5z3KqHtEbUypg/9xxgJARtM6+7RVm0Q6Xnty41xA1ma1IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0" + } + }, + "node_modules/@gerrit0/mini-shiki/node_modules/@shikijs/types": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.14.0.tgz", + "integrity": "sha512-bQGgC6vrY8U/9ObG1Z/vTro+uclbjjD/uG58RvfxKZVD5p9Yc1ka3tVyEFy7BNJLzxuWyHH5NWynP9zZZS59eQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -4146,6 +4205,16 @@ "node": ">= 0.8.0" } }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, "node_modules/local-pkg": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-1.1.1.tgz", @@ -4206,6 +4275,13 @@ "node": ">=10" } }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true, + "license": "MIT" + }, "node_modules/magic-string": { "version": "0.30.19", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", @@ -4222,6 +4298,31 @@ "dev": true, "license": "MIT" }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, "node_modules/mdast-util-to-hast": { "version": "13.2.0", "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz", @@ -4244,6 +4345,13 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -4801,6 +4909,16 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/quansync": { "version": "0.2.10", "resolved": "https://registry.npmjs.org/quansync/-/quansync-0.2.10.tgz", @@ -5425,6 +5543,69 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typedoc": { + "version": "0.28.14", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.28.14.tgz", + "integrity": "sha512-ftJYPvpVfQvFzpkoSfHLkJybdA/geDJ8BGQt/ZnkkhnBYoYW6lBgPQXu6vqLxO4X75dA55hX8Af847H5KXlEFA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@gerrit0/mini-shiki": "^3.12.0", + "lunr": "^2.3.9", + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "yaml": "^2.8.1" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 18", + "pnpm": ">= 10" + }, + "peerDependencies": { + "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x" + } + }, + "node_modules/typedoc-plugin-markdown": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.9.0.tgz", + "integrity": "sha512-9Uu4WR9L7ZBgAl60N/h+jqmPxxvnC9nQAlnnO/OujtG2ubjnKTVUFY1XDhcMY+pCqlX3N2HsQM2QTYZIU9tJuw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "typedoc": "0.28.x" + } + }, + "node_modules/typedoc-vitepress-theme": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/typedoc-vitepress-theme/-/typedoc-vitepress-theme-1.1.2.tgz", + "integrity": "sha512-hQvCZRr5uKDqY1bRuY1+eNTNn6d4TE4OP5pnw65Y7WGgajkJW9X1/lVJK2UJpcwCmwkdjw1QIO49H9JQlxWhhw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typedoc-plugin-markdown": ">=4.4.0" + } + }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -5463,6 +5644,13 @@ "typescript": ">=4.8.4 <6.0.0" } }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, + "license": "MIT" + }, "node_modules/ufo": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.1.tgz", @@ -6587,6 +6775,19 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/yaml": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", + "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index a247397..2d8c5d7 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,9 @@ "@vitejs/plugin-vue": "^6.0.1", "@vue/test-utils": "^2.4.6", "eslint": "^9.38.0", + "typedoc-plugin-markdown": "^4.8.1", + "typedoc-vitepress-theme": "^1.1.2", + "typedoc": "^0.28.12", "typescript": "^5.9.3", "vite": "^7.1.12", "vite-plugin-dts": "^4.5.4", diff --git a/scripts/api.js b/scripts/api.js new file mode 100644 index 0000000..273e730 --- /dev/null +++ b/scripts/api.js @@ -0,0 +1,116 @@ +import path from 'path' +import fs from 'fs/promises' + +async function renameTypeAliasesFolderToTypes() { + try { + const oldPath = path.join(process.cwd(), 'docs', 'api', 'type-aliases') + const newPath = path.join(process.cwd(), 'docs', 'api', 'types') + + // Check if old directory exists + await fs.access(oldPath) + + // Rename the directory + await fs.rename(oldPath, newPath) + + console.log('Successfully renamed type-aliases folder to types') + } + catch (error) { + if (error.code === 'ENOENT') { + console.error('Error: The type-aliases directory does not exist') + } + else { + console.error('Error renaming folder:', error) + } + process.exit(1) + } +} + +async function updateReferences(searchString, replaceString) { + try { + const apiDir = path.join(process.cwd(), 'docs', 'api') + const entries = await fs.readdir(apiDir, { withFileTypes: true, recursive: true }) + + for (const entry of entries) { + if (entry.isFile() && (entry.name.endsWith('.md') || entry.name.endsWith('.json'))) { + const fullPath = path.join(entry.path || '', entry.name) + const content = await fs.readFile(fullPath, 'utf8') + const updatedContent = content.replace(new RegExp(searchString, 'g'), replaceString) + + if (content !== updatedContent) { + await fs.writeFile(fullPath, updatedContent, 'utf8') + console.log(`Updated references in: ${fullPath}`) + } + } + } + console.log(`Successfully updated all references from ${searchString} to ${replaceString}`) + } + catch (error) { + console.error('Error updating references:', error) + throw error + } +} + +async function organizeFilesByGroup() { + try { + const apiDir = path.join(process.cwd(), 'docs', 'api') + const entries = await fs.readdir(apiDir, { withFileTypes: true, recursive: true }) + const changes = new Map() // Track old paths to new paths + + // First pass: collect all the moves we need to make + for (const entry of entries) { + if (entry.isFile() && entry.name.endsWith('.md')) { + const fullPath = path.join(entry.path || '', entry.name) + const content = await fs.readFile(fullPath, 'utf8') + + // Extract group from H1 heading + const match = content.match(/^# ([^:]+):/m) + if (match) { + const group = match[1].trim() + const folderName = group.toLowerCase().replace(/\s+/g, '-') + const targetDir = path.join(apiDir, folderName) + + // Create directory if it doesn't exist + try { + await fs.access(targetDir) + } + catch { + await fs.mkdir(targetDir) + console.log(`Created new directory: ${targetDir}`) + } + + // Check if file needs to be moved + const currentDir = path.dirname(fullPath) + if (currentDir !== targetDir) { + const oldPath = path.relative(apiDir, fullPath) + const newPath = path.join(folderName, entry.name) + changes.set(oldPath, newPath) + } + } + } + } + + // Second pass: perform the moves + for (const [oldPath, newPath] of changes) { + const sourcePath = path.join(apiDir, oldPath) + const targetPath = path.join(apiDir, newPath) + await fs.rename(sourcePath, targetPath) + console.log(`Moved ${oldPath} to ${newPath}`) + } + + // Third pass: update all references for each move + for (const [oldPath, newPath] of changes) { + await updateReferences(oldPath, newPath) + } + + console.log('Successfully organized files by their groups and updated all references') + } + catch (error) { + console.error('Error organizing files:', error) + throw error + } +} + +await renameTypeAliasesFolderToTypes() +await updateReferences('type-aliases', 'types') +await updateReferences('Type Aliases', 'Types') +await organizeFilesByGroup() diff --git a/typedoc.mjs b/typedoc.mjs new file mode 100644 index 0000000..1ce71a3 --- /dev/null +++ b/typedoc.mjs @@ -0,0 +1,34 @@ +export default { + $schema: "https://typedoc.org/schema.json", + entryPoints: ["./dist/kitbag-query.d.ts"], + plugin: [ + "typedoc-plugin-markdown", + "typedoc-vitepress-theme", + ], + out: "./docs/api", + docsRoot: "./docs/", + tsconfig: "./typedoc.tsconfig.json", + readme: "none", + parametersFormat: "table", + propertiesFormat: "table", + hideBreadcrumbs: true, + hidePageHeader: true, + hideGroupHeadings: true, + useCodeBlocks: true, + disableSources: true, + groupOrder: [ + "Compositions", + "Errors", + "Interfaces", + "Type Guards", + "Types", + "Utilities", + "*", + ], + sidebar: { + pretty: true, + }, + pageTitleTemplates: { + member: (args) => `${args.group}: ${args.name}`, + } +} diff --git a/typedoc.tsconfig.json b/typedoc.tsconfig.json new file mode 100644 index 0000000..c72c5fc --- /dev/null +++ b/typedoc.tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": ["dist/kitbag-query.d.ts"], + "exclude": ["node_modules"] +} \ No newline at end of file