@nodetool-ai/app-runtime 0.8.1
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 +104 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/actions.d.ts +85 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +65 -0
- package/dist/actions.js.map +1 -0
- package/dist/bindings.d.ts +109 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +257 -0
- package/dist/bindings.js.map +1 -0
- package/dist/bundle.d.ts +167 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +289 -0
- package/dist/bundle.js.map +1 -0
- package/dist/chat.d.ts +33 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +77 -0
- package/dist/chat.js.map +1 -0
- package/dist/conditions.d.ts +66 -0
- package/dist/conditions.d.ts.map +1 -0
- package/dist/conditions.js +221 -0
- package/dist/conditions.js.map +1 -0
- package/dist/doc-ops.d.ts +205 -0
- package/dist/doc-ops.d.ts.map +1 -0
- package/dist/doc-ops.js +304 -0
- package/dist/doc-ops.js.map +1 -0
- package/dist/document.d.ts +186 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +326 -0
- package/dist/document.js.map +1 -0
- package/dist/documents.d.ts +38 -0
- package/dist/documents.d.ts.map +1 -0
- package/dist/documents.js +108 -0
- package/dist/documents.js.map +1 -0
- package/dist/fold.d.ts +50 -0
- package/dist/fold.d.ts.map +1 -0
- package/dist/fold.js +175 -0
- package/dist/fold.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/input-validation.d.ts +4 -0
- package/dist/input-validation.d.ts.map +1 -0
- package/dist/input-validation.js +26 -0
- package/dist/input-validation.js.map +1 -0
- package/dist/mutable.d.ts +8 -0
- package/dist/mutable.d.ts.map +1 -0
- package/dist/mutable.js +2 -0
- package/dist/mutable.js.map +1 -0
- package/dist/operations.d.ts +51 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +95 -0
- package/dist/operations.js.map +1 -0
- package/dist/policy.d.ts +29 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +16 -0
- package/dist/policy.js.map +1 -0
- package/dist/predicates.d.ts +19 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +19 -0
- package/dist/predicates.js.map +1 -0
- package/dist/script-run.d.ts +86 -0
- package/dist/script-run.d.ts.map +1 -0
- package/dist/script-run.js +113 -0
- package/dist/script-run.js.map +1 -0
- package/dist/state.d.ts +176 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +357 -0
- package/dist/state.js.map +1 -0
- package/dist/widgets.d.ts +89 -0
- package/dist/widgets.d.ts.map +1 -0
- package/dist/widgets.js +667 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +55 -0
package/dist/doc-ops.js
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure operations on the non-UI half of an {@link ApplicationDocument}: its
|
|
3
|
+
* operation bindings, declared variables, and resource bindings.
|
|
4
|
+
*
|
|
5
|
+
* The UI half belongs to whatever renders it (Puck in the web editor); these
|
|
6
|
+
* three lists are edited beside it — by the agent's `ui_app_*` tools, by
|
|
7
|
+
* inspector panels, by the eval bridge — so they live here as immutable
|
|
8
|
+
* functions every consumer calls instead of reimplementing.
|
|
9
|
+
*/
|
|
10
|
+
import { encodeBinding } from "./bindings.js";
|
|
11
|
+
import { implicitOperation, mergeVariables } from "./operations.js";
|
|
12
|
+
import { operationTarget } from "./document.js";
|
|
13
|
+
export const EMPTY_DOC_META = {
|
|
14
|
+
operations: [],
|
|
15
|
+
resources: [],
|
|
16
|
+
variables: []
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Splitting on runs of non-alphanumerics drops the leading and trailing ones as
|
|
20
|
+
* empty fields, so no second pass is needed to trim them.
|
|
21
|
+
*
|
|
22
|
+
* The previous form substituted first and then trimmed with `/^_+|_+$/`, which
|
|
23
|
+
* CodeQL reports as polynomial on user input. That was a false positive — the
|
|
24
|
+
* substitution collapses every run to one character, so the trim never sees
|
|
25
|
+
* more than a single leading or trailing `_` — but this form is equivalent, one
|
|
26
|
+
* pass instead of two, and does not carry the shape that trips the scanner.
|
|
27
|
+
*/
|
|
28
|
+
const slug = (value) => value
|
|
29
|
+
.trim()
|
|
30
|
+
.toLowerCase()
|
|
31
|
+
.split(/[^a-z0-9]+/)
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join("_");
|
|
34
|
+
/** `base`, or `base_2`, `base_3`… until it is free. */
|
|
35
|
+
const uniqueId = (base, taken) => {
|
|
36
|
+
const root = slug(base) || "item";
|
|
37
|
+
if (!taken.has(root))
|
|
38
|
+
return root;
|
|
39
|
+
let n = 2;
|
|
40
|
+
while (taken.has(`${root}_${n}`))
|
|
41
|
+
n += 1;
|
|
42
|
+
return `${root}_${n}`;
|
|
43
|
+
};
|
|
44
|
+
/* ---------------------------------------------------------------- operations */
|
|
45
|
+
export const addOperation = (meta, input) => {
|
|
46
|
+
const taken = new Set(meta.operations.map((op) => op.id));
|
|
47
|
+
if (input.id && taken.has(input.id)) {
|
|
48
|
+
throw new Error(`An operation with id "${input.id}" already exists`);
|
|
49
|
+
}
|
|
50
|
+
const id = input.id ?? uniqueId(input.name ?? input.workflowId, taken);
|
|
51
|
+
const operation = {
|
|
52
|
+
id,
|
|
53
|
+
name: input.name ?? id,
|
|
54
|
+
workflowId: input.workflowId,
|
|
55
|
+
workflowVersion: input.workflowVersion,
|
|
56
|
+
inputs: input.inputs ?? {},
|
|
57
|
+
outputs: input.outputs ?? {},
|
|
58
|
+
policy: input.policy ?? "replace",
|
|
59
|
+
timeoutMs: input.timeoutMs
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
meta: { ...meta, operations: [...meta.operations, operation] },
|
|
63
|
+
operation
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/** What an operation runs, as one comparable key. Version changes are not a retarget. */
|
|
67
|
+
const targetKey = (binding) => {
|
|
68
|
+
const target = operationTarget(binding);
|
|
69
|
+
return target.kind === "script"
|
|
70
|
+
? `script:${target.scriptId}`
|
|
71
|
+
: `workflow:${target.workflowId}`;
|
|
72
|
+
};
|
|
73
|
+
export const updateOperation = (meta, id, patch) => {
|
|
74
|
+
const index = meta.operations.findIndex((op) => op.id === id);
|
|
75
|
+
if (index < 0)
|
|
76
|
+
return { meta, operation: null };
|
|
77
|
+
const current = meta.operations[index];
|
|
78
|
+
const retargeted = targetKey({ ...current, ...patch, id }) !== targetKey(current);
|
|
79
|
+
const operation = {
|
|
80
|
+
...current,
|
|
81
|
+
...patch,
|
|
82
|
+
id,
|
|
83
|
+
// Mappings merge per node id so an agent can set one input without
|
|
84
|
+
// restating the rest — unless the operation now runs something else, whose
|
|
85
|
+
// node ids and port names the old mappings mean nothing against.
|
|
86
|
+
inputs: retargeted
|
|
87
|
+
? patch.inputs ?? {}
|
|
88
|
+
: patch.inputs
|
|
89
|
+
? { ...current.inputs, ...patch.inputs }
|
|
90
|
+
: current.inputs,
|
|
91
|
+
outputs: retargeted
|
|
92
|
+
? patch.outputs ?? {}
|
|
93
|
+
: patch.outputs
|
|
94
|
+
? { ...current.outputs, ...patch.outputs }
|
|
95
|
+
: current.outputs
|
|
96
|
+
};
|
|
97
|
+
const operations = [...meta.operations];
|
|
98
|
+
operations[index] = operation;
|
|
99
|
+
return { meta: { ...meta, operations }, operation };
|
|
100
|
+
};
|
|
101
|
+
export const removeOperation = (meta, id) => {
|
|
102
|
+
const operations = meta.operations.filter((op) => op.id !== id);
|
|
103
|
+
if (operations.length === meta.operations.length) {
|
|
104
|
+
return { meta, removed: false };
|
|
105
|
+
}
|
|
106
|
+
return { meta: { ...meta, operations }, removed: true };
|
|
107
|
+
};
|
|
108
|
+
/* ----------------------------------------------------------------- variables */
|
|
109
|
+
/** Only user-scoped variables may persist — the same rule the parser enforces. */
|
|
110
|
+
const withPersistRule = (scope, persist) => scope === "user" && persist === true;
|
|
111
|
+
export const declareVariable = (meta, input) => {
|
|
112
|
+
const taken = new Set(meta.variables.map((v) => v.id));
|
|
113
|
+
if (input.id && taken.has(input.id)) {
|
|
114
|
+
throw new Error(`A variable with id "${input.id}" already exists`);
|
|
115
|
+
}
|
|
116
|
+
const id = input.id ?? uniqueId(input.name ?? "variable", taken);
|
|
117
|
+
const scope = input.scope ?? "instance";
|
|
118
|
+
const variable = {
|
|
119
|
+
id,
|
|
120
|
+
name: input.name ?? id,
|
|
121
|
+
type: input.type ?? null,
|
|
122
|
+
default: input.default,
|
|
123
|
+
scope,
|
|
124
|
+
persist: withPersistRule(scope, input.persist)
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
meta: { ...meta, variables: [...meta.variables, variable] },
|
|
128
|
+
variable
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export const updateVariable = (meta, id, patch) => {
|
|
132
|
+
const index = meta.variables.findIndex((v) => v.id === id);
|
|
133
|
+
if (index < 0)
|
|
134
|
+
return { meta, variable: null };
|
|
135
|
+
const current = meta.variables[index];
|
|
136
|
+
const scope = patch.scope ?? current.scope;
|
|
137
|
+
const variable = {
|
|
138
|
+
...current,
|
|
139
|
+
...patch,
|
|
140
|
+
id,
|
|
141
|
+
scope,
|
|
142
|
+
persist: withPersistRule(scope, patch.persist === undefined ? current.persist : patch.persist)
|
|
143
|
+
};
|
|
144
|
+
const variables = [...meta.variables];
|
|
145
|
+
variables[index] = variable;
|
|
146
|
+
return { meta: { ...meta, variables }, variable };
|
|
147
|
+
};
|
|
148
|
+
export const removeVariable = (meta, id) => {
|
|
149
|
+
const variables = meta.variables.filter((v) => v.id !== id);
|
|
150
|
+
if (variables.length === meta.variables.length) {
|
|
151
|
+
return { meta, removed: false };
|
|
152
|
+
}
|
|
153
|
+
return { meta: { ...meta, variables }, removed: true };
|
|
154
|
+
};
|
|
155
|
+
/* ----------------------------------------------------------------- resources */
|
|
156
|
+
export const addResource = (meta, input) => {
|
|
157
|
+
if (!input.scope.projectId && !input.scope.fixedId) {
|
|
158
|
+
throw new Error("A resource binding needs a scope: projectId for a collection, or fixedId for one pinned document");
|
|
159
|
+
}
|
|
160
|
+
const taken = new Set(meta.resources.map((r) => r.id));
|
|
161
|
+
if (input.id && taken.has(input.id)) {
|
|
162
|
+
throw new Error(`A resource binding with id "${input.id}" already exists`);
|
|
163
|
+
}
|
|
164
|
+
const id = input.id ?? uniqueId(input.name ?? input.kind, taken);
|
|
165
|
+
const resource = {
|
|
166
|
+
id,
|
|
167
|
+
name: input.name ?? id,
|
|
168
|
+
kind: input.kind,
|
|
169
|
+
scope: {
|
|
170
|
+
projectId: input.scope.projectId,
|
|
171
|
+
fixedId: input.scope.fixedId
|
|
172
|
+
},
|
|
173
|
+
operations: input.operations?.length ? input.operations : ["read"]
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
meta: { ...meta, resources: [...meta.resources, resource] },
|
|
177
|
+
resource
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
export const updateResource = (meta, id, patch) => {
|
|
181
|
+
const index = meta.resources.findIndex((r) => r.id === id);
|
|
182
|
+
if (index < 0)
|
|
183
|
+
return { meta, resource: null };
|
|
184
|
+
const resource = { ...meta.resources[index], ...patch, id };
|
|
185
|
+
const resources = [...meta.resources];
|
|
186
|
+
resources[index] = resource;
|
|
187
|
+
return { meta: { ...meta, resources }, resource };
|
|
188
|
+
};
|
|
189
|
+
export const removeResource = (meta, id) => {
|
|
190
|
+
const resources = meta.resources.filter((r) => r.id !== id);
|
|
191
|
+
if (resources.length === meta.resources.length) {
|
|
192
|
+
return { meta, removed: false };
|
|
193
|
+
}
|
|
194
|
+
return { meta: { ...meta, resources }, removed: true };
|
|
195
|
+
};
|
|
196
|
+
/* ----------------------------------------------------------- binding targets */
|
|
197
|
+
const EXECUTION_FIELDS = [
|
|
198
|
+
"running",
|
|
199
|
+
"progress",
|
|
200
|
+
"error",
|
|
201
|
+
"activity"
|
|
202
|
+
];
|
|
203
|
+
/**
|
|
204
|
+
* Every slot a widget can bind to, with both the display name and the ID-form
|
|
205
|
+
* token to store. A document with no declared operations reports the implicit
|
|
206
|
+
* one bound to the host workflow, which is what a legacy app runs.
|
|
207
|
+
*
|
|
208
|
+
* `scripts` carries the documents of the script operations the caller has
|
|
209
|
+
* loaded, keyed by script id. A script operation whose document is absent
|
|
210
|
+
* reports `ioAvailable: false`, exactly as an operation over an unloaded
|
|
211
|
+
* workflow does.
|
|
212
|
+
*
|
|
213
|
+
* `workflows` carries every other graph the caller has loaded, keyed by
|
|
214
|
+
* workflow id. An app binds more than one workflow, so resolving only the host
|
|
215
|
+
* left every other operation permanently empty — and a caller that worked
|
|
216
|
+
* around it by calling this once per workflow and merging the results was
|
|
217
|
+
* answering the same question twice, differently.
|
|
218
|
+
*/
|
|
219
|
+
export const bindingTargets = (meta, hostWorkflowId, workflow, scripts = new Map(), workflows = new Map()) => {
|
|
220
|
+
const operations = meta.operations.length > 0
|
|
221
|
+
? meta.operations
|
|
222
|
+
: [implicitOperation(hostWorkflowId)];
|
|
223
|
+
return {
|
|
224
|
+
operations: operations.map((op) => {
|
|
225
|
+
const target = operationTarget(op);
|
|
226
|
+
const script = target.kind === "script" ? scripts.get(target.scriptId) : undefined;
|
|
227
|
+
// A script's ports are its bindable surface — its names stand in for the
|
|
228
|
+
// node ids a graph would supply.
|
|
229
|
+
const bindable = script
|
|
230
|
+
? {
|
|
231
|
+
inputs: script.inputs.map((port) => ({
|
|
232
|
+
nodeId: port.name,
|
|
233
|
+
name: port.name,
|
|
234
|
+
label: port.name
|
|
235
|
+
})),
|
|
236
|
+
outputs: script.outputs.map((port) => ({
|
|
237
|
+
nodeId: port.name,
|
|
238
|
+
name: port.name,
|
|
239
|
+
label: port.name
|
|
240
|
+
})),
|
|
241
|
+
variables: []
|
|
242
|
+
}
|
|
243
|
+
: target.kind === "script"
|
|
244
|
+
? undefined
|
|
245
|
+
: op.workflowId === hostWorkflowId
|
|
246
|
+
? workflow
|
|
247
|
+
: workflows.get(op.workflowId);
|
|
248
|
+
const ioAvailable = bindable !== undefined;
|
|
249
|
+
const io = bindable ?? { inputs: [], outputs: [], variables: [] };
|
|
250
|
+
return {
|
|
251
|
+
operationId: op.id,
|
|
252
|
+
name: op.name,
|
|
253
|
+
workflowId: op.workflowId,
|
|
254
|
+
ioAvailable,
|
|
255
|
+
inputs: ioAvailable
|
|
256
|
+
? io.inputs.map((input) => ({
|
|
257
|
+
nodeId: input.nodeId,
|
|
258
|
+
name: input.name,
|
|
259
|
+
label: input.label,
|
|
260
|
+
binding: encodeBinding({
|
|
261
|
+
kind: "input",
|
|
262
|
+
operationId: op.id,
|
|
263
|
+
nodeId: input.nodeId
|
|
264
|
+
})
|
|
265
|
+
}))
|
|
266
|
+
: [],
|
|
267
|
+
outputs: ioAvailable
|
|
268
|
+
? io.outputs.map((output) => ({
|
|
269
|
+
nodeId: output.nodeId,
|
|
270
|
+
name: output.name,
|
|
271
|
+
label: output.label,
|
|
272
|
+
binding: encodeBinding({
|
|
273
|
+
kind: "output",
|
|
274
|
+
operationId: op.id,
|
|
275
|
+
nodeId: output.nodeId
|
|
276
|
+
})
|
|
277
|
+
}))
|
|
278
|
+
: [],
|
|
279
|
+
execution: EXECUTION_FIELDS.map((field) => ({
|
|
280
|
+
field,
|
|
281
|
+
binding: encodeBinding({
|
|
282
|
+
kind: "execution",
|
|
283
|
+
operationId: op.id,
|
|
284
|
+
field
|
|
285
|
+
})
|
|
286
|
+
}))
|
|
287
|
+
};
|
|
288
|
+
}),
|
|
289
|
+
variables: mergeVariables(meta.variables, workflow.variables).map((v) => ({
|
|
290
|
+
id: v.id,
|
|
291
|
+
name: v.name,
|
|
292
|
+
scope: v.scope,
|
|
293
|
+
persist: v.persist,
|
|
294
|
+
binding: encodeBinding({ kind: "variable", variableId: v.id })
|
|
295
|
+
})),
|
|
296
|
+
resources: meta.resources.map((r) => ({
|
|
297
|
+
id: r.id,
|
|
298
|
+
name: r.name,
|
|
299
|
+
kind: r.kind,
|
|
300
|
+
operations: r.operations
|
|
301
|
+
}))
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
//# sourceMappingURL=doc-ops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-ops.js","sourceRoot":"","sources":["../src/doc-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmBhD,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;CACd,CAAC;AAkCF;;;;;;;;;GASG;AACH,MAAM,IAAI,GAAG,CAAC,KAAa,EAAU,EAAE,CACrC,KAAK;KACF,IAAI,EAAE;KACN,WAAW,EAAE;KACb,KAAK,CAAC,YAAY,CAAC;KACnB,MAAM,CAAC,OAAO,CAAC;KACf,IAAI,CAAC,GAAG,CAAC,CAAC;AAEf,uDAAuD;AACvD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAA0B,EAAU,EAAE;IACpE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;IAClC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;QAAE,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,iFAAiF;A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ACxE,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,OAAO,EAAE,aAAa,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;SAC/D,CAAC,CAAC;QACH,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpC,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,UAAU,EAAE,CAAC,CAAC,UAAU;SACzB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The application document: a UI layout plus typed bindings to workflow
|
|
3
|
+
* operations, resources, and app state. Nothing here computes — every
|
|
4
|
+
* concept is configuration, and everything that branches, loops, or calls a
|
|
5
|
+
* provider lives in a workflow graph.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The Puck document. Kept structural rather than importing `@puckeditor/core`
|
|
9
|
+
* so this package stays dependency-free and usable from Node harnesses.
|
|
10
|
+
*/
|
|
11
|
+
export interface PuckData {
|
|
12
|
+
root: {
|
|
13
|
+
props?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
content: unknown[];
|
|
16
|
+
zones?: Record<string, unknown[]>;
|
|
17
|
+
}
|
|
18
|
+
/** Bumped whenever the parser needs a new branch. */
|
|
19
|
+
export declare const APP_SCHEMA_VERSION: 4;
|
|
20
|
+
/** Where an operation input takes its value from. */
|
|
21
|
+
export type InputMapping = {
|
|
22
|
+
from: "widget";
|
|
23
|
+
} | {
|
|
24
|
+
from: "variable";
|
|
25
|
+
variableId: string;
|
|
26
|
+
} | {
|
|
27
|
+
from: "constant";
|
|
28
|
+
value: unknown;
|
|
29
|
+
} | {
|
|
30
|
+
from: "resource";
|
|
31
|
+
resourceBindingId: string;
|
|
32
|
+
};
|
|
33
|
+
/** Where an operation output lands. */
|
|
34
|
+
export type OutputMapping = {
|
|
35
|
+
to: "display";
|
|
36
|
+
} | {
|
|
37
|
+
to: "variable";
|
|
38
|
+
variableId: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* How concurrent invocations of one operation behave: run side by side,
|
|
42
|
+
* cancel the previous one, or queue behind it.
|
|
43
|
+
*/
|
|
44
|
+
export type OperationPolicy = "parallel" | "replace" | "queue";
|
|
45
|
+
/**
|
|
46
|
+
* What an operation runs. A workflow target's id lives in the binding's own
|
|
47
|
+
* `workflowId` (v3's storage, still the storage); a script target is stored
|
|
48
|
+
* under `target`, which pins the script version the way a Code node link does.
|
|
49
|
+
*/
|
|
50
|
+
export type OperationTarget = {
|
|
51
|
+
kind: "workflow";
|
|
52
|
+
workflowId: string;
|
|
53
|
+
workflowVersion?: number;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "script";
|
|
56
|
+
scriptId: string;
|
|
57
|
+
scriptVersion: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A named, typed reference to a workflow or a JS script. The same workflow may
|
|
61
|
+
* be bound twice with different mappings (`translateTitle`, `translateBody`).
|
|
62
|
+
*
|
|
63
|
+
* `inputs`/`outputs` key on node **IDs**, never names: the runtime derives the
|
|
64
|
+
* name-keyed `params` object the run protocol wants at the execution boundary,
|
|
65
|
+
* so renaming a node in the graph editor never breaks an app. A script
|
|
66
|
+
* operation has no nodes, so its ports key on their declared names, which are
|
|
67
|
+
* the script's stable identifiers.
|
|
68
|
+
*/
|
|
69
|
+
export interface OperationBinding {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
/**
|
|
73
|
+
* The workflow this operation runs, `""` for a script operation. Kept for
|
|
74
|
+
* one schema version so v3 readers still work; new code reads
|
|
75
|
+
* {@link operationTarget}, which is the only place the two kinds are told
|
|
76
|
+
* apart.
|
|
77
|
+
*/
|
|
78
|
+
workflowId: string;
|
|
79
|
+
/** Pinned in a release, floating (latest) in a draft. */
|
|
80
|
+
workflowVersion?: number;
|
|
81
|
+
/** Present only for a script target; a workflow target lives in `workflowId`. */
|
|
82
|
+
target?: OperationTarget;
|
|
83
|
+
inputs: Record<string, InputMapping>;
|
|
84
|
+
outputs: Record<string, OutputMapping>;
|
|
85
|
+
policy: OperationPolicy;
|
|
86
|
+
timeoutMs?: number;
|
|
87
|
+
}
|
|
88
|
+
/** What a binding runs, normalized — the one place the union is derived. */
|
|
89
|
+
export declare const operationTarget: (binding: Pick<OperationBinding, "workflowId" | "workflowVersion" | "target">) => OperationTarget;
|
|
90
|
+
/** True when the operation runs a JS script rather than a workflow. */
|
|
91
|
+
export declare const isScriptOperation: (binding: Pick<OperationBinding, "workflowId" | "workflowVersion" | "target">) => boolean;
|
|
92
|
+
export type ResourceKind = "asset" | "timeline" | "storyboard" | "sketch";
|
|
93
|
+
/** The common envelope every resource provider speaks. */
|
|
94
|
+
export interface ResourceRef {
|
|
95
|
+
kind: ResourceKind;
|
|
96
|
+
id: string;
|
|
97
|
+
revision?: number;
|
|
98
|
+
}
|
|
99
|
+
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
100
|
+
export interface ResourceBinding {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
kind: ResourceKind;
|
|
104
|
+
/** A collection (`projectId`) or one pinned document (`fixedId`). */
|
|
105
|
+
scope: {
|
|
106
|
+
projectId?: string;
|
|
107
|
+
fixedId?: string;
|
|
108
|
+
};
|
|
109
|
+
operations: ResourceOperation[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A declared app state slot. Written by widgets and by operation outputs
|
|
113
|
+
* mapped `to: "variable"`; read by widgets and by inputs mapped
|
|
114
|
+
* `from: "variable"`.
|
|
115
|
+
*/
|
|
116
|
+
export interface VariableDeclaration {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
/** Node-SDK type metadata; structural here to stay dependency-free. */
|
|
120
|
+
type?: {
|
|
121
|
+
type: string;
|
|
122
|
+
optional?: boolean;
|
|
123
|
+
} | null;
|
|
124
|
+
default?: unknown;
|
|
125
|
+
/** "instance" = this open app; "user" = persisted per user. */
|
|
126
|
+
scope: "instance" | "user";
|
|
127
|
+
/** Only user-scoped variables may persist. */
|
|
128
|
+
persist: boolean;
|
|
129
|
+
}
|
|
130
|
+
export interface ThemeRef {
|
|
131
|
+
id: string;
|
|
132
|
+
}
|
|
133
|
+
export interface ApplicationDocument {
|
|
134
|
+
schemaVersion: number;
|
|
135
|
+
ui: PuckData;
|
|
136
|
+
operations: OperationBinding[];
|
|
137
|
+
resources: ResourceBinding[];
|
|
138
|
+
variables: VariableDeclaration[];
|
|
139
|
+
theme?: ThemeRef;
|
|
140
|
+
}
|
|
141
|
+
export declare const createEmptyPuckData: (title?: string) => PuckData;
|
|
142
|
+
export declare const createEmptyDocument: (title?: string) => ApplicationDocument;
|
|
143
|
+
/** The default operation id a migrated single-workflow app gets. */
|
|
144
|
+
export declare const DEFAULT_OPERATION_ID = "main";
|
|
145
|
+
/**
|
|
146
|
+
* Parse an unknown value into an {@link ApplicationDocument}, or null.
|
|
147
|
+
*
|
|
148
|
+
* Version branching is real: a v1/v2 `{ version, data }` document (the legacy
|
|
149
|
+
* `workflow.app_doc` shape) is lifted into a v3 document with one operation
|
|
150
|
+
* bound to the host workflow. Widget bindings inside `ui` are left as stored —
|
|
151
|
+
* they are resolved to node IDs against the live graph by `resolveBinding`,
|
|
152
|
+
* which is where a missing name becomes a validation error rather than a
|
|
153
|
+
* silent no-op.
|
|
154
|
+
*
|
|
155
|
+
* Everything outside `ui` is parsed, never cast. Malformed operations,
|
|
156
|
+
* variables, and resources are dropped; so is any single input/output mapping
|
|
157
|
+
* that does not match its union, which leaves that node on the documented
|
|
158
|
+
* default (an input reads its widget, an output displays). So a parsed
|
|
159
|
+
* document's mappings always carry the ids their variant requires — the
|
|
160
|
+
* runtimes can read `variableId` and `resourceBindingId` directly.
|
|
161
|
+
*/
|
|
162
|
+
export declare const parseApplicationDocument: (value: unknown, options?: {
|
|
163
|
+
hostWorkflowId?: string;
|
|
164
|
+
}) => ApplicationDocument | null;
|
|
165
|
+
/**
|
|
166
|
+
* A workflow row carrying a legacy `app_doc`. Structural so callers in the
|
|
167
|
+
* server, the migration, and the CLI can pass their own workflow types.
|
|
168
|
+
*/
|
|
169
|
+
export interface LegacyAppDocHost {
|
|
170
|
+
id: string;
|
|
171
|
+
app_doc?: unknown;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Lift a legacy `workflow.app_doc` into a standalone {@link ApplicationDocument}
|
|
175
|
+
* ready to insert as an application row. Returns null when the workflow carries
|
|
176
|
+
* no document or the stored value cannot be parsed.
|
|
177
|
+
*
|
|
178
|
+
* `app_doc` is stored as JSON text in some databases and as an object in
|
|
179
|
+
* others, so both are accepted. The workflow's id becomes the host id: v1/v2
|
|
180
|
+
* documents get a single operation bound to it, and v3 operations that ship
|
|
181
|
+
* without a workflow (templates, which have no id until installed) bind to it.
|
|
182
|
+
*/
|
|
183
|
+
export declare const liftLegacyAppDoc: (workflow: LegacyAppDocHost | null | undefined) => ApplicationDocument | null;
|
|
184
|
+
/** True when the document has at least one placed component. */
|
|
185
|
+
export declare const isRenderableUi: (ui: PuckData | null | undefined) => ui is PuckData;
|
|
186
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC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