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

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.
@@ -0,0 +1,173 @@
1
+ import { ActionKeys } from "./_core.js";
2
+ /**
3
+ * A pre-built {@link createCollectionAdapter | collection adapter} for **TanStack React Query**.
4
+ *
5
+ * Uses `queryOptions` and `mutationOptions` from `@tanstack/react-query` to produce
6
+ * options objects compatible with `useQuery` and `useMutation`.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
11
+ * import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/react"
12
+ * import { createMiraClient } from "@gettersethya/mira-client"
13
+ *
14
+ * const client = createMiraClient({ url: "/api" }).withCollections({ posts: PostCollection })
15
+ * const api = collectionAdapter(client, "posts")
16
+ *
17
+ * function PostList() {
18
+ * const { data } = useQuery(api.getList({ limit: 10 }).queryOptions)
19
+ * const queryClient = useQueryClient()
20
+ *
21
+ * const mutation = useMutation({
22
+ * ...api.create().mutationOptions,
23
+ * onSuccess: () => api.invalidateAll(queryClient),
24
+ * })
25
+ *
26
+ * if (!data) return <div>Loading...</div>
27
+ * return <ul>{data.items.map(p => <li key={p.id}>{p.title}</li>)}</ul>
28
+ * }
29
+ * ```
30
+ */
31
+ export declare const collectionAdapter: <F extends import("@gettersethya/mira-collection").FieldsMap>(client: import("@gettersethya/mira-client").CollectionClient<F>, name: string) => {
32
+ invalidateAll: (queryClient: {
33
+ invalidateQueries(opts: {
34
+ queryKey: import("./_core.js").QueryKey;
35
+ }): unknown;
36
+ }) => unknown;
37
+ invalidateOne: (queryClient: {
38
+ invalidateQueries(opts: {
39
+ queryKey: import("./_core.js").QueryKey;
40
+ }): unknown;
41
+ }, id: string) => unknown;
42
+ register?: (() => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, import("@gettersethya/mira-collection").RegisterInput<F>>) | undefined;
43
+ getList: (options?: {
44
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
45
+ sort?: (keyof F & string) | undefined;
46
+ order?: "asc" | "desc";
47
+ cursor?: number | null;
48
+ limit?: number;
49
+ select?: readonly (keyof F & string)[] | undefined;
50
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
51
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
52
+ } | undefined) => {
53
+ raw(): Promise<{
54
+ items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
55
+ nextCursor: number | null;
56
+ }>;
57
+ toEffect(): import("effect/Effect").Effect<{
58
+ items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
59
+ nextCursor: number | null;
60
+ }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
61
+ } & {
62
+ queryKey: import("./_core.js").QueryKey;
63
+ queryOptions: import("@tanstack/react-query").UseQueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
64
+ initialData?: unknown;
65
+ } & {
66
+ queryKey: readonly unknown[] & {
67
+ [dataTagSymbol]: unknown;
68
+ [dataTagErrorSymbol]: unknown;
69
+ };
70
+ };
71
+ };
72
+ getOne: (id: string, options?: {
73
+ select?: readonly (keyof F & string)[] | undefined;
74
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
75
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
76
+ } | undefined) => {
77
+ raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>;
78
+ 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>;
79
+ } & {
80
+ queryKey: import("./_core.js").QueryKey;
81
+ queryOptions: import("@tanstack/react-query").UseQueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
82
+ initialData?: unknown;
83
+ } & {
84
+ queryKey: readonly unknown[] & {
85
+ [dataTagSymbol]: unknown;
86
+ [dataTagErrorSymbol]: unknown;
87
+ };
88
+ };
89
+ };
90
+ getFirstOrNone: (filter: (f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode, options?: Omit<{
91
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
92
+ sort?: (keyof F & string) | undefined;
93
+ order?: "asc" | "desc";
94
+ cursor?: number | null;
95
+ limit?: number;
96
+ select?: readonly (keyof F & string)[] | undefined;
97
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
98
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
99
+ }, "filter" | "limit" | "cursor"> | undefined) => {
100
+ raw(): Promise<import("effect/Option").Option<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>>;
101
+ 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>;
102
+ } & {
103
+ queryKey: import("./_core.js").QueryKey;
104
+ queryOptions: import("@tanstack/react-query").UseQueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
105
+ initialData?: unknown;
106
+ } & {
107
+ queryKey: readonly unknown[] & {
108
+ [dataTagSymbol]: unknown;
109
+ [dataTagErrorSymbol]: unknown;
110
+ };
111
+ };
112
+ };
113
+ getFullList: (options?: (Omit<{
114
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
115
+ sort?: (keyof F & string) | undefined;
116
+ order?: "asc" | "desc";
117
+ cursor?: number | null;
118
+ limit?: number;
119
+ select?: readonly (keyof F & string)[] | undefined;
120
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
121
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
122
+ }, "limit" | "cursor"> & {
123
+ limit?: number;
124
+ }) | undefined) => {
125
+ raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[]>;
126
+ 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>;
127
+ } & {
128
+ queryKey: import("./_core.js").QueryKey;
129
+ queryOptions: import("@tanstack/react-query").UseQueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
130
+ initialData?: unknown;
131
+ } & {
132
+ queryKey: readonly unknown[] & {
133
+ [dataTagSymbol]: unknown;
134
+ [dataTagErrorSymbol]: unknown;
135
+ };
136
+ };
137
+ };
138
+ create: () => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, Omit<import("@gettersethya/mira-collection").InferMutationInput<F>, "emailVerified">> & {
139
+ mutationOptions: Omit<import("@tanstack/react-query").UseMutationOptions<unknown, unknown, unknown, unknown>, "mutationKey">;
140
+ };
141
+ update: () => {
142
+ raw(input: import("@gettersethya/mira-collection").UpdateInput<F, "base">): Promise<import("@gettersethya/mira-collection").InferRecord<F>>;
143
+ 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>;
144
+ } & {
145
+ mutationOptions: Omit<import("@tanstack/react-query").UseMutationOptions<unknown, unknown, unknown, unknown>, "mutationKey">;
146
+ };
147
+ delete: () => {
148
+ raw(input: string): Promise<void>;
149
+ toEffect(input: string): import("effect/Effect").Effect<void, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
150
+ } & {
151
+ mutationOptions: Omit<import("@tanstack/react-query").UseMutationOptions<unknown, unknown, unknown, unknown>, "mutationKey">;
152
+ };
153
+ authWithPassword?(): {
154
+ raw(input: {
155
+ email: string;
156
+ password: string;
157
+ }): Promise<{
158
+ token: string;
159
+ record: import("@gettersethya/mira-collection").InferRecord<F>;
160
+ }>;
161
+ toEffect(input: {
162
+ email: string;
163
+ password: string;
164
+ }): import("effect/Effect").Effect<{
165
+ token: string;
166
+ record: import("@gettersethya/mira-collection").InferRecord<F>;
167
+ }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
168
+ };
169
+ fields: import("@gettersethya/mira-client").CollectionFileFields<F>;
170
+ };
171
+ export { ActionKeys };
172
+ export type { ActionKey } from "./_core.js";
173
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAyD,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
package/dist/react.js ADDED
@@ -0,0 +1,34 @@
1
+ import { mutationOptions, queryOptions } from "@tanstack/react-query";
2
+ import { createCollectionAdapter, ActionKeys } from "./_core.js";
3
+ /**
4
+ * A pre-built {@link createCollectionAdapter | collection adapter} for **TanStack React Query**.
5
+ *
6
+ * Uses `queryOptions` and `mutationOptions` from `@tanstack/react-query` to produce
7
+ * options objects compatible with `useQuery` and `useMutation`.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
12
+ * import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/react"
13
+ * import { createMiraClient } from "@gettersethya/mira-client"
14
+ *
15
+ * const client = createMiraClient({ url: "/api" }).withCollections({ posts: PostCollection })
16
+ * const api = collectionAdapter(client, "posts")
17
+ *
18
+ * function PostList() {
19
+ * const { data } = useQuery(api.getList({ limit: 10 }).queryOptions)
20
+ * const queryClient = useQueryClient()
21
+ *
22
+ * const mutation = useMutation({
23
+ * ...api.create().mutationOptions,
24
+ * onSuccess: () => api.invalidateAll(queryClient),
25
+ * })
26
+ *
27
+ * if (!data) return <div>Loading...</div>
28
+ * return <ul>{data.items.map(p => <li key={p.id}>{p.title}</li>)}</ul>
29
+ * }
30
+ * ```
31
+ */
32
+ export const collectionAdapter = createCollectionAdapter(queryOptions, mutationOptions);
33
+ export { ActionKeys };
34
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -0,0 +1,180 @@
1
+ import { ActionKeys } from "./_core.js";
2
+ /**
3
+ * A pre-built {@link createCollectionAdapter | collection adapter} for **TanStack Solid Query**.
4
+ *
5
+ * Uses `queryOptions` and `mutationOptions` from `@tanstack/solid-query` to produce
6
+ * options objects compatible with `createQuery` and `createMutation`.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { createQuery, createMutation, useQueryClient } from "@tanstack/solid-query"
11
+ * import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/solid"
12
+ * import { createMiraClient } from "@gettersethya/mira-client"
13
+ * import { PostCollection } from "../collections"
14
+ *
15
+ * const client = createMiraClient({ url: "/api" }).withCollections({ posts: PostCollection })
16
+ * const api = collectionAdapter(client, "posts")
17
+ * const queryClient = useQueryClient()
18
+ *
19
+ * function PostList() {
20
+ * const query = createQuery(() => api.getList({ limit: 10 }).queryOptions)
21
+ *
22
+ * const mutation = createMutation(() => ({
23
+ * ...api.create().mutationOptions,
24
+ * onSuccess: () => api.invalidateAll(queryClient),
25
+ * }))
26
+ *
27
+ * return (
28
+ * <div>
29
+ * <Show when={query.isLoading}><p>Loading...</p></Show>
30
+ * <Show when={query.data}>
31
+ * <ul>{query.data!.items.map(p => <li>{p.title}</li>)}</ul>
32
+ * </Show>
33
+ * </div>
34
+ * )
35
+ * }
36
+ * ```
37
+ */
38
+ export declare const collectionAdapter: <F extends import("@gettersethya/mira-collection").FieldsMap>(client: import("@gettersethya/mira-client").CollectionClient<F>, name: string) => {
39
+ invalidateAll: (queryClient: {
40
+ invalidateQueries(opts: {
41
+ queryKey: import("./_core.js").QueryKey;
42
+ }): unknown;
43
+ }) => unknown;
44
+ invalidateOne: (queryClient: {
45
+ invalidateQueries(opts: {
46
+ queryKey: import("./_core.js").QueryKey;
47
+ }): unknown;
48
+ }, id: string) => unknown;
49
+ register?: (() => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, import("@gettersethya/mira-collection").RegisterInput<F>>) | undefined;
50
+ getList: (options?: {
51
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
52
+ sort?: (keyof F & string) | undefined;
53
+ order?: "asc" | "desc";
54
+ cursor?: number | null;
55
+ limit?: number;
56
+ select?: readonly (keyof F & string)[] | undefined;
57
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
58
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
59
+ } | undefined) => {
60
+ raw(): Promise<{
61
+ items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
62
+ nextCursor: number | null;
63
+ }>;
64
+ toEffect(): import("effect/Effect").Effect<{
65
+ items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
66
+ nextCursor: number | null;
67
+ }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
68
+ } & {
69
+ queryKey: import("./_core.js").QueryKey;
70
+ queryOptions: import("@tanstack/solid-query").QueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
71
+ initialData: unknown;
72
+ } & {
73
+ queryKey: readonly unknown[] & {
74
+ [dataTagSymbol]: unknown;
75
+ [dataTagErrorSymbol]: unknown;
76
+ };
77
+ };
78
+ };
79
+ getOne: (id: string, options?: {
80
+ select?: readonly (keyof F & string)[] | undefined;
81
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
82
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
83
+ } | undefined) => {
84
+ raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>;
85
+ 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>;
86
+ } & {
87
+ queryKey: import("./_core.js").QueryKey;
88
+ queryOptions: import("@tanstack/solid-query").QueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
89
+ initialData: unknown;
90
+ } & {
91
+ queryKey: readonly unknown[] & {
92
+ [dataTagSymbol]: unknown;
93
+ [dataTagErrorSymbol]: unknown;
94
+ };
95
+ };
96
+ };
97
+ getFirstOrNone: (filter: (f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode, options?: Omit<{
98
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
99
+ sort?: (keyof F & string) | undefined;
100
+ order?: "asc" | "desc";
101
+ cursor?: number | null;
102
+ limit?: number;
103
+ select?: readonly (keyof F & string)[] | undefined;
104
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
105
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
106
+ }, "filter" | "limit" | "cursor"> | undefined) => {
107
+ raw(): Promise<import("effect/Option").Option<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>>;
108
+ 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>;
109
+ } & {
110
+ queryKey: import("./_core.js").QueryKey;
111
+ queryOptions: import("@tanstack/solid-query").QueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
112
+ initialData: unknown;
113
+ } & {
114
+ queryKey: readonly unknown[] & {
115
+ [dataTagSymbol]: unknown;
116
+ [dataTagErrorSymbol]: unknown;
117
+ };
118
+ };
119
+ };
120
+ getFullList: (options?: (Omit<{
121
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
122
+ sort?: (keyof F & string) | undefined;
123
+ order?: "asc" | "desc";
124
+ cursor?: number | null;
125
+ limit?: number;
126
+ select?: readonly (keyof F & string)[] | undefined;
127
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
128
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
129
+ }, "limit" | "cursor"> & {
130
+ limit?: number;
131
+ }) | undefined) => {
132
+ raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[]>;
133
+ 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>;
134
+ } & {
135
+ queryKey: import("./_core.js").QueryKey;
136
+ queryOptions: import("@tanstack/solid-query").QueryOptions<unknown, unknown, unknown, readonly unknown[]> & {
137
+ initialData: unknown;
138
+ } & {
139
+ queryKey: readonly unknown[] & {
140
+ [dataTagSymbol]: unknown;
141
+ [dataTagErrorSymbol]: unknown;
142
+ };
143
+ };
144
+ };
145
+ create: () => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, Omit<import("@gettersethya/mira-collection").InferMutationInput<F>, "emailVerified">> & {
146
+ mutationOptions: Omit<import("@tanstack/solid-query").MutationOptions<unknown, unknown, unknown, unknown>, "mutationKey">;
147
+ };
148
+ update: () => {
149
+ raw(input: import("@gettersethya/mira-collection").UpdateInput<F, "base">): Promise<import("@gettersethya/mira-collection").InferRecord<F>>;
150
+ 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>;
151
+ } & {
152
+ mutationOptions: Omit<import("@tanstack/solid-query").MutationOptions<unknown, unknown, unknown, unknown>, "mutationKey">;
153
+ };
154
+ delete: () => {
155
+ raw(input: string): Promise<void>;
156
+ toEffect(input: string): import("effect/Effect").Effect<void, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
157
+ } & {
158
+ mutationOptions: Omit<import("@tanstack/solid-query").MutationOptions<unknown, unknown, unknown, unknown>, "mutationKey">;
159
+ };
160
+ authWithPassword?(): {
161
+ raw(input: {
162
+ email: string;
163
+ password: string;
164
+ }): Promise<{
165
+ token: string;
166
+ record: import("@gettersethya/mira-collection").InferRecord<F>;
167
+ }>;
168
+ toEffect(input: {
169
+ email: string;
170
+ password: string;
171
+ }): import("effect/Effect").Effect<{
172
+ token: string;
173
+ record: import("@gettersethya/mira-collection").InferRecord<F>;
174
+ }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
175
+ };
176
+ fields: import("@gettersethya/mira-client").CollectionFileFields<F>;
177
+ };
178
+ export { ActionKeys };
179
+ export type { ActionKey } from "./_core.js";
180
+ //# sourceMappingURL=solid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../src/solid.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAyD,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
package/dist/solid.js ADDED
@@ -0,0 +1,41 @@
1
+ import { mutationOptions, queryOptions } from "@tanstack/solid-query";
2
+ import { createCollectionAdapter, ActionKeys } from "./_core.js";
3
+ /**
4
+ * A pre-built {@link createCollectionAdapter | collection adapter} for **TanStack Solid Query**.
5
+ *
6
+ * Uses `queryOptions` and `mutationOptions` from `@tanstack/solid-query` to produce
7
+ * options objects compatible with `createQuery` and `createMutation`.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { createQuery, createMutation, useQueryClient } from "@tanstack/solid-query"
12
+ * import { collectionAdapter } from "@gettersethya/mira-tanstack-adapter/solid"
13
+ * import { createMiraClient } from "@gettersethya/mira-client"
14
+ * import { PostCollection } from "../collections"
15
+ *
16
+ * const client = createMiraClient({ url: "/api" }).withCollections({ posts: PostCollection })
17
+ * const api = collectionAdapter(client, "posts")
18
+ * const queryClient = useQueryClient()
19
+ *
20
+ * function PostList() {
21
+ * const query = createQuery(() => api.getList({ limit: 10 }).queryOptions)
22
+ *
23
+ * const mutation = createMutation(() => ({
24
+ * ...api.create().mutationOptions,
25
+ * onSuccess: () => api.invalidateAll(queryClient),
26
+ * }))
27
+ *
28
+ * return (
29
+ * <div>
30
+ * <Show when={query.isLoading}><p>Loading...</p></Show>
31
+ * <Show when={query.data}>
32
+ * <ul>{query.data!.items.map(p => <li>{p.title}</li>)}</ul>
33
+ * </Show>
34
+ * </div>
35
+ * )
36
+ * }
37
+ * ```
38
+ */
39
+ export const collectionAdapter = createCollectionAdapter(queryOptions, mutationOptions);
40
+ export { ActionKeys };
41
+ //# sourceMappingURL=solid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid.js","sourceRoot":"","sources":["../src/solid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -0,0 +1,161 @@
1
+ import { ActionKeys } from "./_core.js";
2
+ import type { MakeMutationOptions, MakeQueryOptions } from "./_core.js";
3
+ /**
4
+ * Creates a {@link createCollectionAdapter | collection adapter} for **TanStack Svelte Query**.
5
+ *
6
+ * Unlike the React and Solid entries, this entry cannot ship a pre-built adapter:
7
+ * `@tanstack/svelte-query` v6 brands its option objects with a `unique symbol`
8
+ * that is not exported from the package, so any pre-built value re-exposed here
9
+ * fails declaration emit (`TS2527`). Accepting the factories as arguments keeps
10
+ * this entry emit-safe: inference happens in the consumer's project, where the
11
+ * branded types resolve in memory.
12
+ *
13
+ * Uses `queryOptions` and `mutationOptions` from `@tanstack/svelte-query` to produce
14
+ * options objects compatible with `createQuery` and `createMutation`.
15
+ *
16
+ * @example
17
+ * ```svelte
18
+ * <script lang="ts">
19
+ * import { createQuery, createMutation, getQueryClient, mutationOptions, queryOptions } from "@tanstack/svelte-query"
20
+ * import { createSvelteCollectionAdapter } from "@gettersethya/mira-tanstack-adapter/svelte"
21
+ * import { createMiraClient } from "@gettersethya/mira-client"
22
+ * import { PostCollection } from "../collections"
23
+ *
24
+ * const client = createMiraClient({ url: "/api" }).withCollections({ posts: PostCollection })
25
+ * const collectionAdapter = createSvelteCollectionAdapter(queryOptions, mutationOptions)
26
+ * const api = collectionAdapter(client, "posts")
27
+ *
28
+ * const query = createQuery(() => api.getList({ limit: 10 }).queryOptions)
29
+ * const queryClient = getQueryClient()
30
+ *
31
+ * async function handleCreate() {
32
+ * const mutation = createMutation(() => ({
33
+ * ...api.create().mutationOptions,
34
+ * onSuccess: () => api.invalidateAll(queryClient),
35
+ * }))
36
+ * $mutation.mutate({ title: "New Post" })
37
+ * }
38
+ * </script>
39
+ *
40
+ * {#if $query.isLoading}
41
+ * <p>Loading...</p>
42
+ * {:else}
43
+ * <ul>{#each $query.data?.items ?? [] as post}<li>{post.title}</li>{/each}</ul>
44
+ * {/if}
45
+ * ```
46
+ */
47
+ export declare function createSvelteCollectionAdapter<FQ extends MakeQueryOptions, FM extends MakeMutationOptions>(makeQueryOptions: FQ, makeMutationOptions: FM): <F extends import("@gettersethya/mira-collection").FieldsMap>(client: import("@gettersethya/mira-client").CollectionClient<F>, name: string) => {
48
+ invalidateAll: (queryClient: {
49
+ invalidateQueries(opts: {
50
+ queryKey: import("./_core.js").QueryKey;
51
+ }): unknown;
52
+ }) => unknown;
53
+ invalidateOne: (queryClient: {
54
+ invalidateQueries(opts: {
55
+ queryKey: import("./_core.js").QueryKey;
56
+ }): unknown;
57
+ }, id: string) => unknown;
58
+ register?: (() => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, import("@gettersethya/mira-collection").RegisterInput<F>>) | undefined;
59
+ getList: (options?: {
60
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
61
+ sort?: (keyof F & string) | undefined;
62
+ order?: "asc" | "desc";
63
+ cursor?: number | null;
64
+ limit?: number;
65
+ select?: readonly (keyof F & string)[] | undefined;
66
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
67
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
68
+ } | undefined) => {
69
+ raw(): Promise<{
70
+ items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
71
+ nextCursor: number | null;
72
+ }>;
73
+ toEffect(): import("effect/Effect").Effect<{
74
+ items: import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[];
75
+ nextCursor: number | null;
76
+ }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
77
+ } & {
78
+ queryKey: import("./_core.js").QueryKey;
79
+ queryOptions: ReturnType<FQ>;
80
+ };
81
+ getOne: (id: string, options?: {
82
+ select?: readonly (keyof F & string)[] | undefined;
83
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
84
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
85
+ } | undefined) => {
86
+ raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>;
87
+ 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>;
88
+ } & {
89
+ queryKey: import("./_core.js").QueryKey;
90
+ queryOptions: ReturnType<FQ>;
91
+ };
92
+ getFirstOrNone: (filter: (f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode, options?: Omit<{
93
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
94
+ sort?: (keyof F & string) | undefined;
95
+ order?: "asc" | "desc";
96
+ cursor?: number | null;
97
+ limit?: number;
98
+ select?: readonly (keyof F & string)[] | undefined;
99
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
100
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
101
+ }, "filter" | "limit" | "cursor"> | undefined) => {
102
+ raw(): Promise<import("effect/Option").Option<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>>>;
103
+ 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>;
104
+ } & {
105
+ queryKey: import("./_core.js").QueryKey;
106
+ queryOptions: ReturnType<FQ>;
107
+ };
108
+ getFullList: (options?: (Omit<{
109
+ filter?: ((f: import("@gettersethya/mira-client").FilterBuilder<F>) => import("@gettersethya/mira-collection").FilterNode) | undefined;
110
+ sort?: (keyof F & string) | undefined;
111
+ order?: "asc" | "desc";
112
+ cursor?: number | null;
113
+ limit?: number;
114
+ select?: readonly (keyof F & string)[] | undefined;
115
+ expand?: readonly import("@gettersethya/mira-collection").RelationKeys<F>[] | undefined;
116
+ retryOptions?: import("@gettersethya/mira-client").RetryOptions;
117
+ }, "limit" | "cursor"> & {
118
+ limit?: number;
119
+ }) | undefined) => {
120
+ raw(): Promise<import("@gettersethya/mira-collection").WithExpand<F, readonly import("@gettersethya/mira-collection").RelationKeys<F>[]>[]>;
121
+ 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>;
122
+ } & {
123
+ queryKey: import("./_core.js").QueryKey;
124
+ queryOptions: ReturnType<FQ>;
125
+ };
126
+ create: () => import("@gettersethya/mira-client").ClientHandler<import("@gettersethya/mira-collection").InferRecord<F>, Omit<import("@gettersethya/mira-collection").InferMutationInput<F>, "emailVerified">> & {
127
+ mutationOptions: ReturnType<FM>;
128
+ };
129
+ update: () => {
130
+ raw(input: import("@gettersethya/mira-collection").UpdateInput<F, "base">): Promise<import("@gettersethya/mira-collection").InferRecord<F>>;
131
+ 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>;
132
+ } & {
133
+ mutationOptions: ReturnType<FM>;
134
+ };
135
+ delete: () => {
136
+ raw(input: string): Promise<void>;
137
+ toEffect(input: string): import("effect/Effect").Effect<void, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
138
+ } & {
139
+ mutationOptions: ReturnType<FM>;
140
+ };
141
+ authWithPassword?(): {
142
+ raw(input: {
143
+ email: string;
144
+ password: string;
145
+ }): Promise<{
146
+ token: string;
147
+ record: import("@gettersethya/mira-collection").InferRecord<F>;
148
+ }>;
149
+ toEffect(input: {
150
+ email: string;
151
+ password: string;
152
+ }): import("effect/Effect").Effect<{
153
+ token: string;
154
+ record: import("@gettersethya/mira-collection").InferRecord<F>;
155
+ }, import("@gettersethya/mira-client").MiraError, import("effect/http/HttpClient").HttpClient>;
156
+ };
157
+ fields: import("@gettersethya/mira-client").CollectionFileFields<F>;
158
+ };
159
+ export { ActionKeys };
160
+ export type { ActionKey } from "./_core.js";
161
+ //# sourceMappingURL=svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte.d.ts","sourceRoot":"","sources":["../src/svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,UAAU,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,6BAA6B,CAAC,EAAE,SAAS,gBAAgB,EAAE,EAAE,SAAS,mBAAmB,EACvG,gBAAgB,EAAE,EAAE,EACpB,mBAAmB,EAAE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGxB;AACD,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}