@adia-ai/a2ui-retrieval 0.6.4 → 0.6.6

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/wiring-catalog.js CHANGED
@@ -1,195 +1,144 @@
1
- /**
2
- * Wiring Catalog — Knowledge base for the gen-ui pipeline.
3
- *
4
- * Indexes available wiring capabilities so the generator can emit valid
5
- * wireComponents declarations alongside component trees.
6
- *
7
- * The schema has 5 docking points:
8
- * DATA — sources, params (how the surface gets its data)
9
- * STATE — controllers, model (how components manage behavior)
10
- * ACTIONS — UIEvent → handler chains (what happens on events)
11
- * PROVIDES — context injection into subtrees
12
- * LIFECYCLE — onMount, onUnmount, onModelChange hooks
13
- *
14
- * Each point is optional. A static display surface needs none.
15
- * A form needs STATE (FormController) + ACTIONS (submit).
16
- * A dashboard needs DATA (sources) + STATE (DataStreamController).
17
- * A full app needs all five.
18
- */
19
-
20
- // ── UIEvent ──────────────────────────────────────────────────
21
- // A typed event object that the wiring system understands natively.
22
- // Maps 1:1 to DOM events but with AdiaUI semantics and payload contracts.
23
- //
24
- // { "event": "press", "target": "save-btn" }
25
- // { "event": "input", "target": "search", "debounce": 300 }
26
- // { "event": "submit", "target": "form-col" }
27
- // { "event": "mount" }
28
- //
29
- // "event" — UIEvent type name (see adiaEvents below)
30
- // "target" — component id that emits. Omit for surface-level events.
31
- // "debounce" — ms, coalesce rapid-fire (input, resize)
32
- // "throttle" — ms, limit frequency (scroll, drag)
33
- // "condition" — guard: { path, equals|notEquals|exists }
34
-
35
1
  const adiaEvents = [
36
- { event: 'press', payload: null, description: 'Button or interactive element activated.' },
37
- { event: 'submit', payload: 'form-values', description: 'Form submission with validated field values.' },
38
- { event: 'input', payload: 'target-value', description: 'Value changed (fires on every keystroke).' },
39
- { event: 'change', payload: 'event-detail', description: 'Value committed (fires on blur or selection).' },
40
- { event: 'select', payload: 'event-detail', description: 'Item selected from list, table, or menu.' },
41
- { event: 'toggle', payload: 'boolean', description: 'Boolean state flipped (switch, checkbox).' },
42
- { event: 'dismiss', payload: null, description: 'Close/dismiss (dialog, toast, popover).' },
43
- { event: 'navigate', payload: 'route', description: 'Internal navigation request.' },
44
- { event: 'mount', payload: null, description: 'Surface or component entered the DOM.' },
45
- { event: 'unmount', payload: null, description: 'Surface or component left the DOM.' },
46
- { event: 'focus', payload: null, description: 'Element received focus.' },
47
- { event: 'blur', payload: null, description: 'Element lost focus.' },
48
- { event: 'drag', payload: 'event-detail', description: 'Drag operation on a sortable/draggable.' },
49
- { event: 'drop', payload: 'event-detail', description: 'Drop completed on a sortable/draggable.' },
2
+ { event: "press", payload: null, description: "Button or interactive element activated." },
3
+ { event: "submit", payload: "form-values", description: "Form submission with validated field values." },
4
+ { event: "input", payload: "target-value", description: "Value changed (fires on every keystroke)." },
5
+ { event: "change", payload: "event-detail", description: "Value committed (fires on blur or selection)." },
6
+ { event: "select", payload: "event-detail", description: "Item selected from list, table, or menu." },
7
+ { event: "toggle", payload: "boolean", description: "Boolean state flipped (switch, checkbox)." },
8
+ { event: "dismiss", payload: null, description: "Close/dismiss (dialog, toast, popover)." },
9
+ { event: "navigate", payload: "route", description: "Internal navigation request." },
10
+ { event: "mount", payload: null, description: "Surface or component entered the DOM." },
11
+ { event: "unmount", payload: null, description: "Surface or component left the DOM." },
12
+ { event: "focus", payload: null, description: "Element received focus." },
13
+ { event: "blur", payload: null, description: "Element lost focus." },
14
+ { event: "drag", payload: "event-detail", description: "Drag operation on a sortable/draggable." },
15
+ { event: "drop", payload: "event-detail", description: "Drop completed on a sortable/draggable." }
50
16
  ];
51
-
52
- /**
53
- * Get the full wiring catalog.
54
- * @returns {object}
55
- */
56
- export function getWiringCatalog() {
17
+ function getWiringCatalog() {
57
18
  return {
58
19
  // ── ADIA EVENTS ──
59
20
  adiaEvents,
60
-
61
21
  // ── DATA: how the surface gets its data ──
62
22
  data: {
63
- description: 'Fetch external data into the surface model. Sources are URI-based with refresh strategies.',
64
- paramSources: ['route', 'store', 'literal', 'query', 'parent'],
65
- uriSchemes: ['resource://', 'api://', 'mock://', 'ws://', 'sse://'],
66
- refreshStrategies: ['once', 'on-focus', 'interval:{ms}', 'stream'],
23
+ description: "Fetch external data into the surface model. Sources are URI-based with refresh strategies.",
24
+ paramSources: ["route", "store", "literal", "query", "parent"],
25
+ uriSchemes: ["resource://", "api://", "mock://", "ws://", "sse://"],
26
+ refreshStrategies: ["once", "on-focus", "interval:{ms}", "stream"],
67
27
  example: {
68
- params: { userId: { from: 'route', key: 'id' } },
28
+ params: { userId: { from: "route", key: "id" } },
69
29
  sources: [
70
- { id: 'user', uri: 'resource://users/{userId}', path: '/user', refresh: 'once' },
71
- { id: 'activity', uri: 'resource://users/{userId}/activity', path: '/activity', refresh: 'on-focus' },
72
- ],
73
- },
30
+ { id: "user", uri: "resource://users/{userId}", path: "/user", refresh: "once" },
31
+ { id: "activity", uri: "resource://users/{userId}/activity", path: "/activity", refresh: "on-focus" }
32
+ ]
33
+ }
74
34
  },
75
-
76
35
  // ── STATE: controllers that manage component behavior ──
77
36
  controllers: [
78
37
  {
79
- type: 'FormController',
80
- description: 'Manages field values, validation, dirty/pristine tracking. Attach to a Column/Section containing form fields.',
38
+ type: "FormController",
39
+ description: "Manages field values, validation, dirty/pristine tracking. Attach to a Column/Section containing form fields.",
81
40
  config: {
82
- validateOn: { type: 'string', enum: ['blur', 'change', 'submit'], default: 'blur' },
41
+ validateOn: { type: "string", enum: ["blur", "change", "submit"], default: "blur" }
83
42
  },
84
- commands: ['validate', 'reset', 'setFieldError'],
85
- bind: { values: '/form/values', valid: '/form/valid', dirty: '/form/dirty' },
43
+ commands: ["validate", "reset", "setFieldError"],
44
+ bind: { values: "/form/values", valid: "/form/valid", dirty: "/form/dirty" }
86
45
  },
87
46
  {
88
- type: 'DataStreamController',
89
- description: 'Live data buffer for charts, tables, feeds. Supports push, SSE, WebSocket, polling.',
47
+ type: "DataStreamController",
48
+ description: "Live data buffer for charts, tables, feeds. Supports push, SSE, WebSocket, polling.",
90
49
  config: {
91
- max: { type: 'number', default: 100, description: 'FIFO buffer size' },
92
- throttle: { type: 'number', default: 0, description: 'Min ms between renders' },
50
+ max: { type: "number", default: 100, description: "FIFO buffer size" },
51
+ throttle: { type: "number", default: 0, description: "Min ms between renders" }
93
52
  },
94
- commands: ['push', 'pushMany', 'connect', 'poll', 'consume', 'stop', 'clear'],
95
- bind: { data: '/stream/data', status: '/stream/status' },
53
+ commands: ["push", "pushMany", "connect", "poll", "consume", "stop", "clear"],
54
+ bind: { data: "/stream/data", status: "/stream/status" }
96
55
  },
97
56
  {
98
- type: 'SelectionController',
99
- description: 'Single or multi-select state for lists, tables, grids.',
100
- config: { mode: { type: 'string', enum: ['single', 'multi'], default: 'single' } },
101
- commands: ['select', 'deselect', 'toggle', 'selectAll', 'clear'],
102
- bind: { selected: '/selection/items', count: '/selection/count' },
57
+ type: "SelectionController",
58
+ description: "Single or multi-select state for lists, tables, grids.",
59
+ config: { mode: { type: "string", enum: ["single", "multi"], default: "single" } },
60
+ commands: ["select", "deselect", "toggle", "selectAll", "clear"],
61
+ bind: { selected: "/selection/items", count: "/selection/count" }
103
62
  },
104
63
  {
105
- type: 'ToggleController',
106
- description: 'Boolean on/off state with attribute reflection.',
64
+ type: "ToggleController",
65
+ description: "Boolean on/off state with attribute reflection.",
107
66
  config: {},
108
- commands: ['toggle', 'set'],
109
- bind: { value: '/toggle/on' },
67
+ commands: ["toggle", "set"],
68
+ bind: { value: "/toggle/on" }
110
69
  },
111
70
  {
112
- type: 'AccordionController',
113
- description: 'Panel expand/collapse with mutual exclusion.',
114
- config: { multiple: { type: 'boolean', default: false } },
115
- commands: ['open', 'close', 'toggle'],
116
- bind: { openPanels: '/accordion/open' },
117
- },
71
+ type: "AccordionController",
72
+ description: "Panel expand/collapse with mutual exclusion.",
73
+ config: { multiple: { type: "boolean", default: false } },
74
+ commands: ["open", "close", "toggle"],
75
+ bind: { openPanels: "/accordion/open" }
76
+ }
118
77
  ],
119
-
120
78
  // ── ACTIONS: event → handler chains ──
121
79
  handlers: [
122
- { name: 'submit-resource', description: 'POST/PUT/PATCH/DELETE to a resource URI.', config: ['uri', 'method', 'body'] },
123
- { name: 'update-model', description: 'Update the surface data model at a path.', config: ['path', 'value'] },
124
- { name: 'navigate', description: 'Route to a path (supports {param} templates).', config: ['navigate'] },
125
- { name: 'navigate-back', description: 'Go back in browser history.', config: [] },
126
- { name: 'controller-command', description: 'Invoke a command on a controller.', config: ['controllerId', 'command', 'args'] },
127
- { name: 'emit-event', description: 'Dispatch a named CustomEvent on the surface.', config: ['eventName', 'detail'] },
128
- { name: 'refresh-source', description: 'Re-fetch a named data source.', config: ['sourceId'] },
129
- { name: 'notify', description: 'Show a toast/alert notification.', config: ['message', 'variant'] },
80
+ { name: "submit-resource", description: "POST/PUT/PATCH/DELETE to a resource URI.", config: ["uri", "method", "body"] },
81
+ { name: "update-model", description: "Update the surface data model at a path.", config: ["path", "value"] },
82
+ { name: "navigate", description: "Route to a path (supports {param} templates).", config: ["navigate"] },
83
+ { name: "navigate-back", description: "Go back in browser history.", config: [] },
84
+ { name: "controller-command", description: "Invoke a command on a controller.", config: ["controllerId", "command", "args"] },
85
+ { name: "emit-event", description: "Dispatch a named CustomEvent on the surface.", config: ["eventName", "detail"] },
86
+ { name: "refresh-source", description: "Re-fetch a named data source.", config: ["sourceId"] },
87
+ { name: "notify", description: "Show a toast/alert notification.", config: ["message", "variant"] }
130
88
  ],
131
-
132
89
  // ── ACTION SHAPE (UIEvent → handler) ──
133
90
  actionShape: {
134
- event: 'UIEvent object: { event, target?, debounce?, throttle?, condition? }',
135
- handler: 'Handler name from the handlers list.',
136
- config: 'Handler-specific configuration object.',
137
- onSuccess: 'Follow-up actions array (each is { handler, config }).',
138
- onError: 'Follow-up actions array on failure.',
91
+ event: "UIEvent object: { event, target?, debounce?, throttle?, condition? }",
92
+ handler: "Handler name from the handlers list.",
93
+ config: "Handler-specific configuration object.",
94
+ onSuccess: "Follow-up actions array (each is { handler, config }).",
95
+ onError: "Follow-up actions array on failure."
139
96
  },
140
-
141
97
  // ── PROVIDES: context injection ──
142
98
  provides: {
143
- description: 'Inject shared state into a component subtree via a2ui-provider. Children consume via context name.',
144
- example: { name: 'auth', host: 'root', value: { user: null, token: null } },
99
+ description: "Inject shared state into a component subtree via a2ui-provider. Children consume via context name.",
100
+ example: { name: "auth", host: "root", value: { user: null, token: null } }
145
101
  },
