@yaks/lens 0.0.0-stage → 0.2.36

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 (54) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +228 -2
  3. package/_dist/compile.d.ts +30 -0
  4. package/_dist/compile.d.ts.map +1 -0
  5. package/_dist/described.d.ts +12 -0
  6. package/_dist/described.d.ts.map +1 -0
  7. package/_dist/document.d.ts +59 -0
  8. package/_dist/document.d.ts.map +1 -0
  9. package/_dist/graph.d.ts +3 -0
  10. package/_dist/graph.d.ts.map +1 -0
  11. package/_dist/mod.d.ts +7 -0
  12. package/_dist/mod.d.ts.map +1 -0
  13. package/_dist/plugin.d.ts +9 -0
  14. package/_dist/plugin.d.ts.map +1 -0
  15. package/_dist/steps.d.ts +10 -0
  16. package/_dist/steps.d.ts.map +1 -0
  17. package/_dist/view.d.ts +40 -0
  18. package/_dist/view.d.ts.map +1 -0
  19. package/_dist/vocab.d.ts +4 -0
  20. package/_dist/vocab.d.ts.map +1 -0
  21. package/compile.js +318 -0
  22. package/compile.js.map +1 -0
  23. package/compile.ts +290 -0
  24. package/deno.json +1 -0
  25. package/described.js +80 -0
  26. package/described.js.map +1 -0
  27. package/described.ts +85 -0
  28. package/document.js +268 -0
  29. package/document.js.map +1 -0
  30. package/document.ts +335 -0
  31. package/graph.js +5 -0
  32. package/graph.js.map +1 -0
  33. package/graph.ts +4 -0
  34. package/mod.js +7 -0
  35. package/mod.js.map +1 -0
  36. package/mod.ts +6 -0
  37. package/package.json +28 -4
  38. package/plugin.js +454 -0
  39. package/plugin.js.map +1 -0
  40. package/plugin.ts +597 -0
  41. package/schema.js +61 -0
  42. package/schema.js.map +1 -0
  43. package/schema.ts +53 -0
  44. package/steps.js +35 -0
  45. package/steps.js.map +1 -0
  46. package/steps.ts +47 -0
  47. package/tools.fixture.json +190 -0
  48. package/view.js +430 -0
  49. package/view.js.map +1 -0
  50. package/view.ts +448 -0
  51. package/vocab.js +11 -0
  52. package/vocab.js.map +1 -0
  53. package/vocab.json +34 -0
  54. package/vocab.ts +8 -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 2026 Jeff Peterson
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,229 @@
1
- # Temporary Holding Version
1
+ # @yaks/lens
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
+ Pure, compiled changes between JSON document versions. `document(ops)` gives
4
+ `put` (old to current) and `get` (current to old). Graph batches add patch and
5
+ read-view semantics through `compile(rows, speaks)`, plus `ask` for old query
6
+ ASTs, `schema` for old vocabulary declarations, and `find` for stored rows still
7
+ carrying old properties. This package owns the private
8
+ `_lens{package, step, ops}` declarations and the graph plugin.
9
+
10
+ | Export | What it offers |
11
+ | --------- | --------------------------------------------------------------------------------------------------------------------------- |
12
+ | `.` | `document`, `documentChain`, `compile`, `lensesIn`, `described`, `versions`, `packageEid`, `history`, `timestamp`, `lenses` |
13
+ | `./vocab` | Private `_lens{package, step, ops}` declarations |
14
+ | `./graph` | The graph's write normalization and read translations |
15
+
16
+ JSON paths use dots, or arrays of keys for names containing dots and array
17
+ indexes. A compiled operation list snapshots its declarations and copies only
18
+ changed document ancestors; inputs and defaults are never mutated. A missing
19
+ path stays missing, and JSON null stays data.
20
+
21
+ | Operation | Forward | Inverse |
22
+ | ------------------------------------ | ---------------------------------------------------------------------------------- | ------------------------- |
23
+ | `rename: {from, to}` | Move a value | Move it back |
24
+ | `hoist: {from, to}` | Move to a shallower path | Plunge |
25
+ | `plunge: {from, to}` | Move to a deeper path | Hoist |
26
+ | `add: {path, default}` | Fill a missing value | Remove that default |
27
+ | `remove: {path, default}` | Remove that default | Fill it back |
28
+ | `concat: {from, to, separator?}` | Join string paths and `{value}` literals | Split |
29
+ | `scatter: {from, to, keyword, key?}` | Spread a map into each destination entry's keyword | Gather |
30
+ | `in: {path, ops}` | Apply operations within existing children, with `*` matching keys or array indexes | Reverse within each child |
31
+
32
+ ```ts
33
+ import { document } from '@yaks/lens'
34
+ import { equal } from '@yaks/testing'
35
+
36
+ let lens = document([
37
+ { rename: { from: 'options.positional', to: 'positional' } },
38
+ {
39
+ scatter: {
40
+ from: 'options.short',
41
+ to: 'input',
42
+ keyword: 'short',
43
+ key: 'value',
44
+ },
45
+ },
46
+ {
47
+ concat: {
48
+ from: ['options.rest', { value: '...' }],
49
+ to: 'positional',
50
+ append: true,
51
+ },
52
+ },
53
+ { remove: { path: 'options', default: {} } },
54
+ ])
55
+ let old = {
56
+ options: { positional: ['app'], rest: 'files', short: { n: 'limit' } },
57
+ input: { limit: { type: 'number' } },
58
+ }
59
+ let current = lens.put(old)
60
+ equal(current, {
61
+ positional: ['app', 'files...'],
62
+ input: { limit: { type: 'number', short: 'n' } },
63
+ })
64
+ equal(lens.get(current), old)
65
+ ```
66
+
67
+ `tools.fixture.json` contains declarations copied from `@yaks/graph`,
68
+ `@yaks/builders` and `@yaks/spawn`: ordinary positional arguments, rest alone,
69
+ and positional/rest/short together. The test applies this change within a whole
70
+ declaration document's `$defs` map and runs it both ways. The declaration format
71
+ change can therefore be expressed by lenses; no platform reader needs that
72
+ change yet.
73
+
74
+ Inverse domains are explicit. Add/remove cannot reconstruct arbitrary removed
75
+ data: removing a value different from its declared default refuses. Concat
76
+ requires strings and a separator between multiple variable parts, and refuses
77
+ values containing that separator; literals allow reversible prefixes/suffixes.
78
+ `append: true` consumes the last matching array entry on inverse, so an ordinary
79
+ positional without a rest suffix remains unchanged. Scatter requires existing
80
+ destination objects and unique gathered keys; `key: 'value'` turns
81
+ `{n: 'limit'}` into `input.limit.short: 'n'`. Conflicting destinations refuse.
82
+ Empty containers survive moves. Inverses canonicalize omitted defaults and empty
83
+ maps/lists rather than inventing metadata to distinguish equivalent empty
84
+ declarations. Hoist/plunge destinations must be strictly shallower/deeper; paths
85
+ cannot contain their own source. Array index moves address the resulting array
86
+ after source consumption; `in` is useful for transforming array entries.
87
+
88
+ Each change has a numeric UTC timestamp, written as `YYYYMMDDHHMMSS` (for
89
+ example, `20261003140000`). Calendar dates are validated; steps need not be
90
+ contiguous or authored in declaration order. A caller speaks one timestamp per
91
+ package, meaning every change up to that timestamp. Translation applies only
92
+ later steps, sorted by timestamp; the inverse runs them in reverse. Steps are
93
+ immutable once landed. Re-stamp a branch's new step before landing if another
94
+ branch has already landed a later timestamp; inserting an earlier step would
95
+ change what an existing timestamp means.
96
+
97
+ For JSON file formats, `documentChain(steps, speaks)` compiles that suffix. An
98
+ omitted `speaks` (or zero) means before all changes. `history(steps).version`
99
+ returns the current timestamp, or zero for an empty history. `document(ops)`
100
+ remains the primitive for one operation list.
101
+
102
+ ```ts
103
+ import { documentChain, history, type Op } from '@yaks/lens'
104
+ import { equal } from '@yaks/testing'
105
+
106
+ let steps: { step: number; ops: Op[] }[] = [
107
+ { step: 20261003140000, ops: [{ rename: { from: 'title', to: 'name' } }] },
108
+ { step: 20261004102000, ops: [{ rename: { from: 'name', to: 'heading' } }] },
109
+ ]
110
+ let lens = documentChain(steps, 20261003140000)
111
+ equal(lens.put({ name: 'Cake' }), { heading: 'Cake' })
112
+ equal(lens.get({ heading: 'Cake' }), { name: 'Cake' })
113
+ equal(history(steps).version, 20261004102000)
114
+ ```
115
+
116
+ The graph stores steps as `_lens` rows and authors them with `lensesIn`. That
117
+ registration accepts graph renames and declared component views. Declaration
118
+ documents use the JSON operation lists above and require no graph rows. Graph
119
+ and JSON histories share the timestamp ordering and cutoff rules; JSON file
120
+ changes remain independent of graph component views.
121
+
122
+ A graph change can rename a comp.prop or retire a component with a declared
123
+ view. A declaring vocabulary carries its package name and an ordinary `$defs`
124
+ entry:
125
+
126
+ ```ts
127
+ import { compile, lensesIn, versions } from '@yaks/lens'
128
+
129
+ let docs = [{
130
+ label: 'kitchen',
131
+ $defs: {
132
+ title: {
133
+ lens: true,
134
+ step: 20261003140000,
135
+ ops: [
136
+ { rename: { from: 'recipe.title', to: 'doc.title' } },
137
+ ],
138
+ },
139
+ },
140
+ }]
141
+ let lens = compile(lensesIn(docs))
142
+ lens.put([{ entity: { eid: 'cake' }, recipe: { title: 'Cake' } }])
143
+ // [{ entity: { eid: 'cake' }, recipe: {}, doc: { title: 'Cake' } }]
144
+ Object.values(versions(docs)) // [20261003140000]
145
+ ```
146
+
147
+ `lensesIn` reads entries ignored by `loadVocab`, derives the namespace's row
148
+ (@yaks/vocab `labelled`) and step identities, and validates each package's
149
+ timestamp history. `described` produces missing rows. Steps are append-only:
150
+ changing operations at an existing step or inserting a new step before a
151
+ retained later step refuses instead of reinterpreting an old caller.
152
+ `compile(rows, speaks)` composes the remaining steps and caches against their
153
+ content and the package version map. Without `speaks` it starts at zero, for the
154
+ mover. With current versions it returns identity functions.
155
+
156
+ The plugin declares `$speaks`, a package-eid to latest-timestamp map on writes.
157
+ Reads carry the same map in `ReadOpts.speaks`. No map means current: without
158
+ pending component views, normalization returns the exact inputs and reads no
159
+ rows. Pending views expand stored sources for current callers, including
160
+ version-pinned pages, until the mover consumes them.
161
+
162
+ Landed pilot histories retain their original contiguous steps `0..n-1` and count
163
+ versions `0..n` so deployed clients keep answering. A package may append
164
+ timestamp steps after those retained steps; its current version then becomes the
165
+ greatest timestamp. A pilot count still selects its original suffix plus all
166
+ later timestamp steps. New declarations use timestamps.
167
+
168
+ For a rename, Omission is preserved, null clears a property, and moving a
169
+ property retains `recipe{}`. Removing the source aspect clears its moved
170
+ property without deleting the target's unrelated properties. Conflicting writes
171
+ to both names refuse before storing anything; `$was` preconditions translate by
172
+ the same mapping. Old reads copy `doc.title` back only onto entities carrying
173
+ `recipe{}`; `doc.title` remains readable because it existed in the old
174
+ vocabulary too. Raw subscription patches carry `ReadOpts.patch`: the adapter
175
+ reads stored source membership, without copying other stored properties, and
176
+ translates target removals into alias clears. A within-component rename removes
177
+ its replacement from the old view. For a subscription patch,
178
+ `get([patch], {facts: [held], patch: true})` uses the held row only to learn
179
+ whether an omitted source component exists; it never copies held properties.
180
+ Explicit source component removal stays a removal, and destination component
181
+ removal clears the old aliased property.
182
+
183
+ The mover uses `find` and `put`, explicitly clearing the old stored property
184
+ through its expanded vocabulary. `sources` names consumed properties and
185
+ excludes a name a later step restores; `find(admits)` skips sources that earlier
186
+ steps have already removed. A patch translation alone cannot clear a column the
187
+ new vocabulary no longer admits. The mover expands the vocabulary while rows
188
+ still carry that property, then drops the old column as soon as no rows need it.
189
+ The immutable lens chain remains in the graph: old reads and writes translate at
190
+ its boundaries even though the source property is no longer declared. A rollback
191
+ serves older code with the newest vocabulary and retained chain, so it does not
192
+ reintroduce the old column. This package owns neither storage movement nor kept
193
+ app versions, reload policy, rollback decisions, envelopes or tool arguments.
194
+
195
+ An op list expresses direction and patch consumption. Declared graph rules can
196
+ copy a value after admission, but do not clear or consume it, and do not invert.
197
+ Relations could give both directions one definition; they would still need
198
+ omission/null semantics, a compiled mode for speed, and query rewriting. The
199
+ pilot ships no dependency on `@yaks/logic`. Grammar routing such as bare `.eid=`
200
+ stays at its door. Query rewriting for the document operations beyond rename is
201
+ outside this pilot: their inverses transform documents, while the graph adapter
202
+ uses graph renames and declared component views.
203
+
204
+ A `view` operation retires a whole component while preserving its old doors. It
205
+ declares `from`, the old `declaration`, a canonical membership `match`, and
206
+ `props`. Each property maps to a canonical `path` (optionally converting ISO
207
+ strings to numeric milliseconds with `convert: "milliseconds"`), an explicit
208
+ `retired` default, or an `ack` relation naming a request `component`, its source
209
+ `ref`, the companion `mark`, and the deterministic latest-row `order` path. An
210
+ omitted acknowledgement preserves it; null clears the represented marks; a
211
+ non-null write marks only a request addressed to the source entity.
212
+
213
+ The graph interface translates whole changes: `put(bundles, {facts, vocab})` can
214
+ emit patches on more than one entity, and `get(bundles, {facts, vocab})` can
215
+ reconstruct a virtual source from related entities. The graph shell supplies
216
+ facts and repeats translation inside the write transaction. The core validates
217
+ old `$was` values against the old view and emits canonical transaction guards. A
218
+ graph read view selects canonical candidates, reconstructs whole old bundles,
219
+ then runs the caller's original query, projections and aggregates with its old
220
+ schema and supplied moment. Subscriptions include the relation's dependencies.
221
+
222
+ View sources are whole component names in `sources`; contracting one removes its
223
+ membership too. During expansion, unmoved source rows reconstruct through the
224
+ same pure migration for current and old reads. Normal partial writes consume a
225
+ pending source atomically, preserving its other values and historical marks;
226
+ explicit clears consume it too, so old data cannot reappear. Migration mode
227
+ preserves an equal or newer canonical saved moment and existing marks, and uses
228
+ the source's historical attribution for an acknowledged request. A lens step
229
+ with `live: false` remains rehearsal-only in the hosted mover.
@@ -0,0 +1,30 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { VocabDoc } from "@yaks/vocab";
3
+ import { type ComponentView, type Facts } from "./view.js";
4
+ import { type Query } from "@yaks/query";
5
+ /** A caller's latest step timestamp, keyed by the declaring package's eid. */ export type Speaks = Record<string, number>;
6
+ /** The pilot's single operation. Paths name a component and one property. */ export type Rename = {
7
+ rename: {
8
+ from: string;
9
+ to: string;
10
+ };
11
+ };
12
+ export type ViewOp = {
13
+ view: ComponentView;
14
+ };
15
+ export type GraphOp = Rename | ViewOp;
16
+ /** The pure directions of a compiled vocabulary change. */ export type Lens = {
17
+ put: (bundles: Bundle[], ctx?: Facts) => Bundle[];
18
+ get: (bundles: Bundle[], ctx?: Facts) => Bundle[];
19
+ renames: readonly Rename[];
20
+ views: readonly ComponentView[];
21
+ dependencies: readonly string[];
22
+ ask: (query: Query) => Query;
23
+ /** Consumed source properties, excluding names a later step restores. */ sources: readonly string[];
24
+ /** Stored sources still admitted after earlier migrations contracted. */ find: (admits?: (path: string) => boolean) => Query;
25
+ /** The property declarations an old caller's local graph admits. */ schema: (docs: VocabDoc[]) => VocabDoc[];
26
+ };
27
+ /** Compile stored `_lens` rows once. Missing `speaks` means before all steps
28
+ * for moving stored rows; a plugin bypasses compilation for current callers.
29
+ * Each package's immutable timestamp steps run in order. */ export declare let compile: (rows: Bundle[], speaks?: Speaks) => Lens;
30
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sources":["../compile.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,2BAAsC;AAC1D,cAAc,QAAQ,2BAAgC;AACtD,SACE,KAAK,aAAa,EAClB,KAAK,KAAK,oBAKM;AAIlB,SAOE,KAAK,KAAK,2BAEmB;AAE/B,4EAA4E,GAC5E,YAAY,SAAS,OAAO,MAAM,EAAE,MAAM;AAC1C,2EAA2E,GAC3E,YAAY;EAAW;IAAU,MAAM,MAAM;IAAE,IAAI,MAAM;;;AACzD,YAAY;EAAW,MAAM;;AAC7B,YAAY,UAAU,SAAS;AAC/B,yDAAyD,GACzD,YAAY;EACV,MAAM,SAAS,UAAU,MAAM,UAAU;EACzC,MAAM,SAAS,UAAU,MAAM,UAAU;EACzC,kBAAkB;EAClB,gBAAgB;EAChB,uBAAuB,MAAM;EAC7B,MAAM,OAAO,UAAU;EACvB,uEAAuE,GACvE,kBAAkB,MAAM;EACxB,uEAAuE,GACvE,OAAO,UAAU,MAAM,MAAM,KAAK,OAAO,KAAK;EAC9C,kEAAkE,GAClE,SAAS,MAAM,eAAe;;AAwFhC;;0DAE0D,GAC1D,OAAO,YAAI,UAAW,MAAM,UAAU,SAAS,WAAS,KA2JvD"}
@@ -0,0 +1,12 @@
1
+ import type { Bundle, Graph } from "@yaks/graph";
2
+ import { type VocabDoc } from "@yaks/vocab";
3
+ import { type Speaks } from "./compile.js";
4
+ /** The `_namespace{name}` row of a namespace without a `$id`, by its label
5
+ * (@yaks/vocab `labelled`): what a `_lens` names and a page's `$speaks` keys. */ export declare let packageEid: (name: string) => string;
6
+ /** Authored `$defs` lens entries as private `_lens{package, step, ops}` rows.
7
+ * A document must carry its namespace's label. Components and other entries
8
+ * are left to their own readers. */ export declare let lensesIn: (docs: VocabDoc[]) => Bundle[];
9
+ /** The latest step timestamp a set of declaring documents speaks. */ export declare let versions: (docs: VocabDoc[]) => Speaks;
10
+ /** Missing rows the served vocabulary declares. Steps are append-only:
11
+ * reusing one with different operations refuses, including on rollback. */ export declare let described: (g: Graph, docs: VocabDoc[]) => Promise<Bundle[]>;
12
+ //# sourceMappingURL=described.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"described.d.ts","sources":["../described.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,EAAQ,KAAK,2BAAgC;AAEjE,SAAmB,KAAK,QAAQ,2BAAgC;AAChE,SAAkB,KAAK,MAAM,uBAAsB;AAGnD;+EAC+E,GAC/E,OAAO,YAAI,aAAa,MAAM,MAAM,KAAK,MAAM,CAAiC;AAEhF;;kCAEkC,GAClC,OAAO,YAAI,WAAY,MAAM,eAAa,SAiBzC;AAED,mEAAmE,GACnE,OAAO,YAAI,WAAY,MAAM,eAAa,OAazC;AAED;yEACyE,GACzE,OAAO,YAAI,YACT,GAAG,OACH,MAAM,eACL,QAAQ,UA+BV"}
@@ -0,0 +1,59 @@
1
+ /** JSON documents have no graph vocabulary, storage or effects. */ export type Json = null | boolean | number | string | Json[] | {
2
+ [key: string]: Json;
3
+ };
4
+ /** Dotted paths are convenient; arrays preserve keys containing dots. */ export type Path = string | readonly (string | number)[];
5
+ type Move = {
6
+ from: Path;
7
+ to: Path;
8
+ };
9
+ type Default = {
10
+ path: Path;
11
+ default: Json;
12
+ };
13
+ type Part = Path | {
14
+ value: string;
15
+ };
16
+ export type Op = {
17
+ rename: Move;
18
+ } | {
19
+ hoist: Move;
20
+ } | {
21
+ plunge: Move;
22
+ } | {
23
+ add: Default;
24
+ } | {
25
+ remove: Default;
26
+ } | {
27
+ concat: {
28
+ from: readonly Part[];
29
+ to: Path;
30
+ separator?: string;
31
+ /** Append the joined string to a list; inverse consumes its last item. */ append?: boolean;
32
+ };
33
+ } | {
34
+ scatter: {
35
+ from: Path;
36
+ to: Path;
37
+ keyword: string;
38
+ /** A short-name map keys its destination by the entry's value. */ key?: 'name' | 'value';
39
+ };
40
+ } | {
41
+ in: {
42
+ path: Path;
43
+ ops: readonly Op[];
44
+ };
45
+ };
46
+ export type DocumentLens = {
47
+ put: <T extends Json>(value: T) => Json;
48
+ get: <T extends Json>(value: T) => Json;
49
+ };
50
+ /** Compile a reversible JSON document change once. Omitted paths stay omitted;
51
+ * null is data. Add/remove invert within their declared default, concat within
52
+ * its delimiter, and scatter within the map's unique keys. Empty containers
53
+ * survive moves; defaults and empty maps/lists have a canonical inverse. */ export declare let document: (ops: readonly Op[]) => DocumentLens;
54
+ /** Compile the timestamp suffix of a JSON format's declared changes. Zero
55
+ * speaks before all changes, including when the argument is omitted. */ export declare let documentChain: (steps: readonly {
56
+ step: number;
57
+ ops: readonly Op[];
58
+ }[], speaks?: number) => DocumentLens;
59
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sources":["../document.ts"],"names":[],"mappings":"AAEA,iEAAiE,GACjE,YAAY,OAAO,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG;GACnD,KAAK,MAAM,GAAG;;AAEjB,uEAAuE,GACvE,YAAY,OAAO,MAAM,aAAa,MAAM,GAAG,MAAM;KAChD;EAAS,MAAM;EAAM,IAAI;;KACzB;EAAY,MAAM;EAAM,SAAS;;KACjC,OAAO;EAAS,OAAO,MAAM;;AAClC,YAAY;EACN,QAAQ;;EACR,OAAO;;EACP,QAAQ;;EACR,KAAK;;EACL,QAAQ;;EAEV;IACE,eAAe;IACf,IAAI;IACJ,YAAY,MAAM;IAClB,wEAAwE,GACxE,SAAS,OAAO;;;EAIlB;IACE,MAAM;IACN,IAAI;IACJ,SAAS,MAAM;IACf,gEAAgE,GAChE,MAAM,SAAS;;;EAGf;IAAM,MAAM;IAAM,cAAc;;;AACtC,YAAY;EACV,MAAM,UAAU,MAAM,OAAO,MAAM;EACnC,MAAM,UAAU,MAAM,OAAO,MAAM;;AAsRrC;;;0EAG0E,GAC1E,OAAO,YAAI,WAAY,cAAc,SAAO,aAM3C;AAED;sEACsE,GACtE,OAAO,YAAI,gBACT;EAAkB,MAAM,MAAM;EAAE,cAAc;KAC9C,oBACC,aACwE"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "@yaks/graph";
2
+ /** The rename vocabulary and translation hooks. */ export declare let plugins: () => Plugin[];
3
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,2BAAgC;AAEpD,iDAAiD,GACjD,OAAO,YAAI,eAAc,SAAsB"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./document.js";
2
+ export * from "./compile.js";
3
+ export * from "./described.js";
4
+ export * from "./plugin.js";
5
+ export * from "./steps.js";
6
+ export * from "./view.js";
7
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA,8BAA6B;AAC7B,6BAA4B;AAC5B,+BAA8B;AAC9B,4BAA2B;AAC3B,2BAA0B;AAC1B,0BAAyB"}
@@ -0,0 +1,9 @@
1
+ import type { Bundle, Plugin } from "@yaks/graph";
2
+ import { type Vocab } from "@yaks/vocab";
3
+ import { type Speaks } from "./compile.js";
4
+ export declare let lenses: (report?: (error: unknown) => void, pending?: {
5
+ vocab: Vocab;
6
+ rows: Bundle[];
7
+ speaks?: Speaks;
8
+ }) => Plugin;
9
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sources":["../plugin.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,EAAE,MAAM,2BAAgC;AAI5D,SAAoB,KAAK,KAAK,2BAAgC;AAC9D,SAA6B,KAAK,MAAM,uBAAsB;AAmF9D,OAAO,YAAI,SACT,UAAS,OAAO,OAAO,KAAK,IAAI,EAChC;EAAY,OAAO;EAAO,MAAM;EAAU,SAAS;MAClD,OAyfF"}
@@ -0,0 +1,10 @@
1
+ /** Rails-style UTC timestamps, written as YYYYMMDDHHMMSS. */ export declare let timestamp: (value: unknown) => value is number;
2
+ /** Validate and order a package's history, retaining the pilot's landed
3
+ * zero-based steps and count versions. New histories use timestamps. */ export declare let history: <T extends {
4
+ step: number;
5
+ }>(declarations: readonly T[], speaks?: number) => {
6
+ steps: T[];
7
+ version: number;
8
+ remaining: T[];
9
+ };
10
+ //# sourceMappingURL=steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.d.ts","sources":["../steps.ts"],"names":[],"mappings":"AAAA,2DAA2D,GAC3D,OAAO,YAAI,YAAa,OAAO,OAAO,KAAG,SAAS,MAAM,CASvD;AAED;sEACsE,GACtE,OAAO,YAAI,UAAW;EAAY,MAAM,MAAM;GAC5C,uBAAuB,KACvB,SAAS,MAAM;EACZ,OAAO;EAAK,SAAS,MAAM;EAAE,WAAW;EA6B5C"}
@@ -0,0 +1,40 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { PropSchema, Vocab } from "@yaks/vocab";
3
+ /** A scalar view has one canonical path, a retired default, or a referenced mark. */ export type ViewProp = {
4
+ path: string;
5
+ convert?: 'milliseconds';
6
+ } | {
7
+ retired: unknown;
8
+ } | {
9
+ ack: {
10
+ component: string;
11
+ ref: string;
12
+ mark: string;
13
+ order: string;
14
+ };
15
+ };
16
+ export type ComponentView = {
17
+ from: string;
18
+ declaration: PropSchema;
19
+ match: string;
20
+ props: Record<string, ViewProp>;
21
+ };
22
+ /** Facts are supplied by the graph boundary; compiled translations perform no I/O. */ export type Facts = {
23
+ facts?: Bundle[];
24
+ vocab?: Vocab;
25
+ now?: number;
26
+ patch?: boolean;
27
+ migrate?: boolean;
28
+ canonical?: boolean;
29
+ };
30
+ export declare let viewSources: (view: ComponentView) => string[];
31
+ export declare let viewDependencies: (view: ComponentView) => string[];
32
+ export declare let validateView: (v: ComponentView) => void;
33
+ export declare let getViews: (rows: Bundle[], views: ComponentView[], ctx?: Facts) => Bundle[];
34
+ /** Whole-change translation allows an old property to write a referenced entity.
35
+ * Every generated patch retains the source actor and canonical preconditions. */ export declare let putViews: (rows: Bundle[], views: ComponentView[], ctx?: Facts) => Bundle[];
36
+ /** A normal write consumes any pending source it depends on. Partial writes
37
+ * first carry the whole canonical fact across; clearing a view cannot revive
38
+ * the old stored value on the next read. The shell preserves generated historic
39
+ * stamps after admission, never stamps supplied by the caller. */ export declare let stageViews: (rows: Bundle[], views: ComponentView[], ctx?: Facts) => Bundle[];
40
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sources":["../view.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,2BAAsC;AAK1D,cAAc,UAAU,EAAE,KAAK,2BAAgC;AAE/D,mFAAmF,GACnF,YAAY;EACN,MAAM,MAAM;EAAE,UAAU;;EACxB,SAAS,OAAO;;EAChB;IAAO,WAAW,MAAM;IAAE,KAAK,MAAM;IAAE,MAAM,MAAM;IAAE,OAAO,MAAM;;;AACxE,YAAY;EACV,MAAM,MAAM;EACZ,aAAa;EACb,OAAO,MAAM;EACb,OAAO,OAAO,MAAM,EAAE;;AAExB,oFAAoF,GACpF,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,MAAM,MAAM;EACZ,QAAQ,OAAO;EACf,UAAU,OAAO;EACjB,YAAY,OAAO;;AAyCrB,OAAO,YAAI,cAAe,MAAM,kBAAgB,MAAM,GAAiB;AACvE,OAAO,YAAI,mBAAoB,MAAM,kBAAgB,MAAM,GAa1D;AACD,OAAO,YAAI,eAAgB,GAAG,kBAAgB,IAAI,CA2BjD;AAED,OAAO,YAAI,WACT,MAAM,UACN,OAAO,iBACP,MAAK,UACJ,SAyEF;AAYD;+EAC+E,GAC/E,OAAO,YAAI,WACT,MAAM,UACN,OAAO,iBACP,MAAK,UACJ,SAoHF;AAED;;;gEAGgE,GAChE,OAAO,YAAI,aACT,MAAM,UACN,OAAO,iBACP,MAAK,UACJ,SAoHF"}
@@ -0,0 +1,4 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ /** The private `_lens{package, step, ops}` vocabulary. */ export declare let docs: VocabDoc[];
3
+ /** This package's description, from its manifest. */ export declare let description: string;
4
+ //# sourceMappingURL=vocab.d.ts.map