@talelk/newui-data 0.0.0-stage → 1.1.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.
Files changed (68) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +65 -2
  3. package/package.json +54 -3
  4. package/skills/newui-data/SKILL.md +170 -0
  5. package/src/aggregate.test.ts +231 -0
  6. package/src/aggregate.ts +320 -0
  7. package/src/config-store.test.ts +157 -0
  8. package/src/config-store.ts +295 -0
  9. package/src/csv-export.test.ts +156 -0
  10. package/src/csv-export.ts +129 -0
  11. package/src/dashboard.test.tsx +285 -0
  12. package/src/dashboard.tsx +381 -0
  13. package/src/download.test.ts +14 -0
  14. package/src/download.ts +39 -0
  15. package/src/exports.test.ts +135 -0
  16. package/src/form/autosave.test.ts +186 -0
  17. package/src/form/autosave.ts +194 -0
  18. package/src/form/config.test.tsx +288 -0
  19. package/src/form/config.ts +187 -0
  20. package/src/form/form.test.tsx +102 -0
  21. package/src/form/form.tsx +205 -0
  22. package/src/form/index.ts +3 -0
  23. package/src/format.test.ts +22 -0
  24. package/src/format.ts +36 -0
  25. package/src/index.ts +10 -0
  26. package/src/query/client.tsx +53 -0
  27. package/src/query/collection.test.tsx +278 -0
  28. package/src/query/collection.ts +207 -0
  29. package/src/query/index.ts +4 -0
  30. package/src/query/repository.ts +30 -0
  31. package/src/query/server-table.test.ts +136 -0
  32. package/src/query/server-table.ts +181 -0
  33. package/src/resource/client.test.ts +173 -0
  34. package/src/resource/client.ts +307 -0
  35. package/src/resource/connect-realtime.test.ts +135 -0
  36. package/src/resource/connect-realtime.ts +121 -0
  37. package/src/resource/document.test.ts +151 -0
  38. package/src/resource/document.ts +198 -0
  39. package/src/resource/idb.test.ts +169 -0
  40. package/src/resource/idb.ts +167 -0
  41. package/src/resource/index.ts +77 -0
  42. package/src/resource/list.test.ts +150 -0
  43. package/src/resource/list.ts +230 -0
  44. package/src/resource/local.test.ts +111 -0
  45. package/src/resource/local.ts +155 -0
  46. package/src/resource/realtime.test.ts +331 -0
  47. package/src/resource/realtime.ts +287 -0
  48. package/src/resource/resource.test.ts +186 -0
  49. package/src/resource/resource.ts +213 -0
  50. package/src/resource/useCall.test.ts +60 -0
  51. package/src/resource/useCall.ts +74 -0
  52. package/src/resource/useDoc.test.ts +31 -0
  53. package/src/resource/useDoc.ts +23 -0
  54. package/src/resource/useDoctype.test.ts +104 -0
  55. package/src/resource/useDoctype.ts +128 -0
  56. package/src/resource/useList.test.ts +32 -0
  57. package/src/resource/useList.ts +22 -0
  58. package/src/resource/useNewDoc.test.ts +67 -0
  59. package/src/resource/useNewDoc.ts +78 -0
  60. package/src/select.test.ts +13 -0
  61. package/src/select.ts +19 -0
  62. package/src/table-persist.test.ts +258 -0
  63. package/src/table-persist.ts +371 -0
  64. package/src/undo.test.ts +24 -0
  65. package/src/undo.ts +37 -0
  66. package/src/url-serialize.ts +93 -0
  67. package/src/url-state.test.ts +183 -0
  68. package/src/url-state.ts +168 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # @talelk/newui-data
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The logic layer: the things every app does the same way and no two agree on
4
+ when they write them themselves.
5
+
6
+ ```ts
7
+ import { createUndo, downloadCsv, usd, optionsOf } from '@talelk/newui-data'
8
+ ```
9
+
10
+ The package is **headless** — it imports `solid-js` for signals and nothing from
11
+ the visual packages, so a page can use it without paying for a component, and a
12
+ component can never reach up into it. What renders stays in the atomic packages;
13
+ this level only answers *how it behaves*.
14
+
15
+ The first four surfaces are the ones the examples had already copied:
16
+
17
+ | surface | what it owns |
18
+ | --- | --- |
19
+ | `format` | `usd`, `usdK`, `count`, `bytes`, `isEmail` — one `Intl` formatter each, built once |
20
+ | `select` | `optionsOf`, `first` — the `{ label, value }` plumbing and the empty-array unwrap |
21
+ | `undo` | `createUndo` — a snapshot, a restore and a clear, without the page's notice copy |
22
+ | `download` | `downloadBlob`, `downloadText`, `downloadCsv`, `csvText` — the Blob/anchor/revoke dance and RFC-shaped quoting |
23
+
24
+ The analytics primitives, decided in issues #22, #23, #24 and #32, round out the
25
+ headless layer:
26
+
27
+ | surface | what it owns |
28
+ | --- | --- |
29
+ | `url-state` | `createUrlState` — link-reproducible signals behind a router adapter, replace-not-push, debounced search keys |
30
+ | `config-store` | `createConfigStore` — versioned envelopes for saved views and dashboard config over a storage seam |
31
+ | `aggregate` | `aggregate`, `timeBucket`, `rollup` — pure group-by and time-series transforms over rows the app already fetched |
32
+
33
+ ## Query
34
+
35
+ ```tsx
36
+ import { DataProvider, createCollection } from '@talelk/newui-data/query'
37
+
38
+ const tasks = createCollection(() => ({
39
+ key: ['tasks'],
40
+ repository, // list / create / update / remove
41
+ }))
42
+
43
+ tasks.query.rows()
44
+ tasks.update.mutate({ id, patch }) // optimistic, reversible
45
+ ```
46
+
47
+ The query surface is its own entry point, so importing `usd` never pulls a
48
+ cache in. `DataProvider` owns the client (and clears it on unmount);
49
+ `createCollection` returns one list query and four mutations, each refreshing
50
+ the list on settle so a mutation and the Refresh button cannot disagree.
51
+
52
+ TanStack Query and Form are dependencies of this package; the app does not
53
+ depend on them directly. Rendered `DataTable` and `VirtualList` are organisms
54
+ and `ScrollTable` is a molecule. This package supplies their headless data
55
+ behavior, not their rendered surface; `spec/data.md` is the contract for what
56
+ has shipped.
57
+
58
+ ## Resource — `@talelk/newui-data/resource`
59
+
60
+ The Frappe DocType client: `request`/`frappeRequest` transport with
61
+ `setConfig`, document and list hooks (`useDoc`, `useDoctype`, `useList`,
62
+ `useNewDoc`, `useCall`), an IndexedDB cache, and a shared WebSocket realtime
63
+ multiplexer (`createRealtime`, plus `connectRealtime` to invalidate query keys
64
+ from socket events). It lives behind its own entry so importing `usd` never
65
+ pulls a fetch stack, and it is app-specific — generic query needs belong on
66
+ `/query`.
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@talelk/newui-data",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.0",
4
+ "type": "module",
5
+ "description": "The logic layer: formatting, selection, undo and downloads — no components.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/talelk/newui.git",
9
+ "directory": "packages/data"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./src/index.ts",
14
+ "default": "./src/index.ts"
15
+ },
16
+ "./query": {
17
+ "types": "./src/query/index.ts",
18
+ "default": "./src/query/index.ts"
19
+ },
20
+ "./form": {
21
+ "types": "./src/form/index.ts",
22
+ "default": "./src/form/index.ts"
23
+ },
24
+ "./resource": {
25
+ "types": "./src/resource/index.ts",
26
+ "default": "./src/resource/index.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "src",
31
+ "skills"
32
+ ],
33
+ "keywords": [
34
+ "tanstack-intent",
35
+ "agent-skills",
36
+ "solidjs",
37
+ "data"
38
+ ],
39
+ "peerDependencies": {
40
+ "solid-js": "^1.9.0"
41
+ },
42
+ "devDependencies": {
43
+ "solid-js": "^1.9.0"
44
+ },
45
+ "sideEffects": false,
46
+ "dependencies": {
47
+ "@tanstack/solid-form": "^1.33.5",
48
+ "@tanstack/solid-query": "^5.104.3"
49
+ },
50
+ "license": "Apache-2.0",
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "typecheck": "tsc --noEmit -p tsconfig.json"
56
+ }
6
57
  }
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: newui-data
3
+ description: Use the headless newui data layer for SolidJS collections,
4
+ repository queries, optimistic mutations, TanStack Query caching, form submit
5
+ lifecycles, URL-synced state, saved-view/dashboard-config storage and
6
+ aggregation/rollup transforms. Use when a page needs to load a list,
7
+ create/update/delete records, share a cache, sync filters or views to the URL,
8
+ persist saved views, build chart series, or wire TanStack Form through the
9
+ kit's Form and field-error contract.
10
+ metadata:
11
+ type: core
12
+ domain: data
13
+ library: '@talelk/newui-data'
14
+ library_version: '1.1.0'
15
+ sources:
16
+ - talelk/newui:spec/data.md
17
+ - talelk/newui:skills/README.md
18
+ - talelk/newui:packages/data/README.md
19
+ - talelk/newui:packages/data/src/query/client.tsx
20
+ - talelk/newui:packages/data/src/query/collection.ts
21
+ - talelk/newui:packages/data/src/query/repository.ts
22
+ - talelk/newui:packages/data/src/form/form.tsx
23
+ - talelk/newui:packages/data/src/url-state.ts
24
+ - talelk/newui:packages/data/src/config-store.ts
25
+ - talelk/newui:packages/data/src/aggregate.ts
26
+ - talelk/newui:packages/data/src/resource/connect-realtime.ts
27
+ ---
28
+
29
+ # newui-data
30
+
31
+ The headless data layer: one query client, one collection abstraction and one
32
+ form surface. It renders nothing. Load the `newui` skill as well when the page
33
+ needs components.
34
+
35
+ ## Wire the client once
36
+
37
+ ```tsx no-check
38
+ import { DataProvider } from '@talelk/newui-data/query'
39
+
40
+ export function App() {
41
+ return <DataProvider>{/* router and pages */}</DataProvider>
42
+ }
43
+ ```
44
+
45
+ `DataProvider` owns a `QueryClient` and clears it on unmount. Pass `client` to
46
+ share one across panes. The defaults are deliberate: no refetch on window focus,
47
+ one retry, and errors are data the page renders rather than exceptions.
48
+
49
+ ## Collections
50
+
51
+ A repository is the only place that knows where records come from. A collection
52
+ turns it into one cached list and four optimistic mutations.
53
+
54
+ ```tsx
55
+ import { createCollection } from '@talelk/newui-data/query'
56
+
57
+ const projects = createCollection<Project, NewProject>(() => ({
58
+ key: ['projects'],
59
+ repository: projectRepository,
60
+ onError: (error) => setNotice(error.message),
61
+ }))
62
+
63
+ projects.query.rows()
64
+ projects.query.isPending()
65
+ projects.query.isError()
66
+ projects.create.mutateAsync(input)
67
+ projects.update.mutateAsync({ id, patch })
68
+ projects.updateMany.mutate({ ids, patch })
69
+ projects.remove.mutateAsync({ ids })
70
+ ```
71
+
72
+ - Read `collection.query.rows()`; never reach into the cache from a page.
73
+ - `create` is not optimistic because the repository owns the new id and defaults.
74
+ - `update`, `updateMany` and `remove` land immediately and roll back on failure.
75
+ - Mutations resolve after the list refresh settles, so a page can close its
76
+ dialog in the same `await`.
77
+ - Repositories receive an `AbortSignal`; honour it or superseded list requests
78
+ can resurrect stale rows.
79
+
80
+ ## Forms
81
+
82
+ ```tsx no-check
83
+ import { createAppForm, fieldError, Form } from '@talelk/newui-data/form'
84
+
85
+ const { form, submitting } = createAppForm({
86
+ defaultValues: { name: '' },
87
+ onSubmit: async (value) => {
88
+ await projects.create.mutateAsync({ name: value.name })
89
+ },
90
+ })
91
+
92
+ <Form form={form}>
93
+ <form.Field
94
+ name="name"
95
+ validators={{
96
+ onChange: ({ value }) =>
97
+ value.trim().length < 2 ? 'Give the project a name.' : undefined,
98
+ }}
99
+ >
100
+ {(field) => (
101
+ <TextInput
102
+ label="Name"
103
+ required
104
+ value={field().state.value}
105
+ error={fieldError(field())}
106
+ onInput={(event) => field().handleChange(event.currentTarget.value)}
107
+ />
108
+ )}
109
+ </form.Field>
110
+ <Button type="submit" loading={submitting()}>
111
+ Create
112
+ </Button>
113
+ </Form>
114
+ ```
115
+
116
+ - `createAppForm` owns TanStack Form and exposes `submitting()` for the button.
117
+ - `Form` sets `noValidate` and prevents the native submit; field messages are the
118
+ error UI.
119
+ - `fieldError` maps TanStack's error list to the single string `Field` takes and
120
+ de-duplicates the same validator message.
121
+ - Pass the same message to `onChange` and `onSubmit` when the field should
122
+ validate on both; `fieldError` will not print it twice.
123
+
124
+ ### Config forms: the field map, pruning and autosave
125
+
126
+ - `createAppForm({ schema, ui, pruneHidden })` takes a Standard Schema and a
127
+ **field map** (`ui`) keyed by *static* paths (`smtp.host`, never `items[1]`
128
+ — that throws; a repeater's row fields go under its `fields`). Pass the same
129
+ object to the `ConfigForm` organism's `fields`.
130
+ - `when(scope, values)` hides a field: `scope` is the form values for a
131
+ top-level entry and **the row** for a repeater's row field. Hidden fields
132
+ are pruned from the submitted document (`pruneHidden` defaults to `true`),
133
+ and schema issues under them never block submit.
134
+ - `app.document(values)` is that submitted document. Give
135
+ `createAutoSave(app, { save, id })` the `createAppForm` result, not
136
+ `app.form`, so autosave writes the same pruned document submit sends.
137
+ - With `id`, autosave keeps a local, unpruned **draft**; a successful autosave
138
+ or submit drops it. `restoreDraft()` is untrusted input (it may predate the
139
+ schema) — reset the form with it and let validation report what no longer
140
+ fits.
141
+
142
+ ## URL state, saved views and transforms
143
+
144
+ ```ts
145
+ import { createConfigStore, createUrlState, rollup } from '@talelk/newui-data'
146
+
147
+ // Link-reproducible state; the app owns the router through `adapter`.
148
+ const filters = createUrlState(
149
+ { 'board.view': 'kanban', q: '' },
150
+ { adapter, debounce: ['q'] },
151
+ )
152
+ filters['board.view']()
153
+ filters.set('q', 'invoice') // undefined = absent, never ""
154
+
155
+ // Saved views and dashboard configs: versioned envelopes, storage-agnostic.
156
+ const views = createConfigStore({ key: 'acme.views' })
157
+ views.save('week-only', { filters: [] }, { type: 'saved-view' })
158
+
159
+ // Chart series from a time column — pure, no query, no components.
160
+ const series = rollup(rows, { field: 'createdAt', unit: 'day', metric: { field: 'amount', metric: 'sum' } })
161
+ ```
162
+
163
+ - `createUrlState` reads the URL once on mount and **replaces** (never pushes);
164
+ without an adapter it is a plain signal, so tests and SSR stay clean.
165
+ - `createConfigStore` documents are capped at 64KB with a dev warning; a
166
+ server-backed adapter drops in by passing `storage`, no consumer changes.
167
+ - `aggregate`/`rollup` run over rows the app already fetched — past that size
168
+ the answer is server-side, not a client pivot.
169
+ - A collection can poll with `refetchInterval`; `connectRealtime` (from
170
+ `@talelk/newui-data/resource`) invalidates query keys from socket events.