@sylphx/lens-react 2.6.1 → 2.6.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.
package/dist/index.d.ts CHANGED
@@ -19,8 +19,8 @@ interface QueryHookOptions<
19
19
  TInput,
20
20
  TOutput = unknown
21
21
  > {
22
- /** Query input parameters */
23
- input?: TInput;
22
+ /** Query args parameters */
23
+ args?: TInput;
24
24
  /** Field selection */
25
25
  select?: SelectionObject;
26
26
  /** Skip query execution */
@@ -58,7 +58,7 @@ interface MutationHookResult<
58
58
  > {
59
59
  /** Execute the mutation */
60
60
  mutate: (options: {
61
- input: TInput;
61
+ args: TInput;
62
62
  select?: SelectionObject;
63
63
  }) => Promise<TOutput>;
64
64
  /** Mutation is in progress */
@@ -77,7 +77,7 @@ interface QueryEndpoint<
77
77
  > {
78
78
  /** Vanilla JS call - returns QueryResult (Promise + Observable) */
79
79
  (options?: {
80
- input?: TInput;
80
+ args?: TInput;
81
81
  select?: SelectionObject;
82
82
  }): QueryResult<TOutput>;
83
83
  /** React hook for reactive queries */
@@ -90,7 +90,7 @@ interface MutationEndpoint<
90
90
  > {
91
91
  /** Vanilla JS call - returns Promise */
92
92
  (options: {
93
- input: TInput;
93
+ args: TInput;
94
94
  select?: SelectionObject;
95
95
  }): Promise<{
96
96
  data: TOutput;
@@ -120,17 +120,17 @@ type TypedClient<TRouter extends RouterDef> = TRouter extends RouterDef<infer TR
120
120
  * });
121
121
  *
122
122
  * // Vanilla JS (anywhere)
123
- * const user = await client.user.get({ input: { id } });
123
+ * const user = await client.user.get({ args: { id } });
124
124
  *
125
125
  * // React component
126
126
  * function UserProfile({ id }: { id: string }) {
127
- * const { data, loading } = client.user.get.useQuery({ input: { id } });
127
+ * const { data, loading } = client.user.get.useQuery({ args: { id } });
128
128
  * const { mutate } = client.user.update.useMutation();
129
129
  *
130
130
  * return (
131
131
  * <div>
132
132
  * <h1>{data?.name}</h1>
133
- * <button onClick={() => mutate({ input: { id, name: 'New' } })}>
133
+ * <button onClick={() => mutate({ args: { id, name: 'New' } })}>
134
134
  * Update
135
135
  * </button>
136
136
  * </div>
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ function queryReducer(state, action) {
21
21
  }
22
22
  function createUseQueryHook(getEndpoint) {
23
23
  return function useQuery(options) {
24
- const inputKey = JSON.stringify(options?.input);
24
+ const argsKey = JSON.stringify(options?.args);
25
25
  const selectKey = JSON.stringify(options?.select);
26
26
  const debugRef = useRef(options?.debug);
27
27
  debugRef.current = options?.debug;
@@ -29,8 +29,8 @@ function createUseQueryHook(getEndpoint) {
29
29
  if (options?.skip)
30
30
  return null;
31
31
  const endpoint = getEndpoint();
32
- return endpoint({ input: options?.input, select: options?.select });
33
- }, [inputKey, selectKey, options?.skip]);
32
+ return endpoint({ args: options?.args, select: options?.select });
33
+ }, [argsKey, selectKey, options?.skip]);
34
34
  const initialState = {
35
35
  data: null,
36
36
  loading: query != null && !options?.skip,
@@ -118,7 +118,7 @@ function createUseMutationHook(getEndpoint) {
118
118
  setError(null);
119
119
  try {
120
120
  const endpoint = getEndpoint();
121
- const result = await endpoint({ input: options.input, select: options.select });
121
+ const result = await endpoint({ args: options.args, select: options.select });
122
122
  if (mountedRef.current) {
123
123
  setData(result.data);
124
124
  setLoading(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphx/lens-react",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "React bindings for Lens API framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "author": "SylphxAI",
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@sylphx/lens-client": "^3.1.1",
33
+ "@sylphx/lens-client": "^3.1.2",
34
34
  "@sylphx/lens-core": "^4.1.1"
35
35
  },
36
36
  "peerDependencies": {
package/src/create.tsx CHANGED
@@ -16,11 +16,11 @@
16
16
  * });
17
17
  *
18
18
  * // Vanilla JS (anywhere - SSR, utilities, event handlers)
19
- * const user = await client.user.get({ input: { id } });
20
- * client.user.get({ input: { id } }).subscribe(data => console.log(data));
19
+ * const user = await client.user.get({ args: { id } });
20
+ * client.user.get({ args: { id } }).subscribe(data => console.log(data));
21
21
  *
22
22
  * // React hooks (in components)
23
- * const { data, loading } = client.user.get.useQuery({ input: { id } });
23
+ * const { data, loading } = client.user.get.useQuery({ args: { id } });
24
24
  * const { mutate, loading } = client.user.create.useMutation();
25
25
  * ```
26
26
  */
@@ -56,8 +56,8 @@ export interface QueryDebugOptions<T> {
56
56
 
57
57
  /** Query hook options */
58
58
  export interface QueryHookOptions<TInput, TOutput = unknown> {
59
- /** Query input parameters */
60
- input?: TInput;
59
+ /** Query args parameters */
60
+ args?: TInput;
61
61
  /** Field selection */
62
62
  select?: SelectionObject;
63
63
  /** Skip query execution */
@@ -94,7 +94,7 @@ export interface MutationHookOptions<TOutput> {
94
94
  /** Mutation hook result */
95
95
  export interface MutationHookResult<TInput, TOutput> {
96
96
  /** Execute the mutation */
97
- mutate: (options: { input: TInput; select?: SelectionObject }) => Promise<TOutput>;
97
+ mutate: (options: { args: TInput; select?: SelectionObject }) => Promise<TOutput>;
98
98
  /** Mutation is in progress */
99
99
  loading: boolean;
100
100
  /** Mutation error */
@@ -108,7 +108,7 @@ export interface MutationHookResult<TInput, TOutput> {
108
108
  /** Query endpoint with React hooks */
109
109
  export interface QueryEndpoint<TInput, TOutput> {
110
110
  /** Vanilla JS call - returns QueryResult (Promise + Observable) */
111
- (options?: { input?: TInput; select?: SelectionObject }): QueryResult<TOutput>;
111
+ (options?: { args?: TInput; select?: SelectionObject }): QueryResult<TOutput>;
112
112
 
113
113
  /** React hook for reactive queries */
114
114
  useQuery: (
@@ -121,7 +121,7 @@ export interface QueryEndpoint<TInput, TOutput> {
121
121
  /** Mutation endpoint with React hooks */
122
122
  export interface MutationEndpoint<TInput, TOutput> {
123
123
  /** Vanilla JS call - returns Promise */
124
- (options: { input: TInput; select?: SelectionObject }): Promise<{ data: TOutput }>;
124
+ (options: { args: TInput; select?: SelectionObject }): Promise<{ data: TOutput }>;
125
125
 
126
126
  /** React hook for mutations */
127
127
  useMutation: (options?: MutationHookOptions<TOutput>) => MutationHookResult<TInput, TOutput>;
@@ -188,8 +188,8 @@ function createUseQueryHook<TInput, TOutput>(
188
188
  ) {
189
189
  return function useQuery(options?: QueryHookOptions<TInput, TOutput>): QueryHookResult<TOutput> {
190
190
  // Use JSON.stringify for stable dependency comparison
191
- // This prevents re-fetching when input object reference changes but content is the same
192
- const inputKey = JSON.stringify(options?.input);
191
+ // This prevents re-fetching when args object reference changes but content is the same
192
+ const argsKey = JSON.stringify(options?.args);
193
193
  const selectKey = JSON.stringify(options?.select);
194
194
 
195
195
  // Store debug callbacks in ref to avoid dependency issues
@@ -197,12 +197,12 @@ function createUseQueryHook<TInput, TOutput>(
197
197
  debugRef.current = options?.debug;
198
198
 
199
199
  // Get query result from base client
200
- // biome-ignore lint/correctness/useExhaustiveDependencies: Using JSON.stringify keys (inputKey, selectKey) for stable comparison instead of object references
200
+ // biome-ignore lint/correctness/useExhaustiveDependencies: Using JSON.stringify keys (argsKey, selectKey) for stable comparison instead of object references
201
201
  const query = useMemo(() => {
202
202
  if (options?.skip) return null;
203
203
  const endpoint = getEndpoint();
204
- return endpoint({ input: options?.input, select: options?.select });
205
- }, [inputKey, selectKey, options?.skip]);
204
+ return endpoint({ args: options?.args, select: options?.select });
205
+ }, [argsKey, selectKey, options?.skip]);
206
206
 
207
207
  // State management
208
208
  const initialState: QueryState<TOutput> = {
@@ -319,13 +319,13 @@ function createUseMutationHook<TInput, TOutput>(
319
319
  }, []);
320
320
 
321
321
  const mutate = useCallback(
322
- async (options: { input: TInput; select?: SelectionObject }): Promise<TOutput> => {
322
+ async (options: { args: TInput; select?: SelectionObject }): Promise<TOutput> => {
323
323
  setLoading(true);
324
324
  setError(null);
325
325
 
326
326
  try {
327
327
  const endpoint = getEndpoint();
328
- const result = await endpoint({ input: options.input, select: options.select });
328
+ const result = await endpoint({ args: options.args, select: options.select });
329
329
 
330
330
  if (mountedRef.current) {
331
331
  setData(result.data);
@@ -388,17 +388,17 @@ const hookCache = new Map<string, unknown>();
388
388
  * });
389
389
  *
390
390
  * // Vanilla JS (anywhere)
391
- * const user = await client.user.get({ input: { id } });
391
+ * const user = await client.user.get({ args: { id } });
392
392
  *
393
393
  * // React component
394
394
  * function UserProfile({ id }: { id: string }) {
395
- * const { data, loading } = client.user.get.useQuery({ input: { id } });
395
+ * const { data, loading } = client.user.get.useQuery({ args: { id } });
396
396
  * const { mutate } = client.user.update.useMutation();
397
397
  *
398
398
  * return (
399
399
  * <div>
400
400
  * <h1>{data?.name}</h1>
401
- * <button onClick={() => mutate({ input: { id, name: 'New' } })}>
401
+ * <button onClick={() => mutate({ args: { id, name: 'New' } })}>
402
402
  * Update
403
403
  * </button>
404
404
  * </div>
package/src/index.ts CHANGED
@@ -16,11 +16,11 @@
16
16
  * });
17
17
  *
18
18
  * // Vanilla JS (anywhere - SSR, utilities, event handlers)
19
- * const user = await client.user.get({ input: { id } });
20
- * client.user.get({ input: { id } }).subscribe(data => console.log(data));
19
+ * const user = await client.user.get({ args: { id } });
20
+ * client.user.get({ args: { id } }).subscribe(data => console.log(data));
21
21
  *
22
22
  * // React hooks (in components)
23
- * const { data, loading } = client.user.get.useQuery({ input: { id } });
23
+ * const { data, loading } = client.user.get.useQuery({ args: { id } });
24
24
  * const { mutate, loading } = client.user.create.useMutation();
25
25
  * ```
26
26
  */