mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
fix(client): use correct put/delete config wire shape
ConfigApi.putConfig and deleteConfig (and the duplicate in FlowsApi) sent
a flat values:[{type,key,value}] array and a keys:{type,key} object —
neither matches the ConfigService schema, which requires keys:[namespace,
...innerKeys] and values:Record<string,unknown>. Every save in the
workbench /mcp-tools page returned `Put requires at least one key
(namespace)`.
putConfig now groups items by type (namespace) and issues one put per
group; deleteConfig sends keys:[type, key].
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f8252ecd54
commit
4c356cd24c
1 changed files with 56 additions and 26 deletions
|
|
@ -1138,28 +1138,43 @@ export class FlowsApi {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates configuration values
|
||||
* Updates configuration values. Items are grouped by `type` (the namespace);
|
||||
* one put request is issued per distinct type.
|
||||
*/
|
||||
putConfig(values: { type: string; key: string; value: string }[]) {
|
||||
return this.api.makeRequest<ConfigRequest, ConfigResponse>(
|
||||
"config",
|
||||
{
|
||||
operation: "put",
|
||||
values: values,
|
||||
},
|
||||
60000,
|
||||
);
|
||||
putConfig(items: { type: string; key: string; value: string }[]) {
|
||||
const byType = new Map<string, Record<string, unknown>>();
|
||||
for (const item of items) {
|
||||
let group = byType.get(item.type);
|
||||
if (!group) {
|
||||
group = {};
|
||||
byType.set(item.type, group);
|
||||
}
|
||||
group[item.key] = item.value;
|
||||
}
|
||||
return Promise.all(
|
||||
[...byType.entries()].map(([type, values]) =>
|
||||
this.api.makeRequest<ConfigRequest, ConfigResponse>(
|
||||
"config",
|
||||
{
|
||||
operation: "put",
|
||||
keys: [type],
|
||||
values,
|
||||
},
|
||||
60000,
|
||||
),
|
||||
),
|
||||
).then((responses) => responses[responses.length - 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes configuration entries
|
||||
* Deletes a configuration entry
|
||||
*/
|
||||
deleteConfig(keys: { type: string; key: string }) {
|
||||
deleteConfig(target: { type: string; key: string }) {
|
||||
return this.api.makeRequest<ConfigRequest, ConfigResponse>(
|
||||
"config",
|
||||
{
|
||||
operation: "delete",
|
||||
keys: keys,
|
||||
keys: [target.type, target.key],
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
|
@ -2031,28 +2046,43 @@ export class ConfigApi {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates configuration values
|
||||
* Updates configuration values. Items are grouped by `type` (the namespace);
|
||||
* one put request is issued per distinct type.
|
||||
*/
|
||||
putConfig(values: { type: string; key: string; value: string }[]) {
|
||||
return this.api.makeRequest<ConfigRequest, ConfigResponse>(
|
||||
"config",
|
||||
{
|
||||
operation: "put",
|
||||
values: values,
|
||||
},
|
||||
60000,
|
||||
);
|
||||
putConfig(items: { type: string; key: string; value: string }[]) {
|
||||
const byType = new Map<string, Record<string, unknown>>();
|
||||
for (const item of items) {
|
||||
let group = byType.get(item.type);
|
||||
if (!group) {
|
||||
group = {};
|
||||
byType.set(item.type, group);
|
||||
}
|
||||
group[item.key] = item.value;
|
||||
}
|
||||
return Promise.all(
|
||||
[...byType.entries()].map(([type, values]) =>
|
||||
this.api.makeRequest<ConfigRequest, ConfigResponse>(
|
||||
"config",
|
||||
{
|
||||
operation: "put",
|
||||
keys: [type],
|
||||
values,
|
||||
},
|
||||
60000,
|
||||
),
|
||||
),
|
||||
).then((responses) => responses[responses.length - 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes configuration entries
|
||||
* Deletes a configuration entry
|
||||
*/
|
||||
deleteConfig(keys: { type: string; key: string }) {
|
||||
deleteConfig(target: { type: string; key: string }) {
|
||||
return this.api.makeRequest<ConfigRequest, ConfigResponse>(
|
||||
"config",
|
||||
{
|
||||
operation: "delete",
|
||||
keys: keys,
|
||||
keys: [target.type, target.key],
|
||||
},
|
||||
30000,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue