@molecule/app-query-angular 0.0.1-stage → 1.2.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.
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-14T15:07:28.989Z
6
+ Generated: 2026-11-14T22:00:50.867Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-query-angular
@@ -523,6 +523,39 @@ interface QueryResource<T, Create = Partial<T>, Update = Partial<T>> {
523
523
  }
524
524
  ```
525
525
 
526
+ #### `ListQueryRoute`
527
+
528
+ The list route a list query reads: `useListRoute` from `@molecule/app-angular` returns these
529
+ signals (and more), so its result is passed as it is.
530
+
531
+ ```typescript
532
+ interface ListQueryRoute<Filter extends string = string> {
533
+ /** False while a protected view waits for auth, is signed out, or is unavailable. */
534
+ readonly canLoad: Signal<boolean>
535
+ /** The current URL filter values. */
536
+ readonly filters: Signal<Readonly<Record<Filter, string | undefined>>>
537
+ /** The configured items per page. */
538
+ readonly pageSize: Signal<number>
539
+ /** The zero-indexed item offset for the API request. */
540
+ readonly offset: Signal<number>
541
+ }
542
+ ```
543
+
544
+ #### `ListQueryState`
545
+
546
+ The route's current values, as `read` receives them.
547
+
548
+ ```typescript
549
+ interface ListQueryState<Filter extends string = string> {
550
+ /** The current URL filter values. */
551
+ readonly filters: Readonly<Record<Filter, string | undefined>>
552
+ /** The configured items per page. */
553
+ readonly pageSize: number
554
+ /** The zero-indexed item offset for the API request. */
555
+ readonly offset: number
556
+ }
557
+ ```
558
+
526
559
  #### `UseQueryResult`
527
560
 
528
561
  A mounted query's state and its explicit cache and refresh actions. The state
@@ -616,6 +649,26 @@ interface IntentPrefetchProps {
616
649
  }
617
650
  ```
618
651
 
652
+ ### Types
653
+
654
+ #### `ListQuerySource`
655
+
656
+ A plain value or a signal: each input {@link useListQuery} reads reactively.
657
+
658
+ ```typescript
659
+ type ListQuerySource<T> = T | Signal<T>
660
+ ```
661
+
662
+ #### `ListQueryInputs`
663
+
664
+ Each input of {@link useListQuery} as a {@link ListQuerySource}.
665
+
666
+ ```typescript
667
+ type ListQueryInputs<Values> = {
668
+ readonly [Key in keyof Values]: ListQuerySource<Values[Key]>
669
+ }
670
+ ```
671
+
619
672
  ### Classes
620
673
 
621
674
  #### `QueryContent`
