@sylphx/lens-solid 2.4.0 → 2.4.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/create.d.ts +11 -11
- package/dist/create.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +13 -13
- package/package.json +3 -3
- package/src/create.ts +16 -16
- package/src/index.ts +3 -3
package/dist/create.d.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({
|
|
20
|
-
* client.user.get({
|
|
19
|
+
* const user = await client.user.get({ args: { id } });
|
|
20
|
+
* client.user.get({ args: { id } }).subscribe(data => console.log(data));
|
|
21
21
|
*
|
|
22
22
|
* // SolidJS primitives (in components)
|
|
23
|
-
* const { data, loading } = client.user.get.createQuery({
|
|
23
|
+
* const { data, loading } = client.user.get.createQuery({ args: { id } });
|
|
24
24
|
* const { mutate, loading } = client.user.create.createMutation();
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
@@ -43,8 +43,8 @@ export interface QueryDebugOptions<T> {
|
|
|
43
43
|
}
|
|
44
44
|
/** Query primitive options */
|
|
45
45
|
export interface QueryPrimitiveOptions<TInput, TOutput = unknown> {
|
|
46
|
-
/** Query
|
|
47
|
-
|
|
46
|
+
/** Query args parameters */
|
|
47
|
+
args?: TInput;
|
|
48
48
|
/** Field selection */
|
|
49
49
|
select?: SelectionObject;
|
|
50
50
|
/** Skip query execution */
|
|
@@ -79,7 +79,7 @@ export interface MutationPrimitiveOptions<TOutput> {
|
|
|
79
79
|
export interface MutationPrimitiveResult<TInput, TOutput> {
|
|
80
80
|
/** Execute the mutation */
|
|
81
81
|
mutate: (options: {
|
|
82
|
-
|
|
82
|
+
args: TInput;
|
|
83
83
|
select?: SelectionObject;
|
|
84
84
|
}) => Promise<TOutput>;
|
|
85
85
|
/** Reactive loading state */
|
|
@@ -95,7 +95,7 @@ export interface MutationPrimitiveResult<TInput, TOutput> {
|
|
|
95
95
|
export interface QueryEndpoint<TInput, TOutput> {
|
|
96
96
|
/** Vanilla JS call - returns QueryResult (Promise + Observable) */
|
|
97
97
|
(options?: {
|
|
98
|
-
|
|
98
|
+
args?: TInput;
|
|
99
99
|
select?: SelectionObject;
|
|
100
100
|
}): QueryResult<TOutput>;
|
|
101
101
|
/** SolidJS primitive for reactive queries */
|
|
@@ -105,7 +105,7 @@ export interface QueryEndpoint<TInput, TOutput> {
|
|
|
105
105
|
export interface MutationEndpoint<TInput, TOutput> {
|
|
106
106
|
/** Vanilla JS call - returns Promise */
|
|
107
107
|
(options: {
|
|
108
|
-
|
|
108
|
+
args: TInput;
|
|
109
109
|
select?: SelectionObject;
|
|
110
110
|
}): Promise<{
|
|
111
111
|
data: TOutput;
|
|
@@ -137,12 +137,12 @@ export type TypedClient<TRouter extends RouterDef> = TRouter extends RouterDef<i
|
|
|
137
137
|
* });
|
|
138
138
|
*
|
|
139
139
|
* // Vanilla JS (anywhere)
|
|
140
|
-
* const user = await client.user.get({
|
|
140
|
+
* const user = await client.user.get({ args: { id } });
|
|
141
141
|
*
|
|
142
142
|
* // Component usage
|
|
143
143
|
* function UserProfile(props: { id: string }) {
|
|
144
144
|
* const { data, loading, error } = client.user.get.createQuery({
|
|
145
|
-
*
|
|
145
|
+
* args: { id: props.id },
|
|
146
146
|
* });
|
|
147
147
|
*
|
|
148
148
|
* const { mutate, loading: saving } = client.user.update.createMutation({
|
|
@@ -153,7 +153,7 @@ export type TypedClient<TRouter extends RouterDef> = TRouter extends RouterDef<i
|
|
|
153
153
|
* <Show when={!loading()} fallback={<Spinner />}>
|
|
154
154
|
* <h1>{data()?.name}</h1>
|
|
155
155
|
* <button
|
|
156
|
-
* onClick={() => mutate({
|
|
156
|
+
* onClick={() => mutate({ args: { id: props.id, name: 'New' } })}
|
|
157
157
|
* disabled={saving()}
|
|
158
158
|
* >
|
|
159
159
|
* Update
|
package/dist/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,KAAK,QAAQ,EAA6C,MAAM,UAAU,CAAC;AAMpF;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IACnC,mCAAmC;IACnC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC3B,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,8BAA8B;AAC9B,MAAM,WAAW,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;IAC/D,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,KAAK,QAAQ,EAA6C,MAAM,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C;IACtC,cAAc,EAAE,CACf,OAAO,CAAC,EAAE,wBAAwB,CAAC,OAAO,CAAC,KACvC,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C;AAED,2CAA2C;AAC3C,KAAK,gBAAgB,CAAC,OAAO,SAAS,YAAY,IAAI;KACpD,CAAC,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,aAAa,CAAC,GACpE,gBAAgB,CAAC,aAAa,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,MAAM,EAAE,MAAM,OAAO,CAAC,GACvD,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,SAAS,WAAW,CAAC,MAAM,MAAM,EAAE,MAAM,OAAO,CAAC,GAC1D,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,KAAK;CACV,CAAC;AAEF,+BAA+B;AAC/B,MAAM,MAAM,WAAW,CAAC,OAAO,SAAS,SAAS,IAChD,OAAO,SAAS,SAAS,CAAC,MAAM,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AAiK9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,SAAS,EACrD,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,GAC/D,WAAW,CAAC,OAAO,CAAC,CAoEtB"}
|
package/dist/index.d.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({
|
|
20
|
-
* client.user.get({
|
|
19
|
+
* const user = await client.user.get({ args: { id } });
|
|
20
|
+
* client.user.get({ args: { id } }).subscribe(data => console.log(data));
|
|
21
21
|
*
|
|
22
22
|
* // SolidJS primitives (in components)
|
|
23
|
-
* const { data, loading } = client.user.get.createQuery({
|
|
23
|
+
* const { data, loading } = client.user.get.createQuery({ args: { id } });
|
|
24
24
|
* const { mutate } = client.user.create.createMutation();
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1237,7 +1237,7 @@ class SelectionRegistry {
|
|
|
1237
1237
|
let nestedSelection;
|
|
1238
1238
|
if ("select" in value && typeof value.select === "object") {
|
|
1239
1239
|
nestedSelection = value.select;
|
|
1240
|
-
} else if (!("
|
|
1240
|
+
} else if (!("args" in value)) {
|
|
1241
1241
|
nestedSelection = value;
|
|
1242
1242
|
}
|
|
1243
1243
|
if (nestedSelection) {
|
|
@@ -1288,12 +1288,12 @@ function mergeSelections(selections) {
|
|
|
1288
1288
|
if (typeof value === "object" && value !== null) {
|
|
1289
1289
|
if ("select" in value && typeof value.select === "object") {
|
|
1290
1290
|
nestedSelections.push(value.select);
|
|
1291
|
-
if ("
|
|
1292
|
-
lastInput = value.
|
|
1291
|
+
if ("args" in value) {
|
|
1292
|
+
lastInput = value.args;
|
|
1293
1293
|
}
|
|
1294
|
-
} else if ("
|
|
1295
|
-
lastInput = value.
|
|
1296
|
-
merged[key] = {
|
|
1294
|
+
} else if ("args" in value) {
|
|
1295
|
+
lastInput = value.args;
|
|
1296
|
+
merged[key] = { args: lastInput };
|
|
1297
1297
|
} else {
|
|
1298
1298
|
nestedSelections.push(value);
|
|
1299
1299
|
}
|
|
@@ -1302,7 +1302,7 @@ function mergeSelections(selections) {
|
|
|
1302
1302
|
if (nestedSelections.length > 0) {
|
|
1303
1303
|
const mergedNested = mergeSelections(nestedSelections);
|
|
1304
1304
|
if (lastInput !== undefined) {
|
|
1305
|
-
merged[key] = {
|
|
1305
|
+
merged[key] = { args: lastInput, select: mergedNested };
|
|
1306
1306
|
} else {
|
|
1307
1307
|
merged[key] = mergedNested;
|
|
1308
1308
|
}
|
|
@@ -1332,7 +1332,7 @@ function filterToSelection(data, selection) {
|
|
|
1332
1332
|
let nestedSelection = null;
|
|
1333
1333
|
if ("select" in value && typeof value.select === "object") {
|
|
1334
1334
|
nestedSelection = value.select;
|
|
1335
|
-
} else if (!("
|
|
1335
|
+
} else if (!("args" in value)) {
|
|
1336
1336
|
nestedSelection = value;
|
|
1337
1337
|
}
|
|
1338
1338
|
if (nestedSelection) {
|
|
@@ -1888,8 +1888,8 @@ class ClientImpl {
|
|
|
1888
1888
|
return (descriptor) => {
|
|
1889
1889
|
let input;
|
|
1890
1890
|
let select;
|
|
1891
|
-
if (descriptor && typeof descriptor === "object" && (("
|
|
1892
|
-
input = descriptor.
|
|
1891
|
+
if (descriptor && typeof descriptor === "object" && (("args" in descriptor) || ("select" in descriptor))) {
|
|
1892
|
+
input = descriptor.args;
|
|
1893
1893
|
select = descriptor.select;
|
|
1894
1894
|
} else {
|
|
1895
1895
|
input = descriptor;
|
|
@@ -2497,7 +2497,7 @@ function createQueryPrimitiveFactory(getEndpoint) {
|
|
|
2497
2497
|
return;
|
|
2498
2498
|
}
|
|
2499
2499
|
const endpoint = getEndpoint();
|
|
2500
|
-
const query = endpoint({
|
|
2500
|
+
const query = endpoint({ args: options?.args, select: options?.select });
|
|
2501
2501
|
setLoading(true);
|
|
2502
2502
|
setError(null);
|
|
2503
2503
|
options?.debug?.onSubscribe?.();
|
|
@@ -2521,7 +2521,7 @@ function createQueryPrimitiveFactory(getEndpoint) {
|
|
|
2521
2521
|
};
|
|
2522
2522
|
executeQuery();
|
|
2523
2523
|
createEffect(on(() => ({
|
|
2524
|
-
|
|
2524
|
+
argsKey: JSON.stringify(options?.args),
|
|
2525
2525
|
selectKey: JSON.stringify(options?.select),
|
|
2526
2526
|
skip: options?.skip
|
|
2527
2527
|
}), () => {
|
|
@@ -2550,7 +2550,7 @@ function createMutationPrimitiveFactory(getEndpoint) {
|
|
|
2550
2550
|
setError(null);
|
|
2551
2551
|
try {
|
|
2552
2552
|
const endpoint = getEndpoint();
|
|
2553
|
-
const result = await endpoint({
|
|
2553
|
+
const result = await endpoint({ args: options.args, select: options.select });
|
|
2554
2554
|
setData(() => result.data);
|
|
2555
2555
|
setLoading(false);
|
|
2556
2556
|
primitiveOptions?.onSuccess?.(result.data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sylphx/lens-solid",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "SolidJS bindings for Lens API framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"author": "SylphxAI",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@sylphx/lens-client": "^3.1.
|
|
35
|
-
"@sylphx/lens-core": "^4.1.
|
|
34
|
+
"@sylphx/lens-client": "^3.1.2",
|
|
35
|
+
"@sylphx/lens-core": "^4.1.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"solid-js": ">=1.8.0"
|
package/src/create.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({
|
|
20
|
-
* client.user.get({
|
|
19
|
+
* const user = await client.user.get({ args: { id } });
|
|
20
|
+
* client.user.get({ args: { id } }).subscribe(data => console.log(data));
|
|
21
21
|
*
|
|
22
22
|
* // SolidJS primitives (in components)
|
|
23
|
-
* const { data, loading } = client.user.get.createQuery({
|
|
23
|
+
* const { data, loading } = client.user.get.createQuery({ args: { id } });
|
|
24
24
|
* const { mutate, loading } = client.user.create.createMutation();
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
@@ -56,8 +56,8 @@ export interface QueryDebugOptions<T> {
|
|
|
56
56
|
|
|
57
57
|
/** Query primitive options */
|
|
58
58
|
export interface QueryPrimitiveOptions<TInput, TOutput = unknown> {
|
|
59
|
-
/** Query
|
|
60
|
-
|
|
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 MutationPrimitiveOptions<TOutput> {
|
|
|
94
94
|
/** Mutation primitive result */
|
|
95
95
|
export interface MutationPrimitiveResult<TInput, TOutput> {
|
|
96
96
|
/** Execute the mutation */
|
|
97
|
-
mutate: (options: {
|
|
97
|
+
mutate: (options: { args: TInput; select?: SelectionObject }) => Promise<TOutput>;
|
|
98
98
|
/** Reactive loading state */
|
|
99
99
|
loading: Accessor<boolean>;
|
|
100
100
|
/** Reactive error state */
|
|
@@ -108,7 +108,7 @@ export interface MutationPrimitiveResult<TInput, TOutput> {
|
|
|
108
108
|
/** Query endpoint with SolidJS primitives */
|
|
109
109
|
export interface QueryEndpoint<TInput, TOutput> {
|
|
110
110
|
/** Vanilla JS call - returns QueryResult (Promise + Observable) */
|
|
111
|
-
(options?: {
|
|
111
|
+
(options?: { args?: TInput; select?: SelectionObject }): QueryResult<TOutput>;
|
|
112
112
|
|
|
113
113
|
/** SolidJS primitive for reactive queries */
|
|
114
114
|
createQuery: (
|
|
@@ -121,7 +121,7 @@ export interface QueryEndpoint<TInput, TOutput> {
|
|
|
121
121
|
/** Mutation endpoint with SolidJS primitives */
|
|
122
122
|
export interface MutationEndpoint<TInput, TOutput> {
|
|
123
123
|
/** Vanilla JS call - returns Promise */
|
|
124
|
-
(options: {
|
|
124
|
+
(options: { args: TInput; select?: SelectionObject }): Promise<{ data: TOutput }>;
|
|
125
125
|
|
|
126
126
|
/** SolidJS primitive for mutations */
|
|
127
127
|
createMutation: (
|
|
@@ -178,7 +178,7 @@ function createQueryPrimitiveFactory<TInput, TOutput>(
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
const endpoint = getEndpoint();
|
|
181
|
-
const query = endpoint({
|
|
181
|
+
const query = endpoint({ args: options?.args, select: options?.select });
|
|
182
182
|
|
|
183
183
|
setLoading(true);
|
|
184
184
|
setError(null);
|
|
@@ -210,13 +210,13 @@ function createQueryPrimitiveFactory<TInput, TOutput>(
|
|
|
210
210
|
// Execute initial query
|
|
211
211
|
executeQuery();
|
|
212
212
|
|
|
213
|
-
// Watch for
|
|
213
|
+
// Watch for args/select changes using JSON.stringify for stable comparison
|
|
214
214
|
// This prevents re-fetching when object reference changes but content is the same
|
|
215
215
|
// Using on() with defer: true to skip initial run (already executed above)
|
|
216
216
|
createEffect(
|
|
217
217
|
on(
|
|
218
218
|
() => ({
|
|
219
|
-
|
|
219
|
+
argsKey: JSON.stringify(options?.args),
|
|
220
220
|
selectKey: JSON.stringify(options?.select),
|
|
221
221
|
skip: options?.skip,
|
|
222
222
|
}),
|
|
@@ -257,7 +257,7 @@ function createMutationPrimitiveFactory<TInput, TOutput>(
|
|
|
257
257
|
const [error, setError] = createSignal<Error | null>(null);
|
|
258
258
|
|
|
259
259
|
const mutate = async (options: {
|
|
260
|
-
|
|
260
|
+
args: TInput;
|
|
261
261
|
select?: SelectionObject;
|
|
262
262
|
}): Promise<TOutput> => {
|
|
263
263
|
setLoading(true);
|
|
@@ -265,7 +265,7 @@ function createMutationPrimitiveFactory<TInput, TOutput>(
|
|
|
265
265
|
|
|
266
266
|
try {
|
|
267
267
|
const endpoint = getEndpoint();
|
|
268
|
-
const result = await endpoint({
|
|
268
|
+
const result = await endpoint({ args: options.args, select: options.select });
|
|
269
269
|
|
|
270
270
|
setData(() => result.data);
|
|
271
271
|
setLoading(false);
|
|
@@ -321,12 +321,12 @@ const primitiveCache = new Map<string, unknown>();
|
|
|
321
321
|
* });
|
|
322
322
|
*
|
|
323
323
|
* // Vanilla JS (anywhere)
|
|
324
|
-
* const user = await client.user.get({
|
|
324
|
+
* const user = await client.user.get({ args: { id } });
|
|
325
325
|
*
|
|
326
326
|
* // Component usage
|
|
327
327
|
* function UserProfile(props: { id: string }) {
|
|
328
328
|
* const { data, loading, error } = client.user.get.createQuery({
|
|
329
|
-
*
|
|
329
|
+
* args: { id: props.id },
|
|
330
330
|
* });
|
|
331
331
|
*
|
|
332
332
|
* const { mutate, loading: saving } = client.user.update.createMutation({
|
|
@@ -337,7 +337,7 @@ const primitiveCache = new Map<string, unknown>();
|
|
|
337
337
|
* <Show when={!loading()} fallback={<Spinner />}>
|
|
338
338
|
* <h1>{data()?.name}</h1>
|
|
339
339
|
* <button
|
|
340
|
-
* onClick={() => mutate({
|
|
340
|
+
* onClick={() => mutate({ args: { id: props.id, name: 'New' } })}
|
|
341
341
|
* disabled={saving()}
|
|
342
342
|
* >
|
|
343
343
|
* Update
|
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({
|
|
20
|
-
* client.user.get({
|
|
19
|
+
* const user = await client.user.get({ args: { id } });
|
|
20
|
+
* client.user.get({ args: { id } }).subscribe(data => console.log(data));
|
|
21
21
|
*
|
|
22
22
|
* // SolidJS primitives (in components)
|
|
23
|
-
* const { data, loading } = client.user.get.createQuery({
|
|
23
|
+
* const { data, loading } = client.user.get.createQuery({ args: { id } });
|
|
24
24
|
* const { mutate } = client.user.create.createMutation();
|
|
25
25
|
* ```
|
|
26
26
|
*/
|