@gettersethya/mira-tanstack-adapter 0.1.0-alpha.21 → 0.1.0-alpha.22

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
@@ -1,160 +1,158 @@
1
- # @gettersethya/mira-tanstack-adapter
2
-
3
- [![npm](https://img.shields.io/npm/v/@gettersethya/mira-tanstack-adapter)](https://www.npmjs.com/package/@gettersethya/mira-tanstack-adapter)
4
-
5
- > **Early pre-alpha.** Breaking changes may occur without notice.
6
-
7
- TanStack Query adapters for [@gettersethya/mira-client](https://www.npmjs.com/package/@gettersethya/mira-client). Wraps collection client methods with `queryOptions` and `mutationOptions`, with structured query keys for fine-grained cache invalidation.
8
-
9
- Supports React, Svelte, and Solid via separate entry points.
10
-
11
- ## Installation
12
-
13
- ```bash
14
- # React
15
- npm install @gettersethya/mira-tanstack-adapter @tanstack/react-query
16
-
17
- # Svelte
18
- npm install @gettersethya/mira-tanstack-adapter @tanstack/svelte-query
19
-
20
- # Solid
21
- npm install @gettersethya/mira-tanstack-adapter @tanstack/solid-query
22
- ```
23
-
24
- `@gettersethya/mira-client` is a required peer dependency. Only install the TanStack package for the framework you use.
25
-
26
- ## Setup
27
-
28
- ```typescript
29
- import { createMiraClient } from "@gettersethya/mira-client"
30
- import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/react"
31
- // import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/solid"
32
- import { Posts } from "./collections.js"
33
-
34
- const mira = createMiraClient("/api").withCollections({ posts: Posts })
35
- const postsApi = collectionAdapter(mira, "posts")
36
- ```
37
-
38
- Svelte uses a small factory instead of a pre-built adapter (its v6 option
39
- types cannot be re-exported from another package's declarations):
40
-
41
- ```typescript
42
- import { mutationOptions, queryOptions } from "@tanstack/svelte-query"
43
- import { createSvelteCollectionAdapter } from "@gettersethya/mira-tanstack-adapter/svelte"
44
-
45
- const collectionAdapter = createSvelteCollectionAdapter(queryOptions, mutationOptions)
46
- const postsApi = collectionAdapter(mira, "posts")
47
- ```
48
-
49
- The framework-agnostic factory also lives at the package root for custom setups:
50
-
51
- ```typescript
52
- import { queryOptions, mutationOptions } from "@tanstack/react-query"
53
- import { createCollectionAdapter } from "@gettersethya/mira-tanstack-adapter"
54
-
55
- const collectionAdapter = createCollectionAdapter(queryOptions, mutationOptions)
56
- ```
57
-
58
- ## Queries
59
-
60
- ```tsx
61
- import { useQuery } from "@tanstack/react-query"
62
- import { postsApi } from "./setup.js"
63
-
64
- function PostList() {
65
- const { data, isLoading } = useQuery(
66
- postsApi.getList({
67
- filter: (f) => f.field("published").eq(true),
68
- limit: 10,
69
- }).queryOptions
70
- )
71
-
72
- if (isLoading) return <p>Loading...</p>
73
- return <ul>{data?.items.map(p => <li key={p.id}>{p.title}</li>)}</ul>
74
- }
75
-
76
- function PostDetail({ id }: { id: string }) {
77
- const { data } = useQuery(postsApi.getOne(id).queryOptions)
78
- return <h1>{data?.title}</h1>
79
- }
80
- ```
81
-
82
- ## Mutations
83
-
84
- ```tsx
85
- import { useMutation, useQueryClient } from "@tanstack/react-query"
86
- import { postsApi } from "./setup.js"
87
-
88
- function PostActions() {
89
- const queryClient = useQueryClient()
90
-
91
- const create = useMutation({
92
- ...postsApi.create().mutationOptions,
93
- onSuccess: () => postsApi.invalidateAll(queryClient),
94
- })
95
-
96
- const update = useMutation({
97
- ...postsApi.update().mutationOptions,
98
- onSuccess: (post) => postsApi.invalidateOne(queryClient, post.id),
99
- })
100
-
101
- const remove = useMutation({
102
- ...postsApi.delete().mutationOptions,
103
- onSuccess: () => postsApi.invalidateAll(queryClient),
104
- })
105
-
106
- return (
107
- <button onClick={() => create.mutate({ title: "New Post", published: false })}>
108
- Create
109
- </button>
110
- )
111
- }
112
- ```
113
-
114
- ## Svelte and Solid
115
-
116
- React and Solid expose a pre-built `collectionAdapter`. Svelte exposes a
117
- `createSvelteCollectionAdapter(queryOptions, mutationOptions)` factory instead
118
- (see Setup above). Svelte v6 reads options through reactive getters:
119
-
120
- ```typescript
121
- // Svelte
122
- import { createSvelteCollectionAdapter } from "@gettersethya/mira-tanstack-adapter/svelte"
123
- // use with createQuery / createMutation from @tanstack/svelte-query
124
- const query = createQuery(() => api.getList({ limit: 10 }).queryOptions)
125
-
126
- // Solid
127
- import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/solid"
128
- // use with createQuery / createMutation from @tanstack/solid-query
129
- ```
130
-
131
- ## Query key structure
132
-
133
- The adapter produces structured query keys for fine-grained cache invalidation:
134
-
135
- ```typescript
136
- // ["posts", "getList", { limit, filter, sort, order, cursor, select, expand }]
137
- // ["posts", "getOne", "post-id"]
138
- // ["posts", "getFirstOrNone", { filter, sort, order, select, expand }]
139
- // ["posts", "getFullList", { limit, filter, sort, order, select, expand }]
140
-
141
- // Invalidate all queries for a collection
142
- queryClient.invalidateQueries({ queryKey: ["posts"] })
143
-
144
- // Invalidate only list queries
145
- queryClient.invalidateQueries({ queryKey: ["posts", "getList"] })
146
-
147
- // Invalidate a specific record
148
- queryClient.invalidateQueries({ queryKey: ["posts", "getOne", "post-id"] })
149
- ```
150
-
151
- The adapter also exposes two helpers:
152
-
153
- ```typescript
154
- postsApi.invalidateAll(queryClient) // invalidates all posts queries
155
- postsApi.invalidateOne(queryClient, postId) // invalidates the getOne query for postId
156
- ```
157
-
158
- ## More
159
-
160
- See the [Mira root README](https://github.com/gettersethya/mira) for collection definitions, field types, rules, and client usage.
1
+ # @gettersethya/mira-tanstack-adapter
2
+
3
+ [![npm](https://img.shields.io/npm/v/@gettersethya/mira-tanstack-adapter)](https://www.npmjs.com/package/@gettersethya/mira-tanstack-adapter)
4
+
5
+ > **Early pre-alpha.** Breaking changes may occur without notice.
6
+
7
+ Framework-agnostic TanStack Query adapter for
8
+ [@gettersethya/mira-client](https://www.npmjs.com/package/@gettersethya/mira-client).
9
+ Wraps a collection client's methods with `queryOptions` and `mutationOptions`,
10
+ with structured query keys for fine-grained cache invalidation.
11
+
12
+ The option objects are plain `{ queryKey, queryFn }` / `{ mutationFn }` shapes,
13
+ so this package has **no runtime dependency on TanStack** — `useQuery` /
14
+ `useMutation` (React, Solid) and `createQuery` / `createMutation` (Svelte) all
15
+ accept them and infer `data`.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @gettersethya/mira-tanstack-adapter
21
+ ```
22
+
23
+ `@gettersethya/mira-client` is a required peer dependency. Install whichever
24
+ TanStack Query package your framework uses separately.
25
+
26
+ ## Setup
27
+
28
+ Pass `collectionAdapter` to `withCollections` and every accessor is enriched in
29
+ one call:
30
+
31
+ ```typescript
32
+ import { createMiraClient } from "@gettersethya/mira-client"
33
+ import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter"
34
+ import { Posts, Users } from "./collections.js"
35
+
36
+ export const client = createMiraClient("/api").withCollections(
37
+ { posts: Posts, users: Users },
38
+ { adapter: collectionAdapter },
39
+ )
40
+ ```
41
+
42
+ ## Queries
43
+
44
+ ```tsx
45
+ import { useQuery } from "@tanstack/react-query"
46
+ import { client } from "./setup.js"
47
+
48
+ function PostList() {
49
+ const { data, isLoading } = useQuery(
50
+ client.posts.getList({
51
+ filter: (f) => f.field("published").eq(true),
52
+ limit: 10,
53
+ }).queryOptions
54
+ )
55
+
56
+ if (isLoading) return <p>Loading...</p>
57
+ return <ul>{data?.items.map(p => <li key={p.id}>{p.title}</li>)}</ul>
58
+ }
59
+
60
+ function PostDetail({ id }: { id: string }) {
61
+ const { data } = useQuery(client.posts.getOne(id).queryOptions)
62
+ return <h1>{data?.title}</h1>
63
+ }
64
+ ```
65
+
66
+ ## Mutations
67
+
68
+ ```tsx
69
+ import { useMutation, useQueryClient } from "@tanstack/react-query"
70
+ import { client } from "./setup.js"
71
+
72
+ function PostActions() {
73
+ const queryClient = useQueryClient()
74
+
75
+ const create = useMutation({
76
+ ...client.posts.create().mutationOptions,
77
+ onSuccess: () => client.posts.invalidateAll(queryClient),
78
+ })
79
+
80
+ const update = useMutation({
81
+ ...client.posts.update().mutationOptions,
82
+ onSuccess: (post) => client.posts.invalidateOne(queryClient, post.id),
83
+ })
84
+
85
+ const remove = useMutation({
86
+ ...client.posts.delete().mutationOptions,
87
+ onSuccess: () => client.posts.invalidateAll(queryClient),
88
+ })
89
+
90
+ return (
91
+ <button onClick={() => create.mutate({ title: "New Post", published: false })}>
92
+ Create
93
+ </button>
94
+ )
95
+ }
96
+ ```
97
+
98
+ ## Solid and Svelte
99
+
100
+ The same call shape works everywhere — the adapter is framework-agnostic:
101
+
102
+ ```typescript
103
+ // Solid — createQuery / createMutation from @tanstack/solid-query
104
+ createQuery(() => client.posts.getList({ limit: 10 }).queryOptions)
105
+
106
+ // Svelte — reactive getters from @tanstack/svelte-query
107
+ createQuery(() => client.posts.getList({ limit: 10 }).queryOptions)
108
+ ```
109
+
110
+ ## Per-collection usage
111
+
112
+ If you prefer to adapt a single collection (for example with `createMiraClient().collection(def)`),
113
+ call the adapter directly:
114
+
115
+ ```typescript
116
+ import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter"
117
+
118
+ const postsApi = collectionAdapter(client.collection(Posts), Posts.name, Posts.schema["x-collection-kind"])
119
+ ```
120
+
121
+ Or build one yourself with the framework-agnostic factory:
122
+
123
+ ```typescript
124
+ import { createCollectionAdapter } from "@gettersethya/mira-tanstack-adapter"
125
+
126
+ const collectionAdapter = createCollectionAdapter()
127
+ ```
128
+
129
+ ## Query key structure
130
+
131
+ The adapter produces structured query keys for fine-grained cache invalidation:
132
+
133
+ ```typescript
134
+ // ["posts", "getList", { limit, filter, sort, order, cursor, select, expand }]
135
+ // ["posts", "getOne", "post-id", {}]
136
+ // ["posts", "getFirstOrNone", { filter, sort, order, select, expand }]
137
+ // ["posts", "getFullList", { limit, filter, sort, order, select, expand }]
138
+
139
+ // Invalidate all queries for a collection
140
+ queryClient.invalidateQueries({ queryKey: ["posts"] })
141
+
142
+ // Invalidate only list queries
143
+ queryClient.invalidateQueries({ queryKey: ["posts", "getList"] })
144
+
145
+ // Invalidate a specific record
146
+ queryClient.invalidateQueries({ queryKey: ["posts", "getOne", "post-id"] })
147
+ ```
148
+
149
+ The adapter also exposes two helpers:
150
+
151
+ ```typescript
152
+ client.posts.invalidateAll(queryClient) // invalidates all posts queries
153
+ client.posts.invalidateOne(queryClient, postId) // invalidates the getOne query for postId
154
+ ```
155
+
156
+ ## More
157
+
158
+ See the [Mira root README](https://github.com/gettersethya/mira) for collection definitions, field types, rules, and client usage.
package/dist/_core.d.ts CHANGED
@@ -1,47 +1,25 @@
1
- import type { CollectionClient, FieldsMap, FilterBuilder, FilterNode } from "@gettersethya/mira-client";
1
+ import type { AdaptedCollectionClient, AdaptedMutationOptions, AdaptedQueryOptions, CollectionClient, CollectionKind, FieldsMap } from "@gettersethya/mira-client";
2
2
  /**
3
3
  * A readonly array of unknown values used as a TanStack Query query key.
4
4
  *
5
5
  * @example
6
6
  * ```ts
7
- * const key: QueryKey = ["posts", "getList", { limit: 10 }]
7
+ * const key: QueryKey = ["todos", "getList", { limit: 10 }]
8
8
  * ```
9
9
  */
10
10
  export type QueryKey = ReadonlyArray<unknown>;
11
11
  /**
12
- * Shape expected by TanStack Query's `queryOptions` for a query returning `T`.
12
+ * Shape expected by TanStack Query's `useQuery` for a query returning `T`.
13
13
  *
14
- * @template T - The data type returned by the query function.
14
+ * The adapter produces plain objects of this shape (it does not import the
15
+ * framework): `useQuery` / `createQuery` accept them directly and infer `data`.
15
16
  */
16
- export type QueryOptionsShape<T> = {
17
- queryKey: QueryKey;
18
- queryFn: () => Promise<T>;
19
- };
20
- /**
21
- * Shape expected by TanStack Query's `mutationOptions` for a mutation consuming `TInput` and returning `TData`.
22
- *
23
- * @template TData - The data type returned by the mutation function.
24
- * @template TInput - The input data type consumed by the mutation function.
25
- */
26
- export type MutationOptionsShape<TData, TInput> = {
27
- mutationFn: (input: TInput) => Promise<TData>;
28
- };
29
- /**
30
- * Signature for the framework-provided `queryOptions` factory.
31
- * TanStack Query in each framework exports a `queryOptions` function that accepts
32
- * a {@link QueryOptionsShape} and returns a framework-specific options object.
33
- * The return type is intentionally `unknown`: each framework returns its own
34
- * options shape, which callers narrow via `ReturnType` in {@link enrichQuery}.
35
- */
36
- export type MakeQueryOptions = <T>(opts: QueryOptionsShape<T>) => unknown;
17
+ export type QueryOptionsShape<T> = AdaptedQueryOptions<T>;
37
18
  /**
38
- * Signature for the framework-provided `mutationOptions` factory.
39
- * TanStack Query in each framework exports a `mutationOptions` function that accepts
40
- * a {@link MutationOptionsShape} and returns a framework-specific options object.
41
- * The return type is intentionally `unknown`: each framework returns its own
42
- * options shape, which callers narrow via `ReturnType` in {@link enrichMutation}.
19
+ * Shape expected by TanStack Query's `useMutation` for a mutation consuming
20
+ * `TInput` and returning `TData`.
43
21
  */
44
- export type MakeMutationOptions = <TData, TInput>(opts: MutationOptionsShape<TData, TInput>) => unknown;
22
+ export type MutationOptionsShape<TData, TInput> = AdaptedMutationOptions<TData, TInput>;
45
23
  /**
46
24
  * A map of human-readable action names to their string key values.
47
25
  * Used internally to build structured query keys that include the action being performed.
@@ -65,209 +43,85 @@ export type ActionKey = (typeof ActionKeys)[keyof typeof ActionKeys];
65
43
  /**
66
44
  * Extends a query handler with a `queryKey` and pre-built `queryOptions` object.
67
45
  *
68
- * Uses the provided {@link MakeQueryOptions} factory to convert the handler into
69
- * a TanStack Query-compatible options object. The returned handler retains all
70
- * original methods (e.g. `raw()`, `toEffect()`) with `queryKey` and `queryOptions`
71
- * added as extra properties via `Object.assign`.
46
+ * The returned handler retains all original methods (e.g. `raw()`, `toEffect()`)
47
+ * with `queryKey` and `queryOptions` added as extra properties via `Object.assign`.
72
48
  *
73
49
  * @template T - The data type returned by the underlying handler.
74
50
  * @template H - The handler type, constrained to objects with a zero-arg `raw()` method returning `Promise<T>`.
75
- * @template F - The framework `queryOptions` factory. Its return type is preserved
76
- * via `ReturnType`, so framework-specific option fields survive.
77
51
  * @param handler - The original handler (e.g. from `client.getList()`).
78
52
  * @param key - The query key array to associate with this query.
79
- * @param makeQueryOptions - Framework-specific `queryOptions` factory.
80
53
  * @returns The original handler augmented with `queryKey` and `queryOptions`.
81
54
  * @see enrichMutation For the mutation equivalent.
82
55
  */
83
- export declare function enrichQuery<T, H extends {
84
- raw(): Promise<T>;
85
- }, F extends (opts: QueryOptionsShape<T>) => unknown>(handler: H, key: QueryKey, makeQueryOptions: F): H & {
56
+ export declare function enrichQuery<H extends {
57
+ raw(): Promise<unknown>;
58
+ }>(handler: H, key: QueryKey): H & {
86
59
  queryKey: QueryKey;
87
- queryOptions: ReturnType<F>;
60
+ queryOptions: {
61
+ queryKey: QueryKey;
62
+ queryFn: H["raw"];
63
+ };
88
64
  };
89
65
  /**
90
66
  * Extends a mutation handler with a pre-built `mutationOptions` object.
91
67
  *
92
- * Uses the provided {@link MakeMutationOptions} factory to convert the handler into
93
- * a TanStack Query-compatible mutation options object. The returned handler retains all
94
- * original methods with `mutationOptions` added as an extra property via `Object.assign`.
95
- *
96
68
  * @template TData - The data type returned by the mutation handler.
97
69
  * @template TInput - The input data type consumed by the mutation handler.
98
- * @template H - The handler type, constrained to objects with a single-arg `raw(input)` method returning `Promise<TData>`.
99
- * @template F - The framework `mutationOptions` factory. Its return type is preserved
100
- * via `ReturnType`, so framework-specific option fields survive.
70
+ * @template H - The handler type, constrained to objects with a single-arg `raw(input)` method.
101
71
  * @param handler - The original handler (e.g. from `client.create()`).
102
- * @param makeMutationOptions - Framework-specific `mutationOptions` factory.
103
72
  * @returns The original handler augmented with `mutationOptions`.
104
73
  * @see enrichQuery For the query equivalent.
105
74
  */
106
- export declare function enrichMutation<TData, TInput, H extends {
107
- raw(input: TInput): Promise<TData>;
108
- }, F extends (opts: MutationOptionsShape<TData, TInput>) => unknown>(handler: H, makeMutationOptions: F): H & {
109
- mutationOptions: ReturnType<F>;
75
+ export declare function enrichMutation<H extends {
76
+ raw(input: never): Promise<unknown>;
77
+ }>(handler: H): H & {
78
+ mutationOptions: {
79
+ mutationFn: H["raw"];
80
+ };
110
81
  };
111
82
  /**
112
- * Creates a TanStack Query adapter for any {@link CollectionClient}.
83
+ * Creates a framework-agnostic collection adapter.
113
84
  *
114
- * Returns a function that wraps a `CollectionClient` and enriches every query method
115
- * (getList, getOne, getFirstOrNone, getFullList) with `queryKey` and `queryOptions`,
116
- * and every mutation method (create, update, delete) with `mutationOptions`.
85
+ * The adapter wraps a `CollectionClient` and enriches every query method
86
+ * (getList, getOne, getFirstOrNone, getFullList) with `queryKey` and
87
+ * `queryOptions`, and every mutation method (create, update, delete, register)
88
+ * with `mutationOptions`. The produced option objects are plain
89
+ * `{ queryKey, queryFn }` / `{ mutationFn }` shapes, accepted by TanStack Query
90
+ * in every framework — so the package has no runtime dependency on TanStack.
117
91
  *
118
- * Query keys follow a structured pattern: `[collectionName, actionKey, ...params]`.
119
- * This enables fine-grained cache invalidation — for example, invalidating only
120
- * `getOne` queries for a specific record by referencing key `["posts", "getOne", id]`.
92
+ * Query keys follow a structured pattern: `[collectionName, actionKey, ...params]`,
93
+ * enabling fine-grained cache invalidation (e.g. `[name, "getOne", id]`).
121
94
  *
122
95
  * The returned object also exposes `invalidateAll(queryClient)` and
123
- * `invalidateOne(queryClient, id)` convenience methods that call
124
- * `queryClient.invalidateQueries` with the appropriate key prefix.
96
+ * `invalidateOne(queryClient, id)` helpers.
125
97
  *
126
- * @param makeQueryOptions - Framework-specific `queryOptions` factory
127
- * (e.g. from `@tanstack/react-query`, `@tanstack/svelte-query`, or `@tanstack/solid-query`).
128
- * @param makeMutationOptions - Framework-specific `mutationOptions` factory.
129
- * @returns An adapter function that takes a `CollectionClient` and collection name,
130
- * and returns an enhanced client with query/mutation metadata.
98
+ * @returns An adapter function that takes a `CollectionClient` and collection
99
+ * name, and returns an enhanced client with query/mutation metadata.
131
100
  *
132
101
  * @example
133
102
  * ```ts
134
- * import { queryOptions, mutationOptions } from "@tanstack/react-query"
103
+ * import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter"
135
104
  * import { createMiraClient } from "@gettersethya/mira-client"
136
- * import { createCollectionAdapter } from "@gettersethya/mira-tanstack-adapter"
137
105
  *
138
- * const adapt = createCollectionAdapter(queryOptions, mutationOptions)
139
- * const client = createMiraClient({ url: "/api" }).withCollections({ posts: PostCollection })
140
- * const adapted = adapt(client, "posts")
106
+ * const client = createMiraClient("/api").withCollections(
107
+ * { posts: PostCollection },
108
+ * { adapter: collectionAdapter },
109
+ * )
141
110
  *
142
- * // Use in a React component:
143
- * const { data } = useQuery(adapted.getList({ limit: 10 }).queryOptions)
144
- * const mutation = useMutation(adapted.create().mutationOptions)
145
- *
146
- * // Invalidate after mutation:
147
- * adapted.invalidateAll(queryClient)
148
- * adapted.invalidateOne(queryClient, recordId)
111
+ * const { data } = useQuery(client.posts.getList({ limit: 10 }).queryOptions)
112
+ * const mutation = useMutation(client.posts.create().mutationOptions)
149
113
  * ```
150
114
  *
151
115
  * @see enrichQuery
152
116
  * @see enrichMutation
153
- * @see MakeQueryOptions
154
- * @see MakeMutationOptions
155
117
  */
156
- export declare function createCollectionAdapter<FQ extends MakeQueryOptions, FM extends MakeMutationOptions>(makeQueryOptions: FQ, makeMutationOptions: FM): <F extends FieldsMap>(client: CollectionClient<F>, name: string) => {
157
- /**
158
- * Invalidates all cached queries for this collection.
159
- * Calls `queryClient.invalidateQueries` with key prefix `[name]`.
160
- *
161
- * @param queryClient - Any TanStack Query client with `invalidateQueries`.
162
- */
163
- invalidateAll: (queryClient: {
164
- invalidateQueries(opts: {
165
- queryKey: QueryKey;
166
- }): unknown;
167
- }) => unknown;
168
- /**
169
- * Invalidates only the `getOne` cache entry for a specific record.
170
- * Calls `queryClient.invalidateQueries` with key `[name, "getOne", id]`.
171
- *
172
- * @param queryClient - Any TanStack Query client with `invalidateQueries`.
173
- * @param id - The record ID whose cached `getOne` entry should be invalidated.
174
- */
175
- invalidateOne: (queryClient: {
176
- invalidateQueries(opts: {
177
- queryKey: QueryKey;
178
- }): unknown;
179
- }, id: string) => unknown;
180
- register?: (() => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, import("@gettersethya/mira-collection").RegisterInput<F>>) | undefined;
181
- /**
182
- * Enriched version of `getList` that also returns `queryKey` and `queryOptions`.
183
- * Query key: `[name, "getList", options]`.
184
- */
185
- getList: (options?: Parameters<CollectionClient<F>["getList"]>[0]) => {
186
- raw(): Promise<{
187
- items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
188
- nextCursor: number | null;
189
- }>;
190
- toEffect(): import("effect/Effect").Effect<{
191
- items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
192
- nextCursor: number | null;
193
- }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
194
- } & {
195
- queryKey: QueryKey;
196
- queryOptions: ReturnType<FQ>;
197
- };
198
- /**
199
- * Enriched version of `getOne` that also returns `queryKey` and `queryOptions`.
200
- * Query key: `[name, "getOne", id, options]`.
201
- */
202
- getOne: (id: string, options?: Parameters<CollectionClient<F>["getOne"]>[1]) => {
203
- raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>;
204
- toEffect(): import("effect/Effect").Effect<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
205
- } & {
206
- queryKey: QueryKey;
207
- queryOptions: ReturnType<FQ>;
208
- };
209
- /**
210
- * Enriched version of `getFirstOrNone` that also returns `queryKey` and `queryOptions`.
211
- * Query key: `[name, "getFirstOrNone", options]`.
212
- */
213
- getFirstOrNone: (filter: (f: FilterBuilder<F>) => FilterNode, options?: Parameters<CollectionClient<F>["getFirstOrNone"]>[1]) => {
214
- raw(): Promise<import("effect/Option").Option<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>>;
215
- toEffect(): import("effect/Effect").Effect<import("effect/Option").Option<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
216
- } & {
217
- queryKey: QueryKey;
218
- queryOptions: ReturnType<FQ>;
219
- };
220
- /**
221
- * Enriched version of `getFullList` that also returns `queryKey` and `queryOptions`.
222
- * Query key: `[name, "getFullList", options]`.
223
- */
224
- getFullList: (options?: Parameters<CollectionClient<F>["getFullList"]>[0]) => {
225
- raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[]>;
226
- toEffect(): import("effect/Effect").Effect<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[], import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
227
- } & {
228
- queryKey: QueryKey;
229
- queryOptions: ReturnType<FQ>;
230
- };
231
- /**
232
- * Enriched mutation for creating records. Call `raw(input)` to execute.
233
- */
234
- create: () => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, Omit<import("@gettersethya/mira-collection").InferMutationInput<F>, "emailVerified">> & {
235
- mutationOptions: ReturnType<FM>;
236
- };
237
- /**
238
- * Enriched mutation for updating records. Call `raw(input)` to execute.
239
- */
240
- update: () => {
241
- raw(input: import("@gettersethya/mira-collection").UpdateInput<F, "base">): Promise<import("@gettersethya/mira-collection").InferRecord<F>>;
242
- toEffect(input: import("@gettersethya/mira-collection").UpdateInput<F, "base">): import("effect/Effect").Effect<import("@gettersethya/mira-collection").InferRecord<F>, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
243
- } & {
244
- mutationOptions: ReturnType<FM>;
245
- };
246
- /**
247
- * Enriched mutation for deleting records. Call `raw(input)` to execute.
248
- */
249
- delete: () => {
250
- raw(input: string): Promise<void>;
251
- toEffect(input: string): import("effect/Effect").Effect<void, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
252
- } & {
253
- mutationOptions: ReturnType<FM>;
254
- };
255
- authWithPassword?(): {
256
- raw(input: {
257
- email: string;
258
- password: string;
259
- }): Promise<{
260
- token: string;
261
- record: import("@gettersethya/mira-collection").InferRecord<F>;
262
- }>;
263
- toEffect(input: {
264
- email: string;
265
- password: string;
266
- }): import("effect/Effect").Effect<{
267
- token: string;
268
- record: import("@gettersethya/mira-collection").InferRecord<F>;
269
- }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
270
- };
271
- fields: import("@gettersethya/mira-client").CollectionFileFields<F>;
272
- };
118
+ export declare function createCollectionAdapter(): <F extends FieldsMap, K extends CollectionKind = "base">(client: CollectionClient<F, K>, name: string, kind: K) => AdaptedCollectionClient<F, K>;
119
+ /**
120
+ * A pre-built {@link createCollectionAdapter | collection adapter}.
121
+ *
122
+ * Framework-agnostic — the option objects it produces satisfy TanStack Query's
123
+ * `useQuery` / `useMutation` (React, Solid) and `createQuery` / `createMutation`
124
+ * (Svelte) inputs.
125
+ */
126
+ export declare const collectionAdapter: <F extends FieldsMap, K extends CollectionKind = "base">(client: CollectionClient<F, K>, name: string, kind: K) => AdaptedCollectionClient<F, K>;
273
127
  //# sourceMappingURL=_core.d.ts.map