@descix/cli 1.0.21 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/descix.js +14 -122
- package/lib/commands/appInit.js +15 -29
- package/lib/commands/auth.js +10 -1
- package/lib/commands/config.js +4 -6
- package/lib/commands/corpus.js +1 -1
- package/lib/commands/health.js +18 -44
- package/lib/commands/init.js +2 -3
- package/lib/commands/kb.js +1 -1
- package/lib/commands/microservice-restart.js +28 -33
- package/lib/commands/status.js +4 -6
- package/lib/verb-invokes.generated.json +2 -3
- package/lib/workspace-config.js +167 -153
- package/lib/workspace-identity.js +6 -13
- package/package.json +2 -2
- package/lib/workspace-utils.js +0 -106
package/lib/workspace-utils.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workspace Utilities
|
|
3
|
-
*
|
|
4
|
-
* Helper functions for workspace mode detection and path resolution.
|
|
5
|
-
* v2.1 workspace format only (env.platform / env.products).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import path from 'path';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Detect workspace mode from workspace.json configuration (v2.1 format)
|
|
12
|
-
* @param {Object} workspace - Parsed workspace.json
|
|
13
|
-
* @returns {'single_app' | 'single_community' | 'multi_community'}
|
|
14
|
-
*/
|
|
15
|
-
export function detectWorkspaceMode(workspace) {
|
|
16
|
-
// Explicit mode declaration
|
|
17
|
-
if (workspace.mode) {
|
|
18
|
-
return workspace.mode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// v2.1 format: infer from env.platform + env.products
|
|
22
|
-
if (workspace.env?.platform) {
|
|
23
|
-
const productCount = Array.isArray(workspace.env.products) ? workspace.env.products.length : 0;
|
|
24
|
-
// Platform + products = multi-community workspace
|
|
25
|
-
return productCount > 0 ? 'multi_community' : 'single_app';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Fallback for empty/initialized workspace using defaultContext
|
|
29
|
-
if (workspace.defaultContext?.communityId && workspace.defaultContext?.appId) {
|
|
30
|
-
return 'single_app';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
throw new Error('Unable to determine workspace mode from configuration. Expected v2.1 format (env.platform / env.products).');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Resolve local path to Drive path based on workspace mode
|
|
38
|
-
* @param {Object} workspace - Workspace configuration
|
|
39
|
-
* @param {string} localPath - Path relative to workspace root
|
|
40
|
-
* @returns {string} Path relative to user's base_folder_id
|
|
41
|
-
*/
|
|
42
|
-
export function resolveToDrivePath(workspace, localPath) {
|
|
43
|
-
const mode = detectWorkspaceMode(workspace);
|
|
44
|
-
|
|
45
|
-
// Normalize local path (remove leading ./)
|
|
46
|
-
const normalizedLocal = localPath.replace(/^\.\//, '');
|
|
47
|
-
|
|
48
|
-
switch (mode) {
|
|
49
|
-
case 'single_app': {
|
|
50
|
-
const communityId = workspace.defaultContext?.communityId || workspace.env?.platform?.communityId;
|
|
51
|
-
const appId = workspace.defaultContext?.appId || workspace.env?.platform?.appId;
|
|
52
|
-
|
|
53
|
-
if (!communityId || !appId) {
|
|
54
|
-
throw new Error('Missing community_id or app_id for single_app mode path resolution');
|
|
55
|
-
}
|
|
56
|
-
return `${communityId}/${appId}/${normalizedLocal}`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
case 'single_community': {
|
|
60
|
-
const commId = workspace.defaultContext?.communityId || workspace.env?.platform?.communityId;
|
|
61
|
-
if (!commId) {
|
|
62
|
-
throw new Error('Missing community_id for single_community mode path resolution');
|
|
63
|
-
}
|
|
64
|
-
return `${commId}/${normalizedLocal}`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
case 'multi_community':
|
|
68
|
-
// Workspace root = base folder
|
|
69
|
-
return normalizedLocal;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Resolve Drive path to local path based on workspace mode
|
|
75
|
-
* @param {Object} workspace - Workspace configuration
|
|
76
|
-
* @param {string} drivePath - Path relative to user's base_folder_id
|
|
77
|
-
* @returns {string} Path relative to workspace root
|
|
78
|
-
*/
|
|
79
|
-
export function resolveToLocalPath(workspace, drivePath) {
|
|
80
|
-
const mode = detectWorkspaceMode(workspace);
|
|
81
|
-
|
|
82
|
-
switch (mode) {
|
|
83
|
-
case 'single_app': {
|
|
84
|
-
const communityId = workspace.defaultContext?.communityId || workspace.env?.platform?.communityId;
|
|
85
|
-
const appId = workspace.defaultContext?.appId || workspace.env?.platform?.appId;
|
|
86
|
-
|
|
87
|
-
const appPrefix = `${communityId}/${appId}/`;
|
|
88
|
-
if (drivePath.startsWith(appPrefix)) {
|
|
89
|
-
return './' + drivePath.slice(appPrefix.length);
|
|
90
|
-
}
|
|
91
|
-
throw new Error(`Drive path '${drivePath}' does not match workspace app '${appId}'`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
case 'single_community': {
|
|
95
|
-
const commId = workspace.defaultContext?.communityId || workspace.env?.platform?.communityId;
|
|
96
|
-
const commPrefix = `${commId}/`;
|
|
97
|
-
if (drivePath.startsWith(commPrefix)) {
|
|
98
|
-
return './' + drivePath.slice(commPrefix.length);
|
|
99
|
-
}
|
|
100
|
-
throw new Error(`Drive path '${drivePath}' does not match workspace community '${commId}'`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
case 'multi_community':
|
|
104
|
-
return './' + drivePath;
|
|
105
|
-
}
|
|
106
|
-
}
|