@widgentic/designer 0.1.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/action-designer.d.ts +35 -0
- package/dist/action-designer.d.ts.map +1 -0
- package/dist/action-designer.js +294 -0
- package/dist/action-designer.js.map +1 -0
- package/dist/action-editor.d.ts +49 -0
- package/dist/action-editor.d.ts.map +1 -0
- package/dist/action-editor.js +515 -0
- package/dist/action-editor.js.map +1 -0
- package/dist/browser/widgentic-designer.js +433 -0
- package/dist/browser/widgentic-designer.js.map +7 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +12 -0
- package/dist/browser.js.map +1 -0
- package/dist/dom.d.ts +37 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +387 -0
- package/dist/dom.js.map +1 -0
- package/dist/element.d.ts +12 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +131 -0
- package/dist/element.js.map +1 -0
- package/dist/highlight.d.ts +30 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +123 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +6 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +10 -0
- package/dist/internal.js.map +1 -0
- package/dist/io.d.ts +32 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +155 -0
- package/dist/io.js.map +1 -0
- package/dist/json-tree-editor.d.ts +8 -0
- package/dist/json-tree-editor.d.ts.map +1 -0
- package/dist/json-tree-editor.js +186 -0
- package/dist/json-tree-editor.js.map +1 -0
- package/dist/panels.d.ts +13 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/panels.js +414 -0
- package/dist/panels.js.map +1 -0
- package/dist/preview.d.ts +40 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +138 -0
- package/dist/preview.js.map +1 -0
- package/dist/record-editor.d.ts +11 -0
- package/dist/record-editor.d.ts.map +1 -0
- package/dist/record-editor.js +70 -0
- package/dist/record-editor.js.map +1 -0
- package/dist/schema-builder.d.ts +8 -0
- package/dist/schema-builder.d.ts.map +1 -0
- package/dist/schema-builder.js +235 -0
- package/dist/schema-builder.js.map +1 -0
- package/dist/schema-designer.d.ts +33 -0
- package/dist/schema-designer.d.ts.map +1 -0
- package/dist/schema-designer.js +251 -0
- package/dist/schema-designer.js.map +1 -0
- package/dist/schema-form.d.ts +8 -0
- package/dist/schema-form.d.ts.map +1 -0
- package/dist/schema-form.js +181 -0
- package/dist/schema-form.js.map +1 -0
- package/dist/schema-paths.d.ts +18 -0
- package/dist/schema-paths.d.ts.map +1 -0
- package/dist/schema-paths.js +75 -0
- package/dist/schema-paths.js.map +1 -0
- package/dist/seed.d.ts +18 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +299 -0
- package/dist/seed.js.map +1 -0
- package/dist/shell.d.ts +59 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +102 -0
- package/dist/shell.js.map +1 -0
- package/dist/store.d.ts +44 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +71 -0
- package/dist/store.js.map +1 -0
- package/dist/styles-editor.d.ts +8 -0
- package/dist/styles-editor.d.ts.map +1 -0
- package/dist/styles-editor.js +100 -0
- package/dist/styles-editor.js.map +1 -0
- package/dist/template-panel.d.ts +19 -0
- package/dist/template-panel.d.ts.map +1 -0
- package/dist/template-panel.js +585 -0
- package/dist/template-panel.js.map +1 -0
- package/dist/theme-designer.d.ts +35 -0
- package/dist/theme-designer.d.ts.map +1 -0
- package/dist/theme-designer.js +336 -0
- package/dist/theme-designer.js.map +1 -0
- package/dist/theme-panel.d.ts +20 -0
- package/dist/theme-panel.d.ts.map +1 -0
- package/dist/theme-panel.js +96 -0
- package/dist/theme-panel.js.map +1 -0
- package/dist/validate.d.ts +57 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +131 -0
- package/dist/validate.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Diego Hoyos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @widgentic/designer
|
|
2
|
+
|
|
3
|
+
Hostable designers for widgentic: the widget designer (template tree, data
|
|
4
|
+
schema, sample data, styles, action bindings, live preview), plus standalone
|
|
5
|
+
theme, schema and action designers. Each is a function taking a container, and
|
|
6
|
+
each is also a custom element. Runs in the browser; depends only on
|
|
7
|
+
`@widgentic/core`.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @widgentic/designer
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createDesigner } from "@widgentic/designer";
|
|
15
|
+
|
|
16
|
+
const designer = createDesigner(document.querySelector("#host")!, { themes: [] });
|
|
17
|
+
designer.subscribe((draft) => save(draft));
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Without a bundler, load the single-file bundle and use the elements:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<script type="module" src="/node_modules/@widgentic/designer/dist/browser/widgentic-designer.js"></script>
|
|
24
|
+
<widgentic-designer></widgentic-designer>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
MIT © Diego Hoyos
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HttpActionDefinition, StoredAction } from "@widgentic/core";
|
|
2
|
+
import type { SchemaEntry } from "./schema-designer.js";
|
|
3
|
+
export type ActionEntry = StoredAction;
|
|
4
|
+
export interface ActionDesignerOptions {
|
|
5
|
+
initialAction?: ActionEntry;
|
|
6
|
+
appearance?: "auto" | "light" | "dark";
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
/** Shared schemas offered as "copy from" sources for input/output. */
|
|
9
|
+
schemas?: SchemaEntry[];
|
|
10
|
+
/** Secret names offered for header/query values. */
|
|
11
|
+
secretNames?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Host-supplied test call (the production execute path). Without it no
|
|
14
|
+
* Test control renders. Resolves to whatever the host wants shown —
|
|
15
|
+
* typically the redacted response or a structured error.
|
|
16
|
+
*/
|
|
17
|
+
testCall?: (definition: HttpActionDefinition, args: Record<string, unknown>) => Promise<unknown>;
|
|
18
|
+
}
|
|
19
|
+
export type ActionLoadResult = {
|
|
20
|
+
ok: true;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
errors: string[];
|
|
24
|
+
};
|
|
25
|
+
export interface ActionDesignerHandle {
|
|
26
|
+
getAction(): ActionEntry;
|
|
27
|
+
loadAction(entry: unknown): ActionLoadResult;
|
|
28
|
+
setReadOnly(readOnly: boolean): void;
|
|
29
|
+
subscribe(listener: (entry: ActionEntry) => void): () => void;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
}
|
|
32
|
+
/** Validate an untrusted entry; errors instead of throwing. */
|
|
33
|
+
export declare function checkActionEntry(entry: unknown): string[];
|
|
34
|
+
export declare function createActionDesigner(container: Element, options?: ActionDesignerOptions): ActionDesignerHandle;
|
|
35
|
+
//# sourceMappingURL=action-designer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-designer.d.ts","sourceRoot":"","sources":["../src/action-designer.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAoB,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQ5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAClG;AAED,MAAM,MAAM,gBAAgB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACnC,SAAS,IAAI,WAAW,CAAC;IACzB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAC7C,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9D,OAAO,IAAI,IAAI,CAAC;CACjB;AAUD,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAczD;AAgBD,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,OAAO,EAClB,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAkPtB"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone action designer: edits a stored-action entry
|
|
3
|
+
* (`{ name, label?, description?, definition }` — the widget-store's
|
|
4
|
+
* shape). Split out like the theme and schema designers. The Test control
|
|
5
|
+
* appears only when the host supplies `options.testCall`: the library
|
|
6
|
+
* performs no network I/O, and a test call must run through the host's
|
|
7
|
+
* production execution path (secrets, SSRF guard, redaction).
|
|
8
|
+
*/
|
|
9
|
+
import { errorMessage } from "./internal.js";
|
|
10
|
+
import { isPlainObject } from "@widgentic/core";
|
|
11
|
+
import { ACTION_NAME, validateActionDefinition } from "@widgentic/core";
|
|
12
|
+
import { clone } from "./internal.js";
|
|
13
|
+
import { createDefinitionEditor } from "./action-editor.js";
|
|
14
|
+
import { diagnosticLine, h, injectDesignerStyles, section, textField, requireChild } from "./dom.js";
|
|
15
|
+
import { attachJsonHighlight, repaintHighlight } from "./highlight.js";
|
|
16
|
+
import { createSchemaForm } from "./schema-form.js";
|
|
17
|
+
function starterEntry() {
|
|
18
|
+
return {
|
|
19
|
+
name: "my-action",
|
|
20
|
+
label: "My action",
|
|
21
|
+
definition: { kind: "prompt", text: ["Tell me more about ", { bind: "title" }] }
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Validate an untrusted entry; errors instead of throwing. */
|
|
25
|
+
export function checkActionEntry(entry) {
|
|
26
|
+
const errors = [];
|
|
27
|
+
if (!isPlainObject(entry))
|
|
28
|
+
return ["Action entry must be an object."];
|
|
29
|
+
if (typeof entry.name !== "string" || !ACTION_NAME.test(entry.name)) {
|
|
30
|
+
errors.push("'name' must be lowercase letters, digits and dashes, starting with a letter (max 64).");
|
|
31
|
+
}
|
|
32
|
+
for (const field of ["label", "description"]) {
|
|
33
|
+
if (entry[field] !== undefined && typeof entry[field] !== "string") {
|
|
34
|
+
errors.push(`'${field}' must be a string when present.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const problem = validateActionDefinition(entry.definition, "definition");
|
|
38
|
+
if (problem)
|
|
39
|
+
errors.push(`${problem.message} (at ${problem.path})`);
|
|
40
|
+
return errors;
|
|
41
|
+
}
|
|
42
|
+
/** A checked entry with only the fields the shape declares; empty texts are dropped. */
|
|
43
|
+
function normalizeEntry(input) {
|
|
44
|
+
const entry = { name: input.name, definition: clone(input.definition) };
|
|
45
|
+
if (typeof input.label === "string" && input.label !== "")
|
|
46
|
+
entry.label = input.label;
|
|
47
|
+
if (typeof input.description === "string" && input.description !== "")
|
|
48
|
+
entry.description = input.description;
|
|
49
|
+
return entry;
|
|
50
|
+
}
|
|
51
|
+
/** Set or drop an optional text field: an emptied field leaves the entry. */
|
|
52
|
+
function withText(current, field, value) {
|
|
53
|
+
const { [field]: _gone, ...rest } = current;
|
|
54
|
+
return value === "" ? rest : { ...rest, [field]: value };
|
|
55
|
+
}
|
|
56
|
+
export function createActionDesigner(container, options = {}) {
|
|
57
|
+
injectDesignerStyles(document);
|
|
58
|
+
let entry = options.initialAction ? clone(options.initialAction) : starterEntry();
|
|
59
|
+
const testCall = options.testCall;
|
|
60
|
+
const listeners = new Set();
|
|
61
|
+
const panels = h("div", { class: "wgd-panels" });
|
|
62
|
+
const root = h("div", { class: "wgd-root wgd-action-designer" }, [panels]);
|
|
63
|
+
if (options.appearance === "light" || options.appearance === "dark") {
|
|
64
|
+
root.setAttribute("data-wgd-theme", options.appearance);
|
|
65
|
+
}
|
|
66
|
+
container.appendChild(root);
|
|
67
|
+
const getEntry = () => clone(entry);
|
|
68
|
+
function notify() {
|
|
69
|
+
for (const listener of [...listeners])
|
|
70
|
+
listener(getEntry());
|
|
71
|
+
}
|
|
72
|
+
// --- Identity --------------------------------------------------------
|
|
73
|
+
const identityRefreshers = [];
|
|
74
|
+
const nameDiag = diagnosticLine(undefined);
|
|
75
|
+
function identityField(label, read, write) {
|
|
76
|
+
const field = textField(label, read(), write);
|
|
77
|
+
const inputEl = requireChild(field, "input");
|
|
78
|
+
identityRefreshers.push(() => {
|
|
79
|
+
if (document.activeElement !== inputEl)
|
|
80
|
+
inputEl.value = read();
|
|
81
|
+
});
|
|
82
|
+
return field;
|
|
83
|
+
}
|
|
84
|
+
const identity = section("Action", [
|
|
85
|
+
identityField("Name (id)", () => entry.name, (value) => {
|
|
86
|
+
entry = { ...entry, name: value };
|
|
87
|
+
const bad = !ACTION_NAME.test(value);
|
|
88
|
+
nameDiag.hidden = !bad;
|
|
89
|
+
nameDiag.textContent = bad ? "Name must be lowercase letters, digits and dashes, starting with a letter." : "";
|
|
90
|
+
notify();
|
|
91
|
+
}),
|
|
92
|
+
nameDiag,
|
|
93
|
+
identityField("Label", () => entry.label ?? "", (value) => {
|
|
94
|
+
entry = withText(entry, "label", value);
|
|
95
|
+
notify();
|
|
96
|
+
}),
|
|
97
|
+
identityField("Description", () => entry.description ?? "", (value) => {
|
|
98
|
+
entry = withText(entry, "description", value);
|
|
99
|
+
notify();
|
|
100
|
+
})
|
|
101
|
+
]);
|
|
102
|
+
// --- Definition: editor + parse-gated JSON -----------------------------
|
|
103
|
+
const definitionDiag = diagnosticLine(undefined);
|
|
104
|
+
const editor = createDefinitionEditor(entry.definition, { ...(options.schemas ? { schemas: options.schemas } : {}), ...(options.secretNames ? { secretNames: options.secretNames } : {}) }, (definition) => {
|
|
105
|
+
entry = { ...entry, definition };
|
|
106
|
+
syncJson();
|
|
107
|
+
refreshDefinitionDiag();
|
|
108
|
+
refreshTest();
|
|
109
|
+
notify();
|
|
110
|
+
});
|
|
111
|
+
const jsonError = diagnosticLine(undefined);
|
|
112
|
+
const jsonArea = h("textarea", { class: "wgd-textarea", rows: "12", spellcheck: "false" });
|
|
113
|
+
const jsonWrap = h("div", undefined, [jsonArea, jsonError]);
|
|
114
|
+
jsonArea.value = JSON.stringify(entry.definition, null, 2);
|
|
115
|
+
jsonArea.addEventListener("input", () => {
|
|
116
|
+
try {
|
|
117
|
+
const parsed = JSON.parse(jsonArea.value);
|
|
118
|
+
const problem = validateActionDefinition(parsed, "definition");
|
|
119
|
+
if (problem)
|
|
120
|
+
throw new Error(`${problem.message} (at ${problem.path})`);
|
|
121
|
+
jsonError.hidden = true;
|
|
122
|
+
jsonError.textContent = "";
|
|
123
|
+
entry = { ...entry, definition: parsed };
|
|
124
|
+
editor.setValue(entry.definition);
|
|
125
|
+
refreshDefinitionDiag();
|
|
126
|
+
refreshTest();
|
|
127
|
+
notify();
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
jsonError.hidden = false;
|
|
131
|
+
jsonError.textContent = `Invalid (definition keeps the last valid value): ${errorMessage(error)}`;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
function syncJson() {
|
|
135
|
+
if (document.activeElement === jsonArea)
|
|
136
|
+
return;
|
|
137
|
+
jsonArea.value = JSON.stringify(entry.definition, null, 2);
|
|
138
|
+
repaintHighlight(jsonArea);
|
|
139
|
+
}
|
|
140
|
+
function refreshDefinitionDiag() {
|
|
141
|
+
const problem = validateActionDefinition(entry.definition, "definition");
|
|
142
|
+
definitionDiag.hidden = problem === undefined;
|
|
143
|
+
definitionDiag.textContent = problem ? `${problem.message} (at ${problem.path})` : "";
|
|
144
|
+
}
|
|
145
|
+
refreshDefinitionDiag();
|
|
146
|
+
const builderTab = h("button", { class: "wgd-button wgd-tab wgd-tab-active", type: "button" }, ["Editor"]);
|
|
147
|
+
const jsonTab = h("button", { class: "wgd-button wgd-tab", type: "button" }, ["JSON"]);
|
|
148
|
+
jsonWrap.hidden = true;
|
|
149
|
+
builderTab.addEventListener("click", () => {
|
|
150
|
+
editor.element.hidden = false;
|
|
151
|
+
jsonWrap.hidden = true;
|
|
152
|
+
builderTab.classList.add("wgd-tab-active");
|
|
153
|
+
jsonTab.classList.remove("wgd-tab-active");
|
|
154
|
+
});
|
|
155
|
+
jsonTab.addEventListener("click", () => {
|
|
156
|
+
editor.element.hidden = true;
|
|
157
|
+
jsonWrap.hidden = false;
|
|
158
|
+
jsonTab.classList.add("wgd-tab-active");
|
|
159
|
+
builderTab.classList.remove("wgd-tab-active");
|
|
160
|
+
syncJson();
|
|
161
|
+
});
|
|
162
|
+
const definition = section("Definition", [
|
|
163
|
+
h("div", { class: "wgd-row" }, [builderTab, jsonTab]),
|
|
164
|
+
definitionDiag,
|
|
165
|
+
editor.element,
|
|
166
|
+
jsonWrap
|
|
167
|
+
]);
|
|
168
|
+
// --- Test (host-supplied) ------------------------------------------------
|
|
169
|
+
const testHost = h("div", { class: "wgd-action-test" });
|
|
170
|
+
const testSection = section("Test", [testHost]);
|
|
171
|
+
let testArgs = {};
|
|
172
|
+
// Arguments belong to one input schema: a different schema starts them over.
|
|
173
|
+
let testInputJson;
|
|
174
|
+
function refreshTest() {
|
|
175
|
+
if (testCall === undefined)
|
|
176
|
+
return;
|
|
177
|
+
testHost.replaceChildren();
|
|
178
|
+
if (entry.definition.kind !== "http") {
|
|
179
|
+
testInputJson = undefined;
|
|
180
|
+
testArgs = {};
|
|
181
|
+
testHost.append(h("p", { class: "wgd-diagnostic" }, ["Prompt actions run in the host's composer; nothing to test."]));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const definitionNow = entry.definition;
|
|
185
|
+
const inputJson = JSON.stringify(definitionNow.input);
|
|
186
|
+
if (inputJson !== testInputJson)
|
|
187
|
+
testArgs = {};
|
|
188
|
+
testInputJson = inputJson;
|
|
189
|
+
const form = createSchemaForm(definitionNow.input, testArgs, (value) => {
|
|
190
|
+
testArgs = isPlainObject(value) ? value : {};
|
|
191
|
+
});
|
|
192
|
+
testArgs = isPlainObject(form.getValue()) ? form.getValue() : {};
|
|
193
|
+
const output = h("pre", { class: "wgd-test-output" });
|
|
194
|
+
const run = h("button", { class: "wgd-button wgd-add wgd-test-run", type: "button" }, ["Test call"]);
|
|
195
|
+
run.addEventListener("click", () => {
|
|
196
|
+
run.disabled = true;
|
|
197
|
+
run.classList.add("wgd-busy");
|
|
198
|
+
run.setAttribute("aria-busy", "true");
|
|
199
|
+
output.textContent = "…";
|
|
200
|
+
void testCall(definitionNow, testArgs)
|
|
201
|
+
.then((result) => {
|
|
202
|
+
output.textContent = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
203
|
+
})
|
|
204
|
+
.catch((error) => {
|
|
205
|
+
output.textContent = `Test failed: ${error.message}`;
|
|
206
|
+
})
|
|
207
|
+
.finally(() => {
|
|
208
|
+
run.disabled = false;
|
|
209
|
+
run.classList.remove("wgd-busy");
|
|
210
|
+
run.removeAttribute("aria-busy");
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
testHost.append(h("span", { class: "wgd-field-label" }, ["Arguments"]), form.element, h("div", { class: "wgd-row" }, [run]), output);
|
|
214
|
+
}
|
|
215
|
+
refreshTest();
|
|
216
|
+
// --- Import / Export ------------------------------------------------------
|
|
217
|
+
const importError = diagnosticLine(undefined);
|
|
218
|
+
const importArea = h("textarea", { class: "wgd-textarea wgd-action-import", rows: "6", spellcheck: "false" });
|
|
219
|
+
const importButton = h("button", { class: "wgd-button", type: "button" }, ["Import"]);
|
|
220
|
+
importButton.addEventListener("click", () => {
|
|
221
|
+
let parsed;
|
|
222
|
+
try {
|
|
223
|
+
parsed = JSON.parse(importArea.value);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
importError.hidden = false;
|
|
227
|
+
importError.textContent = `Invalid JSON: ${errorMessage(error)}`;
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const result = loadAction(parsed);
|
|
231
|
+
importError.hidden = result.ok;
|
|
232
|
+
importError.textContent = result.ok ? "" : result.errors.join("\n");
|
|
233
|
+
});
|
|
234
|
+
const importSection = section("Import", [
|
|
235
|
+
h("span", { class: "wgd-field-label" }, ["Import action entry JSON ({ name, label?, description?, definition })"]),
|
|
236
|
+
importArea,
|
|
237
|
+
importError,
|
|
238
|
+
h("div", { class: "wgd-row" }, [importButton])
|
|
239
|
+
]);
|
|
240
|
+
const output = h("textarea", { class: "wgd-textarea", rows: "8", readonly: "", spellcheck: "false" });
|
|
241
|
+
const exportButton = h("button", { class: "wgd-button wgd-add", type: "button" }, ["Export action entry"]);
|
|
242
|
+
exportButton.addEventListener("click", () => {
|
|
243
|
+
output.value = JSON.stringify(getEntry(), null, 2);
|
|
244
|
+
repaintHighlight(output);
|
|
245
|
+
});
|
|
246
|
+
const exportSection = section("Export", [h("div", { class: "wgd-toolbar" }, [exportButton]), output]);
|
|
247
|
+
exportSection.classList.add("wgd-view-only");
|
|
248
|
+
panels.append(identity, definition, ...(testCall === undefined ? [] : [testSection]), importSection, exportSection);
|
|
249
|
+
attachJsonHighlight(jsonArea);
|
|
250
|
+
attachJsonHighlight(importArea);
|
|
251
|
+
attachJsonHighlight(output);
|
|
252
|
+
function loadAction(input) {
|
|
253
|
+
const errors = checkActionEntry(input);
|
|
254
|
+
if (errors.length > 0)
|
|
255
|
+
return { ok: false, errors };
|
|
256
|
+
entry = normalizeEntry(input);
|
|
257
|
+
testArgs = {};
|
|
258
|
+
for (const refresh of identityRefreshers)
|
|
259
|
+
refresh();
|
|
260
|
+
nameDiag.hidden = true;
|
|
261
|
+
editor.setValue(entry.definition);
|
|
262
|
+
syncJson();
|
|
263
|
+
refreshDefinitionDiag();
|
|
264
|
+
refreshTest();
|
|
265
|
+
notify();
|
|
266
|
+
return { ok: true };
|
|
267
|
+
}
|
|
268
|
+
function setReadOnly(readOnly) {
|
|
269
|
+
root.classList.toggle("wgd-readonly", readOnly);
|
|
270
|
+
const bodies = [...panels.querySelectorAll(".wgd-section-body")].filter((body) => !body.parentElement?.classList.contains("wgd-view-only"));
|
|
271
|
+
for (const body of bodies) {
|
|
272
|
+
if (readOnly)
|
|
273
|
+
body.setAttribute("inert", "");
|
|
274
|
+
else
|
|
275
|
+
body.removeAttribute("inert");
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (options.readOnly === true)
|
|
279
|
+
setReadOnly(true);
|
|
280
|
+
return {
|
|
281
|
+
getAction: getEntry,
|
|
282
|
+
loadAction,
|
|
283
|
+
setReadOnly,
|
|
284
|
+
subscribe(listener) {
|
|
285
|
+
listeners.add(listener);
|
|
286
|
+
return () => listeners.delete(listener);
|
|
287
|
+
},
|
|
288
|
+
dispose() {
|
|
289
|
+
listeners.clear();
|
|
290
|
+
root.remove();
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=action-designer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-designer.js","sourceRoot":"","sources":["../src/action-designer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,oBAAoB,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY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EAAE,CAAC;QACd,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IACtB,CAAC;IAED,SAAS,WAAW,CAAC,QAAiB;QACpC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CACrE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,CACnE,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,IAAI,QAAQ;gBAAE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;;gBACxC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;QAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAEjD,OAAO;QACL,SAAS,EAAE,QAAQ;QACnB,UAAU;QACV,WAAW;QACX,SAAS,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO;YACL,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared editors for the action model: an action DEFINITION (prompt or
|
|
3
|
+
* http) and a BINDING (shared ref or inline definition, plus the input
|
|
4
|
+
* mapping and output mode). The standalone action designer edits
|
|
5
|
+
* definitions; the widget designer binds them to elements and to the
|
|
6
|
+
* widget's `load`. Everything is plain DOM over immutable values, and no
|
|
7
|
+
* network I/O happens here — testing an action is the host's job.
|
|
8
|
+
*
|
|
9
|
+
* Handlers read the editor's live state at event time and a commit
|
|
10
|
+
* re-renders only its own section, so two edits in a row never lose each
|
|
11
|
+
* other and focus survives a commit. Rows without a name (a new header,
|
|
12
|
+
* query parameter or projection) live in editor-local state until they are
|
|
13
|
+
* named; only named rows reach `onChange`.
|
|
14
|
+
*/
|
|
15
|
+
import type { DataSchema } from "@widgentic/core";
|
|
16
|
+
import type { ActionBinding, ActionDefinition, HttpActionDefinition, StoredAction } from "@widgentic/core";
|
|
17
|
+
import type { SchemaEntry } from "./schema-designer.js";
|
|
18
|
+
export interface ActionEditorContext {
|
|
19
|
+
/** Shared schemas offered as "copy from" sources for input/output. */
|
|
20
|
+
schemas?: SchemaEntry[];
|
|
21
|
+
/** Secret names offered for header/query values. */
|
|
22
|
+
secretNames?: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function starterPromptDefinition(): ActionDefinition;
|
|
25
|
+
export declare function starterHttpDefinition(): HttpActionDefinition;
|
|
26
|
+
export interface DefinitionEditor {
|
|
27
|
+
element: HTMLElement;
|
|
28
|
+
getValue(): ActionDefinition;
|
|
29
|
+
setValue(definition: ActionDefinition): void;
|
|
30
|
+
}
|
|
31
|
+
/** Editor for one action definition, either kind. */
|
|
32
|
+
export declare function createDefinitionEditor(initial: ActionDefinition | undefined, ctx: ActionEditorContext, onChange: (definition: ActionDefinition) => void): DefinitionEditor;
|
|
33
|
+
export interface BindingEditorContext extends ActionEditorContext {
|
|
34
|
+
/** Shared actions offered by name. */
|
|
35
|
+
actions?: StoredAction[];
|
|
36
|
+
/** Data paths in scope at the bound element, offered as completions. */
|
|
37
|
+
scopePaths?: string[];
|
|
38
|
+
/** The widget's effective data schema (inline or resolved ref) — drives output-map targets and type checks. */
|
|
39
|
+
getDataSchema?: () => DataSchema | undefined;
|
|
40
|
+
/** `load` bindings: http GET only, no prompt. */
|
|
41
|
+
loadOnly?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface BindingEditor {
|
|
44
|
+
element: HTMLElement;
|
|
45
|
+
setValue(binding: ActionBinding | undefined): void;
|
|
46
|
+
}
|
|
47
|
+
/** Editor for a binding: none / shared / inline, input mapping, output mode. */
|
|
48
|
+
export declare function createBindingEditor(initial: ActionBinding | undefined, ctx: BindingEditorContext, onChange: (binding: ActionBinding | undefined) => void): BindingEditor;
|
|
49
|
+
//# sourceMappingURL=action-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-editor.d.ts","sourceRoot":"","sources":["../src/action-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EAKpB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUxD,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wBAAgB,uBAAuB,IAAI,gBAAgB,CAE1D;AAED,wBAAgB,qBAAqB,IAAI,oBAAoB,CAQ5D;AA+LD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC9C;AAED,qDAAqD;AACrD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,GAC/C,gBAAgB,CA6Gl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