@nice-code/action 0.2.0 → 0.2.2

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 (36) hide show
  1. package/build/index.js +56 -47
  2. package/build/react-query/index.js +10 -9
  3. package/build/types/ActionDefinition/Action/Action.combined.types.d.ts +16 -6
  4. package/build/types/ActionDefinition/Action/ActionBase.d.ts +2 -2
  5. package/build/types/ActionDefinition/Action/ActionBase.types.d.ts +4 -4
  6. package/build/types/ActionDefinition/Action/Context/ActionContext.d.ts +6 -7
  7. package/build/types/ActionDefinition/Action/Context/ActionContext.types.d.ts +2 -2
  8. package/build/types/ActionDefinition/Action/Core/ActionCore.d.ts +6 -7
  9. package/build/types/ActionDefinition/Action/Core/ActionCore.types.d.ts +2 -2
  10. package/build/types/ActionDefinition/Action/Payload/ActionPayload.d.ts +1 -1
  11. package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +14 -13
  12. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Progress.d.ts +1 -1
  13. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +6 -6
  14. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +3 -3
  15. package/build/types/ActionDefinition/Action/RunningAction.d.ts +1 -1
  16. package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +20 -14
  17. package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +17 -10
  18. package/build/types/ActionDefinition/Domain/ActionDomain.types.d.ts +10 -7
  19. package/build/types/ActionDefinition/Domain/ActionDomainBase.d.ts +4 -4
  20. package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +1 -1
  21. package/build/types/ActionDefinition/Schema/ActionSchema.d.ts +7 -7
  22. package/build/types/ActionDefinition/Schema/ActionSchema.types.d.ts +4 -8
  23. package/build/types/ActionRuntime/ActionDomainManager.d.ts +1 -1
  24. package/build/types/ActionRuntime/ActionRuntime.d.ts +2 -7
  25. package/build/types/ActionRuntime/Handler/ActionHandler.d.ts +1 -1
  26. package/build/types/ActionRuntime/Handler/ActionHandler.types.d.ts +3 -6
  27. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +3 -3
  28. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.d.ts +4 -4
  29. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.types.d.ts +3 -2
  30. package/build/types/ActionRuntime/Routing/ActionRouter.d.ts +7 -7
  31. package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +60 -154
  32. package/build/types/errors/err_nice_action.d.ts +2 -2
  33. package/build/types/react-query/hooks/useActionMutation.d.ts +6 -0
  34. package/build/types/react-query/hooks/useActionQuery.d.ts +15 -0
  35. package/build/types/react-query/index.d.ts +2 -72
  36. package/package.json +1 -1
@@ -9,58 +9,39 @@ export declare function _test_createActions(): {
9
9
  test_dom_user: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
10
10
  domain: string;
11
11
  actions: {
12
- sign_in: import("../../..").ActionSchema<[{
12
+ sign_in: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
13
13
  username: string;
14
14
  password: string;
15
- }] | [{
16
- username: string;
17
- password: string;
18
- }, never], [{
15
+ }, any>, import("../../..").TTransportedValue<{
19
16
  success: boolean;
20
- }] | [{
21
- success: boolean;
22
- }, any], readonly []>;
17
+ }, any>, readonly []>;
23
18
  };
24
19
  }>>;
25
20
  test_dom_edit_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
26
21
  domain: string;
27
22
  actions: {
28
- edit_doc: import("../../..").ActionSchema<[{
23
+ edit_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
29
24
  docId: string;
30
25
  newContent: string;
31
- }] | [{
32
- docId: string;
33
- newContent: string;
34
- }, never], [{
35
- success: boolean;
36
- }] | [{
26
+ }, any>, import("../../..").TTransportedValue<{
37
27
  success: boolean;
38
- }, any], readonly []>;
39
- get_doc: import("../../..").ActionSchema<[{
40
- docId: string;
41
- }] | [{
28
+ }, any>, readonly []>;
29
+ get_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
42
30
  docId: string;
43
- }, never], [{
31
+ }, any>, import("../../..").TTransportedValue<{
44
32
  content: string;
45
- }] | [{
46
- content: string;
47
- }, any], readonly []>;
33
+ }, any>, readonly []>;
48
34
  };
49
35
  }>>;
50
36
  test_dom_push_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
51
37
  domain: string;
