@tai42/studio-sdk 13.2.2 → 14.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/dist/components/icons.d.ts +2 -0
- package/dist/components/icons.d.ts.map +1 -1
- package/dist/components/icons.js +2 -0
- package/dist/components/icons.js.map +1 -1
- package/dist/hooks/useApi.d.ts +199 -24
- package/dist/hooks/useApi.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/navigation/types.d.ts +2 -1
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/query-keys.d.ts +13 -0
- package/dist/query-keys.d.ts.map +1 -1
- package/dist/query-keys.js +13 -0
- package/dist/query-keys.js.map +1 -1
- package/dist/state-binding/AdapterMapping.d.ts +33 -0
- package/dist/state-binding/AdapterMapping.d.ts.map +1 -0
- package/dist/state-binding/AdapterMapping.js +205 -0
- package/dist/state-binding/AdapterMapping.js.map +1 -0
- package/dist/state-binding/BindingJqField.d.ts +36 -0
- package/dist/state-binding/BindingJqField.d.ts.map +1 -0
- package/dist/state-binding/BindingJqField.js +54 -0
- package/dist/state-binding/BindingJqField.js.map +1 -0
- package/dist/state-binding/InputInjectionRow.d.ts +17 -0
- package/dist/state-binding/InputInjectionRow.d.ts.map +1 -0
- package/dist/state-binding/InputInjectionRow.js +55 -0
- package/dist/state-binding/InputInjectionRow.js.map +1 -0
- package/dist/state-binding/StateAttachRow.d.ts +25 -0
- package/dist/state-binding/StateAttachRow.d.ts.map +1 -0
- package/dist/state-binding/StateAttachRow.js +101 -0
- package/dist/state-binding/StateAttachRow.js.map +1 -0
- package/dist/state-binding/StateBindingEditor.d.ts +35 -0
- package/dist/state-binding/StateBindingEditor.d.ts.map +1 -0
- package/dist/state-binding/StateBindingEditor.js +52 -0
- package/dist/state-binding/StateBindingEditor.js.map +1 -0
- package/dist/state-binding/StateBindingSection.d.ts +14 -0
- package/dist/state-binding/StateBindingSection.d.ts.map +1 -0
- package/dist/state-binding/StateBindingSection.js +17 -0
- package/dist/state-binding/StateBindingSection.js.map +1 -0
- package/dist/state-binding/SubjectScopeFields.d.ts +17 -0
- package/dist/state-binding/SubjectScopeFields.d.ts.map +1 -0
- package/dist/state-binding/SubjectScopeFields.js +8 -0
- package/dist/state-binding/SubjectScopeFields.js.map +1 -0
- package/dist/state-binding/UpdateRow.d.ts +19 -0
- package/dist/state-binding/UpdateRow.d.ts.map +1 -0
- package/dist/state-binding/UpdateRow.js +76 -0
- package/dist/state-binding/UpdateRow.js.map +1 -0
- package/dist/state-binding/adapter.d.ts +93 -0
- package/dist/state-binding/adapter.d.ts.map +1 -0
- package/dist/state-binding/adapter.js +251 -0
- package/dist/state-binding/adapter.js.map +1 -0
- package/dist/state-binding/build-catalog.d.ts +19 -0
- package/dist/state-binding/build-catalog.d.ts.map +1 -0
- package/dist/state-binding/build-catalog.js +43 -0
- package/dist/state-binding/build-catalog.js.map +1 -0
- package/dist/state-binding/catalog.d.ts +26 -0
- package/dist/state-binding/catalog.d.ts.map +1 -0
- package/dist/state-binding/catalog.js +71 -0
- package/dist/state-binding/catalog.js.map +1 -0
- package/dist/state-binding/index.d.ts +29 -0
- package/dist/state-binding/index.d.ts.map +1 -0
- package/dist/state-binding/index.js +18 -0
- package/dist/state-binding/index.js.map +1 -0
- package/dist/state-binding/types.d.ts +57 -0
- package/dist/state-binding/types.d.ts.map +1 -0
- package/dist/state-binding/types.js +2 -0
- package/dist/state-binding/types.js.map +1 -0
- package/package.json +5 -5
- package/src/components/icons.tsx +8 -0
- package/src/index.ts +63 -1
- package/src/navigation/types.ts +4 -1
- package/src/query-keys.ts +15 -0
- package/src/state-binding/AdapterMapping.tsx +468 -0
- package/src/state-binding/BindingJqField.tsx +134 -0
- package/src/state-binding/InputInjectionRow.tsx +148 -0
- package/src/state-binding/README.md +46 -0
- package/src/state-binding/StateAttachRow.tsx +281 -0
- package/src/state-binding/StateBindingEditor.tsx +158 -0
- package/src/state-binding/StateBindingSection.tsx +37 -0
- package/src/state-binding/SubjectScopeFields.tsx +49 -0
- package/src/state-binding/UpdateRow.tsx +194 -0
- package/src/state-binding/adapter.ts +276 -0
- package/src/state-binding/build-catalog.ts +59 -0
- package/src/state-binding/catalog.ts +87 -0
- package/src/state-binding/index.ts +61 -0
- package/src/state-binding/types.ts +62 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* One attached state of a binding: the state selector, the templates it attaches
|
|
4
|
+
* (attach-on-use — a not-yet-attached pick shows the "attached on save" hint), the subject
|
|
5
|
+
* and scope expressions, the input injections, and the updates.
|
|
6
|
+
*/
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
import { Button } from '../components/primitives';
|
|
9
|
+
import { CodeBlock } from '../components/code-block';
|
|
10
|
+
import { Checkbox } from '../components/checkbox';
|
|
11
|
+
import { Field } from '../components/field';
|
|
12
|
+
import { Select } from '../components/select';
|
|
13
|
+
import { AlertTriangleIcon, CloseIcon } from '../components/icons';
|
|
14
|
+
import { InjectionList } from './InputInjectionRow';
|
|
15
|
+
import { UpdateList } from './UpdateRow';
|
|
16
|
+
import { SubjectScopeFields } from './SubjectScopeFields';
|
|
17
|
+
import { resolveTemplateJq } from './catalog';
|
|
18
|
+
const ATTACH_ON_USE_HINT = 'This template will be attached to the state when you save.';
|
|
19
|
+
/** The stored binding's raw jq, for the unresolved-catalog read-only fallback. */
|
|
20
|
+
function rawBindingLines(attach) {
|
|
21
|
+
const lines = [`subject: ${attach.subject_expr || '(unset)'}`];
|
|
22
|
+
if (attach.scope_expr !== null && attach.scope_expr !== '')
|
|
23
|
+
lines.push(`scope: ${attach.scope_expr}`);
|
|
24
|
+
for (const injection of attach.input_injections) {
|
|
25
|
+
lines.push(`input ${injection.into || '(unset)'} <- ${injection.template_jq ?? injection.jq ?? ''}`);
|
|
26
|
+
}
|
|
27
|
+
for (const update of attach.updates) {
|
|
28
|
+
const ref = update.template_jq ?? update.jq ?? '';
|
|
29
|
+
lines.push(`update ${ref}${update.adapter !== null && update.adapter !== '' ? ` adapter ${update.adapter}` : ''}`);
|
|
30
|
+
}
|
|
31
|
+
return lines.join('\n');
|
|
32
|
+
}
|
|
33
|
+
export function StateAttachRow({ attach, onChange, onRemove, statesCatalog, templatesCatalog, sources, subjectError, inherited, }) {
|
|
34
|
+
const stateOption = statesCatalog.find((option) => option.name === attach.state);
|
|
35
|
+
const attachedTemplates = stateOption?.attachedTemplates ?? [];
|
|
36
|
+
// A bound state or template absent on the server cannot resolve its pickers: show
|
|
37
|
+
// the raw jq read-only rather than a blank form.
|
|
38
|
+
const stateMissing = attach.state !== '' && stateOption === undefined;
|
|
39
|
+
const missingTemplates = attach.templates.filter((name) => !templatesCatalog.some((template) => template.name === name));
|
|
40
|
+
const unresolved = stateMissing || missingTemplates.length > 0;
|
|
41
|
+
const inputJq = useMemo(() => resolveTemplateJq(attach.templates, templatesCatalog, 'input'), [attach.templates, templatesCatalog]);
|
|
42
|
+
const updateJq = useMemo(() => resolveTemplateJq(attach.templates, templatesCatalog, 'update'), [attach.templates, templatesCatalog]);
|
|
43
|
+
// An `update` jq returns an op batch and is never callable from an expression (it is
|
|
44
|
+
// picked only by an update's own select), so the `tjq_…` insert suggestions offered to
|
|
45
|
+
// EVERY jq field are the attached templates' `input`-purpose jq only.
|
|
46
|
+
const suggestions = useMemo(() => inputJq.map((entry) => ({
|
|
47
|
+
ref: entry.ref,
|
|
48
|
+
purpose: entry.purpose,
|
|
49
|
+
description: entry.description,
|
|
50
|
+
})), [inputJq]);
|
|
51
|
+
const toggleTemplate = (name, checked) => {
|
|
52
|
+
const next = checked
|
|
53
|
+
? [...attach.templates, name]
|
|
54
|
+
: attach.templates.filter((template) => template !== name);
|
|
55
|
+
onChange({ ...attach, templates: next });
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs("div", { "data-testid": `state-attach-${attach.state}`, style: {
|
|
58
|
+
display: 'flex',
|
|
59
|
+
flexDirection: 'column',
|
|
60
|
+
gap: 'var(--tai-space-3)',
|
|
61
|
+
padding: 'var(--tai-space-3)',
|
|
62
|
+
border: '1px solid var(--tai-color-border)',
|
|
63
|
+
borderRadius: 'var(--tai-radius-md)',
|
|
64
|
+
}, children: [_jsxs("div", { style: {
|
|
65
|
+
display: 'flex',
|
|
66
|
+
gap: 'var(--tai-space-2)',
|
|
67
|
+
alignItems: 'flex-end',
|
|
68
|
+
flexWrap: 'wrap',
|
|
69
|
+
}, children: [_jsx(Field, { label: "State", children: _jsx(Select, { "aria-label": "State", placeholder: "Choose a state", value: attach.state, onValueChange: (next) => {
|
|
70
|
+
// A new state resets the template picks (its attachments differ).
|
|
71
|
+
onChange({ ...attach, state: next, templates: [] });
|
|
72
|
+
}, options: statesCatalog.map((option) => ({ value: option.name, label: option.name })) }) }), _jsx(Button, { type: "button", variant: "ghost", "aria-label": `Remove state ${attach.state === '' ? '(unset)' : attach.state}`, onClick: onRemove, children: _jsx(CloseIcon, { "aria-hidden": "true" }) })] }), inherited !== undefined && attach.state !== '' ? (_jsxs("div", { role: "status", style: {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
gap: 'var(--tai-space-2)',
|
|
75
|
+
alignItems: 'flex-start',
|
|
76
|
+
padding: 'var(--tai-space-2)',
|
|
77
|
+
borderRadius: 'var(--tai-radius-md)',
|
|
78
|
+
background: 'var(--tai-color-warn-tint)',
|
|
79
|
+
color: 'var(--tai-color-warn-text)',
|
|
80
|
+
}, children: [_jsx(AlertTriangleIcon, { "aria-hidden": "true" }), _jsxs("div", { children: [_jsx("strong", { children: "Overrides the preset\u2019s subject" }), _jsxs("div", { style: { display: 'flex', gap: 'var(--tai-space-2)', flexWrap: 'wrap' }, children: [_jsx("span", { style: { color: 'var(--tai-color-text-muted)', fontSize: 'var(--tai-text-sm)' }, children: "Preset default:" }), _jsxs("span", { style: { fontFamily: 'var(--tai-font-mono)', fontSize: 'var(--tai-text-sm)' }, children: [`subject: ${inherited.subject_expr}`, inherited.scope_expr !== null && inherited.scope_expr !== ''
|
|
81
|
+
? `, scope: ${inherited.scope_expr}`
|
|
82
|
+
: ''] })] })] })] })) : null, attach.state !== '' && unresolved ? (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-2)' }, children: [_jsx("p", { role: "alert", style: { margin: 0, color: 'var(--tai-color-err-text)' }, children: "Template not attached." }), _jsx(CodeBlock, { code: rawBindingLines(attach), language: "text" })] })) : null, attach.state !== '' && !unresolved ? (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Templates", group: true, description: "One or more templates this binding attaches to the state.", children: _jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-1)' }, children: templatesCatalog.length === 0 ? (_jsx("p", { style: { margin: 0, color: 'var(--tai-color-text-muted)' }, children: "No templates available." })) : (templatesCatalog.map((template) => {
|
|
83
|
+
const checked = attach.templates.includes(template.name);
|
|
84
|
+
const willAttach = checked && !attachedTemplates.includes(template.name);
|
|
85
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '2px' }, children: [_jsx(Checkbox, { checked: checked, label: template.name, onCheckedChange: (next) => {
|
|
86
|
+
toggleTemplate(template.name, next);
|
|
87
|
+
} }), willAttach ? (_jsx("span", { style: {
|
|
88
|
+
color: 'var(--tai-color-text-muted)',
|
|
89
|
+
fontSize: 'var(--tai-text-sm)',
|
|
90
|
+
}, children: ATTACH_ON_USE_HINT })) : null] }, template.name));
|
|
91
|
+
})) }) }), _jsx(SubjectScopeFields, { subjectExpr: attach.subject_expr, scopeExpr: attach.scope_expr, subjectError: subjectError, suggestions: suggestions, onSubjectChange: (next) => {
|
|
92
|
+
onChange({ ...attach, subject_expr: next });
|
|
93
|
+
}, onScopeChange: (next) => {
|
|
94
|
+
onChange({ ...attach, scope_expr: next });
|
|
95
|
+
} }), _jsx(Field, { label: "Inputs", group: true, children: _jsx(InjectionList, { injections: attach.input_injections, inputJq: inputJq, suggestions: suggestions, onChange: (next) => {
|
|
96
|
+
onChange({ ...attach, input_injections: [...next] });
|
|
97
|
+
} }) }), _jsx(Field, { label: "Updates", group: true, children: _jsx(UpdateList, { updates: attach.updates, updateJq: updateJq, sources: sources, suggestions: suggestions, onChange: (next) => {
|
|
98
|
+
onChange({ ...attach, updates: [...next] });
|
|
99
|
+
} }) })] })) : null] }));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=StateAttachRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateAttachRow.js","sourceRoot":"","sources":["../../src/state-binding/StateAttachRow.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAQ9C,MAAM,kBAAkB,GAAG,4DAA4D,CAAC;AAQxF,kFAAkF;AAClF,SAAS,eAAe,CAAC,MAAmB;IAC1C,MAAM,KAAK,GAAG,CAAC,YAAY,MAAM,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC,CAAC;IAC/D,IAA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|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The optional state-binding editor — one shape on every door (a preset, a channel
|
|
3
|
+
* route, a schedule, a hook) and, in the flow engine, per node. It attaches one or
|
|
4
|
+
* more states, each with the templates it attaches on save, a subject/scope, input
|
|
5
|
+
* injections evaluated before the run, and updates applied after it.
|
|
6
|
+
*
|
|
7
|
+
* It lives in the Studio SDK so every plugin door reuses it; it holds NO edge to jq
|
|
8
|
+
* (the jq fields render through the host's ambient expression door, else a plain
|
|
9
|
+
* textarea) and paints from SDK tokens only.
|
|
10
|
+
*/
|
|
11
|
+
import type { ReactNode } from 'react';
|
|
12
|
+
import type { BindingSourceSchemas, BindingStateOption, BindingTemplateOption, StateBinding } from './types';
|
|
13
|
+
export interface StateBindingEditorProps {
|
|
14
|
+
/** The binding, or `null` when the door binds no state. */
|
|
15
|
+
readonly value: StateBinding | null;
|
|
16
|
+
readonly onChange: (value: StateBinding | null) => void;
|
|
17
|
+
/** The states this door may bind, each with its attached templates and fields. */
|
|
18
|
+
readonly statesCatalog: readonly BindingStateOption[];
|
|
19
|
+
/** The templates the editor may attach (attach-on-use), each with its template jq. */
|
|
20
|
+
readonly templatesCatalog: readonly BindingTemplateOption[];
|
|
21
|
+
/** The run's output/input field paths a picker offers when a schema is known. */
|
|
22
|
+
readonly sources?: BindingSourceSchemas;
|
|
23
|
+
/**
|
|
24
|
+
* The TARGET's own binding (e.g. the preset a route dispatches), passed by the door
|
|
25
|
+
* screen — never fetched here. A state this binding names that the inherited one
|
|
26
|
+
* also names shows a precedence warning on its card.
|
|
27
|
+
*/
|
|
28
|
+
readonly inherited?: StateBinding | null;
|
|
29
|
+
/** The catalog fetch is in flight. */
|
|
30
|
+
readonly loading?: boolean;
|
|
31
|
+
/** The catalog fetch failed. */
|
|
32
|
+
readonly error?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function StateBindingEditor({ value, onChange, statesCatalog, templatesCatalog, sources, inherited, loading, error, }: StateBindingEditorProps): ReactNode;
|
|
35
|
+
//# sourceMappingURL=StateBindingEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateBindingEditor.d.ts","sourceRoot":"","sources":["../../src/state-binding/StateBindingEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EAErB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;IACxD,kFAAkF;IAClF,QAAQ,CAAC,aAAa,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACtD,sFAAsF;IACtF,QAAQ,CAAC,gBAAgB,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC5D,iFAAiF;IACjF,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACzC,sCAAsC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAaD,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,OAAe,EACf,KAAK,GACN,EAAE,uBAAuB,GAAG,SAAS,CA6FrC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button, EmptyState, ErrorState, Skeleton } from '../components/primitives';
|
|
3
|
+
import { StateAttachRow } from './StateAttachRow';
|
|
4
|
+
function blankAttach() {
|
|
5
|
+
return {
|
|
6
|
+
state: '',
|
|
7
|
+
templates: [],
|
|
8
|
+
subject_expr: '',
|
|
9
|
+
scope_expr: null,
|
|
10
|
+
input_injections: [],
|
|
11
|
+
updates: [],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function StateBindingEditor({ value, onChange, statesCatalog, templatesCatalog, sources, inherited, loading = false, error, }) {
|
|
15
|
+
if (loading) {
|
|
16
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-2)' }, children: [_jsx(Skeleton, { height: 32 }), _jsx(Skeleton, { height: 32 })] }));
|
|
17
|
+
}
|
|
18
|
+
if (error !== undefined) {
|
|
19
|
+
return _jsx(ErrorState, { message: "Couldn't load states and templates." });
|
|
20
|
+
}
|
|
21
|
+
const states = value?.states ?? [];
|
|
22
|
+
const setStates = (next) => {
|
|
23
|
+
onChange(next.length === 0 ? null : { states: [...next] });
|
|
24
|
+
};
|
|
25
|
+
return (_jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-3)' }, children: states.length === 0 ? (_jsx(EmptyState, { title: "No state bound", description: "Attach a state to inject a value into the run and update the record after it.", action: _jsx(Button, { type: "button", variant: "primary", onClick: () => {
|
|
26
|
+
setStates([blankAttach()]);
|
|
27
|
+
}, children: "Attach a state" }) })) : (_jsxs(_Fragment, { children: [states.map((attach, index) => {
|
|
28
|
+
const inheritedAttach = attach.state === ''
|
|
29
|
+
? undefined
|
|
30
|
+
: inherited?.states.find((entry) => entry.state === attach.state);
|
|
31
|
+
// The subject is a required jq (contract: min_length=1); an empty one is
|
|
32
|
+
// caught inline once a state is chosen, never sent for the server to 422.
|
|
33
|
+
const subjectError = attach.state !== '' && attach.subject_expr.trim() === ''
|
|
34
|
+
? 'Subject is required.'
|
|
35
|
+
: undefined;
|
|
36
|
+
return (_jsx(StateAttachRow
|
|
37
|
+
// Positional identity within a save; a state name may be blank while picking.
|
|
38
|
+
, { attach: attach, statesCatalog: statesCatalog, templatesCatalog: templatesCatalog, sources: sources, subjectError: subjectError, inherited: inheritedAttach === undefined
|
|
39
|
+
? undefined
|
|
40
|
+
: {
|
|
41
|
+
subject_expr: inheritedAttach.subject_expr,
|
|
42
|
+
scope_expr: inheritedAttach.scope_expr,
|
|
43
|
+
}, onChange: (next) => {
|
|
44
|
+
setStates(states.map((current, position) => (position === index ? next : current)));
|
|
45
|
+
}, onRemove: () => {
|
|
46
|
+
setStates(states.filter((_, position) => position !== index));
|
|
47
|
+
} }, index));
|
|
48
|
+
}), _jsx("div", { children: _jsx(Button, { type: "button", variant: "ghost", onClick: () => {
|
|
49
|
+
setStates([...states, blankAttach()]);
|
|
50
|
+
}, children: "Attach a state" }) })] })) }));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=StateBindingEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateBindingEditor.js","sourceRoot":"","sources":["../../src/state-binding/StateBindingEditor.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA+BlD,SAAS,WAAW;IAClB,OAAO;QACL,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,IAAI;QAChB,gBAAgB,EAAE,EAAE;QACpB,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GACmB;IACxB,IAAI,OAAO,EAAE,CAAC;QAC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AG,EAAE;4BACZ,SAAS,CAAC,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;wBACxC,CAAC,+BAGM,GACL,IACL,CACJ,GACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The collapsed "Bind state (optional)" section every platform door screen adds
|
|
3
|
+
* below its own fields. It is chrome only — the door fetches the catalogs (via its
|
|
4
|
+
* own api-client + query stack) and passes them in; this wraps `StateBindingEditor`
|
|
5
|
+
* in a keyboard-native disclosure that opens when a binding already exists.
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
import { type StateBindingEditorProps } from './StateBindingEditor';
|
|
9
|
+
export interface StateBindingSectionProps extends StateBindingEditorProps {
|
|
10
|
+
/** Copy on the disclosure toggle. */
|
|
11
|
+
readonly label?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function StateBindingSection({ label, ...editor }: StateBindingSectionProps): ReactNode;
|
|
14
|
+
//# sourceMappingURL=StateBindingSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateBindingSection.d.ts","sourceRoot":"","sources":["../../src/state-binding/StateBindingSection.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAsB,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAExF,MAAM,WAAW,wBAAyB,SAAQ,uBAAuB;IACvE,qCAAqC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,KAA+B,EAC/B,GAAG,MAAM,EACV,EAAE,wBAAwB,GAAG,SAAS,CAiBtC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The collapsed "Bind state (optional)" section every platform door screen adds
|
|
4
|
+
* below its own fields. It is chrome only — the door fetches the catalogs (via its
|
|
5
|
+
* own api-client + query stack) and passes them in; this wraps `StateBindingEditor`
|
|
6
|
+
* in a keyboard-native disclosure that opens when a binding already exists.
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { Button } from '../components/primitives';
|
|
10
|
+
import { StateBindingEditor } from './StateBindingEditor';
|
|
11
|
+
export function StateBindingSection({ label = 'Bind state (optional)', ...editor }) {
|
|
12
|
+
const [open, setOpen] = useState((editor.value?.states.length ?? 0) > 0);
|
|
13
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-2)' }, children: [_jsx(Button, { type: "button", variant: "ghost", "aria-expanded": open, onClick: () => {
|
|
14
|
+
setOpen((current) => !current);
|
|
15
|
+
}, children: label }), open ? _jsx(StateBindingEditor, { ...editor }) : null] }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=StateBindingSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateBindingSection.js","sourceRoot":"","sources":["../../src/state-binding/StateBindingSection.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAgC,MAAM,sBAAsB,CAAC;AAOxF,MAAM,UAAU,mBAAmB,CAAC,EAClC,KAAK,GAAG,uBAAuB,EAC/B,GAAG,MAAM,EACgB;IACzB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACzE,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,oBAAoB,EAAE,aACjF,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,OAAO,mBACA,IAAI,EACnB,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;gBACjC,CAAC,YAEA,KAAK,GACC,EACR,IAAI,CAAC,CAAC,CAAC,KAAC,kBAAkB,OAAK,MAAM,GAAI,CAAC,CAAC,CAAC,IAAI,IAC7C,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subject + scope jq of one attached state: the SUBJECT expression (required)
|
|
3
|
+
* yields either a bare record-key string or a full subject object; the optional SCOPE
|
|
4
|
+
* expression is a boolean jq predicate — when it is false the state is skipped for the run.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
import { type TemplateJqSuggestion } from './BindingJqField';
|
|
8
|
+
export interface SubjectScopeFieldsProps {
|
|
9
|
+
readonly subjectExpr: string;
|
|
10
|
+
readonly scopeExpr: string | null;
|
|
11
|
+
readonly onSubjectChange: (value: string) => void;
|
|
12
|
+
readonly onScopeChange: (value: string | null) => void;
|
|
13
|
+
readonly subjectError?: string;
|
|
14
|
+
readonly suggestions?: readonly TemplateJqSuggestion[];
|
|
15
|
+
}
|
|
16
|
+
export declare function SubjectScopeFields({ subjectExpr, scopeExpr, onSubjectChange, onScopeChange, subjectError, suggestions, }: SubjectScopeFieldsProps): ReactNode;
|
|
17
|
+
//# sourceMappingURL=SubjectScopeFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubjectScopeFields.d.ts","sourceRoot":"","sources":["../../src/state-binding/SubjectScopeFields.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACxD;AAED,wBAAgB,kBAAkB,CAAC,EACjC,WAAW,EACX,SAAS,EACT,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,EAAE,uBAAuB,GAAG,SAAS,CAuBrC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BindingJqField } from './BindingJqField';
|
|
3
|
+
export function SubjectScopeFields({ subjectExpr, scopeExpr, onSubjectChange, onScopeChange, subjectError, suggestions, }) {
|
|
4
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-2)' }, children: [_jsx(BindingJqField, { label: "Subject", description: "The record key this binding reads and updates: a key string, or a full subject object.", value: subjectExpr, onChange: onSubjectChange, error: subjectError, suggestions: suggestions, placeholder: ".subject_id" }), _jsx(BindingJqField, { label: "Scope", description: "Optional. A jq condition; when it is false this state is skipped for the run.", value: scopeExpr ?? '', onChange: (next) => {
|
|
5
|
+
onScopeChange(next.trim() === '' ? null : next);
|
|
6
|
+
}, suggestions: suggestions })] }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=SubjectScopeFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubjectScopeFields.js","sourceRoot":"","sources":["../../src/state-binding/SubjectScopeFields.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAA6B,MAAM,kBAAkB,CAAC;AAW7E,MAAM,UAAU,kBAAkB,CAAC,EACjC,WAAW,EACX,SAAS,EACT,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,GACa;IACxB,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,oBAAoB,EAAE,aACjF,KAAC,cAAc,IACb,KAAK,EAAC,SAAS,EACf,WAAW,EAAC,wFAAwF,EACpG,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAC,aAAa,GACzB,EACF,KAAC,cAAc,IACb,KAAK,EAAC,OAAO,EACb,WAAW,EAAC,+EAA+E,EAC3F,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;oBACjB,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAClD,CAAC,EACD,WAAW,EAAE,WAAW,GACxB,IACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The update list of one attached state. Each update applies AFTER the run: either
|
|
3
|
+
* a template `update` jq (picked by name, whose declared input is authored through
|
|
4
|
+
* the adapter mapping) or a custom jq over `{ record, output, input }` that authors
|
|
5
|
+
* the whole op batch itself. An optional op-id expression carries idempotency.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
import { type TemplateJqSuggestion } from './BindingJqField';
|
|
9
|
+
import { type ResolvedTemplateJq } from './catalog';
|
|
10
|
+
import type { BindingSourceSchemas, StateUpdate } from './types';
|
|
11
|
+
export interface UpdateListProps {
|
|
12
|
+
readonly updates: readonly StateUpdate[];
|
|
13
|
+
readonly onChange: (updates: readonly StateUpdate[]) => void;
|
|
14
|
+
readonly updateJq: readonly ResolvedTemplateJq[];
|
|
15
|
+
readonly sources?: BindingSourceSchemas;
|
|
16
|
+
readonly suggestions?: readonly TemplateJqSuggestion[];
|
|
17
|
+
}
|
|
18
|
+
export declare function UpdateList({ updates, onChange, updateJq, sources, suggestions, }: UpdateListProps): ReactNode;
|
|
19
|
+
//# sourceMappingURL=UpdateRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateRow.d.ts","sourceRoot":"","sources":["../../src/state-binding/UpdateRow.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA+HjE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACxD;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,WAAW,GACZ,EAAE,eAAe,GAAG,SAAS,CAoC7B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Badge } from '../components/badge';
|
|
3
|
+
import { Button } from '../components/primitives';
|
|
4
|
+
import { Field } from '../components/field';
|
|
5
|
+
import { Select } from '../components/select';
|
|
6
|
+
import { CloseIcon } from '../components/icons';
|
|
7
|
+
import { AdapterMapping } from './AdapterMapping';
|
|
8
|
+
import { BindingJqField } from './BindingJqField';
|
|
9
|
+
import { findByRef } from './catalog';
|
|
10
|
+
const CUSTOM = '__custom__';
|
|
11
|
+
function optionLabel(entry) {
|
|
12
|
+
return entry.description !== undefined && entry.description !== ''
|
|
13
|
+
? `${entry.ref} — ${entry.description}`
|
|
14
|
+
: entry.ref;
|
|
15
|
+
}
|
|
16
|
+
function writesLabel(entry) {
|
|
17
|
+
if (entry?.writes === undefined || entry.writes.length === 0)
|
|
18
|
+
return null;
|
|
19
|
+
return entry.writes.map((path) => path.join('.')).join(', ');
|
|
20
|
+
}
|
|
21
|
+
function UpdateRowEditor({ update, index, updateJq, sources, suggestions, onChange, onRemove, }) {
|
|
22
|
+
const isCustom = update.jq !== null;
|
|
23
|
+
const selectValue = isCustom ? CUSTOM : (update.template_jq ?? '');
|
|
24
|
+
const resolved = update.template_jq !== null ? findByRef(update.template_jq, updateJq) : undefined;
|
|
25
|
+
const writes = writesLabel(resolved);
|
|
26
|
+
return (_jsxs("div", { "data-testid": `update-row-${String(index)}`, style: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flexDirection: 'column',
|
|
29
|
+
gap: 'var(--tai-space-2)',
|
|
30
|
+
padding: 'var(--tai-space-2)',
|
|
31
|
+
border: '1px solid var(--tai-color-border)',
|
|
32
|
+
borderRadius: 'var(--tai-radius-md)',
|
|
33
|
+
}, children: [_jsxs("div", { style: {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
gap: 'var(--tai-space-2)',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
flexWrap: 'wrap',
|
|
38
|
+
}, children: [_jsx(Field, { label: `Update source ${String(index + 1)}`, hideLabel: true, children: _jsx(Select, { placeholder: "Choose a template jq", value: selectValue, onValueChange: (next) => {
|
|
39
|
+
if (next === CUSTOM)
|
|
40
|
+
onChange({ template_jq: null, jq: '', adapter: null, op_id: update.op_id });
|
|
41
|
+
else
|
|
42
|
+
onChange({ template_jq: next, jq: null, adapter: null, op_id: update.op_id });
|
|
43
|
+
}, groups: [
|
|
44
|
+
{
|
|
45
|
+
label: 'Template jq',
|
|
46
|
+
options: updateJq.map((entry) => ({ value: entry.ref, label: optionLabel(entry) })),
|
|
47
|
+
},
|
|
48
|
+
{ label: 'Custom', options: [{ value: CUSTOM, label: 'Custom jq' }] },
|
|
49
|
+
] }) }), writes !== null ? _jsx(Badge, { variant: "neutral", children: `writes: ${writes}` }) : null, _jsx(Button, { type: "button", variant: "ghost", "aria-label": `Remove update ${String(index + 1)}`, onClick: onRemove, children: _jsx(CloseIcon, { "aria-hidden": "true" }) })] }), isCustom ? (_jsx(BindingJqField, { label: `Custom update jq ${String(index + 1)}`, description: "A jq over `{ record, output, input }` returning a template-relative op batch.", value: update.jq ?? '', onChange: (next) => {
|
|
50
|
+
onChange({ template_jq: null, jq: next, adapter: null, op_id: update.op_id });
|
|
51
|
+
}, suggestions: suggestions })) : (_jsx(Field, { label: "Adapter", group: true, children: _jsx(AdapterMapping
|
|
52
|
+
// Remount on a template change so the mapping rebuilds from the newly
|
|
53
|
+
// declared input (and re-seeds its shown default) instead of stale rows.
|
|
54
|
+
, { declaredInput: resolved?.params ?? [], value: update.adapter ?? '', sources: sources, suggestions: suggestions, onChange: (adapterJq) => {
|
|
55
|
+
onChange({ ...update, adapter: adapterJq });
|
|
56
|
+
} }, resolved?.ref ?? '__none__') })), _jsx(BindingJqField, { label: "Op id", description: "Optional \u2014 an idempotency-key expression.", value: update.op_id ?? '', onChange: (next) => {
|
|
57
|
+
onChange({ ...update, op_id: next.trim() === '' ? null : next });
|
|
58
|
+
}, suggestions: suggestions })] }));
|
|
59
|
+
}
|
|
60
|
+
export function UpdateList({ updates, onChange, updateJq, sources, suggestions, }) {
|
|
61
|
+
const add = () => {
|
|
62
|
+
const first = updateJq[0];
|
|
63
|
+
const next = first !== undefined
|
|
64
|
+
? { template_jq: first.ref, jq: null, adapter: null, op_id: null }
|
|
65
|
+
: { template_jq: null, jq: '', adapter: null, op_id: null };
|
|
66
|
+
onChange([...updates, next]);
|
|
67
|
+
};
|
|
68
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--tai-space-2)' }, children: [updates.map((update, index) => (_jsx(UpdateRowEditor
|
|
69
|
+
// Rows are positional; the index is their stable identity within a save.
|
|
70
|
+
, { update: update, index: index, updateJq: updateJq, sources: sources, suggestions: suggestions, onChange: (next) => {
|
|
71
|
+
onChange(updates.map((current, position) => (position === index ? next : current)));
|
|
72
|
+
}, onRemove: () => {
|
|
73
|
+
onChange(updates.filter((_, position) => position !== index));
|
|
74
|
+
} }, index))), _jsx("div", { children: _jsx(Button, { type: "button", variant: "ghost", onClick: add, children: "Add update" }) })] }));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=UpdateRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateRow.js","sourceRoot":"","sources":["../../src/state-binding/UpdateRow.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE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E,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;oBACjB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACtF,CAAC,EACD,QAAQ,EAAE,GAAG,EAAE;oBACb,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC;gBAChE,CAAC,IAXI,KAAK,CAYV,CACH,CAAC,EACF,wBACE,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,2BAEzC,GACL,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adapter compiler — a PURE function set, no React, no jq engine.
|
|
3
|
+
*
|
|
4
|
+
* A named template `update` jq declares an input object (its `params` / declared
|
|
5
|
+
* input keys). A binding must map the run's OUTPUT (and the run's INPUT) into that
|
|
6
|
+
* object; that mapping is the `adapter` — a single jq program over `{ output, input }`
|
|
7
|
+
* that CONSTRUCTS the update jq's declared input (which the update jq then reads as
|
|
8
|
+
* `.input` alongside the record).
|
|
9
|
+
*
|
|
10
|
+
* The editor authors the adapter as a ROW form: one row per declared input key,
|
|
11
|
+
* each row picking one of three value sources — a picked field (from the run's
|
|
12
|
+
* output / input schema), a hardcoded literal, or a raw jq expression. The whole
|
|
13
|
+
* form compiles here into ONE adapter jq; each row's own jq fragment is shown on demand.
|
|
14
|
+
*
|
|
15
|
+
* Compilation never throws: an invalid literal or an empty field surfaces as a
|
|
16
|
+
* loud, human error the editor renders in a `role="alert"`, never a silent empty
|
|
17
|
+
* object.
|
|
18
|
+
*/
|
|
19
|
+
/** Which root of `{ output, input }` a picked field reads. */
|
|
20
|
+
export type FieldRoot = 'output' | 'input';
|
|
21
|
+
/** A picked field: a path into `output` or `input`. */
|
|
22
|
+
export interface FieldSource {
|
|
23
|
+
readonly kind: 'field';
|
|
24
|
+
readonly root: FieldRoot;
|
|
25
|
+
readonly path: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** A hardcoded literal, authored as JSON text (`"a"`, `42`, `true`, `{…}`). */
|
|
28
|
+
export interface LiteralSource {
|
|
29
|
+
readonly kind: 'literal';
|
|
30
|
+
readonly json: string;
|
|
31
|
+
}
|
|
32
|
+
/** A raw jq expression over `{ output, input }`. */
|
|
33
|
+
export interface JqSource {
|
|
34
|
+
readonly kind: 'jq';
|
|
35
|
+
readonly expr: string;
|
|
36
|
+
}
|
|
37
|
+
/** The three value sources one mapping row may carry — exactly one at a time. */
|
|
38
|
+
export type MappingSource = FieldSource | LiteralSource | JqSource;
|
|
39
|
+
/** One mapping row: a target key of the update jq's declared input + its value source. */
|
|
40
|
+
export interface MappingRow {
|
|
41
|
+
readonly target: string;
|
|
42
|
+
readonly source: MappingSource;
|
|
43
|
+
}
|
|
44
|
+
/** A compile outcome: the jq program, or a human error to surface loudly. */
|
|
45
|
+
export type AdapterCompileResult = {
|
|
46
|
+
readonly ok: true;
|
|
47
|
+
readonly jq: string;
|
|
48
|
+
} | {
|
|
49
|
+
readonly ok: false;
|
|
50
|
+
readonly error: string;
|
|
51
|
+
};
|
|
52
|
+
/** An object key rendered for jq: a bare identifier, or a quoted string otherwise. */
|
|
53
|
+
export declare function jqKey(key: string): string;
|
|
54
|
+
/** A picked field rendered as a jq path, e.g. `.output.user.name` / `.input["odd key"]`. */
|
|
55
|
+
export declare function fieldPathToJq(root: FieldRoot, path: readonly string[]): string;
|
|
56
|
+
/** The jq fragment ONE row's value compiles to — the row's "show jq". */
|
|
57
|
+
export declare function rowValueJq(source: MappingSource): AdapterCompileResult;
|
|
58
|
+
/**
|
|
59
|
+
* Compile a mapping form into ONE adapter jq that constructs the update jq's
|
|
60
|
+
* declared input over `{ output, input }`. An empty form compiles to the
|
|
61
|
+
* empty object `{}`; a blank target, a duplicate target, or an invalid source is a
|
|
62
|
+
* loud error.
|
|
63
|
+
*/
|
|
64
|
+
export declare function compileAdapter(rows: readonly MappingRow[]): AdapterCompileResult;
|
|
65
|
+
/** One row per declared input key, each defaulting to a picked `output` field. */
|
|
66
|
+
export declare function defaultRowsForInput(params: readonly string[]): MappingRow[];
|
|
67
|
+
/** Recover a field source from a pure path expression, or `null` if it is not one. */
|
|
68
|
+
export declare function parseFieldPath(value: string): FieldSource | null;
|
|
69
|
+
/** Recover the mapping rows from a stored adapter jq, or `null` if it is not the generated shape. */
|
|
70
|
+
export declare function parseAdapter(jq: string): MappingRow[] | null;
|
|
71
|
+
/**
|
|
72
|
+
* Encode a template-name slug for a jq identifier: each `-` becomes `_`. Under the slug
|
|
73
|
+
* invariant (no consecutive or trailing hyphens) the result carries no `__` and no
|
|
74
|
+
* trailing `_`, which is what makes the first `__` in a call name the template boundary.
|
|
75
|
+
*/
|
|
76
|
+
export declare function encodeTemplateSegment(template: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* The single-expression form of a named template update built from a mapping form:
|
|
79
|
+
* `tjq_<enc(template)>__<name>({…})` for a qualified ref, `tjq_<name>({…})` for a bare
|
|
80
|
+
* one (see the module note on the `__` boundary invariant).
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateTemplateCall(ref: string, rows: readonly MappingRow[]): string;
|
|
83
|
+
/**
|
|
84
|
+
* Recover `{ callName, adapter }` from a `tjq_<callName>(<adapter>)` call, or `null`
|
|
85
|
+
* otherwise. `callName` is the RAW jq identifier — NEVER split here (a jq name may carry
|
|
86
|
+
* its own `__` past the template boundary); resolve it to a catalog ref with
|
|
87
|
+
* `resolveCallName`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseTemplateCall(expr: string): {
|
|
90
|
+
callName: string;
|
|
91
|
+
adapter: string;
|
|
92
|
+
} | null;
|
|
93
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/state-binding/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE3C,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,oDAAoD;AACpD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEnE,0FAA0F;AAC1F,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAC9B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;A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