@qodalis/cli-server-abstractions 1.0.0-beta.12
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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/cli-command-author.d.ts +16 -0
- package/dist/cli-command-author.d.ts.map +1 -0
- package/dist/cli-command-author.js +16 -0
- package/dist/cli-command-author.js.map +1 -0
- package/dist/cli-command-parameter-descriptor.d.ts +34 -0
- package/dist/cli-command-parameter-descriptor.d.ts.map +1 -0
- package/dist/cli-command-parameter-descriptor.js +30 -0
- package/dist/cli-command-parameter-descriptor.js.map +1 -0
- package/dist/cli-command-processor.d.ts +67 -0
- package/dist/cli-command-processor.d.ts.map +1 -0
- package/dist/cli-command-processor.js +20 -0
- package/dist/cli-command-processor.js.map +1 -0
- package/dist/cli-module.d.ts +28 -0
- package/dist/cli-module.d.ts.map +1 -0
- package/dist/cli-module.js +12 -0
- package/dist/cli-module.js.map +1 -0
- package/dist/cli-paging.d.ts +35 -0
- package/dist/cli-paging.d.ts.map +1 -0
- package/dist/cli-paging.js +47 -0
- package/dist/cli-paging.js.map +1 -0
- package/dist/cli-process-command.d.ts +23 -0
- package/dist/cli-process-command.d.ts.map +1 -0
- package/dist/cli-process-command.js +3 -0
- package/dist/cli-process-command.js.map +1 -0
- package/dist/cli-processor-filter.d.ts +14 -0
- package/dist/cli-processor-filter.d.ts.map +1 -0
- package/dist/cli-processor-filter.js +3 -0
- package/dist/cli-processor-filter.js.map +1 -0
- package/dist/cli-stream-command-processor.d.ts +27 -0
- package/dist/cli-stream-command-processor.d.ts.map +1 -0
- package/dist/cli-stream-command-processor.js +13 -0
- package/dist/cli-stream-command-processor.js.map +1 -0
- package/dist/cli-structured-response.d.ts +56 -0
- package/dist/cli-structured-response.d.ts.map +1 -0
- package/dist/cli-structured-response.js +3 -0
- package/dist/cli-structured-response.js.map +1 -0
- package/dist/data-explorer-provider.d.ts +17 -0
- package/dist/data-explorer-provider.d.ts.map +1 -0
- package/dist/data-explorer-provider.js +3 -0
- package/dist/data-explorer-provider.js.map +1 -0
- package/dist/data-explorer-types.d.ts +143 -0
- package/dist/data-explorer-types.d.ts.map +1 -0
- package/dist/data-explorer-types.js +22 -0
- package/dist/data-explorer-types.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/cli-job-execution-context.d.ts +7 -0
- package/dist/jobs/cli-job-execution-context.d.ts.map +1 -0
- package/dist/jobs/cli-job-execution-context.js +3 -0
- package/dist/jobs/cli-job-execution-context.js.map +1 -0
- package/dist/jobs/cli-job-logger.d.ts +12 -0
- package/dist/jobs/cli-job-logger.d.ts.map +1 -0
- package/dist/jobs/cli-job-logger.js +3 -0
- package/dist/jobs/cli-job-logger.js.map +1 -0
- package/dist/jobs/cli-job-options.d.ts +30 -0
- package/dist/jobs/cli-job-options.d.ts.map +1 -0
- package/dist/jobs/cli-job-options.js +3 -0
- package/dist/jobs/cli-job-options.js.map +1 -0
- package/dist/jobs/cli-job-storage-provider.d.ts +30 -0
- package/dist/jobs/cli-job-storage-provider.d.ts.map +1 -0
- package/dist/jobs/cli-job-storage-provider.js +3 -0
- package/dist/jobs/cli-job-storage-provider.js.map +1 -0
- package/dist/jobs/cli-job.d.ts +11 -0
- package/dist/jobs/cli-job.d.ts.map +1 -0
- package/dist/jobs/cli-job.js +3 -0
- package/dist/jobs/cli-job.js.map +1 -0
- package/dist/jobs/index.d.ts +9 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +3 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/job-execution.d.ts +27 -0
- package/dist/jobs/job-execution.d.ts.map +1 -0
- package/dist/jobs/job-execution.js +3 -0
- package/dist/jobs/job-execution.js.map +1 -0
- package/dist/jobs/job-state.d.ts +12 -0
- package/dist/jobs/job-state.d.ts.map +1 -0
- package/dist/jobs/job-state.js +3 -0
- package/dist/jobs/job-state.js.map +1 -0
- package/dist/jobs/log-entry.d.ts +12 -0
- package/dist/jobs/log-entry.d.ts.map +1 -0
- package/dist/jobs/log-entry.js +3 -0
- package/dist/jobs/log-entry.js.map +1 -0
- package/dist/shell-words.d.ts +31 -0
- package/dist/shell-words.d.ts.map +1 -0
- package/dist/shell-words.js +98 -0
- package/dist/shell-words.js.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Qodalis Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @qodalis/cli-server-abstractions
|
|
2
|
+
|
|
3
|
+
Shared interfaces and base classes for building [Qodalis CLI](https://qodalis.com/) command processors. **Zero framework dependencies** — install this package when writing plugins, without pulling in Express, cors, or ws.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qodalis/cli-server-abstractions
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Create a custom command processor by extending `CliCommandProcessor`:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import {
|
|
17
|
+
CliCommandProcessor,
|
|
18
|
+
CliProcessCommand,
|
|
19
|
+
CliCommandParameterDescriptor,
|
|
20
|
+
} from '@qodalis/cli-server-abstractions';
|
|
21
|
+
|
|
22
|
+
export class GreetCommandProcessor extends CliCommandProcessor {
|
|
23
|
+
command = 'greet';
|
|
24
|
+
description = 'Greets a user by name';
|
|
25
|
+
parameters = [
|
|
26
|
+
new CliCommandParameterDescriptor('--name', 'Name to greet', true),
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
async handleAsync(command: CliProcessCommand): Promise<string> {
|
|
30
|
+
const name = command.args['name'] || 'World';
|
|
31
|
+
return `Hello, ${name}!`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then register the processor with the server package. See [`@qodalis/cli-server-node`](https://www.npmjs.com/package/@qodalis/cli-server-node) for server setup.
|
|
37
|
+
|
|
38
|
+
## API Reference
|
|
39
|
+
|
|
40
|
+
### Interfaces
|
|
41
|
+
|
|
42
|
+
| Interface | Description |
|
|
43
|
+
|-----------|-------------|
|
|
44
|
+
| `ICliCommandProcessor` | Contract for command processors: command name, description, author, parameters, sub-processors, and `handleAsync()` |
|
|
45
|
+
| `ICliCommandAuthor` | Author metadata: `name` and `email` |
|
|
46
|
+
| `ICliCommandParameterDescriptor` | Parameter declaration: name, type, required flag, aliases, default value |
|
|
47
|
+
| `CliProcessCommand` | Parsed command input: command name, value, args, chain commands, raw input, data payload |
|
|
48
|
+
| `CliPageRequest` | The rows a list command was asked for: `skip`, `take` |
|
|
49
|
+
| `CliTablePage` | The `page` of a table output: `skip`, `take`, `total?`, `hasMore`, `truncated?` |
|
|
50
|
+
|
|
51
|
+
### Classes
|
|
52
|
+
|
|
53
|
+
| Class | Description |
|
|
54
|
+
|-------|-------------|
|
|
55
|
+
| `CliCommandProcessor` | Abstract base class implementing `ICliCommandProcessor` with sensible defaults |
|
|
56
|
+
| `CliCommandAuthor` | Simple implementation of `ICliCommandAuthor` |
|
|
57
|
+
| `CliCommandParameterDescriptor` | Simple implementation of `ICliCommandParameterDescriptor` |
|
|
58
|
+
| `CliPaging` | `--skip` / `--take` convention: `CliPaging.parameters()` and `CliPaging.from(command)` |
|
|
59
|
+
|
|
60
|
+
### Constants
|
|
61
|
+
|
|
62
|
+
| Constant | Description |
|
|
63
|
+
|----------|-------------|
|
|
64
|
+
| `DefaultLibraryAuthor` | Default `ICliCommandAuthor` instance used when no author is specified |
|
|
65
|
+
| `DEFAULT_TAKE`, `MAX_TAKE` | Rows shown by default (50) and at most (500) |
|
|
66
|
+
|
|
67
|
+
### `CliCommandProcessor` Members
|
|
68
|
+
|
|
69
|
+
| Member | Type | Default | Description |
|
|
70
|
+
|--------|------|---------|-------------|
|
|
71
|
+
| `command` | `string` | *(abstract)* | The command name users type to invoke this processor |
|
|
72
|
+
| `description` | `string` | *(abstract)* | Human-readable description shown in help |
|
|
73
|
+
| `author` | `ICliCommandAuthor` | `DefaultLibraryAuthor` | Author metadata |
|
|
74
|
+
| `version` | `string` | `'1.0.0'` | Processor version |
|
|
75
|
+
| `allowUnlistedCommands` | `boolean?` | `undefined` | Accept sub-commands not in `processors` list |
|
|
76
|
+
| `valueRequired` | `boolean?` | `undefined` | Whether a positional value argument is required |
|
|
77
|
+
| `processors` | `ICliCommandProcessor[]?` | `undefined` | Nested sub-command processors |
|
|
78
|
+
| `parameters` | `ICliCommandParameterDescriptor[]?` | `undefined` | Declared parameters for autocompletion and validation |
|
|
79
|
+
| `handleAsync(command)` | method | *(abstract)* | Execute the command, return result string |
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Describes the author of a CLI command processor. */
|
|
2
|
+
export interface ICliCommandAuthor {
|
|
3
|
+
/** Display name of the author. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Contact email of the author. */
|
|
6
|
+
email: string;
|
|
7
|
+
}
|
|
8
|
+
/** Concrete implementation of {@link ICliCommandAuthor}. */
|
|
9
|
+
export declare class CliCommandAuthor implements ICliCommandAuthor {
|
|
10
|
+
name: string;
|
|
11
|
+
email: string;
|
|
12
|
+
constructor(name: string, email: string);
|
|
13
|
+
}
|
|
14
|
+
/** Default author used for built-in library processors. */
|
|
15
|
+
export declare const DefaultLibraryAuthor: ICliCommandAuthor;
|
|
16
|
+
//# sourceMappingURL=cli-command-author.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-author.d.ts","sourceRoot":"","sources":["../src/cli-command-author.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAC9B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,4DAA4D;AAC5D,qBAAa,gBAAiB,YAAW,iBAAiB;IAE3C,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;gBADb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM;CAE3B;AAED,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,EAAE,iBAGlC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultLibraryAuthor = exports.CliCommandAuthor = void 0;
|
|
4
|
+
/** Concrete implementation of {@link ICliCommandAuthor}. */
|
|
5
|
+
class CliCommandAuthor {
|
|
6
|
+
name;
|
|
7
|
+
email;
|
|
8
|
+
constructor(name, email) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
this.email = email;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.CliCommandAuthor = CliCommandAuthor;
|
|
14
|
+
/** Default author used for built-in library processors. */
|
|
15
|
+
exports.DefaultLibraryAuthor = new CliCommandAuthor('Nicolae Lupei', 'nicolae.lupei@qodalis.com');
|
|
16
|
+
//# sourceMappingURL=cli-command-author.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-author.js","sourceRoot":"","sources":["../src/cli-command-author.ts"],"names":[],"mappings":";;;AAQA,4DAA4D;AAC5D,MAAa,gBAAgB;IAEd;IACA;IAFX,YACW,IAAY,EACZ,KAAa;QADb,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;IACrB,CAAC;CACP;AALD,4CAKC;AAED,2DAA2D;AAC9C,QAAA,oBAAoB,GAAsB,IAAI,gBAAgB,CACvE,eAAe,EACf,2BAA2B,CAC9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Describes a parameter accepted by a CLI command processor. */
|
|
2
|
+
export interface ICliCommandParameterDescriptor {
|
|
3
|
+
/** Parameter name (e.g. "algorithm"). */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Short alias flags (e.g. ["-a"]). */
|
|
6
|
+
aliases?: string[];
|
|
7
|
+
/** Human-readable description shown in help output. */
|
|
8
|
+
description: string;
|
|
9
|
+
/** Whether the parameter must be provided. */
|
|
10
|
+
required: boolean;
|
|
11
|
+
/** Expected value type (e.g. "string", "boolean", "number"). */
|
|
12
|
+
type: string;
|
|
13
|
+
/** Default value used when the parameter is omitted. */
|
|
14
|
+
defaultValue?: any;
|
|
15
|
+
}
|
|
16
|
+
/** Concrete implementation of {@link ICliCommandParameterDescriptor}. */
|
|
17
|
+
export declare class CliCommandParameterDescriptor implements ICliCommandParameterDescriptor {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
required: boolean;
|
|
21
|
+
type: string;
|
|
22
|
+
aliases?: string[] | undefined;
|
|
23
|
+
defaultValue?: any | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* @param name - Parameter name.
|
|
26
|
+
* @param description - Human-readable description.
|
|
27
|
+
* @param required - Whether the parameter is mandatory.
|
|
28
|
+
* @param type - Expected value type.
|
|
29
|
+
* @param aliases - Short alias flags.
|
|
30
|
+
* @param defaultValue - Default value when omitted.
|
|
31
|
+
*/
|
|
32
|
+
constructor(name: string, description: string, required?: boolean, type?: string, aliases?: string[] | undefined, defaultValue?: any | undefined);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=cli-command-parameter-descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-parameter-descriptor.d.ts","sourceRoot":"","sources":["../src/cli-command-parameter-descriptor.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,WAAW,8BAA8B;IAC3C,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,YAAY,CAAC,EAAE,GAAG,CAAC;CACtB;AAED,yEAAyE;AACzE,qBAAa,6BAA8B,YAAW,8BAA8B;IAUrE,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE;IAClB,YAAY,CAAC,EAAE,GAAG;IAd7B;;;;;;;OAOG;gBAEQ,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE,OAAe,EACzB,IAAI,GAAE,MAAiB,EACvB,OAAO,CAAC,EAAE,MAAM,EAAE,YAAA,EAClB,YAAY,CAAC,EAAE,GAAG,YAAA;CAEhC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CliCommandParameterDescriptor = void 0;
|
|
4
|
+
/** Concrete implementation of {@link ICliCommandParameterDescriptor}. */
|
|
5
|
+
class CliCommandParameterDescriptor {
|
|
6
|
+
name;
|
|
7
|
+
description;
|
|
8
|
+
required;
|
|
9
|
+
type;
|
|
10
|
+
aliases;
|
|
11
|
+
defaultValue;
|
|
12
|
+
/**
|
|
13
|
+
* @param name - Parameter name.
|
|
14
|
+
* @param description - Human-readable description.
|
|
15
|
+
* @param required - Whether the parameter is mandatory.
|
|
16
|
+
* @param type - Expected value type.
|
|
17
|
+
* @param aliases - Short alias flags.
|
|
18
|
+
* @param defaultValue - Default value when omitted.
|
|
19
|
+
*/
|
|
20
|
+
constructor(name, description, required = false, type = 'string', aliases, defaultValue) {
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.description = description;
|
|
23
|
+
this.required = required;
|
|
24
|
+
this.type = type;
|
|
25
|
+
this.aliases = aliases;
|
|
26
|
+
this.defaultValue = defaultValue;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.CliCommandParameterDescriptor = CliCommandParameterDescriptor;
|
|
30
|
+
//# sourceMappingURL=cli-command-parameter-descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-parameter-descriptor.js","sourceRoot":"","sources":["../src/cli-command-parameter-descriptor.ts"],"names":[],"mappings":";;;AAgBA,yEAAyE;AACzE,MAAa,6BAA6B;IAU3B;IACA;IACA;IACA;IACA;IACA;IAdX;;;;;;;OAOG;IACH,YACW,IAAY,EACZ,WAAmB,EACnB,WAAoB,KAAK,EACzB,OAAe,QAAQ,EACvB,OAAkB,EAClB,YAAkB;QALlB,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,SAAI,GAAJ,IAAI,CAAmB;QACvB,YAAO,GAAP,OAAO,CAAW;QAClB,iBAAY,GAAZ,YAAY,CAAM;IAC1B,CAAC;CACP;AAjBD,sEAiBC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ICliCommandAuthor } from './cli-command-author';
|
|
2
|
+
import { ICliCommandParameterDescriptor } from './cli-command-parameter-descriptor';
|
|
3
|
+
import { CliProcessCommand } from './cli-process-command';
|
|
4
|
+
import { CliStructuredResponse } from './cli-structured-response';
|
|
5
|
+
/** Contract for a CLI command processor that handles one command (and optionally sub-commands). */
|
|
6
|
+
export interface ICliCommandProcessor {
|
|
7
|
+
/** Primary command keyword (e.g. "echo", "hash"). */
|
|
8
|
+
command: string;
|
|
9
|
+
/** Short description shown in help/listing output. */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Author metadata for this processor. */
|
|
12
|
+
author: ICliCommandAuthor;
|
|
13
|
+
/** When true, sub-commands not listed in {@link processors} are forwarded to this processor. */
|
|
14
|
+
allowUnlistedCommands?: boolean;
|
|
15
|
+
/** When true, the command requires a positional value argument. */
|
|
16
|
+
valueRequired?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* When true, the command reads an optional positional value (`command.value`).
|
|
19
|
+
* Implied by {@link valueRequired}. MCP exposes it as an optional `value` argument.
|
|
20
|
+
*/
|
|
21
|
+
acceptsValue?: boolean;
|
|
22
|
+
/** Semantic version of this processor. */
|
|
23
|
+
version: string;
|
|
24
|
+
/** Nested sub-command processors. */
|
|
25
|
+
processors?: ICliCommandProcessor[];
|
|
26
|
+
/** Parameter descriptors for this command. */
|
|
27
|
+
parameters?: ICliCommandParameterDescriptor[];
|
|
28
|
+
/**
|
|
29
|
+
* Permissions required to execute this command (all of them), enforced
|
|
30
|
+
* server-side when the users plugin protects the server.
|
|
31
|
+
*/
|
|
32
|
+
requiredPermissions?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Executes the command and returns a plain-text result.
|
|
35
|
+
* @param command - Parsed command with arguments.
|
|
36
|
+
* @param signal - Optional AbortSignal to cancel the operation.
|
|
37
|
+
* @returns Plain-text output string.
|
|
38
|
+
*/
|
|
39
|
+
handleAsync(command: CliProcessCommand, signal?: AbortSignal): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Executes the command and returns a structured response with typed outputs.
|
|
42
|
+
* When implemented, takes precedence over {@link handleAsync}.
|
|
43
|
+
* @param command - Parsed command with arguments.
|
|
44
|
+
* @param signal - Optional AbortSignal to cancel the operation.
|
|
45
|
+
* @returns Structured response containing exit code and typed outputs.
|
|
46
|
+
*/
|
|
47
|
+
handleStructuredAsync?(command: CliProcessCommand, signal?: AbortSignal): Promise<CliStructuredResponse>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Abstract base class for CLI command processors with sensible defaults.
|
|
51
|
+
* Extend this class and implement {@link handleAsync} to create a new command.
|
|
52
|
+
*/
|
|
53
|
+
export declare abstract class CliCommandProcessor implements ICliCommandProcessor {
|
|
54
|
+
abstract command: string;
|
|
55
|
+
abstract description: string;
|
|
56
|
+
author: ICliCommandAuthor;
|
|
57
|
+
allowUnlistedCommands?: boolean;
|
|
58
|
+
valueRequired?: boolean;
|
|
59
|
+
acceptsValue?: boolean;
|
|
60
|
+
version: string;
|
|
61
|
+
processors?: ICliCommandProcessor[];
|
|
62
|
+
parameters?: ICliCommandParameterDescriptor[];
|
|
63
|
+
requiredPermissions?: string[];
|
|
64
|
+
abstract handleAsync(command: CliProcessCommand, signal?: AbortSignal): Promise<string>;
|
|
65
|
+
handleStructuredAsync?(command: CliProcessCommand, signal?: AbortSignal): Promise<CliStructuredResponse>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=cli-command-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-processor.d.ts","sourceRoot":"","sources":["../src/cli-command-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,mGAAmG;AACnG,MAAM,WAAW,oBAAoB;IACjC,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,MAAM,EAAE,iBAAiB,CAAC;IAC1B,gGAAgG;IAChG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mEAAmE;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACpC,8CAA8C;IAC9C,UAAU,CAAC,EAAE,8BAA8B,EAAE,CAAC;IAC9C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/E;;;;;;OAMG;IACH,qBAAqB,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC5G;AAED;;;GAGG;AACH,8BAAsB,mBAAoB,YAAW,oBAAoB;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAwB;IACjD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAW;IAC1B,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,8BAA8B,EAAE,CAAC;IAC9C,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IACvF,qBAAqB,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAC3G"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CliCommandProcessor = void 0;
|
|
4
|
+
const cli_command_author_1 = require("./cli-command-author");
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class for CLI command processors with sensible defaults.
|
|
7
|
+
* Extend this class and implement {@link handleAsync} to create a new command.
|
|
8
|
+
*/
|
|
9
|
+
class CliCommandProcessor {
|
|
10
|
+
author = cli_command_author_1.DefaultLibraryAuthor;
|
|
11
|
+
allowUnlistedCommands;
|
|
12
|
+
valueRequired;
|
|
13
|
+
acceptsValue;
|
|
14
|
+
version = '1.0.0';
|
|
15
|
+
processors;
|
|
16
|
+
parameters;
|
|
17
|
+
requiredPermissions;
|
|
18
|
+
}
|
|
19
|
+
exports.CliCommandProcessor = CliCommandProcessor;
|
|
20
|
+
//# sourceMappingURL=cli-command-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-command-processor.js","sourceRoot":"","sources":["../src/cli-command-processor.ts"],"names":[],"mappings":";;;AAAA,6DAA+E;AAkD/E;;;GAGG;AACH,MAAsB,mBAAmB;IAGrC,MAAM,GAAsB,yCAAoB,CAAC;IACjD,qBAAqB,CAAW;IAChC,aAAa,CAAW;IACxB,YAAY,CAAW;IACvB,OAAO,GAAW,OAAO,CAAC;IAC1B,UAAU,CAA0B;IACpC,UAAU,CAAoC;IAC9C,mBAAmB,CAAY;CAIlC;AAdD,kDAcC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ICliCommandProcessor } from './cli-command-processor';
|
|
2
|
+
import { ICliCommandAuthor } from './cli-command-author';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a module that bundles one or more command processors.
|
|
5
|
+
*/
|
|
6
|
+
export interface ICliModule {
|
|
7
|
+
/** Unique name of the module. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Module version. */
|
|
10
|
+
version: string;
|
|
11
|
+
/** Short description of the module. */
|
|
12
|
+
description: string;
|
|
13
|
+
/** Author of the module. */
|
|
14
|
+
author: ICliCommandAuthor;
|
|
15
|
+
/** Command processors provided by this module. */
|
|
16
|
+
processors: ICliCommandProcessor[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Base class for CLI modules providing sensible defaults.
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class CliModule implements ICliModule {
|
|
22
|
+
abstract name: string;
|
|
23
|
+
abstract version: string;
|
|
24
|
+
abstract description: string;
|
|
25
|
+
author: ICliCommandAuthor;
|
|
26
|
+
abstract processors: ICliCommandProcessor[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cli-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module.d.ts","sourceRoot":"","sources":["../src/cli-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAwB,MAAM,sBAAsB,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IAEb,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAEhB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IAEpB,4BAA4B;IAC5B,MAAM,EAAE,iBAAiB,CAAC;IAE1B,kDAAkD;IAClD,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,8BAAsB,SAAU,YAAW,UAAU;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAwB;IACjD,QAAQ,CAAC,UAAU,EAAE,oBAAoB,EAAE,CAAC;CAC/C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CliModule = void 0;
|
|
4
|
+
const cli_command_author_1 = require("./cli-command-author");
|
|
5
|
+
/**
|
|
6
|
+
* Base class for CLI modules providing sensible defaults.
|
|
7
|
+
*/
|
|
8
|
+
class CliModule {
|
|
9
|
+
author = cli_command_author_1.DefaultLibraryAuthor;
|
|
10
|
+
}
|
|
11
|
+
exports.CliModule = CliModule;
|
|
12
|
+
//# sourceMappingURL=cli-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module.js","sourceRoot":"","sources":["../src/cli-module.ts"],"names":[],"mappings":";;;AACA,6DAA+E;AAsB/E;;GAEG;AACH,MAAsB,SAAS;IAI3B,MAAM,GAAsB,yCAAoB,CAAC;CAEpD;AAND,8BAMC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CliProcessCommand } from './cli-process-command';
|
|
2
|
+
import { ICliCommandParameterDescriptor } from './cli-command-parameter-descriptor';
|
|
3
|
+
/** Rows to show when the command line does not say (`--take`). */
|
|
4
|
+
export declare const DEFAULT_TAKE = 50;
|
|
5
|
+
/** The largest `--take` accepted; larger values are lowered to it. */
|
|
6
|
+
export declare const MAX_TAKE = 500;
|
|
7
|
+
/**
|
|
8
|
+
* The rows a list command was asked for, read from `--skip` and `--take`. Commands
|
|
9
|
+
* that can return many rows declare {@link CliPaging.parameters}, read the request
|
|
10
|
+
* with {@link CliPaging.from}, query with `skip` and `take`, and write the rows with
|
|
11
|
+
* `writePagedTable` so the terminal shows which rows these are and how to get the next ones.
|
|
12
|
+
*/
|
|
13
|
+
export interface CliPageRequest {
|
|
14
|
+
/** Rows to skip before the first one shown (0 = from the start). */
|
|
15
|
+
skip: number;
|
|
16
|
+
/** Rows to show (1 to {@link MAX_TAKE}). */
|
|
17
|
+
take: number;
|
|
18
|
+
}
|
|
19
|
+
/** The `--skip` / `--take` convention shared by list commands. */
|
|
20
|
+
export declare class CliPaging {
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* The `--skip` and `--take` parameters, to add to a command's `parameters`
|
|
24
|
+
* so help and completion show them.
|
|
25
|
+
*/
|
|
26
|
+
static parameters(defaultTake?: number): ICliCommandParameterDescriptor[];
|
|
27
|
+
/**
|
|
28
|
+
* The rows asked for by `command`: `--skip` (default 0; negative values become 0) and
|
|
29
|
+
* `--take` (default `defaultTake`, at most {@link MAX_TAKE}; 0, negative or invalid values
|
|
30
|
+
* fall back to the default). Values may be numbers or strings; non-integers fall back to
|
|
31
|
+
* the defaults.
|
|
32
|
+
*/
|
|
33
|
+
static from(command: CliProcessCommand, defaultTake?: number): CliPageRequest;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=cli-paging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-paging.d.ts","sourceRoot":"","sources":["../src/cli-paging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAiC,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AAEnH,kEAAkE;AAClE,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,sEAAsE;AACtE,eAAO,MAAM,QAAQ,MAAM,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,kEAAkE;AAClE,qBAAa,SAAS;IAClB,OAAO;IAEP;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,WAAW,GAAE,MAAqB,GAAG,8BAA8B,EAAE;IAcvF;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,GAAE,MAAqB,GAAG,cAAc;CAM9F"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CliPaging = exports.MAX_TAKE = exports.DEFAULT_TAKE = void 0;
|
|
4
|
+
const cli_command_parameter_descriptor_1 = require("./cli-command-parameter-descriptor");
|
|
5
|
+
/** Rows to show when the command line does not say (`--take`). */
|
|
6
|
+
exports.DEFAULT_TAKE = 50;
|
|
7
|
+
/** The largest `--take` accepted; larger values are lowered to it. */
|
|
8
|
+
exports.MAX_TAKE = 500;
|
|
9
|
+
/** The `--skip` / `--take` convention shared by list commands. */
|
|
10
|
+
class CliPaging {
|
|
11
|
+
constructor() { }
|
|
12
|
+
/**
|
|
13
|
+
* The `--skip` and `--take` parameters, to add to a command's `parameters`
|
|
14
|
+
* so help and completion show them.
|
|
15
|
+
*/
|
|
16
|
+
static parameters(defaultTake = exports.DEFAULT_TAKE) {
|
|
17
|
+
return [
|
|
18
|
+
new cli_command_parameter_descriptor_1.CliCommandParameterDescriptor('skip', 'Rows to skip', false, 'number', undefined, 0),
|
|
19
|
+
new cli_command_parameter_descriptor_1.CliCommandParameterDescriptor('take', `Rows to show (at most ${exports.MAX_TAKE})`, false, 'number', undefined, defaultTake),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The rows asked for by `command`: `--skip` (default 0; negative values become 0) and
|
|
24
|
+
* `--take` (default `defaultTake`, at most {@link MAX_TAKE}; 0, negative or invalid values
|
|
25
|
+
* fall back to the default). Values may be numbers or strings; non-integers fall back to
|
|
26
|
+
* the defaults.
|
|
27
|
+
*/
|
|
28
|
+
static from(command, defaultTake = exports.DEFAULT_TAKE) {
|
|
29
|
+
const skip = Math.max(readInteger(command, 'skip') ?? 0, 0);
|
|
30
|
+
const requested = readInteger(command, 'take');
|
|
31
|
+
const take = Math.min(requested !== undefined && requested > 0 ? requested : defaultTake, exports.MAX_TAKE);
|
|
32
|
+
return { skip, take };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.CliPaging = CliPaging;
|
|
36
|
+
function readInteger(command, name) {
|
|
37
|
+
const value = command?.args?.[name];
|
|
38
|
+
let number;
|
|
39
|
+
if (typeof value === 'number') {
|
|
40
|
+
number = value;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof value === 'string' && /^\s*[+-]?\d+\s*$/.test(value)) {
|
|
43
|
+
number = Number(value.trim());
|
|
44
|
+
}
|
|
45
|
+
return number !== undefined && Number.isSafeInteger(number) ? number : undefined;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=cli-paging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-paging.js","sourceRoot":"","sources":["../src/cli-paging.ts"],"names":[],"mappings":";;;AACA,yFAAmH;AAEnH,kEAAkE;AACrD,QAAA,YAAY,GAAG,EAAE,CAAC;AAE/B,sEAAsE;AACzD,QAAA,QAAQ,GAAG,GAAG,CAAC;AAe5B,kEAAkE;AAClE,MAAa,SAAS;IAClB,gBAAuB,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,cAAsB,oBAAY;QAChD,OAAO;YACH,IAAI,gEAA6B,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;YACxF,IAAI,gEAA6B,CAC7B,MAAM,EACN,yBAAyB,gBAAQ,GAAG,EACpC,KAAK,EACL,QAAQ,EACR,SAAS,EACT,WAAW,CACd;SACJ,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,OAA0B,EAAE,cAAsB,oBAAY;QACtE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,gBAAQ,CAAC,CAAC;QACpG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;CACJ;AAjCD,8BAiCC;AAED,SAAS,WAAW,CAAC,OAA0B,EAAE,IAAY;IACzD,MAAM,KAAK,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,MAA0B,CAAC;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,GAAG,KAAK,CAAC;IACnB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Parsed representation of a CLI command submitted for execution. */
|
|
2
|
+
export interface CliProcessCommand {
|
|
3
|
+
/** Primary command keyword (e.g. "hash", "http"). */
|
|
4
|
+
command: string;
|
|
5
|
+
/** Optional payload data attached to the command. */
|
|
6
|
+
data?: any;
|
|
7
|
+
/** Sub-command chain following the primary command (e.g. ["encode"] for "base64 encode"). */
|
|
8
|
+
chainCommands: string[];
|
|
9
|
+
/** Original unparsed command string as entered by the user. */
|
|
10
|
+
rawCommand: string;
|
|
11
|
+
/** Positional value argument (the first non-flag token after the command). */
|
|
12
|
+
value?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The positional arguments after the command and sub-command words, split
|
|
15
|
+
* like a shell: quotes removed, backslash escapes applied, flags excluded.
|
|
16
|
+
* Sent by newer browsers; `value` stays as typed. Read it with `getPositionals`,
|
|
17
|
+
* which falls back to splitting `value` when it is missing.
|
|
18
|
+
*/
|
|
19
|
+
positionals?: string[];
|
|
20
|
+
/** Named arguments parsed from flags (e.g. { algorithm: "sha256" }). */
|
|
21
|
+
args: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=cli-process-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-process-command.d.ts","sourceRoot":"","sources":["../src/cli-process-command.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,WAAW,iBAAiB;IAC9B,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,6FAA6F;IAC7F,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-process-command.js","sourceRoot":"","sources":["../src/cli-process-command.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ICliCommandProcessor } from './cli-command-processor';
|
|
2
|
+
/**
|
|
3
|
+
* Provides a mechanism to filter whether a command processor is allowed to execute.
|
|
4
|
+
* Implementations can use this to disable processors at runtime (e.g., when a plugin is toggled off).
|
|
5
|
+
*/
|
|
6
|
+
export interface ICliProcessorFilter {
|
|
7
|
+
/**
|
|
8
|
+
* Determines whether the given command processor is allowed to execute.
|
|
9
|
+
* @param processor - The command processor to check.
|
|
10
|
+
* @returns `true` if the processor is allowed; `false` if it should be blocked.
|
|
11
|
+
*/
|
|
12
|
+
isAllowed(processor: ICliCommandProcessor): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cli-processor-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-processor-filter.d.ts","sourceRoot":"","sources":["../src/cli-processor-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC;CACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-processor-filter.js","sourceRoot":"","sources":["../src/cli-processor-filter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CliProcessCommand } from './cli-process-command';
|
|
2
|
+
import { CliStructuredOutput } from './cli-structured-response';
|
|
3
|
+
/**
|
|
4
|
+
* Optional interface for command processors that support streaming output.
|
|
5
|
+
* Processors implementing this interface can emit output chunks incrementally
|
|
6
|
+
* via the `emit` callback, enabling real-time rendering on the client.
|
|
7
|
+
*
|
|
8
|
+
* A processor can implement both ICliCommandProcessor and ICliStreamCommandProcessor.
|
|
9
|
+
* The stream execution endpoint will prefer this interface when available.
|
|
10
|
+
*/
|
|
11
|
+
export interface ICliStreamCommandProcessor {
|
|
12
|
+
/** Must match the command keyword of the corresponding ICliCommandProcessor. */
|
|
13
|
+
readonly command: string;
|
|
14
|
+
/**
|
|
15
|
+
* Execute the command, emitting output chunks as they become available.
|
|
16
|
+
* @param command - Parsed command with arguments.
|
|
17
|
+
* @param emit - Callback to send a single output chunk to the client.
|
|
18
|
+
* @param signal - Optional AbortSignal to cancel the operation.
|
|
19
|
+
* @returns Exit code (0 for success).
|
|
20
|
+
*/
|
|
21
|
+
handleStreamAsync(command: CliProcessCommand, emit: (output: CliStructuredOutput) => void, signal?: AbortSignal): Promise<number>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a processor supports streaming.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isStreamCapable(processor: unknown): processor is ICliStreamCommandProcessor;
|
|
27
|
+
//# sourceMappingURL=cli-stream-command-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-stream-command-processor.d.ts","sourceRoot":"","sources":["../src/cli-stream-command-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,0BAA0B;IACvC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,iBAAiB,CACb,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,EAC3C,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC3B,SAAS,EAAE,OAAO,GACnB,SAAS,IAAI,0BAA0B,CAOzC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStreamCapable = isStreamCapable;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to check if a processor supports streaming.
|
|
6
|
+
*/
|
|
7
|
+
function isStreamCapable(processor) {
|
|
8
|
+
return (typeof processor === 'object' &&
|
|
9
|
+
processor !== null &&
|
|
10
|
+
'handleStreamAsync' in processor &&
|
|
11
|
+
typeof processor.handleStreamAsync === 'function');
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=cli-stream-command-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-stream-command-processor.js","sourceRoot":"","sources":["../src/cli-stream-command-processor.ts"],"names":[],"mappings":";;AAgCA,0CASC;AAZD;;GAEG;AACH,SAAgB,eAAe,CAC3B,SAAkB;IAElB,OAAO,CACH,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,KAAK,IAAI;QAClB,mBAAmB,IAAI,SAAS;QAChC,OAAQ,SAAiB,CAAC,iBAAiB,KAAK,UAAU,CAC7D,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which rows of a longer result a table output holds:
|
|
3
|
+
* `{ "skip": 50, "take": 50, "total": 120, "hasMore": true }`.
|
|
4
|
+
* `total` and `truncated` are omitted when not set.
|
|
5
|
+
*/
|
|
6
|
+
export interface CliTablePage {
|
|
7
|
+
/** Rows skipped before the first row of the table. */
|
|
8
|
+
skip: number;
|
|
9
|
+
/** Rows asked for (the table may hold fewer). */
|
|
10
|
+
take: number;
|
|
11
|
+
/** All rows of the result, when the command knows it. */
|
|
12
|
+
total?: number;
|
|
13
|
+
/** Whether more rows follow (`--skip` = skip + rows shown). */
|
|
14
|
+
hasMore: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Set when the server cut an unpaged table (the `maxTableRows` server option):
|
|
17
|
+
* the command does not page, so `--skip` will not show the rest.
|
|
18
|
+
*/
|
|
19
|
+
truncated?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** A single typed output block within a structured CLI response. */
|
|
22
|
+
export type CliStructuredOutput = {
|
|
23
|
+
type: 'text';
|
|
24
|
+
value: string;
|
|
25
|
+
style?: 'success' | 'error' | 'info' | 'warning';
|
|
26
|
+
} | {
|
|
27
|
+
type: 'table';
|
|
28
|
+
headers: string[];
|
|
29
|
+
rows: string[][];
|
|
30
|
+
/**
|
|
31
|
+
* Which rows of a longer result these are, when the command pages (`--skip`, `--take`);
|
|
32
|
+
* the terminal shows it under the table with the command for the next rows.
|
|
33
|
+
*/
|
|
34
|
+
page?: CliTablePage;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'list';
|
|
37
|
+
items: string[];
|
|
38
|
+
ordered?: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'json';
|
|
41
|
+
value: any;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'key-value';
|
|
44
|
+
entries: {
|
|
45
|
+
key: string;
|
|
46
|
+
value: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
/** Response envelope returned by structured command execution, containing an exit code and typed outputs. */
|
|
50
|
+
export interface CliStructuredResponse {
|
|
51
|
+
/** Process exit code (0 for success, non-zero for errors). */
|
|
52
|
+
exitCode: number;
|
|
53
|
+
/** Ordered list of typed output blocks. */
|
|
54
|
+
outputs: CliStructuredOutput[];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=cli-structured-response.d.ts.map
|