@visualautomate/plugin-sdk 0.6.0 → 0.7.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.
@@ -0,0 +1,42 @@
1
+ /** The console a step has: these four methods, and no others. */
2
+ export interface PluginConsole {
3
+ log(...args: unknown[]): void;
4
+ error(...args: unknown[]): void;
5
+ warn(...args: unknown[]): void;
6
+ info(...args: unknown[]): void;
7
+ }
8
+ export interface LoadOptions {
9
+ /**
10
+ * The `fetch` the step gets. Pass a guarded one to apply an egress rule;
11
+ * without it, this process's own.
12
+ */
13
+ fetch?: typeof fetch;
14
+ /** Where the step's console output goes. Defaults to this process's console. */
15
+ console?: Partial<PluginConsole>;
16
+ /** How long the code's top level may take to run, in milliseconds. */
17
+ timeoutMs?: number;
18
+ }
19
+ /** A console with exactly the platform's four methods, writing where `target` says. */
20
+ export declare function pluginConsole(target?: Partial<PluginConsole>): PluginConsole;
21
+ /**
22
+ * The globals a step's context starts with: the platform's list, taken from
23
+ * this process where the platform takes them from its own, and the blocked
24
+ * names set to undefined.
25
+ */
26
+ export declare function sandboxGlobals(options?: LoadOptions): Record<string, unknown>;
27
+ /**
28
+ * Evaluate a step's code as the runner does, and return what it exported.
29
+ *
30
+ * The code is wrapped exactly as the runner wraps it, on one line with nothing
31
+ * added after it, so a file the platform cannot load fails to load here too:
32
+ * a last line that is a `//` comment with no newline after it comments out the
33
+ * wrapper's closing bracket on the platform, and does here.
34
+ */
35
+ export declare function loadPluginCode(code: string, require: (name: string) => unknown, options?: LoadOptions): unknown;
36
+ /**
37
+ * The function the runner calls, from what the code exported: the export
38
+ * itself if it is a function, else its `execute`, else its `default` if that is
39
+ * a function. `null` when there is none, which the runner reports as "Plugin
40
+ * must export an execute function".
41
+ */
42
+ export declare function executeOf(exported: unknown): ((...args: unknown[]) => unknown) | null;
package/dist/types.d.ts CHANGED
@@ -50,7 +50,10 @@ export interface StorageListResult {
50
50
  * ceiling is refused rather than silently dropped.
51
51
  */
52
52
  export interface PluginStorage {
53
- /** Write a file. Bytes may be a string, a Buffer or any typed array. */
53
+ /**
54
+ * Write a file. Bytes are a string or a Uint8Array: there is no `Buffer` in a
55
+ * step's context.
56
+ */
54
57
  put(path: string, data: Uint8Array | string, contentType?: string): Promise<StorageResult>;
55
58
  /** Read a file back. `null` when it is not there. */
56
59
  get(path: string): Promise<Uint8Array | null>;
@@ -69,6 +72,13 @@ export interface PluginStorage {
69
72
  * to between one minute and one hour; the default is fifteen minutes.
70
73
  */
71
74
  signedUrl(path: string, expiresInSeconds?: number): Promise<string | null>;
75
+ /**
76
+ * A link on VisualAutomate's own domain that opens the file, for somebody
77
+ * with no account: a mail, a message, a page. The storage bucket's own
78
+ * address (signedUrl) is right for an API that fetches the file; this one is
79
+ * right for a person. Fifteen minutes unless `expiresInSeconds` says otherwise.
80
+ */
81
+ shareUrl(path: string, expiresInSeconds?: number): Promise<string | null>;
72
82
  /**
73
83
  * Pull a URL straight into storage without the bytes passing through this
74
84
  * step. A hundred-megabyte file costs the run no memory and no egress,
@@ -87,14 +97,26 @@ export interface PluginStorage {
87
97
  * The account's plan caps how many keys it may hold.
88
98
  */
89
99
  export interface PluginState {
90
- /** The stored value, or `null` when the key has never been set. */
100
+ /** The stored value, or `null` when the key has never been set or has expired. */
91
101
  get(key: string): Promise<unknown>;
102
+ /**
103
+ * Store a JSON value, at most 128 KB once encoded. With `ttlSeconds`, which
104
+ * must be at least 60, it is forgotten after that many seconds.
105
+ */
92
106
  set(key: string, value: unknown, options?: {
93
107
  ttlSeconds?: number;
94
108
  }): Promise<void>;
95
109
  delete(key: string): Promise<void>;
110
+ /**
111
+ * The keys under a prefix, each with when it expires (`null` for never).
112
+ * `complete` is false when there were more than one call returns.
113
+ */
96
114
  list(prefix?: string): Promise<{
97
- keys: string[];
115
+ keys: Array<{
116
+ key: string;
117
+ expiresAt: string | null;
118
+ }>;
119
+ complete: boolean;
98
120
  }>;
99
121
  }
100
122
  /**
@@ -262,7 +284,14 @@ export type PluginPropertyType = "string" | "number" | "boolean" | "select" | "m
262
284
  * `json` above: that one keeps its value structured, so `return 5` would be
263
285
  * saved as the number five and the step would run nothing.
264
286
  */
265
- | "code" | "color" | "date"
287
+ | "code"
288
+ /**
289
+ * A key the user types in: an API key, a token. A string to your code and to
290
+ * a declared call (`Bearer {{config.apiKey}}`), and masked wherever it is
291
+ * shown, because it is the one value on a step that somebody looking over a
292
+ * shoulder must not be able to read off.
293
+ */
294
+ | "secret" | "color" | "date"
266
295
  /** An account the user connected. Rendered as a picker, not a text box. */
267
296
  | "connection"
268
297
  /**
@@ -301,6 +330,49 @@ export interface PluginProperty {
301
330
  * `outlook`. A module inherits its app's, so it does not repeat this.
302
331
  */
303
332
  provider?: string;
333
+ /** Longer help, shown on request rather than under the input. */
334
+ help?: string;
335
+ /** Shown but not editable. */
336
+ disabled?: boolean;
337
+ /**
338
+ * For `select` and `multiselect`: read the options from the user's account
339
+ * instead of listing them, e.g. the channels of the chosen Slack workspace.
340
+ */
341
+ optionsFrom?: OptionsSource;
342
+ /**
343
+ * For `secret`: the properties that say where this secret is sent, such as
344
+ * a server URL. A stored secret is only kept when those are unchanged, so
345
+ * pointing the URL somewhere else cannot carry the key along.
346
+ */
347
+ sentTo?: string[];
348
+ /**
349
+ * For `secret`: the value is sent exactly as typed and never computed with,
350
+ * which lets the platform keep it out of the step's code entirely.
351
+ */
352
+ verbatim?: boolean;
353
+ }
354
+ /**
355
+ * Where a select's options come from: one GET as the account in `connection`,
356
+ * a list in the answer, and what each option shows and stores.
357
+ */
358
+ export interface OptionsSource {
359
+ /** The `connection` property whose account the options are read as. */
360
+ connection: string;
361
+ request: {
362
+ path: string;
363
+ query?: Record<string, unknown>;
364
+ headers?: Record<string, string>;
365
+ };
366
+ /** Where the list is in the answer (`""` when the answer is the list), and how many to offer. */
367
+ items: {
368
+ path: string;
369
+ limit?: number;
370
+ };
371
+ paginate?: Record<string, unknown>;
372
+ /** What each option shows, e.g. `{{item.name}}`. */
373
+ label: string;
374
+ /** What choosing it stores, e.g. `{{item.id}}`. */
375
+ value: string;
304
376
  }
305
377
  /**
306
378
  * How a step reaches the account it acts as.
@@ -35,12 +35,3 @@ export declare function validatePluginCode(code: string): CodeCheck;
35
35
  * the command that installs the version the sandbox has.
36
36
  */
37
37
  export declare function sandboxRequire(load: (name: string) => unknown): (name: string) => unknown;
38
- /**
39
- * Evaluate a step's code the way the sandbox wraps it: as the body of a function
40
- * given `module`, `exports` and `require`, in strict mode. Returns what it exported.
41
- *
42
- * Not a security boundary — this runs your own code on your own machine. It is
43
- * here so a file the sandbox cannot load (an `export` statement, a top-level
44
- * `await`) fails here too, rather than passing a looser loader.
45
- */
46
- export declare function loadPluginCode(code: string, require: (name: string) => unknown): unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visualautomate/plugin-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Types and a local runner for building VisualAutomate plugins.",
5
5
  "license": "MIT",
6
6
  "type": "module",