@planqk/planqk-service-sdk 2.6.2 → 2.8.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 (124) hide show
  1. package/dist/sdk/BaseClient.d.ts +26 -0
  2. package/dist/sdk/{api/resources/serviceApi/types/GetResultResponse.js → BaseClient.js} +1 -3
  3. package/dist/sdk/Client.d.ts +4 -22
  4. package/dist/sdk/Client.js +2 -4
  5. package/dist/sdk/api/index.d.ts +1 -1
  6. package/dist/sdk/api/index.js +1 -1
  7. package/dist/sdk/api/resources/index.d.ts +0 -1
  8. package/dist/sdk/api/resources/index.js +0 -4
  9. package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +9 -26
  10. package/dist/sdk/api/resources/serviceApi/client/Client.js +43 -27
  11. package/dist/sdk/api/resources/serviceApi/index.d.ts +0 -1
  12. package/dist/sdk/api/resources/serviceApi/index.js +0 -1
  13. package/dist/sdk/api/types/HalLink.d.ts +0 -3
  14. package/dist/sdk/api/types/HalLink.js +1 -3
  15. package/dist/sdk/api/types/LogEntry.d.ts +19 -0
  16. package/dist/sdk/api/types/LogEntry.js +15 -0
  17. package/dist/sdk/api/types/RequestBody.d.ts +1 -0
  18. package/dist/sdk/api/types/RequestBody.js +3 -0
  19. package/dist/sdk/api/types/ResultResponse.d.ts +15 -0
  20. package/dist/sdk/api/types/ResultResponse.js +3 -0
  21. package/dist/sdk/api/types/ServiceExecution.d.ts +1 -4
  22. package/dist/sdk/api/types/ServiceExecution.js +1 -3
  23. package/dist/sdk/api/types/index.d.ts +3 -0
  24. package/dist/sdk/api/types/index.js +3 -0
  25. package/dist/sdk/core/auth/AuthProvider.d.ts +4 -0
  26. package/dist/sdk/core/auth/AuthProvider.js +2 -0
  27. package/dist/sdk/core/auth/AuthRequest.d.ts +9 -0
  28. package/dist/sdk/core/auth/AuthRequest.js +2 -0
  29. package/dist/sdk/core/auth/BasicAuth.js +2 -1
  30. package/dist/sdk/core/auth/index.d.ts +2 -0
  31. package/dist/sdk/core/fetcher/APIResponse.d.ts +1 -1
  32. package/dist/sdk/core/fetcher/BinaryResponse.d.ts +1 -1
  33. package/dist/sdk/core/fetcher/EndpointMetadata.d.ts +13 -0
  34. package/dist/sdk/core/fetcher/EndpointMetadata.js +2 -0
  35. package/dist/sdk/core/fetcher/EndpointSupplier.d.ts +12 -0
  36. package/dist/sdk/core/fetcher/EndpointSupplier.js +13 -0
  37. package/dist/sdk/core/fetcher/Fetcher.d.ts +6 -4
  38. package/dist/sdk/core/fetcher/Fetcher.js +3 -3
  39. package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +1 -1
  40. package/dist/sdk/core/fetcher/index.d.ts +7 -5
  41. package/dist/sdk/core/fetcher/index.js +7 -5
  42. package/dist/sdk/core/fetcher/requestWithRetries.js +44 -8
  43. package/dist/sdk/core/headers.d.ts +2 -3
  44. package/dist/sdk/core/url/join.js +23 -3
  45. package/dist/sdk/environments.d.ts +0 -3
  46. package/dist/sdk/environments.js +1 -3
  47. package/dist/sdk/errors/PlanqkServiceApiError.d.ts +0 -3
  48. package/dist/sdk/errors/PlanqkServiceApiError.js +1 -3
  49. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +0 -3
  50. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +1 -3
  51. package/dist/sdk/index.d.ts +1 -0
  52. package/fern/fern.config.json +1 -1
  53. package/fern/generators.yml +6 -4
  54. package/fern/openapi/openapi.yml +115 -80
  55. package/package.json +1 -1
  56. package/planqk/service/_version.py +1 -1
  57. package/planqk/service/client.py +3 -3
  58. package/planqk/service/sdk/__init__.py +61 -8
  59. package/planqk/service/sdk/client.py +27 -7
  60. package/planqk/service/sdk/core/__init__.py +80 -20
  61. package/planqk/service/sdk/core/client_wrapper.py +8 -6
  62. package/planqk/service/sdk/core/force_multipart.py +4 -2
  63. package/planqk/service/sdk/core/http_response.py +1 -1
  64. package/planqk/service/sdk/core/http_sse/__init__.py +42 -0
  65. package/planqk/service/sdk/core/http_sse/_api.py +112 -0
  66. package/planqk/service/sdk/core/http_sse/_decoders.py +61 -0
  67. package/planqk/service/sdk/core/http_sse/_exceptions.py +7 -0
  68. package/planqk/service/sdk/core/http_sse/_models.py +17 -0
  69. package/planqk/service/sdk/core/pydantic_utilities.py +5 -2
  70. package/planqk/service/sdk/core/unchecked_base_model.py +341 -0
  71. package/planqk/service/sdk/service_api/__init__.py +0 -3
  72. package/planqk/service/sdk/service_api/client.py +17 -21
  73. package/planqk/service/sdk/service_api/raw_client.py +36 -40
  74. package/planqk/service/sdk/types/__init__.py +57 -4
  75. package/planqk/service/sdk/types/hal_link.py +3 -2
  76. package/planqk/service/sdk/types/log_entry.py +35 -0
  77. package/planqk/service/sdk/types/log_entry_severity.py +5 -0
  78. package/planqk/service/sdk/types/request_body.py +5 -0
  79. package/planqk/service/sdk/types/result_response.py +27 -0
  80. package/planqk/service/sdk/{service_api/types/get_result_response_embedded.py → types/result_response_embedded.py} +4 -3
  81. package/planqk/service/sdk/{service_api/types/get_result_response_links.py → types/result_response_links.py} +4 -3
  82. package/planqk/service/sdk/types/service_execution.py +3 -2
  83. package/pyproject.toml +1 -1
  84. package/requirements-dev.txt +59 -43
  85. package/requirements.txt +6 -6
  86. package/src/index.test.ts +10 -0
  87. package/src/sdk/BaseClient.ts +30 -0
  88. package/src/sdk/Client.ts +6 -23
  89. package/src/sdk/api/index.ts +1 -1
  90. package/src/sdk/api/resources/index.ts +0 -1
  91. package/src/sdk/api/resources/serviceApi/client/Client.ts +87 -82
  92. package/src/sdk/api/resources/serviceApi/index.ts +0 -1
  93. package/src/sdk/api/types/HalLink.ts +1 -3
  94. package/src/sdk/api/types/LogEntry.ts +22 -0
  95. package/src/sdk/api/types/RequestBody.ts +3 -0
  96. package/src/sdk/api/types/ResultResponse.ts +20 -0
  97. package/src/sdk/api/types/ServiceExecution.ts +2 -4
  98. package/src/sdk/api/types/index.ts +3 -0
  99. package/src/sdk/core/auth/AuthProvider.ts +5 -0
  100. package/src/sdk/core/auth/AuthRequest.ts +9 -0
  101. package/src/sdk/core/auth/BasicAuth.ts +2 -1
  102. package/src/sdk/core/auth/index.ts +2 -0
  103. package/src/sdk/core/fetcher/APIResponse.ts +1 -1
  104. package/src/sdk/core/fetcher/BinaryResponse.ts +1 -1
  105. package/src/sdk/core/fetcher/EndpointMetadata.ts +13 -0
  106. package/src/sdk/core/fetcher/EndpointSupplier.ts +14 -0
  107. package/src/sdk/core/fetcher/Fetcher.ts +8 -6
  108. package/src/sdk/core/fetcher/HttpResponsePromise.ts +1 -1
  109. package/src/sdk/core/fetcher/index.ts +7 -5
  110. package/src/sdk/core/fetcher/requestWithRetries.ts +49 -9
  111. package/src/sdk/core/headers.ts +8 -10
  112. package/src/sdk/core/url/join.ts +28 -3
  113. package/src/sdk/environments.ts +1 -3
  114. package/src/sdk/errors/PlanqkServiceApiError.ts +1 -3
  115. package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +1 -3
  116. package/src/sdk/index.ts +1 -0
  117. package/uv.lock +77 -47
  118. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +0 -18
  119. package/dist/sdk/api/resources/serviceApi/types/index.d.ts +0 -1
  120. package/dist/sdk/api/resources/serviceApi/types/index.js +0 -17
  121. package/planqk/service/sdk/service_api/types/__init__.py +0 -9
  122. package/planqk/service/sdk/service_api/types/get_result_response.py +0 -26
  123. package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +0 -22
  124. package/src/sdk/api/resources/serviceApi/types/index.ts +0 -1
