@planqk/planqk-service-sdk 2.1.1 → 2.2.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 (173) hide show
  1. package/.gitlab-ci.yml +8 -39
  2. package/README-node.md +16 -12
  3. package/README.md +30 -41
  4. package/dist/sdk/Client.d.ts +10 -4
  5. package/dist/sdk/Client.js +46 -4
  6. package/dist/sdk/api/index.d.ts +2 -3
  7. package/dist/sdk/api/index.js +2 -3
  8. package/dist/sdk/api/resources/index.d.ts +2 -2
  9. package/dist/sdk/api/resources/index.js +2 -2
  10. package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +41 -55
  11. package/dist/sdk/api/resources/serviceApi/client/Client.js +131 -227
  12. package/dist/sdk/api/resources/serviceApi/index.d.ts +2 -2
  13. package/dist/sdk/api/resources/serviceApi/index.js +2 -2
  14. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +13 -3
  15. package/dist/sdk/api/resources/serviceApi/types/index.d.ts +1 -4
  16. package/dist/sdk/api/resources/serviceApi/types/index.js +1 -4
  17. package/dist/sdk/api/types/ServiceExecution.d.ts +12 -2
  18. package/dist/sdk/api/types/ServiceExecution.js +12 -0
  19. package/dist/sdk/api/types/index.d.ts +2 -6
  20. package/dist/sdk/api/types/index.js +2 -6
  21. package/dist/sdk/core/auth/BasicAuth.js +3 -3
  22. package/dist/sdk/core/auth/index.d.ts +2 -2
  23. package/dist/sdk/core/auth/index.js +4 -4
  24. package/dist/sdk/core/base64.d.ts +2 -0
  25. package/dist/sdk/core/base64.js +26 -0
  26. package/dist/sdk/core/fetcher/APIResponse.d.ts +10 -0
  27. package/dist/sdk/core/fetcher/BinaryResponse.d.ts +20 -0
  28. package/dist/sdk/core/fetcher/BinaryResponse.js +17 -0
  29. package/dist/sdk/core/fetcher/Fetcher.d.ts +5 -4
  30. package/dist/sdk/core/fetcher/Fetcher.js +41 -22
  31. package/dist/sdk/core/fetcher/Headers.d.ts +2 -0
  32. package/dist/sdk/core/fetcher/Headers.js +85 -0
  33. package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +58 -0
  34. package/dist/sdk/core/fetcher/HttpResponsePromise.js +94 -0
  35. package/dist/sdk/core/fetcher/RawResponse.d.ts +29 -0
  36. package/dist/sdk/core/fetcher/RawResponse.js +44 -0
  37. package/dist/sdk/core/fetcher/ResponseWithBody.d.ts +4 -0
  38. package/dist/sdk/core/fetcher/ResponseWithBody.js +6 -0
  39. package/dist/sdk/core/fetcher/createRequestUrl.d.ts +1 -1
  40. package/dist/sdk/core/fetcher/createRequestUrl.js +3 -7
  41. package/dist/sdk/core/fetcher/getErrorResponseBody.d.ts +1 -0
  42. package/dist/sdk/core/fetcher/getErrorResponseBody.js +32 -0
  43. package/dist/sdk/core/fetcher/getFetchFn.d.ts +1 -4
  44. package/dist/sdk/core/fetcher/getFetchFn.js +1 -52
  45. package/dist/sdk/core/fetcher/getRequestBody.js +2 -1
  46. package/dist/sdk/core/fetcher/getResponseBody.js +34 -30
  47. package/dist/sdk/core/fetcher/index.d.ts +9 -5
  48. package/dist/sdk/core/fetcher/index.js +13 -7
  49. package/dist/sdk/core/fetcher/makeRequest.js +3 -3
  50. package/dist/sdk/core/fetcher/requestWithRetries.js +14 -5
  51. package/dist/sdk/core/headers.d.ts +3 -0
  52. package/dist/sdk/core/headers.js +29 -0
  53. package/dist/sdk/core/index.d.ts +5 -3
  54. package/dist/sdk/core/index.js +28 -3
  55. package/dist/sdk/core/json.d.ts +15 -0
  56. package/dist/sdk/core/json.js +24 -0
  57. package/dist/sdk/core/runtime/index.d.ts +1 -1
  58. package/dist/sdk/core/runtime/index.js +2 -2
  59. package/dist/sdk/core/runtime/runtime.d.ts +1 -1
  60. package/dist/sdk/core/runtime/runtime.js +49 -40
  61. package/dist/sdk/core/url/index.d.ts +2 -0
  62. package/dist/sdk/core/url/index.js +7 -0
  63. package/dist/sdk/core/url/join.d.ts +1 -0
  64. package/dist/sdk/core/url/join.js +49 -0
  65. package/dist/sdk/core/url/qs.d.ts +6 -0
  66. package/dist/sdk/core/url/qs.js +67 -0
  67. package/dist/sdk/errors/PlanqkServiceApiError.d.ts +4 -1
  68. package/dist/sdk/errors/PlanqkServiceApiError.js +7 -8
  69. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +1 -1
  70. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +2 -2
  71. package/dist/sdk/errors/index.d.ts +2 -2
  72. package/dist/sdk/errors/index.js +4 -4
  73. package/dist/sdk/index.d.ts +4 -4
  74. package/dist/sdk/index.js +9 -9
  75. package/fern/fern.config.json +1 -1
  76. package/fern/generators.yml +2 -2
  77. package/fern/openapi/openapi.yml +41 -131
  78. package/notebooks/python-sdk.ipynb +1 -1
  79. package/package.json +2 -3
  80. package/planqk/service/_version.py +1 -1
  81. package/pyproject.toml +1 -1
  82. package/src/index.test.ts +29 -16
  83. package/src/sdk/Client.ts +27 -7
  84. package/src/sdk/api/index.ts +2 -3
  85. package/src/sdk/api/resources/index.ts +2 -2
  86. package/src/sdk/api/resources/serviceApi/client/Client.ts +223 -250
  87. package/src/sdk/api/resources/serviceApi/index.ts +2 -2
  88. package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +15 -3
  89. package/src/sdk/api/resources/serviceApi/types/index.ts +1 -4
  90. package/src/sdk/api/types/ServiceExecution.ts +13 -3
  91. package/src/sdk/api/types/index.ts +2 -6
  92. package/src/sdk/core/auth/BasicAuth.ts +3 -3
  93. package/src/sdk/core/auth/index.ts +2 -2
  94. package/src/sdk/core/base64.ts +27 -0
  95. package/src/sdk/core/fetcher/APIResponse.ts +11 -0
  96. package/src/sdk/core/fetcher/BinaryResponse.ts +36 -0
  97. package/src/sdk/core/fetcher/Fetcher.ts +46 -26
  98. package/src/sdk/core/fetcher/Headers.ts +93 -0
  99. package/src/sdk/core/fetcher/HttpResponsePromise.ts +116 -0
  100. package/src/sdk/core/fetcher/RawResponse.ts +61 -0
  101. package/src/sdk/core/fetcher/ResponseWithBody.ts +7 -0
  102. package/src/sdk/core/fetcher/createRequestUrl.ts +4 -8
  103. package/src/sdk/core/fetcher/getErrorResponseBody.ts +32 -0
  104. package/src/sdk/core/fetcher/getFetchFn.ts +2 -24
  105. package/src/sdk/core/fetcher/getRequestBody.ts +3 -1
  106. package/src/sdk/core/fetcher/getResponseBody.ts +38 -27
  107. package/src/sdk/core/fetcher/index.ts +9 -5
  108. package/src/sdk/core/fetcher/makeRequest.ts +2 -2
  109. package/src/sdk/core/fetcher/requestWithRetries.ts +18 -6
  110. package/src/sdk/core/fetcher/signals.ts +1 -1
  111. package/src/sdk/core/headers.ts +35 -0
  112. package/src/sdk/core/index.ts +5 -3
  113. package/src/sdk/core/json.ts +27 -0
  114. package/src/sdk/core/runtime/index.ts +1 -1
  115. package/src/sdk/core/runtime/runtime.ts +60 -53
  116. package/src/sdk/core/url/index.ts +2 -0
  117. package/src/sdk/core/url/join.ts +55 -0
  118. package/src/sdk/core/url/qs.ts +74 -0
  119. package/src/sdk/errors/PlanqkServiceApiError.ts +21 -11
  120. package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +2 -2
  121. package/src/sdk/errors/index.ts +2 -2
  122. package/src/sdk/index.ts +4 -4
  123. package/dist/sdk/api/errors/BadRequestError.d.ts +0 -7
  124. package/dist/sdk/api/errors/BadRequestError.js +0 -51
  125. package/dist/sdk/api/errors/ForbiddenError.d.ts +0 -7
  126. package/dist/sdk/api/errors/ForbiddenError.js +0 -51
  127. package/dist/sdk/api/errors/InternalServerError.d.ts +0 -7
  128. package/dist/sdk/api/errors/InternalServerError.js +0 -51
  129. package/dist/sdk/api/errors/NotFoundError.d.ts +0 -7
  130. package/dist/sdk/api/errors/NotFoundError.js +0 -51
  131. package/dist/sdk/api/errors/UnauthorizedError.d.ts +0 -7
  132. package/dist/sdk/api/errors/UnauthorizedError.js +0 -51
  133. package/dist/sdk/api/errors/index.d.ts +0 -5
  134. package/dist/sdk/api/errors/index.js +0 -21
  135. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.d.ts +0 -7
  136. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.js +0 -5
  137. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.d.ts +0 -7
  138. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.js +0 -5
  139. package/dist/sdk/api/resources/serviceApi/types/HealthCheckResponse.d.ts +0 -7
  140. package/dist/sdk/api/resources/serviceApi/types/HealthCheckResponse.js +0 -5
  141. package/dist/sdk/api/types/InputData.d.ts +0 -4
  142. package/dist/sdk/api/types/InputData.js +0 -5
  143. package/dist/sdk/api/types/InputDataRef.d.ts +0 -8
  144. package/dist/sdk/api/types/InputDataRef.js +0 -5
  145. package/dist/sdk/api/types/InputParams.d.ts +0 -4
  146. package/dist/sdk/api/types/InputParams.js +0 -5
  147. package/dist/sdk/api/types/ServiceExecutionStatus.d.ts +0 -12
  148. package/dist/sdk/api/types/ServiceExecutionStatus.js +0 -14
  149. package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +0 -30
  150. package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +0 -232
  151. package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -21
  152. package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +0 -91
  153. package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +0 -31
  154. package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +0 -214
  155. package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +0 -18
  156. package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.js +0 -48
  157. package/src/sdk/api/errors/BadRequestError.ts +0 -16
  158. package/src/sdk/api/errors/ForbiddenError.ts +0 -16
  159. package/src/sdk/api/errors/InternalServerError.ts +0 -16
  160. package/src/sdk/api/errors/NotFoundError.ts +0 -16
  161. package/src/sdk/api/errors/UnauthorizedError.ts +0 -16
  162. package/src/sdk/api/errors/index.ts +0 -5
  163. package/src/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.ts +0 -9
  164. package/src/sdk/api/resources/serviceApi/types/GetResultResponseLinks.ts +0 -9
  165. package/src/sdk/api/resources/serviceApi/types/HealthCheckResponse.ts +0 -8
  166. package/src/sdk/api/types/InputData.ts +0 -5
  167. package/src/sdk/api/types/InputDataRef.ts +0 -9
  168. package/src/sdk/api/types/InputParams.ts +0 -5
  169. package/src/sdk/api/types/ServiceExecutionStatus.ts +0 -14
  170. package/src/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +0 -252
  171. package/src/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +0 -106
  172. package/src/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +0 -239
  173. package/src/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +0 -33
