@yaks/reach 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.
- package/LICENSE +202 -0
- package/README.md +97 -2
- package/_dist/mod.d.ts +171 -0
- package/_dist/mod.d.ts.map +1 -0
- package/deno.json +1 -0
- package/mod.js +1297 -0
- package/mod.js.map +1 -0
- package/mod.ts +1520 -0
- package/package.json +23 -4
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,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yaks/reach
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A graph made of graphs. An eid names one entity everywhere, so a book one graph
|
|
4
|
+
holds and a loan another holds about it are one entity wearing two components.
|
|
5
|
+
@yaks/reach asks a question of several graphs at once and answers it as one
|
|
6
|
+
bundle per eid, and splits a write so each component lands in the graph its word
|
|
7
|
+
lives in. yaks.app reads and writes across a person's apps this way, one member
|
|
8
|
+
per app's store (workers/yak/reach.ts).
|
|
9
|
+
|
|
10
|
+
## Members
|
|
11
|
+
|
|
12
|
+
A **member** is a value (`Member`):
|
|
13
|
+
|
|
14
|
+
- `at`: where it is, the name a merged bundle gives a component's home;
|
|
15
|
+
- `read(line, {said, live})`: the bundles a filter line selects, or a reduction
|
|
16
|
+
such as `{count}`. It throws to refuse;
|
|
17
|
+
- `apply(bundles, check)`: the batch as applied, or rehearsed and kept nowhere
|
|
18
|
+
when `check` is set;
|
|
19
|
+
- `vocab()`: the words it declares as its own;
|
|
20
|
+
- `space`, `name` and `sandboxed`, optional: the members whose words agree on
|
|
21
|
+
their shapes, what a caller calls it, and whether it takes only the writes
|
|
22
|
+
aimed at it;
|
|
23
|
+
- `remote`, optional: a graph other than the caller's own, such as another host,
|
|
24
|
+
whose pieces a bundle always names in `_stores`.
|
|
25
|
+
|
|
26
|
+
Where a member runs (a Durable Object, a remote host, a graph in memory) is the
|
|
27
|
+
caller's business.
|
|
28
|
+
|
|
29
|
+
## Use
|
|
30
|
+
|
|
31
|
+
`reach(words)` gives the operations over any set of members. `words.core` is the
|
|
32
|
+
vocabulary every member speaks; `union`, `hidden` and `silent` are optional (the
|
|
33
|
+
members' words as one vocabulary, a listing rule's hidden components, and a
|
|
34
|
+
report of a member left out of a read).
|
|
35
|
+
|
|
36
|
+
```ts ignore
|
|
37
|
+
import { reach } from '@yaks/reach'
|
|
38
|
+
import { loadVocab } from '@yaks/vocab'
|
|
39
|
+
|
|
40
|
+
const fan = reach({ core: loadVocab([]) })
|
|
41
|
+
const bundles = await fan.read(members, '.book&?loan')
|
|
42
|
+
await fan.written(members, undefined, [
|
|
43
|
+
{ entity: { eid: 'dune' }, book: { pages: 412 }, loan: { to: 'Ann' } },
|
|
44
|
+
])
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Reads
|
|
48
|
+
|
|
49
|
+
With one member, a read is that member's own answer. With several:
|
|
50
|
+
|
|
51
|
+
1. The line is cut on its `&` seams into one part per component named, and each
|
|
52
|
+
part is asked of the members that declare that word (every member, for a word
|
|
53
|
+
none declares).
|
|
54
|
+
2. Conjunctions intersect matching eids. Disjunctions (`|`) take the union
|
|
55
|
+
across alternatives before counting or applying a result window. A part that
|
|
56
|
+
only asks for a component (`?loan`) is fetched, never intersected.
|
|
57
|
+
3. Each eid is gathered from every member and composed into one bundle. The
|
|
58
|
+
first member in reach order to answer a component owns it, and the first to
|
|
59
|
+
hold the entity gives its spine. `_stores` names each component's home when a
|
|
60
|
+
bundle spans two members or wears a remote member's piece, and names
|
|
61
|
+
`entity`'s home too when the spine, and so its `num`, is a remote member's: a
|
|
62
|
+
`num` is its store's own (@yaks/id), so `homeOf(bundle)` says whose it is,
|
|
63
|
+
and the yak CLI shows it as `T-12@yaks.app`. A member that is itself composed
|
|
64
|
+
(yaks.app across its stores) has its own `_stores` said within it, as
|
|
65
|
+
`yaks.app/nora/lending`.
|
|
66
|
+
|
|
67
|
+
Ranked hits interleave member by member. An `.order=` and its window run over
|
|
68
|
+
the merged bundles with @yaks/match, in the union of the members' words, since
|
|
69
|
+
the property sorted by may live in another member. `.count` counts the composed
|
|
70
|
+
set. A word two spaces declare with different properties is two words, so a
|
|
71
|
+
bundle wearing both is answered once per space.
|
|
72
|
+
|
|
73
|
+
A member that refuses or fails is left out of the answer, and reported through
|
|
74
|
+
`silent`. One that answers 503 fails the read, and so does a line every member
|
|
75
|
+
refuses.
|
|
76
|
+
|
|
77
|
+
`watch` is the read, live. With one member it is that member's own watch; with
|
|
78
|
+
several, each member watching its part of the line sends news, and the line is
|
|
79
|
+
read again, whole, and sent with `reset` when it moved. A member's frames say
|
|
80
|
+
its store's revision as one number; a watch says each under the member's `at`
|
|
81
|
+
(`named`), and a read again says the newest each member's news had said when it
|
|
82
|
+
began, which its rows are no older than.
|
|
83
|
+
|
|
84
|
+
## Writes
|
|
85
|
+
|
|
86
|
+
`routed` splits a batch into one part per member. Every `$alias` is minted once
|
|
87
|
+
for all of them, so a bundle landing in two members lands under one eid. A
|
|
88
|
+
component goes to the member that declares its word (the one already holding it,
|
|
89
|
+
else the named one, else the first declarer). A word no member declares goes to
|
|
90
|
+
the named member, the one already holding it, or the member whose own words are
|
|
91
|
+
in the same bundle. A core word is one no member declares, even a member that
|
|
92
|
+
held it before the core said it. A death goes to every member holding the
|
|
93
|
+
entity. A write aimed at a named member stays in that member's space: no part
|
|
94
|
+
goes to a member of another space, whatever it declares or holds.
|
|
95
|
+
|
|
96
|
+
`written` rehearses every part, then commits them. A refusal in the rehearsal
|
|
97
|
+
leaves every member unwritten; one after it is marked `partial`, because another
|
|
98
|
+
part may have committed.
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Bundle } from "@yaks/graph";
|
|
2
|
+
import { type PropSchema, type Vocab, type VocabDoc } from "@yaks/vocab";
|
|
3
|
+
/** One graph in the composition. */ export type Member = {
|
|
4
|
+
/** What a merged bundle names as a component's home (`_stores`). */ at: string;
|
|
5
|
+
/** What a caller calls it when asked to choose one. Defaults to `at`. */ name?: string;
|
|
6
|
+
/** The members whose words agree on their shapes: a word two spaces
|
|
7
|
+
* declare with different properties is two words (`apartIn`). Defaults to
|
|
8
|
+
* `at`. */ space?: string;
|
|
9
|
+
/** The bundles a filter line selects, or a reduction (`{count}`). `said`
|
|
10
|
+
* is the line the caller asked, which this member's answer is shaped by
|
|
11
|
+
* when it was asked only a part of it. Throws to refuse. */ read: (line: string, opts?: {
|
|
12
|
+
said?: string;
|
|
13
|
+
live?: boolean;
|
|
14
|
+
}) => Promise<unknown>;
|
|
15
|
+
/** The batch as applied; `check` rehearses it and keeps nothing. */ apply: (bundles: Bundle[], check: boolean) => Promise<Bundle[]>;
|
|
16
|
+
/** The words this member declares as its own. */ vocab: () => Promise<VocabDoc>;
|
|
17
|
+
/** Watch a line live: `sink` is sent each frame the answer moves by, in
|
|
18
|
+
* the frames @yaks/api's subscriptions speak. Returns what stops it. A
|
|
19
|
+
* member without one is read, and never heard from again. */ watch?: (line: string, sink: (frame: Frame) => void) => () => void;
|
|
20
|
+
/** A copy that takes only the writes aimed at it. */ sandboxed?: boolean;
|
|
21
|
+
/** A graph other than the caller's own, such as another host: a bundle
|
|
22
|
+
* wearing any piece of it says so in `_stores`, and names it as the home of
|
|
23
|
+
* `entity` when the spine came from it, since a `num` is its store's own. */ remote?: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** Where a bundle's `entity`, and so its `num`, lives when that is a remote
|
|
26
|
+
* member rather than the caller's own graph (`_stores.entity`). A `num` is
|
|
27
|
+
* its store's own, so one from elsewhere is shown with its home.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { homeOf } from '@yaks/reach'
|
|
31
|
+
* import { assertEquals } from '@std/assert'
|
|
32
|
+
*
|
|
33
|
+
* let eid = 'a3f19c02-4b00-4000-8000-000000000001'
|
|
34
|
+
* assertEquals(
|
|
35
|
+
* homeOf({ entity: { eid, num: 12 }, _stores: { entity: 'yaks.app' } }),
|
|
36
|
+
* 'yaks.app',
|
|
37
|
+
* )
|
|
38
|
+
* assertEquals(homeOf({ entity: { eid, num: 5 } }), undefined)
|
|
39
|
+
* ```
|
|
40
|
+
*/ export declare let homeOf: (b: Bundle) => string | undefined;
|
|
41
|
+
/** A frame of a live watch, as @yaks/api's subscriptions send one: rows
|
|
42
|
+
* (all of them with `reset`) and the eids `gone`, a reduction (`count`,
|
|
43
|
+
* `tally`, `distinct`), or the error the line was refused with. `revision`
|
|
44
|
+
* is the store's revision the rows were read at, and `since` the one the
|
|
45
|
+
* frame before it said: one number from a member, and from a watch, each
|
|
46
|
+
* member's under its `at` ({@link named}). */ export type Frame = {
|
|
47
|
+
bundles?: Bundle[];
|
|
48
|
+
gone?: string[];
|
|
49
|
+
reset?: boolean;
|
|
50
|
+
refused?: unknown;
|
|
51
|
+
revision?: number | Record<string, number>;
|
|
52
|
+
since?: number | Record<string, number>;
|
|
53
|
+
[more: string]: unknown;
|
|
54
|
+
};
|
|
55
|
+
/** A member's frame as a watch says it: its revisions under the member's
|
|
56
|
+
* `at`, since a revision orders one store's frames and no other's.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { named } from '@yaks/reach'
|
|
60
|
+
* import { assertEquals } from '@std/assert'
|
|
61
|
+
*
|
|
62
|
+
* assertEquals(
|
|
63
|
+
* named({ bundles: [], revision: 7, since: 6 }, 'home/books'),
|
|
64
|
+
* { bundles: [], revision: { 'home/books': 7 }, since: { 'home/books': 6 } },
|
|
65
|
+
* )
|
|
66
|
+
* ```
|
|
67
|
+
*/ export declare let named: (frame: Frame, at: string) => Frame;
|
|
68
|
+
/** The language every member shares, and how the composition reports. */ export type Words = {
|
|
69
|
+
/** The words every member speaks. A word outside it was declared by a
|
|
70
|
+
* member, which makes it the most specific thing said about a row. */ core: Vocab;
|
|
71
|
+
/** The members' own words as one vocabulary: `defs` is each word once,
|
|
72
|
+
* from its first declarer, and `docs` is every member's document. Defaults
|
|
73
|
+
* to `core` with `defs` beneath it. */ union?: (defs: Record<string, PropSchema>, docs: VocabDoc[]) => Vocab;
|
|
74
|
+
/** Whether a member's answer to `line` leaves `comp` off (a listing rule's
|
|
75
|
+
* stamps), so a component fetched only to order by leaves with it. */ hidden?: (comp: string, line: string) => boolean;
|
|
76
|
+
/** A member left out of a read because it refused or failed. */ silent?: (error: unknown, member: Member) => void;
|
|
77
|
+
/** Whether a member's failure fails the whole read rather than leaving the
|
|
78
|
+
* member out: it holds rows it could not send, such as a page over its
|
|
79
|
+
* read budget, so an answer without them would be short. */ stops?: (error: unknown) => boolean;
|
|
80
|
+
};
|
|
81
|
+
/** A filter line cut into parts: the segments that name each component, and
|
|
82
|
+
* the ones that ride with every part. A part whose every segment is a request
|
|
83
|
+
* (`?loan`) narrows nothing: it asks for the component, so it is fetched and
|
|
84
|
+
* never intersected.
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { assertEquals } from '@std/assert'
|
|
88
|
+
* let { parts, global } = split('.book&?loan&.limit=5')
|
|
89
|
+
* assertEquals([...parts.keys()], ['book', 'loan'])
|
|
90
|
+
* assertEquals(parts.get('loan')?.asks, true)
|
|
91
|
+
* assertEquals(global, ['.limit=5'])
|
|
92
|
+
* ```
|
|
93
|
+
*/ export declare let split: (line: string) => {
|
|
94
|
+
parts: Map<string, {
|
|
95
|
+
segs: string[];
|
|
96
|
+
asks: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
global: string[];
|
|
99
|
+
};
|
|
100
|
+
/** The words a line names that another member keeps (`uses`, word → its
|
|
101
|
+
* home), in the line's order.
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { assertEquals } from '@std/assert'
|
|
105
|
+
* assertEquals(borrowed('.fire&?doc&.ash', { ash: 'a', fire: 'b' }), [
|
|
106
|
+
* 'fire',
|
|
107
|
+
* 'ash',
|
|
108
|
+
* ])
|
|
109
|
+
* assertEquals(borrowed('.constructor', {}), [])
|
|
110
|
+
* ```
|
|
111
|
+
*/ export declare let borrowed: (line: string, uses: Record<string, string>) => string[];
|
|
112
|
+
/** Whether a line names a word another member keeps, which one member cannot
|
|
113
|
+
* answer alone.
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* import { assertEquals } from '@std/assert'
|
|
117
|
+
* assertEquals(borrows('.fire&?doc', { fire: 'probe' }), true)
|
|
118
|
+
* assertEquals(borrows('.doc&.limit=5', { fire: 'probe' }), false)
|
|
119
|
+
* ```
|
|
120
|
+
*/ export declare let borrows: (line: string, uses: Record<string, string>) => boolean;
|
|
121
|
+
/** A page speaks each borrowed component as its home declares it. A draft's
|
|
122
|
+
* own documents can still carry the declaration from its source manifest. */ export declare let withBorrowedDocs: (own: VocabDoc[], homes: VocabDoc[]) => VocabDoc[];
|
|
123
|
+
/** What the caller asked, which the gather would otherwise lose: the
|
|
124
|
+
* components the answer keeps (`want`), the words two spaces mean two things
|
|
125
|
+
* by (`apart`), the line a member's answer is shaped by (`said`), and the
|
|
126
|
+
* words the filter required (`must`), which is what names the kind. */ export type Ask = {
|
|
127
|
+
want?: Set<string> | null;
|
|
128
|
+
apart?: Set<string>;
|
|
129
|
+
said?: string;
|
|
130
|
+
must?: string[];
|
|
131
|
+
live?: boolean;
|
|
132
|
+
};
|
|
133
|
+
/** Which members declare which word, the words two spaces mean two things
|
|
134
|
+
* by, and the union of every member's words. */ export type Spoken = {
|
|
135
|
+
words: Map<string, Member[]>;
|
|
136
|
+
apart: Set<string>;
|
|
137
|
+
vocab: Vocab;
|
|
138
|
+
};
|
|
139
|
+
/** A write cut into one part per member it lands in, and the eid each
|
|
140
|
+
* `$alias` was given. */ export type Routed = {
|
|
141
|
+
parts: {
|
|
142
|
+
member: Member;
|
|
143
|
+
entities: Bundle[];
|
|
144
|
+
}[];
|
|
145
|
+
aliases: Record<string, string>;
|
|
146
|
+
};
|
|
147
|
+
/** The operations every set of members is asked through. */ export type Reach = {
|
|
148
|
+
read: (members: Member[], line: string, live?: boolean) => Promise<unknown>;
|
|
149
|
+
watch: (members: Member[], line: string, sink: (frame: Frame) => void) => () => void;
|
|
150
|
+
composed: (members: Member[], eids: string[], ask?: Ask) => Promise<Bundle[]>;
|
|
151
|
+
/** The merged rows and the members that supplied them. */ located: (members: Member[], eids: string[], ask?: Ask) => Promise<{
|
|
152
|
+
bundles: Bundle[];
|
|
153
|
+
sources: Set<string>;
|
|
154
|
+
}>;
|
|
155
|
+
routed: (members: Member[], named: Member | undefined, bundles: Bundle[], key?: string) => Promise<Routed>;
|
|
156
|
+
written: (members: Member[], named: Member | undefined, bundles: Bundle[], opts?: WriteOpts) => Promise<{
|
|
157
|
+
bundles: Bundle[];
|
|
158
|
+
aliases: Record<string, string>;
|
|
159
|
+
where: string;
|
|
160
|
+
}>;
|
|
161
|
+
spoken: (members: Member[]) => Promise<Spoken>;
|
|
162
|
+
};
|
|
163
|
+
type DefaultSpace = () => Promise<string | undefined>;
|
|
164
|
+
type WriteOpts = {
|
|
165
|
+
key?: string;
|
|
166
|
+
check?: boolean;
|
|
167
|
+
/** The caller's own space, considered when a write has no home. */ defaultSpace?: DefaultSpace;
|
|
168
|
+
};
|
|
169
|
+
/** A composition over a shared language: the operations every set of
|
|
170
|
+
* members is asked through. */ export declare let reach: (words: Words) => Reach;
|
|
171
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAwBA,cAAc,MAAM,2BA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,OAAO,SAAS,SAAS,EACzB,SAAS,UACT,OAAO,cACJ;IACH,SAAS;IACT,SAAS,OAAO,MAAM,EAAE,MAAM;IAC9B,OAAO,MAAM;;EAEf,SAAS,SAAS,aAAa,QAAQ;;KAGpC,qBAAqB,QAAQ,MAAM,GAAG,SAAS;KAC/C;EACH,MAAM,MAAM;EACZ,QAAQ,OAAO;EACf,iEAAiE,GACjE,eAAe;;AAoEjB;6BAC6B,GAC7B,OAAO,YAAI,QAAS,OAAO,UAAQ,MAmyBlC"}
|
package/deno.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/reach","version":"0.2.36","license":"Apache-2.0","description":"A graph made of graphs: a read asked of every member and merged into one bundle per eid, and a write split by component and routed to the member each word lives in.","exports":{".":"./mod.ts"},"imports":{"@yaks/reach":"./mod.ts"}}
|