@quantum-hub/qhubctl 1.1.2 → 1.1.3
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/dev.js +3 -1
- package/bin/run.js +1 -1
- package/dist/client/kqh/apis/ServicePlatformApplicationsApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformApplicationsApi.js +9 -46
- package/dist/client/kqh/apis/ServicePlatformDashboardApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformDashboardApi.js +5 -42
- package/dist/client/kqh/apis/ServicePlatformDataPoolsApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformDataPoolsApi.js +11 -48
- package/dist/client/kqh/apis/ServicePlatformJobsApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformJobsApi.js +9 -46
- package/dist/client/kqh/apis/ServicePlatformMarketplaceApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformMarketplaceApi.js +5 -42
- package/dist/client/kqh/apis/ServicePlatformMeteringAPIApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformMeteringAPIApi.js +5 -42
- package/dist/client/kqh/apis/ServicePlatformServicesApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformServicesApi.js +34 -71
- package/dist/client/kqh/apis/ServicePlatformSubscriptionsApi.d.ts +2 -2
- package/dist/client/kqh/apis/ServicePlatformSubscriptionsApi.js +7 -44
- package/dist/client/kqh/apis/TaxonomiesApi.d.ts +2 -2
- package/dist/client/kqh/apis/TaxonomiesApi.js +12 -49
- package/dist/client/kqh/apis/index.d.ts +9 -9
- package/dist/client/kqh/apis/index.js +9 -25
- package/dist/client/kqh/index.d.ts +3 -3
- package/dist/client/kqh/index.js +3 -19
- package/dist/client/kqh/models/AccessTokenDto.js +5 -12
- package/dist/client/kqh/models/AmountMajorDto.js +4 -10
- package/dist/client/kqh/models/ApiDto.d.ts +2 -2
- package/dist/client/kqh/models/ApiDto.js +13 -20
- package/dist/client/kqh/models/ApiOverviewDto.d.ts +1 -1
- package/dist/client/kqh/models/ApiOverviewDto.js +10 -17
- package/dist/client/kqh/models/ApplicationDto.js +5 -12
- package/dist/client/kqh/models/BuildJobDto.d.ts +1 -1
- package/dist/client/kqh/models/BuildJobDto.js +9 -16
- package/dist/client/kqh/models/CpuConfiguration.d.ts +1 -1
- package/dist/client/kqh/models/CpuConfiguration.js +7 -13
- package/dist/client/kqh/models/CreateApplicationRequest.js +4 -10
- package/dist/client/kqh/models/CreateDataPoolRequest.js +4 -10
- package/dist/client/kqh/models/CreateExternalServicePricingPlanRequest.d.ts +1 -1
- package/dist/client/kqh/models/CreateExternalServicePricingPlanRequest.js +8 -15
- package/dist/client/kqh/models/CreateJobRequest.d.ts +1 -1
- package/dist/client/kqh/models/CreateJobRequest.js +9 -15
- package/dist/client/kqh/models/CreateManagedServicePricingPlanRequest.js +6 -13
- package/dist/client/kqh/models/CreateProductRequest.js +4 -10
- package/dist/client/kqh/models/CreateSubscriptionRequest.js +4 -10
- package/dist/client/kqh/models/CreateWorkflowServiceRequest.js +4 -10
- package/dist/client/kqh/models/DataPoolDto.d.ts +3 -3
- package/dist/client/kqh/models/DataPoolDto.js +21 -28
- package/dist/client/kqh/models/DataPoolRef.js +4 -10
- package/dist/client/kqh/models/DataSourceDescriptorDto.d.ts +1 -1
- package/dist/client/kqh/models/DataSourceDescriptorDto.js +8 -15
- package/dist/client/kqh/models/FileDto.js +4 -10
- package/dist/client/kqh/models/FileSource.d.ts +1 -1
- package/dist/client/kqh/models/FileSource.js +4 -10
- package/dist/client/kqh/models/GpuConfiguration.d.ts +1 -1
- package/dist/client/kqh/models/GpuConfiguration.js +8 -15
- package/dist/client/kqh/models/JobDto.d.ts +2 -2
- package/dist/client/kqh/models/JobDto.js +13 -20
- package/dist/client/kqh/models/JobOverviewDto.d.ts +1 -1
- package/dist/client/kqh/models/JobOverviewDto.js +8 -15
- package/dist/client/kqh/models/MemoryConfiguration.d.ts +1 -1
- package/dist/client/kqh/models/MemoryConfiguration.js +7 -13
- package/dist/client/kqh/models/MeteringRequest.js +4 -10
- package/dist/client/kqh/models/MeteringResponse.js +4 -10
- package/dist/client/kqh/models/MonthAmountDto.d.ts +2 -2
- package/dist/client/kqh/models/MonthAmountDto.js +10 -16
- package/dist/client/kqh/models/OwnerDto.js +4 -10
- package/dist/client/kqh/models/PageDataPoolDto.d.ts +3 -3
- package/dist/client/kqh/models/PageDataPoolDto.js +13 -19
- package/dist/client/kqh/models/PageableObject.d.ts +1 -1
- package/dist/client/kqh/models/PageableObject.js +7 -13
- package/dist/client/kqh/models/PricingPlanDto.d.ts +1 -1
- package/dist/client/kqh/models/PricingPlanDto.js +8 -15
- package/dist/client/kqh/models/ProductAmountDto.d.ts +1 -1
- package/dist/client/kqh/models/ProductAmountDto.js +7 -13
- package/dist/client/kqh/models/ProductDto.js +5 -12
- package/dist/client/kqh/models/ProductGroupDto.d.ts +2 -2
- package/dist/client/kqh/models/ProductGroupDto.js +10 -16
- package/dist/client/kqh/models/ProductUsageDto.js +4 -10
- package/dist/client/kqh/models/RegistrySource.d.ts +1 -1
- package/dist/client/kqh/models/RegistrySource.js +7 -13
- package/dist/client/kqh/models/RepositorySource.d.ts +1 -1
- package/dist/client/kqh/models/RepositorySource.js +7 -13
- package/dist/client/kqh/models/ResourceConfiguration.js +10 -16
- package/dist/client/kqh/models/ReviewDto.js +5 -12
- package/dist/client/kqh/models/RuntimeConfiguration.js +5 -12
- package/dist/client/kqh/models/ServiceDefinitionCommand.js +5 -12
- package/dist/client/kqh/models/ServiceDefinitionDto.d.ts +5 -5
- package/dist/client/kqh/models/ServiceDefinitionDto.js +21 -28
- package/dist/client/kqh/models/ServiceDefinitionDtoSource.d.ts +3 -3
- package/dist/client/kqh/models/ServiceDefinitionDtoSource.js +18 -23
- package/dist/client/kqh/models/ServiceDefinitionOverviewDto.js +6 -13
- package/dist/client/kqh/models/ServiceDto.d.ts +1 -1
- package/dist/client/kqh/models/ServiceDto.js +8 -15
- package/dist/client/kqh/models/ServiceExecutionConsumerDto.js +5 -12
- package/dist/client/kqh/models/ServiceExecutionDto.js +4 -10
- package/dist/client/kqh/models/ServiceOverviewDto.js +8 -15
- package/dist/client/kqh/models/ServiceSource.js +10 -16
- package/dist/client/kqh/models/SortObject.js +4 -10
- package/dist/client/kqh/models/SubscriptionDto.d.ts +3 -3
- package/dist/client/kqh/models/SubscriptionDto.js +13 -19
- package/dist/client/kqh/models/TaxonomyElement.js +4 -10
- package/dist/client/kqh/models/UpdateDataPoolRequest.js +4 -10
- package/dist/client/kqh/models/UpdateResourceConfigurationRequest.d.ts +3 -3
- package/dist/client/kqh/models/UpdateResourceConfigurationRequest.js +18 -23
- package/dist/client/kqh/models/UpdateVersionRequest.d.ts +1 -1
- package/dist/client/kqh/models/UpdateVersionRequest.js +7 -13
- package/dist/client/kqh/models/UpdateWorkflowServiceRequest.js +4 -10
- package/dist/client/kqh/models/ValidationResult.js +5 -12
- package/dist/client/kqh/models/index.d.ts +57 -57
- package/dist/client/kqh/models/index.js +57 -73
- package/dist/client/kqh/runtime.js +17 -32
- package/dist/client/users/apis/AuthenticationApi.d.ts +2 -2
- package/dist/client/users/apis/AuthenticationApi.js +4 -41
- package/dist/client/users/apis/ExpertsApi.d.ts +2 -2
- package/dist/client/users/apis/ExpertsApi.js +5 -42
- package/dist/client/users/apis/SearchApi.d.ts +2 -2
- package/dist/client/users/apis/SearchApi.js +5 -42
- package/dist/client/users/apis/UserSettingsApi.d.ts +2 -2
- package/dist/client/users/apis/UserSettingsApi.js +11 -48
- package/dist/client/users/apis/UserSettingsPersonalAccessTokensApi.d.ts +2 -2
- package/dist/client/users/apis/UserSettingsPersonalAccessTokensApi.js +7 -44
- package/dist/client/users/apis/UsersApi.d.ts +2 -2
- package/dist/client/users/apis/UsersApi.js +4 -41
- package/dist/client/users/apis/index.d.ts +6 -6
- package/dist/client/users/apis/index.js +6 -22
- package/dist/client/users/index.d.ts +3 -3
- package/dist/client/users/index.js +3 -19
- package/dist/client/users/models/AccessTokenCreateRequest.js +5 -12
- package/dist/client/users/models/AccessTokenDto.js +5 -12
- package/dist/client/users/models/AccessTokensResponse.d.ts +1 -1
- package/dist/client/users/models/AccessTokensResponse.js +7 -13
- package/dist/client/users/models/DefaultAccessTokenResponse.js +4 -10
- package/dist/client/users/models/Language.js +4 -10
- package/dist/client/users/models/PageUserDto.d.ts +3 -3
- package/dist/client/users/models/PageUserDto.js +13 -19
- package/dist/client/users/models/Pageable.js +4 -10
- package/dist/client/users/models/PageableObject.d.ts +1 -1
- package/dist/client/users/models/PageableObject.js +7 -13
- package/dist/client/users/models/PersonalAccessTokenPrincipal.d.ts +1 -1
- package/dist/client/users/models/PersonalAccessTokenPrincipal.js +7 -13
- package/dist/client/users/models/Skill.js +4 -10
- package/dist/client/users/models/SortObject.js +4 -10
- package/dist/client/users/models/UpdateUserRequest.js +4 -10
- package/dist/client/users/models/UserDto.d.ts +2 -2
- package/dist/client/users/models/UserDto.js +10 -16
- package/dist/client/users/models/UserOverviewDto.js +4 -10
- package/dist/client/users/models/index.d.ts +14 -14
- package/dist/client/users/models/index.js +14 -30
- package/dist/client/users/runtime.js +17 -32
- package/dist/commands/compress/index.d.ts +1 -1
- package/dist/commands/compress/index.js +13 -19
- package/dist/commands/datapool/upload.d.ts +4 -4
- package/dist/commands/datapool/upload.js +24 -30
- package/dist/commands/get-context/index.d.ts +1 -1
- package/dist/commands/get-context/index.js +2 -5
- package/dist/commands/init/index.d.ts +3 -3
- package/dist/commands/init/index.js +30 -36
- package/dist/commands/list-contexts/index.d.ts +2 -2
- package/dist/commands/list-contexts/index.js +11 -17
- package/dist/commands/login/index.d.ts +3 -3
- package/dist/commands/login/index.js +16 -22
- package/dist/commands/logout/index.d.ts +1 -1
- package/dist/commands/logout/index.js +7 -10
- package/dist/commands/openapi/index.d.ts +7 -7
- package/dist/commands/openapi/index.js +81 -87
- package/dist/commands/run/index.d.ts +6 -6
- package/dist/commands/run/index.js +43 -48
- package/dist/commands/serve/index.d.ts +3 -3
- package/dist/commands/serve/index.js +31 -37
- package/dist/commands/services/index.d.ts +5 -5
- package/dist/commands/services/index.js +17 -23
- package/dist/commands/set-context/index.d.ts +4 -4
- package/dist/commands/set-context/index.js +13 -19
- package/dist/commands/up/index.d.ts +5 -5
- package/dist/commands/up/index.js +51 -57
- package/dist/index.js +1 -4
- package/dist/lib/command.js +5 -10
- package/dist/lib/debug.js +1 -5
- package/dist/lib/entrypoint-resolver.js +3 -7
- package/dist/lib/error.js +8 -12
- package/dist/lib/fetch.js +4 -10
- package/dist/lib/init-user-input.d.ts +1 -1
- package/dist/lib/init-user-input.js +16 -20
- package/dist/lib/random-name.js +1 -5
- package/dist/lib/random-string.js +1 -5
- package/dist/lib/repository.js +9 -17
- package/dist/lib/stream-to-blob.d.ts +1 -1
- package/dist/lib/stream-to-blob.js +1 -5
- package/dist/lib/up/get-description.js +9 -15
- package/dist/lib/up/ignore.js +9 -15
- package/dist/lib/up/zip.js +18 -24
- package/dist/model/account.js +1 -2
- package/dist/model/command.d.ts +2 -2
- package/dist/model/command.js +11 -19
- package/dist/model/managed-service-config.js +4 -7
- package/dist/model/user-config.js +3 -6
- package/dist/service/auth-service.d.ts +3 -3
- package/dist/service/auth-service.js +8 -14
- package/dist/service/command-service.d.ts +2 -2
- package/dist/service/command-service.js +1 -5
- package/dist/service/quantum-hub-service.d.ts +10 -10
- package/dist/service/quantum-hub-service.js +21 -24
- package/dist/service/service-config-service.d.ts +1 -1
- package/dist/service/service-config-service.js +14 -21
- package/dist/service/user-config-service.d.ts +1 -1
- package/dist/service/user-config-service.js +14 -21
- package/dist/service/user-service.d.ts +2 -2
- package/dist/service/user-service.js +8 -11
- package/oclif.manifest.json +119 -119
- package/package.json +4 -2
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const command_1 = require("../../model/command");
|
|
11
|
-
const platform_1 = require("@quantum-hub/qhub-api/dist/api/platform");
|
|
12
|
-
class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
1
|
+
import { input, select } from '@inquirer/prompts';
|
|
2
|
+
import { Flags, ux } from '@oclif/core';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { AuthenticatedCommand } from '../../model/command.js';
|
|
6
|
+
import { HubPlatformClient, HubPlatformError } from "@quantum-hub/qhub-api/platform";
|
|
7
|
+
export default class DatapoolUpload extends AuthenticatedCommand {
|
|
13
8
|
static description = 'Upload files to a data pool';
|
|
14
9
|
static examples = [
|
|
15
10
|
'$ qhubctl datapool upload --file ./data/dataset.csv',
|
|
@@ -17,13 +12,13 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
17
12
|
'$ qhubctl datapool upload -f ./data/dataset.csv -f ./data/metadata.json --datapool-id 550e8400-e29b-41d4-a716-446655440000',
|
|
18
13
|
];
|
|
19
14
|
static flags = {
|
|
20
|
-
file:
|
|
15
|
+
file: Flags.string({
|
|
21
16
|
char: 'f',
|
|
22
17
|
description: 'Path to a file to upload (can be specified multiple times)',
|
|
23
18
|
required: true,
|
|
24
19
|
multiple: true,
|
|
25
20
|
}),
|
|
26
|
-
'datapool-id':
|
|
21
|
+
'datapool-id': Flags.string({
|
|
27
22
|
char: 'd',
|
|
28
23
|
description: 'ID of the data pool to upload the files to (optional - will prompt to create a new one if not provided)',
|
|
29
24
|
required: false,
|
|
@@ -39,7 +34,7 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
39
34
|
? `${this.userConfig.endpoint.basePath}/qc-catalog`
|
|
40
35
|
: undefined; // Will use the default environment if no custom endpoint is set
|
|
41
36
|
const apiKey = this.userConfig.auth?.value;
|
|
42
|
-
this.hubPlatformClient = new
|
|
37
|
+
this.hubPlatformClient = new HubPlatformClient({
|
|
43
38
|
baseUrl: baseUrl,
|
|
44
39
|
apiKey: apiKey,
|
|
45
40
|
organizationId: this.userConfig.context?.isOrganization ? this.userConfig.context.id : undefined,
|
|
@@ -53,20 +48,20 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
53
48
|
// Handle datapool ID - check if exists or prompt to create
|
|
54
49
|
datapoolId = await this.ensureDatapoolExists(datapoolId, filePaths);
|
|
55
50
|
for (const filePath of filePaths) {
|
|
56
|
-
const fileName =
|
|
57
|
-
|
|
51
|
+
const fileName = path.basename(filePath);
|
|
52
|
+
ux.action.start(`Uploading ${fileName} to data pool ${datapoolId}`);
|
|
58
53
|
await this.uploadToDatapool(datapoolId, filePath);
|
|
59
54
|
}
|
|
60
55
|
}
|
|
61
56
|
ensureFilesExist(filePaths) {
|
|
62
57
|
// Validate files exist
|
|
63
58
|
for (const filePath of filePaths) {
|
|
64
|
-
if (!
|
|
59
|
+
if (!fs.existsSync(filePath)) {
|
|
65
60
|
this.error(`File not found: ${filePath}`);
|
|
66
61
|
}
|
|
67
62
|
// Check if file is readable
|
|
68
63
|
try {
|
|
69
|
-
|
|
64
|
+
fs.accessSync(filePath, fs.constants.R_OK);
|
|
70
65
|
}
|
|
71
66
|
catch {
|
|
72
67
|
this.error(`Cannot read file: ${filePath}`);
|
|
@@ -85,7 +80,7 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
85
80
|
return datapoolId;
|
|
86
81
|
}
|
|
87
82
|
catch (error) {
|
|
88
|
-
if (error instanceof
|
|
83
|
+
if (error instanceof HubPlatformError && error.statusCode === 404) {
|
|
89
84
|
this.log(`Data pool ${datapoolId} not found. Would you like to create a new data pool instead?`);
|
|
90
85
|
return await this.createOrSelectDataPool(filePaths);
|
|
91
86
|
}
|
|
@@ -116,7 +111,7 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
116
111
|
return 'create';
|
|
117
112
|
}
|
|
118
113
|
// Offer choice between creating new or selecting existing using select prompt
|
|
119
|
-
return await
|
|
114
|
+
return await select({
|
|
120
115
|
message: 'What would you like to do?',
|
|
121
116
|
choices: [
|
|
122
117
|
{ name: 'Create a new data pool', value: 'create' },
|
|
@@ -145,7 +140,7 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
145
140
|
dataPools.forEach((pool, index) => {
|
|
146
141
|
this.log(`${index + 1}. ${pool.name} (${pool.id})`);
|
|
147
142
|
});
|
|
148
|
-
const selection = await
|
|
143
|
+
const selection = await input({
|
|
149
144
|
message: `Select a data pool (1-${dataPools.length}) or enter the ID directly:`,
|
|
150
145
|
});
|
|
151
146
|
// Check if it's a number (index selection)
|
|
@@ -162,7 +157,7 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
162
157
|
}
|
|
163
158
|
async createDatapool(suggestedName) {
|
|
164
159
|
try {
|
|
165
|
-
const name = await
|
|
160
|
+
const name = await input({
|
|
166
161
|
message: 'Enter a name for the new data pool:',
|
|
167
162
|
default: `Data Pool for ${suggestedName}`,
|
|
168
163
|
});
|
|
@@ -173,7 +168,7 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
173
168
|
return datapool.id;
|
|
174
169
|
}
|
|
175
170
|
catch (error) {
|
|
176
|
-
if (error instanceof
|
|
171
|
+
if (error instanceof HubPlatformError) {
|
|
177
172
|
const errorMessage = error.body || error.message || 'Unknown API error occurred';
|
|
178
173
|
this.error(`Failed to create data pool (HTTP ${error.statusCode}): ${JSON.stringify(errorMessage)}`);
|
|
179
174
|
}
|
|
@@ -184,11 +179,11 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
184
179
|
}
|
|
185
180
|
}
|
|
186
181
|
async uploadToDatapool(datapoolId, filePath) {
|
|
187
|
-
const fileName =
|
|
182
|
+
const fileName = path.basename(filePath);
|
|
188
183
|
try {
|
|
189
|
-
const fileStream =
|
|
184
|
+
const fileStream = fs.createReadStream(filePath);
|
|
190
185
|
const result = await this.hubPlatformClient.dataPools.addDataPoolFile({ "id": datapoolId, file: fileStream });
|
|
191
|
-
|
|
186
|
+
ux.action.stop('✓');
|
|
192
187
|
this.log(`Successfully uploaded ${fileName} to data pool ${datapoolId}`);
|
|
193
188
|
this.log(`File ID: ${result.id}`);
|
|
194
189
|
}
|
|
@@ -197,8 +192,8 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
197
192
|
}
|
|
198
193
|
}
|
|
199
194
|
handleError(error, datapoolId) {
|
|
200
|
-
|
|
201
|
-
if (error instanceof
|
|
195
|
+
ux.action.stop('✗');
|
|
196
|
+
if (error instanceof HubPlatformError) {
|
|
202
197
|
const statusCode = error.statusCode ?? 500; // Default to 500 if statusCode is not set
|
|
203
198
|
let errorMessage = 'Unknown API error occurred';
|
|
204
199
|
if (error.body) {
|
|
@@ -263,4 +258,3 @@ class DatapoolUpload extends command_1.AuthenticatedCommand {
|
|
|
263
258
|
}
|
|
264
259
|
}
|
|
265
260
|
}
|
|
266
|
-
exports.default = DatapoolUpload;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const command_1 = require("../../model/command");
|
|
4
|
-
class GetContext extends command_1.AuthenticatedCommand {
|
|
1
|
+
import { AuthenticatedCommand } from '../../model/command.js';
|
|
2
|
+
export default class GetContext extends AuthenticatedCommand {
|
|
5
3
|
static description = 'Get the current context, i.e., the personal or organization account you are currently working with.';
|
|
6
4
|
static examples = [
|
|
7
5
|
'$ qhubctl get-context',
|
|
@@ -10,4 +8,3 @@ class GetContext extends command_1.AuthenticatedCommand {
|
|
|
10
8
|
// printing the current context is done by parent 'init' method
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
|
-
exports.default = GetContext;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AbstractCommand } from '../../model/command';
|
|
1
|
+
import { AbstractCommand } from '../../model/command.js';
|
|
2
2
|
export default class Init extends AbstractCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
name: import("@oclif/core/
|
|
7
|
-
'non-interactive': import("@oclif/core/
|
|
6
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'non-interactive': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const repository_1 = require("../../lib/repository");
|
|
12
|
-
const command_1 = require("../../model/command");
|
|
13
|
-
const managed_service_config_1 = require("../../model/managed-service-config");
|
|
14
|
-
const service_config_service_1 = require("../../service/service-config-service");
|
|
15
|
-
class Init extends command_1.AbstractCommand {
|
|
1
|
+
import { Flags, ux } from '@oclif/core';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { DEFAULT_STARTER, promptUserInput } from '../../lib/init-user-input.js';
|
|
5
|
+
import { randomName } from '../../lib/random-name.js';
|
|
6
|
+
import { downloadRepository, extractStarter } from '../../lib/repository.js';
|
|
7
|
+
import { AbstractCommand } from '../../model/command.js';
|
|
8
|
+
import { Runtime } from '../../model/managed-service-config.js';
|
|
9
|
+
import { writeServiceConfig } from '../../service/service-config-service.js';
|
|
10
|
+
export default class Init extends AbstractCommand {
|
|
16
11
|
static description = 'Bootstrap project to create a service.';
|
|
17
12
|
static examples = [
|
|
18
13
|
'$ qhubctl init',
|
|
19
14
|
];
|
|
20
15
|
static flags = {
|
|
21
|
-
name:
|
|
22
|
-
'non-interactive':
|
|
16
|
+
name: Flags.string({ description: 'The name of the service', required: false }),
|
|
17
|
+
'non-interactive': Flags.boolean({
|
|
23
18
|
description: 'Run it in non-interactive mode',
|
|
24
19
|
required: false,
|
|
25
20
|
}),
|
|
@@ -27,21 +22,21 @@ class Init extends command_1.AbstractCommand {
|
|
|
27
22
|
async run() {
|
|
28
23
|
const { flags } = await this.parse(Init);
|
|
29
24
|
const nonInteractive = flags['non-interactive'];
|
|
30
|
-
let name = flags.name ??
|
|
25
|
+
let name = flags.name ?? randomName();
|
|
31
26
|
const input = nonInteractive ? {
|
|
32
27
|
cpu: 1,
|
|
33
28
|
descriptionFile: 'README.md',
|
|
34
29
|
gpu: undefined,
|
|
35
30
|
memory: 1,
|
|
36
31
|
name: name,
|
|
37
|
-
starter:
|
|
38
|
-
} : await
|
|
32
|
+
starter: DEFAULT_STARTER,
|
|
33
|
+
} : await promptUserInput(name);
|
|
39
34
|
name = input.name || name;
|
|
40
35
|
// use current directory if no template is selected
|
|
41
|
-
const targetDirectory = input.starter ?
|
|
36
|
+
const targetDirectory = input.starter ? path.join(process.cwd(), name) : path.join(process.cwd());
|
|
42
37
|
// exit if the target directory already exists (only if a starter is selected)
|
|
43
|
-
if (input.starter &&
|
|
44
|
-
|
|
38
|
+
if (input.starter && fs.existsSync(targetDirectory)) {
|
|
39
|
+
ux.error(`Destination ${targetDirectory} already exists. Please choose another name.`);
|
|
45
40
|
}
|
|
46
41
|
const serviceConfig = {
|
|
47
42
|
name,
|
|
@@ -50,7 +45,7 @@ class Init extends command_1.AbstractCommand {
|
|
|
50
45
|
cpu: input.cpu,
|
|
51
46
|
memory: input.memory,
|
|
52
47
|
},
|
|
53
|
-
runtime: input.starter ? input.starter.runtime :
|
|
48
|
+
runtime: input.starter ? input.starter.runtime : Runtime.PYTHON_TEMPLATE,
|
|
54
49
|
};
|
|
55
50
|
if (input.gpu) {
|
|
56
51
|
serviceConfig.resources.gpu = {
|
|
@@ -60,22 +55,21 @@ class Init extends command_1.AbstractCommand {
|
|
|
60
55
|
}
|
|
61
56
|
// make sure the target directory exists if a starter is selected
|
|
62
57
|
if (input.starter) {
|
|
63
|
-
|
|
58
|
+
fs.mkdirSync(targetDirectory);
|
|
64
59
|
}
|
|
65
|
-
|
|
60
|
+
writeServiceConfig(targetDirectory, serviceConfig);
|
|
66
61
|
if (input.starter) {
|
|
67
|
-
const zip = await
|
|
68
|
-
const starterName =
|
|
69
|
-
|
|
62
|
+
const zip = await downloadRepository(input.starter.url);
|
|
63
|
+
const starterName = path.basename(input.starter.url, '.zip');
|
|
64
|
+
extractStarter(zip, starterName, targetDirectory);
|
|
70
65
|
}
|
|
71
|
-
|
|
66
|
+
ux.stdout('\u{1F389} Initialized project. Happy hacking!');
|
|
72
67
|
if (input.starter) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
ux.stdout('\n Next steps:');
|
|
69
|
+
ux.stdout(` \u{2022} cd ${name}`);
|
|
70
|
+
ux.stdout(' \u{2022} qhubctl up (deploys your code as a service to Kipu Quantum Hub)');
|
|
71
|
+
ux.stdout(' \u{2022} qhubclt run (executes your service using the data from the input directory)');
|
|
77
72
|
}
|
|
78
|
-
|
|
73
|
+
ux.stdout('');
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
|
-
exports.default = Init;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthenticatedCommand } from '../../model/command';
|
|
2
|
-
import QuantumHubService from '../../service/quantum-hub-service';
|
|
1
|
+
import { AuthenticatedCommand } from '../../model/command.js';
|
|
2
|
+
import QuantumHubService from '../../service/quantum-hub-service.js';
|
|
3
3
|
export default class ListContexts extends AuthenticatedCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const core_1 = require("@oclif/core");
|
|
7
|
-
const tty_table_1 = __importDefault(require("tty-table"));
|
|
8
|
-
const command_1 = require("../../model/command");
|
|
9
|
-
const quantum_hub_service_1 = __importDefault(require("../../service/quantum-hub-service"));
|
|
10
|
-
class ListContexts extends command_1.AuthenticatedCommand {
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
2
|
+
import Table from 'tty-table';
|
|
3
|
+
import { AuthenticatedCommand } from '../../model/command.js';
|
|
4
|
+
import QuantumHubService from '../../service/quantum-hub-service.js';
|
|
5
|
+
export default class ListContexts extends AuthenticatedCommand {
|
|
11
6
|
static description = 'Retrieves the available contexts, i.e., the personal or organizational accounts available to you to work with.';
|
|
12
7
|
static examples = [
|
|
13
8
|
'$ qhubctl list-contexts',
|
|
@@ -15,12 +10,12 @@ class ListContexts extends command_1.AuthenticatedCommand {
|
|
|
15
10
|
quantumHubService;
|
|
16
11
|
async init() {
|
|
17
12
|
await super.init();
|
|
18
|
-
this.quantumHubService = new
|
|
13
|
+
this.quantumHubService = new QuantumHubService(this, this.config, this.userConfig);
|
|
19
14
|
}
|
|
20
15
|
async run() {
|
|
21
|
-
|
|
16
|
+
ux.action.start('Loading available contexts');
|
|
22
17
|
const accounts = await this.quantumHubService.getAccounts();
|
|
23
|
-
|
|
18
|
+
ux.action.stop('Done');
|
|
24
19
|
const tableData = accounts
|
|
25
20
|
.map(account => ({ displayName: account.displayName, id: account.id, isOrganization: account.isOrganization }));
|
|
26
21
|
const header = [
|
|
@@ -28,9 +23,8 @@ class ListContexts extends command_1.AuthenticatedCommand {
|
|
|
28
23
|
{ value: "id", alias: "ID", align: "left" },
|
|
29
24
|
{ value: "isOrganization", alias: "Account", width: 14, formatter: (value) => value ? "Organization" : "Personal" },
|
|
30
25
|
];
|
|
31
|
-
const t = (
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const t = Table(header, tableData);
|
|
27
|
+
ux.stdout(t.render());
|
|
28
|
+
ux.stdout();
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
|
-
exports.default = ListContexts;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AbstractCommand } from '../../model/command';
|
|
1
|
+
import { AbstractCommand } from '../../model/command.js';
|
|
2
2
|
export default class Login extends AbstractCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
token: import("@oclif/core/
|
|
7
|
-
'base-path': import("@oclif/core/
|
|
6
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'base-path': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const command_1 = require("../../model/command");
|
|
9
|
-
const user_config_1 = require("../../model/user-config");
|
|
10
|
-
const auth_service_1 = __importDefault(require("../../service/auth-service"));
|
|
11
|
-
const user_config_service_1 = require("../../service/user-config-service");
|
|
12
|
-
class Login extends command_1.AbstractCommand {
|
|
1
|
+
import { password } from '@inquirer/prompts';
|
|
2
|
+
import { Flags, ux } from '@oclif/core';
|
|
3
|
+
import { AbstractCommand } from '../../model/command.js';
|
|
4
|
+
import { AuthType, defaultBasePath } from '../../model/user-config.js';
|
|
5
|
+
import AuthService from '../../service/auth-service.js';
|
|
6
|
+
import { writeUserConfig } from '../../service/user-config-service.js';
|
|
7
|
+
export default class Login extends AbstractCommand {
|
|
13
8
|
static description = 'Login with your credentials';
|
|
14
9
|
static examples = [
|
|
15
10
|
'$ qhubctl login -t <personal access token>',
|
|
16
|
-
`$ qhubctl login -t <personal access token> --base-path ${
|
|
11
|
+
`$ qhubctl login -t <personal access token> --base-path ${defaultBasePath}`,
|
|
17
12
|
];
|
|
18
13
|
static flags = {
|
|
19
|
-
token:
|
|
20
|
-
'base-path':
|
|
14
|
+
token: Flags.string({ char: 't', description: 'Your personal access token', required: false }),
|
|
15
|
+
'base-path': Flags.string({ description: 'Custom base path for authentication (development)', required: false }),
|
|
21
16
|
};
|
|
22
17
|
async run() {
|
|
23
18
|
const { flags } = await this.parse(Login);
|
|
24
19
|
let { token } = flags;
|
|
25
20
|
const { 'base-path': basePath } = flags;
|
|
26
21
|
if (!token) {
|
|
27
|
-
token = await
|
|
22
|
+
token = await password({ message: 'Enter or paste your personal access token?', mask: true });
|
|
28
23
|
}
|
|
29
24
|
if (!token) {
|
|
30
25
|
throw new Error('Invalid credentials. Please try again.');
|
|
@@ -33,7 +28,7 @@ class Login extends command_1.AbstractCommand {
|
|
|
33
28
|
if (basePath) {
|
|
34
29
|
this.showCustomBasePathWarning();
|
|
35
30
|
}
|
|
36
|
-
|
|
31
|
+
ux.action.start('Login');
|
|
37
32
|
// Create temporary config with custom basePath for authentication
|
|
38
33
|
const tempUserConfig = basePath ? {
|
|
39
34
|
...this.userConfig,
|
|
@@ -42,11 +37,11 @@ class Login extends command_1.AbstractCommand {
|
|
|
42
37
|
defaultHeaders: this.userConfig.endpoint?.defaultHeaders || {}
|
|
43
38
|
}
|
|
44
39
|
} : this.userConfig;
|
|
45
|
-
const user = await new
|
|
40
|
+
const user = await new AuthService(tempUserConfig).authenticate(token);
|
|
46
41
|
const userConfig = {
|
|
47
42
|
...this.userConfig,
|
|
48
43
|
auth: {
|
|
49
|
-
type:
|
|
44
|
+
type: AuthType.API_KEY,
|
|
50
45
|
value: token,
|
|
51
46
|
},
|
|
52
47
|
context: {
|
|
@@ -61,8 +56,7 @@ class Login extends command_1.AbstractCommand {
|
|
|
61
56
|
}
|
|
62
57
|
})
|
|
63
58
|
};
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
writeUserConfig(this.config.configDir, userConfig);
|
|
60
|
+
ux.action.stop('successful');
|
|
66
61
|
}
|
|
67
62
|
}
|
|
68
|
-
exports.default = Login;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const user_config_service_1 = require("../../service/user-config-service");
|
|
6
|
-
class Logout extends command_1.AbstractCommand {
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
2
|
+
import { AbstractCommand } from '../../model/command.js';
|
|
3
|
+
import { writeUserConfig } from '../../service/user-config-service.js';
|
|
4
|
+
export default class Logout extends AbstractCommand {
|
|
7
5
|
static description = 'Logout';
|
|
8
6
|
static examples = [
|
|
9
7
|
'$ qhubctl logout',
|
|
10
8
|
];
|
|
11
9
|
async run() {
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
ux.action.start('Logout');
|
|
11
|
+
writeUserConfig(this.config.configDir, {
|
|
14
12
|
...this.userConfig,
|
|
15
13
|
auth: undefined,
|
|
16
14
|
context: undefined,
|
|
17
15
|
});
|
|
18
|
-
|
|
16
|
+
ux.action.stop('successful');
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
exports.default = Logout;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AbstractCommand } from '../../model/command';
|
|
1
|
+
import { AbstractCommand } from '../../model/command.js';
|
|
2
2
|
export default class Openapi extends AbstractCommand {
|
|
3
3
|
static readonly description: string;
|
|
4
4
|
static readonly examples: string[];
|
|
5
5
|
static readonly flags: {
|
|
6
|
-
force: import("@oclif/core/
|
|
7
|
-
file: import("@oclif/core/
|
|
8
|
-
format: import("@oclif/core/
|
|
9
|
-
entrypoint: import("@oclif/core/
|
|
10
|
-
package: import("@oclif/core/
|
|
11
|
-
method: import("@oclif/core/
|
|
6
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
format: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
entrypoint: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
package: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
method: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
};
|
|
13
13
|
run(): Promise<void>;
|
|
14
14
|
private getErrorMessage;
|