52
38
  actions: {
53
- push_doc_update: import("../../..").ActionSchema<[{
54
- docId: string;
55
- updateContent: string;
56
- }] | [{
39
+ push_doc_update: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
57
40
  docId: string;
58
41
  updateContent: string;
59
- }, never], [{
60
- updated: boolean;
61
- }] | [{
42
+ }, any>, import("../../..").TTransportedValue<{
62
43
  updated: boolean;
63
- }, any], readonly []>;
44
+ }, any>, readonly []>;
64
45
  };
65
46
  }>>;
66
47
  };
@@ -68,83 +49,55 @@ export declare function _test_createActions(): {
68
49
  action_user_sign_in: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
69
50
  domain: string;
70
51
  actions: {
71
- sign_in: import("../../..").ActionSchema<[{
52
+ sign_in: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
72
53
  username: string;
73
54
  password: string;
74
- }] | [{
75
- username: string;
76
- password: string;
77
- }, never], [{
78
- success: boolean;
79
- }] | [{
55
+ }, any>, import("../../..").TTransportedValue<{
80
56
  success: boolean;
81
- }, any], readonly []>;
57
+ }, any>, readonly []>;
82
58
  };
83
59
  }>, "sign_in">;
84
60
  action_edit_doc_edit: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
85
61
  domain: string;
86
62
  actions: {
87
- edit_doc: import("../../..").ActionSchema<[{
63
+ edit_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
88
64
  docId: string;
89
65
  newContent: string;
90
- }] | [{
91
- docId: string;
92
- newContent: string;
93
- }, never], [{
66
+ }, any>, import("../../..").TTransportedValue<{
94
67
  success: boolean;
95
- }] | [{
96
- success: boolean;
97
- }, any], readonly []>;
98
- get_doc: import("../../..").ActionSchema<[{
99
- docId: string;
100
- }] | [{
68
+ }, any>, readonly []>;
69
+ get_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
101
70
  docId: string;
102
- }, never], [{
71
+ }, any>, import("../../..").TTransportedValue<{
103
72
  content: string;
104
- }] | [{
105
- content: string;
106
- }, any], readonly []>;
73
+ }, any>, readonly []>;
107
74
  };
108
75
  }>, "edit_doc">;
109
76
  action_edit_doc_get: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
110
77
  domain: string;
111
78
  actions: {
112
- edit_doc: import("../../..").ActionSchema<[{
113
- docId: string;
114
- newContent: string;
115
- }] | [{
79
+ edit_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
116
80
  docId: string;
117
81
  newContent: string;
118
- }, never], [{
82
+ }, any>, import("../../..").TTransportedValue<{
119
83
  success: boolean;
120
- }] | [{
121
- success: boolean;
122
- }, any], readonly []>;
123
- get_doc: import("../../..").ActionSchema<[{
124
- docId: string;
125
- }] | [{
84
+ }, any>, readonly []>;
85
+ get_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
126
86
  docId: string;
127
- }, never], [{
128
- content: string;
129
- }] | [{
87
+ }, any>, import("../../..").TTransportedValue<{
130
88
  content: string;
131
- }, any], readonly []>;
89
+ }, any>, readonly []>;
132
90
  };
133
91
  }>, "get_doc">;
134
92
  action_push_doc_update: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
135
93
  domain: string;
136
94
  actions: {
137
- push_doc_update: import("../../..").ActionSchema<[{
95
+ push_doc_update: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
138
96
  docId: string;
139
97
  updateContent: string;
140
- }] | [{
141
- docId: string;
142
- updateContent: string;
143
- }, never], [{
144
- updated: boolean;
145
- }] | [{
98
+ }, any>, import("../../..").TTransportedValue<{
146
99
  updated: boolean;
147
- }, any], readonly []>;
100
+ }, any>, readonly []>;
148
101
  };
149
102
  }>, "push_doc_update">;
150
103
  };
@@ -155,58 +108,39 @@ export declare const _test_createTestActionRuntimeData: () => {
155
108
  test_dom_user: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
156
109
  domain: string;
157
110
  actions: {
158
- sign_in: import("../../..").ActionSchema<[{
111
+ sign_in: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
159
112
  username: string;
160
113
  password: string;
161
- }] | [{
162
- username: string;
163
- password: string;
164
- }, never], [{
114
+ }, any>, import("../../..").TTransportedValue<{
165
115
  success: boolean;
166
- }] | [{
167
- success: boolean;
168
- }, any], readonly []>;
116
+ }, any>, readonly []>;
169
117
  };
