@adecore/intelligent-ui 0.23.1 → 0.24.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/catalog.d.ts +3 -3
- package/dist/catalog.js +3 -3
- package/dist/query.d.ts +1 -1
- package/dist/query.js +7 -2
- package/dist/text.js +1 -2
- package/package.json +1 -1
- package/src/catalog.ts +3 -3
- package/src/query.ts +8 -2
- package/src/text.ts +1 -2
package/dist/catalog.d.ts
CHANGED
|
@@ -34,8 +34,8 @@ export declare const UI_GROUPS: {
|
|
|
34
34
|
readonly rules: 'Bind value={$name}. A Button sets a literal with action={@Set($name, value)} or restores a default with {@Reset($name)} or {@Reset()}. State stays local until a Choice sends visible context.';
|
|
35
35
|
};
|
|
36
36
|
readonly choices: {
|
|
37
|
-
readonly description: 'Offer
|
|
38
|
-
readonly rules: 'Never
|
|
37
|
+
readonly description: 'Offer shortcuts after finished work that the person may ignore.';
|
|
38
|
+
readonly rules: 'Never a question your turn waits on (a missing fact, a decision, a go-ahead for work you would otherwise do): ask that with your own question tool if you have one, otherwise in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.';
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
export declare const UI_CATALOG: {
|
|
@@ -355,7 +355,7 @@ export declare const UI_CATALOG: {
|
|
|
355
355
|
};
|
|
356
356
|
readonly Choices: {
|
|
357
357
|
readonly group: 'choices';
|
|
358
|
-
readonly description: '
|
|
358
|
+
readonly description: 'Shortcuts after finished work, never a question you wait on.';
|
|
359
359
|
readonly schema: z.ZodObject<{}, z.core.$strict>;
|
|
360
360
|
readonly children: readonly ['Choice'];
|
|
361
361
|
};
|
package/dist/catalog.js
CHANGED
|
@@ -23,8 +23,8 @@ export const UI_GROUPS = {
|
|
|
23
23
|
rules: 'Bind value={$name}. A Button sets a literal with action={@Set($name, value)} or restores a default with {@Reset($name)} or {@Reset()}. State stays local until a Choice sends visible context.'
|
|
24
24
|
},
|
|
25
25
|
choices: {
|
|
26
|
-
description: 'Offer
|
|
27
|
-
rules: 'Never
|
|
26
|
+
description: 'Offer shortcuts after finished work that the person may ignore.',
|
|
27
|
+
rules: 'Never a question your turn waits on (a missing fact, a decision, a go-ahead for work you would otherwise do): ask that with your own question tool if you have one, otherwise in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.'
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
export const UI_CATALOG = {
|
|
@@ -131,7 +131,7 @@ export const UI_CATALOG = {
|
|
|
131
131
|
description: 'Repeat children over local data.',
|
|
132
132
|
schema: z.strictObject({ items: z.array(z.unknown()).max(1000), as: name.regex(/^[A-Za-z_][A-Za-z_\d]*$/) })
|
|
133
133
|
},
|
|
134
|
-
Choices: { group: 'choices', description: '
|
|
134
|
+
Choices: { group: 'choices', description: 'Shortcuts after finished work, never a question you wait on.', schema: empty, children: ['Choice'] },
|
|
135
135
|
Choice: {
|
|
136
136
|
group: 'choices',
|
|
137
137
|
description: 'Send its label and visible context once.',
|
package/dist/query.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import type { UiBlock } from './compiler.ts';
|
|
|
3
3
|
import { type UiValue } from './expression.ts';
|
|
4
4
|
import { UiState } from './runtime.ts';
|
|
5
5
|
export declare function uiValidatedState(block: UiBlock, input?: Readonly<Record<string, unknown>>, queries?: Readonly<Record<string, unknown>>, limits?: Partial<UiLimits>): UiState;
|
|
6
|
-
export declare function uiQueryArguments(block: UiBlock, name: string, input?: Readonly<Record<string, unknown>>, limits?: Partial<UiLimits
|
|
6
|
+
export declare function uiQueryArguments(block: UiBlock, name: string, input?: Readonly<Record<string, unknown>>, limits?: Partial<UiLimits>, queries?: Readonly<Record<string, unknown>>): Record<string, UiValue>;
|
|
7
7
|
export declare function uiQueryFallback(block: UiBlock, queries: Readonly<Record<string, unknown>>): string;
|
package/dist/query.js
CHANGED
|
@@ -32,11 +32,16 @@ export function uiValidatedState(block, input = {}, queries = {}, limits = {}) {
|
|
|
32
32
|
}
|
|
33
33
|
return state;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/*
|
|
36
|
+
* `queries` are the readings the person saw, so an input chosen from options a query read is checked
|
|
37
|
+
* against them; without them such an input only passes as its default. The arguments themselves read
|
|
38
|
+
* only local state.
|
|
39
|
+
*/
|
|
40
|
+
export function uiQueryArguments(block, name, input = {}, limits = {}, queries = {}) {
|
|
36
41
|
if (!Object.hasOwn(block.queries, name)) {
|
|
37
42
|
throw new UiFailure('invalid_query', 'This block does not declare that query.');
|
|
38
43
|
}
|
|
39
|
-
const state = uiValidatedState(block, input,
|
|
44
|
+
const state = uiValidatedState(block, input, queries, limits);
|
|
40
45
|
const query = block.queries[name];
|
|
41
46
|
return query.expression
|
|
42
47
|
? evaluateUiExpression(query.expression, state.scope(), new UiBudget(limits))
|
package/dist/text.js
CHANGED
|
@@ -19,12 +19,11 @@ function uiExample(language) {
|
|
|
19
19
|
'<Summary badge="Draft">Release overview</Summary>',
|
|
20
20
|
'<Stats><Stat label="Tests" value={42}/></Stats>',
|
|
21
21
|
'<Switch value={$enabled}>Notify me</Switch>',
|
|
22
|
-
'<Choices><Choice context="Review the release overview">Continue</Choice></Choices>',
|
|
23
22
|
'```'
|
|
24
23
|
].join('\n');
|
|
25
24
|
}
|
|
26
25
|
export function uiSessionNote({ fenceLanguage = UI_FENCE_LANGUAGE } = {}) {
|
|
27
|
-
return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices
|
|
26
|
+
return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices are shortcuts after finished work that the person may ignore. When your turn would end waiting on the person (a missing fact, a decision, a go-ahead for work you would otherwise do), ask with your own question tool if you have one, otherwise in prose, never with Choices. Choice labels and precise context stay visible and send once. Image: attachment or generated="latest", never URL/path. No code execution. State resets on reload. Catalog (? means optional props): ${uiCompactCatalog()}\nExample:\n${uiExample(fenceLanguage)}\n`;
|
|
28
27
|
}
|
|
29
28
|
export function uiReferenceText({ fenceLanguage = UI_FENCE_LANGUAGE } = {}) {
|
|
30
29
|
const groups = Object.entries(UI_GROUPS)
|
package/package.json
CHANGED
package/src/catalog.ts
CHANGED
|
@@ -27,8 +27,8 @@ export const UI_GROUPS = {
|
|
|
27
27
|
rules: 'Bind value={$name}. A Button sets a literal with action={@Set($name, value)} or restores a default with {@Reset($name)} or {@Reset()}. State stays local until a Choice sends visible context.'
|
|
28
28
|
},
|
|
29
29
|
choices: {
|
|
30
|
-
description: 'Offer
|
|
31
|
-
rules: 'Never
|
|
30
|
+
description: 'Offer shortcuts after finished work that the person may ignore.',
|
|
31
|
+
rules: 'Never a question your turn waits on (a missing fact, a decision, a go-ahead for work you would otherwise do): ask that with your own question tool if you have one, otherwise in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.'
|
|
32
32
|
}
|
|
33
33
|
} as const;
|
|
34
34
|
|
|
@@ -136,7 +136,7 @@ export const UI_CATALOG = {
|
|
|
136
136
|
description: 'Repeat children over local data.',
|
|
137
137
|
schema: z.strictObject({ items: z.array(z.unknown()).max(1000), as: name.regex(/^[A-Za-z_][A-Za-z_\d]*$/) })
|
|
138
138
|
},
|
|
139
|
-
Choices: { group: 'choices', description: '
|
|
139
|
+
Choices: { group: 'choices', description: 'Shortcuts after finished work, never a question you wait on.', schema: empty, children: ['Choice'] },
|
|
140
140
|
Choice: {
|
|
141
141
|
group: 'choices',
|
|
142
142
|
description: 'Send its label and visible context once.',
|
package/src/query.ts
CHANGED
|
@@ -40,16 +40,22 @@ export function uiValidatedState(
|
|
|
40
40
|
return state;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/*
|
|
44
|
+
* `queries` are the readings the person saw, so an input chosen from options a query read is checked
|
|
45
|
+
* against them; without them such an input only passes as its default. The arguments themselves read
|
|
46
|
+
* only local state.
|
|
47
|
+
*/
|
|
43
48
|
export function uiQueryArguments(
|
|
44
49
|
block: UiBlock,
|
|
45
50
|
name: string,
|
|
46
51
|
input: Readonly<Record<string, unknown>> = {},
|
|
47
|
-
limits: Partial<UiLimits> = {}
|
|
52
|
+
limits: Partial<UiLimits> = {},
|
|
53
|
+
queries: Readonly<Record<string, unknown>> = {}
|
|
48
54
|
): Record<string, UiValue> {
|
|
49
55
|
if (!Object.hasOwn(block.queries, name)) {
|
|
50
56
|
throw new UiFailure('invalid_query', 'This block does not declare that query.');
|
|
51
57
|
}
|
|
52
|
-
const state = uiValidatedState(block, input,
|
|
58
|
+
const state = uiValidatedState(block, input, queries, limits);
|
|
53
59
|
const query = block.queries[name];
|
|
54
60
|
return query.expression
|
|
55
61
|
? (evaluateUiExpression(query.expression, state.scope(), new UiBudget(limits)) as Record<string, UiValue>)
|
package/src/text.ts
CHANGED
|
@@ -27,13 +27,12 @@ function uiExample(language: string): string {
|
|
|
27
27
|
'<Summary badge="Draft">Release overview</Summary>',
|
|
28
28
|
'<Stats><Stat label="Tests" value={42}/></Stats>',
|
|
29
29
|
'<Switch value={$enabled}>Notify me</Switch>',
|
|
30
|
-
'<Choices><Choice context="Review the release overview">Continue</Choice></Choices>',
|
|
31
30
|
'```'
|
|
32
31
|
].join('\n');
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export function uiSessionNote({ fenceLanguage = UI_FENCE_LANGUAGE }: UiTextOptions = {}): string {
|
|
36
|
-
return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices
|
|
35
|
+
return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices are shortcuts after finished work that the person may ignore. When your turn would end waiting on the person (a missing fact, a decision, a go-ahead for work you would otherwise do), ask with your own question tool if you have one, otherwise in prose, never with Choices. Choice labels and precise context stay visible and send once. Image: attachment or generated="latest", never URL/path. No code execution. State resets on reload. Catalog (? means optional props): ${uiCompactCatalog()}\nExample:\n${uiExample(fenceLanguage)}\n`;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export function uiReferenceText({ fenceLanguage = UI_FENCE_LANGUAGE }: UiTextOptions = {}): string {
|