146
-
147
102
  // ── LIFECYCLE hooks ──
148
103
  lifecycle: {
149
- onMount: 'Actions to run when the surface first renders (fetch initial data, start streams).',
150
- onUnmount: 'Cleanup actions when the surface is destroyed (close WebSocket, stop polling).',
151
- onModelChange: 'Watch a model path and fire actions when it changes (debounce supported).',
104
+ onMount: "Actions to run when the surface first renders (fetch initial data, start streams).",
105
+ onUnmount: "Cleanup actions when the surface is destroyed (close WebSocket, stop polling).",
106
+ onModelChange: "Watch a model path and fire actions when it changes (debounce supported)."
152
107
  },
153
-
154
108
  // ── VALUE EXTRACTION (how actions read data) ──
155
109
  valueSources: [
156
- { from: 'event-detail', description: 'Read from event.detail (key = property)' },
157
- { from: 'event-target', description: 'Read from event.target (key = property, e.g., value)' },
158
- { from: 'model', description: 'Read from data model (path = JSON Pointer)' },
159
- { from: 'literal', description: 'Static value (value = the value)' },
160
- { from: 'param', description: 'Read from resolved parameters (key = param name)' },
161
- { from: 'controller', description: 'Read from a controller state (controllerId + key)' },
110
+ { from: "event-detail", description: "Read from event.detail (key = property)" },
111
+ { from: "event-target", description: "Read from event.target (key = property, e.g., value)" },
112
+ { from: "model", description: "Read from data model (path = JSON Pointer)" },
113
+ { from: "literal", description: "Static value (value = the value)" },
114
+ { from: "param", description: "Read from resolved parameters (key = param name)" },
115
+ { from: "controller", description: "Read from a controller state (controllerId + key)" }
162
116
  ],
163
-
164
117
  // ── MULTI-SURFACE ASSOCIATIONS ──
165
118
  associations: [
166
- { name: 'routes-to', description: 'Navigation source links to target.' },
167
- { name: 'feeds', description: 'Data flow source output target input.' },
168
- { name: 'shares-context', description: 'Shared state both read/write same context.' },
169
- { name: 'depends-on', description: 'Lifecycle source waits for target.' },
170
- { name: 'triggers', description: 'Side effect source event target update.' },
171
- { name: 'contains', description: 'Composition target renders inside source.' },
172
- ],
119
+ { name: "routes-to", description: "Navigation \u2014 source links to target." },
120
+ { name: "feeds", description: "Data flow \u2014 source output \u2192 target input." },
121
+ { name: "shares-context", description: "Shared state \u2014 both read/write same context." },
122
+ { name: "depends-on", description: "Lifecycle \u2014 source waits for target." },
123
+ { name: "triggers", description: "Side effect \u2014 source event \u2192 target update." },
124
+ { name: "contains", description: "Composition \u2014 target renders inside source." }
125
+ ]
173
126
  };
174
127
  }
175
-
176
- /**
177
- * Get UIEvent type info.
178
- */
179
- export function getAdiaEvent(type) {
180
- return adiaEvents.find(e => e.event === type) || null;
128
+ function getAdiaEvent(type) {
129
+ return adiaEvents.find((e) => e.event === type) ?? void 0;
181
130
  }
182
-
183
- /**
184
- * Get controller catalog entry by type name.
185
- */
186
- export function getControllerInfo(type) {
187
- return getWiringCatalog().controllers.find(c => c.type === type) || null;
131
+ function getControllerInfo(type) {
132
+ const catalog = getWiringCatalog();
133
+ return catalog["controllers"].find((c) => c.type === type) ?? void 0;
188
134
  }
189
-
190
- /**
191
- * Get handler catalog entry by name.
192
- */
193
- export function getHandlerInfo(name) {
194
- return getWiringCatalog().handlers.find(h => h.name === name) || null;
135
+ function getHandlerInfo(name) {
136
+ const catalog = getWiringCatalog();
137
+ return catalog["handlers"].find((h) => h.name === name) ?? void 0;
195
138
  }
139
+ export {
140
+ getAdiaEvent,
141
+ getControllerInfo,
142
+ getHandlerInfo,
143
+ getWiringCatalog
144
+ };