Skip to content

Commit 9c31af2

Browse files
authored
Revert #515 and modify stringFormat to take named args. (#573)
1 parent 20d6471 commit 9c31af2

File tree

9 files changed

+316
-201
lines changed

9 files changed

+316
-201
lines changed

specification/v0_9/docs/a2ui_protocol.md

Lines changed: 41 additions & 40 deletions
Large diffs are not rendered by default.

specification/v0_9/docs/evolution_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Specifying an unknown surfaceId will cause an error. It is recommended that clie
228228

229229
- **String Formatting**: Introduced the `formatString` function, which supports `${expression}` syntax for interpolation.
230230
- **Unified Expression Language**: Allows embedding JSON Pointer paths (absolute and relative) and client-side function calls directly within the format string.
231-
- **Nesting**: Supports recursive nesting of expressions (e.g., `${formatDate(${/timestamp}, 'yyyy-MM-dd')}`).
231+
- **Nesting**: Supports recursive nesting of expressions (e.g., `${formatDate(value: ${/timestamp}, format: 'yyyy-MM-dd')}`).
232232
- **Restriction**: String interpolation `${...}` is **ONLY** supported within the `formatString` function. It is not supported in general for string properties, in order to strictly separate data binding definitions from static content.
233233
- **Reason**: Improves readability for complex strings. Instead of generating complex nested JSON objects (like chained concatenations) to combine strings and data, the model can write natural-looking template literals within the `formatString` function.
234234

specification/v0_9/eval/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ function loadSchemas(): Record<string, any> {
4040
const schema = JSON.parse(schemaString);
4141
schemas[path.basename(file)] = schema;
4242
}
43+
44+
// Alias standard_catalog.json to catalog.json to match server_to_client.json references
45+
// This mirrors the logic in run_tests.py
46+
if (schemas["standard_catalog.json"]) {
47+
const catalogSchema = JSON.parse(
48+
JSON.stringify(schemas["standard_catalog.json"]),
49+
);
50+
if (catalogSchema["$id"]) {
51+
catalogSchema["$id"] = catalogSchema["$id"].replace(
52+
"standard_catalog.json",
53+
"catalog.json",
54+
);
55+
}
56+
schemas["catalog.json"] = catalogSchema;
57+
}
58+
4359
return schemas;
4460
}
4561

specification/v0_9/json/common_types.json

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,43 @@
7474
"DynamicValue": {
7575
"description": "A value that can be a literal, a path, or a function call returning any type.",
7676
"oneOf": [
77-
{ "type": "string" },
78-
{ "type": "number" },
79-
{ "type": "boolean" },
80-
{ "$ref": "#/$defs/DataBinding" },
81-
{ "$ref": "#/$defs/FunctionCall" }
77+
{
78+
"type": "string"
79+
},
80+
{
81+
"type": "number"
82+
},
83+
{
84+
"type": "boolean"
85+
},
86+
{
87+
"$ref": "#/$defs/DataBinding"
88+
},
89+
{
90+
"$ref": "#/$defs/FunctionCall"
91+
}
8292
]
8393
},
8494
"DynamicString": {
8595
"description": "Represents a string",
8696
"oneOf": [
87-
{ "type": "string" },
88-
{ "$ref": "#/$defs/DataBinding" },
97+
{
98+
"type": "string"
99+
},
100+
{
101+
"$ref": "#/$defs/DataBinding"
102+
},
89103
{
90104
"allOf": [
91-
{ "$ref": "#/$defs/FunctionCall" },
92105
{
93-
"properties": { "returnType": { "const": "string" } },
106+
"$ref": "#/$defs/FunctionCall"
107+
},
108+
{
109+
"properties": {
110+
"returnType": {
111+
"const": "string"
112+
}
113+
},
94114
"required": ["returnType"]
95115
}
96116
]
@@ -100,13 +120,23 @@
100120
"DynamicNumber": {
101121
"description": "Represents a value that can be either a literal number, a path to a number in the data model, or a function call returning a number.",
102122
"oneOf": [
103-
{ "type": "number" },
104-
{ "$ref": "#/$defs/DataBinding" },
123+
{
124+
"type": "number"
125+
},
126+
{
127+
"$ref": "#/$defs/DataBinding"
128+
},
105129
{
106130
"allOf": [
107-
{ "$ref": "#/$defs/FunctionCall" },
108131
{
109-
"properties": { "returnType": { "const": "number" } },
132+
"$ref": "#/$defs/FunctionCall"
133+
},
134+
{
135+
"properties": {
136+
"returnType": {
137+
"const": "number"
138+
}
139+
},
110140
"required": ["returnType"]
111141
}
112142
]
@@ -116,24 +146,40 @@
116146
"DynamicBoolean": {
117147
"description": "A boolean value that can be a literal, a path, or a logic expression (including function calls returning boolean).",
118148
"oneOf": [
119-
{ "type": "boolean" },
120-
{ "$ref": "#/$defs/DataBinding" },
121-
{ "$ref": "#/$defs/LogicExpression" }
149+
{
150+
"type": "boolean"
151+
},
152+
{
153+
"$ref": "#/$defs/DataBinding"
154+
},
155+
{
156+
"$ref": "#/$defs/LogicExpression"
157+
}
122158
]
123159
},
124160
"DynamicStringList": {
125161
"description": "Represents a value that can be either a literal array of strings, a path to a string array in the data model, or a function call returning a string array.",
126162
"oneOf": [
127163
{
128164
"type": "array",
129-
"items": { "type": "string" }
165+
"items": {
166+
"type": "string"
167+
}
168+
},
169+
{
170+
"$ref": "#/$defs/DataBinding"
130171
},
131-
{ "$ref": "#/$defs/DataBinding" },
132172
{
133173
"allOf": [
134-
{ "$ref": "#/$defs/FunctionCall" },
135174
{
136-
"properties": { "returnType": { "const": "array" } },
175+
"$ref": "#/$defs/FunctionCall"
176+
},
177+
{
178+
"properties": {
179+
"returnType": {
180+
"const": "array"
181+
}
182+
},
137183
"required": ["returnType"]
138184
}
139185
]
@@ -149,11 +195,13 @@
149195
"description": "The name of the function to call."
150196
},
151197
"args": {
152-
"type": "array",
198+
"type": "object",
153199
"description": "Arguments passed to the function.",
154-
"items": {
200+
"additionalProperties": {
155201
"anyOf": [
156-
{ "$ref": "#/$defs/DynamicValue" },
202+
{
203+
"$ref": "#/$defs/DynamicValue"
204+
},
157205
{
158206
"type": "object",
159207
"description": "A literal object argument (e.g. configuration)."
@@ -164,7 +212,15 @@
164212
"returnType": {
165213
"type": "string",
166214
"description": "The expected return type of the function call.",
167-
"enum": ["string", "number", "boolean", "array", "object", "any", "void"],
215+
"enum": [
216+
"string",
217+
"number",
218+
"boolean",
219+
"array",
220+
"object",
221+
"any",
222+
"void"
223+
],
168224
"default": "boolean"
169225
}
170226
},

0 commit comments

Comments
 (0)