@@ -0,0 +1,30 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ import * as environments from "./environments.js";
4
+ import * as core from "./core/index.js";
5
+
6
+ export interface BaseClientOptions {
7
+ environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
8
+ /** Specify a custom URL to connect the client to. */
9
+ baseUrl?: core.Supplier<string>;
10
+ token?: core.Supplier<core.BearerToken | undefined>;
11
+ /** Additional headers to include in requests. */
12
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
13
+ /** The default maximum time to wait for a response in seconds. */
14
+ timeoutInSeconds?: number;
15
+ /** The default number of times to retry the request. Defaults to 2. */
16
+ maxRetries?: number;
17
+ }
18
+
19
+ export interface BaseRequestOptions {
20
+ /** The maximum time to wait for a response in seconds. */
21
+ timeoutInSeconds?: number;
22
+ /** The number of times to retry the request. Defaults to 2. */
23
+ maxRetries?: number;
24
+ /** A hook to abort the request. */
25
+ abortSignal?: AbortSignal;
26
+ /** Additional query string parameters to include in the request. */
27
+ queryParams?: Record<string, unknown>;
28
+ /** Additional headers to include in the request. */
29
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
30
+ }
package/src/sdk/Client.ts CHANGED
@@ -1,39 +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
- import * as environments from "./environments.js";
3
+ import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
6
4
  import * as core from "./core/index.js";
