api_binding_ui 1.0.0 → 2.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/README.md +74 -384
- package/SKILL.md +49 -294
- package/dist/framework/contract.d.ts +268 -0
- package/dist/framework/engine.d.ts +88 -0
- package/dist/framework/expr.d.ts +34 -0
- package/dist/framework/loadCatalog.d.ts +6 -0
- package/dist/framework/names.d.ts +7 -0
- package/dist/framework/openapi.d.ts +7 -0
- package/dist/framework/runner.d.ts +33 -0
- package/dist/framework/schema.d.ts +22 -0
- package/dist/framework/store.d.ts +17 -0
- package/dist/framework/validate.d.ts +7 -0
- package/dist/index-e9twc25y.js +754 -0
- package/dist/index-e9twc25y.js.map +16 -0
- package/dist/index.d.ts +11 -26
- package/dist/index.js +345 -3790
- package/dist/index.js.map +14 -0
- package/dist/runtime/BindingProvider.d.ts +42 -0
- package/dist/runtime/BindingScreen.d.ts +23 -0
- package/dist/runtime/hooks.d.ts +22 -0
- package/dist/runtime/screenStore.d.ts +7 -0
- package/dist/studio/ApiPicker.d.ts +15 -0
- package/dist/studio/BindingStudio.d.ts +21 -0
- package/dist/studio/BindingWidget.d.ts +9 -0
- package/dist/studio/Collapse.d.ts +6 -0
- package/dist/studio/ComponentList.d.ts +10 -0
- package/dist/studio/FindAnything.d.ts +7 -0
- package/dist/studio/Inspector.d.ts +12 -0
- package/dist/studio/Navigator.d.ts +17 -0
- package/dist/studio/SettingsPanel.d.ts +15 -0
- package/dist/studio/Tip.d.ts +23 -0
- package/dist/studio/editors/ConsumeEditor.d.ts +4 -0
- package/dist/studio/editors/RequestInputs.d.ts +11 -0
- package/dist/studio/editors/ScopedEditor.d.ts +3 -0
- package/dist/studio/editors/SlotSection.d.ts +3 -0
- package/dist/studio/editors/SourceSelect.d.ts +10 -0
- package/dist/studio/editors/StepCard.d.ts +12 -0
- package/dist/studio/editors/TriggerEditor.d.ts +4 -0
- package/dist/studio/editors/types.d.ts +14 -0
- package/dist/studio/icons.d.ts +65 -0
- package/dist/studio/index.css +2021 -0
- package/dist/studio/index.d.ts +3 -0
- package/dist/studio/index.js +2806 -0
- package/dist/studio/index.js.map +33 -0
- package/dist/studio/useBindings.d.ts +20 -0
- package/dist/studio/useCatalog.d.ts +15 -0
- package/dist/studio/useGlide.d.ts +11 -0
- package/dist/studio/useSettings.d.ts +8 -0
- package/package.json +20 -9
- package/spec/FRAMEWORK.md +271 -0
- package/dist/api-binding-ui.css +0 -244
- package/dist/components/ApiBindingWorkspace.d.ts +0 -10
- package/dist/components/ApiMappings.d.ts +0 -21
- package/dist/components/BindApiButton.d.ts +0 -41
- package/dist/components/RequestPreview.d.ts +0 -7
- package/dist/components/SimulationDialog.d.ts +0 -8
- package/dist/components/WorkspaceContext.d.ts +0 -7
- package/dist/components/ui/AppGrid.d.ts +0 -27
- package/dist/components/ui/Badge.d.ts +0 -9
- package/dist/components/ui/Banner.d.ts +0 -8
- package/dist/components/ui/Button.d.ts +0 -31
- package/dist/components/ui/Card.d.ts +0 -14
- package/dist/components/ui/Dialog.d.ts +0 -61
- package/dist/components/ui/Icons.d.ts +0 -21
- package/dist/components/ui/Input.d.ts +0 -31
- package/dist/core/bindingContext.d.ts +0 -67
- package/dist/core/catalog.d.ts +0 -18
- package/dist/core/componentId.d.ts +0 -12
- package/dist/core/model.d.ts +0 -57
- package/dist/core/transport.d.ts +0 -33
- package/dist/core/valueCoercion.d.ts +0 -14
- package/dist/hooks/useAppliedBinding.d.ts +0 -6
- package/dist/index.css +0 -244
- package/dist/style.css +0 -244
- package/dist/types.d.ts +0 -232
package/README.md
CHANGED
|
@@ -1,384 +1,74 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
The
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
bun
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Host Application Setup
|
|
78
|
-
|
|
79
|
-
### Step 1: Register the Studio Route
|
|
80
|
-
|
|
81
|
-
The studio window opens at the path `/api-binding/$key`. Configure your application router to mount the `ApiBindingWorkspace` component at this path.
|
|
82
|
-
|
|
83
|
-
#### TanStack Router (`src/routes/api-binding.$key.tsx`)
|
|
84
|
-
```tsx
|
|
85
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
86
|
-
import { ApiBindingWorkspace } from "api_binding_ui";
|
|
87
|
-
import "api_binding_ui/style.css";
|
|
88
|
-
|
|
89
|
-
export const Route = createFileRoute("/api-binding/$key")({
|
|
90
|
-
head: () => ({
|
|
91
|
-
meta: [
|
|
92
|
-
{ title: "API Binding Studio" },
|
|
93
|
-
{ name: "description", content: "Visual API mapping and simulation studio." },
|
|
94
|
-
],
|
|
95
|
-
}),
|
|
96
|
-
component: ApiBindingRouteView,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
function ApiBindingRouteView() {
|
|
100
|
-
const { key } = Route.useParams();
|
|
101
|
-
return <ApiBindingWorkspace key={key} pageKey={key} />;
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### React Router (`src/App.tsx`)
|
|
106
|
-
```tsx
|
|
107
|
-
import { BrowserRouter, Routes, Route, useParams } from "react-router-dom";
|
|
108
|
-
import { ApiBindingWorkspace } from "api_binding_ui";
|
|
109
|
-
import "api_binding_ui/style.css";
|
|
110
|
-
|
|
111
|
-
function ApiBindingPage() {
|
|
112
|
-
const { key = "default" } = useParams();
|
|
113
|
-
return <ApiBindingWorkspace key={key} pageKey={key} />;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function App() {
|
|
117
|
-
return (
|
|
118
|
-
<BrowserRouter>
|
|
119
|
-
<Routes>
|
|
120
|
-
<Route path="/api-binding/:key" element={<ApiBindingPage />} />
|
|
121
|
-
{/* Application routes */}
|
|
122
|
-
</Routes>
|
|
123
|
-
</BrowserRouter>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
### Step 2: Mount `<BindApiButton />` on Host Screens
|
|
131
|
-
|
|
132
|
-
Place `<BindApiButton />` inside your modal dialogs, slide-out drawers, form panels, or screen toolbars.
|
|
133
|
-
|
|
134
|
-
#### Example A: Dialog with Data Grid Context
|
|
135
|
-
```tsx
|
|
136
|
-
import * as React from "react";
|
|
137
|
-
import { BindApiButton } from "api_binding_ui";
|
|
138
|
-
|
|
139
|
-
interface CustomerRecord {
|
|
140
|
-
customerId: number;
|
|
141
|
-
customerName: string;
|
|
142
|
-
accountNumber: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function AddNotesModal({
|
|
146
|
-
open,
|
|
147
|
-
onClose,
|
|
148
|
-
selectedCustomers,
|
|
149
|
-
}: {
|
|
150
|
-
open: boolean;
|
|
151
|
-
onClose: () => void;
|
|
152
|
-
selectedCustomers: CustomerRecord[];
|
|
153
|
-
}) {
|
|
154
|
-
if (!open) return null;
|
|
155
|
-
|
|
156
|
-
const noteTypeOptions = [
|
|
157
|
-
{ value: "1", label: "General Follow-up" },
|
|
158
|
-
{ value: "2", label: "Promise to Pay" },
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
const templateOptions = [
|
|
162
|
-
{
|
|
163
|
-
value: "tmpl-payment",
|
|
164
|
-
label: "Payment Reminder",
|
|
165
|
-
subject: "Pending statement follow-up",
|
|
166
|
-
description: "Contacted accounts payable regarding past-due invoices.",
|
|
167
|
-
},
|
|
168
|
-
];
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<div role="dialog" aria-labelledby="modal-heading" className="modal-container">
|
|
172
|
-
<h2 id="modal-heading">Add Customer Note</h2>
|
|
173
|
-
|
|
174
|
-
<div className="form-group">
|
|
175
|
-
<label htmlFor="notesType">Note Type</label>
|
|
176
|
-
<select id="notesType" name="notesType" required>
|
|
177
|
-
{noteTypeOptions.map((opt) => (
|
|
178
|
-
<option key={opt.value} value={opt.value}>
|
|
179
|
-
{opt.label}
|
|
180
|
-
</option>
|
|
181
|
-
))}
|
|
182
|
-
</select>
|
|
183
|
-
</div>
|
|
184
|
-
|
|
185
|
-
<div className="form-group">
|
|
186
|
-
<label htmlFor="subject">Subject</label>
|
|
187
|
-
<input id="subject" name="subject" required />
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
<div className="form-group">
|
|
191
|
-
<label htmlFor="notes">Description</label>
|
|
192
|
-
<textarea id="notes" name="notes" required />
|
|
193
|
-
</div>
|
|
194
|
-
|
|
195
|
-
<div className="modal-actions">
|
|
196
|
-
<button type="button" onClick={onClose}>
|
|
197
|
-
Cancel
|
|
198
|
-
</button>
|
|
199
|
-
<button type="submit">
|
|
200
|
-
Save Note
|
|
201
|
-
</button>
|
|
202
|
-
|
|
203
|
-
<BindApiButton
|
|
204
|
-
appId="collections"
|
|
205
|
-
windowId="worklist-add-notes"
|
|
206
|
-
source="Add Notes Dialog"
|
|
207
|
-
parent="Worklist Grid"
|
|
208
|
-
grid={{
|
|
209
|
-
gridId: "worklistUIGrid",
|
|
210
|
-
rows: selectedCustomers,
|
|
211
|
-
}}
|
|
212
|
-
options={{
|
|
213
|
-
notesType: noteTypeOptions,
|
|
214
|
-
template: templateOptions,
|
|
215
|
-
}}
|
|
216
|
-
/>
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
#### Example B: Standalone Screen or Drawer without a Grid
|
|
224
|
-
```tsx
|
|
225
|
-
import * as React from "react";
|
|
226
|
-
import { BindApiButton } from "api_binding_ui";
|
|
227
|
-
|
|
228
|
-
export function CreateDisputeDrawer({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) {
|
|
229
|
-
if (!isOpen) return null;
|
|
230
|
-
|
|
231
|
-
const reasonCodes = [
|
|
232
|
-
{ value: "PRICING_ERROR", label: "Pricing Discrepancy" },
|
|
233
|
-
{ value: "DAMAGED_GOODS", label: "Damaged Goods" },
|
|
234
|
-
];
|
|
235
|
-
|
|
236
|
-
return (
|
|
237
|
-
<aside className="drawer-panel" aria-label="Create Dispute">
|
|
238
|
-
<h2>Create Dispute</h2>
|
|
239
|
-
|
|
240
|
-
<form id="dispute-form">
|
|
241
|
-
<label htmlFor="reasonCode">Reason Code</label>
|
|
242
|
-
<select id="reasonCode" name="reasonCode" required>
|
|
243
|
-
{reasonCodes.map((r) => (
|
|
244
|
-
<option key={r.value} value={r.value}>{r.label}</option>
|
|
245
|
-
))}
|
|
246
|
-
</select>
|
|
247
|
-
|
|
248
|
-
<label htmlFor="amount">Disputed Amount</label>
|
|
249
|
-
<input id="amount" name="amount" type="number" required />
|
|
250
|
-
|
|
251
|
-
<label htmlFor="comments">Comments</label>
|
|
252
|
-
<textarea id="comments" name="comments" />
|
|
253
|
-
|
|
254
|
-
<div className="drawer-footer">
|
|
255
|
-
<button type="button" onClick={onClose}>Cancel</button>
|
|
256
|
-
<button type="submit">Submit Dispute</button>
|
|
257
|
-
|
|
258
|
-
<BindApiButton
|
|
259
|
-
appId="receivables"
|
|
260
|
-
windowId="dispute-create"
|
|
261
|
-
source="Create Dispute"
|
|
262
|
-
parent="Disputes Management"
|
|
263
|
-
options={{
|
|
264
|
-
reasonCode: reasonCodes,
|
|
265
|
-
}}
|
|
266
|
-
/>
|
|
267
|
-
</div>
|
|
268
|
-
</form>
|
|
269
|
-
</aside>
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
## Component API Specification
|
|
277
|
-
|
|
278
|
-
### `<BindApiButton />` Props
|
|
279
|
-
|
|
280
|
-
| Prop | Type | Default | Description |
|
|
281
|
-
| :--- | :--- | :--- | :--- |
|
|
282
|
-
| `appId` | `string` | `"default"` | Identifier of the parent application module. |
|
|
283
|
-
| `windowId` | `string` | *(Required)* | Stable identifier of the screen, dialog, or form. |
|
|
284
|
-
| `source` | `string` | *(Required)* | Human-readable title of the current screen or action. |
|
|
285
|
-
| `parent` | `string` | *(Required)* | Human-readable title of the parent view or grid. |
|
|
286
|
-
| `grid` | `BindingGrid` | `undefined` | Grid context including `gridId`, `columns`, and `rows` when actions target selected records. |
|
|
287
|
-
| `parents` | `SnapshotContext[]` | `undefined` | Array of parent context hierarchies for multi-level navigation. |
|
|
288
|
-
| `kind` | `WindowKind` | Automatic | `"dialog" \| "drawer" \| "screen" \| "action-form"`. Detected automatically if omitted. |
|
|
289
|
-
| `trigger` | `WindowTrigger` | `undefined` | Metadata regarding the invocation trigger (button text, hotkey, icon). |
|
|
290
|
-
| `options` | `Record<string, BindingOption[]>` | `{}` | Lookup options for select and combobox fields. Supports `{ value, label, subject, description }`. |
|
|
291
|
-
| `definitions` | `ApiDefinition[]` | `[]` | Registered API endpoints catalog available for mapping. |
|
|
292
|
-
| `mappingFile` | `MappingFile \| null` | `null` | Pre-existing mapping file to preload. |
|
|
293
|
-
| `routeBase` | `string` | `"/api-binding"` | Studio route base path configured in the application router. |
|
|
294
|
-
| `containerRef` | `React.RefObject<HTMLElement>` | `undefined` | Explicit DOM reference to the container element. |
|
|
295
|
-
| `containerSelector` | `string` | `undefined` | CSS selector used to locate the enclosing container element. |
|
|
296
|
-
| `rootElement` | `HTMLElement \| null` | `undefined` | Direct DOM element override. |
|
|
297
|
-
| `formId` | `string` | `undefined` | Target HTML `<form id="...">` identifier. |
|
|
298
|
-
| `components` | `SnapshotComponent[]` | `undefined` | Explicit components list overriding automatic DOM discovery. |
|
|
299
|
-
| `buttons` | `string[]` | `undefined` | Explicit action buttons list overriding automatic DOM discovery. |
|
|
300
|
-
| `className` | `string` | `""` | Additional CSS class for the button. |
|
|
301
|
-
| `children` | `React.ReactNode` | `"Bind API"` | Button label or children nodes. |
|
|
302
|
-
|
|
303
|
-
---
|
|
304
|
-
|
|
305
|
-
## DOM Discovery Protocol
|
|
306
|
-
|
|
307
|
-
When `<BindApiButton />` is clicked, the context extraction pipeline executes the following sequence:
|
|
308
|
-
|
|
309
|
-
1. **Container Resolution**:
|
|
310
|
-
- Checks `rootElement`, `containerRef`, `containerSelector`, and `formId`.
|
|
311
|
-
- Searches upward for `role="dialog"`, `<dialog>`, or `.ds-dialog`.
|
|
312
|
-
- Searches upward for `<form>`.
|
|
313
|
-
- Searches upward for `role="region"`, `[data-drawer]`, `<aside>`, `<main>`, `<section>`, `.drawer`, or `.panel`.
|
|
314
|
-
- Traverses parent elements to locate any ancestor containing at least two input elements.
|
|
315
|
-
- Falls back to `document.body`.
|
|
316
|
-
|
|
317
|
-
2. **Form Control Discovery**:
|
|
318
|
-
- Evaluates all standard controls (`input`, `select`, `textarea`) and custom ARIA controls (`role="combobox"`, `role="textbox"`, `role="checkbox"`, `role="switch"`).
|
|
319
|
-
- Resolves control names from `name`, `id`, `data-testid`, `data-field`, or `aria-label`.
|
|
320
|
-
- Extracts labels from `<label for="...">`, parent `<label>`, `aria-labelledby`, `aria-label`, or field placeholders.
|
|
321
|
-
- Captures current input values and state (`checked`, `value`, `data-value`).
|
|
322
|
-
|
|
323
|
-
3. **Action Button Discovery**:
|
|
324
|
-
- Evaluates buttons and submit inputs within the container.
|
|
325
|
-
- Excludes modal close controls, minimize/maximize adornments, dismiss triggers, and API binding triggers.
|
|
326
|
-
- Captures active primary and secondary action labels (e.g., `"Save"`, `"Submit"`, `"Cancel"`, `"Reset"`).
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
## Consuming Applied Bindings
|
|
331
|
-
|
|
332
|
-
When an engineer or analyst clicks **Apply Binding** inside the Studio, the verified configuration is stored in `localStorage` under `api-binding:applied:<key>` and broadcast across active windows.
|
|
333
|
-
|
|
334
|
-
Host components can listen to applied bindings using the `useAppliedBinding` hook:
|
|
335
|
-
|
|
336
|
-
```tsx
|
|
337
|
-
import { useAppliedBinding } from "api_binding_ui";
|
|
338
|
-
|
|
339
|
-
export function AddNotesModal() {
|
|
340
|
-
const { isApplied, appliedConfig, appliedAt } = useAppliedBinding(
|
|
341
|
-
"collections.worklistUIGrid.worklist-add-notes"
|
|
342
|
-
);
|
|
343
|
-
|
|
344
|
-
React.useEffect(() => {
|
|
345
|
-
if (isApplied && appliedConfig) {
|
|
346
|
-
console.log("Applied API Binding Configuration:", appliedConfig);
|
|
347
|
-
// Access appliedConfig.calls, appliedConfig.fields, appliedConfig.customerRule
|
|
348
|
-
}
|
|
349
|
-
}, [isApplied, appliedConfig]);
|
|
350
|
-
|
|
351
|
-
// Render modal
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
## Testing and Verification
|
|
358
|
-
|
|
359
|
-
Run test suites using the bundled test runner:
|
|
360
|
-
|
|
361
|
-
```bash
|
|
362
|
-
bun test
|
|
363
|
-
# or
|
|
364
|
-
yarn test
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
Build the distribution package:
|
|
368
|
-
|
|
369
|
-
```bash
|
|
370
|
-
bun run build
|
|
371
|
-
# or
|
|
372
|
-
yarn build
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
The build produces:
|
|
376
|
-
- `dist/index.js`: Browser ES module bundle.
|
|
377
|
-
- `dist/api-binding-ui.css`: Compiled style bundle with `--ds-*` design token bridges.
|
|
378
|
-
- `dist/**/*.d.ts`: TypeScript declaration definitions.
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
## License
|
|
383
|
-
|
|
384
|
-
Internal enterprise package. All rights reserved.
|
|
1
|
+
# api_binding_ui
|
|
2
|
+
|
|
3
|
+
Bind any UI component to documented APIs while a product is being designed, then run those bindings in production.
|
|
4
|
+
|
|
5
|
+
- **Generic.** The code knows three slot roles (`consume`, `produce`, `trigger`) and nothing else. Component kinds, screens, products and APIs are data.
|
|
6
|
+
- **Docs only.** APIs come from the OpenAPI documents. If the docs do not have it, it cannot be bound.
|
|
7
|
+
- **API only.** Bindings say which API is called with what data and where results go. Opening, closing and navigation stay in the app.
|
|
8
|
+
|
|
9
|
+
The full contract is in [`spec/FRAMEWORK.md`](spec/FRAMEWORK.md); the types are in [`src/framework/contract.ts`](src/framework/contract.ts).
|
|
10
|
+
|
|
11
|
+
## Entries
|
|
12
|
+
|
|
13
|
+
| Import | Use | In production |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `api_binding_ui` | Contract types, `catalogFromOpenApi`, the runtime (`BindingProvider`, `BindingScreen`, `useSlot`, `useCell`, `useProduce`, `useTrigger`), validation | Yes |
|
|
16
|
+
| `api_binding_ui/studio` + `api_binding_ui/studio.css` | `BindingWidget`, `BindingStudio` | No; import only from design-time code |
|
|
17
|
+
|
|
18
|
+
## Runtime
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { BindingProvider, BindingScreen, useSlot, useProduce, useTrigger } from "api_binding_ui";
|
|
22
|
+
|
|
23
|
+
<BindingProvider catalog={catalog} manifests={manifests} fetcher={fetcher}>
|
|
24
|
+
<BindingScreen id="collections.worklist.add-notes" context={{ selection }}>
|
|
25
|
+
<AddNotesForm />
|
|
26
|
+
</BindingScreen>
|
|
27
|
+
</BindingProvider>;
|
|
28
|
+
|
|
29
|
+
function AddNotesForm() {
|
|
30
|
+
const notesType = useSlot<{ value: string; label: string }[]>("notesType", "options");
|
|
31
|
+
const [subject, setSubject] = useState("");
|
|
32
|
+
useProduce("subject", "value", subject);
|
|
33
|
+
const submit = useTrigger("submit", "click");
|
|
34
|
+
// render notesType.data, call submit.run(), then close the dialog in your own code
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`fetcher` receives `{ method, path, query, headers, body }` and the catalog operation; base URL, auth and errors stay in the app.
|
|
39
|
+
|
|
40
|
+
## Studio
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { BindingWidget } from "api_binding_ui/studio";
|
|
44
|
+
import "api_binding_ui/studio.css";
|
|
45
|
+
|
|
46
|
+
// once, inside <BindingProvider persistence={…}>, design mode only
|
|
47
|
+
<BindingWidget framework={{ descriptors, registry }} />
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A floating button opens the studio over the app on the screen being shown. Edits apply when it closes.
|
|
51
|
+
|
|
52
|
+
The studio reads every product's APIs from the published docs (default `https://apidocs.highradius.com/documentation-ui/index.yaml`, JSON or YAML). Each user can change the URL in **Settings** (top right), which also downloads and imports bindings as JSON for committing with the app. Pass `docsUrl` to change the default, or `framework.catalog` to skip loading.
|
|
53
|
+
|
|
54
|
+
## Layout
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
src/
|
|
58
|
+
framework/ pure TypeScript: contract, OpenAPI → catalog, schema, names, engine, validation,
|
|
59
|
+
expressions, request runner, persistence
|
|
60
|
+
runtime/ React runtime: provider, screen scope, hooks
|
|
61
|
+
studio/ design-time UI: shell, navigator, search, component list, inspector, slot editors
|
|
62
|
+
dev/ sample data and the local harness (not published)
|
|
63
|
+
spec/ FRAMEWORK.md (the contract) and contract.ts (re-export)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Develop
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
bun install
|
|
70
|
+
bun run dev # studio with sample data on http://localhost:5174
|
|
71
|
+
bun test
|
|
72
|
+
bun run typecheck
|
|
73
|
+
bun run build
|
|
74
|
+
```
|