170
118
  }>>;
171
119
  test_dom_edit_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
172
120
  domain: string;
173
121
  actions: {
174
- edit_doc: import("../../..").ActionSchema<[{
122
+ edit_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
175
123
  docId: string;
176
124
  newContent: string;
177
- }] | [{
178
- docId: string;
179
- newContent: string;
180
- }, never], [{
181
- success: boolean;
182
- }] | [{
125
+ }, any>, import("../../..").TTransportedValue<{
183
126
  success: boolean;
184
- }, any], readonly []>;
185
- get_doc: import("../../..").ActionSchema<[{
186
- docId: string;
187
- }] | [{
127
+ }, any>, readonly []>;
128
+ get_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
188
129
  docId: string;
189
- }, never], [{
130
+ }, any>, import("../../..").TTransportedValue<{
190
131
  content: string;
191
- }] | [{
192
- content: string;
193
- }, any], readonly []>;
132
+ }, any>, readonly []>;
194
133
  };
195
134
  }>>;
196
135
  test_dom_push_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
197
136
  domain: string;
198
137
  actions: {
199
- push_doc_update: import("../../..").ActionSchema<[{
200
- docId: string;
201
- updateContent: string;
202
- }] | [{
138
+ push_doc_update: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
203
139
  docId: string;
204
140
  updateContent: string;
205
- }, never], [{
206
- updated: boolean;
207
- }] | [{
141
+ }, any>, import("../../..").TTransportedValue<{
208
142
  updated: boolean;
209
- }, any], readonly []>;
143
+ }, any>, readonly []>;
210
144
  };
211
145
  }>>;
212
146
  };
@@ -214,83 +148,55 @@ export declare const _test_createTestActionRuntimeData: () => {
214
148
  action_user_sign_in: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
215
149
  domain: string;
216
150
  actions: {
217
- sign_in: import("../../..").ActionSchema<[{
151
+ sign_in: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
218
152
  username: string;
219
153
  password: string;
220
- }] | [{
221
- username: string;
222
- password: string;
223
- }, never], [{
224
- success: boolean;
225
- }] | [{
154
+ }, any>, import("../../..").TTransportedValue<{
226
155
  success: boolean;
227
- }, any], readonly []>;
156
+ }, any>, readonly []>;
228
157
  };
229
158
  }>, "sign_in">;
230
159
  action_edit_doc_edit: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
231
160
  domain: string;
232
161
  actions: {
233
- edit_doc: import("../../..").ActionSchema<[{
162
+ edit_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
234
163
  docId: string;
235
164
  newContent: string;
236
- }] | [{
237
- docId: string;
238
- newContent: string;
239
- }, never], [{
165
+ }, any>, import("../../..").TTransportedValue<{
240
166
  success: boolean;
241
- }] | [{
242
- success: boolean;
243
- }, any], readonly []>;
244
- get_doc: import("../../..").ActionSchema<[{
245
- docId: string;
246
- }] | [{
167
+ }, any>, readonly []>;
168
+ get_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
247
169
  docId: string;
248
- }, never], [{
170
+ }, any>, import("../../..").TTransportedValue<{
249
171
  content: string;
250
- }] | [{
251
- content: string;
252
- }, any], readonly []>;
172
+ }, any>, readonly []>;
253
173
  };
254
174
  }>, "edit_doc">;
255
175
  action_edit_doc_get: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
256
176
  domain: string;
257
177
  actions: {
258
- edit_doc: import("../../..").ActionSchema<[{
259
- docId: string;
260
- newContent: string;
261
- }] | [{
178
+ edit_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
262
179
  docId: string;
263
180
  newContent: string;
264
- }, never], [{
181
+ }, any>, import("../../..").TTransportedValue<{
265
182
  success: boolean;
266
- }] | [{
267
- success: boolean;
268
- }, any], readonly []>;
269
- get_doc: import("../../..").ActionSchema<[{
270
- docId: string;
271
- }] | [{
183
+ }, any>, readonly []>;
184
+ get_doc: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
272
185
  docId: string;
273
- }, never], [{
274
- content: string;
275
- }] | [{
186
+ }, any>, import("../../..").TTransportedValue<{
276
187
  content: string;
277
- }, any], readonly []>;
188
+ }, any>, readonly []>;
278
189
  };
279
190
  }>, "get_doc">;
280
191
  action_push_doc_update: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
