@yaks/edge 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 +325 -2
- package/_dist/comp.d.ts +7 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/eid.d.ts +43 -0
- package/_dist/eid.d.ts.map +1 -0
- package/_dist/graph.d.ts +10 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/guard.d.ts +8 -0
- package/_dist/guard.d.ts.map +1 -0
- package/_dist/keywords.d.ts +13 -0
- package/_dist/keywords.d.ts.map +1 -0
- package/_dist/mod.d.ts +58 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/order.d.ts +7 -0
- package/_dist/order.d.ts.map +1 -0
- package/_dist/plugin.d.ts +23 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/relations.d.ts +44 -0
- package/_dist/relations.d.ts.map +1 -0
- package/_dist/say.d.ts +13 -0
- package/_dist/say.d.ts.map +1 -0
- package/_dist/sql.d.ts +10 -0
- package/_dist/sql.d.ts.map +1 -0
- package/_dist/vocab.d.ts +10 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/walk.d.ts +16 -0
- package/_dist/walk.d.ts.map +1 -0
- package/comp.js +25 -0
- package/comp.js.map +1 -0
- package/comp.ts +26 -0
- package/deno.json +1 -0
- package/eid.js +66 -0
- package/eid.js.map +1 -0
- package/eid.ts +109 -0
- package/graph.js +18 -0
- package/graph.js.map +1 -0
- package/graph.ts +23 -0
- package/guard.js +71 -0
- package/guard.js.map +1 -0
- package/guard.ts +75 -0
- package/keywords.js +32 -0
- package/keywords.js.map +1 -0
- package/keywords.ts +32 -0
- package/meta/edge.vocab.json +20 -0
- package/mod.js +58 -0
- package/mod.js.map +1 -0
- package/mod.ts +59 -0
- package/order.js +59 -0
- package/order.js.map +1 -0
- package/order.ts +44 -0
- package/package.json +28 -4
- package/plugin.js +47 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +42 -0
- package/relations.js +80 -0
- package/relations.js.map +1 -0
- package/relations.ts +92 -0
- package/say.js +39 -0
- package/say.js.map +1 -0
- package/say.ts +41 -0
- package/sql.js +58 -0
- package/sql.js.map +1 -0
- package/sql.ts +68 -0
- package/vocab.js +19 -0
- package/vocab.js.map +1 -0
- package/vocab.json +52 -0
- package/vocab.ts +21 -0
- package/walk.js +88 -0
- package/walk.js.map +1 -0
- package/walk.ts +116 -0
package/guard.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// The rejection: an incomplete link is not a link.
|
|
2
|
+
//
|
|
3
|
+
// A link is three things — an endpoint, a relation, an endpoint — and any two
|
|
4
|
+
// of them mean nothing. A bundle holding an edge component with no relation
|
|
5
|
+
// beside it would be stored as a row nothing can interpret; one missing an
|
|
6
|
+
// endpoint would point nowhere. Both are caught here, in the `mint` phase,
|
|
7
|
+
// which runs after the graph has resolved every `$alias`, so an endpoint
|
|
8
|
+
// written as an alias is already the id it resolved to; an edge the batch
|
|
9
|
+
// minted is named by its alias, the name its writer knows.
|
|
10
|
+
//
|
|
11
|
+
// A bundle naming neither endpoint is a patch of a link that already exists
|
|
12
|
+
// (setting `ord`, say) and is left alone: it does not create a link, so it
|
|
13
|
+
// cannot create half of one.
|
|
14
|
+
//
|
|
15
|
+
// Every bundle in the write is read before any check, because one entity may
|
|
16
|
+
// arrive as several bundles — the edge component in one, its relation component
|
|
17
|
+
// in another — and together they are one link.
|
|
18
|
+
|
|
19
|
+
import type { Bundle, Comp, Eid, Hook } from 'jsr:@yaks/graph@0.2.36'
|
|
20
|
+
import { comps } from '@yaks/graph/bundle'
|
|
21
|
+
import { Refused } from '@yaks/graph/errors'
|
|
22
|
+
import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
23
|
+
import { EDGE, names } from './relations.js'
|
|
24
|
+
import { tagOf } from './eid.js'
|
|
25
|
+
|
|
26
|
+
// Every bundle in the write merged per entity, so a link spread over several
|
|
27
|
+
// of them is checked as the one link it is.
|
|
28
|
+
let gathered = (bundles: Bundle[]): Map<Eid, Bundle> => {
|
|
29
|
+
let out = new Map<Eid, Bundle>()
|
|
30
|
+
for (let b of bundles) {
|
|
31
|
+
let at = out.get(b.entity.eid) ?? { entity: b.entity }
|
|
32
|
+
if (b.$alias) at.$alias = b.$alias
|
|
33
|
+
for (let [name, comp] of comps(b)) {
|
|
34
|
+
let had = at[name] as Comp | null | undefined
|
|
35
|
+
at[name] = comp == null ? null : { ...(had ?? {}), ...comp }
|
|
36
|
+
}
|
|
37
|
+
out.set(b.entity.eid, at)
|
|
38
|
+
}
|
|
39
|
+
return out
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The `mint` hook that rejects an incomplete link, naming what is missing.
|
|
44
|
+
* Registered by the {@link plugin}; exported on its own for a graph that wants
|
|
45
|
+
* the check without the rest.
|
|
46
|
+
*/
|
|
47
|
+
export let stated = (
|
|
48
|
+
vocab: Vocab,
|
|
49
|
+
): Hook & ((bundles: Bundle[]) => Bundle[]) => {
|
|
50
|
+
let tags = names(vocab)
|
|
51
|
+
let known = Object.values(tags).sort()
|
|
52
|
+
return (bundles) => {
|
|
53
|
+
for (let [id, b] of gathered(bundles)) {
|
|
54
|
+
// An edge the batch minted is named as the batch named it.
|
|
55
|
+
let eid = b.$alias ?? id
|
|
56
|
+
let edge = b[EDGE] as Record<string, unknown> | null | undefined
|
|
57
|
+
// no link created here (a patch, or a bundle about something else)
|
|
58
|
+
if (!edge || (edge.from == null && edge.to == null)) continue
|
|
59
|
+
for (let end of ['from', 'to']) {
|
|
60
|
+
if (edge[end] == null) {
|
|
61
|
+
throw new Refused(`edge ${eid} has no \`${end}\` end`)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!tagOf(b, tags)) {
|
|
65
|
+
throw new Refused(
|
|
66
|
+
`edge ${eid} declares no relation — an edge carries a relation tag ` +
|
|
67
|
+
`beside edge{from, to}${
|
|
68
|
+
known.length ? ` (this vocabulary knows ${known.join(', ')})` : ''
|
|
69
|
+
}`,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return bundles
|
|
74
|
+
}
|
|
75
|
+
}
|
package/keywords.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The registration: what @yaks/edge adds to a component vocabulary, written in
|
|
2
|
+
// JSON Schema's own extension form. `meta/edge.vocab.json` is the authored
|
|
3
|
+
// source (the keyword's schema and its documentation); this module gives it a
|
|
4
|
+
// name and the shape `loadVocab(docs, [edgeKeywords])` expects.
|
|
5
|
+
//
|
|
6
|
+
// One thing is open: which relations exist. The `edge` component itself is
|
|
7
|
+
// fixed and ships with the package; the components stored beside it belong to
|
|
8
|
+
// the application's vocabulary — a blog links post to post, a bookstore has a
|
|
9
|
+
// book cite another book — so they are ordinary components that declare `edge`
|
|
10
|
+
// about themselves, and `reversed` for how they read from the far end.
|
|
11
|
+
import doc from './meta/edge.vocab.json' with {
|
|
12
|
+
type: 'json'
|
|
13
|
+
};
|
|
14
|
+
/** The URI a vocab file declares under `$vocabulary` to use `edge`. */ export let EDGE_URI = 'https://yak.sh/vocab/edge';
|
|
15
|
+
/**
|
|
16
|
+
* The `edge` keyword vocabulary, ready to register:
|
|
17
|
+
* `loadVocab(docs, [edgeKeywords])` copies each component's declarations onto
|
|
18
|
+
* `v.comp(name).keywords.edge` and `.reversed`, which is where
|
|
19
|
+
* {@link relations} and {@link reversed} read them.
|
|
20
|
+
*
|
|
21
|
+
* The keyword is the name of the component it accompanies, so one rule ("this
|
|
22
|
+
* component is stored beside that one") covers both an edge's relations and
|
|
23
|
+
* {@link https://jsr.io/@yaks/key | @yaks/key}'s.
|
|
24
|
+
*/ export let edgeKeywords = {
|
|
25
|
+
uri: EDGE_URI,
|
|
26
|
+
comp: [
|
|
27
|
+
'edge',
|
|
28
|
+
'reversed'
|
|
29
|
+
],
|
|
30
|
+
doc
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=keywords.js.map
|
package/keywords.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keywords.js","sources":["./keywords.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AAGvE,OAAO,SAAS,8BAA8B;EAAE,MAAM;AAAO,EAAC;AAE9D,qEAAqE,GACrE,OAAO,IAAI,WAAW,4BAA2B;AAEjD;;;;;;;;;CASC,GACD,OAAO,IAAI,eAAyB;EAClC,KAAK;EACL,MAAM;IAAC;IAAQ;GAAW;EAC1B;AACF,EAAC"}
|
package/keywords.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The registration: what @yaks/edge adds to a component vocabulary, written in
|
|
2
|
+
// JSON Schema's own extension form. `meta/edge.vocab.json` is the authored
|
|
3
|
+
// source (the keyword's schema and its documentation); this module gives it a
|
|
4
|
+
// name and the shape `loadVocab(docs, [edgeKeywords])` expects.
|
|
5
|
+
//
|
|
6
|
+
// One thing is open: which relations exist. The `edge` component itself is
|
|
7
|
+
// fixed and ships with the package; the components stored beside it belong to
|
|
8
|
+
// the application's vocabulary — a blog links post to post, a bookstore has a
|
|
9
|
+
// book cite another book — so they are ordinary components that declare `edge`
|
|
10
|
+
// about themselves, and `reversed` for how they read from the far end.
|
|
11
|
+
|
|
12
|
+
import type { Keywords } from 'jsr:@yaks/vocab@0.2.36'
|
|
13
|
+
import doc from './meta/edge.vocab.json' with { type: 'json' }
|
|
14
|
+
|
|
15
|
+
/** The URI a vocab file declares under `$vocabulary` to use `edge`. */
|
|
16
|
+
export let EDGE_URI = 'https://yak.sh/vocab/edge'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The `edge` keyword vocabulary, ready to register:
|
|
20
|
+
* `loadVocab(docs, [edgeKeywords])` copies each component's declarations onto
|
|
21
|
+
* `v.comp(name).keywords.edge` and `.reversed`, which is where
|
|
22
|
+
* {@link relations} and {@link reversed} read them.
|
|
23
|
+
*
|
|
24
|
+
* The keyword is the name of the component it accompanies, so one rule ("this
|
|
25
|
+
* component is stored beside that one") covers both an edge's relations and
|
|
26
|
+
* {@link https://jsr.io/@yaks/key | @yaks/key}'s.
|
|
27
|
+
*/
|
|
28
|
+
export let edgeKeywords: Keywords = {
|
|
29
|
+
uri: EDGE_URI,
|
|
30
|
+
comp: ['edge', 'reversed'],
|
|
31
|
+
doc,
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://yak.sh/vocab/edge",
|
|
4
|
+
"title": "yaks edge keyword vocabulary",
|
|
5
|
+
"description": "The keywords @yaks/edge adds to a component vocabulary. A component declaring `edge` names a relation: an entity carrying it, beside `edge{from,to}`, is a link of that kind \u2014 a `cites` component beside `edge{from,to}` means this post cites that one. Which relations exist is for the application to declare, and these keywords are how it declares them.",
|
|
6
|
+
"$comment": "A vocabulary declaration in the JSON Schema sense: a URI naming this keyword set, plus the schema of each keyword. A vocab file declares it under $vocabulary; a loader registers it with loadVocab(docs, [edgeKeywords]).",
|
|
7
|
+
"$defs": {
|
|
8
|
+
"edge": {
|
|
9
|
+
"description": "This component, stored beside an `edge` component, names the kind of link. `true` names the relation after the component itself (a `cites` component is the `cites` relation); a string gives it a different name in queries, for a vocabulary that stores `references` but queries it as `referenced`. The keyword is named after the component it accompanies, so one rule covers them all \u2014 a component stored beside a key declares `key`.",
|
|
10
|
+
"type": [
|
|
11
|
+
"boolean",
|
|
12
|
+
"string"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"reversed": {
|
|
16
|
+
"description": "How the relation reads from its far end: `cited by` for `cites`, so a post that another cites says it is cited by that one. A reader drawing the links that point at an entity shows this phrase; without one it can only show the relation's own name.",
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/mod.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/edge — links between entities, as a component.
|
|
3
|
+
*
|
|
4
|
+
* A relationship in a yaks graph is not a foreign-key column; it is an entity
|
|
5
|
+
* of its own, carrying the `edge{from, to, ord}` component plus a second
|
|
6
|
+
* component naming the relation. A blog declares that a post cites a post; a
|
|
7
|
+
* bookstore declares that a book cites a book; the structure is the same, and
|
|
8
|
+
* the relations are yours to declare — this package ships the link mechanism
|
|
9
|
+
* and no relations of its own.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
13
|
+
* import { edgeDoc, edgeKeywords, link } from '@yaks/edge'
|
|
14
|
+
*
|
|
15
|
+
* let blog = {
|
|
16
|
+
* $defs: {
|
|
17
|
+
* post: { component: true, type: 'object', kind: true },
|
|
18
|
+
* // one component, declared as a relation
|
|
19
|
+
* cites: { component: true, type: 'object', edge: true },
|
|
20
|
+
* },
|
|
21
|
+
* }
|
|
22
|
+
* let vocab = loadVocab([edgeDoc, blog], [edgeKeywords])
|
|
23
|
+
* link('p1', 'cites', 'p2') // the bundle that says p1 cites p2
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Four things follow from that:
|
|
27
|
+
*
|
|
28
|
+
* - **A link's id is derived from the link itself.** {@link edgeEid} hashes
|
|
29
|
+
* `from | relation | to`, so two writers who create the same link land on one
|
|
30
|
+
* entity, and a writer removing a link ({@link unlink}) computes its id
|
|
31
|
+
* without a lookup.
|
|
32
|
+
* - **A link lives only while both endpoints do.** Both endpoints are
|
|
33
|
+
* references declared `death: cascade`, so deleting a post deletes its links.
|
|
34
|
+
* - **An incomplete link is rejected** by name: an edge component with no
|
|
35
|
+
* relation beside it, or with an endpoint missing, never reaches storage
|
|
36
|
+
* ({@link edges} registers the check).
|
|
37
|
+
* - **Walking is querying.** {@link walk} implements `out`, `in` and a bounded
|
|
38
|
+
* `reach` over {@link https://jsr.io/@yaks/graph | @yaks/graph}'s `Storage`
|
|
39
|
+
* interface, and {@link traverse} adds to
|
|
40
|
+
* {@link https://jsr.io/@yaks/sql | @yaks/sql} the clause it cannot compile
|
|
41
|
+
* on its own: `.cites[<=3]->p1`, a recursive walk over one relation. A link
|
|
42
|
+
* is an entity, so a query reads links as rows (`.cites&.edge.from=p1`).
|
|
43
|
+
*
|
|
44
|
+
* It imports no platform API, so the same code runs on a server, in a worker,
|
|
45
|
+
* and in a browser tab.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/ export * from "./keywords.js";
|
|
49
|
+
export * from "./relations.js";
|
|
50
|
+
export * from "./comp.js";
|
|
51
|
+
export * from "./eid.js";
|
|
52
|
+
export * from "./say.js";
|
|
53
|
+
export * from "./order.js";
|
|
54
|
+
export * from "./guard.js";
|
|
55
|
+
export * from "./plugin.js";
|
|
56
|
+
export * from "./sql.js";
|
|
57
|
+
export * from "./walk.js";
|
|
58
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CC,GAED,8BAA6B;AAC7B,+BAA8B;AAC9B,0BAAyB;AACzB,yBAAwB;AACxB,yBAAwB;AACxB,2BAA0B;AAC1B,2BAA0B;AAC1B,4BAA2B;AAC3B,yBAAwB;AACxB,0BAAyB"}
|
package/mod.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/edge — links between entities, as a component.
|
|
3
|
+
*
|
|
4
|
+
* A relationship in a yaks graph is not a foreign-key column; it is an entity
|
|
5
|
+
* of its own, carrying the `edge{from, to, ord}` component plus a second
|
|
6
|
+
* component naming the relation. A blog declares that a post cites a post; a
|
|
7
|
+
* bookstore declares that a book cites a book; the structure is the same, and
|
|
8
|
+
* the relations are yours to declare — this package ships the link mechanism
|
|
9
|
+
* and no relations of its own.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
13
|
+
* import { edgeDoc, edgeKeywords, link } from '@yaks/edge'
|
|
14
|
+
*
|
|
15
|
+
* let blog = {
|
|
16
|
+
* $defs: {
|
|
17
|
+
* post: { component: true, type: 'object', kind: true },
|
|
18
|
+
* // one component, declared as a relation
|
|
19
|
+
* cites: { component: true, type: 'object', edge: true },
|
|
20
|
+
* },
|
|
21
|
+
* }
|
|
22
|
+
* let vocab = loadVocab([edgeDoc, blog], [edgeKeywords])
|
|
23
|
+
* link('p1', 'cites', 'p2') // the bundle that says p1 cites p2
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Four things follow from that:
|
|
27
|
+
*
|
|
28
|
+
* - **A link's id is derived from the link itself.** {@link edgeEid} hashes
|
|
29
|
+
* `from | relation | to`, so two writers who create the same link land on one
|
|
30
|
+
* entity, and a writer removing a link ({@link unlink}) computes its id
|
|
31
|
+
* without a lookup.
|
|
32
|
+
* - **A link lives only while both endpoints do.** Both endpoints are
|
|
33
|
+
* references declared `death: cascade`, so deleting a post deletes its links.
|
|
34
|
+
* - **An incomplete link is rejected** by name: an edge component with no
|
|
35
|
+
* relation beside it, or with an endpoint missing, never reaches storage
|
|
36
|
+
* ({@link edges} registers the check).
|
|
37
|
+
* - **Walking is querying.** {@link walk} implements `out`, `in` and a bounded
|
|
38
|
+
* `reach` over {@link https://jsr.io/@yaks/graph | @yaks/graph}'s `Storage`
|
|
39
|
+
* interface, and {@link traverse} adds to
|
|
40
|
+
* {@link https://jsr.io/@yaks/sql | @yaks/sql} the clause it cannot compile
|
|
41
|
+
* on its own: `.cites[<=3]->p1`, a recursive walk over one relation. A link
|
|
42
|
+
* is an entity, so a query reads links as rows (`.cites&.edge.from=p1`).
|
|
43
|
+
*
|
|
44
|
+
* It imports no platform API, so the same code runs on a server, in a worker,
|
|
45
|
+
* and in a browser tab.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export * from './keywords.js'
|
|
51
|
+
export * from './relations.js'
|
|
52
|
+
export * from './comp.js'
|
|
53
|
+
export * from './eid.js'
|
|
54
|
+
export * from './say.js'
|
|
55
|
+
export * from './order.js'
|
|
56
|
+
export * from './guard.js'
|
|
57
|
+
export * from './plugin.js'
|
|
58
|
+
export * from './sql.js'
|
|
59
|
+
export * from './walk.js'
|
package/order.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Putting a link in its place in a list.
|
|
2
|
+
//
|
|
3
|
+
// Where order matters, a link's position among the others of its list is its
|
|
4
|
+
// `edge.ord`. A list is drawn in some order (by position, then by whatever
|
|
5
|
+
// its reader breaks ties with), and a person moves a row within it, or brings
|
|
6
|
+
// one in from elsewhere: `placed` says what to write so the list reads in the
|
|
7
|
+
// new order. A move between neighbours that each have a position writes the
|
|
8
|
+
// moved link alone, halfway between them, so a move is one write. A list
|
|
9
|
+
// whose links have no positions yet, or the same one, is numbered from 1 in
|
|
10
|
+
// its new order the first time, writing only the links whose position changes.
|
|
11
|
+
import { EDGE } from "./relations.js";
|
|
12
|
+
let ordOf = (b)=>{
|
|
13
|
+
let ord = b[EDGE]?.ord;
|
|
14
|
+
return typeof ord == 'number' ? ord : undefined;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The bundles that put `put` at `at` among the other links of a list, given
|
|
18
|
+
* in the order it is drawn. `put` is one of them, moving, or a link joining
|
|
19
|
+
* the list (`link()`), which is written whole with its position.
|
|
20
|
+
*/ /// placed([], { entity: { eid: 'e' }, edge: { from: 'p', to: 'a' } }, 0)[0].edge
|
|
21
|
+
/// -> { from: 'p', to: 'a', ord: 1 }
|
|
22
|
+
export let placed = (links, put, at)=>{
|
|
23
|
+
let id = put.entity.eid;
|
|
24
|
+
let joins = !links.some((b)=>b.entity.eid == id);
|
|
25
|
+
let rest = links.filter((b)=>b.entity.eid != id);
|
|
26
|
+
let i = Math.max(0, Math.min(at, rest.length));
|
|
27
|
+
let ords = rest.map(ordOf);
|
|
28
|
+
let rising = ords.every((o, k)=>o != null && (k == 0 || o > ords[k - 1]));
|
|
29
|
+
let [p, n] = [
|
|
30
|
+
ords[i - 1],
|
|
31
|
+
ords[i]
|
|
32
|
+
];
|
|
33
|
+
let mid = p == null ? n == null ? 1 : n - 1 : n == null ? p + 1 : (p + n) / 2;
|
|
34
|
+
let set = (b, ord)=>b.entity.eid == id && joins ? {
|
|
35
|
+
...b,
|
|
36
|
+
[EDGE]: {
|
|
37
|
+
...b[EDGE],
|
|
38
|
+
ord
|
|
39
|
+
}
|
|
40
|
+
} : {
|
|
41
|
+
entity: {
|
|
42
|
+
eid: b.entity.eid
|
|
43
|
+
},
|
|
44
|
+
[EDGE]: {
|
|
45
|
+
ord
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
if (rising && mid != p && mid != n) return [
|
|
49
|
+
set(put, mid)
|
|
50
|
+
];
|
|
51
|
+
return [
|
|
52
|
+
...rest.slice(0, i),
|
|
53
|
+
put,
|
|
54
|
+
...rest.slice(i)
|
|
55
|
+
].flatMap((b, k)=>ordOf(b) == k + 1 && !(b.entity.eid == id && joins) ? [] : [
|
|
56
|
+
set(b, k + 1)
|
|
57
|
+
]);
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=order.js.map
|
package/order.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.js","sources":["./order.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,+EAA+E;AAG/E,SAAS,IAAI,yBAAwB;AAErC,IAAI,QAAQ,CAAC;EACX,IAAI,MAAO,CAAC,CAAC,KAAK,EAA2C;EAC7D,OAAO,OAAO,OAAO,WAAW,MAAM;AACxC;AAEA;;;;CAIC,GACD,iFAAiF;AACjF,uCAAuC;AACvC,OAAO,IAAI,SAAS,CAAC,OAAiB,KAAa;EACjD,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG;EACvB,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,IAAM,EAAE,MAAM,CAAC,GAAG,IAAI;EAC/C,IAAI,OAAO,MAAM,MAAM,CAAC,CAAC,IAAM,EAAE,MAAM,CAAC,GAAG,IAAI;EAC/C,IAAI,IAAI,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,KAAK,MAAM;EAC5C,IAAI,OAAO,KAAK,GAAG,CAAC;EACpB,IAAI,SAAS,KAAK,KAAK,CAAC,CAAC,GAAG,IAAM,KAAK,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,AAAC;EAC1E,IAAI,CAAC,GAAG,EAAE,GAAG;IAAC,IAAI,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE;GAAC;EACnC,IAAI,MAAM,KAAK,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI;EAC5E,IAAI,MAAM,CAAC,GAAW,MACpB,EAAE,MAAM,CAAC,GAAG,IAAI,MAAM,QAClB;MAAE,GAAG,CAAC;MAAE,CAAC,KAAK,EAAE;QAAE,GAAG,CAAC,CAAC,KAAK;QAAY;MAAI;IAAE,IAC9C;MAAE,QAAQ;QAAE,KAAK,EAAE,MAAM,CAAC,GAAG;MAAC;MAAG,CAAC,KAAK,EAAE;QAAE;MAAI;IAAE;EACvD,IAAI,UAAU,OAAO,KAAK,OAAO,GAAG,OAAO;IAAC,IAAI,KAAK;GAAK;EAC1D,OAAO;OAAI,KAAK,KAAK,CAAC,GAAG;IAAI;OAAQ,KAAK,KAAK,CAAC;GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,IAC9D,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,MAAM,KAAK,IAAI,EAAE,GAAG;MAAC,IAAI,GAAG,IAAI;KAAG;AAE9E,EAAC"}
|
package/order.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Putting a link in its place in a list.
|
|
2
|
+
//
|
|
3
|
+
// Where order matters, a link's position among the others of its list is its
|
|
4
|
+
// `edge.ord`. A list is drawn in some order (by position, then by whatever
|
|
5
|
+
// its reader breaks ties with), and a person moves a row within it, or brings
|
|
6
|
+
// one in from elsewhere: `placed` says what to write so the list reads in the
|
|
7
|
+
// new order. A move between neighbours that each have a position writes the
|
|
8
|
+
// moved link alone, halfway between them, so a move is one write. A list
|
|
9
|
+
// whose links have no positions yet, or the same one, is numbered from 1 in
|
|
10
|
+
// its new order the first time, writing only the links whose position changes.
|
|
11
|
+
|
|
12
|
+
import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
|
|
13
|
+
import { EDGE } from './relations.js'
|
|
14
|
+
|
|
15
|
+
let ordOf = (b: Bundle): number | undefined => {
|
|
16
|
+
let ord = (b[EDGE] as { ord?: unknown } | null | undefined)?.ord
|
|
17
|
+
return typeof ord == 'number' ? ord : undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The bundles that put `put` at `at` among the other links of a list, given
|
|
22
|
+
* in the order it is drawn. `put` is one of them, moving, or a link joining
|
|
23
|
+
* the list (`link()`), which is written whole with its position.
|
|
24
|
+
*/
|
|
25
|
+
/// placed([], { entity: { eid: 'e' }, edge: { from: 'p', to: 'a' } }, 0)[0].edge
|
|
26
|
+
/// -> { from: 'p', to: 'a', ord: 1 }
|
|
27
|
+
export let placed = (links: Bundle[], put: Bundle, at: number): Bundle[] => {
|
|
28
|
+
let id = put.entity.eid
|
|
29
|
+
let joins = !links.some((b) => b.entity.eid == id)
|
|
30
|
+
let rest = links.filter((b) => b.entity.eid != id)
|
|
31
|
+
let i = Math.max(0, Math.min(at, rest.length))
|
|
32
|
+
let ords = rest.map(ordOf)
|
|
33
|
+
let rising = ords.every((o, k) => o != null && (k == 0 || o > ords[k - 1]!))
|
|
34
|
+
let [p, n] = [ords[i - 1], ords[i]]
|
|
35
|
+
let mid = p == null ? n == null ? 1 : n - 1 : n == null ? p + 1 : (p + n) / 2
|
|
36
|
+
let set = (b: Bundle, ord: number): Bundle =>
|
|
37
|
+
b.entity.eid == id && joins
|
|
38
|
+
? { ...b, [EDGE]: { ...b[EDGE] as object, ord } }
|
|
39
|
+
: { entity: { eid: b.entity.eid }, [EDGE]: { ord } }
|
|
40
|
+
if (rising && mid != p && mid != n) return [set(put, mid)]
|
|
41
|
+
return [...rest.slice(0, i), put, ...rest.slice(i)].flatMap((b, k) =>
|
|
42
|
+
ordOf(b) == k + 1 && !(b.entity.eid == id && joins) ? [] : [set(b, k + 1)]
|
|
43
|
+
)
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaks/edge",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.36",
|
|
4
|
+
"homepage": "https://jsr.io/@yaks/edge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./_dist/mod.d.ts",
|
|
9
|
+
"default": "./mod.js"
|
|
10
|
+
},
|
|
11
|
+
"./vocab": {
|
|
12
|
+
"types": "./_dist/vocab.d.ts",
|
|
13
|
+
"default": "./vocab.js"
|
|
14
|
+
},
|
|
15
|
+
"./graph": {
|
|
16
|
+
"types": "./_dist/graph.d.ts",
|
|
17
|
+
"default": "./graph.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@yaks/fp": "0.2.36",
|
|
23
|
+
"@yaks/graph": "0.2.36",
|
|
24
|
+
"@yaks/query": "0.2.36",
|
|
25
|
+
"@yaks/sql": "0.2.36",
|
|
26
|
+
"@yaks/vocab": "0.2.36"
|
|
27
|
+
},
|
|
28
|
+
"description": "Creates directed links as graph entities with content-derived eids, validates writes, and follows links through storage reads and SQL queries.",
|
|
29
|
+
"repository": "https://github.com/yak-sh/yak.git"
|
|
30
|
+
}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// The package as a graph plugin: the `edge` component, the id a link derives
|
|
2
|
+
// from its own endpoints and relation, and the check that keeps incomplete
|
|
3
|
+
// links out.
|
|
4
|
+
//
|
|
5
|
+
// It is given the loaded vocabulary because the relations belong to the
|
|
6
|
+
// application, not to this package: which components name a relation is
|
|
7
|
+
// something only a loaded vocabulary knows. So a graph is built in two steps —
|
|
8
|
+
// load the documents, then pass that same vocabulary to the plugin.
|
|
9
|
+
import { hook } from "@yaks/graph/plugin";
|
|
10
|
+
import { EDGE, names } from "./relations.js";
|
|
11
|
+
import { derive } from "./eid.js";
|
|
12
|
+
import { stated } from "./guard.js";
|
|
13
|
+
import { edgeDoc } from "./comp.js";
|
|
14
|
+
/**
|
|
15
|
+
* The edge plugin:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
19
|
+
* import { graph } from '@yaks/graph'
|
|
20
|
+
* import { ram } from '@yaks/ram'
|
|
21
|
+
* import { edgeDoc, edgeKeywords, edges } from '@yaks/edge'
|
|
22
|
+
*
|
|
23
|
+
* let cites = { component: true, type: 'object', edge: true }
|
|
24
|
+
* let blog = { $defs: { cites } }
|
|
25
|
+
* let vocab = loadVocab([edgeDoc, blog], [edgeKeywords])
|
|
26
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [edges(vocab)] })
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* It contributes {@link edgeDoc}, derives a link's id from its endpoints and
|
|
30
|
+
* relation (so a link written under a `$alias` lands on the same entity every
|
|
31
|
+
* time), and rejects in the `mint` phase any edge missing an endpoint or a
|
|
32
|
+
* relation.
|
|
33
|
+
*/ export let edges = (vocab)=>({
|
|
34
|
+
name: '@yaks/edge',
|
|
35
|
+
vocab: [
|
|
36
|
+
edgeDoc
|
|
37
|
+
],
|
|
38
|
+
derive: {
|
|
39
|
+
[EDGE]: derive(names(vocab), vocab)
|
|
40
|
+
},
|
|
41
|
+
hooks: {
|
|
42
|
+
mint: hook([
|
|
43
|
+
EDGE
|
|
44
|
+
], stated(vocab))
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=plugin.js.map
|
package/plugin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["./plugin.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2EAA2E;AAC3E,aAAa;AACb,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AACxE,+EAA+E;AAC/E,oEAAoE;AAEpE,SAAS,IAAI,kCAAoD;AAEjE,SAAS,IAAI,EAAE,KAAK,yBAAwB;AAC5C,SAAS,MAAM,mBAAkB;AACjC,SAAS,MAAM,qBAAoB;AACnC,SAAS,OAAO,oBAAmB;AAEnC;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,IAAI,QAAQ,CAAC,QAAyB,CAAC;IAC5C,MAAM;IACN,OAAO;MAAC;KAAQ;IAChB,QAAQ;MAAE,CAAC,KAAK,EAAE,OAAO,MAAM,QAAQ;IAAO;IAC9C,OAAO;MAAE,MAAM,KAAK;QAAC;OAAK,EAAE,OAAO;IAAQ;EAC7C,CAAC,EAAC"}
|
package/plugin.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// The package as a graph plugin: the `edge` component, the id a link derives
|
|
2
|
+
// from its own endpoints and relation, and the check that keeps incomplete
|
|
3
|
+
// links out.
|
|
4
|
+
//
|
|
5
|
+
// It is given the loaded vocabulary because the relations belong to the
|
|
6
|
+
// application, not to this package: which components name a relation is
|
|
7
|
+
// something only a loaded vocabulary knows. So a graph is built in two steps —
|
|
8
|
+
// load the documents, then pass that same vocabulary to the plugin.
|
|
9
|
+
|
|
10
|
+
import { hook, type Plugin } from '@yaks/graph/plugin'
|
|
11
|
+
import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
12
|
+
import { EDGE, names } from './relations.js'
|
|
13
|
+
import { derive } from './eid.js'
|
|
14
|
+
import { stated } from './guard.js'
|
|
15
|
+
import { edgeDoc } from './comp.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The edge plugin:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
22
|
+
* import { graph } from '@yaks/graph'
|
|
23
|
+
* import { ram } from '@yaks/ram'
|
|
24
|
+
* import { edgeDoc, edgeKeywords, edges } from '@yaks/edge'
|
|
25
|
+
*
|
|
26
|
+
* let cites = { component: true, type: 'object', edge: true }
|
|
27
|
+
* let blog = { $defs: { cites } }
|
|
28
|
+
* let vocab = loadVocab([edgeDoc, blog], [edgeKeywords])
|
|
29
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [edges(vocab)] })
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* It contributes {@link edgeDoc}, derives a link's id from its endpoints and
|
|
33
|
+
* relation (so a link written under a `$alias` lands on the same entity every
|
|
34
|
+
* time), and rejects in the `mint` phase any edge missing an endpoint or a
|
|
35
|
+
* relation.
|
|
36
|
+
*/
|
|
37
|
+
export let edges = (vocab: Vocab): Plugin => ({
|
|
38
|
+
name: '@yaks/edge',
|
|
39
|
+
vocab: [edgeDoc],
|
|
40
|
+
derive: { [EDGE]: derive(names(vocab), vocab) },
|
|
41
|
+
hooks: { mint: hook([EDGE], stated(vocab)) },
|
|
42
|
+
})
|
package/relations.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// The `edge` keywords, interpreted: which components name a relation, what
|
|
2
|
+
// each of them is called, and how each reads from its far end.
|
|
3
|
+
//
|
|
4
|
+
// The set of relations is not a fixed list this package ships. An application
|
|
5
|
+
// declares as many as it has — a blog's `links`, a bookstore's `cites`, a task
|
|
6
|
+
// board's `requires` — and each is an ordinary component declaring `edge`
|
|
7
|
+
// about itself. Everything here reads that declaration off a loaded vocabulary;
|
|
8
|
+
// nothing is hardcoded, so adding a relation means adding one component, not
|
|
9
|
+
// editing this file.
|
|
10
|
+
//
|
|
11
|
+
// A relation has two names, and they may differ. The component name is the
|
|
12
|
+
// component stored on the link entity (`references`); the query name is what a
|
|
13
|
+
// query uses (`referenced`). Declaring `edge: true` makes them identical,
|
|
14
|
+
// which is the common case; declaring a string gives the query name. The link's
|
|
15
|
+
// id is derived from the component name, so the two maps below are not
|
|
16
|
+
// interchangeable.
|
|
17
|
+
/** The component every edge carries: its two ends, and its place in a list. */ export let EDGE = 'edge';
|
|
18
|
+
/**
|
|
19
|
+
* Every relation the vocabulary declares, as query name → component name:
|
|
20
|
+
* `{ cites: 'cites', referenced: 'references' }`. Reads the `edge` keyword,
|
|
21
|
+
* so the vocabulary must have been loaded with `edgeKeywords` registered — an
|
|
22
|
+
* unregistered keyword is invisible to the loader.
|
|
23
|
+
*/ export let relations = (v)=>{
|
|
24
|
+
let out = {};
|
|
25
|
+
for (let tag of v.all){
|
|
26
|
+
// The keyword is named after the component it is stored beside, so one
|
|
27
|
+
// rule covers them all (@yaks/key's components declare `key`).
|
|
28
|
+
let said = v.comp(tag)?.keywords?.edge;
|
|
29
|
+
if (said === true) out[tag] = tag;
|
|
30
|
+
else if (typeof said == 'string' && said) out[said] = tag;
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The relations a link here can be kept as: every one {@link relations}
|
|
36
|
+
* finds, or none in a vocabulary without the {@link EDGE} component each link
|
|
37
|
+
* carries. A graph composing @yaks/task but not @yaks/edge declares
|
|
38
|
+
* `contains`, yet holds no link of it, and a read of `edge.from` there is a
|
|
39
|
+
* read of a property it does not have.
|
|
40
|
+
*/ export let linkable = (v)=>v.comp(EDGE) ? relations(v) : {};
|
|
41
|
+
/**
|
|
42
|
+
* The same declarations the other way round, as component name → query name.
|
|
43
|
+
* This is what reads a stored link back: a bundle carrying `references` is a
|
|
44
|
+
* `referenced` link.
|
|
45
|
+
*/ export let names = (v)=>{
|
|
46
|
+
let out = {};
|
|
47
|
+
for (let [name, tag] of Object.entries(relations(v)))out[tag] = name;
|
|
48
|
+
return out;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* How each relation reads from its far end, as query name → phrase: what a
|
|
52
|
+
* page says about the links pointing at the entity it draws. A relation that
|
|
53
|
+
* declares no `reversed` is left out, and its reader shows the relation's name.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { assertEquals } from '@std/assert'
|
|
57
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
58
|
+
* import { edgeKeywords, reversed } from '@yaks/edge'
|
|
59
|
+
*
|
|
60
|
+
* let v = loadVocab([{
|
|
61
|
+
* $defs: {
|
|
62
|
+
* cites: {
|
|
63
|
+
* component: true,
|
|
64
|
+
* type: 'object',
|
|
65
|
+
* edge: true,
|
|
66
|
+
* reversed: 'cited by',
|
|
67
|
+
* },
|
|
68
|
+
* },
|
|
69
|
+
* }], [edgeKeywords])
|
|
70
|
+
* assertEquals(reversed(v), { cites: 'cited by' })
|
|
71
|
+
* ```
|
|
72
|
+
*/ export let reversed = (v)=>{
|
|
73
|
+
let out = {};
|
|
74
|
+
for (let [name, tag] of Object.entries(relations(v))){
|
|
75
|
+
let said = v.comp(tag)?.keywords?.reversed;
|
|
76
|
+
if (typeof said == 'string' && said) out[name] = said;
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=relations.js.map
|
package/relations.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.js","sources":["./relations.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+DAA+D;AAC/D,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,0EAA0E;AAC1E,gFAAgF;AAChF,6EAA6E;AAC7E,qBAAqB;AACrB,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,0EAA0E;AAC1E,gFAAgF;AAChF,uEAAuE;AACvE,mBAAmB;AAInB,6EAA6E,GAC7E,OAAO,IAAI,OAAO,OAAM;AAExB;;;;;CAKC,GACD,OAAO,IAAI,YAAY,CAAC;EACtB,IAAI,MAA8B,CAAC;EACnC,KAAK,IAAI,OAAO,EAAE,GAAG,CAAE;IACrB,uEAAuE;IACvE,+DAA+D;IAC/D,IAAI,OAAO,EAAE,IAAI,CAAC,MAAM,UAAU;IAClC,IAAI,SAAS,MAAM,GAAG,CAAC,IAAI,GAAG;SACzB,IAAI,OAAO,QAAQ,YAAY,MAAM,GAAG,CAAC,KAAK,GAAG;EACxD;EACA,OAAO;AACT,EAAC;AAED;;;;;;CAMC,GACD,OAAO,IAAI,WAAW,CAAC,IACrB,EAAE,IAAI,CAAC,QAAQ,UAAU,KAAK,CAAC,EAAC;AAElC;;;;CAIC,GACD,OAAO,IAAI,QAAQ,CAAC;EAClB,IAAI,MAA8B,CAAC;EACnC,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,OAAO,OAAO,CAAC,UAAU,IAAK,GAAG,CAAC,IAAI,GAAG;EACjE,OAAO;AACT,EAAC;AAED;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,IAAI,WAAW,CAAC;EACrB,IAAI,MAA8B,CAAC;EACnC,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,OAAO,OAAO,CAAC,UAAU,IAAK;IACpD,IAAI,OAAO,EAAE,IAAI,CAAC,MAAM,UAAU;IAClC,IAAI,OAAO,QAAQ,YAAY,MAAM,GAAG,CAAC,KAAK,GAAG;EACnD;EACA,OAAO;AACT,EAAC"}
|