@astrale-domains/shell 0.1.0-beta.50 → 0.1.0-beta.51
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.
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path';
|
|
2
|
+
import { defineQuery, Query, queryResult, } from '@astrale-os/sdk/query';
|
|
3
|
+
/** `/:shell.astrale.ai:core.views`, the Namespace `/v/<name>` reads. */
|
|
4
|
+
const viewsNamespace = (origin) => Path.project({ origin: origin, kind: 'core', name: 'views' });
|
|
5
|
+
/** The `views` Namespace, which names are given in; nothing on a Shell release without it. */
|
|
6
|
+
export const readViewsNamespace = defineQuery()((domain) => ({
|
|
7
|
+
id: 'shell.namespace.views',
|
|
8
|
+
page: { size: 1 },
|
|
9
|
+
pagination: { maximumPages: 1 },
|
|
10
|
+
build: () => Query.from({ nodes: [viewsNamespace(domain.origin)] }).select({
|
|
11
|
+
kind: 'nodes',
|
|
12
|
+
projection: { kind: 'reference' },
|
|
13
|
+
}),
|
|
14
|
+
project: (pages) => queryResult.completeNodeIds(pages, 'Shell views Namespace')[0],
|
|
15
|
+
}));
|
|
16
|
+
/** Every name of the `views` Namespace, with the View it opens, in name order. */
|
|
17
|
+
export const readViewAliases = defineQuery()((domain) => ({
|
|
18
|
+
id: 'shell.namespace.view-aliases',
|
|
19
|
+
page: { size: 256 },
|
|
20
|
+
pagination: { maximumPages: 8 },
|
|
21
|
+
build: () => {
|
|
22
|
+
const named = Query.from({ nodes: [viewsNamespace(domain.origin)] }).expand({
|
|
23
|
+
via: [domain.classes.alias],
|
|
24
|
+
direction: 'outgoing',
|
|
25
|
+
});
|
|
26
|
+
return named.select({
|
|
27
|
+
kind: 'edges',
|
|
28
|
+
binding: named.edge,
|
|
29
|
+
projection: { edge: 'value', source: 'reference', target: 'reference' },
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
project(pages) {
|
|
33
|
+
const aliases = [];
|
|
34
|
+
for (const page of pages) {
|
|
35
|
+
for (const item of queryResult.edgeItems(page, 'Shell view aliases')) {
|
|
36
|
+
if (item.edge.kind !== 'value' || item.edge.value.slug === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
aliases.push({ view: item.edge.value.target, name: item.edge.value.slug });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return aliases.sort((a, b) => a.name.localeCompare(b.name));
|
|
42
|
+
},
|
|
43
|
+
}));
|