@quantum-hub/qhubctl 1.1.2 → 1.1.4
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 +15 -22
- 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 +46 -46
- package/package.json +4 -2
package/dist/lib/error.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const handleError = async (error) => {
|
|
8
|
-
if (error instanceof kqh_1.ResponseError) {
|
|
9
|
-
return (0, fetch_1.getErrorMessage)(error.response);
|
|
1
|
+
import { FetchError, ResponseError } from '../client/kqh/index.js';
|
|
2
|
+
import { debugEnabled } from './debug.js';
|
|
3
|
+
import { getErrorMessage } from './fetch.js';
|
|
4
|
+
export const handleError = async (error) => {
|
|
5
|
+
if (error instanceof ResponseError) {
|
|
6
|
+
return getErrorMessage(error.response);
|
|
10
7
|
}
|
|
11
|
-
if (error instanceof
|
|
8
|
+
if (error instanceof FetchError) {
|
|
12
9
|
const errorMessage = error.cause ? error.cause.message : error.message;
|
|
13
10
|
return `Internal error occurred, please try again later (${errorMessage})`;
|
|
14
11
|
}
|
|
15
|
-
if (
|
|
12
|
+
if (debugEnabled()) {
|
|
16
13
|
console.error(JSON.stringify(error));
|
|
17
14
|
}
|
|
18
15
|
return 'Internal error occurred, please contact your KQH administrator';
|
|
19
16
|
};
|
|
20
|
-
exports.handleError = handleError;
|
package/dist/lib/fetch.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getErrorMessage = exports.fetchOrThrow = exports.PlatformError = void 0;
|
|
4
|
-
class PlatformError extends Error {
|
|
1
|
+
export class PlatformError extends Error {
|
|
5
2
|
response;
|
|
6
3
|
constructor(response) {
|
|
7
4
|
super(response.statusText);
|
|
8
5
|
this.response = response;
|
|
9
6
|
}
|
|
10
7
|
async getErrorMessage() {
|
|
11
|
-
return
|
|
8
|
+
return getErrorMessage(this.response);
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
const fetchOrThrow = async (input, init) => {
|
|
11
|
+
export const fetchOrThrow = async (input, init) => {
|
|
16
12
|
const response = await fetch(input, init);
|
|
17
13
|
if (!response.ok) {
|
|
18
14
|
throw new PlatformError(response);
|
|
19
15
|
}
|
|
20
16
|
return response;
|
|
21
17
|
};
|
|
22
|
-
|
|
23
|
-
const getErrorMessage = async (response) => {
|
|
18
|
+
export const getErrorMessage = async (response) => {
|
|
24
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
20
|
let body;
|
|
26
21
|
try {
|
|
@@ -40,4 +35,3 @@ const getErrorMessage = async (response) => {
|
|
|
40
35
|
errorMessage = body.detail;
|
|
41
36
|
return errorMessage ? `${errorMessage} (${httpStatus})` : `${httpStatus}`;
|
|
42
37
|
};
|
|
43
|
-
exports.getErrorMessage = getErrorMessage;
|
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const prompts_1 = require("@inquirer/prompts");
|
|
5
|
-
const managed_service_config_1 = require("../model/managed-service-config");
|
|
6
|
-
exports.DEFAULT_STARTER = {
|
|
1
|
+
import { input, select, number } from '@inquirer/prompts';
|
|
2
|
+
import { GpuType, Runtime } from '../model/managed-service-config.js';
|
|
3
|
+
export const DEFAULT_STARTER = {
|
|
7
4
|
url: 'https://gitlab.com/planqk-foss/planqk-starter-python/-/archive/main/planqk-starter-python-main.zip',
|
|
8
|
-
runtime:
|
|
5
|
+
runtime: Runtime.PYTHON_TEMPLATE
|
|
9
6
|
};
|
|
10
|
-
const promptUserInput = async (defaultName) => {
|
|
11
|
-
const name = await
|
|
7
|
+
export const promptUserInput = async (defaultName) => {
|
|
8
|
+
const name = await input({
|
|
12
9
|
message: `Service name (${defaultName}):`,
|
|
13
10
|
default: defaultName,
|
|
14
11
|
});
|
|
15
|
-
const starter = await
|
|
12
|
+
const starter = await select({
|
|
16
13
|
message: 'Choose a starter template',
|
|
17
14
|
choices: [
|
|
18
15
|
{
|
|
19
16
|
name: 'Python Starter (recommended to get started quickly)',
|
|
20
|
-
value:
|
|
17
|
+
value: DEFAULT_STARTER,
|
|
21
18
|
},
|
|
22
19
|
{
|
|
23
20
|
name: 'Docker Starter (setup for experienced users)',
|
|
24
21
|
value: {
|
|
25
22
|
url: 'https://gitlab.com/planqk-foss/planqk-starter-docker/-/archive/main/planqk-starter-docker-main.zip',
|
|
26
|
-
runtime:
|
|
23
|
+
runtime: Runtime.DOCKER
|
|
27
24
|
},
|
|
28
25
|
},
|
|
29
26
|
{
|
|
30
27
|
name: 'NVIDIA CUDA-Q Starter (for GPU accelerated applications; setup for experienced users)',
|
|
31
28
|
value: {
|
|
32
29
|
url: 'https://gitlab.com/planqk-foss/planqk-starter-gpu/-/archive/main/planqk-starter-gpu-main.zip',
|
|
33
|
-
runtime:
|
|
30
|
+
runtime: Runtime.DOCKER
|
|
34
31
|
},
|
|
35
32
|
},
|
|
36
33
|
{ name: 'None (creates "qhub.json" in current directory)', value: undefined },
|
|
37
34
|
],
|
|
38
|
-
default:
|
|
35
|
+
default: DEFAULT_STARTER,
|
|
39
36
|
});
|
|
40
|
-
const cpu = await
|
|
37
|
+
const cpu = await number({
|
|
41
38
|
message: 'Enter vCPU configuration (may be between 1 and 220 vCPUs, depending on your account):',
|
|
42
39
|
default: 1,
|
|
43
40
|
validate: (input) => {
|
|
@@ -50,7 +47,7 @@ const promptUserInput = async (defaultName) => {
|
|
|
50
47
|
return true;
|
|
51
48
|
},
|
|
52
49
|
});
|
|
53
|
-
const memory = await
|
|
50
|
+
const memory = await number({
|
|
54
51
|
message: 'Enter memory configuration in GB (may be between 1 and 848 GBs, depending on your account):',
|
|
55
52
|
default: 1,
|
|
56
53
|
validate: (input) => {
|
|
@@ -65,12 +62,12 @@ const promptUserInput = async (defaultName) => {
|
|
|
65
62
|
});
|
|
66
63
|
let gpu = undefined;
|
|
67
64
|
if (!starter || starter.url.includes('planqk-starter-gpu')) {
|
|
68
|
-
gpu = await
|
|
65
|
+
gpu = await select({
|
|
69
66
|
message: 'Choose your GPU configuration',
|
|
70
67
|
choices: [
|
|
71
68
|
{ name: 'No GPU support', value: undefined },
|
|
72
|
-
{ name: 'NVIDIA® T4', value:
|
|
73
|
-
{ name: 'NVIDIA® V100', value:
|
|
69
|
+
{ name: 'NVIDIA® T4', value: GpuType.NVIDIA_TESLA_T4 },
|
|
70
|
+
{ name: 'NVIDIA® V100', value: GpuType.NVIDIA_TESLA_V100 },
|
|
74
71
|
],
|
|
75
72
|
default: undefined,
|
|
76
73
|
});
|
|
@@ -84,4 +81,3 @@ const promptUserInput = async (defaultName) => {
|
|
|
84
81
|
descriptionFile: 'README.md',
|
|
85
82
|
};
|
|
86
83
|
};
|
|
87
|
-
exports.promptUserInput = promptUserInput;
|
package/dist/lib/random-name.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomName = void 0;
|
|
4
|
-
const randomName = () => {
|
|
1
|
+
export const randomName = () => {
|
|
5
2
|
const suffix = Math.random().toString(36).slice(2, 7);
|
|
6
3
|
const randomAdjective = adjectives[Math.floor(Math.random() * adjectives.length)];
|
|
7
4
|
const randomAnimal = animals[Math.floor(Math.random() * animals.length)];
|
|
8
5
|
return `${randomAdjective}-${randomAnimal}-${suffix}`;
|
|
9
6
|
};
|
|
10
|
-
exports.randomName = randomName;
|
|
11
7
|
const adjectives = [
|
|
12
8
|
'admiring',
|
|
13
9
|
'adoring',
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomString = void 0;
|
|
4
1
|
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
5
|
-
const randomString = (length) => {
|
|
2
|
+
export const randomString = (length) => {
|
|
6
3
|
let value = '';
|
|
7
4
|
for (let i = 0; i < length; i++) {
|
|
8
5
|
value += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
9
6
|
}
|
|
10
7
|
return value;
|
|
11
8
|
};
|
|
12
|
-
exports.randomString = randomString;
|
package/dist/lib/repository.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.extractStarter = exports.downloadRepository = void 0;
|
|
7
|
-
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
8
|
-
const debug_1 = require("./debug");
|
|
9
|
-
const fetch_1 = require("./fetch");
|
|
10
|
-
const downloadRepository = async (url) => {
|
|
1
|
+
import AdmZip from 'adm-zip';
|
|
2
|
+
import { debugEnabled } from './debug.js';
|
|
3
|
+
import { fetchOrThrow, PlatformError } from './fetch.js';
|
|
4
|
+
export const downloadRepository = async (url) => {
|
|
11
5
|
const config = {
|
|
12
6
|
cache: 'no-cache',
|
|
13
7
|
method: 'GET',
|
|
@@ -17,24 +11,23 @@ const downloadRepository = async (url) => {
|
|
|
17
11
|
};
|
|
18
12
|
let zip;
|
|
19
13
|
try {
|
|
20
|
-
const response = await
|
|
14
|
+
const response = await fetchOrThrow(url, config);
|
|
21
15
|
const buffer = await response.arrayBuffer();
|
|
22
|
-
zip = new
|
|
16
|
+
zip = new AdmZip(Buffer.from(buffer), {});
|
|
23
17
|
}
|
|
24
18
|
catch (error) {
|
|
25
|
-
if (error instanceof
|
|
19
|
+
if (error instanceof PlatformError) {
|
|
26
20
|
const errorMessage = await error.getErrorMessage();
|
|
27
21
|
throw new Error(errorMessage);
|
|
28
22
|
}
|
|
29
|
-
if (
|
|
23
|
+
if (debugEnabled()) {
|
|
30
24
|
console.error(JSON.stringify(error));
|
|
31
25
|
}
|
|
32
26
|
throw new Error('Internal error occurred, please contact your Quantum Hub administrator');
|
|
33
27
|
}
|
|
34
28
|
return zip;
|
|
35
29
|
};
|
|
36
|
-
|
|
37
|
-
const extractStarter = (zip, starterName, targetDirectory) => {
|
|
30
|
+
export const extractStarter = (zip, starterName, targetDirectory) => {
|
|
38
31
|
const templateFolder = `${starterName}/`;
|
|
39
32
|
for (const entry of zip.getEntries()) {
|
|
40
33
|
if (!entry.isDirectory && entry.entryName.startsWith(templateFolder)) {
|
|
@@ -48,4 +41,3 @@ const extractStarter = (zip, starterName, targetDirectory) => {
|
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
43
|
};
|
|
51
|
-
exports.extractStarter = extractStarter;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ReadStream } from 'fs
|
|
1
|
+
import type { ReadStream } from 'node:fs';
|
|
2
2
|
export declare const streamToBlob: (stream: ReadStream, mimeType?: string) => Promise<Blob>;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.streamToBlob = void 0;
|
|
4
|
-
const streamToBlob = (stream, mimeType) => {
|
|
1
|
+
export const streamToBlob = (stream, mimeType) => {
|
|
5
2
|
return new Promise((resolve, reject) => {
|
|
6
3
|
const chunks = [];
|
|
7
4
|
stream.on('data', (chunk) => {
|
|
@@ -24,4 +21,3 @@ const streamToBlob = (stream, mimeType) => {
|
|
|
24
21
|
});
|
|
25
22
|
});
|
|
26
23
|
};
|
|
27
|
-
exports.streamToBlob = streamToBlob;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDescriptionText = getDescriptionText;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
9
3
|
function getDescriptionPath(workingDirectory = process.cwd()) {
|
|
10
|
-
const configPath =
|
|
11
|
-
if (
|
|
12
|
-
const config = JSON.parse(
|
|
4
|
+
const configPath = path.join(workingDirectory, 'qhub.json');
|
|
5
|
+
if (fs.existsSync(configPath)) {
|
|
6
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
13
7
|
if (config.descriptionFile) {
|
|
14
|
-
return
|
|
8
|
+
return path.join(workingDirectory, config.descriptionFile);
|
|
15
9
|
}
|
|
16
10
|
return '';
|
|
17
11
|
}
|
|
18
12
|
throw new Error('qhub.json file not found');
|
|
19
13
|
}
|
|
20
|
-
async function getDescriptionText(workingDirectory = process.cwd()) {
|
|
14
|
+
export async function getDescriptionText(workingDirectory = process.cwd()) {
|
|
21
15
|
const descriptionPath = getDescriptionPath(workingDirectory);
|
|
22
16
|
if (descriptionPath) {
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
17
|
+
if (fs.existsSync(descriptionPath)) {
|
|
18
|
+
return fs.readFileSync(descriptionPath, 'utf8');
|
|
25
19
|
}
|
|
26
20
|
throw new Error('Provided "descriptionFile" was not found');
|
|
27
21
|
}
|
package/dist/lib/up/ignore.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const node_util_1 = require("node:util");
|
|
11
|
-
const readFile = (0, node_util_1.promisify)(node_fs_1.default.readFile);
|
|
12
|
-
async function createIgnoreFileChecker(filePath = process.cwd()) {
|
|
13
|
-
const ignoreFilePath = node_path_1.default.join(filePath, '.dockerignore');
|
|
14
|
-
if (!node_fs_1.default.existsSync(ignoreFilePath)) {
|
|
1
|
+
import ignore from 'ignore';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
const readFile = promisify(fs.readFile);
|
|
6
|
+
export async function createIgnoreFileChecker(filePath = process.cwd()) {
|
|
7
|
+
const ignoreFilePath = path.join(filePath, '.dockerignore');
|
|
8
|
+
if (!fs.existsSync(ignoreFilePath)) {
|
|
15
9
|
return () => false;
|
|
16
10
|
}
|
|
17
11
|
const ignoreFileContents = await readFile(ignoreFilePath, 'utf8');
|
|
18
|
-
const ig = (
|
|
12
|
+
const ig = ignore().add(ignoreFileContents.split('\n'));
|
|
19
13
|
ig.add('service.zip');
|
|
20
14
|
return (fullPath) => ig.ignores(fullPath);
|
|
21
15
|
}
|
package/dist/lib/up/zip.js
CHANGED
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const stream_to_blob_1 = require("../stream-to-blob");
|
|
12
|
-
const ignore_1 = require("./ignore");
|
|
13
|
-
async function zipProjectFolder(workingDirectory = process.cwd(), targetDirectory = (0, node_os_1.tmpdir)(), targetFilename = 'user_code.zip') {
|
|
14
|
-
const targetFilePath = node_path_1.default.join(targetDirectory, '/', targetFilename);
|
|
15
|
-
if (fs_extra_1.default.existsSync(targetFilePath)) {
|
|
16
|
-
fs_extra_1.default.unlinkSync(targetFilePath);
|
|
1
|
+
import AdmZip from 'adm-zip';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { streamToBlob } from '../stream-to-blob.js';
|
|
6
|
+
import { createIgnoreFileChecker } from './ignore.js';
|
|
7
|
+
export async function zipProjectFolder(workingDirectory = process.cwd(), targetDirectory = tmpdir(), targetFilename = 'user_code.zip') {
|
|
8
|
+
const targetFilePath = path.join(targetDirectory, '/', targetFilename);
|
|
9
|
+
if (fs.existsSync(targetFilePath)) {
|
|
10
|
+
fs.unlinkSync(targetFilePath);
|
|
17
11
|
}
|
|
18
|
-
const zip = new
|
|
19
|
-
const ignoreFile = await
|
|
12
|
+
const zip = new AdmZip();
|
|
13
|
+
const ignoreFile = await createIgnoreFileChecker(workingDirectory);
|
|
20
14
|
function addToZip(folderPath) {
|
|
21
|
-
const files =
|
|
15
|
+
const files = fs.readdirSync(folderPath);
|
|
22
16
|
for (const file of files) {
|
|
23
|
-
const fullPath =
|
|
17
|
+
const fullPath = path.join(folderPath, file);
|
|
24
18
|
if (ignoreFile(fullPath)) {
|
|
25
19
|
continue;
|
|
26
20
|
}
|
|
27
|
-
const stat =
|
|
21
|
+
const stat = fs.statSync(fullPath);
|
|
28
22
|
if (stat.isDirectory()) {
|
|
29
23
|
addToZip(fullPath);
|
|
30
24
|
}
|
|
31
25
|
else {
|
|
32
|
-
zip.addLocalFile(fullPath,
|
|
26
|
+
zip.addLocalFile(fullPath, path.relative(workingDirectory, folderPath));
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
30
|
addToZip(workingDirectory);
|
|
37
31
|
zip.writeZip(targetFilePath);
|
|
38
|
-
const userCode =
|
|
39
|
-
return
|
|
32
|
+
const userCode = fs.createReadStream(path.join(targetFilePath));
|
|
33
|
+
return streamToBlob(userCode);
|
|
40
34
|
}
|
package/dist/model/account.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/model/command.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import { Config } from '@oclif/core/
|
|
3
|
-
import UserConfig from './user-config';
|
|
2
|
+
import { Config } from '@oclif/core/config';
|
|
3
|
+
import UserConfig from './user-config.js';
|
|
4
4
|
export declare abstract class AbstractCommand extends Command {
|
|
5
5
|
userConfig: UserConfig;
|
|
6
6
|
constructor(argv: string[], config: Config);
|
package/dist/model/command.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AuthenticatedCommand = exports.AbstractCommand = void 0;
|
|
7
|
-
const core_1 = require("@oclif/core");
|
|
8
|
-
const auth_service_1 = __importDefault(require("../service/auth-service"));
|
|
9
|
-
const user_config_service_1 = require("../service/user-config-service");
|
|
10
|
-
class AbstractCommand extends core_1.Command {
|
|
1
|
+
import { Command, ux } from '@oclif/core';
|
|
2
|
+
import AuthService from '../service/auth-service.js';
|
|
3
|
+
import { readUserConfig, writeUserConfig } from '../service/user-config-service.js';
|
|
4
|
+
export class AbstractCommand extends Command {
|
|
11
5
|
userConfig;
|
|
12
6
|
constructor(argv, config) {
|
|
13
7
|
super(argv, config);
|
|
14
|
-
this.userConfig =
|
|
8
|
+
this.userConfig = readUserConfig(this.config.configDir);
|
|
15
9
|
}
|
|
16
10
|
showCustomBasePathWarning() {
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
ux.warn(`Using custom base path. This is intended for internal development use only.`);
|
|
12
|
+
ux.stdout('');
|
|
19
13
|
}
|
|
20
14
|
}
|
|
21
|
-
|
|
22
|
-
class AuthenticatedCommand extends AbstractCommand {
|
|
15
|
+
export class AuthenticatedCommand extends AbstractCommand {
|
|
23
16
|
async getContextOutputString(userConfig) {
|
|
24
17
|
if (userConfig?.context) {
|
|
25
18
|
const type = userConfig.context.isOrganization ? 'Organization' : 'Personal';
|
|
@@ -35,12 +28,12 @@ class AuthenticatedCommand extends AbstractCommand {
|
|
|
35
28
|
if (this.userConfig.endpoint?.basePath) {
|
|
36
29
|
this.showCustomBasePathWarning();
|
|
37
30
|
}
|
|
38
|
-
const auth = new
|
|
31
|
+
const auth = new AuthService(this.userConfig);
|
|
39
32
|
try {
|
|
40
33
|
await auth.authenticate(this.userConfig.auth.value);
|
|
41
34
|
}
|
|
42
35
|
catch {
|
|
43
|
-
|
|
36
|
+
writeUserConfig(this.config.configDir, {
|
|
44
37
|
...this.userConfig,
|
|
45
38
|
auth: undefined,
|
|
46
39
|
context: undefined,
|
|
@@ -48,8 +41,7 @@ class AuthenticatedCommand extends AbstractCommand {
|
|
|
48
41
|
throw new Error('Invalid credentials provided. Use the "login" command to log-in.');
|
|
49
42
|
}
|
|
50
43
|
if (printContext) {
|
|
51
|
-
|
|
44
|
+
ux.stdout('Current context: ' + await this.getContextOutputString(this.userConfig));
|
|
52
45
|
}
|
|
53
46
|
}
|
|
54
47
|
}
|
|
55
|
-
exports.AuthenticatedCommand = AuthenticatedCommand;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GpuType = exports.Runtime = void 0;
|
|
4
|
-
var Runtime;
|
|
1
|
+
export var Runtime;
|
|
5
2
|
(function (Runtime) {
|
|
6
3
|
Runtime["DOCKER"] = "DOCKER";
|
|
7
4
|
Runtime["PYTHON"] = "PYTHON";
|
|
8
5
|
Runtime["PYTHON_TEMPLATE"] = "PYTHON_TEMPLATE";
|
|
9
|
-
})(Runtime || (
|
|
10
|
-
var GpuType;
|
|
6
|
+
})(Runtime || (Runtime = {}));
|
|
7
|
+
export var GpuType;
|
|
11
8
|
(function (GpuType) {
|
|
12
9
|
GpuType["NVIDIA_TESLA_A100"] = "NVIDIA_TESLA_A100";
|
|
13
10
|
GpuType["NVIDIA_TESLA_P100"] = "NVIDIA_TESLA_P100";
|
|
14
11
|
GpuType["NVIDIA_TESLA_T4"] = "NVIDIA_TESLA_T4";
|
|
15
12
|
GpuType["NVIDIA_TESLA_V100"] = "NVIDIA_TESLA_V100";
|
|
16
|
-
})(GpuType || (
|
|
13
|
+
})(GpuType || (GpuType = {}));
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultBasePath = exports.AuthType = void 0;
|
|
4
|
-
var AuthType;
|
|
1
|
+
export var AuthType;
|
|
5
2
|
(function (AuthType) {
|
|
6
3
|
AuthType["API_KEY"] = "API_KEY";
|
|
7
|
-
})(AuthType || (
|
|
8
|
-
|
|
4
|
+
})(AuthType || (AuthType = {}));
|
|
5
|
+
export const defaultBasePath = 'https://api.hub.kipu-quantum.com';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserDto } from '../client/users';
|
|
2
|
-
import UserConfig from '../model/user-config';
|
|
3
|
-
import UserService from './user-service';
|
|
1
|
+
import { UserDto } from '../client/users/index.js';
|
|
2
|
+
import UserConfig from '../model/user-config.js';
|
|
3
|
+
import UserService from './user-service.js';
|
|
4
4
|
export default class AuthService {
|
|
5
5
|
userConfig: UserConfig;
|
|
6
6
|
userService: UserService;
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fetch_1 = require("../lib/fetch");
|
|
7
|
-
const user_config_1 = require("../model/user-config");
|
|
8
|
-
const user_service_1 = __importDefault(require("./user-service"));
|
|
9
|
-
class AuthService {
|
|
1
|
+
import { fetchOrThrow, PlatformError } from '../lib/fetch.js';
|
|
2
|
+
import { defaultBasePath } from '../model/user-config.js';
|
|
3
|
+
import UserService from './user-service.js';
|
|
4
|
+
export default class AuthService {
|
|
10
5
|
userConfig;
|
|
11
6
|
userService;
|
|
12
7
|
constructor(userConfig) {
|
|
13
8
|
this.userConfig = userConfig;
|
|
14
|
-
this.userService = new
|
|
9
|
+
this.userService = new UserService(userConfig);
|
|
15
10
|
}
|
|
16
11
|
async authenticate(apiKey) {
|
|
17
12
|
try {
|
|
18
|
-
const basePath = (this.userConfig.endpoint?.basePath ||
|
|
19
|
-
await
|
|
13
|
+
const basePath = (this.userConfig.endpoint?.basePath || defaultBasePath) + '/qc-catalog';
|
|
14
|
+
await fetchOrThrow(basePath + '/authorize', {
|
|
20
15
|
headers: { 'X-Auth-Token': apiKey },
|
|
21
16
|
method: 'POST',
|
|
22
17
|
});
|
|
23
18
|
return await this.userService.getCurrentUser(apiKey);
|
|
24
19
|
}
|
|
25
20
|
catch (error) {
|
|
26
|
-
if (error instanceof
|
|
21
|
+
if (error instanceof PlatformError) {
|
|
27
22
|
if (error.response.status === 401) {
|
|
28
23
|
throw new Error('Invalid API key');
|
|
29
24
|
}
|
|
@@ -35,4 +30,3 @@ class AuthService {
|
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
|
-
exports.default = AuthService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import { Config } from '@oclif/core/
|
|
3
|
-
import UserConfig from '../model/user-config';
|
|
2
|
+
import { Config } from '@oclif/core/config';
|
|
3
|
+
import UserConfig from '../model/user-config.js';
|
|
4
4
|
export declare class CommandService {
|
|
5
5
|
cmd: Command;
|
|
6
6
|
config: Config;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandService = void 0;
|
|
4
|
-
class CommandService {
|
|
1
|
+
export class CommandService {
|
|
5
2
|
cmd;
|
|
6
3
|
config;
|
|
7
4
|
userConfig;
|
|
@@ -11,4 +8,3 @@ class CommandService {
|
|
|
11
8
|
this.userConfig = userConfig;
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
exports.CommandService = CommandService;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import { Config } from '@oclif/core/
|
|
3
|
-
import { HubPlatformClient } from "@quantum-hub/qhub-api/
|
|
4
|
-
import { BuildJobDto, ServiceDefinitionDto, ServiceDto, ServiceOverviewDto, ServicePlatformServicesApi } from '../client/kqh';
|
|
5
|
-
import Account from '../model/account';
|
|
6
|
-
import ManagedServiceConfig from '../model/managed-service-config';
|
|
7
|
-
import UserConfig from '../model/user-config';
|
|
8
|
-
import { CommandService } from './command-service';
|
|
9
|
-
import {
|
|
2
|
+
import { Config } from '@oclif/core/config';
|
|
3
|
+
import { HubPlatformClient } from "@quantum-hub/qhub-api/platform";
|
|
4
|
+
import { BuildJobDto, ServiceDefinitionDto, ServiceDto, ServiceOverviewDto, ServicePlatformServicesApi } from '../client/kqh/index.js';
|
|
5
|
+
import Account from '../model/account.js';
|
|
6
|
+
import ManagedServiceConfig from '../model/managed-service-config.js';
|
|
7
|
+
import UserConfig from '../model/user-config.js';
|
|
8
|
+
import { CommandService } from './command-service.js';
|
|
9
|
+
import { HubPlatform } from "@quantum-hub/qhub-api/platform";
|
|
10
10
|
export default class QuantumHubService extends CommandService {
|
|
11
11
|
serviceApi: ServicePlatformServicesApi;
|
|
12
12
|
apiClient: HubPlatformClient;
|
|
@@ -14,10 +14,10 @@ export default class QuantumHubService extends CommandService {
|
|
|
14
14
|
createService(serviceConfig: ManagedServiceConfig, sourceCode: Blob, apiDefinition?: Blob): Promise<ServiceDto>;
|
|
15
15
|
getAccounts(): Promise<Account[]>;
|
|
16
16
|
getBuildJob(service: ServiceDto, serviceDefinition: ServiceDefinitionDto): Promise<BuildJobDto>;
|
|
17
|
-
getJobById(id: string): Promise<ServiceJobDto>;
|
|
17
|
+
getJobById(id: string): Promise<HubPlatform.ServiceJobDto>;
|
|
18
18
|
getService(id: string): Promise<ServiceDto>;
|
|
19
19
|
getServices(): Promise<ServiceOverviewDto[]>;
|
|
20
|
-
runJob(request: CreateServiceJobRequest): Promise<ServiceJobDto>;
|
|
20
|
+
runJob(request: HubPlatform.CreateServiceJobRequest): Promise<HubPlatform.ServiceJobDto>;
|
|
21
21
|
updateDescription(serviceConfig: ManagedServiceConfig, description: string): Promise<void>;
|
|
22
22
|
updateOpenapi(serviceConfig: ManagedServiceConfig, apiDefinition: Blob): Promise<void>;
|
|
23
23
|
updateService(serviceConfig: ManagedServiceConfig, description: string, sourceCode: Blob, apiDefinition?: Blob): Promise<ServiceDto>;
|