@quantum-hub/qhubctl 1.1.1 → 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/README.md +1 -1
- 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 +170 -170
- package/package.json +4 -2
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const command_service_1 = require("./command-service");
|
|
9
|
-
class QuantumHubService extends command_service_1.CommandService {
|
|
1
|
+
import { HubPlatformClient } from "@quantum-hub/qhub-api/platform";
|
|
2
|
+
import { Configuration, ServicePlatformServicesApi, } from '../client/kqh/index.js';
|
|
3
|
+
import { handleError } from '../lib/error.js';
|
|
4
|
+
import { fetchOrThrow } from '../lib/fetch.js';
|
|
5
|
+
import { defaultBasePath } from '../model/user-config.js';
|
|
6
|
+
import { CommandService } from './command-service.js';
|
|
7
|
+
export default class QuantumHubService extends CommandService {
|
|
10
8
|
serviceApi;
|
|
11
9
|
apiClient;
|
|
12
10
|
constructor(cmd, config, userConfig) {
|
|
13
11
|
super(cmd, config, userConfig);
|
|
14
|
-
const basePath = (userConfig.endpoint?.basePath ||
|
|
12
|
+
const basePath = (userConfig.endpoint?.basePath || defaultBasePath) + '/qc-catalog';
|
|
15
13
|
const defaultHeaders = userConfig.endpoint?.defaultHeaders || {};
|
|
16
14
|
const apiKey = userConfig.auth?.value;
|
|
17
15
|
const organizationId = this.userConfig.context?.isOrganization ? this.userConfig.context.id : undefined;
|
|
18
|
-
this.serviceApi = new
|
|
16
|
+
this.serviceApi = new ServicePlatformServicesApi(new Configuration({
|
|
19
17
|
apiKey,
|
|
20
18
|
basePath,
|
|
21
19
|
headers: defaultHeaders,
|
|
22
20
|
}));
|
|
23
|
-
this.apiClient = new
|
|
21
|
+
this.apiClient = new HubPlatformClient({
|
|
24
22
|
apiKey,
|
|
25
23
|
baseUrl: basePath,
|
|
26
24
|
organizationId
|
|
@@ -46,20 +44,20 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
46
44
|
});
|
|
47
45
|
}
|
|
48
46
|
catch (error) {
|
|
49
|
-
const errorMessage = await
|
|
47
|
+
const errorMessage = await handleError(error);
|
|
50
48
|
throw new Error(errorMessage);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
async getAccounts() {
|
|
54
|
-
const basePath = (this.userConfig.endpoint?.basePath ||
|
|
52
|
+
const basePath = (this.userConfig.endpoint?.basePath || defaultBasePath) + '/qc-catalog';
|
|
55
53
|
try {
|
|
56
|
-
const response = await
|
|
54
|
+
const response = await fetchOrThrow(basePath + '/my/accounts', {
|
|
57
55
|
headers: { 'X-Auth-Token': this.userConfig.auth.value },
|
|
58
56
|
});
|
|
59
57
|
return (await response.json());
|
|
60
58
|
}
|
|
61
59
|
catch (error) {
|
|
62
|
-
const errorMessage = await
|
|
60
|
+
const errorMessage = await handleError(error);
|
|
63
61
|
throw new Error(errorMessage);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
@@ -73,7 +71,7 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
73
|
catch (error) {
|
|
76
|
-
const errorMessage = await
|
|
74
|
+
const errorMessage = await handleError(error);
|
|
77
75
|
throw new Error(errorMessage);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
@@ -82,7 +80,7 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
82
80
|
return await this.apiClient.serviceJobs.getServiceJob({ "id": id });
|
|
83
81
|
}
|
|
84
82
|
catch (error) {
|
|
85
|
-
const errorMessage = await
|
|
83
|
+
const errorMessage = await handleError(error);
|
|
86
84
|
throw new Error(errorMessage);
|
|
87
85
|
}
|
|
88
86
|
}
|
|
@@ -92,7 +90,7 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
92
90
|
return await this.serviceApi.getService({ id, xOrganizationId: organizationId });
|
|
93
91
|
}
|
|
94
92
|
catch (error) {
|
|
95
|
-
const errorMessage = await
|
|
93
|
+
const errorMessage = await handleError(error);
|
|
96
94
|
throw new Error(errorMessage);
|
|
97
95
|
}
|
|
98
96
|
}
|
|
@@ -102,7 +100,7 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
102
100
|
return await this.serviceApi.getServices({ xOrganizationId: organizationId });
|
|
103
101
|
}
|
|
104
102
|
catch (error) {
|
|
105
|
-
const errorMessage = await
|
|
103
|
+
const errorMessage = await handleError(error);
|
|
106
104
|
throw new Error(errorMessage);
|
|
107
105
|
}
|
|
108
106
|
}
|
|
@@ -111,7 +109,7 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
111
109
|
return await this.apiClient.serviceJobs.createServiceJob(request);
|
|
112
110
|
}
|
|
113
111
|
catch (error) {
|
|
114
|
-
const errorMessage = await
|
|
112
|
+
const errorMessage = await handleError(error);
|
|
115
113
|
throw new Error(errorMessage);
|
|
116
114
|
}
|
|
117
115
|
}
|
|
@@ -128,7 +126,7 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
128
126
|
});
|
|
129
127
|
}
|
|
130
128
|
catch (error) {
|
|
131
|
-
const errorMessage = await
|
|
129
|
+
const errorMessage = await handleError(error);
|
|
132
130
|
throw new Error(errorMessage);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
@@ -214,9 +212,8 @@ class QuantumHubService extends command_service_1.CommandService {
|
|
|
214
212
|
return service;
|
|
215
213
|
}
|
|
216
214
|
catch (error) {
|
|
217
|
-
const errorMessage = await
|
|
215
|
+
const errorMessage = await handleError(error);
|
|
218
216
|
throw new Error(errorMessage);
|
|
219
217
|
}
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
|
-
exports.default = QuantumHubService;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import ManagedServiceConfig from '../model/managed-service-config';
|
|
1
|
+
import ManagedServiceConfig from '../model/managed-service-config.js';
|
|
2
2
|
export declare const readServiceConfig: (location: string) => ManagedServiceConfig;
|
|
3
3
|
export declare const writeServiceConfig: (location: string, serviceConfig: ManagedServiceConfig) => ManagedServiceConfig;
|
|
@@ -1,26 +1,19 @@
|
|
|
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 readServiceConfig = (location) => {
|
|
11
|
-
const file = node_path_1.default.join(location, 'qhub.json');
|
|
12
|
-
if (!node_fs_1.default.existsSync(file)) {
|
|
1
|
+
import fsExtra from 'fs-extra';
|
|
2
|
+
const { createFileSync, readJsonSync, writeJsonSync } = fsExtra;
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
export const readServiceConfig = (location) => {
|
|
6
|
+
const file = path.join(location, 'qhub.json');
|
|
7
|
+
if (!fs.existsSync(file)) {
|
|
13
8
|
throw new Error('No qhub.json file found in current directory');
|
|
14
9
|
}
|
|
15
|
-
return
|
|
10
|
+
return readJsonSync(file, { encoding: 'utf8' });
|
|
16
11
|
};
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(0, fs_extra_1.createFileSync)(file);
|
|
12
|
+
export const writeServiceConfig = (location, serviceConfig) => {
|
|
13
|
+
const file = path.join(location, 'qhub.json');
|
|
14
|
+
if (!fs.existsSync(file)) {
|
|
15
|
+
createFileSync(file);
|
|
22
16
|
}
|
|
23
|
-
|
|
24
|
-
return
|
|
17
|
+
writeJsonSync(file, serviceConfig, { encoding: 'utf8', spaces: 2 });
|
|
18
|
+
return readServiceConfig(location);
|
|
25
19
|
};
|
|
26
|
-
exports.writeServiceConfig = writeServiceConfig;
|
|
@@ -1,26 +1,19 @@
|
|
|
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 readUserConfig = (location) => {
|
|
11
|
-
const file = node_path_1.default.join(location, 'config.json');
|
|
12
|
-
if (!node_fs_1.default.existsSync(file)) {
|
|
1
|
+
import fsExtra from 'fs-extra';
|
|
2
|
+
const { createFileSync, readJsonSync, writeJsonSync } = fsExtra;
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
export const readUserConfig = (location) => {
|
|
6
|
+
const file = path.join(location, 'config.json');
|
|
7
|
+
if (!fs.existsSync(file)) {
|
|
13
8
|
return {};
|
|
14
9
|
}
|
|
15
|
-
return
|
|
10
|
+
return readJsonSync(file, { encoding: 'utf8' });
|
|
16
11
|
};
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(0, fs_extra_1.createFileSync)(file);
|
|
12
|
+
export const writeUserConfig = (location, userConfig) => {
|
|
13
|
+
const file = path.join(location, 'config.json');
|
|
14
|
+
if (!fs.existsSync(file)) {
|
|
15
|
+
createFileSync(file);
|
|
22
16
|
}
|
|
23
|
-
|
|
24
|
-
return
|
|
17
|
+
writeJsonSync(file, userConfig, { encoding: 'utf8', spaces: 2 });
|
|
18
|
+
return readUserConfig(location);
|
|
25
19
|
};
|
|
26
|
-
exports.writeUserConfig = writeUserConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UserDto, UserSettingsApi } from '../client/users';
|
|
2
|
-
import UserConfig from '../model/user-config';
|
|
1
|
+
import { UserDto, UserSettingsApi } from '../client/users/index.js';
|
|
2
|
+
import UserConfig from '../model/user-config.js';
|
|
3
3
|
export default class UserService {
|
|
4
4
|
basePath: string;
|
|
5
5
|
defaultHeaders: Record<string, string>;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const user_config_1 = require("../model/user-config");
|
|
6
|
-
class UserService {
|
|
1
|
+
import { Configuration, UserSettingsApi } from '../client/users/index.js';
|
|
2
|
+
import { handleError } from '../lib/error.js';
|
|
3
|
+
import { defaultBasePath } from '../model/user-config.js';
|
|
4
|
+
export default class UserService {
|
|
7
5
|
basePath;
|
|
8
6
|
defaultHeaders;
|
|
9
7
|
userSettingsApi;
|
|
10
8
|
constructor(userConfig) {
|
|
11
|
-
this.basePath = (userConfig.endpoint?.basePath ||
|
|
9
|
+
this.basePath = (userConfig.endpoint?.basePath || defaultBasePath) + '/user-service';
|
|
12
10
|
this.defaultHeaders = userConfig.endpoint?.defaultHeaders || {};
|
|
13
11
|
const apiKey = userConfig.auth?.value;
|
|
14
|
-
this.userSettingsApi = new
|
|
12
|
+
this.userSettingsApi = new UserSettingsApi(new Configuration({
|
|
15
13
|
apiKey,
|
|
16
14
|
basePath: this.basePath,
|
|
17
15
|
headers: this.defaultHeaders,
|
|
18
16
|
}));
|
|
19
17
|
}
|
|
20
18
|
async getCurrentUser(apiKey) {
|
|
21
|
-
const userSettingsApi = new
|
|
19
|
+
const userSettingsApi = new UserSettingsApi(new Configuration({
|
|
22
20
|
apiKey,
|
|
23
21
|
basePath: this.basePath,
|
|
24
22
|
headers: this.defaultHeaders,
|
|
@@ -27,9 +25,8 @@ class UserService {
|
|
|
27
25
|
return await userSettingsApi.getUser();
|
|
28
26
|
}
|
|
29
27
|
catch (error) {
|
|
30
|
-
const errorMessage = await
|
|
28
|
+
const errorMessage = await handleError(error);
|
|
31
29
|
throw new Error(errorMessage);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
|
-
exports.default = UserService;
|