281
192
  domain: string;
282
193
  actions: {
283
- push_doc_update: import("../../..").ActionSchema<[{
194
+ push_doc_update: import("../../..").ActionSchema<import("../../..").TTransportedValue<{
284
195
  docId: string;
285
196
  updateContent: string;
286
- }] | [{
287
- docId: string;
288
- updateContent: string;
289
- }, never], [{
290
- updated: boolean;
291
- }] | [{
197
+ }, any>, import("../../..").TTransportedValue<{
292
198
  updated: boolean;
293
- }, any], readonly []>;
199
+ }, any>, readonly []>;
294
200
  };
295
201
  }>, "push_doc_update">;
296
202
  };
@@ -9,7 +9,7 @@ export declare enum EErrId_NiceAction {
9
9
  hydration_action_state_mismatch = "hydration_action_state_mismatch",
10
10
  hydration_action_id_not_found = "hydration_action_id_not_found",
11
11
  no_action_execution_handler = "no_action_execution_handler",
12
- wire_action_not_primed_or_response = "wire_action_not_primed_or_response",
12
+ wire_action_not_payload = "wire_action_not_payload",
13
13
  wire_not_action_data = "wire_not_action_data",
14
14
  client_runtime_already_registered = "client_runtime_already_registered",
15
15
  client_runtime_not_registered = "client_runtime_not_registered",
@@ -55,7 +55,7 @@ export declare const err_nice_action: import("@nice-code/error").NiceErrorDomain
55
55
  actionId: string;
56
56
  specifiedClient?: ActionClientSpecifier;
57
57
  }, import("@nice-code/error").JSONSerializableValue>;
