@molecule/app-query-solid 1.1.0 → 1.2.1
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/README.md +80 -3
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/list-query.d.ts +56 -0
- package/dist/list-query.d.ts.map +1 -0
- package/dist/list-query.js +33 -0
- package/dist/list-query.js.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-15T13:02:04.243Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-query-solid
|
|
@@ -45,7 +45,7 @@ its writes already publish the response and refresh its tracked collections.
|
|
|
45
45
|
```tsx
|
|
46
46
|
import { Match, Show, Switch } from 'solid-js'
|
|
47
47
|
import { getClient, isHttpError } from '@molecule/app-http'
|
|
48
|
-
import {
|
|
48
|
+
import { useTranslation } from '@molecule/app-solid'
|
|
49
49
|
import { intentPrefetchProps, useQuery } from '@molecule/app-query-solid'
|
|
50
50
|
|
|
51
51
|
interface PackageDocument {
|
|
@@ -78,6 +78,7 @@ function PackageLink(props: { name: string }) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
function PackagePage(props: { name: string }) {
|
|
81
|
+
const { t } = useTranslation()
|
|
81
82
|
// The options are an accessor, so a changed name (route param, input) re-keys
|
|
82
83
|
// the observer on the same mounted component, the way React re-renders useQuery.
|
|
83
84
|
const query = useQuery(() => packageQuery(props.name))
|
|
@@ -194,7 +195,7 @@ explicit `fetch()` retries into the mounted page.
|
|
|
194
195
|
|
|
195
196
|
```tsx
|
|
196
197
|
import { getClient } from '@molecule/app-http'
|
|
197
|
-
import {
|
|
198
|
+
import { useTranslation } from '@molecule/app-solid'
|
|
198
199
|
import { getQueryClient } from '@molecule/app-query'
|
|
199
200
|
|
|
200
201
|
// The key names what the document actually depends on — here the signed-in
|
|
@@ -223,6 +224,7 @@ async function setFollowing(principal: string, authorId: string, follow: boolean
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
function Retry(props: { principal: string }) {
|
|
227
|
+
const { t } = useTranslation()
|
|
226
228
|
return (
|
|
227
229
|
<button
|
|
228
230
|
onClick={() => {
|
|
@@ -475,6 +477,39 @@ interface QueryResource<T, Create = Partial<T>, Update = Partial<T>> {
|
|
|
475
477
|
}
|
|
476
478
|
```
|
|
477
479
|
|
|
480
|
+
#### `ListQueryRoute`
|
|
481
|
+
|
|
482
|
+
The list route a list query reads: `useListRoute` from `@molecule/app-solid` returns these
|
|
483
|
+
accessors (and more), so its result is passed as it is.
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
interface ListQueryRoute<Filter extends string = string> {
|
|
487
|
+
/** False while a protected view waits for auth, is signed out, or is unavailable. */
|
|
488
|
+
readonly canLoad: Accessor<boolean>
|
|
489
|
+
/** The current URL filter values. */
|
|
490
|
+
readonly filters: Accessor<Readonly<Record<Filter, string | undefined>>>
|
|
491
|
+
/** The configured items per page. */
|
|
492
|
+
readonly pageSize: Accessor<number>
|
|
493
|
+
/** The zero-indexed item offset for the API request. */
|
|
494
|
+
readonly offset: Accessor<number>
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
#### `ListQueryState`
|
|
499
|
+
|
|
500
|
+
The route's current values, as `read` receives them.
|
|
501
|
+
|
|
502
|
+
```typescript
|
|
503
|
+
interface ListQueryState<Filter extends string = string> {
|
|
504
|
+
/** The current URL filter values. */
|
|
505
|
+
readonly filters: Readonly<Record<Filter, string | undefined>>
|
|
506
|
+
/** The configured items per page. */
|
|
507
|
+
readonly pageSize: number
|
|
508
|
+
/** The zero-indexed item offset for the API request. */
|
|
509
|
+
readonly offset: number
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
478
513
|
#### `UseQueryResult`
|
|
479
514
|
|
|
480
515
|
A mounted query's state and its explicit cache and refresh actions. The state
|
|
@@ -540,6 +575,26 @@ interface IntentPrefetchProps {
|
|
|
540
575
|
}
|
|
541
576
|
```
|
|
542
577
|
|
|
578
|
+
### Types
|
|
579
|
+
|
|
580
|
+
#### `ListQuerySource`
|
|
581
|
+
|
|
582
|
+
A plain value or an accessor: each input {@link useListQuery} reads reactively.
|
|
583
|
+
|
|
584
|
+
```typescript
|
|
585
|
+
type ListQuerySource<T> = T | Accessor<T>
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
#### `ListQueryInputs`
|
|
589
|
+
|
|
590
|
+
Each input of {@link useListQuery} as a {@link ListQuerySource}.
|
|
591
|
+
|
|
592
|
+
```typescript
|
|
593
|
+
type ListQueryInputs<Values> = {
|
|
594
|
+
readonly [Key in keyof Values]: ListQuerySource<Values[Key]>
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
543
598
|
### Functions
|
|
544
599
|
|
|
545
600
|
#### `prefetchQuery(options)`
|
|
@@ -589,6 +644,28 @@ function createQueryResource<T, Create = Partial<T>, Update = Partial<T>>(
|
|
|
589
644
|
|
|
590
645
|
**Returns:** List and detail query options, and create, update, remove, toggle and refresh.
|
|
591
646
|
|
|
647
|
+
#### `useListQuery(route, inputs, read)`
|
|
648
|
+
|
|
649
|
+
Observe the page a URL list route points at. `read` builds the query from the current value of
|
|
650
|
+
each input (the signed-in `viewer`, request params, a parent record's id) and the route's
|
|
651
|
+
filters, page size and offset. The query is disabled (`null`, no request) while `viewer` is
|
|
652
|
+
null (auth is still being restored) or the route cannot load yet; a changed input or URL moves
|
|
653
|
+
the same observer to the new page.
|
|
654
|
+
|
|
655
|
+
```typescript
|
|
656
|
+
function useListQuery<T, Values extends { viewer: string | null }, Filter extends string = string>(
|
|
657
|
+
route: ListQueryRoute<Filter>,
|
|
658
|
+
inputs: ListQueryInputs<Values>,
|
|
659
|
+
read: (values: Values & { viewer: string }, list: ListQueryState<Filter>) => QueryOptions<T>,
|
|
660
|
+
): UseQueryResult<T>
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
- `route` — The list route, usually `useListRoute(...)` from `@molecule/app-solid`.
|
|
664
|
+
- `inputs` — Plain values or accessors; `viewer` is the signed-in user's id, 'anonymous', or null while auth is restoring.
|
|
665
|
+
- `read` — Builds the page's query options, e.g. a generated `articlesPage(...)`.
|
|
666
|
+
|
|
667
|
+
**Returns:** The query state, as {@link useQuery} returns it.
|
|
668
|
+
|
|
592
669
|
#### `QueryContent(props)`
|
|
593
670
|
|
|
594
671
|
The loaded-data branch receives a non-null document. Pending, failed initial reads and
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* ```tsx
|
|
32
32
|
* import { Match, Show, Switch } from 'solid-js'
|
|
33
33
|
* import { getClient, isHttpError } from '@molecule/app-http'
|
|
34
|
-
* import {
|
|
34
|
+
* import { useTranslation } from '@molecule/app-solid'
|
|
35
35
|
* import { intentPrefetchProps, useQuery } from '@molecule/app-query-solid'
|
|
36
36
|
*
|
|
37
37
|
* interface PackageDocument {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
* }
|
|
65
65
|
*
|
|
66
66
|
* function PackagePage(props: { name: string }) {
|
|
67
|
+
* const { t } = useTranslation()
|
|
67
68
|
* // The options are an accessor, so a changed name (route param, input) re-keys
|
|
68
69
|
* // the observer on the same mounted component, the way React re-renders useQuery.
|
|
69
70
|
* const query = useQuery(() => packageQuery(props.name))
|
|
@@ -183,7 +184,7 @@
|
|
|
183
184
|
*
|
|
184
185
|
* ```tsx
|
|
185
186
|
* import { getClient } from '@molecule/app-http'
|
|
186
|
-
* import {
|
|
187
|
+
* import { useTranslation } from '@molecule/app-solid'
|
|
187
188
|
* import { getQueryClient } from '@molecule/app-query'
|
|
188
189
|
*
|
|
189
190
|
* // The key names what the document actually depends on — here the signed-in
|
|
@@ -212,6 +213,7 @@
|
|
|
212
213
|
* }
|
|
213
214
|
*
|
|
214
215
|
* function Retry(props: { principal: string }) {
|
|
216
|
+
* const { t } = useTranslation()
|
|
215
217
|
* return (
|
|
216
218
|
* <button
|
|
217
219
|
* onClick={() => {
|
|
@@ -424,6 +426,7 @@
|
|
|
424
426
|
*
|
|
425
427
|
* @module
|
|
426
428
|
*/
|
|
429
|
+
export * from './list-query.js';
|
|
427
430
|
export * from './query-content.jsx';
|
|
428
431
|
export * from './resource.js';
|
|
429
432
|
export * from './types.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2aG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* ```tsx
|
|
32
32
|
* import { Match, Show, Switch } from 'solid-js'
|
|
33
33
|
* import { getClient, isHttpError } from '@molecule/app-http'
|
|
34
|
-
* import {
|
|
34
|
+
* import { useTranslation } from '@molecule/app-solid'
|
|
35
35
|
* import { intentPrefetchProps, useQuery } from '@molecule/app-query-solid'
|
|
36
36
|
*
|
|
37
37
|
* interface PackageDocument {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
* }
|
|
65
65
|
*
|
|
66
66
|
* function PackagePage(props: { name: string }) {
|
|
67
|
+
* const { t } = useTranslation()
|
|
67
68
|
* // The options are an accessor, so a changed name (route param, input) re-keys
|
|
68
69
|
* // the observer on the same mounted component, the way React re-renders useQuery.
|
|
69
70
|
* const query = useQuery(() => packageQuery(props.name))
|
|
@@ -183,7 +184,7 @@
|
|
|
183
184
|
*
|
|
184
185
|
* ```tsx
|
|
185
186
|
* import { getClient } from '@molecule/app-http'
|
|
186
|
-
* import {
|
|
187
|
+
* import { useTranslation } from '@molecule/app-solid'
|
|
187
188
|
* import { getQueryClient } from '@molecule/app-query'
|
|
188
189
|
*
|
|
189
190
|
* // The key names what the document actually depends on — here the signed-in
|
|
@@ -212,6 +213,7 @@
|
|
|
212
213
|
* }
|
|
213
214
|
*
|
|
214
215
|
* function Retry(props: { principal: string }) {
|
|
216
|
+
* const { t } = useTranslation()
|
|
215
217
|
* return (
|
|
216
218
|
* <button
|
|
217
219
|
* onClick={() => {
|
|
@@ -424,6 +426,7 @@
|
|
|
424
426
|
*
|
|
425
427
|
* @module
|
|
426
428
|
*/
|
|
429
|
+
export * from './list-query.js';
|
|
427
430
|
export * from './query-content.jsx';
|
|
428
431
|
export * from './resource.js';
|
|
429
432
|
export * from './types.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2aG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useListQuery`: one cached read driven by a URL list route.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Accessor } from 'solid-js';
|
|
7
|
+
import type { QueryOptions } from '@molecule/app-query';
|
|
8
|
+
import type { UseQueryResult } from './types.js';
|
|
9
|
+
/** A plain value or an accessor: each input {@link useListQuery} reads reactively. */
|
|
10
|
+
export type ListQuerySource<T> = T | Accessor<T>;
|
|
11
|
+
/** Each input of {@link useListQuery} as a {@link ListQuerySource}. */
|
|
12
|
+
export type ListQueryInputs<Values> = {
|
|
13
|
+
readonly [Key in keyof Values]: ListQuerySource<Values[Key]>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The list route a list query reads: `useListRoute` from `@molecule/app-solid` returns these
|
|
17
|
+
* accessors (and more), so its result is passed as it is.
|
|
18
|
+
*/
|
|
19
|
+
export interface ListQueryRoute<Filter extends string = string> {
|
|
20
|
+
/** False while a protected view waits for auth, is signed out, or is unavailable. */
|
|
21
|
+
readonly canLoad: Accessor<boolean>;
|
|
22
|
+
/** The current URL filter values. */
|
|
23
|
+
readonly filters: Accessor<Readonly<Record<Filter, string | undefined>>>;
|
|
24
|
+
/** The configured items per page. */
|
|
25
|
+
readonly pageSize: Accessor<number>;
|
|
26
|
+
/** The zero-indexed item offset for the API request. */
|
|
27
|
+
readonly offset: Accessor<number>;
|
|
28
|
+
}
|
|
29
|
+
/** The route's current values, as `read` receives them. */
|
|
30
|
+
export interface ListQueryState<Filter extends string = string> {
|
|
31
|
+
/** The current URL filter values. */
|
|
32
|
+
readonly filters: Readonly<Record<Filter, string | undefined>>;
|
|
33
|
+
/** The configured items per page. */
|
|
34
|
+
readonly pageSize: number;
|
|
35
|
+
/** The zero-indexed item offset for the API request. */
|
|
36
|
+
readonly offset: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Observe the page a URL list route points at. `read` builds the query from the current value of
|
|
40
|
+
* each input (the signed-in `viewer`, request params, a parent record's id) and the route's
|
|
41
|
+
* filters, page size and offset. The query is disabled (`null`, no request) while `viewer` is
|
|
42
|
+
* null (auth is still being restored) or the route cannot load yet; a changed input or URL moves
|
|
43
|
+
* the same observer to the new page.
|
|
44
|
+
*
|
|
45
|
+
* @param route - The list route, usually `useListRoute(...)` from `@molecule/app-solid`.
|
|
46
|
+
* @param inputs - Plain values or accessors; `viewer` is the signed-in user's id, 'anonymous',
|
|
47
|
+
* or null while auth is restoring.
|
|
48
|
+
* @param read - Builds the page's query options, e.g. a generated `articlesPage(...)`.
|
|
49
|
+
* @returns The query state, as {@link useQuery} returns it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function useListQuery<T, Values extends {
|
|
52
|
+
viewer: string | null;
|
|
53
|
+
}, Filter extends string = string>(route: ListQueryRoute<Filter>, inputs: ListQueryInputs<Values>, read: (values: Values & {
|
|
54
|
+
viewer: string;
|
|
55
|
+
}, list: ListQueryState<Filter>) => QueryOptions<T>): UseQueryResult<T>;
|
|
56
|
+
//# sourceMappingURL=list-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-query.d.ts","sourceRoot":"","sources":["../src/list-query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGhD,sFAAsF;AACtF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEhD,uEAAuE;AACvE,MAAM,MAAM,eAAe,CAAC,MAAM,IAAI;IACpC,QAAQ,EAAE,GAAG,IAAI,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;CAC7D,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IAC5D,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACnC,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IACxE,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACnC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAClC;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IAC5D,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IAC9D,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EACD,MAAM,SAAS;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACxC,MAAM,SAAS,MAAM,GAAG,MAAM,EAE9B,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,EAC/B,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAC3F,cAAc,CAAC,CAAC,CAAC,CAYnB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useQuery } from './use-query.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a plain value or an accessor; inside the query's options accessor the read is tracked.
|
|
4
|
+
*
|
|
5
|
+
* @param source - The argument as the caller passed it.
|
|
6
|
+
* @returns Its current value.
|
|
7
|
+
*/
|
|
8
|
+
const access = (source) => typeof source === 'function' ? source() : source;
|
|
9
|
+
/**
|
|
10
|
+
* Observe the page a URL list route points at. `read` builds the query from the current value of
|
|
11
|
+
* each input (the signed-in `viewer`, request params, a parent record's id) and the route's
|
|
12
|
+
* filters, page size and offset. The query is disabled (`null`, no request) while `viewer` is
|
|
13
|
+
* null (auth is still being restored) or the route cannot load yet; a changed input or URL moves
|
|
14
|
+
* the same observer to the new page.
|
|
15
|
+
*
|
|
16
|
+
* @param route - The list route, usually `useListRoute(...)` from `@molecule/app-solid`.
|
|
17
|
+
* @param inputs - Plain values or accessors; `viewer` is the signed-in user's id, 'anonymous',
|
|
18
|
+
* or null while auth is restoring.
|
|
19
|
+
* @param read - Builds the page's query options, e.g. a generated `articlesPage(...)`.
|
|
20
|
+
* @returns The query state, as {@link useQuery} returns it.
|
|
21
|
+
*/
|
|
22
|
+
export function useListQuery(route, inputs, read) {
|
|
23
|
+
return useQuery(() => {
|
|
24
|
+
const values = {};
|
|
25
|
+
for (const key of Object.keys(inputs))
|
|
26
|
+
values[key] = access(inputs[key]);
|
|
27
|
+
const { viewer } = values;
|
|
28
|
+
if (viewer === null || !route.canLoad())
|
|
29
|
+
return null;
|
|
30
|
+
return read({ ...values, viewer }, { filters: route.filters(), pageSize: route.pageSize(), offset: route.offset() });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=list-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-query.js","sourceRoot":"","sources":["../src/list-query.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAmCzC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAI,MAA0B,EAAK,EAAE,CAClD,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAE,MAAsB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAA;AAEnE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAK1B,KAA6B,EAC7B,MAA+B,EAC/B,IAA4F;IAE5F,OAAO,QAAQ,CAAI,GAAG,EAAE;QACtB,MAAM,MAAM,GAAoB,EAAE,CAAA;QAClC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAqB;YACvD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAuB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;QACzD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAgB,CAAA;QACnC,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YAAE,OAAO,IAAI,CAAA;QACpD,OAAO,IAAI,CACT,EAAE,GAAI,MAAiB,EAAE,MAAM,EAAE,EACjC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CACjF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-query-solid",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Solid hooks for @molecule/app-query — read a cached document synchronously, observe it, and prefetch on intent",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-query-solid",
|
|
6
6
|
"type": "module",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
53
|
-
"@molecule/app-i18n": "1.2.
|
|
53
|
+
"@molecule/app-i18n": "1.2.2",
|
|
54
54
|
"@molecule/app-icons": "1.0.4",
|
|
55
55
|
"@molecule/app-query": "1.2.0",
|
|
56
56
|
"@molecule/app-query-memory": "1.0.5",
|
|
57
57
|
"@molecule/app-query-tanstack": "1.0.5",
|
|
58
|
-
"@molecule/app-solid": "3.
|
|
59
|
-
"@molecule/app-ui": "1.
|
|
60
|
-
"@molecule/app-ui-solid": "1.1.
|
|
58
|
+
"@molecule/app-solid": "3.7.1",
|
|
59
|
+
"@molecule/app-ui": "1.4.0",
|
|
60
|
+
"@molecule/app-ui-solid": "1.1.4",
|
|
61
61
|
"@types/node": "26.6.5",
|
|
62
62
|
"jsdom": "30.1.3",
|
|
63
63
|
"solid-js": "1.9.17",
|