@nestbox-ai/cli 1.0.28 → 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/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/test/{projects.test.ts → project.test.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 @@
|
|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AAK;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,M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CAAC,YAAY,CAAC,EAAE,CAAA,MAAA,KAAK,CAAC,QAAQ,CAAC,IAAI,0CAAE,OAAO,KAAI,eAAe,CAAC,CAAC;oBAC1F,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC,CAAC;oBACvE,CAAC;gBACH,CAAC;YACH,CAAC,CAAA,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACpD,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,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"}
|
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";
|
|
File without changes
|