@planqk/planqk-service-sdk 1.4.0

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 (149) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc +7 -0
  3. package/README.md +35 -0
  4. package/dist/auth.d.ts +10 -0
  5. package/dist/auth.js +46 -0
  6. package/dist/client.d.ts +16 -0
  7. package/dist/client.js +90 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +7 -0
  10. package/dist/sdk/Client.d.ts +25 -0
  11. package/dist/sdk/Client.js +22 -0
  12. package/dist/sdk/api/errors/BadRequestError.d.ts +7 -0
  13. package/dist/sdk/api/errors/BadRequestError.js +41 -0
  14. package/dist/sdk/api/errors/ForbiddenError.d.ts +7 -0
  15. package/dist/sdk/api/errors/ForbiddenError.js +41 -0
  16. package/dist/sdk/api/errors/InternalServerError.d.ts +7 -0
  17. package/dist/sdk/api/errors/InternalServerError.js +41 -0
  18. package/dist/sdk/api/errors/NotFoundError.d.ts +7 -0
  19. package/dist/sdk/api/errors/NotFoundError.js +41 -0
  20. package/dist/sdk/api/errors/UnauthorizedError.d.ts +7 -0
  21. package/dist/sdk/api/errors/UnauthorizedError.js +41 -0
  22. package/dist/sdk/api/errors/index.d.ts +5 -0
  23. package/dist/sdk/api/errors/index.js +21 -0
  24. package/dist/sdk/api/index.d.ts +3 -0
  25. package/dist/sdk/api/index.js +19 -0
  26. package/dist/sdk/api/resources/index.d.ts +5 -0
  27. package/dist/sdk/api/resources/index.js +34 -0
  28. package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +71 -0
  29. package/dist/sdk/api/resources/serviceApi/client/Client.js +361 -0
  30. package/dist/sdk/api/resources/serviceApi/client/index.d.ts +1 -0
  31. package/dist/sdk/api/resources/serviceApi/client/index.js +17 -0
  32. package/dist/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.d.ts +10 -0
  33. package/dist/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.js +5 -0
  34. package/dist/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.d.ts +12 -0
  35. package/dist/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.js +5 -0
  36. package/dist/sdk/api/resources/serviceApi/client/requests/index.d.ts +2 -0
  37. package/dist/sdk/api/resources/serviceApi/client/requests/index.js +2 -0
  38. package/dist/sdk/api/resources/serviceApi/index.d.ts +2 -0
  39. package/dist/sdk/api/resources/serviceApi/index.js +18 -0
  40. package/dist/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.d.ts +5 -0
  41. package/dist/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.js +5 -0
  42. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +5 -0
  43. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.js +5 -0
  44. package/dist/sdk/api/resources/serviceApi/types/index.d.ts +2 -0
  45. package/dist/sdk/api/resources/serviceApi/types/index.js +18 -0
  46. package/dist/sdk/api/resources/statusApi/client/Client.d.ts +28 -0
  47. package/dist/sdk/api/resources/statusApi/client/Client.js +97 -0
  48. package/dist/sdk/api/resources/statusApi/client/index.d.ts +1 -0
  49. package/dist/sdk/api/resources/statusApi/client/index.js +2 -0
  50. package/dist/sdk/api/resources/statusApi/index.d.ts +2 -0
  51. package/dist/sdk/api/resources/statusApi/index.js +18 -0
  52. package/dist/sdk/api/resources/statusApi/types/HealthCheckResponse.d.ts +6 -0
  53. package/dist/sdk/api/resources/statusApi/types/HealthCheckResponse.js +5 -0
  54. package/dist/sdk/api/resources/statusApi/types/index.d.ts +1 -0
  55. package/dist/sdk/api/resources/statusApi/types/index.js +17 -0
  56. package/dist/sdk/api/types/ErrorResponse.d.ts +4 -0
  57. package/dist/sdk/api/types/ErrorResponse.js +5 -0
  58. package/dist/sdk/api/types/InputData.d.ts +4 -0
  59. package/dist/sdk/api/types/InputData.js +5 -0
  60. package/dist/sdk/api/types/InputParams.d.ts +4 -0
  61. package/dist/sdk/api/types/InputParams.js +5 -0
  62. package/dist/sdk/api/types/InterimResultResponse.d.ts +4 -0
  63. package/dist/sdk/api/types/InterimResultResponse.js +5 -0
  64. package/dist/sdk/api/types/Job.d.ts +11 -0
  65. package/dist/sdk/api/types/Job.js +5 -0
  66. package/dist/sdk/api/types/JobStatus.d.ts +12 -0
  67. package/dist/sdk/api/types/JobStatus.js +14 -0
  68. package/dist/sdk/api/types/ResultResponse.d.ts +4 -0
  69. package/dist/sdk/api/types/ResultResponse.js +5 -0
  70. package/dist/sdk/api/types/index.d.ts +7 -0
  71. package/dist/sdk/api/types/index.js +23 -0
  72. package/dist/sdk/core/auth/BasicAuth.d.ts +8 -0
  73. package/dist/sdk/core/auth/BasicAuth.js +26 -0
  74. package/dist/sdk/core/auth/BearerToken.d.ts +5 -0
  75. package/dist/sdk/core/auth/BearerToken.js +15 -0
  76. package/dist/sdk/core/auth/index.d.ts +2 -0
  77. package/dist/sdk/core/auth/index.js +7 -0
  78. package/dist/sdk/core/fetcher/APIResponse.d.ts +9 -0
  79. package/dist/sdk/core/fetcher/APIResponse.js +2 -0
  80. package/dist/sdk/core/fetcher/Fetcher.d.ts +38 -0
  81. package/dist/sdk/core/fetcher/Fetcher.js +130 -0
  82. package/dist/sdk/core/fetcher/Supplier.d.ts +4 -0
  83. package/dist/sdk/core/fetcher/Supplier.js +22 -0
  84. package/dist/sdk/core/fetcher/index.d.ts +4 -0
  85. package/dist/sdk/core/fetcher/index.js +7 -0
  86. package/dist/sdk/core/index.d.ts +2 -0
  87. package/dist/sdk/core/index.js +18 -0
  88. package/dist/sdk/environments.d.ts +7 -0
  89. package/dist/sdk/environments.js +9 -0
  90. package/dist/sdk/errors/PlanqkServiceApiError.d.ts +12 -0
  91. package/dist/sdk/errors/PlanqkServiceApiError.js +32 -0
  92. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +6 -0
  93. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +13 -0
  94. package/dist/sdk/errors/index.d.ts +2 -0
  95. package/dist/sdk/errors/index.js +7 -0
  96. package/dist/sdk/index.d.ts +4 -0
  97. package/dist/sdk/index.js +34 -0
  98. package/jest.config.js +12 -0
  99. package/package.json +51 -0
  100. package/src/auth.ts +42 -0
  101. package/src/client.ts +93 -0
  102. package/src/index.ts +2 -0
  103. package/src/sdk/Client.ts +36 -0
  104. package/src/sdk/api/errors/BadRequestError.ts +16 -0
  105. package/src/sdk/api/errors/ForbiddenError.ts +16 -0
  106. package/src/sdk/api/errors/InternalServerError.ts +16 -0
  107. package/src/sdk/api/errors/NotFoundError.ts +16 -0
  108. package/src/sdk/api/errors/UnauthorizedError.ts +16 -0
  109. package/src/sdk/api/errors/index.ts +5 -0
  110. package/src/sdk/api/index.ts +3 -0
  111. package/src/sdk/api/resources/index.ts +5 -0
  112. package/src/sdk/api/resources/serviceApi/client/Client.ts +365 -0
  113. package/src/sdk/api/resources/serviceApi/client/index.ts +1 -0
  114. package/src/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.ts +11 -0
  115. package/src/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.ts +14 -0
  116. package/src/sdk/api/resources/serviceApi/client/requests/index.ts +2 -0
  117. package/src/sdk/api/resources/serviceApi/index.ts +2 -0
  118. package/src/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.ts +9 -0
  119. package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +7 -0
  120. package/src/sdk/api/resources/serviceApi/types/index.ts +2 -0
  121. package/src/sdk/api/resources/statusApi/client/Client.ts +75 -0
  122. package/src/sdk/api/resources/statusApi/client/index.ts +1 -0
  123. package/src/sdk/api/resources/statusApi/index.ts +2 -0
  124. package/src/sdk/api/resources/statusApi/types/HealthCheckResponse.ts +7 -0
  125. package/src/sdk/api/resources/statusApi/types/index.ts +1 -0
  126. package/src/sdk/api/types/ErrorResponse.ts +5 -0
  127. package/src/sdk/api/types/InputData.ts +5 -0
  128. package/src/sdk/api/types/InputParams.ts +5 -0
  129. package/src/sdk/api/types/InterimResultResponse.ts +5 -0
  130. package/src/sdk/api/types/Job.ts +13 -0
  131. package/src/sdk/api/types/JobStatus.ts +14 -0
  132. package/src/sdk/api/types/ResultResponse.ts +5 -0
  133. package/src/sdk/api/types/index.ts +7 -0
  134. package/src/sdk/core/auth/BasicAuth.ts +31 -0
  135. package/src/sdk/core/auth/BearerToken.ts +15 -0
  136. package/src/sdk/core/auth/index.ts +2 -0
  137. package/src/sdk/core/fetcher/APIResponse.ts +11 -0
  138. package/src/sdk/core/fetcher/Fetcher.ts +160 -0
  139. package/src/sdk/core/fetcher/Supplier.ts +11 -0
  140. package/src/sdk/core/fetcher/index.ts +4 -0
  141. package/src/sdk/core/index.ts +2 -0
  142. package/src/sdk/environments.ts +9 -0
  143. package/src/sdk/errors/PlanqkServiceApiError.ts +45 -0
  144. package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +10 -0
  145. package/src/sdk/errors/index.ts +2 -0
  146. package/src/sdk/index.ts +4 -0
  147. package/tests/fixtures/complex-input.ts +477 -0
  148. package/tests/integration.test.ts +61 -0
  149. package/tsconfig.json +110 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments";
5
+ import * as core from "../../../../core";
6
+ import * as PlanqkServiceApi from "../../..";
7
+ export declare namespace ServiceApi {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
10
+ token: core.Supplier<core.BearerToken>;
11
+ }
12
+ interface RequestOptions {
13
+ timeoutInSeconds?: number;
14
+ maxRetries?: number;
15
+ }
16
+ }
17
+ export declare class ServiceApi {
18
+ protected readonly _options: ServiceApi.Options;
19
+ constructor(_options: ServiceApi.Options);
20
+ /**
21
+ * This method starts an execution of the service, which in turn is processed asynchronously by the platform. The location header of the response contains the URL which can be used to query the status and the result of the execution.
22
+ * @throws {@link PlanqkServiceApi.BadRequestError}
23
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
24
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
25
+ * @throws {@link PlanqkServiceApi.NotFoundError}
26
+ * @throws {@link PlanqkServiceApi.InternalServerError}
27
+ *
28
+ * @example
29
+ * await planqkServiceApi.serviceApi.startExecution({})
30
+ */
31
+ startExecution(request?: PlanqkServiceApi.StartExecutionRequest, requestOptions?: ServiceApi.RequestOptions): Promise<PlanqkServiceApi.Job>;
32
+ /**
33
+ * Checks the status of a service execution.
34
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
35
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
36
+ * @throws {@link PlanqkServiceApi.NotFoundError}
37
+ * @throws {@link PlanqkServiceApi.InternalServerError}
38
+ *
39
+ * @example
40
+ * await planqkServiceApi.serviceApi.getStatus("id")
41
+ */
42
+ getStatus(id: string, requestOptions?: ServiceApi.RequestOptions): Promise<PlanqkServiceApi.Job>;
43
+ /**
44
+ * Gets the result of a service execution.
45
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
46
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
47
+ * @throws {@link PlanqkServiceApi.NotFoundError}
48
+ * @throws {@link PlanqkServiceApi.InternalServerError}
49
+ */
50
+ getResult(id: string, requestOptions?: ServiceApi.RequestOptions): Promise<PlanqkServiceApi.GetResultResponse>;
51
+ /**
52
+ * Gets the last or a list of interim results of a service execution.
53
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
54
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
55
+ * @throws {@link PlanqkServiceApi.NotFoundError}
56
+ * @throws {@link PlanqkServiceApi.InternalServerError}
57
+ */
58
+ getInterimResults(id: string, request?: PlanqkServiceApi.GetInterimResultsRequest, requestOptions?: ServiceApi.RequestOptions): Promise<PlanqkServiceApi.GetInterimResultsResponse>;
59
+ /**
60
+ * Cancels a running service execution.
61
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
62
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
63
+ * @throws {@link PlanqkServiceApi.NotFoundError}
64
+ * @throws {@link PlanqkServiceApi.InternalServerError}
65
+ *
66
+ * @example
67
+ * await planqkServiceApi.serviceApi.cancelExecution("id")
68
+ */
69
+ cancelExecution(id: string, requestOptions?: ServiceApi.RequestOptions): Promise<PlanqkServiceApi.Job>;
70
+ protected _getAuthorizationHeader(): Promise<string>;
71
+ }
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.ServiceApi = void 0;
42
+ const environments = __importStar(require("../../../../environments"));
43
+ const core = __importStar(require("../../../../core"));
44
+ const PlanqkServiceApi = __importStar(require("../../.."));
45
+ const errors = __importStar(require("../../../../errors"));
46
+ const url_join_1 = __importDefault(require("url-join"));
47
+ class ServiceApi {
48
+ constructor(_options) {
49
+ this._options = _options;
50
+ }
51
+ /**
52
+ * This method starts an execution of the service, which in turn is processed asynchronously by the platform. The location header of the response contains the URL which can be used to query the status and the result of the execution.
53
+ * @throws {@link PlanqkServiceApi.BadRequestError}
54
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
55
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
56
+ * @throws {@link PlanqkServiceApi.NotFoundError}
57
+ * @throws {@link PlanqkServiceApi.InternalServerError}
58
+ *
59
+ * @example
60
+ * await planqkServiceApi.serviceApi.startExecution({})
61
+ */
62
+ startExecution(request = {}, requestOptions) {
63
+ var _a;
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const _response = yield core.fetcher({
66
+ url: (_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.PlanqkServiceApiEnvironment.Default,
67
+ method: "POST",
68
+ headers: {
69
+ Authorization: yield this._getAuthorizationHeader(),
70
+ "X-Fern-Language": "JavaScript",
71
+ },
72
+ contentType: "application/json",
73
+ body: request,
74
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
75
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
76
+ withCredentials: true,
77
+ });
78
+ if (_response.ok) {
79
+ return _response.body;
80
+ }
81
+ if (_response.error.reason === "status-code") {
82
+ switch (_response.error.statusCode) {
83
+ case 400:
84
+ throw new PlanqkServiceApi.BadRequestError(_response.error.body);
85
+ case 401:
86
+ throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
87
+ case 403:
88
+ throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
89
+ case 404:
90
+ throw new PlanqkServiceApi.NotFoundError(_response.error.body);
91
+ case 500:
92
+ throw new PlanqkServiceApi.InternalServerError(_response.error.body);
93
+ default:
94
+ throw new errors.PlanqkServiceApiError({
95
+ statusCode: _response.error.statusCode,
96
+ body: _response.error.body,
97
+ });
98
+ }
99
+ }
100
+ switch (_response.error.reason) {
101
+ case "non-json":
102
+ throw new errors.PlanqkServiceApiError({
103
+ statusCode: _response.error.statusCode,
104
+ body: _response.error.rawBody,
105
+ });
106
+ case "timeout":
107
+ throw new errors.PlanqkServiceApiTimeoutError();
108
+ case "unknown":
109
+ throw new errors.PlanqkServiceApiError({
110
+ message: _response.error.errorMessage,
111
+ });
112
+ }
113
+ });
114
+ }
115
+ /**
116
+ * Checks the status of a service execution.
117
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
118
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
119
+ * @throws {@link PlanqkServiceApi.NotFoundError}
120
+ * @throws {@link PlanqkServiceApi.InternalServerError}
121
+ *
122
+ * @example
123
+ * await planqkServiceApi.serviceApi.getStatus("id")
124
+ */
125
+ getStatus(id, requestOptions) {
126
+ var _a;
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ const _response = yield core.fetcher({
129
+ url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.PlanqkServiceApiEnvironment.Default, `${id}`),
130
+ method: "GET",
131
+ headers: {
132
+ Authorization: yield this._getAuthorizationHeader(),
133
+ "X-Fern-Language": "JavaScript",
134
+ },
135
+ contentType: "application/json",
136
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
137
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
138
+ withCredentials: true,
139
+ });
140
+ if (_response.ok) {
141
+ return _response.body;
142
+ }
143
+ if (_response.error.reason === "status-code") {
144
+ switch (_response.error.statusCode) {
145
+ case 401:
146
+ throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
147
+ case 403:
148
+ throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
149
+ case 404:
150
+ throw new PlanqkServiceApi.NotFoundError(_response.error.body);
151
+ case 500:
152
+ throw new PlanqkServiceApi.InternalServerError(_response.error.body);
153
+ default:
154
+ throw new errors.PlanqkServiceApiError({
155
+ statusCode: _response.error.statusCode,
156
+ body: _response.error.body,
157
+ });
158
+ }
159
+ }
160
+ switch (_response.error.reason) {
161
+ case "non-json":
162
+ throw new errors.PlanqkServiceApiError({
163
+ statusCode: _response.error.statusCode,
164
+ body: _response.error.rawBody,
165
+ });
166
+ case "timeout":
167
+ throw new errors.PlanqkServiceApiTimeoutError();
168
+ case "unknown":
169
+ throw new errors.PlanqkServiceApiError({
170
+ message: _response.error.errorMessage,
171
+ });
172
+ }
173
+ });
174
+ }
175
+ /**
176
+ * Gets the result of a service execution.
177
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
178
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
179
+ * @throws {@link PlanqkServiceApi.NotFoundError}
180
+ * @throws {@link PlanqkServiceApi.InternalServerError}
181
+ */
182
+ getResult(id, requestOptions) {
183
+ var _a;
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ const _response = yield core.fetcher({
186
+ url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.PlanqkServiceApiEnvironment.Default, `${id}/result`),
187
+ method: "GET",
188
+ headers: {
189
+ Authorization: yield this._getAuthorizationHeader(),
190
+ "X-Fern-Language": "JavaScript",
191
+ },
192
+ contentType: "application/json",
193
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
194
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
195
+ withCredentials: true,
196
+ });
197
+ if (_response.ok) {
198
+ return _response.body;
199
+ }
200
+ if (_response.error.reason === "status-code") {
201
+ switch (_response.error.statusCode) {
202
+ case 401:
203
+ throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
204
+ case 403:
205
+ throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
206
+ case 404:
207
+ throw new PlanqkServiceApi.NotFoundError(_response.error.body);
208
+ case 500:
209
+ throw new PlanqkServiceApi.InternalServerError(_response.error.body);
210
+ default:
211
+ throw new errors.PlanqkServiceApiError({
212
+ statusCode: _response.error.statusCode,
213
+ body: _response.error.body,
214
+ });
215
+ }
216
+ }
217
+ switch (_response.error.reason) {
218
+ case "non-json":
219
+ throw new errors.PlanqkServiceApiError({
220
+ statusCode: _response.error.statusCode,
221
+ body: _response.error.rawBody,
222
+ });
223
+ case "timeout":
224
+ throw new errors.PlanqkServiceApiTimeoutError();
225
+ case "unknown":
226
+ throw new errors.PlanqkServiceApiError({
227
+ message: _response.error.errorMessage,
228
+ });
229
+ }
230
+ });
231
+ }
232
+ /**
233
+ * Gets the last or a list of interim results of a service execution.
234
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
235
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
236
+ * @throws {@link PlanqkServiceApi.NotFoundError}
237
+ * @throws {@link PlanqkServiceApi.InternalServerError}
238
+ */
239
+ getInterimResults(id, request = {}, requestOptions) {
240
+ var _a;
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ const { last } = request;
243
+ const _queryParams = {};
244
+ if (last != null) {
245
+ _queryParams["last"] = last.toString();
246
+ }
247
+ const _response = yield core.fetcher({
248
+ url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.PlanqkServiceApiEnvironment.Default, `${id}/interim-results`),
249
+ method: "GET",
250
+ headers: {
251
+ Authorization: yield this._getAuthorizationHeader(),
252
+ "X-Fern-Language": "JavaScript",
253
+ },
254
+ contentType: "application/json",
255
+ queryParameters: _queryParams,
256
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
257
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
258
+ withCredentials: true,
259
+ });
260
+ if (_response.ok) {
261
+ return _response.body;
262
+ }
263
+ if (_response.error.reason === "status-code") {
264
+ switch (_response.error.statusCode) {
265
+ case 401:
266
+ throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
267
+ case 403:
268
+ throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
269
+ case 404:
270
+ throw new PlanqkServiceApi.NotFoundError(_response.error.body);
271
+ case 500:
272
+ throw new PlanqkServiceApi.InternalServerError(_response.error.body);
273
+ default:
274
+ throw new errors.PlanqkServiceApiError({
275
+ statusCode: _response.error.statusCode,
276
+ body: _response.error.body,
277
+ });
278
+ }
279
+ }
280
+ switch (_response.error.reason) {
281
+ case "non-json":
282
+ throw new errors.PlanqkServiceApiError({
283
+ statusCode: _response.error.statusCode,
284
+ body: _response.error.rawBody,
285
+ });
286
+ case "timeout":
287
+ throw new errors.PlanqkServiceApiTimeoutError();
288
+ case "unknown":
289
+ throw new errors.PlanqkServiceApiError({
290
+ message: _response.error.errorMessage,
291
+ });
292
+ }
293
+ });
294
+ }
295
+ /**
296
+ * Cancels a running service execution.
297
+ * @throws {@link PlanqkServiceApi.UnauthorizedError}
298
+ * @throws {@link PlanqkServiceApi.ForbiddenError}
299
+ * @throws {@link PlanqkServiceApi.NotFoundError}
300
+ * @throws {@link PlanqkServiceApi.InternalServerError}
301
+ *
302
+ * @example
303
+ * await planqkServiceApi.serviceApi.cancelExecution("id")
304
+ */
305
+ cancelExecution(id, requestOptions) {
306
+ var _a;
307
+ return __awaiter(this, void 0, void 0, function* () {
308
+ const _response = yield core.fetcher({
309
+ url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.PlanqkServiceApiEnvironment.Default, `${id}/cancel`),
310
+ method: "PUT",
311
+ headers: {
312
+ Authorization: yield this._getAuthorizationHeader(),
313
+ "X-Fern-Language": "JavaScript",
314
+ },
315
+ contentType: "application/json",
316
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
317
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
318
+ withCredentials: true,
319
+ });
320
+ if (_response.ok) {
321
+ return _response.body;
322
+ }
323
+ if (_response.error.reason === "status-code") {
324
+ switch (_response.error.statusCode) {
325
+ case 401:
326
+ throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
327
+ case 403:
328
+ throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
329
+ case 404:
330
+ throw new PlanqkServiceApi.NotFoundError(_response.error.body);
331
+ case 500:
332
+ throw new PlanqkServiceApi.InternalServerError(_response.error.body);
333
+ default:
334
+ throw new errors.PlanqkServiceApiError({
335
+ statusCode: _response.error.statusCode,
336
+ body: _response.error.body,
337
+ });
338
+ }
339
+ }
340
+ switch (_response.error.reason) {
341
+ case "non-json":
342
+ throw new errors.PlanqkServiceApiError({
343
+ statusCode: _response.error.statusCode,
344
+ body: _response.error.rawBody,
345
+ });
346
+ case "timeout":
347
+ throw new errors.PlanqkServiceApiTimeoutError();
348
+ case "unknown":
349
+ throw new errors.PlanqkServiceApiError({
350
+ message: _response.error.errorMessage,
351
+ });
352
+ }
353
+ });
354
+ }
355
+ _getAuthorizationHeader() {
356
+ return __awaiter(this, void 0, void 0, function* () {
357
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
358
+ });
359
+ }
360
+ }
361
+ exports.ServiceApi = ServiceApi;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface GetInterimResultsRequest {
5
+ /**
6
+ * Either true or false to show only the last or all interim results (default: false).
7
+ *
8
+ */
9
+ last?: boolean;
10
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as PlanqkServiceApi from "../../../..";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface StartExecutionRequest {
10
+ data?: PlanqkServiceApi.InputData;
11
+ params?: PlanqkServiceApi.InputParams;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { StartExecutionRequest } from "./StartExecutionRequest";
2
+ export { GetInterimResultsRequest } from "./GetInterimResultsRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./client";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client"), exports);
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as PlanqkServiceApi from "../../..";
5
+ export type GetInterimResultsResponse = PlanqkServiceApi.InterimResultResponse[] | PlanqkServiceApi.InterimResultResponse;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as PlanqkServiceApi from "../../..";
5
+ export type GetResultResponse = PlanqkServiceApi.ResultResponse | PlanqkServiceApi.ErrorResponse;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./GetResultResponse";
2
+ export * from "./GetInterimResultsResponse";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./GetResultResponse"), exports);
18
+ __exportStar(require("./GetInterimResultsResponse"), exports);
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments";
5
+ import * as core from "../../../../core";
6
+ import * as PlanqkServiceApi from "../../..";
7
+ export declare namespace StatusApi {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
10
+ token: core.Supplier<core.BearerToken>;
11
+ }
12
+ interface RequestOptions {
13
+ timeoutInSeconds?: number;
14
+ maxRetries?: number;
15
+ }
16
+ }
17
+ export declare class StatusApi {
18
+ protected readonly _options: StatusApi.Options;
19
+ constructor(_options: StatusApi.Options);
20
+ /**
21
+ * Checks the health of the service.
22
+ *
23
+ * @example
24
+ * await planqkServiceApi.statusApi.healthCheck()
25
+ */
26
+ healthCheck(requestOptions?: StatusApi.RequestOptions): Promise<PlanqkServiceApi.HealthCheckResponse>;
27
+ protected _getAuthorizationHeader(): Promise<string>;
28
+ }