@nestbox-ai/cli 1.0.27 → 1.0.29
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/commands/image/apiUtils.d.ts +9 -0
- package/dist/commands/image/apiUtils.js +19 -0
- package/dist/commands/image/apiUtils.js.map +1 -0
- package/dist/commands/image/display.d.ts +2 -0
- package/dist/commands/image/display.js +56 -0
- package/dist/commands/image/display.js.map +1 -0
- package/dist/commands/image/index.d.ts +3 -0
- package/dist/commands/image/index.js +10 -0
- package/dist/commands/image/index.js.map +1 -0
- package/dist/commands/image/list.d.ts +2 -0
- package/dist/commands/image/list.js +71 -0
- package/dist/commands/image/list.js.map +1 -0
- package/dist/commands/image.d.ts +6 -1
- package/dist/commands/image.js +15 -109
- package/dist/commands/image.js.map +1 -1
- package/dist/commands/project/add.js +1 -1
- package/dist/commands/project/add.js.map +1 -1
- package/dist/commands/project/index.d.ts +2 -2
- package/dist/commands/project/index.js +1 -1
- package/dist/commands/project/index.js.map +1 -1
- package/dist/commands/project/list.js +1 -1
- package/dist/commands/project/list.js.map +1 -1
- package/dist/commands/project/use.js +1 -1
- package/dist/commands/project/use.js.map +1 -1
- package/dist/commands/{projects.d.ts → project.d.ts} +0 -1
- package/dist/commands/{projects.js → project.js} +1 -7
- package/dist/commands/project.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/project.js +2 -2
- package/dist/utils/project.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/image/apiUtils.ts +22 -0
- package/src/commands/image/display.ts +52 -0
- package/src/commands/image/index.ts +4 -0
- package/src/commands/image/list.ts +61 -0
- package/src/commands/image.ts +17 -105
- package/src/commands/project/add.ts +1 -1
- package/src/commands/project/index.ts +2 -2
- package/src/commands/project/list.ts +1 -1
- package/src/commands/project/use.ts +1 -1
- package/src/commands/{projects.ts → project.ts} +0 -9
- package/src/index.ts +1 -1
- package/src/utils/project.ts +1 -1
- package/test/{projects.test.ts → project.test.ts} +1 -1
- package/dist/commands/project/config.js.map +0 -1
- package/dist/commands/projects.js.map +0 -1
- /package/dist/{commands/project → utils}/config.d.ts +0 -0
- /package/dist/{commands/project → utils}/config.js +0 -0
- /package/src/{commands/project → utils}/config.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MiscellaneousApi, ProjectsApi } from "@nestbox-ai/admin";
|
|
2
|
+
export interface ApiInstances {
|
|
3
|
+
miscellaneousApi: MiscellaneousApi;
|
|
4
|
+
projectsApi: ProjectsApi;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Create API instances with current authentication using setupAuthAndConfig
|
|
8
|
+
*/
|
|
9
|
+
export declare function createApis(): ApiInstances;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createApis = createApis;
|
|
4
|
+
const admin_1 = require("@nestbox-ai/admin");
|
|
5
|
+
const api_1 = require("../../utils/api");
|
|
6
|
+
/**
|
|
7
|
+
* Create API instances with current authentication using setupAuthAndConfig
|
|
8
|
+
*/
|
|
9
|
+
function createApis() {
|
|
10
|
+
const authResult = (0, api_1.setupAuthAndConfig)();
|
|
11
|
+
if (!authResult) {
|
|
12
|
+
throw new Error('No authentication token found. Please log in first.');
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
miscellaneousApi: new admin_1.MiscellaneousApi(authResult.configuration),
|
|
16
|
+
projectsApi: new admin_1.ProjectsApi(authResult.configuration),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=apiUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiUtils.js","sourceRoot":"","sources":["../../../src/commands/image/apiUtils.ts"],"names":[],"mappings":";;AAWA,gCAUC;AArBD,6CAAiF;AACjF,yCAAsE;AAOtE;;GAEG;AACH,SAAgB,UAAU;IACxB,MAAM,UAAU,GAAG,IAAA,wBAAkB,GAAE,CAAC;IACxC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO;QACL,gBAAgB,EAAE,IAAI,wBAAgB,CAAC,UAAU,CAAC,aAAa,CAAC;QAChE,WAAW,EAAE,IAAI,mBAAW,CAAC,UAAU,CAAC,aAAa,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.statusMappings = void 0;
|
|
7
|
+
exports.displayImagesTable = displayImagesTable;
|
|
8
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
// Helper function to display images in a table
|
|
11
|
+
function displayImagesTable(images) {
|
|
12
|
+
const table = new cli_table3_1.default({
|
|
13
|
+
head: [
|
|
14
|
+
chalk_1.default.white.bold('Name'),
|
|
15
|
+
chalk_1.default.white.bold('Type'),
|
|
16
|
+
chalk_1.default.white.bold('License'),
|
|
17
|
+
chalk_1.default.white.bold('Category'),
|
|
18
|
+
chalk_1.default.white.bold('Pricing'),
|
|
19
|
+
chalk_1.default.white.bold('Source')
|
|
20
|
+
],
|
|
21
|
+
style: {
|
|
22
|
+
head: [],
|
|
23
|
+
border: []
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
// Status mappings (kept from original code for potential future use)
|
|
27
|
+
const statusMappings = {
|
|
28
|
+
'Job Scheduled': 'Scheduled',
|
|
29
|
+
'Job Executed': 'Ready',
|
|
30
|
+
'Job in Progress': 'Initializing',
|
|
31
|
+
'Job Failed': 'Failed',
|
|
32
|
+
'Deleting': 'Deleting',
|
|
33
|
+
};
|
|
34
|
+
// Add rows to the table
|
|
35
|
+
images.forEach((image) => {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
table.push([
|
|
38
|
+
image.name || 'N/A',
|
|
39
|
+
image.type || 'N/A',
|
|
40
|
+
((_a = image.metadata) === null || _a === void 0 ? void 0 : _a.License) || 'N/A',
|
|
41
|
+
((_b = image.metadata) === null || _b === void 0 ? void 0 : _b.Type) || 'N/A',
|
|
42
|
+
((_c = image.metadata) === null || _c === void 0 ? void 0 : _c.Pricing) || 'N/A',
|
|
43
|
+
image.source || 'N/A'
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
console.log(table.toString());
|
|
47
|
+
}
|
|
48
|
+
// Export status mappings for potential future use
|
|
49
|
+
exports.statusMappings = {
|
|
50
|
+
'Job Scheduled': 'Scheduled',
|
|
51
|
+
'Job Executed': 'Ready',
|
|
52
|
+
'Job in Progress': 'Initializing',
|
|
53
|
+
'Job Failed': 'Failed',
|
|
54
|
+
'Deleting': 'Deleting',
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../../src/commands/image/display.ts"],"names":[],"mappings":";;;;;;AAIA,gDAsCC;AA1CD,4DAA+B;AAC/B,kDAA0B;AAE1B,+CAA+C;AAC/C,SAAgB,kBAAkB,CAAC,MAAa;IAC9C,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,IAAI,EAAE;YACJ,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YACxB,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3B,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;YAC5B,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3B,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3B;QACD,KAAK,EAAE;YACL,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,EAAE;SACX;KACF,CAAC,CAAC;IAEH,qEAAqE;IACrE,MAAM,cAAc,GAA2B;QAC7C,eAAe,EAAE,WAAW;QAC5B,cAAc,EAAE,OAAO;QACvB,iBAAiB,EAAE,cAAc;QACjC,YAAY,EAAE,QAAQ;QACtB,UAAU,EAAE,UAAU;KACvB,CAAC;IAEF,wBAAwB;IACxB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;;QAC5B,KAAK,CAAC,IAAI,CAAC;YACT,KAAK,CAAC,IAAI,IAAI,KAAK;YACnB,KAAK,CAAC,IAAI,IAAI,KAAK;YACnB,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,OAAO,KAAI,KAAK;YAChC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,KAAI,KAAK;YAC7B,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,OAAO,KAAI,KAAK;YAChC,KAAK,CAAC,MAAM,IAAI,KAAK;SACtB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,kDAAkD;AACrC,QAAA,cAAc,GAA2B;IACpD,eAAe,EAAE,WAAW;IAC5B,cAAc,EAAE,OAAO;IACvB,iBAAiB,EAAE,cAAc;IACjC,YAAY,EAAE,QAAQ;IACtB,UAAU,EAAE,UAAU;CACvB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.statusMappings = exports.displayImagesTable = exports.createApis = void 0;
|
|
4
|
+
// Export utility functions that might be used by other modules
|
|
5
|
+
var apiUtils_1 = require("./apiUtils");
|
|
6
|
+
Object.defineProperty(exports, "createApis", { enumerable: true, get: function () { return apiUtils_1.createApis; } });
|
|
7
|
+
var display_1 = require("./display");
|
|
8
|
+
Object.defineProperty(exports, "displayImagesTable", { enumerable: true, get: function () { return display_1.displayImagesTable; } });
|
|
9
|
+
Object.defineProperty(exports, "statusMappings", { enumerable: true, get: function () { return display_1.statusMappings; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/image/index.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,uCAAwC;AAA/B,sGAAA,UAAU,OAAA;AAEnB,qCAA+D;AAAtD,6GAAA,kBAAkB,OAAA;AAAE,yGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerListCommand = registerListCommand;
|
|
16
|
+
const error_1 = require("../../utils/error");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const ora_1 = __importDefault(require("ora"));
|
|
19
|
+
const project_1 = require("../../utils/project");
|
|
20
|
+
const apiUtils_1 = require("./apiUtils");
|
|
21
|
+
const display_1 = require("./display");
|
|
22
|
+
function registerListCommand(imageCommand) {
|
|
23
|
+
imageCommand
|
|
24
|
+
.command('list')
|
|
25
|
+
.description('List images for a project')
|
|
26
|
+
.option('--project <projectId>', 'Project ID or name (defaults to the current project)')
|
|
27
|
+
.action((options) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
const apis = (0, apiUtils_1.createApis)();
|
|
30
|
+
// Execute with token refresh support
|
|
31
|
+
yield (0, error_1.withTokenRefresh)(() => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a;
|
|
33
|
+
// Resolve project using the shared utility
|
|
34
|
+
const project = yield (0, project_1.resolveProject)(apis.projectsApi, options);
|
|
35
|
+
const spinner = (0, ora_1.default)(`Listing images for project ${project.name}...`).start();
|
|
36
|
+
try {
|
|
37
|
+
const response = yield apis.miscellaneousApi.miscellaneousControllerGetData();
|
|
38
|
+
spinner.succeed('Successfully retrieved images');
|
|
39
|
+
const images = response.data;
|
|
40
|
+
if (!images || images.length === 0) {
|
|
41
|
+
console.log(chalk_1.default.yellow(`No images found for project ${project.name}.`));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Create and display the table
|
|
45
|
+
(0, display_1.displayImagesTable)(images);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
spinner.fail('Failed to retrieve images');
|
|
49
|
+
if (error.response && error.response.status === 401) {
|
|
50
|
+
console.error(chalk_1.default.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
51
|
+
}
|
|
52
|
+
else if (error.response) {
|
|
53
|
+
console.error(chalk_1.default.red('API Error:'), ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error.response && error.response.status === 401) {
|
|
63
|
+
console.error(chalk_1.default.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/image/list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAQA,kDAoDC;AA3DD,6CAAqD;AACrD,kDAA0B;AAC1B,8CAAsB;AACtB,iDAAqD;AACrD,yCAAwC;AACxC,uCAA+C;AAE/C,SAAgB,mBAAmB,CAAC,YAAqB;IACvD,YAAY;SACT,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,2BAA2B,CAAC;SACxC,MAAM,CAAC,uBAAuB,EAAE,sDAAsD,CAAC;SACvF,MAAM,CAAC,CAAO,OAAO,EAAE,EAAE;QACxB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAA,qBAAU,GAAE,CAAC;YAE1B,qCAAqC;YACrC,MAAM,IAAA,wBAAgB,EACpB,GAAS,EAAE;;gBACT,2CAA2C;gBAC3C,MAAM,OAAO,GAAG,MAAM,IAAA,wBAAc,EAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;gBAEhE,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,8BAA8B,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;gBAE7E,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,8BAA8B,EAAE,CAAC;oBAE9E,OA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AC,sFAAsF,CAAC,CAAC,CAAC;YACnH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AACP,CAAC"}
|
package/dist/commands/image.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* Register all image-related commands
|
|
4
|
+
*/
|
|
2
5
|
export declare function registerImageCommands(program: Command): void;
|
|
6
|
+
export { displayImagesTable, statusMappings } from "./image/display";
|
|
7
|
+
export type { ApiInstances } from "./image/apiUtils";
|
package/dist/commands/image.js
CHANGED
|
@@ -1,115 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.statusMappings = exports.displayImagesTable = void 0;
|
|
15
4
|
exports.registerImageCommands = registerImageCommands;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const project_1 = require("../utils/project");
|
|
21
|
-
const api_1 = require("../utils/api");
|
|
5
|
+
const list_1 = require("./image/list");
|
|
6
|
+
/**
|
|
7
|
+
* Register all image-related commands
|
|
8
|
+
*/
|
|
22
9
|
function registerImageCommands(program) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const projectsApi = new admin_1.ProjectsApi(configuration);
|
|
30
|
-
const imageCommand = program.command('image').description('Manage Nestbox images');
|
|
31
|
-
// LIST command
|
|
32
|
-
imageCommand
|
|
33
|
-
.command('list')
|
|
34
|
-
.description('List images for a project')
|
|
35
|
-
.option('--project <projectId>', 'Project ID or name (defaults to the current project)')
|
|
36
|
-
.action((options) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
var _a;
|
|
38
|
-
try {
|
|
39
|
-
// Resolve project using the shared utility
|
|
40
|
-
const project = yield (0, project_1.resolveProject)(projectsApi, options);
|
|
41
|
-
const spinner = (0, ora_1.default)(`Listing images for project ${project.name}...`).start();
|
|
42
|
-
try {
|
|
43
|
-
const response = yield miscellaneousApi.miscellaneousControllerGetData();
|
|
44
|
-
spinner.succeed('Successfully retrieved images');
|
|
45
|
-
const images = response.data;
|
|
46
|
-
if (!images || images.length === 0) {
|
|
47
|
-
console.log(chalk_1.default.yellow(`No images found for project ${project.name}.`));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
// Create and display the table
|
|
51
|
-
displayImagesTable(images);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
spinner.fail('Failed to retrieve images');
|
|
55
|
-
if (error.response && error.response.status === 401) {
|
|
56
|
-
console.error(chalk_1.default.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
57
|
-
}
|
|
58
|
-
else if (error.response) {
|
|
59
|
-
console.error(chalk_1.default.red('API Error:'), ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error');
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (error.response && error.response.status === 401) {
|
|
68
|
-
console.error(chalk_1.default.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
console.error(chalk_1.default.red('Error:'), error.message || 'Unknown error');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
// Additional commands can be added here following the same pattern
|
|
76
|
-
}
|
|
77
|
-
// Helper function to display images in a table
|
|
78
|
-
function displayImagesTable(images) {
|
|
79
|
-
const table = new cli_table3_1.default({
|
|
80
|
-
head: [
|
|
81
|
-
chalk_1.default.white.bold('Name'),
|
|
82
|
-
chalk_1.default.white.bold('Type'),
|
|
83
|
-
chalk_1.default.white.bold('License'),
|
|
84
|
-
chalk_1.default.white.bold('Category'),
|
|
85
|
-
chalk_1.default.white.bold('Pricing'),
|
|
86
|
-
chalk_1.default.white.bold('Source')
|
|
87
|
-
],
|
|
88
|
-
style: {
|
|
89
|
-
head: [],
|
|
90
|
-
border: []
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
// Status mappings (kept from original code for potential future use)
|
|
94
|
-
const statusMappings = {
|
|
95
|
-
'Job Scheduled': 'Scheduled',
|
|
96
|
-
'Job Executed': 'Ready',
|
|
97
|
-
'Job in Progress': 'Initializing',
|
|
98
|
-
'Job Failed': 'Failed',
|
|
99
|
-
'Deleting': 'Deleting',
|
|
100
|
-
};
|
|
101
|
-
// Add rows to the table
|
|
102
|
-
images.forEach((image) => {
|
|
103
|
-
var _a, _b, _c;
|
|
104
|
-
table.push([
|
|
105
|
-
image.name || 'N/A',
|
|
106
|
-
image.type || 'N/A',
|
|
107
|
-
((_a = image.metadata) === null || _a === void 0 ? void 0 : _a.License) || 'N/A',
|
|
108
|
-
((_b = image.metadata) === null || _b === void 0 ? void 0 : _b.Type) || 'N/A',
|
|
109
|
-
((_c = image.metadata) === null || _c === void 0 ? void 0 : _c.Pricing) || 'N/A',
|
|
110
|
-
image.source || 'N/A'
|
|
111
|
-
]);
|
|
112
|
-
});
|
|
113
|
-
console.log(table.toString());
|
|
10
|
+
// Create the main image command
|
|
11
|
+
const imageCommand = program
|
|
12
|
+
.command("image")
|
|
13
|
+
.description("Manage Nestbox images");
|
|
14
|
+
// Register all subcommands
|
|
15
|
+
(0, list_1.registerListCommand)(imageCommand);
|
|
114
16
|
}
|
|
17
|
+
// Export image utilities for use in other modules
|
|
18
|
+
var display_1 = require("./image/display");
|
|
19
|
+
Object.defineProperty(exports, "displayImagesTable", { enumerable: true, get: function () { return display_1.displayImagesTable; } });
|
|
20
|
+
Object.defineProperty(exports, "statusMappings", { enumerable: true, get: function () { return display_1.statusMappings; } });
|
|
115
21
|
//# sourceMappingURL=image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/commands/image.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/commands/image.ts"],"names":[],"mappings":";;;AAMA,sDAQC;AAbD,uCAAmD;AAEnD;;GAEG;AACH,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,gCAAgC;IAChC,MAAM,YAAY,GAAG,OAAO;SACzB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAExC,2BAA2B;IAC3B,IAAA,0BAAmB,EAAC,YAAY,CAAC,CAAC;AACpC,CAAC;AAED,kDAAkD;AAClD,2CAGyB;AAFvB,6GAAA,kBAAkB,OAAA;AAClB,yGAAA,cAAc,OAAA"}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerAddCommand = registerAddCommand;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const config_1 = require("
|
|
8
|
+
const config_1 = require("../../utils/config");
|
|
9
9
|
const apiUtils_1 = require("./apiUtils");
|
|
10
10
|
function registerAddCommand(projectCommand) {
|
|
11
11
|
projectCommand
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/commands/project/add.ts"],"names":[],"mappings":";;;;;AAKA,gDAyCC;AA7CD,kDAA0B;AAC1B
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/commands/project/add.ts"],"names":[],"mappings":";;;;;AAKA,gDAyCC;AA7CD,kDAA0B;AAC1B,+CAA2E;AAC3E,yCAAwC;AAExC,SAAgB,kBAAkB,CAAC,cAAuB;IACxD,cAAc;SACX,OAAO,CAAC,4BAA4B,CAAC;SACrC,WAAW,CAAC,mCAAmC,CAAC;SAChD,MAAM,CAAC,CAAC,WAAmB,EAAE,KAAc,EAAE,EAAE;QAC9C,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAA,qBAAU,GAAE,CAAC;YAE1B,MAAM,MAAM,GAAG,IAAA,0BAAiB,GAAE,CAAC;YACnC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;YAExC,sCAAsC;YACtC,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,YAAY,WAAW,mBAAmB,CAAC,CAAC,CAAC;gBACrE,OAAO;YACT,CAAC;YACD,oCAAoC;YACpC,IAAI,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,KAAK,mBAAmB,CAAC,CAAC,CAAC;gBAC7D,OAAO;YACT,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;gBACrC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,kBAAkB,WAAW,iBAAiB,KAAK,GAAG,CAAC,CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;gBAC3C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,kBAAkB,WAAW,GAAG,CAAC,CAAC,CAAC;YAC7D,CAAC;YAED,kDAAkD;YAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBAC7B,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAG,WAAW,CAAC;gBACtC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,QAAQ,WAAW,0BAA0B,CAAC,CAAC,CAAC;YAC1E,CAAC;YAED,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC9G,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { readNestboxConfig, writeNestboxConfig, getNestboxConfigPath } from "
|
|
2
|
-
export type { ProjectsConfig, NestboxConfig } from "
|
|
1
|
+
export { readNestboxConfig, writeNestboxConfig, getNestboxConfigPath } from "../../utils/config";
|
|
2
|
+
export type { ProjectsConfig, NestboxConfig } from "../../utils/config";
|
|
3
3
|
export { createApis } from "./apiUtils";
|
|
4
4
|
export type { ApiInstances } from "./apiUtils";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createApis = exports.getNestboxConfigPath = exports.writeNestboxConfig = exports.readNestboxConfig = void 0;
|
|
4
4
|
// Export utility functions that might be used by other modules
|
|
5
|
-
var config_1 = require("
|
|
5
|
+
var config_1 = require("../../utils/config");
|
|
6
6
|
Object.defineProperty(exports, "readNestboxConfig", { enumerable: true, get: function () { return config_1.readNestboxConfig; } });
|
|
7
7
|
Object.defineProperty(exports, "writeNestboxConfig", { enumerable: true, get: function () { return config_1.writeNestboxConfig; } });
|
|
8
8
|
Object.defineProperty(exports, "getNestboxConfigPath", { enumerable: true, get: function () { return config_1.getNestboxConfigPath; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/project/index.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/project/index.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,6CAAiG;AAAxF,2GAAA,iBAAiB,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAAE,8GAAA,oBAAoB,OAAA;AAEpE,uCAAwC;AAA/B,sGAAA,UAAU,OAAA"}
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.registerListCommand = registerListCommand;
|
|
16
16
|
const error_1 = require("../../utils/error");
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
-
const config_1 = require("
|
|
18
|
+
const config_1 = require("../../utils/config");
|
|
19
19
|
const apiUtils_1 = require("./apiUtils");
|
|
20
20
|
function registerListCommand(projectCommand) {
|
|
21
21
|
projectCommand
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/project/list.ts"],"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AE,CAAC;YACpB,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC9D,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1C,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,eAAe,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.registerUseCommand = registerUseCommand;
|
|
16
16
|
const error_1 = require("../../utils/error");
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
-
const config_1 = require("
|
|
18
|
+
const config_1 = require("../../utils/config");
|
|
19
19
|
const apiUtils_1 = require("./apiUtils");
|
|
20
20
|
function registerUseCommand(projectCommand) {
|
|
21
21
|
projectCommand
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../../src/commands/project/use.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,gDAsCC;AA3CD,6CAAqD;AACrD,kDAA0B;AAC1B
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../../src/commands/project/use.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,gDAsCC;AA3CD,6CAAqD;AACrD,kDAA0B;AAC1B,+CAA2E;AAC3E,yCAAwC;AAExC,SAAgB,kBAAkB,CAAC,cAAuB;IACxD,cAAc;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CAAC,CAAC;YAC1C,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,gCAAgC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5E,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,gCAAgC,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -3,4 +3,3 @@ import { Command } from "commander";
|
|
|
3
3
|
* Register all project-related commands
|
|
4
4
|
*/
|
|
5
5
|
export declare function registerProjectCommands(program: Command): void;
|
|
6
|
-
export { readNestboxConfig, writeNestboxConfig, getNestboxConfigPath, type ProjectsConfig, type NestboxConfig } from "./project";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNestboxConfigPath = exports.writeNestboxConfig = exports.readNestboxConfig = void 0;
|
|
4
3
|
exports.registerProjectCommands = registerProjectCommands;
|
|
5
4
|
const use_1 = require("./project/use");
|
|
6
5
|
const add_1 = require("./project/add");
|
|
@@ -18,9 +17,4 @@ function registerProjectCommands(program) {
|
|
|
18
17
|
(0, add_1.registerAddCommand)(projectCommand);
|
|
19
18
|
(0, list_1.registerListCommand)(projectCommand);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
var project_1 = require("./project");
|
|
23
|
-
Object.defineProperty(exports, "readNestboxConfig", { enumerable: true, get: function () { return project_1.readNestboxConfig; } });
|
|
24
|
-
Object.defineProperty(exports, "writeNestboxConfig", { enumerable: true, get: function () { return project_1.writeNestboxConfig; } });
|
|
25
|
-
Object.defineProperty(exports, "getNestboxConfigPath", { enumerable: true, get: function () { return project_1.getNestboxConfigPath; } });
|
|
26
|
-
//# sourceMappingURL=projects.js.map
|
|
20
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/commands/project.ts"],"names":[],"mappings":";;AAQA,0DAUC;AAjBD,uCAAmD;AACnD,uCAAmD;AACnD,yCAAqD;AAErD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAAgB;IACtD,kCAAkC;IAClC,MAAM,cAAc,GAAG,OAAO;SAC3B,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAE1C,2BAA2B;IAC3B,IAAA,wBAAkB,EAAC,cAAc,CAAC,CAAC;IACnC,IAAA,wBAAkB,EAAC,cAAc,CAAC,CAAC;IACnC,IAAA,0BAAmB,EAAC,cAAc,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const commander_1 = require("commander");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const auth_1 = require("./commands/auth");
|
|
8
|
-
const
|
|
8
|
+
const project_1 = require("./commands/project");
|
|
9
9
|
const compute_1 = require("./commands/compute");
|
|
10
10
|
const document_1 = require("./commands/document");
|
|
11
11
|
const image_1 = require("./commands/image");
|
|
@@ -20,7 +20,7 @@ program
|
|
|
20
20
|
.version(packageJson.version);
|
|
21
21
|
// Register command groups
|
|
22
22
|
(0, auth_1.registerAuthCommands)(program);
|
|
23
|
-
(0,
|
|
23
|
+
(0, project_1.registerProjectCommands)(program);
|
|
24
24
|
(0, compute_1.registerComputeProgram)(program);
|
|
25
25
|
(0, agent_1.registerAgentCommands)(program);
|
|
26
26
|
(0, document_1.registerDocumentCommands)(program);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,2BAAkC;AAClC,+BAA4B;AAC5B,0CAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,2BAAkC;AAClC,+BAA4B;AAC5B,0CAAuD;AACvD,gDAA6D;AAC7D,gDAA4D;AAC5D,kDAA+D;AAC/D,4CAAyD;AACzD,4CAAyD;AAEzD,iCAAiC;AACjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAEzF,wBAAwB;AACxB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,sCAAsC,CAAC;KACnD,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEhC,0BAA0B;AAC1B,IAAA,2BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,iCAAuB,EAAC,OAAO,CAAC,CAAC;AACjC,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;AAChC,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;AAC/B,IAAA,mCAAwB,EAAC,OAAO,CAAC,CAAC;AAClC,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAC;AAE/B,+BAA+B;AAC/B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,+CAA+C;AAC/C,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":";;;;;AAcA,oDAEC;AAED,8CAWC;AAED,gDAGC;AAlCD,4CAAoB;AACpB,gDAAwB;AAYxB,8CAA8C;AAC9C,SAAgB,oBAAoB;IAChC,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,iBAAiB;IAC7B,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;IAC1C,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC5B,CAAC;AAED,SAAgB,kBAAkB,CAAC,MAAqB;IACpD,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;IAC1C,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/utils/project.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.resolveProject = resolveProject;
|
|
16
16
|
const ora_1 = __importDefault(require("ora"));
|
|
17
|
-
const
|
|
17
|
+
const config_1 = require("./config");
|
|
18
18
|
function resolveProject(projectsApi, options) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a, _b, _c;
|
|
@@ -51,7 +51,7 @@ function resolveProject(projectsApi, options) {
|
|
|
51
51
|
spinner.succeed(`Using project: ${projectName} (ID: ${projectId})`);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
const config = (0,
|
|
54
|
+
const config = (0, config_1.readNestboxConfig)();
|
|
55
55
|
const defaultProjectName = (_c = config.projects) === null || _c === void 0 ? void 0 : _c.default;
|
|
56
56
|
if (!defaultProjectName) {
|
|
57
57
|
if (spinner)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAsBA,wCAiEC;AAtFD,8CAAsB;AACtB,
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/utils/project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAsBA,wCAiEC;AAtFD,8CAAsB;AACtB,qCAA6C;AAoB7C,SAAsB,cAAc,CAChC,WAAwB,EACxB,OAA8B;;;QAEhC,8CAA8C;QAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,KAAK,KAAK,CAAC;QAClD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,aAAG,EAAC,sBAAsB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAEzE,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,+BAA+B,EAAE,CAAC;YAC7E,MAAM,WAAW,GAAG,MAAA,MAAA,gBAAgB,CAAC,IAAI,0CAAE,IAAI,0CAAE,QAAQ,CAAC;YAE1D,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC7C,IAAI,OAAO;oBAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;gBAChD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC;YAED,IAAI,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;YAChC,IAAI,WAAW,GAAG,EAAE,CAAC;YAErB,IAAI,SAAS,E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BAE9E,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,IAAI,OAAO;wBAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,kBAAkB,cAAc,CAAC,CAAC;oBAChF,MAAM,IAAI,KAAK,CAAC,oBAAoB,kBAAkB,cAAc,CAAC,CAAC;gBACxE,CAAC;gBAED,SAAS,GAAG,cAAc,CAAC,EAAE,CAAC;gBAC9B,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC;gBAClC,IAAI,OAAO;oBAAE,OAAO,CAAC,OAAO,CAAC,0BAA0B,WAAW,SAAS,SAAS,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAC5C,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Configuration, MiscellaneousApi, ProjectsApi } from "@nestbox-ai/admin";
|
|
2
|
+
import { setupAuthAndConfig, type AuthResult } from "../../utils/api";
|
|
3
|
+
|
|
4
|
+
export interface ApiInstances {
|
|
5
|
+
miscellaneousApi: MiscellaneousApi;
|
|
6
|
+
projectsApi: ProjectsApi;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create API instances with current authentication using setupAuthAndConfig
|
|
11
|
+
*/
|
|
12
|
+
export function createApis(): ApiInstances {
|
|
13
|
+
const authResult = setupAuthAndConfig();
|
|
14
|
+
if (!authResult) {
|
|
15
|
+
throw new Error('No authentication token found. Please log in first.');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
miscellaneousApi: new MiscellaneousApi(authResult.configuration),
|
|
20
|
+
projectsApi: new ProjectsApi(authResult.configuration),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Table from "cli-table3";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
// Helper function to display images in a table
|
|
5
|
+
export function displayImagesTable(images: any[]): void {
|
|
6
|
+
const table = new Table({
|
|
7
|
+
head: [
|
|
8
|
+
chalk.white.bold('Name'),
|
|
9
|
+
chalk.white.bold('Type'),
|
|
10
|
+
chalk.white.bold('License'),
|
|
11
|
+
chalk.white.bold('Category'),
|
|
12
|
+
chalk.white.bold('Pricing'),
|
|
13
|
+
chalk.white.bold('Source')
|
|
14
|
+
],
|
|
15
|
+
style: {
|
|
16
|
+
head: [],
|
|
17
|
+
border: []
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Status mappings (kept from original code for potential future use)
|
|
22
|
+
const statusMappings: Record<string, string> = {
|
|
23
|
+
'Job Scheduled': 'Scheduled',
|
|
24
|
+
'Job Executed': 'Ready',
|
|
25
|
+
'Job in Progress': 'Initializing',
|
|
26
|
+
'Job Failed': 'Failed',
|
|
27
|
+
'Deleting': 'Deleting',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Add rows to the table
|
|
31
|
+
images.forEach((image: any) => {
|
|
32
|
+
table.push([
|
|
33
|
+
image.name || 'N/A',
|
|
34
|
+
image.type || 'N/A',
|
|
35
|
+
image.metadata?.License || 'N/A',
|
|
36
|
+
image.metadata?.Type || 'N/A',
|
|
37
|
+
image.metadata?.Pricing || 'N/A',
|
|
38
|
+
image.source || 'N/A'
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
console.log(table.toString());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Export status mappings for potential future use
|
|
46
|
+
export const statusMappings: Record<string, string> = {
|
|
47
|
+
'Job Scheduled': 'Scheduled',
|
|
48
|
+
'Job Executed': 'Ready',
|
|
49
|
+
'Job in Progress': 'Initializing',
|
|
50
|
+
'Job Failed': 'Failed',
|
|
51
|
+
'Deleting': 'Deleting',
|
|
52
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { withTokenRefresh } from "../../utils/error";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import ora from "ora";
|
|
5
|
+
import { resolveProject } from "../../utils/project";
|
|
6
|
+
import { createApis } from "./apiUtils";
|
|
7
|
+
import { displayImagesTable } from "./display";
|
|
8
|
+
|
|
9
|
+
export function registerListCommand(imageCommand: Command): void {
|
|
10
|
+
imageCommand
|
|
11
|
+
.command('list')
|
|
12
|
+
.description('List images for a project')
|
|
13
|
+
.option('--project <projectId>', 'Project ID or name (defaults to the current project)')
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
try {
|
|
16
|
+
const apis = createApis();
|
|
17
|
+
|
|
18
|
+
// Execute with token refresh support
|
|
19
|
+
await withTokenRefresh(
|
|
20
|
+
async () => {
|
|
21
|
+
// Resolve project using the shared utility
|
|
22
|
+
const project = await resolveProject(apis.projectsApi, options);
|
|
23
|
+
|
|
24
|
+
const spinner = ora(`Listing images for project ${project.name}...`).start();
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const response = await apis.miscellaneousApi.miscellaneousControllerGetData();
|
|
28
|
+
|
|
29
|
+
spinner.succeed('Successfully retrieved images');
|
|
30
|
+
|
|
31
|
+
const images: any = response.data;
|
|
32
|
+
|
|
33
|
+
if (!images || images.length === 0) {
|
|
34
|
+
console.log(chalk.yellow(`No images found for project ${project.name}.`));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Create and display the table
|
|
39
|
+
displayImagesTable(images);
|
|
40
|
+
|
|
41
|
+
} catch (error: any) {
|
|
42
|
+
spinner.fail('Failed to retrieve images');
|
|
43
|
+
if (error.response && error.response.status === 401) {
|
|
44
|
+
console.error(chalk.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
45
|
+
} else if (error.response) {
|
|
46
|
+
console.error(chalk.red('API Error:'), error.response.data?.message || 'Unknown error');
|
|
47
|
+
} else {
|
|
48
|
+
console.error(chalk.red('Error:'), error.message || 'Unknown error');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
} catch (error: any) {
|
|
54
|
+
if (error.response && error.response.status === 401) {
|
|
55
|
+
console.error(chalk.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
56
|
+
} else {
|
|
57
|
+
console.error(chalk.red('Error:'), error.message || 'Unknown error');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
package/src/commands/image.ts
CHANGED
|
@@ -1,110 +1,22 @@
|
|
|
1
|
-
import { Command } from
|
|
2
|
-
import
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import Table from 'cli-table3';
|
|
5
|
-
import { MiscellaneousApi, ProjectsApi } from '@nestbox-ai/admin';
|
|
6
|
-
import { resolveProject } from '../utils/project';
|
|
7
|
-
import { setupAuthAndConfig } from '../utils/api';
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { registerListCommand } from "./image/list";
|
|
8
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Register all image-related commands
|
|
6
|
+
*/
|
|
9
7
|
export function registerImageCommands(program: Command): void {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
8
|
+
// Create the main image command
|
|
9
|
+
const imageCommand = program
|
|
10
|
+
.command("image")
|
|
11
|
+
.description("Manage Nestbox images");
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const projectsApi = new ProjectsApi(configuration);
|
|
19
|
-
|
|
20
|
-
const imageCommand = program.command('image').description('Manage Nestbox images');
|
|
21
|
-
|
|
22
|
-
// LIST command
|
|
23
|
-
imageCommand
|
|
24
|
-
.command('list')
|
|
25
|
-
.description('List images for a project')
|
|
26
|
-
.option('--project <projectId>', 'Project ID or name (defaults to the current project)')
|
|
27
|
-
.action(async (options) => {
|
|
28
|
-
try {
|
|
29
|
-
// Resolve project using the shared utility
|
|
30
|
-
const project = await resolveProject(projectsApi, options);
|
|
31
|
-
|
|
32
|
-
const spinner = ora(`Listing images for project ${project.name}...`).start();
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const response = await miscellaneousApi.miscellaneousControllerGetData();
|
|
36
|
-
|
|
37
|
-
spinner.succeed('Successfully retrieved images');
|
|
38
|
-
|
|
39
|
-
const images: any = response.data;
|
|
40
|
-
|
|
41
|
-
if (!images || images.length === 0) {
|
|
42
|
-
console.log(chalk.yellow(`No images found for project ${project.name}.`));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Create and display the table
|
|
47
|
-
displayImagesTable(images);
|
|
48
|
-
|
|
49
|
-
} catch (error: any) {
|
|
50
|
-
spinner.fail('Failed to retrieve images');
|
|
51
|
-
if (error.response && error.response.status === 401) {
|
|
52
|
-
console.error(chalk.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
53
|
-
} else if (error.response) {
|
|
54
|
-
console.error(chalk.red('API Error:'), error.response.data?.message || 'Unknown error');
|
|
55
|
-
} else {
|
|
56
|
-
console.error(chalk.red('Error:'), error.message || 'Unknown error');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} catch (error: any) {
|
|
60
|
-
if (error.response && error.response.status === 401) {
|
|
61
|
-
console.error(chalk.red('Authentication token has expired. Please login again using "nestbox login <domain>".'));
|
|
62
|
-
} else {
|
|
63
|
-
console.error(chalk.red('Error:'), error.message || 'Unknown error');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Additional commands can be added here following the same pattern
|
|
13
|
+
// Register all subcommands
|
|
14
|
+
registerListCommand(imageCommand);
|
|
69
15
|
}
|
|
70
16
|
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
chalk.white.bold('License'),
|
|
78
|
-
chalk.white.bold('Category'),
|
|
79
|
-
chalk.white.bold('Pricing'),
|
|
80
|
-
chalk.white.bold('Source')
|
|
81
|
-
],
|
|
82
|
-
style: {
|
|
83
|
-
head: [],
|
|
84
|
-
border: []
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Status mappings (kept from original code for potential future use)
|
|
89
|
-
const statusMappings: Record<string, string> = {
|
|
90
|
-
'Job Scheduled': 'Scheduled',
|
|
91
|
-
'Job Executed': 'Ready',
|
|
92
|
-
'Job in Progress': 'Initializing',
|
|
93
|
-
'Job Failed': 'Failed',
|
|
94
|
-
'Deleting': 'Deleting',
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Add rows to the table
|
|
98
|
-
images.forEach((image: any) => {
|
|
99
|
-
table.push([
|
|
100
|
-
image.name || 'N/A',
|
|
101
|
-
image.type || 'N/A',
|
|
102
|
-
image.metadata?.License || 'N/A',
|
|
103
|
-
image.metadata?.Type || 'N/A',
|
|
104
|
-
image.metadata?.Pricing || 'N/A',
|
|
105
|
-
image.source || 'N/A'
|
|
106
|
-
]);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
console.log(table.toString());
|
|
110
|
-
}
|
|
17
|
+
// Export image utilities for use in other modules
|
|
18
|
+
export {
|
|
19
|
+
displayImagesTable,
|
|
20
|
+
statusMappings
|
|
21
|
+
} from "./image/display";
|
|
22
|
+
export type { ApiInstances } from "./image/apiUtils";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import { readNestboxConfig, writeNestboxConfig } from "
|
|
3
|
+
import { readNestboxConfig, writeNestboxConfig } from "../../utils/config";
|
|
4
4
|
import { createApis } from "./apiUtils";
|
|
5
5
|
|
|
6
6
|
export function registerAddCommand(projectCommand: Command): void {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Export utility functions that might be used by other modules
|
|
2
|
-
export { readNestboxConfig, writeNestboxConfig, getNestboxConfigPath } from "
|
|
3
|
-
export type { ProjectsConfig, NestboxConfig } from "
|
|
2
|
+
export { readNestboxConfig, writeNestboxConfig, getNestboxConfigPath } from "../../utils/config";
|
|
3
|
+
export type { ProjectsConfig, NestboxConfig } from "../../utils/config";
|
|
4
4
|
export { createApis } from "./apiUtils";
|
|
5
5
|
export type { ApiInstances } from "./apiUtils";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { withTokenRefresh } from "../../utils/error";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { readNestboxConfig } from "
|
|
4
|
+
import { readNestboxConfig } from "../../utils/config";
|
|
5
5
|
import { createApis } from "./apiUtils";
|
|
6
6
|
|
|
7
7
|
export function registerListCommand(projectCommand: Command): void {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { withTokenRefresh } from "../../utils/error";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { readNestboxConfig, writeNestboxConfig } from "
|
|
4
|
+
import { readNestboxConfig, writeNestboxConfig } from "../../utils/config";
|
|
5
5
|
import { createApis } from "./apiUtils";
|
|
6
6
|
|
|
7
7
|
export function registerUseCommand(projectCommand: Command): void {
|
|
@@ -17,12 +17,3 @@ export function registerProjectCommands(program: Command): void {
|
|
|
17
17
|
registerAddCommand(projectCommand);
|
|
18
18
|
registerListCommand(projectCommand);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
// Export project utilities for use in other modules
|
|
22
|
-
export {
|
|
23
|
-
readNestboxConfig,
|
|
24
|
-
writeNestboxConfig,
|
|
25
|
-
getNestboxConfigPath,
|
|
26
|
-
type ProjectsConfig,
|
|
27
|
-
type NestboxConfig
|
|
28
|
-
} from "./project";
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Command } from 'commander';
|
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { registerAuthCommands } from './commands/auth';
|
|
7
|
-
import { registerProjectCommands } from './commands/
|
|
7
|
+
import { registerProjectCommands } from './commands/project';
|
|
8
8
|
import { registerComputeProgram } from './commands/compute';
|
|
9
9
|
import { registerDocumentCommands } from './commands/document';
|
|
10
10
|
import { registerImageCommands } from './commands/image';
|
package/src/utils/project.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import { registerProjectCommands } from '../src/commands/
|
|
3
|
+
import { registerProjectCommands } from '../src/commands/project';
|
|
4
4
|
|
|
5
5
|
describe('Project Commands', () => {
|
|
6
6
|
let program: Command;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/project/config.ts"],"names":[],"mappings":";;;;;AAcA,oDAEC;AAED,8CAWC;AAED,gDAGC;AAlCD,4CAAoB;AACpB,gDAAwB;AAYxB,8CAA8C;AAC9C,SAAgB,oBAAoB;IAChC,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,iBAAiB;IAC7B,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;IAC1C,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC5B,CAAC;AAED,SAAgB,kBAAkB,CAAC,MAAqB;IACpD,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;IAC1C,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/commands/projects.ts"],"names":[],"mappings":";;;AAQA,0DAUC;AAjBD,uCAAmD;AACnD,uCAAmD;AACnD,yCAAqD;AAErD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAAgB;IACtD,kCAAkC;IAClC,MAAM,cAAc,GAAG,OAAO;SAC3B,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAE1C,2BAA2B;IAC3B,IAAA,wBAAkB,EAAC,cAAc,CAAC,CAAC;IACnC,IAAA,wBAAkB,EAAC,cAAc,CAAC,CAAC;IACnC,IAAA,0BAAmB,EAAC,cAAc,CAAC,CAAC;AACtC,CAAC;AAED,oDAAoD;AACpD,qCAMmB;AALjB,4GAAA,iBAAiB,OAAA;AACjB,6GAAA,kBAAkB,OAAA;AAClB,+GAAA,oBAAoB,OAAA"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|