package/src/index.test.ts CHANGED
@@ -3,7 +3,7 @@ import {test} from 'vitest'
3
3
  import 'dotenv/config'
4
4
  import {PlanqkServiceClient} from "./client";
5
5
 
6
- test.skip('adds 1 + 2 to equal 3', {timeout: 5 * 60 * 1000}, async () => {
6
+ test.skip('integration test', {timeout: 5 * 60 * 1000}, async () => {
7
7
  const tokenEndpoint = process.env.TOKEN_ENDPOINT
8
8
  const serviceEndpoint = process.env.SERVICE_ENDPOINT
9
9
  const consumerKey = process.env.CONSUMER_KEY
@@ -15,29 +15,42 @@ test.skip('adds 1 + 2 to equal 3', {timeout: 5 * 60 * 1000}, async () => {
15
15
  console.log(`Consumer secret: ${consumerSecret}`)
16
16
 
17
17
  const client = new PlanqkServiceClient(serviceEndpoint!, consumerKey, consumerSecret, tokenEndpoint);
18
- await client.api().healthCheck()
19
18
 
20
- // prepare your input data and parameters
21
- const data = {input: {a: 1, b: 2}};
22
- const params = {param1: "value1", param2: "value2"};
19
+ let serviceExecutions = await client.api().getServiceExecutions()
20
+ console.log(serviceExecutions)
23
21
 
24
- // execute the service
25
- let serviceExecution = await client.api().execute({data, params})
22
+ const data = {n_coin_tosses: 2}
23
+ // const dataRef = {
24
+ // dataPoolId: "87cb778e-ac43-11ec-b909-0242ac120002",
25
+ // dataSourceDescriptorId: "87cb778e-ac43-11ec-b909-0242ac120002",
26
+ // fileId: "87cb778e-ac43-11ec-b909-0242ac120002"
27
+ // }
28
+ const params = {shots: 100}
29
+
30
+ let serviceExecution = await client.api().startExecution({data, params}, {timeoutInSeconds: 60})
26
31
  console.log(serviceExecution)
27
32
 
28
- // retrieve the status of a service execution
29
- serviceExecution = await client.api().getStatus(serviceExecution.id!);
33
+ serviceExecution = await client.api().getStatus(serviceExecution.id!)
34
+ console.log(serviceExecution)
30
35
 
31
- // wait for the service execution to finish
32
- const finalStates = ["SUCCEEDED", "CANCELLED", "FAILED"];
36
+ const finalStates = ["SUCCEEDED", "CANCELLED", "FAILED"]
33
37
  while (!finalStates.includes(serviceExecution.status!)) {
34
- serviceExecution = await client.api().getStatus(serviceExecution.id!);
38
+ serviceExecution = await client.api().getStatus(serviceExecution.id!)
35
39
  }
36
40
  console.log(serviceExecution)
37
41
 
38
- // retrieve the result
39
- await client.api().getResult(serviceExecution.id!)
42
+ const result = await client.api().getResult(serviceExecution.id!)
43
+ console.log(result)
44
+
45
+ const logs = await client.api().getLogs(serviceExecution.id!)
46
+ console.log(logs)
47
+
48
+ serviceExecution = await client.api().cancelExecution(serviceExecution.id!)
49
+ console.log(serviceExecution)
50
+
51
+ serviceExecution = await client.api().getStatus(serviceExecution.id!)
52
+ console.log(serviceExecution)
40
53
 
41
- // retrieve the logs
42
- await client.api().getLogs(serviceExecution.id!)
54
+ serviceExecutions = await client.api().getServiceExecutions()
55
+ console.log(serviceExecutions)
43
56
  })
package/src/sdk/Client.ts CHANGED
@@ -2,31 +2,51 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- import * as environments from "./environments";
6
- import * as core from "./core";
7
- import { ServiceApi } from "./api/resources/serviceApi/client/Client";
5
+ import * as environments from "./environments.js";
6
+ import * as core from "./core/index.js";
7
+ import { mergeHeaders } from "./core/headers.js";
8
+ import { ServiceApi } from "./api/resources/serviceApi/client/Client.js";
8
9
 
9
10
  export declare namespace PlanqkServiceApiClient {
10
- interface Options {
11
+ export interface Options {
11
12
  environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
13
+ /** Specify a custom URL to connect the client to. */
14
+ baseUrl?: core.Supplier<string>;
12
15
  token: core.Supplier<core.BearerToken>;
16
+ /** Additional headers to include in requests. */
17
+ headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
13
18
  }
14
19
 
15
- interface RequestOptions {
20
+ export interface RequestOptions {
16
21
  /** The maximum time to wait for a response in seconds. */
17
22
  timeoutInSeconds?: number;
18
23
  /** The number of times to retry the request. Defaults to 2. */
19
24
  maxRetries?: number;
20
25
  /** A hook to abort the request. */
21
26
  abortSignal?: AbortSignal;
27
+ /** Additional headers to include in the request. */
28
+ headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
22
29
  }
23
30
  }
24
31
 
25
32
  export class PlanqkServiceApiClient {
26
- constructor(protected readonly _options: PlanqkServiceApiClient.Options) {}
27
-
33
+ protected readonly _options: PlanqkServiceApiClient.Options;
28
34
  protected _serviceApi: ServiceApi | undefined;
29
35
 
36
+ constructor(_options: PlanqkServiceApiClient.Options) {
37
+ this._options = {
38
+ ..._options,
39
+ headers: mergeHeaders(
40
+ {
41
+ "X-Fern-Language": "JavaScript",
42
+ "X-Fern-Runtime": core.RUNTIME.type,
43
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
44
+ },
45
+ _options?.headers,
46
+ ),
47
+ };
48
+ }
49
+
30
50
  public get serviceApi(): ServiceApi {
31
51
  return (this._serviceApi ??= new ServiceApi(this._options));
32
52
  }
@@ -1,3 +1,2 @@
1
- export * from "./resources";
2
- export * from "./types";
3
- export * from "./errors";
1
+ export * from "./resources/index.js";
2
+ export * from "./types/index.js";
@@ -1,2 +1,2 @@
1
- export * as serviceApi from "./serviceApi";
2
- export * from "./serviceApi/types";
1
+ export * as serviceApi from "./serviceApi/index.js";
2
+ export * from "./serviceApi/types/index.js";