@vspark/plugin-sdk 0.1.1 → 0.2.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 +36 -2
- package/index.d.ts +275 -62
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @vspark/plugin-sdk
|
|
2
2
|
|
|
3
3
|
TypeScript typings of the [vspark](https://github.com/fennsorenn/vspark) plugin
|
|
4
|
-
API (`apiVersion`
|
|
4
|
+
API (`apiVersion` 2). **Types only:** vspark injects the SDK into each entry
|
|
5
5
|
module's default-exported factory at runtime, so plugin code imports nothing
|
|
6
6
|
but types from here:
|
|
7
7
|
|
|
@@ -17,4 +17,38 @@ export default plugin;
|
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Start a plugin from the `vspark_plugin_template` repository. The package
|
|
20
|
-
|
|
20
|
+
version is `0.<apiVersion>.x` (0.1.x: API 1, 0.2.x: API 2): a plugin built
|
|
21
|
+
against one API version needs the matching range, e.g. `^0.2.0`.
|
|
22
|
+
|
|
23
|
+
API 2 replaced Action kinds and response types with **trigger types**, **step
|
|
24
|
+
types** and **action presets** (`triggerTypes`, `stepTypes`, `actionPresets`
|
|
25
|
+
in the shared module's output), plus `legacyConverters` that turn actions
|
|
26
|
+
stored with a plugin's API 1 kinds into the new form.
|
|
27
|
+
|
|
28
|
+
A trigger type declares the **fields** it provides (`fields: [{ name, type }]`,
|
|
29
|
+
`type` one of `text`, `number`, `record`). They are the placeholders users
|
|
30
|
+
write step inputs with. A step type declares **inputs** (`text` or `number`).
|
|
31
|
+
The user fills each one in as a template (`${message}`, `Song: ${payload.song}`,
|
|
32
|
+
plain text) or, for a number, as an expression (`${message} - 1`). The step's
|
|
33
|
+
`build` gets each input already rendered in `ctx.inputs`.
|
|
34
|
+
|
|
35
|
+
Trigger types, step types and presets may set a **category** (0.2.1). The
|
|
36
|
+
action drawer has a tab for each category, and the action list can be grouped
|
|
37
|
+
by category. Use one of vspark's ids (`chat`, `stream`, `input`, `automation`,
|
|
38
|
+
`animation`, `avatar`, `media`, `scene`) to join that category, or your own id
|
|
39
|
+
for a category of your plugin, labelled by the `categories.<id>` key in your
|
|
40
|
+
locales. Without a category, a type goes into one category named after the
|
|
41
|
+
plugin.
|
|
42
|
+
|
|
43
|
+
A composite (overlay) setting with `control: 'template'` (0.2.1) lets the user
|
|
44
|
+
pick one of several looks or edit the code. Its `presets` list
|
|
45
|
+
`{ id, template, css }`, `links` name the template field, then the CSS field
|
|
46
|
+
(`config.template`, `config.css` on a feed layer). The select shows the preset
|
|
47
|
+
whose code matches (CSS custom-property values are ignored, so the other look
|
|
48
|
+
settings don't turn it into "Custom"), and switching presets keeps those
|
|
49
|
+
values. Label each preset with `option.<key>.<id>` in your locales.
|
|
50
|
+
|
|
51
|
+
A composite type's `demo(live)` (0.2.1) returns sample feed fields; the
|
|
52
|
+
settings then get a "Demo data" switch that shows them in the editor preview
|
|
53
|
+
(never in the stream output), laid over the live fields — return only the
|
|
54
|
+
fields events would bring, and keep the user's own ones from `live`.
|
package/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vspark/plugin-sdk — typings of the vspark plugin API (apiVersion
|
|
2
|
+
* @vspark/plugin-sdk — typings of the vspark plugin API (apiVersion 2).
|
|
3
3
|
*
|
|
4
4
|
* vspark INJECTS the SDK into each entry module's default-exported factory;
|
|
5
5
|
* nothing in this package runs. Plugin code must only `import type` from it
|
|
6
6
|
* (bundling vspark's modules would register nodes in a copy the engine never
|
|
7
7
|
* sees). Kept in step with the host by hand: packages/backend/src/plugins/
|
|
8
8
|
* (loader.ts BACKEND_SDK, context.ts, accounts/api.ts) and
|
|
9
|
-
* @vspark/shared/actions (PLUGIN_ACTIONS_SDK, FormField,
|
|
9
|
+
* @vspark/shared/actions (PLUGIN_ACTIONS_SDK, FormField, actionModel.ts).
|
|
10
10
|
* See vspark dev-notes/modules/plugins.md.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export type ApiVersion =
|
|
13
|
+
export type ApiVersion = 2;
|
|
14
14
|
|
|
15
15
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
16
|
// Signal graph
|
|
@@ -70,7 +70,10 @@ export interface SignalNodeClass {
|
|
|
70
70
|
new (): SignalNodeBase;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
type FieldDecorator = (
|
|
73
|
+
type FieldDecorator = (
|
|
74
|
+
value: undefined,
|
|
75
|
+
ctx: ClassFieldDecoratorContext
|
|
76
|
+
) => void;
|
|
74
77
|
type MethodDecorator = (
|
|
75
78
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
79
|
value: (...args: any[]) => any,
|
|
@@ -149,7 +152,8 @@ export interface FormField {
|
|
|
149
152
|
* when there is no translation). `account`: provider id
|
|
150
153
|
* (`'overlive'` or `'<pluginId>:<provider>'`). */
|
|
151
154
|
provider?: string;
|
|
152
|
-
/** Placeholders
|
|
155
|
+
/** Placeholders a text field accepts (filled by your node): shown as
|
|
156
|
+
* buttons under it; any other `${…}` it uses is flagged in the editor. */
|
|
153
157
|
placeholders?: readonly string[];
|
|
154
158
|
when?: (read: (path: string) => unknown) => boolean;
|
|
155
159
|
}
|
|
@@ -160,72 +164,227 @@ export interface FormField {
|
|
|
160
164
|
|
|
161
165
|
export type ActionSettings = Record<string, unknown>;
|
|
162
166
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Plugin API 2: every action is a trigger → steps. A plugin contributes
|
|
169
|
+
* trigger types (what starts an action), step types (what it does) and
|
|
170
|
+
* presets (ready-made trigger + steps). vspark assembles the graph: trigger →
|
|
171
|
+
* rank gate → cooldown → per-viewer cooldown → counter → steps; the options
|
|
172
|
+
* (rank, cooldowns, counter) are the host's, not the plugin's.
|
|
173
|
+
*
|
|
174
|
+
* Labels: `triggers.<type>.label` / `.description`, `steps.<type>.label` /
|
|
175
|
+
* `.description`, `presets.<id>.label` / `.description` in the plugin's
|
|
176
|
+
* namespace. Ids must start with `<pluginId>_`.
|
|
177
|
+
*/
|
|
168
178
|
export type PreviewToken =
|
|
169
179
|
| { t: 'text'; text: string }
|
|
170
180
|
| { t: 'msg'; key: string; params?: Record<string, string | number> };
|
|
171
181
|
|
|
172
|
-
export
|
|
173
|
-
|
|
174
|
-
|
|
182
|
+
export type Out = [nodeId: string, port: string];
|
|
183
|
+
|
|
184
|
+
/** What a trigger field holds. */
|
|
185
|
+
export type TriggerFieldType = 'text' | 'number' | 'record';
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* A named field a trigger provides: a placeholder steps use as `${name}`
|
|
189
|
+
* (a record's keys as `${name.key}`). Every action also has `${count}` (its
|
|
190
|
+
* counter). Built-in triggers use `user` (display name), `username` (login
|
|
191
|
+
* name — also enables the per-viewer cooldown), `message`, `args`, `reward`,
|
|
192
|
+
* `combo`, `groups` (a pattern's named groups) and `payload` (a record).
|
|
193
|
+
*/
|
|
194
|
+
export interface TriggerField {
|
|
195
|
+
name: string;
|
|
196
|
+
type: TriggerFieldType;
|
|
175
197
|
}
|
|
176
198
|
|
|
177
|
-
export interface
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
icon: string;
|
|
182
|
-
fields: readonly ActionSettingField[];
|
|
183
|
-
/** The generated form (host `SchemaForm`). Omit when `ui.mjs` provides one. */
|
|
184
|
-
form?: readonly FormField[];
|
|
185
|
-
defaults(): ActionSettings;
|
|
186
|
-
normalize(raw: unknown): ActionSettings;
|
|
187
|
-
build(shape: ActionSettings): TemplateGraph;
|
|
188
|
-
preview(settings: ActionSettings): ActionPreview;
|
|
199
|
+
export interface RankOuts {
|
|
200
|
+
isSub: Out;
|
|
201
|
+
isMod: Out;
|
|
202
|
+
isBroadcaster: Out;
|
|
189
203
|
}
|
|
190
204
|
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
/** What a step input produces: text (a template) or a number (an expression). */
|
|
206
|
+
export type StepInputType = 'text' | 'number';
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* An input of a step. The user writes it as a template over the trigger's
|
|
210
|
+
* placeholders (`${message}`, `Song: ${payload.song}`, plain text) — or, for
|
|
211
|
+
* a number, as an expression (`${message} - 1`). The editor flags
|
|
212
|
+
* placeholders the action's trigger does not provide.
|
|
213
|
+
*/
|
|
214
|
+
export interface StepInput {
|
|
215
|
+
/** Key in `ctx.inputs` and in the step's `inputs.<name>` setting. */
|
|
216
|
+
name: string;
|
|
217
|
+
type: StepInputType;
|
|
218
|
+
/** Shows "needs input" when it is empty or uses a placeholder the trigger lacks. */
|
|
219
|
+
required?: boolean;
|
|
220
|
+
/** i18n key (plugin namespace). */
|
|
203
221
|
label: string;
|
|
222
|
+
/** The template a new step starts with, e.g. `${message}`. */
|
|
223
|
+
default?: string;
|
|
204
224
|
}
|
|
205
225
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
226
|
+
/**
|
|
227
|
+
* The builder a trigger or step part gets. Node ids are local to the part
|
|
228
|
+
* (vspark prefixes them); settings fields are relative to the part's own
|
|
229
|
+
* settings. Outputs handed in from elsewhere (trigger fields, the fire
|
|
230
|
+
* signal, inputs) are absolute and start with `@` — `wire` accepts both.
|
|
231
|
+
*/
|
|
209
232
|
export interface TemplateBuilder {
|
|
210
|
-
node(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
233
|
+
node(
|
|
234
|
+
id: string,
|
|
235
|
+
kind: string,
|
|
236
|
+
x: number,
|
|
237
|
+
y: number,
|
|
238
|
+
defaultConfig?: Record<string, unknown>
|
|
239
|
+
): string;
|
|
240
|
+
wire(
|
|
241
|
+
fromNodeId: string,
|
|
242
|
+
fromPort: string,
|
|
243
|
+
toNodeId: string,
|
|
244
|
+
toPort: string
|
|
245
|
+
): void;
|
|
246
|
+
/** Feed a settings field of this part into `to.toPort` (a `settings` node). */
|
|
247
|
+
setting(
|
|
248
|
+
field: string,
|
|
249
|
+
to: string,
|
|
250
|
+
toPort: string,
|
|
251
|
+
x: number,
|
|
252
|
+
y: number
|
|
253
|
+
): void;
|
|
254
|
+
/** A settings field of this part as an output. */
|
|
255
|
+
value(field: string, x: number, y: number): Out;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
interface PartDef {
|
|
259
|
+
type: string;
|
|
260
|
+
/** English fallback label. */
|
|
261
|
+
label: string;
|
|
262
|
+
icon: string;
|
|
263
|
+
/** Settings paths (relative, dotted) that change the graph structure; every
|
|
264
|
+
* other field is a value read live by the graph. */
|
|
265
|
+
shapeFields?: readonly string[];
|
|
266
|
+
defaults(): ActionSettings;
|
|
267
|
+
normalize(raw: unknown): ActionSettings;
|
|
268
|
+
/** Tokens for the action list row. `msg` keys are in the plugin namespace. */
|
|
269
|
+
preview(settings: ActionSettings): PreviewToken[];
|
|
270
|
+
/** The generated form (host `SchemaForm`). */
|
|
271
|
+
form?: readonly FormField[];
|
|
272
|
+
/** Where the drawer and the action list file it. One of vspark's
|
|
273
|
+
* categories (`chat`, `stream`, `input`, `automation`, `animation`,
|
|
274
|
+
* `avatar`, `media`, `scene`) joins that one; any other id is the
|
|
275
|
+
* plugin's own, labelled by its `categories.<id>` key. Default: one
|
|
276
|
+
* category named after the plugin. */
|
|
277
|
+
category?: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface TriggerParts {
|
|
281
|
+
/** Fires when the trigger matched (several outputs = any of them). */
|
|
282
|
+
fire: Out | Out[];
|
|
283
|
+
/** The output of each declared field, by name. */
|
|
284
|
+
fields: Record<string, Out>;
|
|
285
|
+
/** The chatter's rank, when the trigger declares `rank: true`. */
|
|
286
|
+
rank?: RankOuts;
|
|
287
|
+
/** Work done once the action runs (after the option gates). */
|
|
288
|
+
afterRun?(b: TemplateBuilder, fired: Out[]): void;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface TriggerTypeDef extends PartDef {
|
|
292
|
+
/** The placeholders `build` returns outputs for in `fields`. */
|
|
293
|
+
fields: readonly TriggerField[];
|
|
294
|
+
/** `build` returns the chatter's `rank`: enables the minimum-rank option. */
|
|
295
|
+
rank?: boolean;
|
|
296
|
+
/** The keys a record field is known to hold with these settings (the
|
|
297
|
+
* editor checks `${record.key}` against them); without an entry any key
|
|
298
|
+
* may be present. */
|
|
299
|
+
recordKeys?(settings: ActionSettings): Record<string, readonly string[]>;
|
|
300
|
+
/** Cooldown (seconds) a new action with this trigger starts with. */
|
|
301
|
+
defaultCooldown?: number;
|
|
302
|
+
/** Gets the shape projection of the trigger's settings. */
|
|
303
|
+
build(b: TemplateBuilder, shape: ActionSettings): TriggerParts;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface StepContext {
|
|
307
|
+
/** Fire signals (absolute): wire each into the step's entry. */
|
|
308
|
+
fire: Out[];
|
|
309
|
+
/** Each declared input, rendered from its template (text) or evaluated
|
|
310
|
+
* (number: no value when the result is not a number). */
|
|
311
|
+
inputs: Record<string, Out>;
|
|
312
|
+
/** The trigger's field outputs, by name (the ones it provides). */
|
|
313
|
+
fields: Record<string, Out>;
|
|
314
|
+
/** The action counter's value after this run's increment. */
|
|
315
|
+
counter: Out;
|
|
316
|
+
/**
|
|
317
|
+
* A formatter over every placeholder, its template read live from the
|
|
318
|
+
* step's setting `field`: `text` renders a template, `number` evaluates an
|
|
319
|
+
* expression, `record` renders rows of `{ key, value }` templates.
|
|
320
|
+
*/
|
|
321
|
+
format(
|
|
322
|
+
field: string,
|
|
323
|
+
as: 'text' | 'number' | 'record',
|
|
324
|
+
x: number,
|
|
325
|
+
y: number
|
|
326
|
+
): Out;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface StepTypeDef extends PartDef {
|
|
330
|
+
inputs?: readonly StepInput[];
|
|
331
|
+
/** The trigger a new action started from this step gets. */
|
|
332
|
+
defaultTrigger?: string;
|
|
333
|
+
/** Gets the shape projection of the step's settings. */
|
|
334
|
+
build(b: TemplateBuilder, shape: ActionSettings, ctx: StepContext): void;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export type StepMode = 'all' | 'cycle';
|
|
338
|
+
|
|
339
|
+
export interface ActionPresetDef {
|
|
340
|
+
id: string;
|
|
341
|
+
/** i18n key (plugin namespace), e.g. `presets.<id>.label`. */
|
|
342
|
+
label: string;
|
|
343
|
+
icon: string;
|
|
344
|
+
/** `{ type, ...settings }` or null (the user picks a trigger). */
|
|
345
|
+
trigger: ActionSettings | null;
|
|
346
|
+
/** `[{ type, ...settings }]`. */
|
|
347
|
+
steps: ActionSettings[];
|
|
348
|
+
stepMode?: StepMode;
|
|
349
|
+
/** `{ minRank?, cooldown?: { seconds, group }, userCooldown?: { seconds }, counter? }`. */
|
|
350
|
+
options?: ActionSettings;
|
|
351
|
+
/** As a trigger's / step's; default: its first step's category. */
|
|
352
|
+
category?: string;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** Turns a stored action of a former (API 1) kind into trigger → steps
|
|
356
|
+
* settings (`{ trigger, steps: [...], stepMode?, options? }`). Return `null`
|
|
357
|
+
* to delete the action. Runs once when vspark starts. */
|
|
358
|
+
export type LegacyConverter = (
|
|
359
|
+
settings: ActionSettings
|
|
360
|
+
) => ActionSettings | null;
|
|
216
361
|
|
|
217
362
|
export interface CooldownSettings {
|
|
218
363
|
seconds: number;
|
|
219
364
|
group: string;
|
|
220
365
|
}
|
|
221
366
|
|
|
367
|
+
export interface SinkStepDef {
|
|
368
|
+
nodeKind: string;
|
|
369
|
+
/** Event input fired by the action (default `fire`). */
|
|
370
|
+
entryPort?: string;
|
|
371
|
+
/** Value inputs of the sink, each fed from the step setting of the same name. */
|
|
372
|
+
fields?: readonly string[];
|
|
373
|
+
/** Template inputs, each fed into the sink's port of the same name. */
|
|
374
|
+
inputs?: readonly StepInput[];
|
|
375
|
+
form?: readonly FormField[];
|
|
376
|
+
icon?: string;
|
|
377
|
+
/** As a step's (see `StepTypeDef.category`). */
|
|
378
|
+
category?: string;
|
|
379
|
+
defaults?: () => ActionSettings;
|
|
380
|
+
preview?: (settings: ActionSettings) => PreviewToken[];
|
|
381
|
+
defaultTrigger?: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
222
384
|
export interface ActionsSdk {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
/** `cooldown` fed by `cooldown.seconds` / `cooldown.group`. */
|
|
227
|
-
addCooldown(b: TemplateBuilder, entries: Out[], x: number): Out;
|
|
228
|
-
/** Builds `!name` aliases → anchored regex (the Chat command kind's matcher). */
|
|
385
|
+
/** A step that fires one node (the common case). */
|
|
386
|
+
sinkStep(type: string, def: SinkStepDef): StepTypeDef;
|
|
387
|
+
/** `!name` aliases → names (the Chat command trigger's matcher). */
|
|
229
388
|
commandNames(command: unknown, aliases: unknown): string[];
|
|
230
389
|
commandPattern(names: string[]): string;
|
|
231
390
|
escapeRegExp(text: string): string;
|
|
@@ -256,7 +415,23 @@ export interface SettingLink {
|
|
|
256
415
|
|
|
257
416
|
export interface CompositeSetting {
|
|
258
417
|
key: string;
|
|
259
|
-
control:
|
|
418
|
+
control:
|
|
419
|
+
| 'text'
|
|
420
|
+
| 'number'
|
|
421
|
+
| 'slider'
|
|
422
|
+
| 'select'
|
|
423
|
+
| 'color'
|
|
424
|
+
| 'asset'
|
|
425
|
+
| 'account'
|
|
426
|
+
| 'toggle'
|
|
427
|
+
| 'duration'
|
|
428
|
+
/** A feed's look as code (host >= SDK 0.2.1): a select of `presets`
|
|
429
|
+
* plus Custom, and a template / CSS editor. `links[0]` is the template
|
|
430
|
+
* field (`config.template`), `links[1]` the CSS (`config.css`). The
|
|
431
|
+
* select shows the preset whose code matches, CSS custom-property values
|
|
432
|
+
* ignored; switching keeps those values. Preset labels:
|
|
433
|
+
* `option.<key>.<presetId>`. */
|
|
434
|
+
| 'template';
|
|
260
435
|
group: string;
|
|
261
436
|
options?: string[];
|
|
262
437
|
min?: number;
|
|
@@ -266,6 +441,16 @@ export interface CompositeSetting {
|
|
|
266
441
|
links?: SettingLink[];
|
|
267
442
|
provider?: string;
|
|
268
443
|
when?: (read: (key: string) => unknown) => boolean;
|
|
444
|
+
/** `template`: the looks to choose from. Each one's CSS should declare
|
|
445
|
+
* the custom properties the type's other settings link. */
|
|
446
|
+
presets?: TemplatePreset[];
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** One look of a `template` setting. */
|
|
450
|
+
export interface TemplatePreset {
|
|
451
|
+
id: string;
|
|
452
|
+
template: string;
|
|
453
|
+
css: string;
|
|
269
454
|
}
|
|
270
455
|
|
|
271
456
|
/** Labels live in the plugin's namespace under the host's composite keys:
|
|
@@ -276,6 +461,12 @@ export interface CompositeTypeDef {
|
|
|
276
461
|
rootRtype: 'compose_layer' | 'scene_node';
|
|
277
462
|
parts: Record<string, PartRtype>;
|
|
278
463
|
settings: CompositeSetting[];
|
|
464
|
+
/** Sample data (0.2.1): with it, the settings get a "Demo data" switch that
|
|
465
|
+
* fills the editor preview with these feed fields, laid over the live ones
|
|
466
|
+
* (`live`), so users can set the overlay up without real events. The
|
|
467
|
+
* viewer / stream output never shows it. Called when switched on (and when
|
|
468
|
+
* the live fields change). */
|
|
469
|
+
demo?: (live: Record<string, unknown>) => Record<string, unknown>;
|
|
279
470
|
}
|
|
280
471
|
|
|
281
472
|
/** A placeable composite: one feed layer (plus optional logic). */
|
|
@@ -306,8 +497,11 @@ export interface SharedSdk {
|
|
|
306
497
|
}
|
|
307
498
|
|
|
308
499
|
export interface SharedPlugin {
|
|
309
|
-
|
|
310
|
-
|
|
500
|
+
triggerTypes?: TriggerTypeDef[];
|
|
501
|
+
stepTypes?: StepTypeDef[];
|
|
502
|
+
actionPresets?: ActionPresetDef[];
|
|
503
|
+
/** Former (API 1) action kind → converter. */
|
|
504
|
+
legacyConverters?: Record<string, LegacyConverter>;
|
|
311
505
|
compositeTypes?: CompositeTypeDef[];
|
|
312
506
|
compositePresets?: FeedCompositePreset[];
|
|
313
507
|
}
|
|
@@ -359,12 +553,20 @@ export interface AccountProviderDef<Identity = Record<string, unknown>> {
|
|
|
359
553
|
/** `secret: true` (e.g. `clientSecret`): kept server-side only and sent to
|
|
360
554
|
* the token endpoint as `client_secret`; the editor shows only whether it
|
|
361
555
|
* is set. */
|
|
362
|
-
appFields: readonly {
|
|
556
|
+
appFields: readonly {
|
|
557
|
+
path: string;
|
|
558
|
+
control: 'text';
|
|
559
|
+
label: string;
|
|
560
|
+
hint?: string;
|
|
561
|
+
secret?: boolean;
|
|
562
|
+
}[];
|
|
363
563
|
/** Extra authorize params. */
|
|
364
564
|
extraParams?: Record<string, string>;
|
|
365
565
|
};
|
|
366
566
|
/** Called after a token exchange; returns the identity shown in the list. */
|
|
367
|
-
fetchIdentity(
|
|
567
|
+
fetchIdentity(
|
|
568
|
+
tokens: OAuthTokens
|
|
569
|
+
): Promise<{ label: string; identity: Identity & Record<string, unknown> }>;
|
|
368
570
|
/** i18n key of a setup walkthrough shown in the add dialog (markdown). */
|
|
369
571
|
setupHelp?: string;
|
|
370
572
|
}
|
|
@@ -377,7 +579,10 @@ export interface AccountsApi {
|
|
|
377
579
|
defaultFor(projectId: string, provider: string): AccountRow | undefined;
|
|
378
580
|
/** Runs `fn` with a valid access token, refreshing (and persisting) when expired.
|
|
379
581
|
* On a revoked refresh token the account goes to `needs_reauth` and this rejects. */
|
|
380
|
-
withToken<T>(
|
|
582
|
+
withToken<T>(
|
|
583
|
+
accountId: string,
|
|
584
|
+
fn: (accessToken: string) => Promise<T>
|
|
585
|
+
): Promise<T>;
|
|
381
586
|
/** Forces a refresh on the next `withToken` (e.g. after a 401). */
|
|
382
587
|
invalidate(accountId: string): void;
|
|
383
588
|
setStatus(accountId: string, status: AccountStatus, message?: string): void;
|
|
@@ -388,7 +593,13 @@ export interface AccountsApi {
|
|
|
388
593
|
export interface LogicApi {
|
|
389
594
|
/** Fire `payload` into the `port` event input of every running node of `kind`
|
|
390
595
|
* in the project whose `account` input resolves to `accountId` (empty = default). */
|
|
391
|
-
routeEvent(
|
|
596
|
+
routeEvent(
|
|
597
|
+
projectId: string,
|
|
598
|
+
kind: string,
|
|
599
|
+
port: string,
|
|
600
|
+
payload: unknown,
|
|
601
|
+
accountId?: string
|
|
602
|
+
): void;
|
|
392
603
|
/** Whether a running graph in the project contains a node of one of `kinds`. */
|
|
393
604
|
hasConsumers(projectId: string, kinds: readonly string[]): boolean;
|
|
394
605
|
}
|
|
@@ -460,17 +671,19 @@ export type BackendFactory = (sdk: BackendSdk) => BackendPlugin;
|
|
|
460
671
|
export interface UiSdk extends SharedSdk {
|
|
461
672
|
// Typed loosely so the preview does not depend on @types/react.
|
|
462
673
|
React: unknown;
|
|
463
|
-
useTranslation: (ns?: string) => {
|
|
674
|
+
useTranslation: (ns?: string) => {
|
|
675
|
+
t: (key: string, opts?: Record<string, unknown>) => string;
|
|
676
|
+
};
|
|
464
677
|
components: Record<string, unknown>;
|
|
465
678
|
}
|
|
466
679
|
|
|
467
680
|
export interface UiPlugin {
|
|
468
|
-
/** Custom forms per
|
|
681
|
+
/** Custom forms per trigger / step type (instead of the generated `SchemaForm`). */
|
|
469
682
|
actionForms?: Record<string, unknown>;
|
|
470
683
|
}
|
|
471
684
|
|
|
472
685
|
/** `ui.mjs` default export. Reserved: the editor does not load `ui.mjs` yet
|
|
473
|
-
* (
|
|
686
|
+
* (forms are generated from `form`). */
|
|
474
687
|
export type UiFactory = (sdk: UiSdk) => UiPlugin;
|
|
475
688
|
|
|
476
689
|
// ─────────────────────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vspark/plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Typings of the vspark plugin API (apiVersion
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Typings of the vspark plugin API (apiVersion 2). Types only — vspark injects the SDK at runtime.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|