@arkitektio/bsx 6.8.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bsx/declared.d.ts +25 -0
- package/dist/bsx/declared.d.ts.map +1 -1
- package/dist/bsx/declared.js +59 -0
- package/dist/bsx/declared.js.map +1 -1
- package/dist/bsx/infer.d.ts.map +1 -1
- package/dist/bsx/infer.js +4 -2
- package/dist/bsx/infer.js.map +1 -1
- package/dist/bsx/language.d.ts.map +1 -1
- package/dist/bsx/language.js +17 -12
- package/dist/bsx/language.js.map +1 -1
- package/dist/bsx/references.d.ts.map +1 -1
- package/dist/bsx/references.js +139 -37
- package/dist/bsx/references.js.map +1 -1
- package/dist/catalogs/index.d.ts +191 -98
- package/dist/catalogs/index.d.ts.map +1 -1
- package/dist/catalogs/parts/data.d.ts +2 -2
- package/dist/catalogs/parts/data.d.ts.map +1 -1
- package/dist/catalogs/parts/data.js +2 -3
- package/dist/catalogs/parts/data.js.map +1 -1
- package/dist/catalogs/parts/feedback.d.ts +6 -6
- package/dist/catalogs/parts/forms.d.ts +8 -8
- package/dist/catalogs/parts/icons.d.ts +4 -4
- package/dist/catalogs/parts/index.d.ts +48 -48
- package/dist/catalogs/parts/navigation.d.ts +8 -8
- package/dist/catalogs/parts/overlays.d.ts +22 -22
- package/dist/catalogs/parts/run.d.ts.map +1 -1
- package/dist/catalogs/parts/run.js +4 -5
- package/dist/catalogs/parts/run.js.map +1 -1
- package/dist/catalogs/parts/scene.d.ts.map +1 -1
- package/dist/catalogs/parts/scene.js +7 -14
- package/dist/catalogs/parts/scene.js.map +1 -1
- package/dist/catalogs/parts/structure.d.ts.map +1 -1
- package/dist/catalogs/parts/structure.js +2 -3
- package/dist/catalogs/parts/structure.js.map +1 -1
- package/dist/catalogs/parts/toast.d.ts.map +1 -1
- package/dist/catalogs/parts/toast.js +2 -1
- package/dist/catalogs/parts/toast.js.map +1 -1
- package/dist/catalogs/props.d.ts +23 -0
- package/dist/catalogs/props.d.ts.map +1 -1
- package/dist/catalogs/props.js +56 -4
- package/dist/catalogs/props.js.map +1 -1
- package/dist/catalogs/scene.d.ts +134 -127
- package/dist/catalogs/scene.d.ts.map +1 -1
- package/dist/catalogs/scene.js +5 -3
- package/dist/catalogs/scene.js.map +1 -1
- package/dist/catalogs/shadcn.d.ts +79 -41
- package/dist/catalogs/shadcn.d.ts.map +1 -1
- package/dist/catalogs/shadcn.js +13 -13
- package/dist/catalogs/shadcn.js.map +1 -1
- package/dist/catalogs/structure.d.ts +9 -2
- package/dist/catalogs/structure.d.ts.map +1 -1
- package/dist/catalogs/structure.js +1 -1
- package/dist/catalogs/structure.js.map +1 -1
- package/dist/catalogs/ui.d.ts +935 -892
- package/dist/catalogs/ui.d.ts.map +1 -1
- package/dist/catalogs/ui.js +16 -14
- package/dist/catalogs/ui.js.map +1 -1
- package/dist/catalogs/zodToPort.d.ts +9 -0
- package/dist/catalogs/zodToPort.d.ts.map +1 -0
- package/dist/catalogs/zodToPort.js +156 -0
- package/dist/catalogs/zodToPort.js.map +1 -0
- package/dist/catalogs.d.ts +4 -1
- package/dist/catalogs.d.ts.map +1 -1
- package/dist/catalogs.js +3 -0
- package/dist/catalogs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ports/rekuest.d.ts +6 -0
- package/dist/ports/rekuest.d.ts.map +1 -1
- package/dist/ports/rekuest.js +6 -0
- package/dist/ports/rekuest.js.map +1 -1
- package/dist/renderer/bloks/control.d.ts +7 -1
- package/dist/renderer/bloks/control.d.ts.map +1 -1
- package/dist/renderer/bloks/control.js +20 -2
- package/dist/renderer/bloks/control.js.map +1 -1
- package/dist/renderer/bloks/data.d.ts +2 -2
- package/dist/renderer/bloks/feedback.d.ts +6 -6
- package/dist/renderer/bloks/forms.d.ts +8 -8
- package/dist/renderer/bloks/icons.d.ts +2 -2
- package/dist/renderer/bloks/index.d.ts +48 -48
- package/dist/renderer/bloks/navigation.d.ts +8 -8
- package/dist/renderer/bloks/overlays.d.ts +22 -22
- package/dist/renderer/runtime/components.d.ts +6 -8
- package/dist/renderer/runtime/components.d.ts.map +1 -1
- package/dist/renderer/runtime/components.js.map +1 -1
- package/dist/renderer/runtime/describe.d.ts +5 -12
- package/dist/renderer/runtime/describe.d.ts.map +1 -1
- package/dist/renderer/runtime/describe.js +25 -89
- package/dist/renderer/runtime/describe.js.map +1 -1
- package/dist/renderer/runtime/hooks.d.ts.map +1 -1
- package/dist/renderer/runtime/hooks.js +3 -1
- package/dist/renderer/runtime/hooks.js.map +1 -1
- package/dist/renderer/runtime/schemas.d.ts +8 -6
- package/dist/renderer/runtime/schemas.d.ts.map +1 -1
- package/dist/renderer/runtime/schemas.js +40 -16
- package/dist/renderer/runtime/schemas.js.map +1 -1
- package/dist/shadcn.d.ts +48 -48
- package/dist/spec/bsx_v2.json +1421 -19
- package/dist/spec/catalogs/base@4.json +18738 -5273
- package/dist/spec/catalogs/base@4.json.js +18738 -5273
- package/dist/spec/catalogs/orkestrator@1.json +532 -126
- package/dist/spec/catalogs/orkestrator@1.json.js +532 -126
- package/dist/spec/catalogs.d.ts +3 -11
- package/dist/spec/catalogs.d.ts.map +1 -1
- package/dist/spec/catalogs.js +13 -11
- package/dist/spec/catalogs.js.map +1 -1
- package/dist/spec/fit.d.ts +21 -0
- package/dist/spec/fit.d.ts.map +1 -0
- package/dist/spec/fit.js +114 -0
- package/dist/spec/fit.js.map +1 -0
- package/dist/spec/ports.d.ts +56 -0
- package/dist/spec/ports.d.ts.map +1 -0
- package/dist/spec/ports.js +174 -0
- package/dist/spec/ports.js.map +1 -0
- package/dist/spec/vocabulary.json +12 -5
- package/dist/spec/vocabulary.json.js +12 -5
- package/package.json +1 -1
- package/src/bsx/declared.ts +60 -0
- package/src/bsx/infer.test.ts +1 -1
- package/src/bsx/infer.ts +4 -2
- package/src/bsx/language.ts +16 -11
- package/src/bsx/logo.test.ts +47 -0
- package/src/bsx/references.ts +170 -39
- package/src/catalogs/parts/data.ts +3 -2
- package/src/catalogs/parts/run.ts +9 -7
- package/src/catalogs/parts/scene.ts +7 -14
- package/src/catalogs/parts/structure.ts +2 -3
- package/src/catalogs/parts/toast.ts +5 -1
- package/src/catalogs/props.ts +64 -4
- package/src/catalogs/scene.ts +5 -3
- package/src/catalogs/shadcn.ts +13 -13
- package/src/catalogs/structure.ts +1 -1
- package/src/catalogs/ui.ts +16 -14
- package/src/catalogs/zodToPort.test.ts +96 -0
- package/src/catalogs/zodToPort.ts +177 -0
- package/src/catalogs.ts +4 -1
- package/src/index.ts +2 -0
- package/src/ports/rekuest.ts +6 -0
- package/src/renderer/bloks/control.tsx +26 -2
- package/src/renderer/runtime/catalog.test.ts +12 -8
- package/src/renderer/runtime/components.tsx +5 -8
- package/src/renderer/runtime/describe.ts +25 -100
- package/src/renderer/runtime/hooks.ts +3 -1
- package/src/renderer/runtime/schemas.ts +51 -17
- package/src/spec/bsx_v2.json +1421 -19
- package/src/spec/catalogs/base@4.json +18738 -5273
- package/src/spec/catalogs/orkestrator@1.json +532 -126
- package/src/spec/catalogs.ts +14 -19
- package/src/spec/fit.test.ts +65 -0
- package/src/spec/fit.ts +114 -0
- package/src/spec/ports.ts +172 -0
- package/src/spec/spec.test.ts +5 -2
- package/src/spec/vocabulary.json +12 -5
package/src/spec/catalogs.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import baseCatalogJson from './catalogs/base@4.json';
|
|
2
2
|
import orkestratorCatalogJson from './catalogs/orkestrator@1.json';
|
|
3
|
+
import {parsePort, type SpecPort} from './ports';
|
|
3
4
|
import {loadVocabulary, type BlokContextName, type VocabFunction} from './vocabulary';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -29,18 +30,12 @@ export const LANGUAGE_GROUP = 'language';
|
|
|
29
30
|
/** The Orkestrator's catalog: what it draws beyond the base. */
|
|
30
31
|
export const ORKESTRATOR_CATALOG_ID = 'https://arkitekt.live/catalogs/orkestrator/v1';
|
|
31
32
|
|
|
32
|
-
export type SpecEventField = {key: string; kind: string; description: string | null};
|
|
33
|
-
|
|
34
33
|
export type SpecProp = {
|
|
35
34
|
key: string;
|
|
36
|
-
/** `
|
|
37
|
-
|
|
35
|
+
/** What it takes (`spec/ports.ts`): a CALLBACK's children are its payload, a BINDING's one child what it writes; open (kind null) for the language's own. */
|
|
36
|
+
port: SpecPort;
|
|
38
37
|
required: boolean;
|
|
39
38
|
description: string | null;
|
|
40
|
-
/** For a `CALLBACK`, the payload it is called with (`[]` when none); null otherwise. */
|
|
41
|
-
event: readonly SpecEventField[] | null;
|
|
42
|
-
/** For a `STRING`, the closed set of literals the component draws; null: any string. */
|
|
43
|
-
values: readonly string[] | null;
|
|
44
39
|
/** The minor of its catalog that added the prop; 0: there from the start. */
|
|
45
40
|
since: number;
|
|
46
41
|
};
|
|
@@ -119,17 +114,17 @@ export const parseSpecCatalog = (raw: unknown, file: string): SpecCatalog => {
|
|
|
119
114
|
downstreamOf: texts(entry.downstream_of),
|
|
120
115
|
notDownstreamOf: texts(entry.not_downstream_of),
|
|
121
116
|
textProp: text(entry.text_prop) || null,
|
|
122
|
-
props: rawList(entry.props).filter(isRaw).map((prop): SpecProp =>
|
|
123
|
-
|
|
124
|
-
kind
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})
|
|
117
|
+
props: rawList(entry.props).filter(isRaw).map((prop): SpecProp => {
|
|
118
|
+
const where = `${file}: <${String(entry.name)}> ${String(prop.key)}`;
|
|
119
|
+
if ('kind' in prop && !('port' in prop)) throw new Error(`${where} is typed by a kind, not a port: a catalog written before ports; export it again`);
|
|
120
|
+
return {
|
|
121
|
+
key: String(prop.key),
|
|
122
|
+
port: parsePort(prop.port, where),
|
|
123
|
+
required: prop.required === true,
|
|
124
|
+
description: text(prop.description),
|
|
125
|
+
since: count(prop.since),
|
|
126
|
+
};
|
|
127
|
+
}),
|
|
133
128
|
kinds: texts(entry.kinds),
|
|
134
129
|
service: text(entry.service) || null,
|
|
135
130
|
since: count(entry.since),
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import corpus from './bsx_v2.json';
|
|
3
|
+
import {bindingFits, fits, literalPort} from './fit';
|
|
4
|
+
import {parsePort, portSummary, TEXT_PORT} from './ports';
|
|
5
|
+
import {loadVocabulary} from './vocabulary';
|
|
6
|
+
|
|
7
|
+
type FitCase = {name: string; source: unknown; target: unknown; status: string};
|
|
8
|
+
|
|
9
|
+
const cases = (corpus as unknown as {fits: FitCase[]}).fits;
|
|
10
|
+
|
|
11
|
+
describe('fits, against the corpus', () => {
|
|
12
|
+
it('has the cases', () => {
|
|
13
|
+
expect(cases.length).toBeGreaterThan(20);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it.each(cases.map(entry => [entry.name, entry] as const))('%s', (name, entry) => {
|
|
17
|
+
expect(fits(parsePort(entry.source, name), parsePort(entry.target, name)).status).toBe(entry.status);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('a binding', () => {
|
|
22
|
+
const {bindKinds} = loadVocabulary().locals;
|
|
23
|
+
const port = (kind: string) => ({kind});
|
|
24
|
+
|
|
25
|
+
it('relaxes as bind_kinds says, for each row', () => {
|
|
26
|
+
for (const [writes, locals] of Object.entries(bindKinds)) {
|
|
27
|
+
for (const local of locals) {
|
|
28
|
+
if (local === 'LIST' || local === 'DICT' || local === 'MODEL') continue;
|
|
29
|
+
expect(bindingFits(port(local), port(writes), bindKinds).status, `${writes} -> ${local}`).toBe('ok');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
expect(bindingFits(port('INT'), port('BOOL'), bindKinds).status).toBe('mismatch');
|
|
33
|
+
expect(bindingFits(port('STRING'), port('FLOAT'), bindKinds).status).toBe('mismatch');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('writes a structure into a local of that structure', () => {
|
|
37
|
+
const any = {kind: 'STRUCTURE', identifier: '*'};
|
|
38
|
+
expect(bindingFits({kind: 'STRUCTURE', identifier: '@mikro/image'}, any, bindKinds).status).toBe('ok');
|
|
39
|
+
expect(bindingFits({kind: 'STRING'}, any, bindKinds).status).toBe('mismatch');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('a literal', () => {
|
|
44
|
+
it('is checked by its kind and as its one choice', () => {
|
|
45
|
+
expect(fits(literalPort(3), {kind: 'FLOAT'}).status).toBe('ok');
|
|
46
|
+
expect(fits(literalPort(true), TEXT_PORT).status).toBe('ok');
|
|
47
|
+
expect(fits(literalPort('x'), {kind: 'STRING', choices: [{value: 'a'}]}).status).toBe('mismatch');
|
|
48
|
+
expect(fits(literalPort([1]), {kind: 'STRING'}).status).toBe('open');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('a task record (a DICT) fits a DICT of named fields', () => {
|
|
52
|
+
const record = {kind: 'DICT', children: [{key: 'status', kind: 'STRING'}, {key: 'args', kind: null}]};
|
|
53
|
+
expect(fits(record, {kind: 'DICT', children: [{key: 'status', kind: 'STRING'}]}).status).toBe('ok');
|
|
54
|
+
expect(fits(record, {kind: 'MODEL', children: [{key: 'status', kind: 'STRING'}]}).status).toBe('mismatch');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('portSummary', () => {
|
|
59
|
+
it('says a port as one line', () => {
|
|
60
|
+
expect(portSummary(TEXT_PORT)).toBe('STRING | INT | FLOAT | BOOL');
|
|
61
|
+
expect(portSummary({kind: 'LIST', children: [{key: '...', kind: 'STRING'}]})).toBe('LIST<STRING>');
|
|
62
|
+
expect(portSummary({kind: 'CALLBACK', children: [{key: 'value', kind: 'BOOL'}]})).toBe('CALLBACK(value: BOOL)');
|
|
63
|
+
expect(portSummary({kind: 'STRING', choices: [{value: 'a'}]})).toBe("'a'");
|
|
64
|
+
});
|
|
65
|
+
});
|
package/src/spec/fit.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {childOf, isIdentifiedKind, ITEM_KEY, OPEN_PORT, OPEN_STRUCTURE, pythonRepr, type SpecChoice, type SpecPort} from './ports';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether a value of one port fits a prop typed by another: arkitekt-spec's
|
|
5
|
+
* `declare/catalogs/fit.py`, held to the corpus' `fits` cases.
|
|
6
|
+
*
|
|
7
|
+
* `ok` it fits; `open` nothing can be said (an open side), never a finding;
|
|
8
|
+
* `mismatch` both are concrete and do not overlap.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type FitStatus = 'ok' | 'open' | 'mismatch';
|
|
12
|
+
export type Fit = {status: FitStatus; reason?: string};
|
|
13
|
+
|
|
14
|
+
const OK: Fit = {status: 'ok'};
|
|
15
|
+
const OPEN: Fit = {status: 'open'};
|
|
16
|
+
const mismatch = (reason: string): Fit => ({status: 'mismatch', reason});
|
|
17
|
+
|
|
18
|
+
export const fitOk = (fit: Fit): boolean => fit.status !== 'mismatch';
|
|
19
|
+
|
|
20
|
+
const WIDENS: Readonly<Record<string, readonly string[]>> = {
|
|
21
|
+
FLOAT: ['INT', 'QUANTITY'],
|
|
22
|
+
STRING: ['ENUM', 'DATE'],
|
|
23
|
+
DICT: ['MODEL'],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const name = (port: SpecPort): string => (isIdentifiedKind(port.kind) ? `${port.kind}(${port.identifier})` : (port.kind ?? 'ANY'));
|
|
27
|
+
|
|
28
|
+
const join = (fits: readonly Fit[]): Fit => fits.find(fit => fit.status === 'mismatch') ?? (fits.some(fit => fit.status === 'open') ? OPEN : OK);
|
|
29
|
+
|
|
30
|
+
const within = (fit: Fit, where: string): Fit => (fit.status === 'mismatch' ? mismatch(`${where}: ${fit.reason}`) : fit);
|
|
31
|
+
|
|
32
|
+
const choicesFit = (source: readonly SpecChoice[] | null | undefined, target: readonly SpecChoice[] | null | undefined): Fit => {
|
|
33
|
+
if (!target || !source) return OK;
|
|
34
|
+
const allowed = target.map(choice => choice.value);
|
|
35
|
+
const stray = source.map(choice => choice.value).filter(value => !allowed.includes(value));
|
|
36
|
+
if (!stray.length) return OK;
|
|
37
|
+
const sorted = [...new Set(allowed)].sort((a, b) => (String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0));
|
|
38
|
+
return mismatch(`${stray.map(pythonRepr).join(', ')} not among ${sorted.map(pythonRepr).join(', ')}`);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Whether a value of `source` fits where `target` is taken. */
|
|
42
|
+
export const fits = (source: SpecPort, target: SpecPort): Fit => {
|
|
43
|
+
if (source.kind === null || target.kind === null) return OPEN;
|
|
44
|
+
if (target.kind === 'UNION') {
|
|
45
|
+
const results = (target.children ?? []).map(child => fits(source, child));
|
|
46
|
+
if (results.some(result => result.status === 'ok')) return OK;
|
|
47
|
+
if (results.some(result => result.status === 'open')) return OPEN;
|
|
48
|
+
return mismatch(`${name(source)} is none of ${(target.children ?? []).map(name).join(', ')}`);
|
|
49
|
+
}
|
|
50
|
+
if (source.kind === 'UNION') return join((source.children ?? []).map(child => fits(child, target)));
|
|
51
|
+
|
|
52
|
+
const kind = source.kind;
|
|
53
|
+
const wanted = target.kind;
|
|
54
|
+
if (kind === 'STRUCTURE' && wanted === 'DICT') return OPEN;
|
|
55
|
+
if (kind !== wanted) {
|
|
56
|
+
if ((WIDENS[wanted] ?? []).includes(kind)) return choicesFit(source.choices, target.choices);
|
|
57
|
+
return mismatch(`a ${name(source)} is not a ${name(target)}`);
|
|
58
|
+
}
|
|
59
|
+
if (isIdentifiedKind(kind)) {
|
|
60
|
+
if (source.identifier === OPEN_STRUCTURE || target.identifier === OPEN_STRUCTURE || source.identifier === target.identifier) return OK;
|
|
61
|
+
return mismatch(`a ${name(source)} is not a ${name(target)}`);
|
|
62
|
+
}
|
|
63
|
+
if (kind === 'LIST') return within(fits(source.children?.[0] ?? OPEN_PORT, target.children?.[0] ?? OPEN_PORT), 'an item');
|
|
64
|
+
if (kind === 'DICT') return dictFits(source, target);
|
|
65
|
+
if (kind === 'MODEL') return fieldsFit(source, target);
|
|
66
|
+
return choicesFit(source.choices, target.choices);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const dictFits = (source: SpecPort, target: SpecPort): Fit => {
|
|
70
|
+
const item = childOf(target, ITEM_KEY);
|
|
71
|
+
if (item) return join((source.children ?? []).map(child => within(fits(child, item), child.key)));
|
|
72
|
+
return fieldsFit(source, target);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const fieldsFit = (source: SpecPort, target: SpecPort): Fit => {
|
|
76
|
+
const results: Fit[] = [];
|
|
77
|
+
for (const field of target.children ?? []) {
|
|
78
|
+
const given = childOf(source, field.key) ?? childOf(source, ITEM_KEY);
|
|
79
|
+
if (!given) {
|
|
80
|
+
if (!field.nullable) results.push(mismatch(`no field ${pythonRepr(field.key)}`));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
results.push(within(fits(given, field), field.key));
|
|
84
|
+
}
|
|
85
|
+
return join(results);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** Whether a local takes what a control writes (a BINDING's child), by the vocabulary's `bind_kinds`. */
|
|
89
|
+
export const bindingFits = (local: SpecPort, writes: SpecPort, bindKinds: Readonly<Record<string, readonly string[]>>): Fit => {
|
|
90
|
+
if (local.kind === null || writes.kind === null) return OPEN;
|
|
91
|
+
if (writes.kind === 'UNION') {
|
|
92
|
+
// The control writes one of them, by how it is set (a ToggleGroup's `multiple`).
|
|
93
|
+
const results = (writes.children ?? []).map(child => bindingFits(local, child, bindKinds));
|
|
94
|
+
if (results.some(result => result.status === 'ok')) return OK;
|
|
95
|
+
if (results.some(result => result.status === 'open')) return OPEN;
|
|
96
|
+
return mismatch(`a ${name(writes)} control writes none a ${name(local)} local takes`);
|
|
97
|
+
}
|
|
98
|
+
const allowed = bindKinds[writes.kind];
|
|
99
|
+
if (!allowed) return fits(writes, local);
|
|
100
|
+
if (!allowed.includes(local.kind)) {
|
|
101
|
+
return mismatch(`a ${name(writes)} control writes a ${[...allowed].sort().join(', ')} local, not a ${name(local)}`);
|
|
102
|
+
}
|
|
103
|
+
if (local.kind === writes.kind && ['LIST', 'DICT', 'MODEL'].includes(local.kind)) return fits(writes, local);
|
|
104
|
+
return OK;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** The port of a literal: its kind, and itself as its one choice. A list or an object is open. */
|
|
108
|
+
export const literalPort = (value: unknown): SpecPort => {
|
|
109
|
+
if (value === null || value === undefined) return {kind: null, nullable: true};
|
|
110
|
+
if (typeof value === 'boolean') return {kind: 'BOOL', choices: [{value}]};
|
|
111
|
+
if (typeof value === 'number') return {kind: Number.isInteger(value) ? 'INT' : 'FLOAT', choices: [{value}]};
|
|
112
|
+
if (typeof value === 'string') return {kind: 'STRING', choices: [{value}]};
|
|
113
|
+
return OPEN_PORT;
|
|
114
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The port a catalog types a prop by: arkitekt-spec's `declare/catalogs/ports.py`.
|
|
3
|
+
*
|
|
4
|
+
* An action's port (kind, identifier, nullable, choices, children, ...) plus three kinds only
|
|
5
|
+
* a catalog uses: CALLBACK (its children are the payload), ASSET (a file an app registered)
|
|
6
|
+
* and BINDING (its one child, keyed `...`, is what the control writes). A `kind` of null is
|
|
7
|
+
* open: it takes any value. A child is a port with a `key` and a `description`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const CALLBACK = 'CALLBACK';
|
|
11
|
+
export const ASSET = 'ASSET';
|
|
12
|
+
export const BINDING = 'BINDING';
|
|
13
|
+
export const ITEM_KEY = '...';
|
|
14
|
+
/** A STRUCTURE identifier that takes any structure. */
|
|
15
|
+
export const OPEN_STRUCTURE = '*';
|
|
16
|
+
|
|
17
|
+
export const PORT_KINDS: readonly string[] = [
|
|
18
|
+
'INT', 'STRING', 'STRUCTURE', 'LIST', 'BOOL', 'DICT', 'FLOAT', 'DATE', 'UNION', 'ENUM', 'MODEL',
|
|
19
|
+
'MEMORY_STRUCTURE', 'INTERFACE', 'QUANTITY', CALLBACK, ASSET, BINDING,
|
|
20
|
+
];
|
|
21
|
+
export const CATALOG_ONLY_KINDS: ReadonlySet<string> = new Set([CALLBACK, ASSET, BINDING]);
|
|
22
|
+
|
|
23
|
+
export type SpecChoice = {value: unknown; label?: string | null; description?: string | null};
|
|
24
|
+
|
|
25
|
+
export type SpecPort = {
|
|
26
|
+
kind: string | null;
|
|
27
|
+
identifier?: string | null;
|
|
28
|
+
nullable?: boolean;
|
|
29
|
+
choices?: readonly SpecChoice[] | null;
|
|
30
|
+
children?: readonly SpecChildPort[];
|
|
31
|
+
default?: unknown;
|
|
32
|
+
reference_unit?: string | null;
|
|
33
|
+
proposed_units?: readonly string[] | null;
|
|
34
|
+
dimension?: string | null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type SpecChildPort = SpecPort & {key: string; description?: string | null};
|
|
38
|
+
|
|
39
|
+
export const OPEN_PORT: SpecPort = {kind: null};
|
|
40
|
+
|
|
41
|
+
const IDENTIFIED: ReadonlySet<string> = new Set(['STRUCTURE', 'MEMORY_STRUCTURE', 'INTERFACE']);
|
|
42
|
+
const LEAVES: ReadonlySet<string> = new Set(['INT', 'STRING', 'BOOL', 'FLOAT', 'DATE', 'ENUM', 'QUANTITY', ASSET, ...IDENTIFIED]);
|
|
43
|
+
|
|
44
|
+
export const isIdentifiedKind = (kind: string | null | undefined): boolean => kind != null && IDENTIFIED.has(kind);
|
|
45
|
+
export const childOf = (port: SpecPort, key: string): SpecChildPort | undefined => port.children?.find(child => child.key === key);
|
|
46
|
+
|
|
47
|
+
type Raw = Record<string, unknown>;
|
|
48
|
+
const isRaw = (value: unknown): value is Raw => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
49
|
+
const field = (raw: Raw, snake: string): unknown => {
|
|
50
|
+
const [head, ...rest] = snake.split('_');
|
|
51
|
+
return raw[snake] ?? raw[head + rest.map(part => part[0].toUpperCase() + part.slice(1)).join('')];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** A port as a catalog writes one (snake or camel case); null is open. Throws on a malformed one. */
|
|
55
|
+
export const parsePort = (raw: unknown, where: string): SpecPort => {
|
|
56
|
+
if (raw === null || raw === undefined) return OPEN_PORT;
|
|
57
|
+
if (!isRaw(raw)) throw new Error(`${where}: a port is an object`);
|
|
58
|
+
const kind = raw.kind ?? null;
|
|
59
|
+
if (kind !== null && (typeof kind !== 'string' || !PORT_KINDS.includes(kind))) throw new Error(`${where}: unknown port kind ${String(kind)}`);
|
|
60
|
+
const children = (Array.isArray(raw.children) ? raw.children : []).map((child, index): SpecChildPort => {
|
|
61
|
+
if (!isRaw(child) || typeof child.key !== 'string') throw new Error(`${where}.${index}: a child port has a key`);
|
|
62
|
+
const description = typeof child.description === 'string' ? child.description : null;
|
|
63
|
+
return {key: child.key, ...parsePort(child, `${where}.${index}(${child.key})`), ...(description ? {description} : {})};
|
|
64
|
+
});
|
|
65
|
+
const port: SpecPort = {kind: kind as string | null};
|
|
66
|
+
if (typeof raw.identifier === 'string' && raw.identifier) port.identifier = raw.identifier;
|
|
67
|
+
if (raw.nullable === true) port.nullable = true;
|
|
68
|
+
if (Array.isArray(raw.choices)) {
|
|
69
|
+
port.choices = raw.choices.map(choice => {
|
|
70
|
+
if (isRaw(choice)) {
|
|
71
|
+
return {
|
|
72
|
+
value: choice.value,
|
|
73
|
+
...(typeof choice.label === 'string' ? {label: choice.label} : {}),
|
|
74
|
+
...(typeof choice.description === 'string' ? {description: choice.description} : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (['string', 'number', 'boolean'].includes(typeof choice)) return {value: choice};
|
|
78
|
+
throw new Error(`${where}: a choice is a value or {value, label}`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (children.length) port.children = children;
|
|
82
|
+
if (raw.default !== undefined && raw.default !== null) port.default = raw.default;
|
|
83
|
+
const unit = field(raw, 'reference_unit');
|
|
84
|
+
if (typeof unit === 'string' && unit) port.reference_unit = unit;
|
|
85
|
+
const units = field(raw, 'proposed_units');
|
|
86
|
+
if (Array.isArray(units) && units.length) port.proposed_units = units.map(String);
|
|
87
|
+
if (typeof raw.dimension === 'string' && raw.dimension) port.dimension = raw.dimension;
|
|
88
|
+
checkShape(port, where);
|
|
89
|
+
return port;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** What a kind needs: children, an identifier, choices (`check_shape`). Throws when it lacks one. */
|
|
93
|
+
export const checkShape = (port: SpecPort, where: string): void => {
|
|
94
|
+
const {kind} = port;
|
|
95
|
+
const children = port.children ?? [];
|
|
96
|
+
const count = children.length;
|
|
97
|
+
if (kind === null) return;
|
|
98
|
+
if (LEAVES.has(kind) && count) throw new Error(`${where}: a ${kind} port has no children`);
|
|
99
|
+
if (IDENTIFIED.has(kind) && !port.identifier) throw new Error(`${where}: a ${kind} port names its identifier`);
|
|
100
|
+
if (kind === 'ENUM' && !port.choices?.length) throw new Error(`${where}: an ENUM port lists its choices`);
|
|
101
|
+
if (kind === 'LIST' && count !== 1) throw new Error(`${where}: a LIST port has exactly one child, its item`);
|
|
102
|
+
if ((kind === 'DICT' || kind === 'MODEL') && count === 0) throw new Error(`${where}: a ${kind} port has children`);
|
|
103
|
+
if (kind === 'UNION' && count < 2) throw new Error(`${where}: a UNION port has at least two variants`);
|
|
104
|
+
if (kind === BINDING && (count !== 1 || children[0].key !== ITEM_KEY)) {
|
|
105
|
+
throw new Error(`${where}: a BINDING port has one child, keyed '...': the value it writes`);
|
|
106
|
+
}
|
|
107
|
+
const keys = children.map(child => child.key);
|
|
108
|
+
if (kind !== 'UNION' && new Set(keys).size !== keys.length) throw new Error(`${where}: child keys repeat`);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** The port as a catalog writes it (`port_json`): null for an open root, fields left out when empty. */
|
|
112
|
+
export const portJson = (port: SpecPort): Record<string, unknown> | null =>
|
|
113
|
+
port.kind === null && !port.children?.length ? null : portFields(port);
|
|
114
|
+
|
|
115
|
+
const portFields = (port: SpecPort): Record<string, unknown> => {
|
|
116
|
+
const out: Record<string, unknown> = {kind: port.kind};
|
|
117
|
+
if (port.identifier) out.identifier = port.identifier;
|
|
118
|
+
if (port.nullable) out.nullable = true;
|
|
119
|
+
if (port.choices) {
|
|
120
|
+
out.choices = port.choices.map(choice => ({
|
|
121
|
+
value: choice.value,
|
|
122
|
+
...(choice.label != null ? {label: choice.label} : {}),
|
|
123
|
+
...(choice.description != null ? {description: choice.description} : {}),
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
if (port.children?.length) {
|
|
127
|
+
out.children = port.children.map(child => ({key: child.key, ...portFields(child), ...(child.description ? {description: child.description} : {})}));
|
|
128
|
+
}
|
|
129
|
+
if (port.default !== undefined && port.default !== null) out.default = port.default;
|
|
130
|
+
if (port.reference_unit) out.reference_unit = port.reference_unit;
|
|
131
|
+
if (port.proposed_units?.length) out.proposed_units = [...port.proposed_units];
|
|
132
|
+
if (port.dimension) out.dimension = port.dimension;
|
|
133
|
+
return out;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** Whether the port, or any port below it, is open. */
|
|
137
|
+
export const hasOpenNode = (port: SpecPort): boolean => port.kind === null || (port.children ?? []).some(hasOpenNode);
|
|
138
|
+
|
|
139
|
+
/** A value as Python's `repr` writes it. */
|
|
140
|
+
export const pythonRepr = (value: unknown): string => {
|
|
141
|
+
if (typeof value === 'string') return `'${value}'`;
|
|
142
|
+
if (value === null || value === undefined) return 'None';
|
|
143
|
+
if (value === true) return 'True';
|
|
144
|
+
if (value === false) return 'False';
|
|
145
|
+
return JSON.stringify(value);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** The port as one line (`summary`): `LIST<STRING>`, `STRING | INT`, `CALLBACK(value: BOOL)`. */
|
|
149
|
+
export const portSummary = (port: SpecPort): string => {
|
|
150
|
+
const kind = port.kind ?? 'ANY';
|
|
151
|
+
const nullable = port.nullable ? '?' : '';
|
|
152
|
+
const children = port.children ?? [];
|
|
153
|
+
if (port.choices?.length && ['STRING', 'INT', 'FLOAT', 'ENUM'].includes(kind)) return port.choices.map(choice => pythonRepr(choice.value)).join(' | ') + nullable;
|
|
154
|
+
if (IDENTIFIED.has(kind)) return `${kind}(${port.identifier})${nullable}`;
|
|
155
|
+
if (kind === 'UNION') return children.map(portSummary).join(' | ') + nullable;
|
|
156
|
+
if (kind === 'LIST' || kind === BINDING) return `${kind}<${children[0] ? portSummary(children[0]) : 'ANY'}>${nullable}`;
|
|
157
|
+
if (kind === 'DICT' || kind === 'MODEL' || kind === CALLBACK) {
|
|
158
|
+
const inner = children.map(child => (child.key === ITEM_KEY ? portSummary(child) : `${child.key}: ${portSummary(child)}`)).join(', ');
|
|
159
|
+
const angled = kind === 'DICT' && children[0]?.key === ITEM_KEY;
|
|
160
|
+
return `${kind}${angled ? '<' : '('}${inner}${angled ? '>' : ')'}${nullable}`;
|
|
161
|
+
}
|
|
162
|
+
return kind + nullable;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** What a BINDING writes: its one child; any other port is itself. */
|
|
166
|
+
export const bindingWrites = (port: SpecPort): SpecPort => (port.kind === BINDING && port.children?.length ? port.children[0] : port);
|
|
167
|
+
|
|
168
|
+
/** The text a prop shows: `UNION(STRING, INT, FLOAT, BOOL)`. */
|
|
169
|
+
export const TEXT_PORT: SpecPort = {
|
|
170
|
+
kind: 'UNION',
|
|
171
|
+
children: ['STRING', 'INT', 'FLOAT', 'BOOL'].map((kind, index) => ({key: String(index), kind})),
|
|
172
|
+
};
|
package/src/spec/spec.test.ts
CHANGED
|
@@ -49,7 +49,7 @@ describe('the synced vocabulary', () => {
|
|
|
49
49
|
expect(vocabulary.callKinds).not.toContain('query_refetch');
|
|
50
50
|
expect(vocabulary.records.query.fields.map(field => field.key)).toContain('fetching_more');
|
|
51
51
|
expect(Object.keys(vocabulary.theme.dataAttributes).sort()).toEqual(['busy', 'stale']);
|
|
52
|
-
expect([vocabulary.vocab, vocabulary.minor]).toEqual([2,
|
|
52
|
+
expect([vocabulary.vocab, vocabulary.minor]).toEqual([2, 9]);
|
|
53
53
|
expect(vocabulary.baseCatalog).toBe('https://arkitekt.live/catalogs/base/v4');
|
|
54
54
|
expect(Object.values(vocabulary.bundledCatalogs)).toEqual(['catalogs/base@4.json', 'catalogs/orkestrator@1.json']);
|
|
55
55
|
expect(vocabulary.hostParts).toEqual(['args', 'arg', 'deps', 'dep', 'ask', 'returns', 'status', 'timeline', 'label', 'description', 'message', 'control', 'field']);
|
|
@@ -112,9 +112,12 @@ describe('the catalogs', () => {
|
|
|
112
112
|
|
|
113
113
|
it('take in what an app registers, and read a blok against the catalog it names', () => {
|
|
114
114
|
const lab = parseSpecCatalog(
|
|
115
|
-
{id: 'https://acme.example/catalogs/lab/v1', name: 'lab', version: 1, minor: 2, extends: ORKESTRATOR_CATALOG_ID, components: [{name: 'Spectrum', props: [{key: 'bands', kind: 'LIST', since: 2}]}]},
|
|
115
|
+
{id: 'https://acme.example/catalogs/lab/v1', name: 'lab', version: 1, minor: 2, extends: ORKESTRATOR_CATALOG_ID, components: [{name: 'Spectrum', props: [{key: 'bands', port: {kind: 'LIST', children: [{key: '...', kind: 'FLOAT'}]}, since: 2}]}]},
|
|
116
116
|
'lab',
|
|
117
117
|
);
|
|
118
|
+
expect(lab.components[0].props[0].port).toEqual({kind: 'LIST', children: [{key: '...', kind: 'FLOAT'}]});
|
|
119
|
+
expect(() => parseSpecCatalog({name: 'old', components: [{name: 'Dial', props: [{key: 'level', kind: 'FLOAT'}]}]}, 'old')).toThrow(/typed by a kind/);
|
|
120
|
+
expect(() => parseSpecCatalog({name: 'odd', components: [{name: 'Dial', props: [{key: 'level', port: {kind: 'LIST'}}]}]}, 'odd')).toThrow(/one child/);
|
|
118
121
|
expect(blokViewFor(lab.id).complete).toBe(false);
|
|
119
122
|
registerBlokCatalog(lab);
|
|
120
123
|
const view = blokViewFor(lab.id);
|
package/src/spec/vocabulary.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"vocab": 2,
|
|
3
|
-
"minor":
|
|
3
|
+
"minor": 9,
|
|
4
4
|
"description": "The blok language, version 2: what a blok may read, call and store. The spec's parser, the server (rekuest_core, takt) and the renderer (orkestrator) load this file or are generated from it. The design is the blok-vocab-v2 proposal of 2026-10-25. Three layers, each versioned on its own: this language (vocab, and minor for what it gained since); the base catalog, everything every renderer draws; and the app catalogs that extend it with what one frontend draws beyond (see catalogs). A server holds a blok to the language alone, never to a catalog: whoever draws a blok checks it against the catalog it has, and an author's tooling checks it when asked.",
|
|
5
5
|
"roots": {
|
|
6
6
|
"data": {
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"query": "<query name=\"x\" service=\"mikro\" document=\"query (...) {...}\" poll={5} more=\"items\"><var key=\"k\" value={...} /></query>: a declared read, queries.<name>. A child of <Blok>, before its content.",
|
|
100
100
|
"subscription": "<subscription name=\"x\" service=\"mikro\" document=\"subscription (...) {...}\" keep={10} history=\"q\"><var key=\"k\" value={...} /></subscription>: a declared stream, subscriptions.<name>. A child of <Blok>, before its content.",
|
|
101
101
|
"dependencies": "<dependencies key=\"cells\" like=\"self.<action>\" />: the dependencies of one of the app's own actions, for an agent blok to read, call and hand to a run of it. A custom blok declares those of an action of an agent it is bound to: like=\"agents.<name>.<action>\" (stored deps.<name>.<action>). Each is read through the key, bare: cells.<dependency>.<state>.<field>, cells.<dependency>.<action>(...), cells.<dependency>.connected (stored as the blok's dependency deps.cells__<dependency>). cells.options.<dependency> lists the agents that fit one ({id, name, connected, picked}) and cells.pick(<dependency>: <agent id>) binds it; <deppicker key=\"cells.<dependency>\" /> is the ready-made picker. Which agent each is bound to is the viewer's own choice, kept on their device and never on a server; until they choose it is seeded once, with the agent the latest run of the action had, else the only one that fits. A child of <Blok>, after its locals and before what reads through it; an agent blok only. An action whose dependency is called options or pick cannot be read through one.",
|
|
102
|
+
"logo": "<logo title=\"Microscope\"><Circle cx=\"12\" cy=\"12\" r=\"7\" /></logo>: the blok's own logo, standing for it in lists, pins and tabs. A child of <Blok>, one, in a blok that is no logo. It holds a drawing of the logo catalog on a 24-unit grid (viewBox=\"0 0 24 24\" unless it says otherwise), painted with the logo pens and drawn with the action logos' pen (fill none, stroke ink, round) unless a shape says otherwise. title and viewBox are literals, and so is everything it draws: a fixed drawing that reads nothing. It is checked and drawn as a logo blok of its own.",
|
|
102
103
|
"var": "<var key=\"k\" value={expression or literal} />: one variable of a query or subscription; an expression over args, blok-level locals and agents."
|
|
103
104
|
}
|
|
104
105
|
},
|
|
@@ -388,7 +389,7 @@
|
|
|
388
389
|
"any": "ANY is a local's kind only (no action port is ever ANY): an untyped value. It is never an error and gets no warning; it skips the bind_kinds and arg_kinds checks and a path below it is taken as written. A renderer treats it as an untyped value.",
|
|
389
390
|
"kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "A given kind and like= come before rule 1. Only uses inside the local's scope (its parent's subtree) count. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
|
|
390
391
|
"bind": "bind={<local>} or bind={<local>.<field>...}: the control writes the local; nothing else does. The catalog's kind of the bind prop is what the control writes: the local (or the field of it bound) must be a port kind bind_kinds lists for it.",
|
|
391
|
-
"bind_kinds": {"description": "Per
|
|
392
|
+
"bind_kinds": {"description": "Per kind a control writes (the one child of its bind prop's BINDING port), the port kinds of the locals it may write. A kind not listed writes a local of its own kind; an open child writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
|
|
392
393
|
"arg_kinds": {"description": "Per port kind of a local passed whole as a task call's argument, the kinds of the action's arg port that take it, where the action is known (agent self.<action> demands, an action's dependencies). STRUCTURE also needs the same identifier. An ANY local is not checked.", "STRING": ["STRING"], "INT": ["INT", "FLOAT"], "FLOAT": ["FLOAT"], "BOOL": ["BOOL"], "ENUM": ["ENUM", "STRING"], "DATE": ["DATE", "STRING"], "QUANTITY": ["QUANTITY", "FLOAT"], "LIST": ["LIST"], "DICT": ["DICT"], "MODEL": ["MODEL", "DICT"], "STRUCTURE": ["STRUCTURE"]}
|
|
393
394
|
},
|
|
394
395
|
"theme": {
|
|
@@ -429,7 +430,7 @@
|
|
|
429
430
|
"logo_path_data_props": ["d", "points"]
|
|
430
431
|
},
|
|
431
432
|
"catalogs": {
|
|
432
|
-
"description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
|
|
433
|
+
"description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it. Every prop, and every argument and result of an operation, is typed by a port: the port of an action's argument (kind, identifier, nullable, choices, children), plus three kinds only a catalog types by -- CALLBACK (its children are the payload, event.<key>), ASSET (a file an app registered) and BINDING (its one child, keyed '...', is what the control writes). A port of no kind is open: only the language's own props and generic operations are.",
|
|
433
434
|
"base": "https://arkitekt.live/catalogs/base/v4",
|
|
434
435
|
"bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
|
|
435
436
|
"id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
|
|
@@ -479,9 +480,9 @@
|
|
|
479
480
|
"callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
|
|
480
481
|
"callback.with": {"level": "error", "message": "with hands a task call the dependencies the blok declares for that action: `self.<action>(...) with <key>`, in a custom blok `agents.<name>.<action>(...) with <key>`.", "hint": "Write `self.<action>(name: value) with cells into run`, where the blok declares <dependencies key=\"cells\" like=\"self.<action>\" />."},
|
|
481
482
|
"callback.into": {"level": "error", "message": "into names the record of a task call: `<call> into <name>`.", "hint": "Write `deps.<key>.<action>(name: value) into run`, then read run.running, run.returns.<port>."},
|
|
482
|
-
"callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog
|
|
483
|
+
"callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog types them CALLBACK), or compute {key} without a call."},
|
|
483
484
|
"callback.unbound": {"level": "error", "message": "{key} of <{component}> is a callback prop: it holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer, assign.start, port.set).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
|
|
484
|
-
"callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields
|
|
485
|
+
"callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields its CALLBACK port lists for {key}: {fields}."},
|
|
485
486
|
"roots.unknown": {"level": "error", "message": "{path} reads {root!r}, which is no root, local, loop variable or record of this blok.", "hint": "Read a root this blok has (deps.<key>, args.<key>, queries.<name>, ...), a declared local, a foreach let or index, or an into record."},
|
|
486
487
|
"roots.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok has no {root!r} (it reads {roots}).", "hint": "Read one of {roots} instead."},
|
|
487
488
|
"roots.custom_deps": {"level": "error", "message": "{path}: a custom blok reads an agent it is bound to as agents.<key>, not deps.<key>.", "hint": "Write agents.<key> instead: the same path, from agents."},
|
|
@@ -532,6 +533,8 @@
|
|
|
532
533
|
"palette.raw_colour": {"level": "warning", "message": "{token}: a blok picks a colour role, not a colour; try {suggestion}."},
|
|
533
534
|
"palette.logo_paint": {"level": "error", "message": "<{component}> paints {prop}={value!r}; a logo paints with {pens} or url(#id)."},
|
|
534
535
|
"palette.scene_colour": {"level": "warning", "message": "<{component}> {prop}={value!r} is no colour of the theme; a scene picks a colour role ({roles}).", "hint": "Pick one of the colour roles listed."},
|
|
536
|
+
"props.type": {"level": "warning", "message": "{key} of <{component}> takes {expected}, but {value} does not fit: {reason}.", "hint": "Give {key} a value of the type the catalog lists for it ({expected})."},
|
|
537
|
+
"port.catalog_only": {"level": "error", "message": "{path} is a {kind} port: CALLBACK, ASSET and BINDING type a catalog's props, never an action's, a state's or a local's.", "hint": "Type the port by the value it holds (a STRING, a STRUCTURE, ...)."},
|
|
535
538
|
"props.literal_type": {"level": "error", "message": "<{component}> {key}={value!r} is a string, but {key} takes a {kind}; write {hint}.", "hint": "Write the value as an expression in braces: {key}={{...}}."},
|
|
536
539
|
"foreach.position_key": {"level": "warning", "message": "<foreach let=\"{let}\"> has no key, so its items are keyed by their position; they are not scalars, so key them by a stable field (key={{{let}.id}})."},
|
|
537
540
|
"returns.unnamed": {"level": "warning", "message": "{path} reads {port}, a return the action left unnamed; name it in the action, as Annotated[T, Key(\"name\")] or as a field of a NamedTuple return, and read it by that name."},
|
|
@@ -544,6 +547,10 @@
|
|
|
544
547
|
"calls.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok calls no agent.", "hint": "A port blok is a field of a form: read the agent's state and write the port (port.set(...), bind={{port.value}}). What starts a task belongs in the action's assign blok."},
|
|
545
548
|
"assign.kind": {"level": "error", "message": "{what} belongs to starting a run, so only an action's assign blok holds it, not a{n} {kind} blok.", "hint": "Make it <Blok kind=\"assign\"> in the action's bloks=[...]."},
|
|
546
549
|
"logo.complexity": {"level": "error", "message": "{detail}"},
|
|
550
|
+
"logo.misplaced": {"level": "error", "message": "A <logo> is a child of the <Blok> it stands for, not inside another element.", "hint": "Move it to the top of the blok, beside its queries."},
|
|
551
|
+
"logo.twice": {"level": "error", "message": "A blok has one <logo>; this is a second one."},
|
|
552
|
+
"logo.in_logo": {"level": "error", "message": "A logo blok is a logo already: it declares no <logo> of its own.", "hint": "Draw it in the blok's <Logo> instead."},
|
|
553
|
+
"logo.dynamic": {"level": "warning", "message": "<{component}> sets {prop} with an expression; a <logo> is a fixed drawing that reads nothing, so it is drawn without it.", "hint": "Write the value as a literal."},
|
|
547
554
|
"catalog.unknown_component": {"level": "warning", "message": "<{component}> is not in the catalog the blok is written for ({catalogs}).", "hint": "Look the component up in the catalog; names are case-sensitive."},
|
|
548
555
|
"catalog.children": {"level": "warning", "message": "<{component}> takes no children.", "hint": "Close <{component}> without children (<{component} ... />), or put them beside it."},
|
|
549
556
|
"catalog.text": {"level": "warning", "message": "<{component}> {detail}", "hint": "Put the text in a component that draws it (<Text>, <p>, <span>), or set it once."},
|