@fnndsc/brasa 0.56.4 → 0.57.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/buildinfo.json +1 -1
- package/dist/builtins/argumentTokens.d.ts +13 -0
- package/dist/builtins/argumentTokens.js +15 -3
- package/dist/builtins/argumentTokens.js.map +1 -1
- package/dist/builtins/fs/url.d.ts +27 -2
- package/dist/builtins/fs/url.js +60 -10
- package/dist/builtins/fs/url.js.map +1 -1
- package/dist/builtins/help.d.ts +6 -10
- package/dist/builtins/help.js +34 -87
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/pluginExecute.d.ts +21 -3
- package/dist/builtins/pluginExecute.js +69 -33
- package/dist/builtins/pluginExecute.js.map +1 -1
- package/dist/builtins/res/pipeline.d.ts +231 -2
- package/dist/builtins/res/pipeline.js +225 -107
- package/dist/builtins/res/pipeline.js.map +1 -1
- package/dist/builtins/res/plugin.d.ts +343 -3
- package/dist/builtins/res/plugin.js +221 -67
- package/dist/builtins/res/plugin.js.map +1 -1
- package/dist/builtins/res/plugin.sync.js +5 -3
- package/dist/builtins/res/plugin.sync.js.map +1 -1
- package/dist/chris/binDeclarations.d.ts +312 -0
- package/dist/chris/binDeclarations.js +572 -0
- package/dist/chris/binDeclarations.js.map +1 -0
- package/dist/chris/chrisCommands.d.ts +1 -0
- package/dist/chris/chrisCommands.js +5 -30
- package/dist/chris/chrisCommands.js.map +1 -1
- package/dist/chris/commandFallback.d.ts +30 -3
- package/dist/chris/commandFallback.js +163 -94
- package/dist/chris/commandFallback.js.map +1 -1
- package/dist/chris/completion.d.ts +37 -0
- package/dist/chris/completion.js +41 -121
- package/dist/chris/completion.js.map +1 -1
- package/dist/chris/kinds.d.ts +11 -0
- package/dist/chris/kinds.js +32 -1
- package/dist/chris/kinds.js.map +1 -1
- package/dist/core/argumentKinds.d.ts +18 -0
- package/dist/core/argumentKinds.js +33 -0
- package/dist/core/argumentKinds.js.map +1 -1
- package/dist/core/backend.d.ts +12 -5
- package/dist/core/backend.js.map +1 -1
- package/dist/core/commandDeclaration.d.ts +40 -0
- package/dist/core/commandDeclaration.js.map +1 -1
- package/dist/core/commandOrder.js +3 -3
- package/dist/core/commandOrder.js.map +1 -1
- package/dist/core/commandParse.d.ts +14 -0
- package/dist/core/commandParse.js +39 -5
- package/dist/core/commandParse.js.map +1 -1
- package/dist/core/commandRegistry.d.ts +22 -36
- package/dist/core/commandRegistry.js +19 -10
- package/dist/core/commandRegistry.js.map +1 -1
- package/dist/core/commandSchema.js +4 -0
- package/dist/core/commandSchema.js.map +1 -1
- package/dist/core/coreCommands.d.ts +1 -0
- package/dist/core/coreCommands.js +6 -19
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/dispatch.js +12 -41
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/preprocess.d.ts +0 -15
- package/dist/core/preprocess.js +0 -17
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/shellWords.d.ts +34 -0
- package/dist/core/shellWords.js +60 -0
- package/dist/core/shellWords.js.map +1 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.js +4 -0
- package/dist/core.js.map +1 -1
- package/dist/lib/completer/declared.js +22 -6
- package/dist/lib/completer/declared.js.map +1 -1
- package/dist/lib/completer/index.js +15 -53
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +1 -1
- package/dist/builtins/res/pipeline.args.d.ts +0 -35
- package/dist/builtins/res/pipeline.args.js +0 -94
- package/dist/builtins/res/pipeline.args.js.map +0 -1
- package/dist/chris/help.d.ts +0 -18
- package/dist/chris/help.js +0 -229
- package/dist/chris/help.js.map +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The declaration of a `/bin` line: a plugin's or a pipeline's, made
|
|
3
|
+
* from what CUBE declares of it, so the line is parsed, completed, refused
|
|
4
|
+
* and described as a builtin's is.
|
|
5
|
+
*
|
|
6
|
+
* CUBE owns a plugin's parameters and a pipeline's nodes; nothing here
|
|
7
|
+
* declares them a second time. A plugin's declaration is made from its
|
|
8
|
+
* parameters (flag, short flag, type, optional, default, help): a `bool`
|
|
9
|
+
* parameter is a switch, `int` and `float` are numbers, `path` and
|
|
10
|
+
* `unextpath` are CFS paths, anything else a word. A pipeline's is made
|
|
11
|
+
* from its manifest: one `--<node>.<field>` option for every field of every
|
|
12
|
+
* node, the node named by its title when that is unique and shell-safe and
|
|
13
|
+
* always by `@<piping id>`. Beside them stand the session's own options of
|
|
14
|
+
* a `/bin` line (`--detach`, `--parameters`, `--diagram`, …), which win a
|
|
15
|
+
* name both claim, and the operands: the line's input paths, which glob.
|
|
16
|
+
*
|
|
17
|
+
* A declaration is made when the session first needs it and kept, by the
|
|
18
|
+
* `/bin` entry it is made for: a plugin's carries its version
|
|
19
|
+
* (`pl-dircopy-v2.1.1`), a pipeline's its id in this CUBE
|
|
20
|
+
* (`PHI_detection_id12`), so a new version or a new registration is a new
|
|
21
|
+
* declaration.
|
|
22
|
+
*
|
|
23
|
+
* A plugin's line ends, after a lone `--`, with the run's own `key=value`
|
|
24
|
+
* context (`-- feed_title="T"`), which the line keeps apart before it is
|
|
25
|
+
* parsed.
|
|
26
|
+
*
|
|
27
|
+
* Key components:
|
|
28
|
+
* - pluginDeclaration_make / pipelineDeclaration_make: the pure builders.
|
|
29
|
+
* - binDeclaration_get: the declaration of a word `/bin` answers, kept once made.
|
|
30
|
+
* - pluginLine_parse / pipelineLine_parse: a line's words to its typed reading.
|
|
31
|
+
*
|
|
32
|
+
* Typical usage:
|
|
33
|
+
* ```ts
|
|
34
|
+
* const declaration: CommandDeclaration | null = await binDeclaration_get('pl-dircopy');
|
|
35
|
+
* const parsed: PluginLineParse = await pluginLine_parse('pl-dircopy-v2.1.1', ['~/uploads', '--', 'feed_title=T']);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Dependencies: the parser and the declaration types; CUBE through cumin and
|
|
39
|
+
* salsa (loaded when a declaration is made); `/bin` for which entry a word names.
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
42
|
+
*/
|
|
43
|
+
import type { PipelineManifest } from '@fnndsc/salsa';
|
|
44
|
+
import type { CommandEnvelope } from '@fnndsc/menu';
|
|
45
|
+
import type { CommandArguments, CommandDeclaration, CommandGrammar } from '../core/commandDeclaration.js';
|
|
46
|
+
import { type ParsedArguments } from '../core/commandParse.js';
|
|
47
|
+
/** One parameter of a plugin, as CUBE declares it. */
|
|
48
|
+
export interface PluginParameterSpec {
|
|
49
|
+
/** Its name, as CUBE stores it. */
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/** Its type: `str`, `int`, `float`, `bool`, `path`, `unextpath` (or their long spellings). */
|
|
52
|
+
readonly type: string;
|
|
53
|
+
/** Whether a run may leave it out. */
|
|
54
|
+
readonly optional: boolean;
|
|
55
|
+
/** Its default, when it declares one. */
|
|
56
|
+
readonly default?: unknown;
|
|
57
|
+
/** One line of help. */
|
|
58
|
+
readonly help?: string;
|
|
59
|
+
/** Its flag as typed: `--dir`. */
|
|
60
|
+
readonly flag: string;
|
|
61
|
+
/** Its one-letter flag, when it has one: `-d`. */
|
|
62
|
+
readonly shortFlag?: string;
|
|
63
|
+
}
|
|
64
|
+
/** One plugin version, as its declaration is made from it. */
|
|
65
|
+
export interface PluginSpec {
|
|
66
|
+
/** The plugin's name. */
|
|
67
|
+
readonly name: string;
|
|
68
|
+
/** Its version. */
|
|
69
|
+
readonly version: string;
|
|
70
|
+
/** Its kind: `ds`, `fs` or `ts`. */
|
|
71
|
+
readonly kind: string;
|
|
72
|
+
/** Its title, when it has one. */
|
|
73
|
+
readonly title?: string;
|
|
74
|
+
/** What it does, when it says. */
|
|
75
|
+
readonly description?: string;
|
|
76
|
+
/** Every parameter, in CUBE's order. */
|
|
77
|
+
readonly parameters: readonly PluginParameterSpec[];
|
|
78
|
+
}
|
|
79
|
+
/** A plugin line, read: its input, its parameters, its context, and what the session does with it. */
|
|
80
|
+
export interface PluginLine {
|
|
81
|
+
/** The operand words, as typed: paths, `as <subject>`, and any bare `key=value`. */
|
|
82
|
+
readonly operands: readonly string[];
|
|
83
|
+
/** The plugin's parameters given, by flag name (`dir`), each its value. */
|
|
84
|
+
readonly parameters: Readonly<Record<string, string | number | boolean>>;
|
|
85
|
+
/** The run's context words, after a lone `--` (`feed_title=T`). */
|
|
86
|
+
readonly context: readonly string[];
|
|
87
|
+
/** Return the run's handle at once rather than wait for it. */
|
|
88
|
+
readonly detach: boolean;
|
|
89
|
+
/** A look at the plugin instead of a run: its parameters, its README, or its raw README. */
|
|
90
|
+
readonly inspect: 'parameters' | 'readme' | 'readmeRaw' | null;
|
|
91
|
+
}
|
|
92
|
+
/** What reading a plugin line came to. */
|
|
93
|
+
export type PluginLineParse = {
|
|
94
|
+
readonly ok: true;
|
|
95
|
+
readonly line: PluginLine;
|
|
96
|
+
} | {
|
|
97
|
+
readonly ok: false;
|
|
98
|
+
readonly refusal: string;
|
|
99
|
+
};
|
|
100
|
+
/** The ways a pipeline line asks to look at the pipeline rather than run it. */
|
|
101
|
+
export type PipelineLook = 'diagram' | 'signalflow' | 'manifest' | 'nodes' | 'source' | 'help';
|
|
102
|
+
/** One override of a pipeline node, as `pipeline run` takes it. */
|
|
103
|
+
export interface PipelineLineBinding {
|
|
104
|
+
/** The node: its title, or `@<piping id>`. */
|
|
105
|
+
readonly node: string;
|
|
106
|
+
/** The field: a parameter or an execution control. */
|
|
107
|
+
readonly field: string;
|
|
108
|
+
/** The value. */
|
|
109
|
+
readonly value: unknown;
|
|
110
|
+
}
|
|
111
|
+
/** A pipeline line, read. */
|
|
112
|
+
export interface PipelineLine {
|
|
113
|
+
/** The operand words: the input paths, as typed. */
|
|
114
|
+
readonly operands: readonly string[];
|
|
115
|
+
/** A look at the pipeline instead of a run, or null for a run. */
|
|
116
|
+
readonly look: PipelineLook | null;
|
|
117
|
+
/** Draw the diagram with each node's stored arguments. */
|
|
118
|
+
readonly withArguments: boolean;
|
|
119
|
+
/** Draw the diagram as SignalFlow YAML. */
|
|
120
|
+
readonly signalflow: boolean;
|
|
121
|
+
/** The compute resource every node runs on, when given. */
|
|
122
|
+
readonly compute?: string;
|
|
123
|
+
/** The instance the run attaches to, when given. */
|
|
124
|
+
readonly previous?: number;
|
|
125
|
+
/** A CFS file of overrides, when given. */
|
|
126
|
+
readonly paramFile?: string;
|
|
127
|
+
/** The node overrides given. */
|
|
128
|
+
readonly bindings: readonly PipelineLineBinding[];
|
|
129
|
+
/** Return the run's handles at once. */
|
|
130
|
+
readonly detach: boolean;
|
|
131
|
+
/** Echo every parameter of every piping. */
|
|
132
|
+
readonly verbose: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** What reading a pipeline line came to. */
|
|
135
|
+
export type PipelineLineParse = {
|
|
136
|
+
readonly ok: true;
|
|
137
|
+
readonly line: PipelineLine;
|
|
138
|
+
} | {
|
|
139
|
+
readonly ok: false;
|
|
140
|
+
readonly refusal: string;
|
|
141
|
+
};
|
|
142
|
+
/** The `/bin` entry a word names: a plugin version, or a pipeline. */
|
|
143
|
+
export type BinEntry = {
|
|
144
|
+
readonly kind: 'plugin';
|
|
145
|
+
readonly executable: string;
|
|
146
|
+
} | {
|
|
147
|
+
readonly kind: 'pipeline';
|
|
148
|
+
readonly name: string;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* A plugin version's declaration, made from what CUBE declares of it: its
|
|
152
|
+
* `/bin` entry's name, its input operand, the session's options and one per
|
|
153
|
+
* parameter, and help from its title and description.
|
|
154
|
+
*
|
|
155
|
+
* @param spec - The plugin version.
|
|
156
|
+
* @param handler - What runs a parsed line (the run, or a test's stand-in).
|
|
157
|
+
* @returns The declaration.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* const declaration = pluginDeclaration_make({ name: 'pl-dircopy', version: '2.1.1', kind: 'fs', parameters: [{ name: 'dir', type: 'path', optional: false, flag: '--dir' }] }, run);
|
|
162
|
+
* declaration.grammar.options?.['dir']?.value?.kind; // 'cfsPath'
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare function pluginDeclaration_make(spec: PluginSpec, handler: (args: CommandArguments<CommandGrammar>) => Promise<CommandEnvelope>): CommandDeclaration;
|
|
166
|
+
/**
|
|
167
|
+
* A pipeline's declaration, made from its manifest: its `/bin` entry's
|
|
168
|
+
* name, its input operand, the session's options and one `--<node>.<field>`
|
|
169
|
+
* option for every field of every node.
|
|
170
|
+
*
|
|
171
|
+
* @param binName - The pipeline's `/bin` name (`PHI_detection_id12`).
|
|
172
|
+
* @param manifest - Its manifest, with the nodes' parameter definitions.
|
|
173
|
+
* @param handler - What runs a parsed line.
|
|
174
|
+
* @returns The declaration.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* const declaration = pipelineDeclaration_make('PHI_id3', manifest, run);
|
|
179
|
+
* Object.keys(declaration.grammar.options ?? {}); // ['diagram', …, 'segment.threshold', '@41.threshold', …]
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare function pipelineDeclaration_make(binName: string, manifest: PipelineManifest, handler: (args: CommandArguments<CommandGrammar>) => Promise<CommandEnvelope>): CommandDeclaration;
|
|
183
|
+
/** A parsed line as these readers take it: its operands and options by name, whatever grammar parsed it. */
|
|
184
|
+
type LineRead = Pick<ParsedArguments, 'operands' | 'options'> | CommandArguments<CommandGrammar>;
|
|
185
|
+
/**
|
|
186
|
+
* A plugin line, parsed: the typed reading of the line a declaration parsed.
|
|
187
|
+
*
|
|
188
|
+
* @param args - The parsed line.
|
|
189
|
+
* @param context - The run's context words.
|
|
190
|
+
* @returns The plugin line.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* pluginLine_read(parsed.args, ['feed_title=T']).parameters; // { dir: '/home/a/uploads' }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare function pluginLine_read(args: LineRead, context?: readonly string[]): PluginLine;
|
|
198
|
+
/**
|
|
199
|
+
* Parses a plugin's line against a declaration: the context split off at
|
|
200
|
+
* the first lone `--`, the rest parsed as a builtin's line is.
|
|
201
|
+
*
|
|
202
|
+
* @param declaration - The plugin's declaration.
|
|
203
|
+
* @param args - The words after the `/bin` name, carrying their shell words when a line gave them.
|
|
204
|
+
* @returns The plugin line, or the refusal (`pl-dircopy-v2.1.1: unrecognized option '--x'; usage: …`).
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* const parsed: PluginLineParse = await pluginWords_parse(declaration, ['~/uploads', '--', 'feed_title=T']);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export declare function pluginWords_parse(declaration: CommandDeclaration, args: readonly string[]): Promise<PluginLineParse>;
|
|
212
|
+
/**
|
|
213
|
+
* A pipeline line, parsed: the look it asks for or the run's options and
|
|
214
|
+
* node overrides.
|
|
215
|
+
*
|
|
216
|
+
* @param args - The parsed line.
|
|
217
|
+
* @returns The pipeline line.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* pipelineLine_read(parsed.args).bindings; // [{ node: 'segment', field: 'threshold', value: 0.5 }]
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare function pipelineLine_read(args: LineRead): PipelineLine;
|
|
225
|
+
/**
|
|
226
|
+
* Parses a pipeline's line against a declaration.
|
|
227
|
+
*
|
|
228
|
+
* @param declaration - The pipeline's declaration.
|
|
229
|
+
* @param args - The words after the `/bin` name.
|
|
230
|
+
* @returns The pipeline line, or the refusal.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* const parsed: PipelineLineParse = await pipelineWords_parse(declaration, ['--segment.threshold', '0.5']);
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export declare function pipelineWords_parse(declaration: CommandDeclaration, args: readonly string[]): Promise<PipelineLineParse>;
|
|
238
|
+
/**
|
|
239
|
+
* Forgets every declaration made, so the next is read from CUBE again.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* binDeclarations_forget();
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function binDeclarations_forget(): void;
|
|
247
|
+
/**
|
|
248
|
+
* The `/bin` entry a word names: a plugin by its full `/bin` name, a
|
|
249
|
+
* pipeline by its `/bin` name or its own, or a bare plugin name's highest
|
|
250
|
+
* version.
|
|
251
|
+
*
|
|
252
|
+
* @param command - The word.
|
|
253
|
+
* @returns The entry, or null when `/bin` names none.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* await binEntry_resolve('pl-dircopy'); // { kind: 'plugin', executable: 'pl-dircopy-v2.1.1' }
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export declare function binEntry_resolve(command: string): Promise<BinEntry | null>;
|
|
261
|
+
/**
|
|
262
|
+
* The declaration of a word `/bin` answers, made from CUBE the first time
|
|
263
|
+
* and kept by its entry: what completion, help and the schema read of a
|
|
264
|
+
* plugin or a pipeline, and what its line is parsed against.
|
|
265
|
+
*
|
|
266
|
+
* @param command - The word: a plugin's `/bin` name or bare name, or a pipeline's.
|
|
267
|
+
* @returns The declaration, or null when the word names nothing in `/bin` or CUBE cannot say.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* (await binDeclaration_get('pl-dircopy'))?.name; // 'pl-dircopy-v2.1.1'
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
export declare function binDeclaration_get(command: string): Promise<CommandDeclaration | null>;
|
|
275
|
+
/**
|
|
276
|
+
* The declaration of one plugin version, by its full `/bin` name.
|
|
277
|
+
*
|
|
278
|
+
* @param executable - `<name>-v<version>`.
|
|
279
|
+
* @returns The declaration, or null when CUBE cannot say.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* await pluginDeclaration_get('pl-dircopy-v2.1.1');
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export declare function pluginDeclaration_get(executable: string): Promise<CommandDeclaration | null>;
|
|
287
|
+
/**
|
|
288
|
+
* The declaration of one pipeline, by its `/bin` name.
|
|
289
|
+
*
|
|
290
|
+
* @param name - The pipeline's `/bin` name.
|
|
291
|
+
* @returns The declaration, or null when CUBE cannot say.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* await pipelineDeclaration_get('PHI_detection_id12');
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
export declare function pipelineDeclaration_get(name: string): Promise<CommandDeclaration | null>;
|
|
299
|
+
/**
|
|
300
|
+
* The fields `--<node>.<field>` names for a pipeline, for `pipeline run`'s
|
|
301
|
+
* completion: every option of its declaration that overrides a node.
|
|
302
|
+
*
|
|
303
|
+
* @param pipeline - The pipeline as the line names it.
|
|
304
|
+
* @returns The names, without the dashes; none when the pipeline cannot be read.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* await pipelineNodeOptions_list('PHI_detection'); // ['segment.threshold', '@41.threshold', …]
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
export declare function pipelineNodeOptions_list(pipeline: string): Promise<string[]>;
|
|
312
|
+
export {};
|