@qodalis/cli-server-node 1.0.0-beta.4 → 1.0.0-beta.6
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 +315 -37
- package/dist/src/abstractions/index.d.ts +1 -1
- package/dist/src/abstractions/index.d.ts.map +1 -1
- package/dist/src/abstractions/index.js +4 -1
- package/dist/src/abstractions/index.js.map +1 -1
- package/dist/src/auth/cli-server-auth-gate.d.ts +31 -0
- package/dist/src/auth/cli-server-auth-gate.d.ts.map +1 -0
- package/dist/src/auth/cli-server-auth-gate.js +118 -0
- package/dist/src/auth/cli-server-auth-gate.js.map +1 -0
- package/dist/src/auth/cli-server-auth.d.ts +147 -0
- package/dist/src/auth/cli-server-auth.d.ts.map +1 -0
- package/dist/src/auth/cli-server-auth.js +143 -0
- package/dist/src/auth/cli-server-auth.js.map +1 -0
- package/dist/src/auth/index.d.ts +4 -0
- package/dist/src/auth/index.d.ts.map +1 -0
- package/dist/src/auth/index.js +19 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/ws-upgrade-auth.d.ts +30 -0
- package/dist/src/auth/ws-upgrade-auth.d.ts.map +1 -0
- package/dist/src/auth/ws-upgrade-auth.js +49 -0
- package/dist/src/auth/ws-upgrade-auth.js.map +1 -0
- package/dist/src/controllers/cli-controller.d.ts +8 -1
- package/dist/src/controllers/cli-controller.d.ts.map +1 -1
- package/dist/src/controllers/cli-controller.js +78 -3
- package/dist/src/controllers/cli-controller.js.map +1 -1
- package/dist/src/controllers/cli-version-controller.d.ts +16 -1
- package/dist/src/controllers/cli-version-controller.d.ts.map +1 -1
- package/dist/src/controllers/cli-version-controller.js +18 -5
- package/dist/src/controllers/cli-version-controller.js.map +1 -1
- package/dist/src/controllers/filesystem-controller.d.ts.map +1 -1
- package/dist/src/controllers/filesystem-controller.js +51 -7
- package/dist/src/controllers/filesystem-controller.js.map +1 -1
- package/dist/src/create-cli-server.d.ts +76 -5
- package/dist/src/create-cli-server.d.ts.map +1 -1
- package/dist/src/create-cli-server.js +88 -20
- package/dist/src/create-cli-server.js.map +1 -1
- package/dist/src/extensions/cli-builder.d.ts +19 -1
- package/dist/src/extensions/cli-builder.d.ts.map +1 -1
- package/dist/src/extensions/cli-builder.js +26 -0
- package/dist/src/extensions/cli-builder.js.map +1 -1
- package/dist/src/filesystem/filesystem-options.d.ts +1 -0
- package/dist/src/filesystem/filesystem-options.d.ts.map +1 -1
- package/dist/src/index.d.ts +5 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +18 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/cli-server-command-descriptor.d.ts +2 -1
- package/dist/src/models/cli-server-command-descriptor.d.ts.map +1 -1
- package/dist/src/models/cli-server-output.d.ts +1 -22
- package/dist/src/models/cli-server-output.d.ts.map +1 -1
- package/dist/src/models/cli-server-response.d.ts +1 -5
- package/dist/src/models/cli-server-response.d.ts.map +1 -1
- package/dist/src/processors/cli-base64-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-base64-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-base64-command-processor.js +3 -0
- package/dist/src/processors/cli-base64-command-processor.js.map +1 -1
- package/dist/src/processors/cli-echo-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-echo-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-echo-command-processor.js +1 -0
- package/dist/src/processors/cli-echo-command-processor.js.map +1 -1
- package/dist/src/processors/cli-hash-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-hash-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-hash-command-processor.js +1 -0
- package/dist/src/processors/cli-hash-command-processor.js.map +1 -1
- package/dist/src/processors/cli-http-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-http-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-http-command-processor.js +85 -6
- package/dist/src/processors/cli-http-command-processor.js.map +1 -1
- package/dist/src/processors/cli-status-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-status-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-status-command-processor.js +1 -0
- package/dist/src/processors/cli-status-command-processor.js.map +1 -1
- package/dist/src/processors/cli-system-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-system-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-system-command-processor.js +1 -0
- package/dist/src/processors/cli-system-command-processor.js.map +1 -1
- package/dist/src/server.js +20 -6
- package/dist/src/server.js.map +1 -1
- package/dist/src/services/cli-command-executor-service.d.ts +24 -3
- package/dist/src/services/cli-command-executor-service.d.ts.map +1 -1
- package/dist/src/services/cli-command-executor-service.js +35 -3
- package/dist/src/services/cli-command-executor-service.js.map +1 -1
- package/dist/src/services/cli-command-registry.d.ts +11 -0
- package/dist/src/services/cli-command-registry.d.ts.map +1 -1
- package/dist/src/services/cli-command-registry.js +5 -0
- package/dist/src/services/cli-command-registry.js.map +1 -1
- package/dist/src/services/cli-event-socket-manager.d.ts +42 -0
- package/dist/src/services/cli-event-socket-manager.d.ts.map +1 -1
- package/dist/src/services/cli-event-socket-manager.js +139 -27
- package/dist/src/services/cli-event-socket-manager.js.map +1 -1
- package/dist/src/services/cli-log-socket-manager.d.ts +17 -1
- package/dist/src/services/cli-log-socket-manager.d.ts.map +1 -1
- package/dist/src/services/cli-log-socket-manager.js +59 -12
- package/dist/src/services/cli-log-socket-manager.js.map +1 -1
- package/dist/src/services/cli-response-builder.d.ts +9 -0
- package/dist/src/services/cli-response-builder.d.ts.map +1 -1
- package/dist/src/services/cli-response-builder.js +1 -0
- package/dist/src/services/cli-response-builder.js.map +1 -1
- package/dist/src/services/cli-shell-options.d.ts +107 -0
- package/dist/src/services/cli-shell-options.d.ts.map +1 -0
- package/dist/src/services/cli-shell-options.js +139 -0
- package/dist/src/services/cli-shell-options.js.map +1 -0
- package/dist/src/services/cli-shell-session-manager.d.ts +86 -2
- package/dist/src/services/cli-shell-session-manager.d.ts.map +1 -1
- package/dist/src/services/cli-shell-session-manager.js +493 -73
- package/dist/src/services/cli-shell-session-manager.js.map +1 -1
- package/dist/src/services/index.d.ts +2 -1
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +5 -1
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/process-tree.d.ts +38 -0
- package/dist/src/services/process-tree.d.ts.map +1 -0
- package/dist/src/services/process-tree.js +249 -0
- package/dist/src/services/process-tree.js.map +1 -0
- package/dist/src/services/session-bound-sockets.d.ts +45 -0
- package/dist/src/services/session-bound-sockets.d.ts.map +1 -0
- package/dist/src/services/session-bound-sockets.js +129 -0
- package/dist/src/services/session-bound-sockets.js.map +1 -0
- package/dist/src/utils/logger.d.ts +11 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +13 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/package.json +12 -3
- package/dist/src/controllers/cli-controller-v2.d.ts +0 -4
- package/dist/src/controllers/cli-controller-v2.d.ts.map +0 -1
- package/dist/src/controllers/cli-controller-v2.js +0 -46
- package/dist/src/controllers/cli-controller-v2.js.map +0 -1
|
@@ -33,19 +33,31 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolveShellCapabilities = resolveShellCapabilities;
|
|
36
37
|
exports.createCliVersionController = createCliVersionController;
|
|
37
38
|
const express_1 = require("express");
|
|
38
39
|
const os = __importStar(require("os"));
|
|
39
40
|
const SERVER_VERSION = '2.0.0';
|
|
40
|
-
|
|
41
|
+
/** Resolves the shell fields of `/capabilities`. */
|
|
42
|
+
function resolveShellCapabilities(options) {
|
|
43
|
+
return options?.shellCapabilities ? options.shellCapabilities() : { shell: true };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates an Express router for API version discovery and server capabilities.
|
|
47
|
+
* @returns Router with `/versions` and `/capabilities` endpoints.
|
|
48
|
+
*/
|
|
49
|
+
function createCliVersionController(options) {
|
|
41
50
|
const router = (0, express_1.Router)();
|
|
42
|
-
router.get('/
|
|
51
|
+
router.get('/versions', (_req, res) => {
|
|
43
52
|
res.json({
|
|
44
|
-
supportedVersions: [1
|
|
45
|
-
preferredVersion:
|
|
53
|
+
supportedVersions: [1],
|
|
54
|
+
preferredVersion: 1,
|
|
46
55
|
serverVersion: SERVER_VERSION,
|
|
47
56
|
});
|
|
48
57
|
});
|
|
58
|
+
router.get('/version', (_req, res) => {
|
|
59
|
+
res.redirect(301, 'versions');
|
|
60
|
+
});
|
|
49
61
|
router.get('/capabilities', (_req, res) => {
|
|
50
62
|
const detectedOs = os.platform() === 'win32'
|
|
51
63
|
? 'win32'
|
|
@@ -57,10 +69,11 @@ function createCliVersionController() {
|
|
|
57
69
|
? 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
|
|
58
70
|
: '/bin/bash';
|
|
59
71
|
res.json({
|
|
60
|
-
|
|
72
|
+
...resolveShellCapabilities(options),
|
|
61
73
|
os: detectedOs,
|
|
62
74
|
shellPath,
|
|
63
75
|
version: SERVER_VERSION,
|
|
76
|
+
streaming: true,
|
|
64
77
|
});
|
|
65
78
|
});
|
|
66
79
|
return router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-version-controller.js","sourceRoot":"","sources":["../../../src/controllers/cli-version-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cli-version-controller.js","sourceRoot":"","sources":["../../../src/controllers/cli-version-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,4DAEC;AAMD,gEAqCC;AA/DD,qCAAiC;AACjC,uCAAyB;AAGzB,MAAM,cAAc,GAAG,OAAO,CAAC;AAa/B,oDAAoD;AACpD,SAAgB,wBAAwB,CAAC,OAA6B;IAClE,OAAO,OAAO,EAAE,iBAAiB,CAA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cAAc;YACvB,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/filesystem-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AAEpD,OAAO,EACH,oBAAoB,EAMvB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"filesystem-controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/filesystem-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AAEpD,OAAO,EACH,oBAAoB,EAMvB,MAAM,uCAAuC,CAAC;AAsB/C;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAmK7E"}
|
|
@@ -7,6 +7,8 @@ exports.createFilesystemRouter = createFilesystemRouter;
|
|
|
7
7
|
const express_1 = require("express");
|
|
8
8
|
const multer_1 = __importDefault(require("multer"));
|
|
9
9
|
const cli_server_plugin_filesystem_1 = require("@qodalis/cli-server-plugin-filesystem");
|
|
10
|
+
const logger_1 = require("../utils/logger");
|
|
11
|
+
const logger = (0, logger_1.createLogger)('FileSystem');
|
|
10
12
|
/**
|
|
11
13
|
* Maps provider errors to appropriate HTTP status codes and sends a JSON error response.
|
|
12
14
|
*/
|
|
@@ -34,10 +36,10 @@ function handleError(err, res) {
|
|
|
34
36
|
function createFilesystemRouter(provider) {
|
|
35
37
|
const router = (0, express_1.Router)();
|
|
36
38
|
const upload = (0, multer_1.default)({ storage: multer_1.default.memoryStorage() });
|
|
37
|
-
// ------------------------------------------------------------------ ls
|
|
38
39
|
router.get('/ls', async (req, res) => {
|
|
39
40
|
try {
|
|
40
41
|
const dirPath = req.query.path;
|
|
42
|
+
logger.debug('ls path=%s', dirPath);
|
|
41
43
|
if (!dirPath) {
|
|
42
44
|
res.status(400).json({ error: 'Missing required query parameter: path' });
|
|
43
45
|
return;
|
|
@@ -46,13 +48,19 @@ function createFilesystemRouter(provider) {
|
|
|
46
48
|
res.json({ entries });
|
|
47
49
|
}
|
|
48
50
|
catch (err) {
|
|
51
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
52
|
+
logger.warn('Failed to ls: %s', err.message ?? err);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
logger.error('Failed to ls: %s', err.message ?? err);
|
|
56
|
+
}
|
|
49
57
|
handleError(err, res);
|
|
50
58
|
}
|
|
51
59
|
});
|
|
52
|
-
// ----------------------------------------------------------------- cat
|
|
53
60
|
router.get('/cat', async (req, res) => {
|
|
54
61
|
try {
|
|
55
62
|
const filePath = req.query.path;
|
|
63
|
+
logger.debug('cat path=%s', filePath);
|
|
56
64
|
if (!filePath) {
|
|
57
65
|
res.status(400).json({ error: 'Missing required query parameter: path' });
|
|
58
66
|
return;
|
|
@@ -61,13 +69,19 @@ function createFilesystemRouter(provider) {
|
|
|
61
69
|
res.json({ content });
|
|
62
70
|
}
|
|
63
71
|
catch (err) {
|
|
72
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
73
|
+
logger.warn('Failed to cat: %s', err.message ?? err);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
logger.error('Failed to cat: %s', err.message ?? err);
|
|
77
|
+
}
|
|
64
78
|
handleError(err, res);
|
|
65
79
|
}
|
|
66
80
|
});
|
|
67
|
-
// ---------------------------------------------------------------- stat
|
|
68
81
|
router.get('/stat', async (req, res) => {
|
|
69
82
|
try {
|
|
70
83
|
const filePath = req.query.path;
|
|
84
|
+
logger.debug('stat path=%s', filePath);
|
|
71
85
|
if (!filePath) {
|
|
72
86
|
res.status(400).json({ error: 'Missing required query parameter: path' });
|
|
73
87
|
return;
|
|
@@ -76,13 +90,19 @@ function createFilesystemRouter(provider) {
|
|
|
76
90
|
res.json(fileStat);
|
|
77
91
|
}
|
|
78
92
|
catch (err) {
|
|
93
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
94
|
+
logger.warn('Failed to stat: %s', err.message ?? err);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
logger.error('Failed to stat: %s', err.message ?? err);
|
|
98
|
+
}
|
|
79
99
|
handleError(err, res);
|
|
80
100
|
}
|
|
81
101
|
});
|
|
82
|
-
// ------------------------------------------------------------ download
|
|
83
102
|
router.get('/download', async (req, res) => {
|
|
84
103
|
try {
|
|
85
104
|
const filePath = req.query.path;
|
|
105
|
+
logger.debug('download path=%s', filePath);
|
|
86
106
|
if (!filePath) {
|
|
87
107
|
res.status(400).json({ error: 'Missing required query parameter: path' });
|
|
88
108
|
return;
|
|
@@ -94,13 +114,19 @@ function createFilesystemRouter(provider) {
|
|
|
94
114
|
stream.pipe(res);
|
|
95
115
|
}
|
|
96
116
|
catch (err) {
|
|
117
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
118
|
+
logger.warn('Failed to download: %s', err.message ?? err);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
logger.error('Failed to download: %s', err.message ?? err);
|
|
122
|
+
}
|
|
97
123
|
handleError(err, res);
|
|
98
124
|
}
|
|
99
125
|
});
|
|
100
|
-
// -------------------------------------------------------------- upload
|
|
101
126
|
router.post('/upload', upload.single('file'), async (req, res) => {
|
|
102
127
|
try {
|
|
103
128
|
const targetPath = req.body?.path;
|
|
129
|
+
logger.debug('upload path=%s', targetPath);
|
|
104
130
|
if (!targetPath) {
|
|
105
131
|
res.status(400).json({ error: 'Missing required field: path' });
|
|
106
132
|
return;
|
|
@@ -113,13 +139,19 @@ function createFilesystemRouter(provider) {
|
|
|
113
139
|
res.json({ path: targetPath, size: req.file.size });
|
|
114
140
|
}
|
|
115
141
|
catch (err) {
|
|
142
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
143
|
+
logger.warn('Failed to upload: %s', err.message ?? err);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
logger.error('Failed to upload: %s', err.message ?? err);
|
|
147
|
+
}
|
|
116
148
|
handleError(err, res);
|
|
117
149
|
}
|
|
118
150
|
});
|
|
119
|
-
// --------------------------------------------------------------- mkdir
|
|
120
151
|
router.post('/mkdir', async (req, res) => {
|
|
121
152
|
try {
|
|
122
153
|
const dirPath = req.body?.path;
|
|
154
|
+
logger.debug('mkdir path=%s', dirPath);
|
|
123
155
|
if (!dirPath) {
|
|
124
156
|
res.status(400).json({ error: 'Missing required field: path' });
|
|
125
157
|
return;
|
|
@@ -128,13 +160,19 @@ function createFilesystemRouter(provider) {
|
|
|
128
160
|
res.json({ path: dirPath });
|
|
129
161
|
}
|
|
130
162
|
catch (err) {
|
|
163
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
164
|
+
logger.warn('Failed to mkdir: %s', err.message ?? err);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
logger.error('Failed to mkdir: %s', err.message ?? err);
|
|
168
|
+
}
|
|
131
169
|
handleError(err, res);
|
|
132
170
|
}
|
|
133
171
|
});
|
|
134
|
-
// ----------------------------------------------------------------- rm
|
|
135
172
|
router.delete('/rm', async (req, res) => {
|
|
136
173
|
try {
|
|
137
174
|
const targetPath = req.query.path;
|
|
175
|
+
logger.debug('rm path=%s', targetPath);
|
|
138
176
|
if (!targetPath) {
|
|
139
177
|
res.status(400).json({ error: 'Missing required query parameter: path' });
|
|
140
178
|
return;
|
|
@@ -143,6 +181,12 @@ function createFilesystemRouter(provider) {
|
|
|
143
181
|
res.json({ deleted: targetPath });
|
|
144
182
|
}
|
|
145
183
|
catch (err) {
|
|
184
|
+
if (err instanceof cli_server_plugin_filesystem_1.PermissionDeniedError) {
|
|
185
|
+
logger.warn('Failed to rm: %s', err.message ?? err);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
logger.error('Failed to rm: %s', err.message ?? err);
|
|
189
|
+
}
|
|
146
190
|
handleError(err, res);
|
|
147
191
|
}
|
|
148
192
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-controller.js","sourceRoot":"","sources":["../../../src/controllers/filesystem-controller.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"filesystem-controller.js","sourceRoot":"","sources":["../../../src/controllers/filesystem-controller.ts"],"names":[],"mappings":";;;;;AAmCA,wDAmKC;AAtMD,qCAAoD;AACpD,oDAA4B;AAC5B,wFAO+C;AAC/C,4CAA+C;AAE/C,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,YAAY,CAAC,CAAC;AAE1C;;GAEG;AACH,SAAS,WAAW,CAAC,GAAY,EAAE,GAAa;IAC5C,IAAI,GAAG,YAAY,gDAAiB,EAAE,CAAC;QACnC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,GAAG,YAAY,oDAAqB,EAAE,CAAC;QAC9C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,GAAG,YAAY,iDAAkB,IAAI,GAAG,YAAY,gDAAiB,EAAE,CAAC;QAC/E,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,GAAG,YAAY,8CAAe,EAAE,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO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AqB,EAAG,GAAa,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACvE,CAAC;YACD,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;QACvD,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,IAA0B,CAAC;YACxD,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YACvC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,wCAAwC,EAAE,CAAC,CAAC;gBAC1E,OAAO;YACX,CAAC;YAED,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YACxC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,GAAG,YAAY,oDAAqB,EAAE,CAAC;gBACvC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAG,GAAa,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACJ,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAG,GAAa,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACpE,CAAC;YACD,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,12 +1,66 @@
|
|
|
1
|
-
import { Express } from 'express';
|
|
1
|
+
import { Express, Router } from 'express';
|
|
2
2
|
import cors from 'cors';
|
|
3
|
-
import { CliCommandRegistry, CliEventSocketManager, CliLogSocketManager } from './services';
|
|
3
|
+
import { CliCommandRegistry, CliCommandExecutorService, CliEventSocketManager, CliLogSocketManager } from './services';
|
|
4
4
|
import { CliBuilder } from './extensions';
|
|
5
|
+
import { ICliServerAuth } from './auth/cli-server-auth';
|
|
6
|
+
import { CliShellOptions } from './services/cli-shell-options';
|
|
7
|
+
/**
|
|
8
|
+
* Generic interface for plugin results that can be auto-mounted.
|
|
9
|
+
* Plugins expose a `prefix` and `router`; some also have a
|
|
10
|
+
* `dashboardPrefix` / `dashboardRouter` pair.
|
|
11
|
+
*/
|
|
12
|
+
export interface MountablePlugin {
|
|
13
|
+
prefix: string;
|
|
14
|
+
router: Router;
|
|
15
|
+
dashboardPrefix?: string;
|
|
16
|
+
dashboardRouter?: Router;
|
|
17
|
+
/**
|
|
18
|
+
* Auth provider exposed by the users plugin. Mounting such a plugin
|
|
19
|
+
* installs it: when `protectServer` is on, every server route and socket
|
|
20
|
+
* then requires a users session.
|
|
21
|
+
*/
|
|
22
|
+
serverAuth?: ICliServerAuth;
|
|
23
|
+
/** Routes that stay public under server protection, as `"METHOD /path"` (e.g. a plugin's login). */
|
|
24
|
+
publicRoutes?: string[];
|
|
25
|
+
}
|
|
26
|
+
/** Options for creating a standalone CLI server instance. */
|
|
5
27
|
export interface CliServerOptions {
|
|
6
28
|
/** Base path for CLI routes. Defaults to '/api/qcli'. */
|
|
7
29
|
basePath?: string;
|
|
8
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* CORS configuration. `true` = permissive (any origin, no credentials),
|
|
32
|
+
* `false` = disabled, or a cors options object. When omitted, CORS is
|
|
33
|
+
* enabled only for `allowedOrigins` (disabled if none are set).
|
|
34
|
+
*/
|
|
9
35
|
cors?: boolean | cors.CorsOptions;
|
|
36
|
+
/**
|
|
37
|
+
* Origins allowed for CORS and WebSocket upgrades (exact match; `http://host:*`
|
|
38
|
+
* matches any port). Every WS upgrade with an `Origin` header is checked.
|
|
39
|
+
*/
|
|
40
|
+
allowedOrigins?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Accept interactive shell WebSocket sessions (default false). When enabled,
|
|
43
|
+
* access is decided by one mode: users plugin mounted (ticket +
|
|
44
|
+
* `shell:execute`), `shell.token`, `shell.authorize` or `shell.allowAnonymous`.
|
|
45
|
+
* With none of them the shell is locked (every connection closed with 4401).
|
|
46
|
+
*/
|
|
47
|
+
enableShell?: boolean;
|
|
48
|
+
/** Remote shell security: access mode, limits, timeouts, cwd, shell binary, environment. */
|
|
49
|
+
shell?: CliShellOptions;
|
|
50
|
+
/**
|
|
51
|
+
* Behind reverse proxies: the number of trusted proxy hops (`true` = 1,
|
|
52
|
+
* `false`/0 = none, the default). The client IP (Express `req.ip`, the
|
|
53
|
+
* shell's per-address limits) is the `X-Forwarded-For` entry at index
|
|
54
|
+
* `len - hops` (with one hop, the rightmost entry, appended by the trusted
|
|
55
|
+
* proxy); the leftmost entry when the list is shorter, the socket address
|
|
56
|
+
* when the header is absent. `X-Forwarded-Proto`/`-Host` are honoured too.
|
|
57
|
+
*/
|
|
58
|
+
trustProxy?: boolean | number;
|
|
59
|
+
/**
|
|
60
|
+
* Auth provider protecting the whole server (e.g. `usersPlugin.serverAuth`).
|
|
61
|
+
* Can also be installed later with `setAuth()` or by `mountPlugin(usersPlugin)`.
|
|
62
|
+
*/
|
|
63
|
+
auth?: ICliServerAuth;
|
|
10
64
|
/** Configure processors via the builder. */
|
|
11
65
|
configure?: (builder: CliBuilder) => void;
|
|
12
66
|
}
|
|
@@ -16,11 +70,28 @@ export interface CliServerOptions {
|
|
|
16
70
|
* Use this for standalone server mode. For integration into an existing
|
|
17
71
|
* Express app, use `createCliController` directly instead.
|
|
18
72
|
*/
|
|
19
|
-
export
|
|
73
|
+
export interface CliServerResult {
|
|
20
74
|
app: Express;
|
|
21
75
|
registry: CliCommandRegistry;
|
|
22
76
|
builder: CliBuilder;
|
|
77
|
+
executor: CliCommandExecutorService;
|
|
23
78
|
eventSocketManager: CliEventSocketManager;
|
|
24
79
|
logSocketManager: CliLogSocketManager;
|
|
25
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Mount a plugin using its built-in prefix.
|
|
82
|
+
* Reads `prefix` and `router` from the plugin result, and optionally
|
|
83
|
+
* `dashboardPrefix` / `dashboardRouter` for plugins that serve a UI.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const result = createCliServer();
|
|
88
|
+
* result.mountPlugin(jobsPlugin);
|
|
89
|
+
* result.mountPlugin(adminPlugin);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
mountPlugin(plugin: MountablePlugin): void;
|
|
93
|
+
/** Installs (or removes) the auth provider protecting server routes and sockets. */
|
|
94
|
+
setAuth(auth: ICliServerAuth | undefined): void;
|
|
95
|
+
}
|
|
96
|
+
export declare function createCliServer(options?: CliServerOptions): CliServerResult;
|
|
26
97
|
//# sourceMappingURL=create-cli-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cli-server.d.ts","sourceRoot":"","sources":["../../src/create-cli-server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"create-cli-server.d.ts","sourceRoot":"","sources":["../../src/create-cli-server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EAAE,cAAc,EAAmD,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,MAAM,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H/E"}
|
|
@@ -9,38 +9,76 @@ const cors_1 = __importDefault(require("cors"));
|
|
|
9
9
|
const services_1 = require("./services");
|
|
10
10
|
const extensions_1 = require("./extensions");
|
|
11
11
|
const cli_controller_1 = require("./controllers/cli-controller");
|
|
12
|
-
const cli_controller_v2_1 = require("./controllers/cli-controller-v2");
|
|
13
12
|
const cli_version_controller_1 = require("./controllers/cli-version-controller");
|
|
14
13
|
const filesystem_controller_1 = require("./controllers/filesystem-controller");
|
|
15
14
|
const cli_server_plugin_filesystem_1 = require("@qodalis/cli-server-plugin-filesystem");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
15
|
+
const cli_server_plugin_data_explorer_1 = require("@qodalis/cli-server-plugin-data-explorer");
|
|
16
|
+
const logger_1 = require("./utils/logger");
|
|
17
|
+
const cli_server_auth_1 = require("./auth/cli-server-auth");
|
|
18
|
+
const cli_server_auth_gate_1 = require("./auth/cli-server-auth-gate");
|
|
19
|
+
const logger = (0, logger_1.createLogger)('Server');
|
|
22
20
|
function createCliServer(options = {}) {
|
|
23
|
-
const { basePath = '/api/qcli', cors: corsOption =
|
|
21
|
+
const { basePath = '/api/qcli', cors: corsOption, configure, allowedOrigins, enableShell = false, shell, trustProxy = false } = options;
|
|
22
|
+
if (shell && !enableShell) {
|
|
23
|
+
logger.warn('shell options are set but enableShell is false: the shell stays disabled');
|
|
24
|
+
}
|
|
24
25
|
const app = (0, express_1.default)();
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const proxyHops = (0, cli_server_auth_1.trustedProxyHops)(trustProxy);
|
|
27
|
+
if (proxyHops > 0) {
|
|
28
|
+
app.set('trust proxy', proxyHops);
|
|
29
|
+
}
|
|
30
|
+
if (corsOption === true) {
|
|
31
|
+
app.use((0, cors_1.default)());
|
|
32
|
+
}
|
|
33
|
+
else if (corsOption && typeof corsOption === 'object') {
|
|
34
|
+
app.use((0, cors_1.default)(corsOption));
|
|
27
35
|
}
|
|
28
|
-
|
|
36
|
+
else if (corsOption === undefined && allowedOrigins && allowedOrigins.length > 0) {
|
|
37
|
+
// Same-origin requests (e.g. the bundled admin dashboard) are always allowed.
|
|
38
|
+
app.use((0, cors_1.default)((req, callback) => {
|
|
39
|
+
const origin = req.headers.origin;
|
|
40
|
+
callback(null, {
|
|
41
|
+
origin: (0, cli_server_auth_1.isOriginAllowed)(origin, allowedOrigins) || (0, cli_server_auth_1.isSameOrigin)(origin, req),
|
|
42
|
+
});
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
app.use(express_1.default.json({ limit: '1mb' }));
|
|
46
|
+
// Render body-parser failures (malformed JSON, too large) as JSON `{ error }`
|
|
47
|
+
app.use((err, _req, res, next) => {
|
|
48
|
+
if (err && (err.type === 'entity.parse.failed' || err.type === 'entity.too.large')) {
|
|
49
|
+
const status = err.type === 'entity.too.large' ? 413 : 400;
|
|
50
|
+
res.status(status).json({ error: status === 413 ? 'request body too large' : 'invalid JSON body' });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
next(err);
|
|
54
|
+
});
|
|
29
55
|
const registry = new services_1.CliCommandRegistry();
|
|
30
56
|
const builder = new extensions_1.CliBuilder(registry);
|
|
57
|
+
// Server-wide auth gate (no-op until an auth provider is installed)
|
|
58
|
+
let serverAuth;
|
|
59
|
+
const publicRoutes = new Set();
|
|
60
|
+
app.use((0, cli_server_auth_gate_1.createServerAuthGate)(() => serverAuth, {
|
|
61
|
+
registry,
|
|
62
|
+
cliPrefixes: Array.from(new Set(['/api/v1/qcli', (0, cli_server_auth_gate_1.normalizePath)(basePath)])),
|
|
63
|
+
publicRoutes,
|
|
64
|
+
}));
|
|
31
65
|
if (configure) {
|
|
32
66
|
configure(builder);
|
|
33
67
|
}
|
|
34
68
|
const executor = new services_1.CliCommandExecutorService(registry);
|
|
69
|
+
const eventSocketManager = new services_1.CliEventSocketManager({ enableShell, shell, allowedOrigins, trustProxy });
|
|
70
|
+
const logSocketManager = new services_1.CliLogSocketManager({ allowedOrigins, trustProxy });
|
|
71
|
+
const shellCapabilities = () => {
|
|
72
|
+
const mode = eventSocketManager.shellAuthMode;
|
|
73
|
+
return mode ? { shell: true, shellAuth: mode } : { shell: false };
|
|
74
|
+
};
|
|
35
75
|
// Version discovery endpoint
|
|
36
|
-
app.use('/api/qcli', (0, cli_version_controller_1.createCliVersionController)());
|
|
76
|
+
app.use('/api/qcli', (0, cli_version_controller_1.createCliVersionController)({ shellCapabilities }));
|
|
37
77
|
// API v1 routes
|
|
38
|
-
app.use('/api/v1/qcli', (0, cli_controller_1.createCliController)(registry, executor));
|
|
39
|
-
// API v2 routes
|
|
40
|
-
app.use('/api/v2/qcli', (0, cli_controller_v2_1.createCliControllerV2)(registry, executor));
|
|
78
|
+
app.use('/api/v1/qcli', (0, cli_controller_1.createCliController)(registry, executor, { shellCapabilities }));
|
|
41
79
|
// Custom basePath fallback (when user overrides the default)
|
|
42
|
-
if (basePath !== '/api/v1/qcli'
|
|
43
|
-
app.use(basePath, (0, cli_controller_1.createCliController)(registry, executor));
|
|
80
|
+
if (basePath !== '/api/v1/qcli') {
|
|
81
|
+
app.use(basePath, (0, cli_controller_1.createCliController)(registry, executor, { shellCapabilities }));
|
|
44
82
|
}
|
|
45
83
|
// Filesystem API — provider-based
|
|
46
84
|
let fsProvider = builder.fileStorageProvider;
|
|
@@ -51,8 +89,38 @@ function createCliServer(options = {}) {
|
|
|
51
89
|
if (fsProvider) {
|
|
52
90
|
app.use('/api/qcli/fs', (0, filesystem_controller_1.createFilesystemRouter)(fsProvider));
|
|
53
91
|
}
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
92
|
+
// Data Explorer API
|
|
93
|
+
const deBuilder = builder.dataExplorerBuilder;
|
|
94
|
+
if (deBuilder && deBuilder.registry.size > 0) {
|
|
95
|
+
const deExecutor = new cli_server_plugin_data_explorer_1.DataExplorerExecutor(deBuilder.registry);
|
|
96
|
+
app.use('/api/qcli/data-explorer', (0, cli_server_plugin_data_explorer_1.createDataExplorerController)(deBuilder.registry, deExecutor));
|
|
97
|
+
}
|
|
98
|
+
logger.info('CLI server created with %d processors', registry.processors.length);
|
|
99
|
+
const setAuth = (auth) => {
|
|
100
|
+
serverAuth = auth;
|
|
101
|
+
eventSocketManager.setAuth(auth);
|
|
102
|
+
logSocketManager.setAuth(auth);
|
|
103
|
+
auth?.attachToServer?.({
|
|
104
|
+
allowedOrigins,
|
|
105
|
+
broadcast: (msg) => eventSocketManager.broadcastMessage(msg),
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
if (options.auth) {
|
|
109
|
+
setAuth(options.auth);
|
|
110
|
+
}
|
|
111
|
+
const mountPlugin = (plugin) => {
|
|
112
|
+
for (const route of plugin.publicRoutes ?? []) {
|
|
113
|
+
const [method, ...rest] = route.trim().split(/\s+/);
|
|
114
|
+
publicRoutes.add(`${method.toUpperCase()} ${(0, cli_server_auth_gate_1.normalizePath)(rest.join(' '))}`);
|
|
115
|
+
}
|
|
116
|
+
if (plugin.serverAuth && plugin.serverAuth !== serverAuth) {
|
|
117
|
+
setAuth(plugin.serverAuth);
|
|
118
|
+
}
|
|
119
|
+
app.use(plugin.prefix, plugin.router);
|
|
120
|
+
if (plugin.dashboardPrefix && plugin.dashboardRouter) {
|
|
121
|
+
app.use(plugin.dashboardPrefix, plugin.dashboardRouter);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return { app, registry, builder, executor, eventSocketManager, logSocketManager, mountPlugin, setAuth };
|
|
57
125
|
}
|
|
58
126
|
//# sourceMappingURL=create-cli-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cli-server.js","sourceRoot":"","sources":["../../src/create-cli-server.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"create-cli-server.js","sourceRoot":"","sources":["../../src/create-cli-server.ts"],"names":[],"mappings":";;;;;AA6GA,0CA6HC;AA1OD,sDAAmD;AACnD,g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IAC1B,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,MAAuB,EAAE,EAAE;QAC5C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACpD,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAA,oCAAa,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;YACxD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YACnD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAC5G,CAAC"}
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import { ICliCommandProcessor, ICliModule } from '../abstractions';
|
|
1
|
+
import { ICliCommandProcessor, ICliModule, IDataExplorerProvider, DataExplorerProviderOptions } from '../abstractions';
|
|
2
2
|
import { FileSystemOptions } from '../filesystem';
|
|
3
3
|
import { IFileStorageProvider } from '@qodalis/cli-server-plugin-filesystem';
|
|
4
|
+
import { DataExplorerBuilder, DataExplorerProviderFactory } from '@qodalis/cli-server-plugin-data-explorer';
|
|
4
5
|
import { CliCommandRegistry } from '../services';
|
|
6
|
+
/**
|
|
7
|
+
* Fluent builder for configuring CLI server processors, modules, filesystem, and data explorer providers.
|
|
8
|
+
* Passed to the `configure` callback in {@link CliServerOptions}.
|
|
9
|
+
*/
|
|
5
10
|
export declare class CliBuilder {
|
|
6
11
|
private readonly _registry;
|
|
7
12
|
private readonly _modules;
|
|
8
13
|
private _fileSystemOptions?;
|
|
9
14
|
private _fileStorageProvider?;
|
|
15
|
+
private _dataExplorerBuilder?;
|
|
10
16
|
constructor(registry: CliCommandRegistry);
|
|
17
|
+
/** Registers a single command processor. */
|
|
11
18
|
addProcessor(processor: ICliCommandProcessor): CliBuilder;
|
|
19
|
+
/** Registers a module and all of its command processors. */
|
|
12
20
|
addModule(module: ICliModule): CliBuilder;
|
|
21
|
+
/** Returns all registered modules. */
|
|
13
22
|
get modules(): ReadonlyArray<ICliModule>;
|
|
23
|
+
/** Configures the filesystem API with path-based access control. */
|
|
14
24
|
addFileSystem(options: FileSystemOptions): CliBuilder;
|
|
25
|
+
/** Returns the underlying command registry. */
|
|
15
26
|
get registry(): CliCommandRegistry;
|
|
27
|
+
/** Sets a custom file storage provider for the filesystem API. */
|
|
16
28
|
setFileStorageProvider(provider: IFileStorageProvider): CliBuilder;
|
|
29
|
+
/** Returns the configured filesystem options, if any. */
|
|
17
30
|
get fileSystemOptions(): FileSystemOptions | undefined;
|
|
31
|
+
/** Returns the configured file storage provider, if any. */
|
|
18
32
|
get fileStorageProvider(): IFileStorageProvider | undefined;
|
|
33
|
+
/** Registers a data explorer provider with its configuration options. */
|
|
34
|
+
addDataExplorerProvider(providerOrFactory: IDataExplorerProvider | DataExplorerProviderFactory, options: DataExplorerProviderOptions): CliBuilder;
|
|
35
|
+
/** Returns the data explorer builder, if any providers have been registered. */
|
|
36
|
+
get dataExplorerBuilder(): DataExplorerBuilder | undefined;
|
|
19
37
|
}
|
|
20
38
|
//# sourceMappingURL=cli-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-builder.d.ts","sourceRoot":"","sources":["../../../src/extensions/cli-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-builder.d.ts","sourceRoot":"","sources":["../../../src/extensions/cli-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACvH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAC5G,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;GAGG;AACH,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,OAAO,CAAC,oBAAoB,CAAC,CAAuB;IACpD,OAAO,CAAC,oBAAoB,CAAC,CAAsB;gBAEvC,QAAQ,EAAE,kBAAkB;IAIxC,4CAA4C;IAC5C,YAAY,CAAC,SAAS,EAAE,oBAAoB,GAAG,UAAU;IAKzD,4DAA4D;IAC5D,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU;IAQzC,sCAAsC;IACtC,IAAI,OAAO,IAAI,aAAa,CAAC,UAAU,CAAC,CAEvC;IAED,oEAAoE;IACpE,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU;IAKrD,+CAA+C;IAC/C,IAAI,QAAQ,IAAI,kBAAkB,CAEjC;IAED,kEAAkE;IAClE,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,UAAU;IAKlE,yDAAyD;IACzD,IAAI,iBAAiB,IAAI,iBAAiB,GAAG,SAAS,CAErD;IAED,4DAA4D;IAC5D,IAAI,mBAAmB,IAAI,oBAAoB,GAAG,SAAS,CAE1D;IAED,yEAAyE;IACzE,uBAAuB,CACnB,iBAAiB,EAAE,qBAAqB,GAAG,2BAA2B,EACtE,OAAO,EAAE,2BAA2B,GACrC,UAAU;IAQb,gFAAgF;IAChF,IAAI,mBAAmB,IAAI,mBAAmB,GAAG,SAAS,CAEzD;CACJ"}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CliBuilder = void 0;
|
|
4
|
+
const cli_server_plugin_data_explorer_1 = require("@qodalis/cli-server-plugin-data-explorer");
|
|
5
|
+
/**
|
|
6
|
+
* Fluent builder for configuring CLI server processors, modules, filesystem, and data explorer providers.
|
|
7
|
+
* Passed to the `configure` callback in {@link CliServerOptions}.
|
|
8
|
+
*/
|
|
4
9
|
class CliBuilder {
|
|
5
10
|
_registry;
|
|
6
11
|
_modules = [];
|
|
7
12
|
_fileSystemOptions;
|
|
8
13
|
_fileStorageProvider;
|
|
14
|
+
_dataExplorerBuilder;
|
|
9
15
|
constructor(registry) {
|
|
10
16
|
this._registry = registry;
|
|
11
17
|
}
|
|
18
|
+
/** Registers a single command processor. */
|
|
12
19
|
addProcessor(processor) {
|
|
13
20
|
this._registry.register(processor);
|
|
14
21
|
return this;
|
|
15
22
|
}
|
|
23
|
+
/** Registers a module and all of its command processors. */
|
|
16
24
|
addModule(module) {
|
|
17
25
|
this._modules.push(module);
|
|
18
26
|
for (const processor of module.processors) {
|
|
@@ -20,26 +28,44 @@ class CliBuilder {
|
|
|
20
28
|
}
|
|
21
29
|
return this;
|
|
22
30
|
}
|
|
31
|
+
/** Returns all registered modules. */
|
|
23
32
|
get modules() {
|
|
24
33
|
return this._modules;
|
|
25
34
|
}
|
|
35
|
+
/** Configures the filesystem API with path-based access control. */
|
|
26
36
|
addFileSystem(options) {
|
|
27
37
|
this._fileSystemOptions = options;
|
|
28
38
|
return this;
|
|
29
39
|
}
|
|
40
|
+
/** Returns the underlying command registry. */
|
|
30
41
|
get registry() {
|
|
31
42
|
return this._registry;
|
|
32
43
|
}
|
|
44
|
+
/** Sets a custom file storage provider for the filesystem API. */
|
|
33
45
|
setFileStorageProvider(provider) {
|
|
34
46
|
this._fileStorageProvider = provider;
|
|
35
47
|
return this;
|
|
36
48
|
}
|
|
49
|
+
/** Returns the configured filesystem options, if any. */
|
|
37
50
|
get fileSystemOptions() {
|
|
38
51
|
return this._fileSystemOptions;
|
|
39
52
|
}
|
|
53
|
+
/** Returns the configured file storage provider, if any. */
|
|
40
54
|
get fileStorageProvider() {
|
|
41
55
|
return this._fileStorageProvider;
|
|
42
56
|
}
|
|
57
|
+
/** Registers a data explorer provider with its configuration options. */
|
|
58
|
+
addDataExplorerProvider(providerOrFactory, options) {
|
|
59
|
+
if (!this._dataExplorerBuilder) {
|
|
60
|
+
this._dataExplorerBuilder = new cli_server_plugin_data_explorer_1.DataExplorerBuilder();
|
|
61
|
+
}
|
|
62
|
+
this._dataExplorerBuilder.addProvider(providerOrFactory, options);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/** Returns the data explorer builder, if any providers have been registered. */
|
|
66
|
+
get dataExplorerBuilder() {
|
|
67
|
+
return this._dataExplorerBuilder;
|
|
68
|
+
}
|
|
43
69
|
}
|
|
44
70
|
exports.CliBuilder = CliBuilder;
|
|
45
71
|
//# sourceMappingURL=cli-builder.js.map
|