7
5
  import { mergeHeaders } from "./core/headers.js";
6
+ import * as environments from "./environments.js";
8
7
  import { ServiceApi } from "./api/resources/serviceApi/client/Client.js";
9
8
 
10
9
  export declare namespace PlanqkServiceApiClient {
11
- export interface Options {
12
- environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
13
- /** Specify a custom URL to connect the client to. */
14
- baseUrl?: core.Supplier<string>;
15
- token: core.Supplier<core.BearerToken>;
16
- /** Additional headers to include in requests. */
17
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
18
- }
10
+ export interface Options extends BaseClientOptions {}
19
11
 
20
- export interface RequestOptions {
21
- /** The maximum time to wait for a response in seconds. */
22
- timeoutInSeconds?: number;
23
- /** The number of times to retry the request. Defaults to 2. */
24
- maxRetries?: number;
25
- /** A hook to abort the request. */
26
- abortSignal?: AbortSignal;
27
- /** Additional headers to include in the request. */
28
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
29
- }
12
+ export interface RequestOptions extends BaseRequestOptions {}
30
13
  }
31
14
 
32
15
  export class PlanqkServiceApiClient {
33
16
  protected readonly _options: PlanqkServiceApiClient.Options;
34
17
  protected _serviceApi: ServiceApi | undefined;
35
18
 
36
- constructor(_options: PlanqkServiceApiClient.Options) {
19
+ constructor(_options: PlanqkServiceApiClient.Options = {}) {
37
20
  this._options = {
38
21
  ..._options,
39
22
  headers: mergeHeaders(
@@ -1,2 +1,2 @@
1
- export * from "./resources/index.js";
2
1
  export * from "./types/index.js";
2
+ export * from "./resources/index.js";
@@ -1,2 +1 @@
1
1
  export * as serviceApi from "./serviceApi/index.js";
2
- export * from "./serviceApi/types/index.js";
@@ -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,31 +8,15 @@ 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>;
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 {
34
17
  protected readonly _options: ServiceApi.Options;
35
18
 
36
- constructor(_options: ServiceApi.Options) {
19
+ constructor(_options: ServiceApi.Options = {}) {
37
20
  this._options = _options;
38
21
  }
39
22
 
@@ -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: mergeHeaders(
65
- this._options?.headers,
66
- mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
67
- requestOptions?.headers,
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 {Record<string, any>} request
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: Record<string, any>,
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: Record<string, any>,
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: mergeHeaders(
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 != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
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: mergeHeaders(
204
- this._options?.headers,
205
- mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
206
- requestOptions?.headers,
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.GetResultResponse> {
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.GetResultResponse>> {
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: mergeHeaders(
273
- this._options?.headers,
274
- mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
275
- requestOptions?.headers,
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.GetResultResponse, rawResponse: _response.rawResponse };
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: mergeHeaders(
338
- this._options?.headers,
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 != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
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
  });
@@ -383,14 +376,22 @@ export class ServiceApi {
383
376
  * @example
384
377
  * await client.serviceApi.getLogs("id")
385
378
  */
386
- public getLogs(id: string, requestOptions?: ServiceApi.RequestOptions): core.HttpResponsePromise<string[]> {
379
+ public getLogs(
380
+ id: string,
381
+ requestOptions?: ServiceApi.RequestOptions,
382
+ ): core.HttpResponsePromise<PlanqkServiceApi.LogEntry[]> {
387
383
  return core.HttpResponsePromise.fromPromise(this.__getLogs(id, requestOptions));
388
384
  }
389
385
 
390
386
  private async __getLogs(
391
387
  id: string,
392
388
  requestOptions?: ServiceApi.RequestOptions,
393
- ): Promise<core.WithRawResponse<string[]>> {
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
+ );
394
395
  const _response = await core.fetcher({
395
396
  url: core.url.join(
396
397
  (await core.Supplier.get(this._options.baseUrl)) ??
@@ -399,18 +400,15 @@ export class ServiceApi {
399
400
  `${encodeURIComponent(id)}/log`,
400
401
  ),
401
402
  method: "GET",
402
- headers: mergeHeaders(
403
- this._options?.headers,
404
- mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
405
- requestOptions?.headers,
406
- ),
407
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
408
- 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,
409
407
  withCredentials: true,
410
408
  abortSignal: requestOptions?.abortSignal,
411
409
  });
412
410
  if (_response.ok) {
413
- return { data: _response.body as string[], rawResponse: _response.rawResponse };
411
+ return { data: _response.body as PlanqkServiceApi.LogEntry[], rawResponse: _response.rawResponse };
414
412
  }
415
413
 
416
414
  if (_response.error.reason === "status-code") {
@@ -458,6 +456,11 @@ export class ServiceApi {
458
456
  id: string,
459
457
  requestOptions?: ServiceApi.RequestOptions,
460
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
+ );
461
464
  const _response = await core.fetcher({
462
465
  url: core.url.join(
463
466
  (await core.Supplier.get(this._options.baseUrl)) ??
@@ -466,13 +469,10 @@ export class ServiceApi {
466
469
  `${encodeURIComponent(id)}/cancel`,
467
470
  ),
468
471
  method: "PUT",
469
- headers: mergeHeaders(
470
- this._options?.headers,
471
- mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
472
- requestOptions?.headers,
473
- ),
474
- timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
475
- 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,
476
476
  withCredentials: true,
477
477
  abortSignal: requestOptions?.abortSignal,
478
478
  });
@@ -505,7 +505,12 @@ export class ServiceApi {
505
505
  }
506
506
  }
507
507
 
508
- protected async _getAuthorizationHeader(): Promise<string> {
509
- return `Bearer ${await core.Supplier.get(this._options.token)}`;
508
+ protected async _getAuthorizationHeader(): Promise<string | undefined> {
509
+ const bearer = await core.Supplier.get(this._options.token);
510
+ if (bearer != null) {
511
+ return `Bearer ${bearer}`;
512
+ }
513
+
514
+ return undefined;
510
515
  }
511
516
  }
@@ -1,2 +1 @@
1
- export * from "./types/index.js";
2
1
  export * from "./client/index.js";
@@ -1,6 +1,4 @@
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 HalLink {
6
4
  /** The URL of the link */
@@ -0,0 +1,22 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ export interface LogEntry {
4
+ /** Log message content. */
5
+ message?: string;
6
+ /** Severity of the log entry. */
7
+ severity?: LogEntry.Severity;
8
+ /** Timestamp when the entry was logged. */
9
+ timestamp?: string;
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,3 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+
3
+ export type RequestBody = Record<string, any>;
@@ -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,6 +1,4 @@
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 {
6
4
  id?: string;
@@ -11,7 +9,6 @@ export interface ServiceExecution {
11
9
  }
12
10
 
13
11
  export namespace ServiceExecution {
14
- export type Status = "UNKNOWN" | "PENDING" | "RUNNING" | "SUCCEEDED" | "CANCELLED" | "FAILED";
15
12
  export const Status = {
16
13
  Unknown: "UNKNOWN",
17
14
  Pending: "PENDING",
@@ -20,4 +17,5 @@ export namespace ServiceExecution {
20
17
  Cancelled: "CANCELLED",
21
18
  Failed: "FAILED",
22
19
  } as const;
20
+ export type Status = (typeof Status)[keyof typeof Status];
23
21
  }
@@ -1,2 +1,5 @@
1
+ export * from "./RequestBody.js";
2
+ export * from "./ResultResponse.js";
1
3
  export * from "./ServiceExecution.js";
4
+ export * from "./LogEntry.js";
2
5
  export * from "./HalLink.js";
@@ -0,0 +1,5 @@
1
+ import type { AuthRequest } from "./AuthRequest.js";
2
+
3
+ export interface AuthProvider {
4
+ getAuthRequest(): Promise<AuthRequest>;
5
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Request parameters for authentication requests.
3
+ */
4
+ export interface AuthRequest {
5
+ /**
6
+ * The headers to be included in the request.
7
+ */
8
+ headers: Record<string, string>;
9
+ }
@@ -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, password] = decoded.split(":", 2);
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");
@@ -1,2 +1,4 @@
1
+ export type { AuthProvider } from "./AuthProvider.js";
2
+ export type { AuthRequest } from "./AuthRequest.js";
1
3
  export { BasicAuth } from "./BasicAuth.js";
2
4
  export { BearerToken } from "./BearerToken.js";
@@ -1,4 +1,4 @@
1
- import { RawResponse } from "./RawResponse.js";
1
+ import type { RawResponse } from "./RawResponse.js";
2
2
 
3
3
  /**
4
4
  * The response of an API call.
@@ -1,4 +1,4 @@
1
- import { ResponseWithBody } from "./ResponseWithBody.js";
1
+ import type { ResponseWithBody } from "./ResponseWithBody.js";
2
2
 
3
3
  export type BinaryResponse = {
4
4
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
@@ -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 | Supplier<string | undefined> | undefined>;
21
- queryParameters?: Record<string, string | string[] | object | object[] | null>;
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 Supplier.get(value);
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,4 +1,4 @@
1
- import { WithRawResponse } from "./RawResponse.js";
1
+ import type { WithRawResponse } from "./RawResponse.js";
2
2
 
3
3
  /**
4
4
  * A promise that returns the parsed response and lets you retrieve the raw response too.
@@ -1,9 +1,11 @@
1
1
  export type { APIResponse } from "./APIResponse.js";
2
- export { fetcher } from "./Fetcher.js";
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 { BinaryResponse } from "./BinaryResponse.js";
9
+ export type { RawResponse, WithRawResponse } from "./RawResponse.js";
10
+ export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
11
+ export { Supplier } from "./Supplier.js";