58
- wire_action_not_primed_or_response: import("@nice-code/error").INiceErrorIdMetadata<{
58
+ wire_action_not_payload: import("@nice-code/error").INiceErrorIdMetadata<{
59
59
  domain: string;
60
60
  actionId: string;
61
61
  actionState: string | undefined;
@@ -0,0 +1,6 @@
1
+ import { type UseMutationOptions, type UseMutationResult } from "@tanstack/react-query";
2
+ import type { ActionCore } from "../../ActionDefinition/Action/Core/ActionCore";
3
+ import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../ActionDefinition/Domain/ActionDomain.types";
4
+ import type { TInferActionError } from "../../ActionDefinition/Schema/ActionSchema";
5
+ export type TUseNiceMutationOptions<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID] = DOM["actionSchema"][ID], TContext = unknown> = Omit<UseMutationOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TInferInputFromSchema<SCH>["Input"], TContext>, "mutationFn">;
6
+ export declare function useActionMutation<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID], TContext = unknown>(action: ActionCore<DOM, ID>, options?: TUseNiceMutationOptions<DOM, ID, SCH, TContext>): UseMutationResult<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TInferInputFromSchema<SCH>["Input"], TContext>;
@@ -0,0 +1,15 @@
1
+ import { type QueryKey, type UseQueryOptions, type UseQueryResult } from "@tanstack/react-query";
2
+ import type { ActionCore } from "../../ActionDefinition/Action/Core/ActionCore";
3
+ import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../ActionDefinition/Domain/ActionDomain.types";
4
+ import type { TInferActionError } from "../../ActionDefinition/Schema/ActionSchema";
5
+ export declare function niceActionQueryKey<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionCore<DOM, ID>): readonly ["nice-action", DOM["domain"], DOM["allDomains"], ID];
6
+ export declare function niceActionQueryKey<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionCore<DOM, ID>, input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]): readonly [
7
+ "nice-action",
8
+ DOM["domain"],
9
+ DOM["allDomains"],
10
+ ID,
11
+ TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"],
12
+ string | undefined
13
+ ];
14
+ export type TUseNiceQueryOptions<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID] = DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]> = Omit<UseQueryOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TSelect, QueryKey>, "queryKey" | "queryFn">;
15
+ export declare function useNiceQuery<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]>(action: ActionCore<DOM, ID>, input: TInferInputFromSchema<SCH>["Input"] | null | undefined, options?: TUseNiceQueryOptions<DOM, ID, SCH, TSelect>): UseQueryResult<TSelect, TInferActionError<SCH>>;
@@ -1,72 +1,2 @@
1
- import type { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
2
- import type { ActionCore } from "../ActionDefinition/Action/Core/ActionCore";
3
- import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../ActionDefinition/Domain/ActionDomain.types";
4
- import type { TInferActionError } from "../ActionDefinition/Schema/ActionSchema";
5
- /**
6
- * Builds a stable TanStack Query key for a Nice Action.
7
- *
8
- * Overload 1 (no input) — returns a prefix key suitable for `queryClient.invalidateQueries`,
9
- * which will match every cached query for this action regardless of input.
10
- *
11
- * Overload 2 (with input) — returns the exact key used by `useNiceQuery` for the given input.
12
- * Use this when you need to read or invalidate a single cached result.
13
- *
14
- * @example
15
- * // Invalidate all cached results for an action
16
- * queryClient.invalidateQueries({ queryKey: niceActionQueryKey(domain.action("getUser")) });
17
- *
18
- * // Invalidate a specific cached result
19
- * queryClient.invalidateQueries({ queryKey: niceActionQueryKey(domain.action("getUser"), { userId: "123" }) });
20
- */
21
- export declare function niceActionQueryKey<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string>(action: ActionCore<DOM, ID>): readonly ["nice-action", DOM["domain"], DOM["allDomains"], ID];
22
- export declare function niceActionQueryKey<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string>(action: ActionCore<DOM, ID>, input: TInferInputFromSchema<DOM["actions"][ID]>["Input"]): readonly [
23
- "nice-action",
24
- DOM["domain"],
25
- DOM["allDomains"],
26
- ID,
27
- TInferInputFromSchema<DOM["actions"][ID]>["Input"],
28
- string | undefined
29
- ];
30
- export type TUseNiceQueryOptions<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string, SCH extends DOM["actions"][ID] = DOM["actions"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]> = Omit<UseQueryOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TSelect, QueryKey>, "queryKey" | "queryFn">;
31
- export type TUseNiceMutationOptions<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string, SCH extends DOM["actions"][ID] = DOM["actions"][ID], TContext = unknown> = Omit<UseMutationOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TInferInputFromSchema<SCH>["Input"], TContext>, "mutationFn">;
32
- /**
33
- * Execute a Nice Action as a TanStack Query.
34
- *
35
- * Automatically constructs a stable query key from the action's domain, id, and input.
36
- * Passing `null` or `undefined` as `input` disables the query (sets `enabled: false`),
37
- * which allows conditional execution while respecting React's rules of hooks.
38
- *
39
- * The `tag` option targets a specific named handler registered on the runtime environment.
40
- *
41
- * Supports TanStack Query's `select` option with full type inference — if you pass a
42
- * `select` transformer, `data` will be typed as the transformer's return type.
43
- *
44
- * @example
45
- * const { data, isPending, error } = useNiceQuery(
46
- * domain.action("getUser"),
47
- * { userId: "123" },
48
- * );
49
- *
50
- * @example
51
- * // Conditionally enabled
52
- * const { data } = useNiceQuery(domain.action("getUser"), userId ? { userId } : null);
53
- */
54
- export declare function useNiceQuery<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string, SCH extends DOM["actions"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]>(action: ActionCore<DOM, ID>, input: TInferInputFromSchema<SCH>["Input"] | null | undefined, options?: TUseNiceQueryOptions<DOM, ID, SCH, TSelect>): UseQueryResult<TSelect, TInferActionError<SCH>>;
55
- /**
56
- * Execute a Nice Action as a TanStack Mutation.
57
- *
58
- * Ideal for actions that change server state — form submissions, updates, deletes, etc.
59
- * The input is provided at call time via `mutation.mutate(input)` or `mutation.mutateAsync(input)`.
60
- *
61
- * The `tag` option targets a specific named handler registered on the runtime environment.
62
- *
63
- * @example
64
- * const mutation = useNiceMutation(domain.action("createUser"));
65
- *
66
- * function handleSubmit(data: CreateUserInput) {
67
- * mutation.mutate(data, {
68
- * onSuccess: (user) => router.push(`/users/${user.id}`),
69
- * });
70
- * }
71
- */
72
- export declare function useNiceMutation<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string, SCH extends DOM["actions"][ID], TContext = unknown>(action: ActionCore<DOM, ID>, options?: TUseNiceMutationOptions<DOM, ID, SCH, TContext>): UseMutationResult<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TInferInputFromSchema<SCH>["Input"], TContext>;
1
+ export * from "./hooks/useActionMutation";
2
+ export * from "./hooks/useActionQuery";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-code/action",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {