@mdxui/do 2.1.1 → 4.0.0

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.
Files changed (75) hide show
  1. package/README.md +115 -323
  2. package/dist/{agents-xcIn2dUB.d.ts → agents-2_r9e9i7.d.ts} +213 -2
  3. package/dist/app/index.d.ts +347 -0
  4. package/dist/app/index.js +14 -0
  5. package/dist/app/index.js.map +1 -0
  6. package/dist/breadcrumbs-C9Qn3S7d.d.ts +81 -0
  7. package/dist/capnweb-client-Bq78FtEA.d.ts +229 -0
  8. package/dist/chunk-3XKYQRXY.js +192 -0
  9. package/dist/chunk-3XKYQRXY.js.map +1 -0
  10. package/dist/chunk-4KXVN3EQ.js +56 -0
  11. package/dist/chunk-4KXVN3EQ.js.map +1 -0
  12. package/dist/chunk-5SHZZC7L.js +234 -0
  13. package/dist/chunk-5SHZZC7L.js.map +1 -0
  14. package/dist/chunk-7UFINK3Q.js +1994 -0
  15. package/dist/chunk-7UFINK3Q.js.map +1 -0
  16. package/dist/chunk-JJLAES6W.js +76 -0
  17. package/dist/chunk-JJLAES6W.js.map +1 -0
  18. package/dist/chunk-KT52UU3U.js +985 -0
  19. package/dist/chunk-KT52UU3U.js.map +1 -0
  20. package/dist/chunk-LJIWB7KE.js +95 -0
  21. package/dist/chunk-LJIWB7KE.js.map +1 -0
  22. package/dist/chunk-NA652ART.js +596 -0
  23. package/dist/chunk-NA652ART.js.map +1 -0
  24. package/dist/chunk-OVLO7UOH.js +1071 -0
  25. package/dist/chunk-OVLO7UOH.js.map +1 -0
  26. package/dist/chunk-VRLUXCLD.js +31 -0
  27. package/dist/chunk-VRLUXCLD.js.map +1 -0
  28. package/dist/chunk-WMNT4OIE.js +249 -0
  29. package/dist/chunk-WMNT4OIE.js.map +1 -0
  30. package/dist/chunk-Y52IEYVM.js +131 -0
  31. package/dist/chunk-Y52IEYVM.js.map +1 -0
  32. package/dist/components/index.d.ts +14 -732
  33. package/dist/components/index.js +3 -6
  34. package/dist/config-CxvpD8Y6.d.ts +111 -0
  35. package/dist/{do-CaQVueZw.d.ts → do-D27i5bU0.d.ts} +32 -33
  36. package/dist/errors-DratdVIz.d.ts +346 -0
  37. package/dist/hooks/index.d.ts +450 -691
  38. package/dist/hooks/index.js +6 -4
  39. package/dist/hooks/things/index.d.ts +298 -0
  40. package/dist/hooks/things/index.js +8 -0
  41. package/dist/hooks/things/index.js.map +1 -0
  42. package/dist/index.d.ts +62 -989
  43. package/dist/index.js +12 -839
  44. package/dist/index.js.map +1 -1
  45. package/dist/lib/index.d.ts +798 -0
  46. package/dist/lib/index.js +6 -0
  47. package/dist/lib/index.js.map +1 -0
  48. package/dist/providers/index.d.ts +130 -34
  49. package/dist/providers/index.js +3 -2
  50. package/dist/query-keys-CZNFikIi.d.ts +153 -0
  51. package/dist/schemas/index.d.ts +5 -5
  52. package/dist/schemas/index.js +2 -2
  53. package/dist/schemas/index.js.map +1 -1
  54. package/dist/{thing-DtI25yZh.d.ts → thing-BF25aUtJ.d.ts} +72 -72
  55. package/dist/types/index.d.ts +693 -658
  56. package/dist/types/index.js +1 -2
  57. package/dist/views/index.d.ts +131 -0
  58. package/dist/views/index.js +11 -0
  59. package/dist/views/index.js.map +1 -0
  60. package/package.json +39 -17
  61. package/dist/__test-utils__/index.d.ts +0 -399
  62. package/dist/__test-utils__/index.js +0 -34641
  63. package/dist/__test-utils__/index.js.map +0 -1
  64. package/dist/chunk-EEDMN7UF.js +0 -1351
  65. package/dist/chunk-EEDMN7UF.js.map +0 -1
  66. package/dist/chunk-G3PMV62Z.js +0 -33
  67. package/dist/chunk-G3PMV62Z.js.map +0 -1
  68. package/dist/chunk-NXPXL5NA.js +0 -3789
  69. package/dist/chunk-NXPXL5NA.js.map +0 -1
  70. package/dist/chunk-PC5FJY6M.js +0 -20
  71. package/dist/chunk-PC5FJY6M.js.map +0 -1
  72. package/dist/chunk-XF6LKY2M.js +0 -445
  73. package/dist/chunk-XF6LKY2M.js.map +0 -1
  74. package/dist/magic-string.es-J7BYFTTJ.js +0 -1307
  75. package/dist/magic-string.es-J7BYFTTJ.js.map +0 -1
@@ -0,0 +1,234 @@
1
+ import { thingsKeys } from './chunk-4KXVN3EQ.js';
2
+ import { useDO, useDataProviderSafe } from './chunk-WMNT4OIE.js';
3
+ import { ThingFilterSchema, ThingSortSchema, ThingPaginationSchema, ThingCreateInputSchema, ThingUpdateInputSchema, ThingDeleteOptionsSchema } from './chunk-GGO5GW72.js';
4
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
5
+ import { useMemo } from 'react';
6
+ import { useDeepCompareMemo } from 'use-deep-compare';
7
+
8
+ function isThingParams(arg) {
9
+ return typeof arg === "object" && arg !== null && "ns" in arg && "type" in arg && "id" in arg && typeof arg.ns === "string" && typeof arg.type === "string" && typeof arg.id === "string";
10
+ }
11
+ function isTypeStatsParams(arg) {
12
+ return typeof arg === "object" && arg !== null && "ns" in arg && "type" in arg && typeof arg.ns === "string" && typeof arg.type === "string";
13
+ }
14
+ function useThings(filter = {}, sort, pagination) {
15
+ const { client, namespace } = useDO();
16
+ const queryKey = useDeepCompareMemo(
17
+ () => thingsKeys.list({ ...filter, ns: filter.ns ?? namespace }, sort, pagination),
18
+ [filter, namespace, sort, pagination]
19
+ );
20
+ const query = useQuery({
21
+ queryKey,
22
+ queryFn: async () => {
23
+ const validatedFilter = ThingFilterSchema.parse(filter);
24
+ const validatedSort = sort ? ThingSortSchema.parse(sort) : void 0;
25
+ const validatedPagination = pagination ? ThingPaginationSchema.parse(pagination) : void 0;
26
+ const result = await client.Thing.list({
27
+ filter: { ...validatedFilter, ns: validatedFilter.ns ?? namespace },
28
+ sort: validatedSort,
29
+ pagination: validatedPagination
30
+ });
31
+ return result;
32
+ }
33
+ });
34
+ return {
35
+ data: query.data ?? null,
36
+ isLoading: query.isLoading,
37
+ error: query.error,
38
+ refetch: query.refetch,
39
+ queryKey,
40
+ isRefetching: query.isRefetching,
41
+ isFetching: query.isFetching,
42
+ status: query.status
43
+ };
44
+ }
45
+ function useThing(nsOrParams, type, id) {
46
+ const ns = isThingParams(nsOrParams) ? nsOrParams.ns : nsOrParams;
47
+ const thingType = isThingParams(nsOrParams) ? nsOrParams.type : type;
48
+ const thingId = isThingParams(nsOrParams) ? nsOrParams.id : id;
49
+ const { client } = useDO();
50
+ const queryKey = useMemo(() => thingsKeys.detail(ns, thingType, thingId), [ns, thingType, thingId]);
51
+ const query = useQuery({
52
+ queryKey,
53
+ queryFn: async () => {
54
+ const result = await client.Thing.get({ ns, type: thingType, id: thingId });
55
+ return result;
56
+ },
57
+ enabled: Boolean(ns && thingType && thingId)
58
+ });
59
+ return {
60
+ data: query.data ?? null,
61
+ isLoading: query.isLoading,
62
+ error: query.error,
63
+ refetch: query.refetch,
64
+ queryKey,
65
+ isRefetching: query.isRefetching,
66
+ isFetching: query.isFetching,
67
+ status: query.status
68
+ };
69
+ }
70
+ function useThingVersions(nsOrParams, type, id) {
71
+ const ns = isThingParams(nsOrParams) ? nsOrParams.ns : nsOrParams;
72
+ const thingType = isThingParams(nsOrParams) ? nsOrParams.type : type;
73
+ const thingId = isThingParams(nsOrParams) ? nsOrParams.id : id;
74
+ const { client } = useDO();
75
+ const queryKey = useMemo(() => thingsKeys.versions(ns, thingType, thingId), [ns, thingType, thingId]);
76
+ const query = useQuery({
77
+ queryKey,
78
+ queryFn: async () => {
79
+ const result = await client.Thing.versions({ ns, type: thingType, id: thingId });
80
+ return result;
81
+ },
82
+ enabled: Boolean(ns && thingType && thingId)
83
+ });
84
+ return {
85
+ data: query.data ?? null,
86
+ isLoading: query.isLoading,
87
+ error: query.error,
88
+ refetch: query.refetch,
89
+ queryKey,
90
+ isRefetching: query.isRefetching,
91
+ isFetching: query.isFetching,
92
+ status: query.status
93
+ };
94
+ }
95
+ function useTypeStats(nsOrParams, type) {
96
+ const ns = isTypeStatsParams(nsOrParams) ? nsOrParams.ns : nsOrParams;
97
+ const thingType = isTypeStatsParams(nsOrParams) ? nsOrParams.type : type;
98
+ const { client } = useDO();
99
+ const queryKey = useMemo(() => thingsKeys.typeStats(ns, thingType), [ns, thingType]);
100
+ const query = useQuery({
101
+ queryKey,
102
+ queryFn: async () => {
103
+ const result = await client.Thing.stats({ ns, type: thingType });
104
+ return result;
105
+ },
106
+ enabled: Boolean(ns && thingType)
107
+ });
108
+ return {
109
+ data: query.data ?? null,
110
+ isLoading: query.isLoading,
111
+ error: query.error,
112
+ refetch: query.refetch,
113
+ queryKey,
114
+ isRefetching: query.isRefetching,
115
+ isFetching: query.isFetching,
116
+ status: query.status
117
+ };
118
+ }
119
+ function isThingParams2(arg) {
120
+ return typeof arg === "object" && arg !== null && "ns" in arg && "type" in arg && "id" in arg && typeof arg.ns === "string" && typeof arg.type === "string" && typeof arg.id === "string";
121
+ }
122
+ function useCreateThing() {
123
+ const { client, namespace } = useDO();
124
+ const queryClient = useQueryClient();
125
+ const dataProvider = useDataProviderSafe();
126
+ const mutation = useMutation({
127
+ mutationFn: async (input) => {
128
+ const validatedInput = ThingCreateInputSchema.parse(input);
129
+ if (dataProvider) {
130
+ const result2 = await dataProvider.create("Thing", {
131
+ data: {
132
+ type: validatedInput.type,
133
+ name: validatedInput.name,
134
+ data: validatedInput.data,
135
+ ns: validatedInput.ns ?? namespace,
136
+ variant: validatedInput.variant
137
+ }
138
+ });
139
+ return result2.data;
140
+ }
141
+ const result = await client.Thing.create(validatedInput);
142
+ return result;
143
+ },
144
+ onSuccess: () => {
145
+ queryClient.invalidateQueries({ queryKey: thingsKeys.all });
146
+ }
147
+ });
148
+ return {
149
+ mutate: mutation.mutate,
150
+ mutateAsync: mutation.mutateAsync,
151
+ isLoading: mutation.isPending,
152
+ error: mutation.error,
153
+ isSuccess: mutation.isSuccess,
154
+ reset: mutation.reset
155
+ };
156
+ }
157
+ function useUpdateThing(nsOrParams, type, id) {
158
+ const ns = isThingParams2(nsOrParams) ? nsOrParams.ns : nsOrParams;
159
+ const thingType = isThingParams2(nsOrParams) ? nsOrParams.type : type;
160
+ const thingId = isThingParams2(nsOrParams) ? nsOrParams.id : id;
161
+ const { client } = useDO();
162
+ const queryClient = useQueryClient();
163
+ const dataProvider = useDataProviderSafe();
164
+ const mutation = useMutation({
165
+ mutationFn: async (input) => {
166
+ const validatedInput = ThingUpdateInputSchema.parse(input);
167
+ if (dataProvider) {
168
+ const result2 = await dataProvider.update("Thing", {
169
+ id: thingId,
170
+ data: {
171
+ ...validatedInput,
172
+ ns,
173
+ type: thingType
174
+ }
175
+ });
176
+ return result2.data;
177
+ }
178
+ const result = await client.Thing.update({
179
+ ns,
180
+ type: thingType,
181
+ id: thingId,
182
+ ...validatedInput
183
+ });
184
+ return result;
185
+ },
186
+ onSuccess: (data) => {
187
+ queryClient.setQueryData(thingsKeys.detail(ns, thingType, thingId), data);
188
+ queryClient.invalidateQueries({ queryKey: thingsKeys.lists() });
189
+ }
190
+ });
191
+ return {
192
+ mutate: mutation.mutate,
193
+ mutateAsync: mutation.mutateAsync,
194
+ isLoading: mutation.isPending,
195
+ error: mutation.error,
196
+ isSuccess: mutation.isSuccess,
197
+ reset: mutation.reset
198
+ };
199
+ }
200
+ function useDeleteThing(nsOrParams, type, id) {
201
+ const ns = isThingParams2(nsOrParams) ? nsOrParams.ns : nsOrParams;
202
+ const thingType = isThingParams2(nsOrParams) ? nsOrParams.type : type;
203
+ const thingId = isThingParams2(nsOrParams) ? nsOrParams.id : id;
204
+ const { client } = useDO();
205
+ const queryClient = useQueryClient();
206
+ const dataProvider = useDataProviderSafe();
207
+ const mutation = useMutation({
208
+ mutationFn: async (options) => {
209
+ const validatedOptions = options ? ThingDeleteOptionsSchema.parse(options) : {};
210
+ const hard = validatedOptions.hard ?? false;
211
+ if (dataProvider && !hard) {
212
+ await dataProvider.delete("Thing", { id: thingId });
213
+ return;
214
+ }
215
+ await client.Thing.delete({ ns, type: thingType, id: thingId, hard });
216
+ },
217
+ onSuccess: () => {
218
+ queryClient.removeQueries({ queryKey: thingsKeys.detail(ns, thingType, thingId) });
219
+ queryClient.invalidateQueries({ queryKey: thingsKeys.lists() });
220
+ }
221
+ });
222
+ return {
223
+ mutate: mutation.mutate,
224
+ mutateAsync: mutation.mutateAsync,
225
+ isLoading: mutation.isPending,
226
+ error: mutation.error,
227
+ isSuccess: mutation.isSuccess,
228
+ reset: mutation.reset
229
+ };
230
+ }
231
+
232
+ export { useCreateThing, useDeleteThing, useThing, useThingVersions, useThings, useTypeStats, useUpdateThing };
233
+ //# sourceMappingURL=chunk-5SHZZC7L.js.map
234
+ //# sourceMappingURL=chunk-5SHZZC7L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/things/queries.ts","../src/hooks/things/mutations.ts"],"names":["isThingParams","result"],"mappings":";;;;;;;AA4CA,SAAS,cAAc,GAAA,EAAkC;AACvD,EAAA,OACE,OAAO,QAAQ,QAAA,IACf,GAAA,KAAQ,QACR,IAAA,IAAQ,GAAA,IACR,UAAU,GAAA,IACV,IAAA,IAAQ,OACR,OAAQ,GAAA,CAAoB,OAAO,QAAA,IACnC,OAAQ,IAAoB,IAAA,KAAS,QAAA,IACrC,OAAQ,GAAA,CAAoB,EAAA,KAAO,QAAA;AAEvC;AAKA,SAAS,kBAAkB,GAAA,EAAsC;AAC/D,EAAA,OACE,OAAO,GAAA,KAAQ,QAAA,IACf,GAAA,KAAQ,QACR,IAAA,IAAQ,GAAA,IACR,MAAA,IAAU,GAAA,IACV,OAAQ,GAAA,CAAwB,EAAA,KAAO,QAAA,IACvC,OAAQ,IAAwB,IAAA,KAAS,QAAA;AAE7C;AAOO,SAAS,SAAA,CACd,MAAA,GAAsB,EAAC,EACvB,MACA,UAAA,EACiB;AACjB,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAA,EAAU,GAAI,KAAA,EAAM;AAIpC,EAAA,MAAM,QAAA,GAAW,kBAAA;AAAA,IACf,MAAM,UAAA,CAAW,IAAA,CAAK,EAAE,GAAG,MAAA,EAAQ,EAAA,EAAI,MAAA,CAAO,EAAA,IAAM,SAAA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AAW,OAAO,CAAA,EAAG,CAAA;AAEjF,MAAA,WAAA,CAAY,kBAAkB,EAAE,QAAA,EAAU,UAAA,CAAW,KAAA,IAAS,CAAA;AAAA,IAChE;AAAA,GACD,CAAA;AAED,EAAA,OAAO;AAAA,IACL,QAAQ,QAAA,CAAS,MAAA;AAAA,IACjB,aAAa,QAAA,CAAS,WAAA;AAAA,IACtB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS,KAAA;AAAA,IAChB,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,OAAO,QAAA,CAAS;AAAA,GAClB;AACF","file":"chunk-5SHZZC7L.js","sourcesContent":["'use client'\n\n/**\n * Query hooks for Things\n *\n * Provides reactive data access to Things via React Query + @dotdo/client RPC.\n * Automatic caching, background refetching, and cache invalidation.\n */\n\nimport { useQuery } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport { useDeepCompareMemo } from 'use-deep-compare'\nimport { useDO } from '../../providers/do-provider'\nimport { thingsKeys } from '../../lib/query-keys'\nimport type {\n Thing,\n ThingFilter,\n ThingSort,\n ThingPagination,\n ThingQueryResult,\n ThingVersion,\n TypeStats,\n} from '../../types'\nimport {\n ThingFilterSchema,\n ThingSortSchema,\n ThingPaginationSchema,\n} from '../../types/schemas'\nimport type {\n UseThingsResult,\n UseThingResult,\n UseThingVersionsResult,\n UseTypeStatsResult,\n ThingParams,\n TypeStatsParams,\n} from './types'\n\n// ============================================================================\n// Helper to detect object-based API usage\n// ============================================================================\n\n/**\n * Type guard to check if argument is a ThingParams object\n */\nfunction isThingParams(arg: unknown): arg is ThingParams {\n return (\n typeof arg === 'object' &&\n arg !== null &&\n 'ns' in arg &&\n 'type' in arg &&\n 'id' in arg &&\n typeof (arg as ThingParams).ns === 'string' &&\n typeof (arg as ThingParams).type === 'string' &&\n typeof (arg as ThingParams).id === 'string'\n )\n}\n\n/**\n * Type guard to check if argument is a TypeStatsParams object\n */\nfunction isTypeStatsParams(arg: unknown): arg is TypeStatsParams {\n return (\n typeof arg === 'object' &&\n arg !== null &&\n 'ns' in arg &&\n 'type' in arg &&\n typeof (arg as TypeStatsParams).ns === 'string' &&\n typeof (arg as TypeStatsParams).type === 'string'\n )\n}\n\n/**\n * Hook to fetch a list of Things\n *\n * Uses React Query for caching with @dotdo/client RPC for data fetching.\n */\nexport function useThings(\n filter: ThingFilter = {},\n sort?: ThingSort,\n pagination?: ThingPagination\n): UseThingsResult {\n const { client, namespace } = useDO()\n\n // Build query key with merged namespace\n // Use deep comparison for object dependencies to avoid unnecessary recomputations\n const queryKey = useDeepCompareMemo(\n () => thingsKeys.list({ ...filter, ns: filter.ns ?? namespace }, sort, pagination),\n [filter, namespace, sort, pagination]\n )\n\n const query = useQuery({\n queryKey,\n queryFn: async () => {\n // Validate inputs before API call\n const validatedFilter = ThingFilterSchema.parse(filter)\n const validatedSort = sort ? ThingSortSchema.parse(sort) : undefined\n const validatedPagination = pagination ? ThingPaginationSchema.parse(pagination) : undefined\n\n // Use @dotdo/client RPC for data fetching\n const result = await (client as any).Thing.list({\n filter: { ...validatedFilter, ns: validatedFilter.ns ?? namespace },\n sort: validatedSort,\n pagination: validatedPagination,\n })\n return result as ThingQueryResult\n },\n })\n\n return {\n data: query.data ?? null,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n queryKey,\n isRefetching: query.isRefetching,\n isFetching: query.isFetching,\n status: query.status,\n }\n}\n\n/**\n * Hook to fetch a single Thing\n *\n * Uses React Query for caching with @dotdo/client RPC calls.\n *\n * @example Object-based API (preferred)\n * ```tsx\n * const { data } = useThing({ ns: 'default', type: 'Task', id: 'task-123' })\n * ```\n *\n * @example Positional API (deprecated)\n * ```tsx\n * const { data } = useThing('default', 'Task', 'task-123')\n * ```\n */\nexport function useThing(params: ThingParams): UseThingResult\n/**\n * @deprecated Use object-based API: `useThing({ ns, type, id })` instead\n */\nexport function useThing(ns: string, type: string, id: string): UseThingResult\nexport function useThing(\n nsOrParams: string | ThingParams,\n type?: string,\n id?: string\n): UseThingResult {\n // Normalize parameters - support both object and positional APIs\n const ns = isThingParams(nsOrParams) ? nsOrParams.ns : nsOrParams\n const thingType = isThingParams(nsOrParams) ? nsOrParams.type : type!\n const thingId = isThingParams(nsOrParams) ? nsOrParams.id : id!\n\n const { client } = useDO()\n\n const queryKey = useMemo(() => thingsKeys.detail(ns, thingType, thingId), [ns, thingType, thingId])\n\n const query = useQuery({\n queryKey,\n queryFn: async () => {\n const result = await (client as any).Thing.get({ ns, type: thingType, id: thingId })\n return result as Thing\n },\n enabled: Boolean(ns && thingType && thingId),\n })\n\n return {\n data: query.data ?? null,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n queryKey,\n isRefetching: query.isRefetching,\n isFetching: query.isFetching,\n status: query.status,\n }\n}\n\n/**\n * Hook to fetch Thing version history\n *\n * @example Object-based API (preferred)\n * ```tsx\n * const { data } = useThingVersions({ ns: 'default', type: 'Task', id: 'task-123' })\n * ```\n *\n * @example Positional API (deprecated)\n * ```tsx\n * const { data } = useThingVersions('default', 'Task', 'task-123')\n * ```\n */\nexport function useThingVersions(params: ThingParams): UseThingVersionsResult\n/**\n * @deprecated Use object-based API: `useThingVersions({ ns, type, id })` instead\n */\nexport function useThingVersions(ns: string, type: string, id: string): UseThingVersionsResult\nexport function useThingVersions(\n nsOrParams: string | ThingParams,\n type?: string,\n id?: string\n): UseThingVersionsResult {\n // Normalize parameters - support both object and positional APIs\n const ns = isThingParams(nsOrParams) ? nsOrParams.ns : nsOrParams\n const thingType = isThingParams(nsOrParams) ? nsOrParams.type : type!\n const thingId = isThingParams(nsOrParams) ? nsOrParams.id : id!\n\n const { client } = useDO()\n\n const queryKey = useMemo(() => thingsKeys.versions(ns, thingType, thingId), [ns, thingType, thingId])\n\n const query = useQuery({\n queryKey,\n queryFn: async () => {\n const result = await (client as any).Thing.versions({ ns, type: thingType, id: thingId })\n return result as ThingVersion[]\n },\n enabled: Boolean(ns && thingType && thingId),\n })\n\n return {\n data: query.data ?? null,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n queryKey,\n isRefetching: query.isRefetching,\n isFetching: query.isFetching,\n status: query.status,\n }\n}\n\n/**\n * Hook to fetch type statistics\n *\n * @example Object-based API (preferred)\n * ```tsx\n * const { data } = useTypeStats({ ns: 'default', type: 'Task' })\n * ```\n *\n * @example Positional API (deprecated)\n * ```tsx\n * const { data } = useTypeStats('default', 'Task')\n * ```\n */\nexport function useTypeStats(params: TypeStatsParams): UseTypeStatsResult\n/**\n * @deprecated Use object-based API: `useTypeStats({ ns, type })` instead\n */\nexport function useTypeStats(ns: string, type: string): UseTypeStatsResult\nexport function useTypeStats(\n nsOrParams: string | TypeStatsParams,\n type?: string\n): UseTypeStatsResult {\n // Normalize parameters - support both object and positional APIs\n const ns = isTypeStatsParams(nsOrParams) ? nsOrParams.ns : nsOrParams\n const thingType = isTypeStatsParams(nsOrParams) ? nsOrParams.type : type!\n\n const { client } = useDO()\n\n const queryKey = useMemo(() => thingsKeys.typeStats(ns, thingType), [ns, thingType])\n\n const query = useQuery({\n queryKey,\n queryFn: async () => {\n const result = await (client as any).Thing.stats({ ns, type: thingType })\n return result as TypeStats\n },\n enabled: Boolean(ns && thingType),\n })\n\n return {\n data: query.data ?? null,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n queryKey,\n isRefetching: query.isRefetching,\n isFetching: query.isFetching,\n status: query.status,\n }\n}\n","'use client'\n\n/**\n * Mutation hooks for Things\n *\n * Provides create, update, and delete operations with automatic cache invalidation.\n * Uses @dotdo/client RPC for backend communication.\n */\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useDO, useDataProviderSafe } from '../../providers/do-provider'\nimport { thingsKeys } from '../../lib/query-keys'\nimport type { Thing, ThingCreateInput, ThingUpdateInput } from '../../types'\nimport {\n ThingCreateInputSchema,\n ThingUpdateInputSchema,\n ThingDeleteOptionsSchema,\n} from '../../types/schemas'\nimport type {\n UseCreateThingResult,\n UseUpdateThingResult,\n UseDeleteThingResult,\n ThingParams,\n} from './types'\n\n// ============================================================================\n// Helper to detect object-based API usage\n// ============================================================================\n\n/**\n * Type guard to check if argument is a ThingParams object\n */\nfunction isThingParams(arg: unknown): arg is ThingParams {\n return (\n typeof arg === 'object' &&\n arg !== null &&\n 'ns' in arg &&\n 'type' in arg &&\n 'id' in arg &&\n typeof (arg as ThingParams).ns === 'string' &&\n typeof (arg as ThingParams).type === 'string' &&\n typeof (arg as ThingParams).id === 'string'\n )\n}\n\n/**\n * Hook to create a Thing\n *\n * Automatically invalidates the things list cache on success.\n *\n * Supports two modes:\n * 1. **DataProvider mode**: Uses DataProvider.create() when available (via DoDataProviderProvider)\n * 2. **RPC mode**: Uses @dotdo/client for backend communication\n */\nexport function useCreateThing(): UseCreateThingResult {\n const { client, namespace } = useDO()\n const queryClient = useQueryClient()\n const dataProvider = useDataProviderSafe()\n\n const mutation = useMutation({\n mutationFn: async (input: ThingCreateInput): Promise<Thing> => {\n // Validate input before API call\n const validatedInput = ThingCreateInputSchema.parse(input)\n\n // Priority 1: Use DataProvider if available\n if (dataProvider) {\n const result = await dataProvider.create<Thing>('Thing', {\n data: {\n type: validatedInput.type,\n name: validatedInput.name,\n data: validatedInput.data,\n ns: validatedInput.ns ?? namespace,\n variant: validatedInput.variant,\n },\n })\n return result.data\n }\n\n // Priority 2: Use @dotdo/client RPC\n // The client is a dynamic proxy - we can call any method\n const result = await (client as any).Thing.create(validatedInput)\n return result as Thing\n },\n onSuccess: () => {\n // Invalidate all things queries to refetch\n queryClient.invalidateQueries({ queryKey: thingsKeys.all })\n },\n })\n\n return {\n mutate: mutation.mutate,\n mutateAsync: mutation.mutateAsync,\n isLoading: mutation.isPending,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n }\n}\n\n/**\n * Hook to update a Thing\n *\n * Automatically invalidates the related cache entries on success.\n *\n * @example Object-based API (preferred)\n * ```tsx\n * const updateThing = useUpdateThing({ ns: 'default', type: 'Task', id: 'task-123' })\n * updateThing.mutate({ name: 'Updated Task' })\n * ```\n */\nexport function useUpdateThing(params: ThingParams): UseUpdateThingResult\n/**\n * @deprecated Use object-based API: `useUpdateThing({ ns, type, id })` instead\n */\nexport function useUpdateThing(ns: string, type: string, id: string): UseUpdateThingResult\nexport function useUpdateThing(\n nsOrParams: string | ThingParams,\n type?: string,\n id?: string\n): UseUpdateThingResult {\n // Normalize parameters - support both object and positional APIs\n const ns = isThingParams(nsOrParams) ? nsOrParams.ns : nsOrParams\n const thingType = isThingParams(nsOrParams) ? nsOrParams.type : type!\n const thingId = isThingParams(nsOrParams) ? nsOrParams.id : id!\n\n const { client } = useDO()\n const queryClient = useQueryClient()\n const dataProvider = useDataProviderSafe()\n\n const mutation = useMutation({\n mutationFn: async (input: ThingUpdateInput): Promise<Thing> => {\n // Validate input before API call\n const validatedInput = ThingUpdateInputSchema.parse(input)\n\n // Priority 1: Use DataProvider if available\n if (dataProvider) {\n const result = await dataProvider.update<Thing>('Thing', {\n id: thingId,\n data: {\n ...validatedInput,\n ns,\n type: thingType,\n },\n })\n return result.data\n }\n\n // Priority 2: Use @dotdo/client RPC\n const result = await (client as any).Thing.update({\n ns,\n type: thingType,\n id: thingId,\n ...validatedInput,\n })\n return result as Thing\n },\n onSuccess: (data) => {\n // Update the cache for this specific thing\n queryClient.setQueryData(thingsKeys.detail(ns, thingType, thingId), data)\n // Invalidate list queries\n queryClient.invalidateQueries({ queryKey: thingsKeys.lists() })\n },\n })\n\n return {\n mutate: mutation.mutate,\n mutateAsync: mutation.mutateAsync,\n isLoading: mutation.isPending,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n }\n}\n\n/**\n * Hook to delete a Thing (soft delete by default)\n *\n * Automatically invalidates the related cache entries on success.\n *\n * @example Object-based API (preferred)\n * ```tsx\n * const deleteThing = useDeleteThing({ ns: 'default', type: 'Task', id: 'task-123' })\n * deleteThing.mutate() // soft delete\n * deleteThing.mutate({ hard: true }) // hard delete\n * ```\n */\nexport function useDeleteThing(params: ThingParams): UseDeleteThingResult\n/**\n * @deprecated Use object-based API: `useDeleteThing({ ns, type, id })` instead\n */\nexport function useDeleteThing(ns: string, type: string, id: string): UseDeleteThingResult\nexport function useDeleteThing(\n nsOrParams: string | ThingParams,\n type?: string,\n id?: string\n): UseDeleteThingResult {\n // Normalize parameters - support both object and positional APIs\n const ns = isThingParams(nsOrParams) ? nsOrParams.ns : nsOrParams\n const thingType = isThingParams(nsOrParams) ? nsOrParams.type : type!\n const thingId = isThingParams(nsOrParams) ? nsOrParams.id : id!\n\n const { client } = useDO()\n const queryClient = useQueryClient()\n const dataProvider = useDataProviderSafe()\n\n const mutation = useMutation({\n mutationFn: async (options?: { hard?: boolean }): Promise<void> => {\n // Validate options before API call\n const validatedOptions = options ? ThingDeleteOptionsSchema.parse(options) : {}\n const hard = validatedOptions.hard ?? false\n\n // Priority 1: Use DataProvider if available (soft delete only)\n if (dataProvider && !hard) {\n await dataProvider.delete('Thing', { id: thingId })\n return\n }\n\n // Priority 2: Use @dotdo/client RPC\n await (client as any).Thing.delete({ ns, type: thingType, id: thingId, hard })\n },\n onSuccess: () => {\n // Remove from cache\n queryClient.removeQueries({ queryKey: thingsKeys.detail(ns, thingType, thingId) })\n // Invalidate list queries\n queryClient.invalidateQueries({ queryKey: thingsKeys.lists() })\n },\n })\n\n return {\n mutate: mutation.mutate,\n mutateAsync: mutation.mutateAsync,\n isLoading: mutation.isPending,\n error: mutation.error,\n isSuccess: mutation.isSuccess,\n reset: mutation.reset,\n }\n}\n"]}