@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.
Files changed (211) hide show
  1. package/README.md +1 -1
  2. package/bin/dev.js +3 -1
  3. package/bin/run.js +1 -1
  4. package/dist/client/kqh/apis/ServicePlatformApplicationsApi.d.ts +2 -2
  5. package/dist/client/kqh/apis/ServicePlatformApplicationsApi.js +9 -46
  6. package/dist/client/kqh/apis/ServicePlatformDashboardApi.d.ts +2 -2
  7. package/dist/client/kqh/apis/ServicePlatformDashboardApi.js +5 -42
  8. package/dist/client/kqh/apis/ServicePlatformDataPoolsApi.d.ts +2 -2
  9. package/dist/client/kqh/apis/ServicePlatformDataPoolsApi.js +11 -48
  10. package/dist/client/kqh/apis/ServicePlatformJobsApi.d.ts +2 -2
  11. package/dist/client/kqh/apis/ServicePlatformJobsApi.js +9 -46
  12. package/dist/client/kqh/apis/ServicePlatformMarketplaceApi.d.ts +2 -2
  13. package/dist/client/kqh/apis/ServicePlatformMarketplaceApi.js +5 -42
  14. package/dist/client/kqh/apis/ServicePlatformMeteringAPIApi.d.ts +2 -2
  15. package/dist/client/kqh/apis/ServicePlatformMeteringAPIApi.js +5 -42
  16. package/dist/client/kqh/apis/ServicePlatformServicesApi.d.ts +2 -2
  17. package/dist/client/kqh/apis/ServicePlatformServicesApi.js +34 -71
  18. package/dist/client/kqh/apis/ServicePlatformSubscriptionsApi.d.ts +2 -2
  19. package/dist/client/kqh/apis/ServicePlatformSubscriptionsApi.js +7 -44
  20. package/dist/client/kqh/apis/TaxonomiesApi.d.ts +2 -2
  21. package/dist/client/kqh/apis/TaxonomiesApi.js +12 -49
  22. package/dist/client/kqh/apis/index.d.ts +9 -9
  23. package/dist/client/kqh/apis/index.js +9 -25
  24. package/dist/client/kqh/index.d.ts +3 -3
  25. package/dist/client/kqh/index.js +3 -19
  26. package/dist/client/kqh/models/AccessTokenDto.js +5 -12
  27. package/dist/client/kqh/models/AmountMajorDto.js +4 -10
  28. package/dist/client/kqh/models/ApiDto.d.ts +2 -2
  29. package/dist/client/kqh/models/ApiDto.js +13 -20
  30. package/dist/client/kqh/models/ApiOverviewDto.d.ts +1 -1
  31. package/dist/client/kqh/models/ApiOverviewDto.js +10 -17
  32. package/dist/client/kqh/models/ApplicationDto.js +5 -12
  33. package/dist/client/kqh/models/BuildJobDto.d.ts +1 -1
  34. package/dist/client/kqh/models/BuildJobDto.js +9 -16
  35. package/dist/client/kqh/models/CpuConfiguration.d.ts +1 -1
  36. package/dist/client/kqh/models/CpuConfiguration.js +7 -13
  37. package/dist/client/kqh/models/CreateApplicationRequest.js +4 -10
  38. package/dist/client/kqh/models/CreateDataPoolRequest.js +4 -10
  39. package/dist/client/kqh/models/CreateExternalServicePricingPlanRequest.d.ts +1 -1
  40. package/dist/client/kqh/models/CreateExternalServicePricingPlanRequest.js +8 -15
  41. package/dist/client/kqh/models/CreateJobRequest.d.ts +1 -1
  42. package/dist/client/kqh/models/CreateJobRequest.js +9 -15
  43. package/dist/client/kqh/models/CreateManagedServicePricingPlanRequest.js +6 -13
  44. package/dist/client/kqh/models/CreateProductRequest.js +4 -10
  45. package/dist/client/kqh/models/CreateSubscriptionRequest.js +4 -10
  46. package/dist/client/kqh/models/CreateWorkflowServiceRequest.js +4 -10
  47. package/dist/client/kqh/models/DataPoolDto.d.ts +3 -3
  48. package/dist/client/kqh/models/DataPoolDto.js +21 -28
  49. package/dist/client/kqh/models/DataPoolRef.js +4 -10
  50. package/dist/client/kqh/models/DataSourceDescriptorDto.d.ts +1 -1
  51. package/dist/client/kqh/models/DataSourceDescriptorDto.js +8 -15
  52. package/dist/client/kqh/models/FileDto.js +4 -10
  53. package/dist/client/kqh/models/FileSource.d.ts +1 -1
  54. package/dist/client/kqh/models/FileSource.js +4 -10
  55. package/dist/client/kqh/models/GpuConfiguration.d.ts +1 -1
  56. package/dist/client/kqh/models/GpuConfiguration.js +8 -15
  57. package/dist/client/kqh/models/JobDto.d.ts +2 -2
  58. package/dist/client/kqh/models/JobDto.js +13 -20
  59. package/dist/client/kqh/models/JobOverviewDto.d.ts +1 -1
  60. package/dist/client/kqh/models/JobOverviewDto.js +8 -15
  61. package/dist/client/kqh/models/MemoryConfiguration.d.ts +1 -1
  62. package/dist/client/kqh/models/MemoryConfiguration.js +7 -13
  63. package/dist/client/kqh/models/MeteringRequest.js +4 -10
  64. package/dist/client/kqh/models/MeteringResponse.js +4 -10
  65. package/dist/client/kqh/models/MonthAmountDto.d.ts +2 -2
  66. package/dist/client/kqh/models/MonthAmountDto.js +10 -16
  67. package/dist/client/kqh/models/OwnerDto.js +4 -10
  68. package/dist/client/kqh/models/PageDataPoolDto.d.ts +3 -3
  69. package/dist/client/kqh/models/PageDataPoolDto.js +13 -19
  70. package/dist/client/kqh/models/PageableObject.d.ts +1 -1
  71. package/dist/client/kqh/models/PageableObject.js +7 -13
  72. package/dist/client/kqh/models/PricingPlanDto.d.ts +1 -1
  73. package/dist/client/kqh/models/PricingPlanDto.js +8 -15
  74. package/dist/client/kqh/models/ProductAmountDto.d.ts +1 -1
  75. package/dist/client/kqh/models/ProductAmountDto.js +7 -13
  76. package/dist/client/kqh/models/ProductDto.js +5 -12
  77. package/dist/client/kqh/models/ProductGroupDto.d.ts +2 -2
  78. package/dist/client/kqh/models/ProductGroupDto.js +10 -16
  79. package/dist/client/kqh/models/ProductUsageDto.js +4 -10
  80. package/dist/client/kqh/models/RegistrySource.d.ts +1 -1
  81. package/dist/client/kqh/models/RegistrySource.js +7 -13
  82. package/dist/client/kqh/models/RepositorySource.d.ts +1 -1
  83. package/dist/client/kqh/models/RepositorySource.js +7 -13
  84. package/dist/client/kqh/models/ResourceConfiguration.js +10 -16
  85. package/dist/client/kqh/models/ReviewDto.js +5 -12
  86. package/dist/client/kqh/models/RuntimeConfiguration.js +5 -12
  87. package/dist/client/kqh/models/ServiceDefinitionCommand.js +5 -12
  88. package/dist/client/kqh/models/ServiceDefinitionDto.d.ts +5 -5
  89. package/dist/client/kqh/models/ServiceDefinitionDto.js +21 -28
  90. package/dist/client/kqh/models/ServiceDefinitionDtoSource.d.ts +3 -3
  91. package/dist/client/kqh/models/ServiceDefinitionDtoSource.js +18 -23
  92. package/dist/client/kqh/models/ServiceDefinitionOverviewDto.js +6 -13
  93. package/dist/client/kqh/models/ServiceDto.d.ts +1 -1
  94. package/dist/client/kqh/models/ServiceDto.js +8 -15
  95. package/dist/client/kqh/models/ServiceExecutionConsumerDto.js +5 -12
  96. package/dist/client/kqh/models/ServiceExecutionDto.js +4 -10
  97. package/dist/client/kqh/models/ServiceOverviewDto.js +8 -15
  98. package/dist/client/kqh/models/ServiceSource.js +10 -16
  99. package/dist/client/kqh/models/SortObject.js +4 -10
  100. package/dist/client/kqh/models/SubscriptionDto.d.ts +3 -3
  101. package/dist/client/kqh/models/SubscriptionDto.js +13 -19
  102. package/dist/client/kqh/models/TaxonomyElement.js +4 -10
  103. package/dist/client/kqh/models/UpdateDataPoolRequest.js +4 -10
  104. package/dist/client/kqh/models/UpdateResourceConfigurationRequest.d.ts +3 -3
  105. package/dist/client/kqh/models/UpdateResourceConfigurationRequest.js +18 -23
  106. package/dist/client/kqh/models/UpdateVersionRequest.d.ts +1 -1
  107. package/dist/client/kqh/models/UpdateVersionRequest.js +7 -13
  108. package/dist/client/kqh/models/UpdateWorkflowServiceRequest.js +4 -10
  109. package/dist/client/kqh/models/ValidationResult.js +5 -12
  110. package/dist/client/kqh/models/index.d.ts +57 -57
  111. package/dist/client/kqh/models/index.js +57 -73
  112. package/dist/client/kqh/runtime.js +17 -32
  113. package/dist/client/users/apis/AuthenticationApi.d.ts +2 -2
  114. package/dist/client/users/apis/AuthenticationApi.js +4 -41
  115. package/dist/client/users/apis/ExpertsApi.d.ts +2 -2
  116. package/dist/client/users/apis/ExpertsApi.js +5 -42
  117. package/dist/client/users/apis/SearchApi.d.ts +2 -2
  118. package/dist/client/users/apis/SearchApi.js +5 -42
  119. package/dist/client/users/apis/UserSettingsApi.d.ts +2 -2
  120. package/dist/client/users/apis/UserSettingsApi.js +11 -48
  121. package/dist/client/users/apis/UserSettingsPersonalAccessTokensApi.d.ts +2 -2
  122. package/dist/client/users/apis/UserSettingsPersonalAccessTokensApi.js +7 -44
  123. package/dist/client/users/apis/UsersApi.d.ts +2 -2
  124. package/dist/client/users/apis/UsersApi.js +4 -41
  125. package/dist/client/users/apis/index.d.ts +6 -6
  126. package/dist/client/users/apis/index.js +6 -22
  127. package/dist/client/users/index.d.ts +3 -3
  128. package/dist/client/users/index.js +3 -19
  129. package/dist/client/users/models/AccessTokenCreateRequest.js +5 -12
  130. package/dist/client/users/models/AccessTokenDto.js +5 -12
  131. package/dist/client/users/models/AccessTokensResponse.d.ts +1 -1
  132. package/dist/client/users/models/AccessTokensResponse.js +7 -13
  133. package/dist/client/users/models/DefaultAccessTokenResponse.js +4 -10
  134. package/dist/client/users/models/Language.js +4 -10
  135. package/dist/client/users/models/PageUserDto.d.ts +3 -3
  136. package/dist/client/users/models/PageUserDto.js +13 -19
  137. package/dist/client/users/models/Pageable.js +4 -10
  138. package/dist/client/users/models/PageableObject.d.ts +1 -1
  139. package/dist/client/users/models/PageableObject.js +7 -13
  140. package/dist/client/users/models/PersonalAccessTokenPrincipal.d.ts +1 -1
  141. package/dist/client/users/models/PersonalAccessTokenPrincipal.js +7 -13
  142. package/dist/client/users/models/Skill.js +4 -10
  143. package/dist/client/users/models/SortObject.js +4 -10
  144. package/dist/client/users/models/UpdateUserRequest.js +4 -10
  145. package/dist/client/users/models/UserDto.d.ts +2 -2
  146. package/dist/client/users/models/UserDto.js +10 -16
  147. package/dist/client/users/models/UserOverviewDto.js +4 -10
  148. package/dist/client/users/models/index.d.ts +14 -14
  149. package/dist/client/users/models/index.js +14 -30
  150. package/dist/client/users/runtime.js +17 -32
  151. package/dist/commands/compress/index.d.ts +1 -1
  152. package/dist/commands/compress/index.js +13 -19
  153. package/dist/commands/datapool/upload.d.ts +4 -4
  154. package/dist/commands/datapool/upload.js +24 -30
  155. package/dist/commands/get-context/index.d.ts +1 -1
  156. package/dist/commands/get-context/index.js +2 -5
  157. package/dist/commands/init/index.d.ts +3 -3
  158. package/dist/commands/init/index.js +30 -36
  159. package/dist/commands/list-contexts/index.d.ts +2 -2
  160. package/dist/commands/list-contexts/index.js +11 -17
  161. package/dist/commands/login/index.d.ts +3 -3
  162. package/dist/commands/login/index.js +16 -22
  163. package/dist/commands/logout/index.d.ts +1 -1
  164. package/dist/commands/logout/index.js +7 -10
  165. package/dist/commands/openapi/index.d.ts +7 -7
  166. package/dist/commands/openapi/index.js +81 -87
  167. package/dist/commands/run/index.d.ts +6 -6
  168. package/dist/commands/run/index.js +43 -48
  169. package/dist/commands/serve/index.d.ts +3 -3
  170. package/dist/commands/serve/index.js +31 -37
  171. package/dist/commands/services/index.d.ts +5 -5
  172. package/dist/commands/services/index.js +17 -23
  173. package/dist/commands/set-context/index.d.ts +4 -4
  174. package/dist/commands/set-context/index.js +13 -19
  175. package/dist/commands/up/index.d.ts +5 -5
  176. package/dist/commands/up/index.js +51 -57
  177. package/dist/index.js +1 -4
  178. package/dist/lib/command.js +5 -10
  179. package/dist/lib/debug.js +1 -5
  180. package/dist/lib/entrypoint-resolver.js +3 -7
  181. package/dist/lib/error.js +8 -12
  182. package/dist/lib/fetch.js +4 -10
  183. package/dist/lib/init-user-input.d.ts +1 -1
  184. package/dist/lib/init-user-input.js +16 -20
  185. package/dist/lib/random-name.js +1 -5
  186. package/dist/lib/random-string.js +1 -5
  187. package/dist/lib/repository.js +9 -17
  188. package/dist/lib/stream-to-blob.d.ts +1 -1
  189. package/dist/lib/stream-to-blob.js +1 -5
  190. package/dist/lib/up/get-description.js +9 -15
  191. package/dist/lib/up/ignore.js +9 -15
  192. package/dist/lib/up/zip.js +18 -24
  193. package/dist/model/account.js +1 -2
  194. package/dist/model/command.d.ts +2 -2
  195. package/dist/model/command.js +11 -19
  196. package/dist/model/managed-service-config.js +4 -7
  197. package/dist/model/user-config.js +3 -6
  198. package/dist/service/auth-service.d.ts +3 -3
  199. package/dist/service/auth-service.js +8 -14
  200. package/dist/service/command-service.d.ts +2 -2
  201. package/dist/service/command-service.js +1 -5
  202. package/dist/service/quantum-hub-service.d.ts +10 -10
  203. package/dist/service/quantum-hub-service.js +21 -24
  204. package/dist/service/service-config-service.d.ts +1 -1
  205. package/dist/service/service-config-service.js +14 -21
  206. package/dist/service/user-config-service.d.ts +1 -1
  207. package/dist/service/user-config-service.js +14 -21
  208. package/dist/service/user-service.d.ts +2 -2
  209. package/dist/service/user-service.js +8 -11
  210. package/oclif.manifest.json +170 -170
  211. package/package.json +4 -2
