@planqk/planqk-service-sdk 2.7.0 → 2.9.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.
- package/dist/sdk/BaseClient.d.ts +26 -0
- package/dist/sdk/{api/resources/serviceApi/types/GetResultResponse.js → BaseClient.js} +1 -3
- package/dist/sdk/Client.d.ts +3 -21
- package/dist/sdk/Client.js +1 -3
- package/dist/sdk/api/index.d.ts +1 -1
- package/dist/sdk/api/index.js +1 -1
- package/dist/sdk/api/resources/index.d.ts +0 -1
- package/dist/sdk/api/resources/index.js +0 -4
- package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +6 -23
- package/dist/sdk/api/resources/serviceApi/client/Client.js +37 -25
- package/dist/sdk/api/resources/serviceApi/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/index.js +0 -1
- package/dist/sdk/api/types/HalLink.d.ts +0 -3
- package/dist/sdk/api/types/HalLink.js +1 -3
- package/dist/sdk/api/types/LogEntry.d.ts +15 -4
- package/dist/sdk/api/types/LogEntry.js +13 -3
- package/dist/sdk/api/types/RequestBody.d.ts +1 -0
- package/dist/sdk/api/types/RequestBody.js +3 -0
- package/dist/sdk/api/types/ResultResponse.d.ts +15 -0
- package/dist/sdk/api/types/ResultResponse.js +3 -0
- package/dist/sdk/api/types/ServiceExecution.d.ts +22 -5
- package/dist/sdk/api/types/ServiceExecution.js +7 -3
- package/dist/sdk/api/types/index.d.ts +2 -0
- package/dist/sdk/api/types/index.js +2 -0
- package/dist/sdk/core/auth/AuthProvider.d.ts +4 -0
- package/dist/sdk/core/auth/AuthProvider.js +2 -0
- package/dist/sdk/core/auth/AuthRequest.d.ts +9 -0
- package/dist/sdk/core/auth/AuthRequest.js +2 -0
- package/dist/sdk/core/auth/BasicAuth.js +2 -1
- package/dist/sdk/core/auth/index.d.ts +2 -0
- package/dist/sdk/core/fetcher/APIResponse.d.ts +1 -1
- package/dist/sdk/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/sdk/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/sdk/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/sdk/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/sdk/core/fetcher/EndpointSupplier.js +13 -0
- package/dist/sdk/core/fetcher/Fetcher.d.ts +6 -4
- package/dist/sdk/core/fetcher/Fetcher.js +3 -3
- package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +1 -1
- package/dist/sdk/core/fetcher/index.d.ts +7 -5
- package/dist/sdk/core/fetcher/index.js +7 -5
- package/dist/sdk/core/fetcher/requestWithRetries.js +44 -8
- package/dist/sdk/core/headers.d.ts +2 -3
- package/dist/sdk/core/url/join.js +23 -3
- package/dist/sdk/environments.d.ts +0 -3
- package/dist/sdk/environments.js +1 -3
- package/dist/sdk/errors/PlanqkServiceApiError.d.ts +0 -3
- package/dist/sdk/errors/PlanqkServiceApiError.js +1 -3
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +0 -3
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +1 -3
- package/dist/sdk/index.d.ts +1 -0
- package/fern/fern.config.json +1 -1
- package/fern/openapi/openapi.yml +46 -6
- package/package.json +1 -1
- package/planqk/service/_version.py +1 -1
- package/planqk/service/sdk/__init__.py +6 -0
- package/planqk/service/sdk/types/__init__.py +6 -0
- package/planqk/service/sdk/types/log_entry.py +15 -3
- package/planqk/service/sdk/types/log_entry_severity.py +5 -0
- package/planqk/service/sdk/types/service_execution.py +57 -5
- package/planqk/service/sdk/types/service_execution_type.py +5 -0
- package/pyproject.toml +1 -1
- package/requirements-dev.txt +117 -83
- package/requirements.txt +58 -58
- package/src/index.test.ts +10 -0
- package/src/sdk/BaseClient.ts +30 -0
- package/src/sdk/Client.ts +5 -22
- package/src/sdk/api/index.ts +1 -1
- package/src/sdk/api/resources/index.ts +0 -1
- package/src/sdk/api/resources/serviceApi/client/Client.ts +73 -76
- package/src/sdk/api/resources/serviceApi/index.ts +0 -1
- package/src/sdk/api/types/HalLink.ts +1 -3
- package/src/sdk/api/types/LogEntry.ts +17 -4
- package/src/sdk/api/types/RequestBody.ts +3 -0
- package/src/sdk/api/types/ResultResponse.ts +20 -0
- package/src/sdk/api/types/ServiceExecution.ts +23 -5
- package/src/sdk/api/types/index.ts +2 -0
- package/src/sdk/core/auth/AuthProvider.ts +5 -0
- package/src/sdk/core/auth/AuthRequest.ts +9 -0
- package/src/sdk/core/auth/BasicAuth.ts +2 -1
- package/src/sdk/core/auth/index.ts +2 -0
- package/src/sdk/core/fetcher/APIResponse.ts +1 -1
- package/src/sdk/core/fetcher/BinaryResponse.ts +1 -1
- package/src/sdk/core/fetcher/EndpointMetadata.ts +13 -0
- package/src/sdk/core/fetcher/EndpointSupplier.ts +14 -0
- package/src/sdk/core/fetcher/Fetcher.ts +8 -6
- package/src/sdk/core/fetcher/HttpResponsePromise.ts +1 -1
- package/src/sdk/core/fetcher/index.ts +7 -5
- package/src/sdk/core/fetcher/requestWithRetries.ts +49 -9
- package/src/sdk/core/headers.ts +8 -10
- package/src/sdk/core/url/join.ts +28 -3
- package/src/sdk/environments.ts +1 -3
- package/src/sdk/errors/PlanqkServiceApiError.ts +1 -3
- package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +1 -3
- package/src/sdk/index.ts +1 -0
- package/uv.lock +260 -109
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +0 -18
- package/dist/sdk/api/resources/serviceApi/types/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/types/index.js +0 -17
- package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +0 -22
- package/src/sdk/api/resources/serviceApi/types/index.ts +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
4
2
|
|
|
3
|
+
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
5
4
|
import * as environments from "../../../../environments.js";
|
|
6
5
|
import * as core from "../../../../core/index.js";
|
|
7
6
|
import * as PlanqkServiceApi from "../../../index.js";
|
|
@@ -9,25 +8,9 @@ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.
|
|
|
9
8
|
import * as errors from "../../../../errors/index.js";
|
|
10
9
|
|
|
11
10
|
export declare namespace ServiceApi {
|
|
12
|
-
export interface Options {
|
|
13
|
-
environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
|
|
14
|
-
/** Specify a custom URL to connect the client to. */
|
|
15
|
-
baseUrl?: core.Supplier<string>;
|
|
16
|
-
token?: core.Supplier<core.BearerToken | undefined>;
|
|
17
|
-
/** Additional headers to include in requests. */
|
|
18
|
-
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
19
|
-
}
|
|
11
|
+
export interface Options extends BaseClientOptions {}
|
|
20
12
|
|
|
21
|
-
export interface RequestOptions {
|
|
22
|
-
/** The maximum time to wait for a response in seconds. */
|
|
23
|
-
timeoutInSeconds?: number;
|
|
24
|
-
/** The number of times to retry the request. Defaults to 2. */
|
|
25
|
-
maxRetries?: number;
|
|
26
|
-
/** A hook to abort the request. */
|
|
27
|
-
abortSignal?: AbortSignal;
|
|
28
|
-
/** Additional headers to include in the request. */
|
|
29
|
-
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
30
|
-
}
|
|
13
|
+
export interface RequestOptions extends BaseRequestOptions {}
|
|
31
14
|
}
|
|
32
15
|
|
|
33
16
|
export class ServiceApi {
|
|
@@ -55,19 +38,21 @@ export class ServiceApi {
|
|
|
55
38
|
private async __getServiceExecutions(
|
|
56
39
|
requestOptions?: ServiceApi.RequestOptions,
|
|
57
40
|
): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution[]>> {
|
|
41
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
42
|
+
this._options?.headers,
|
|
43
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
44
|
+
requestOptions?.headers,
|
|
45
|
+
);
|
|
58
46
|
const _response = await core.fetcher({
|
|
59
47
|
url:
|
|
60
48
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
61
49
|
(await core.Supplier.get(this._options.environment)) ??
|
|
62
50
|
environments.PlanqkServiceApiEnvironment.Default,
|
|
63
51
|
method: "GET",
|
|
64
|
-
headers:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
),
|
|
69
|
-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
70
|
-
maxRetries: requestOptions?.maxRetries,
|
|
52
|
+
headers: _headers,
|
|
53
|
+
queryParameters: requestOptions?.queryParams,
|
|
54
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
55
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
71
56
|
withCredentials: true,
|
|
72
57
|
abortSignal: requestOptions?.abortSignal,
|
|
73
58
|
});
|
|
@@ -104,7 +89,7 @@ export class ServiceApi {
|
|
|
104
89
|
* Starts a service execution, which in turn is processed asynchronously.
|
|
105
90
|
* The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
106
91
|
*
|
|
107
|
-
* @param {
|
|
92
|
+
* @param {PlanqkServiceApi.RequestBody} request
|
|
108
93
|
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
109
94
|
*
|
|
110
95
|
* @example
|
|
@@ -113,32 +98,34 @@ export class ServiceApi {
|
|
|
113
98
|
* })
|
|
114
99
|
*/
|
|
115
100
|
public startExecution(
|
|
116
|
-
request:
|
|
101
|
+
request: PlanqkServiceApi.RequestBody,
|
|
117
102
|
requestOptions?: ServiceApi.RequestOptions,
|
|
118
103
|
): core.HttpResponsePromise<PlanqkServiceApi.ServiceExecution> {
|
|
119
104
|
return core.HttpResponsePromise.fromPromise(this.__startExecution(request, requestOptions));
|
|
120
105
|
}
|
|
121
106
|
|
|
122
107
|
private async __startExecution(
|
|
123
|
-
request:
|
|
108
|
+
request: PlanqkServiceApi.RequestBody,
|
|
124
109
|
requestOptions?: ServiceApi.RequestOptions,
|
|
125
110
|
): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution>> {
|
|
111
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
112
|
+
this._options?.headers,
|
|
113
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
114
|
+
requestOptions?.headers,
|
|
115
|
+
);
|
|
126
116
|
const _response = await core.fetcher({
|
|
127
117
|
url:
|
|
128
118
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
129
119
|
(await core.Supplier.get(this._options.environment)) ??
|
|
130
120
|
environments.PlanqkServiceApiEnvironment.Default,
|
|
131
121
|
method: "POST",
|
|
132
|
-
headers:
|
|
133
|
-
this._options?.headers,
|
|
134
|
-
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
135
|
-
requestOptions?.headers,
|
|
136
|
-
),
|
|
122
|
+
headers: _headers,
|
|
137
123
|
contentType: "application/json",
|
|
124
|
+
queryParameters: requestOptions?.queryParams,
|
|
138
125
|
requestType: "json",
|
|
139
126
|
body: request,
|
|
140
|
-
timeoutMs: requestOptions?.timeoutInSeconds
|
|
141
|
-
maxRetries: requestOptions?.maxRetries,
|
|
127
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
128
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
142
129
|
withCredentials: true,
|
|
143
130
|
abortSignal: requestOptions?.abortSignal,
|
|
144
131
|
});
|
|
@@ -192,6 +179,11 @@ export class ServiceApi {
|
|
|
192
179
|
id: string,
|
|
193
180
|
requestOptions?: ServiceApi.RequestOptions,
|
|
194
181
|
): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution>> {
|
|
182
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
183
|
+
this._options?.headers,
|
|
184
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
185
|
+
requestOptions?.headers,
|
|
186
|
+
);
|
|
195
187
|
const _response = await core.fetcher({
|
|
196
188
|
url: core.url.join(
|
|
197
189
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
@@ -200,13 +192,10 @@ export class ServiceApi {
|
|
|
200
192
|
`${encodeURIComponent(id)}`,
|
|
201
193
|
),
|
|
202
194
|
method: "GET",
|
|
203
|
-
headers:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
),
|
|
208
|
-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
209
|
-
maxRetries: requestOptions?.maxRetries,
|
|
195
|
+
headers: _headers,
|
|
196
|
+
queryParameters: requestOptions?.queryParams,
|
|
197
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
198
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
210
199
|
withCredentials: true,
|
|
211
200
|
abortSignal: requestOptions?.abortSignal,
|
|
212
201
|
});
|
|
@@ -253,14 +242,19 @@ export class ServiceApi {
|
|
|
253
242
|
public getResult(
|
|
254
243
|
id: string,
|
|
255
244
|
requestOptions?: ServiceApi.RequestOptions,
|
|
256
|
-
): core.HttpResponsePromise<PlanqkServiceApi.
|
|
245
|
+
): core.HttpResponsePromise<PlanqkServiceApi.ResultResponse> {
|
|
257
246
|
return core.HttpResponsePromise.fromPromise(this.__getResult(id, requestOptions));
|
|
258
247
|
}
|
|
259
248
|
|
|
260
249
|
private async __getResult(
|
|
261
250
|
id: string,
|
|
262
251
|
requestOptions?: ServiceApi.RequestOptions,
|
|
263
|
-
): Promise<core.WithRawResponse<PlanqkServiceApi.
|
|
252
|
+
): Promise<core.WithRawResponse<PlanqkServiceApi.ResultResponse>> {
|
|
253
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
254
|
+
this._options?.headers,
|
|
255
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
256
|
+
requestOptions?.headers,
|
|
257
|
+
);
|
|
264
258
|
const _response = await core.fetcher({
|
|
265
259
|
url: core.url.join(
|
|
266
260
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
@@ -269,18 +263,15 @@ export class ServiceApi {
|
|
|
269
263
|
`${encodeURIComponent(id)}/result`,
|
|
270
264
|
),
|
|
271
265
|
method: "GET",
|
|
272
|
-
headers:
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
),
|
|
277
|
-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
278
|
-
maxRetries: requestOptions?.maxRetries,
|
|
266
|
+
headers: _headers,
|
|
267
|
+
queryParameters: requestOptions?.queryParams,
|
|
268
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
269
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
279
270
|
withCredentials: true,
|
|
280
271
|
abortSignal: requestOptions?.abortSignal,
|
|
281
272
|
});
|
|
282
273
|
if (_response.ok) {
|
|
283
|
-
return { data: _response.body as PlanqkServiceApi.
|
|
274
|
+
return { data: _response.body as PlanqkServiceApi.ResultResponse, rawResponse: _response.rawResponse };
|
|
284
275
|
}
|
|
285
276
|
|
|
286
277
|
if (_response.error.reason === "status-code") {
|
|
@@ -326,6 +317,11 @@ export class ServiceApi {
|
|
|
326
317
|
file: string,
|
|
327
318
|
requestOptions?: ServiceApi.RequestOptions,
|
|
328
319
|
): Promise<core.WithRawResponse<core.BinaryResponse>> {
|
|
320
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
321
|
+
this._options?.headers,
|
|
322
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
323
|
+
requestOptions?.headers,
|
|
324
|
+
);
|
|
329
325
|
const _response = await core.fetcher<core.BinaryResponse>({
|
|
330
326
|
url: core.url.join(
|
|
331
327
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
@@ -334,14 +330,11 @@ export class ServiceApi {
|
|
|
334
330
|
`${encodeURIComponent(id)}/result/${encodeURIComponent(file)}`,
|
|
335
331
|
),
|
|
336
332
|
method: "GET",
|
|
337
|
-
headers:
|
|
338
|
-
|
|
339
|
-
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
340
|
-
requestOptions?.headers,
|
|
341
|
-
),
|
|
333
|
+
headers: _headers,
|
|
334
|
+
queryParameters: requestOptions?.queryParams,
|
|
342
335
|
responseType: "binary-response",
|
|
343
|
-
timeoutMs: requestOptions?.timeoutInSeconds
|
|
344
|
-
maxRetries: requestOptions?.maxRetries,
|
|
336
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
337
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
345
338
|
withCredentials: true,
|
|
346
339
|
abortSignal: requestOptions?.abortSignal,
|
|
347
340
|
});
|
|
@@ -394,6 +387,11 @@ export class ServiceApi {
|
|
|
394
387
|
id: string,
|
|
395
388
|
requestOptions?: ServiceApi.RequestOptions,
|
|
396
389
|
): Promise<core.WithRawResponse<PlanqkServiceApi.LogEntry[]>> {
|
|
390
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
391
|
+
this._options?.headers,
|
|
392
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
393
|
+
requestOptions?.headers,
|
|
394
|
+
);
|
|
397
395
|
const _response = await core.fetcher({
|
|
398
396
|
url: core.url.join(
|
|
399
397
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
@@ -402,13 +400,10 @@ export class ServiceApi {
|
|
|
402
400
|
`${encodeURIComponent(id)}/log`,
|
|
403
401
|
),
|
|
404
402
|
method: "GET",
|
|
405
|
-
headers:
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
),
|
|
410
|
-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
411
|
-
maxRetries: requestOptions?.maxRetries,
|
|
403
|
+
headers: _headers,
|
|
404
|
+
queryParameters: requestOptions?.queryParams,
|
|
405
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
406
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
412
407
|
withCredentials: true,
|
|
413
408
|
abortSignal: requestOptions?.abortSignal,
|
|
414
409
|
});
|
|
@@ -461,6 +456,11 @@ export class ServiceApi {
|
|
|
461
456
|
id: string,
|
|
462
457
|
requestOptions?: ServiceApi.RequestOptions,
|
|
463
458
|
): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution>> {
|
|
459
|
+
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
|
|
460
|
+
this._options?.headers,
|
|
461
|
+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
|
|
462
|
+
requestOptions?.headers,
|
|
463
|
+
);
|
|
464
464
|
const _response = await core.fetcher({
|
|
465
465
|
url: core.url.join(
|
|
466
466
|
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
@@ -469,13 +469,10 @@ export class ServiceApi {
|
|
|
469
469
|
`${encodeURIComponent(id)}/cancel`,
|
|
470
470
|
),
|
|
471
471
|
method: "PUT",
|
|
472
|
-
headers:
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
),
|
|
477
|
-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
478
|
-
maxRetries: requestOptions?.maxRetries,
|
|
472
|
+
headers: _headers,
|
|
473
|
+
queryParameters: requestOptions?.queryParams,
|
|
474
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
475
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
479
476
|
withCredentials: true,
|
|
480
477
|
abortSignal: requestOptions?.abortSignal,
|
|
481
478
|
});
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
4
2
|
|
|
5
3
|
export interface LogEntry {
|
|
4
|
+
/** Log message content. */
|
|
6
5
|
message?: string;
|
|
7
|
-
|
|
6
|
+
/** Severity of the log entry. */
|
|
7
|
+
severity?: LogEntry.Severity;
|
|
8
|
+
/** Timestamp when the entry was logged. */
|
|
8
9
|
timestamp?: string;
|
|
9
10
|
}
|
|
11
|
+
|
|
12
|
+
export namespace LogEntry {
|
|
13
|
+
/** Severity of the log entry. */
|
|
14
|
+
export const Severity = {
|
|
15
|
+
Debug: "DEBUG",
|
|
16
|
+
Notice: "NOTICE",
|
|
17
|
+
Info: "INFO",
|
|
18
|
+
Warning: "WARNING",
|
|
19
|
+
Error: "ERROR",
|
|
20
|
+
} as const;
|
|
21
|
+
export type Severity = (typeof Severity)[keyof typeof Severity];
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import * as PlanqkServiceApi from "../index.js";
|
|
4
|
+
|
|
5
|
+
export interface ResultResponse {
|
|
6
|
+
_links?: ResultResponse.Links;
|
|
7
|
+
_embedded?: ResultResponse.Embedded;
|
|
8
|
+
/** Accepts any additional properties */
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export namespace ResultResponse {
|
|
13
|
+
export interface Links {
|
|
14
|
+
status?: PlanqkServiceApi.HalLink;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Embedded {
|
|
18
|
+
status?: PlanqkServiceApi.ServiceExecution;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
4
2
|
|
|
5
3
|
export interface ServiceExecution {
|
|
4
|
+
/** Unique identifier of the service execution. */
|
|
6
5
|
id?: string;
|
|
7
|
-
|
|
6
|
+
/** Timestamp when the service execution was created. */
|
|
8
7
|
createdAt?: string;
|
|
8
|
+
/** Timestamp when the service execution started. */
|
|
9
9
|
startedAt?: string;
|
|
10
|
+
/** Timestamp when the service execution ended. */
|
|
10
11
|
endedAt?: string;
|
|
12
|
+
/** Status of the service execution. */
|
|
13
|
+
status?: ServiceExecution.Status;
|
|
14
|
+
/** Type identifier indicating whether the underlying service is a 'managed' or 'workflow' service. */
|
|
15
|
+
type?: ServiceExecution.Type;
|
|
16
|
+
/** The ID of the service for which this service execution was created. */
|
|
17
|
+
serviceId?: string;
|
|
18
|
+
/** The ID of the service definition for which this service execution was created. */
|
|
19
|
+
serviceDefinitionId?: string;
|
|
20
|
+
/** The ID of the application for which this service execution was created. */
|
|
21
|
+
applicationId?: string;
|
|
11
22
|
}
|
|
12
23
|
|
|
13
24
|
export namespace ServiceExecution {
|
|
14
|
-
|
|
25
|
+
/** Status of the service execution. */
|
|
15
26
|
export const Status = {
|
|
16
27
|
Unknown: "UNKNOWN",
|
|
17
28
|
Pending: "PENDING",
|
|
@@ -20,4 +31,11 @@ export namespace ServiceExecution {
|
|
|
20
31
|
Cancelled: "CANCELLED",
|
|
21
32
|
Failed: "FAILED",
|
|
22
33
|
} as const;
|
|
34
|
+
export type Status = (typeof Status)[keyof typeof Status];
|
|
35
|
+
/** Type identifier indicating whether the underlying service is a 'managed' or 'workflow' service. */
|
|
36
|
+
export const Type = {
|
|
37
|
+
Managed: "MANAGED",
|
|
38
|
+
Workflow: "WORKFLOW",
|
|
39
|
+
} as const;
|
|
40
|
+
export type Type = (typeof Type)[keyof typeof Type];
|
|
23
41
|
}
|
|
@@ -18,7 +18,8 @@ export const BasicAuth = {
|
|
|
18
18
|
fromAuthorizationHeader: (header: string): BasicAuth => {
|
|
19
19
|
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
20
20
|
const decoded = base64Decode(credentials);
|
|
21
|
-
const [username,
|
|
21
|
+
const [username, ...passwordParts] = decoded.split(":");
|
|
22
|
+
const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
|
|
22
23
|
|
|
23
24
|
if (username == null || password == null) {
|
|
24
25
|
throw new Error("Invalid basic auth");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SecuritySchemeKey = string;
|
|
2
|
+
/**
|
|
3
|
+
* A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme.
|
|
4
|
+
* All schemes in the collection must be satisfied for authentication to be successful.
|
|
5
|
+
*/
|
|
6
|
+
export type SecuritySchemeCollection = Record<SecuritySchemeKey, AuthScope[]>;
|
|
7
|
+
export type AuthScope = string;
|
|
8
|
+
export type EndpointMetadata = {
|
|
9
|
+
/**
|
|
10
|
+
* An array of security scheme collections. Each collection represents an alternative way to authenticate.
|
|
11
|
+
*/
|
|
12
|
+
security?: SecuritySchemeCollection[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
2
|
+
import { Supplier } from "./Supplier.js";
|
|
3
|
+
|
|
4
|
+
type EndpointSupplierFn<T> = (arg: { endpointMetadata: EndpointMetadata }) => T | Promise<T>;
|
|
5
|
+
export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
|
|
6
|
+
export const EndpointSupplier = {
|
|
7
|
+
get: async <T>(supplier: EndpointSupplier<T>, arg: { endpointMetadata: EndpointMetadata }): Promise<T> => {
|
|
8
|
+
if (typeof supplier === "function") {
|
|
9
|
+
return (supplier as EndpointSupplierFn<T>)(arg);
|
|
10
|
+
} else {
|
|
11
|
+
return supplier;
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { toJson } from "../json.js";
|
|
2
|
-
import { APIResponse } from "./APIResponse.js";
|
|
3
|
-
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
4
|
-
import { Supplier } from "./Supplier.js";
|
|
2
|
+
import type { APIResponse } from "./APIResponse.js";
|
|
5
3
|
import { createRequestUrl } from "./createRequestUrl.js";
|
|
4
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
5
|
+
import { EndpointSupplier } from "./EndpointSupplier.js";
|
|
6
6
|
import { getErrorResponseBody } from "./getErrorResponseBody.js";
|
|
7
7
|
import { getFetchFn } from "./getFetchFn.js";
|
|
8
8
|
import { getRequestBody } from "./getRequestBody.js";
|
|
9
9
|
import { getResponseBody } from "./getResponseBody.js";
|
|
10
10
|
import { makeRequest } from "./makeRequest.js";
|
|
11
|
+
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
11
12
|
import { requestWithRetries } from "./requestWithRetries.js";
|
|
12
13
|
|
|
13
14
|
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
@@ -17,8 +18,8 @@ export declare namespace Fetcher {
|
|
|
17
18
|
url: string;
|
|
18
19
|
method: string;
|
|
19
20
|
contentType?: string;
|
|
20
|
-
headers?: Record<string, string |
|
|
21
|
-
queryParameters?: Record<string,
|
|
21
|
+
headers?: Record<string, string | EndpointSupplier<string | null | undefined> | null | undefined>;
|
|
22
|
+
queryParameters?: Record<string, unknown>;
|
|
22
23
|
body?: unknown;
|
|
23
24
|
timeoutMs?: number;
|
|
24
25
|
maxRetries?: number;
|
|
@@ -27,6 +28,7 @@ export declare namespace Fetcher {
|
|
|
27
28
|
requestType?: "json" | "file" | "bytes";
|
|
28
29
|
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
29
30
|
duplex?: "half";
|
|
31
|
+
endpointMetadata?: EndpointMetadata;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
|
|
@@ -64,7 +66,7 @@ async function getHeaders(args: Fetcher.Args): Promise<Record<string, string>> {
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
for (const [key, value] of Object.entries(args.headers)) {
|
|
67
|
-
const result = await
|
|
69
|
+
const result = await EndpointSupplier.get(value, { endpointMetadata: args.endpointMetadata ?? {} });
|
|
68
70
|
if (typeof result === "string") {
|
|
69
71
|
newHeaders[key] = result;
|
|
70
72
|
continue;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export type { APIResponse } from "./APIResponse.js";
|
|
2
|
-
export {
|
|
2
|
+
export type { BinaryResponse } from "./BinaryResponse.js";
|
|
3
|
+
export type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
4
|
+
export { EndpointSupplier } from "./EndpointSupplier.js";
|
|
3
5
|
export type { Fetcher, FetchFunction } from "./Fetcher.js";
|
|
6
|
+
export { fetcher } from "./Fetcher.js";
|
|
4
7
|
export { getHeader } from "./getHeader.js";
|
|
5
|
-
export { Supplier } from "./Supplier.js";
|
|
6
|
-
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
7
|
-
export type { RawResponse, WithRawResponse } from "./RawResponse.js";
|
|
8
8
|
export { HttpResponsePromise } from "./HttpResponsePromise.js";
|
|
9
|
-
export {
|
|
9
|
+
export type { RawResponse, WithRawResponse } from "./RawResponse.js";
|
|
10
|
+
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
11
|
+
export { Supplier } from "./Supplier.js";
|
|
@@ -3,12 +3,55 @@ const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
|
3
3
|
const DEFAULT_MAX_RETRIES = 2;
|
|
4
4
|
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
5
5
|
|
|
6
|
-
function
|
|
7
|
-
// Generate a random value between
|
|
8
|
-
const jitterMultiplier = 1 +
|
|
6
|
+
function addPositiveJitter(delay: number): number {
|
|
7
|
+
// Generate a random value between 0 and +JITTER_FACTOR
|
|
8
|
+
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
9
9
|
return delay * jitterMultiplier;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
function addSymmetricJitter(delay: number): number {
|
|
13
|
+
// Generate a random value in a JITTER_FACTOR-sized percentage range around delay
|
|
14
|
+
const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
|
|
15
|
+
return delay * jitterMultiplier;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getRetryDelayFromHeaders(response: Response, retryAttempt: number): number {
|
|
19
|
+
// Check for Retry-After header first (RFC 7231), with no jitter
|
|
20
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
21
|
+
if (retryAfter) {
|
|
22
|
+
// Parse as number of seconds...
|
|
23
|
+
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
24
|
+
if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
|
|
25
|
+
return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ...or as an HTTP date; both are valid
|
|
29
|
+
const retryAfterDate = new Date(retryAfter);
|
|
30
|
+
if (!isNaN(retryAfterDate.getTime())) {
|
|
31
|
+
const delay = retryAfterDate.getTime() - Date.now();
|
|
32
|
+
if (delay > 0) {
|
|
33
|
+
return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Then check for industry-standard X-RateLimit-Reset header, with positive jitter
|
|
39
|
+
const rateLimitReset = response.headers.get("X-RateLimit-Reset");
|
|
40
|
+
if (rateLimitReset) {
|
|
41
|
+
const resetTime = parseInt(rateLimitReset, 10);
|
|
42
|
+
if (!isNaN(resetTime)) {
|
|
43
|
+
// Assume Unix timestamp in epoch seconds
|
|
44
|
+
const delay = resetTime * 1000 - Date.now();
|
|
45
|
+
if (delay > 0) {
|
|
46
|
+
return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Fall back to exponential backoff, with symmetric jitter
|
|
52
|
+
return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
|
|
53
|
+
}
|
|
54
|
+
|
|
12
55
|
export async function requestWithRetries(
|
|
13
56
|
requestFn: () => Promise<Response>,
|
|
14
57
|
maxRetries: number = DEFAULT_MAX_RETRIES,
|
|
@@ -17,13 +60,10 @@ export async function requestWithRetries(
|
|
|
17
60
|
|
|
18
61
|
for (let i = 0; i < maxRetries; ++i) {
|
|
19
62
|
if ([408, 429].includes(response.status) || response.status >= 500) {
|
|
20
|
-
//
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
// Add jitter to the delay
|
|
24
|
-
const delayWithJitter = addJitter(baseDelay);
|
|
63
|
+
// Get delay with appropriate jitter applied
|
|
64
|
+
const delay = getRetryDelayFromHeaders(response, i);
|
|
25
65
|
|
|
26
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
66
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
27
67
|
response = await requestFn();
|
|
28
68
|
} else {
|
|
29
69
|
break;
|