@@ -794,6 +847,29 @@ function createQueryResource<T, Create = Partial<T>, Update = Partial<T>>(
794
847
 
795
848
  **Returns:** List and detail query options, and create, update, remove, toggle and refresh.
796
849
 
850
+ #### `useListQuery(route, inputs, read)`
851
+
852
+ Observe the page a URL list route points at. `read` builds the query from the current value of
853
+ each input (the signed-in `viewer`, request params, a parent record's id) and the route's
854
+ filters, page size and offset. The query is disabled (`null`, no request) while `viewer` is
855
+ null (auth is still being restored) or the route cannot load yet; a changed input or URL moves
856
+ the same observer to the new page.
857
+ Call it in an injection context, as {@link useQuery}.
858
+
859
+ ```typescript
860
+ function useListQuery<T, Values extends { viewer: string | null }, Filter extends string = string>(
861
+ route: ListQueryRoute<Filter>,
862
+ inputs: ListQueryInputs<Values>,
863
+ read: (values: Values & { viewer: string }, list: ListQueryState<Filter>) => QueryOptions<T>,
864
+ ): UseQueryResult<T>
865
+ ```
866
+
867
+ - `route` — The list route, usually `useListRoute(...)` from `@molecule/app-angular`.
868
+ - `inputs` — Plain values or signals; `viewer` is the signed-in user's id, 'anonymous', or null while auth is restoring.
869
+ - `read` — Builds the page's query options, e.g. a generated `articlesPage(...)`.
870
+
871
+ **Returns:** The query state, as {@link useQuery} returns it.
872
+
797
873
  #### `usePrefetch()`
798
874
 
799
875
  A stable `prefetch(options)` function for event handlers. Call it in an
package/dist/index.d.ts CHANGED
@@ -456,6 +456,7 @@
456
456
  *
457
457
  * @module
458
458
  */
459
+ export * from './list-query.js';
459
460
  export * from './query-content.component.js';
460
461
  export * from './resource.js';
461
462
  export * from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAycG;AAEH,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAycG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -456,6 +456,7 @@
456
456
  *
457
457
  * @module
458
458
  */
459
+ export * from './list-query.js';
459
460
  export * from './query-content.component.js';
460
461
  export * from './resource.js';
461
462
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAycG;AAEH,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAycG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * `useListQuery`: one cached read driven by a URL list route.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Signal } from '@angular/core';
7
+ import type { QueryOptions } from '@molecule/app-query';
8
+ import type { UseQueryResult } from './types.js';
9
+ /** A plain value or a signal: each input {@link useListQuery} reads reactively. */
10
+ export type ListQuerySource<T> = T | Signal<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-angular` returns these
17
+ * signals (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: Signal<boolean>;
22
+ /** The current URL filter values. */
23
+ readonly filters: Signal<Readonly<Record<Filter, string | undefined>>>;
24
+ /** The configured items per page. */
25
+ readonly pageSize: Signal<number>;
26
+ /** The zero-indexed item offset for the API request. */
27
+ readonly offset: Signal<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
+ * Call it in an injection context, as {@link useQuery}.
45
+ *
46
+ * @param route - The list route, usually `useListRoute(...)` from `@molecule/app-angular`.
47
+ * @param inputs - Plain values or signals; `viewer` is the signed-in user's id, 'anonymous',
48
+ * or null while auth is restoring.
49
+ * @param read - Builds the page's query options, e.g. a generated `articlesPage(...)`.
50
+ * @returns The query state, as {@link useQuery} returns it.
51
+ */
52
+ export declare function useListQuery<T, Values extends {
53
+ viewer: string | null;
54
+ }, Filter extends string = string>(route: ListQueryRoute<Filter>, inputs: ListQueryInputs<Values>, read: (values: Values & {
55
+ viewer: string;
56
+ }, list: ListQueryState<Filter>) => QueryOptions<T>): UseQueryResult<T>;
57
+ //# sourceMappingURL=list-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-query.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,EAAE,MAAM,CAAA;CACxB;AAUD;;;;;;;;;;;;;GAaG;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,CAcnB"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `useListQuery`: one cached read driven by a URL list route.
3
+ *
4
+ * @module
5
+ */
6
+ import { computed, isSignal } from '@angular/core';
7
+ import { useQuery } from './use-query.js';
8
+ /**
9
+ * Reads a plain value or a signal; inside the query's computed options the read is tracked.
10
+ *
11
+ * @param source - The argument as the caller passed it.
12
+ * @returns Its current value.
13
+ */
14
+ const current = (source) => (isSignal(source) ? source() : source);
15
+ /**
16
+ * Observe the page a URL list route points at. `read` builds the query from the current value of
17
+ * each input (the signed-in `viewer`, request params, a parent record's id) and the route's
18
+ * filters, page size and offset. The query is disabled (`null`, no request) while `viewer` is
19
+ * null (auth is still being restored) or the route cannot load yet; a changed input or URL moves
20
+ * the same observer to the new page.
21
+ * Call it in an injection context, as {@link useQuery}.
22
+ *
23
+ * @param route - The list route, usually `useListRoute(...)` from `@molecule/app-angular`.
24
+ * @param inputs - Plain values or signals; `viewer` is the signed-in user's id, 'anonymous',
25
+ * or null while auth is restoring.
26
+ * @param read - Builds the page's query options, e.g. a generated `articlesPage(...)`.
27
+ * @returns The query state, as {@link useQuery} returns it.
28
+ */
29
+ export function useListQuery(route, inputs, read) {
30
+ return useQuery(computed(() => {
31
+ const values = {};
32
+ for (const key of Object.keys(inputs))
33
+ values[key] = current(inputs[key]);
34
+ const { viewer } = values;
35
+ if (viewer === null || !route.canLoad())
36
+ return null;
37
+ return read({ ...values, viewer }, { filters: route.filters(), pageSize: route.pageSize(), offset: route.offset() });
38
+ }));
39
+ }
40
+ //# sourceMappingURL=list-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-query.js","sourceRoot":"","sources":["../src/list-query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AAK/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAmCzC;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAAI,MAA0B,EAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAE5F;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAK1B,KAA6B,EAC7B,MAA+B,EAC/B,IAA4F;IAE5F,OAAO,QAAQ,CACb,QAAQ,CAAC,GAAG,EAAE;QACZ,MAAM,MAAM,GAAoB,EAAE,CAAA;QAClC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAqB;YACvD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAuB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1D,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,CACH,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-query-angular",
3
- "version": "0.0.1-stage",
3
+ "version": "1.2.0",
4
4
  "description": "Angular 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-angular",
6
6
  "type": "module",
@@ -56,7 +56,7 @@
56
56
  "@angular/compiler-cli": "22.2.3",
57
57
  "@angular/core": "22.2.3",
58
58
  "@angular/platform-browser": "22.2.3",
59
- "@molecule/app-angular": "3.5.0",
59
+ "@molecule/app-angular": "3.6.0",
60
60
  "@molecule/app-framework-conformance": "0.0.0",
61
61
  "@molecule/app-i18n": "1.2.1",
62
62
  "@molecule/app-icons": "1.0.4",
@@ -64,7 +64,7 @@
64
64
  "@molecule/app-query-memory": "1.0.5",
65
65
  "@molecule/app-query-tanstack": "1.0.5",
66
66
  "@molecule/app-ui": "1.3.11",
67
- "@molecule/app-ui-angular": "1.1.1",
67
+ "@molecule/app-ui-angular": "1.1.2",
68
68
  "@types/node": "26.6.5",
69
69
  "jsdom": "30.1.3",
70
70
  "rxjs": "7.8.2",