@@ -1,26 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const platform_1 = require("@quantum-hub/qhub-api/dist/api/platform");
4
- const kqh_1 = require("../client/kqh");
5
- const error_1 = require("../lib/error");
6
- const fetch_1 = require("../lib/fetch");
7
- const user_config_1 = require("../model/user-config");
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 || user_config_1.defaultBasePath) + '/qc-catalog';
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 kqh_1.ServicePlatformServicesApi(new kqh_1.Configuration({
16
+ this.serviceApi = new ServicePlatformServicesApi(new Configuration({
19
17
  apiKey,
20
18
  basePath,
21
19
  headers: defaultHeaders,
22
20
  }));
23
- this.apiClient = new platform_1.HubPlatformClient({
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 (0, error_1.handleError)(error);
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 || user_config_1.defaultBasePath) + '/qc-catalog';
52
+ const basePath = (this.userConfig.endpoint?.basePath || defaultBasePath) + '/qc-catalog';
55
53
  try {
56
- const response = await (0, fetch_1.fetchOrThrow)(basePath + '/my/accounts', {
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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 (0, error_1.handleError)(error);
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
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.writeServiceConfig = exports.readServiceConfig = void 0;
7
- const fs_extra_1 = require("fs-extra");
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 (0, fs_extra_1.readJsonSync)(file, { encoding: 'utf8' });
10
+ return readJsonSync(file, { encoding: 'utf8' });
16
11
  };
17
- exports.readServiceConfig = readServiceConfig;
18
- const writeServiceConfig = (location, serviceConfig) => {
19
- const file = node_path_1.default.join(location, 'qhub.json');
20
- if (!node_fs_1.default.existsSync(file)) {
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
- (0, fs_extra_1.writeJsonSync)(file, serviceConfig, { encoding: 'utf8', spaces: 2 });
24
- return (0, exports.readServiceConfig)(location);
17
+ writeJsonSync(file, serviceConfig, { encoding: 'utf8', spaces: 2 });
18
+ return readServiceConfig(location);
25
19
  };
26
- exports.writeServiceConfig = writeServiceConfig;
@@ -1,3 +1,3 @@
1
- import UserConfig from '../model/user-config';
1
+ import UserConfig from '../model/user-config.js';
2
2
  export declare const readUserConfig: (location: string) => UserConfig;
3
3
  export declare const writeUserConfig: (location: string, userConfig: UserConfig) => UserConfig;
@@ -1,26 +1,19 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.writeUserConfig = exports.readUserConfig = void 0;
7
- const fs_extra_1 = require("fs-extra");
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 (0, fs_extra_1.readJsonSync)(file, { encoding: 'utf8' });
10
+ return readJsonSync(file, { encoding: 'utf8' });
16
11
  };
17
- exports.readUserConfig = readUserConfig;
18
- const writeUserConfig = (location, userConfig) => {
19
- const file = node_path_1.default.join(location, 'config.json');
20
- if (!node_fs_1.default.existsSync(file)) {
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
- (0, fs_extra_1.writeJsonSync)(file, userConfig, { encoding: 'utf8', spaces: 2 });
24
- return (0, exports.readUserConfig)(location);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const users_1 = require("../client/users");
4
- const error_1 = require("../lib/error");
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 || user_config_1.defaultBasePath) + '/user-service';
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 users_1.UserSettingsApi(new users_1.Configuration({
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 users_1.UserSettingsApi(new users_1.Configuration({
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 (0, error_1.handleError)(error);
28
+ const errorMessage = await handleError(error);
31
29
  throw new Error(errorMessage);
32
30
  }
33
31
  }
34
32
  }
35
- exports.default = UserService;