@planqk/planqk-service-sdk 1.7.0 → 1.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.
Files changed (29) hide show
  1. package/dist/client.d.ts +1 -1
  2. package/dist/client.js +13 -5
  3. package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +1 -1
  4. package/dist/sdk/api/resources/serviceApi/client/Client.js +1 -1
  5. package/dist/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.d.ts +0 -1
  6. package/dist/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.d.ts +2 -3
  7. package/dist/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.d.ts +1 -1
  8. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +1 -1
  9. package/dist/sdk/api/resources/statusApi/client/Client.d.ts +1 -1
  10. package/dist/sdk/api/types/{InputDataRef.d.ts → InputRef.d.ts} +1 -1
  11. package/dist/sdk/api/types/Job.d.ts +1 -1
  12. package/dist/sdk/api/types/index.d.ts +1 -2
  13. package/dist/sdk/api/types/index.js +1 -2
  14. package/package.json +1 -1
  15. package/src/client.ts +13 -6
  16. package/src/sdk/api/resources/serviceApi/client/Client.ts +1 -1
  17. package/src/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.ts +0 -1
  18. package/src/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.ts +2 -3
  19. package/src/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.ts +1 -1
  20. package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +1 -1
  21. package/src/sdk/api/resources/statusApi/client/Client.ts +1 -1
  22. package/src/sdk/api/types/{InputDataRef.ts → InputRef.ts} +1 -1
  23. package/src/sdk/api/types/Job.ts +1 -1
  24. package/src/sdk/api/types/index.ts +1 -2
  25. package/tests/integration.test.ts +33 -30
  26. package/dist/sdk/api/types/InputParamsRef.d.ts +0 -8
  27. package/dist/sdk/api/types/InputParamsRef.js +0 -5
  28. package/src/sdk/api/types/InputParamsRef.ts +0 -9
  29. /package/dist/sdk/api/types/{InputDataRef.js → InputRef.js} +0 -0
package/dist/client.d.ts CHANGED
@@ -2,7 +2,7 @@ import { GetInterimResultsRequest, GetInterimResultsResponse, GetResultResponse,
2
2
  import { ServiceApi } from './sdk/api/resources/serviceApi/client/Client';
3
3
  export declare class PlanqkServiceClient {
4
4
  private _api;
5
- constructor(serviceEndpoint: string, consumerKey: string, consumerSecret: string, tokenEndpoint?: string);
5
+ constructor(serviceEndpoint: string, consumerKey?: string, consumerSecret?: string, tokenEndpoint?: string);
6
6
  cancelExecution(jobId: string, requestOptions?: ServiceApi.RequestOptions): Promise<Job>;
7
7
  getInterimResults(jobId: string, request?: GetInterimResultsRequest, requestOptions?: ServiceApi.RequestOptions): Promise<GetInterimResultsResponse>;
8
8
  getResult(jobId: string, requestOptions?: ServiceApi.RequestOptions): Promise<GetResultResponse>;
package/dist/client.js CHANGED
@@ -15,11 +15,19 @@ const sdk_1 = require("./sdk");
15
15
  const api_1 = require("./sdk/api");
16
16
  class PlanqkServiceClient {
17
17
  constructor(serviceEndpoint, consumerKey, consumerSecret, tokenEndpoint = auth_1.DEFAULT_TOKEN_ENDPOINT) {
18
- const auth = new auth_1.PlanqkServiceAuth(consumerKey, consumerSecret, tokenEndpoint);
19
- this._api = new sdk_1.PlanqkServiceApiClient({
20
- environment: () => serviceEndpoint,
21
- token: () => __awaiter(this, void 0, void 0, function* () { return auth.getAccessToken(); }),
22
- });
18
+ if (consumerKey && consumerSecret) {
19
+ const auth = new auth_1.PlanqkServiceAuth(consumerKey, consumerSecret, tokenEndpoint);
20
+ this._api = new sdk_1.PlanqkServiceApiClient({
21
+ environment: () => serviceEndpoint,
22
+ token: () => __awaiter(this, void 0, void 0, function* () { return auth.getAccessToken(); }),
23
+ });
24
+ }
25
+ else {
26
+ this._api = new sdk_1.PlanqkServiceApiClient({
27
+ environment: () => serviceEndpoint,
28
+ token: () => __awaiter(this, void 0, void 0, function* () { return Math.random().toString(36).slice(2); }),
29
+ });
30
+ }
23
31
  }
24
32
  cancelExecution(jobId, requestOptions) {
25
33
  return this._api.serviceApi.cancelExecution(jobId, requestOptions);
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as environments from "../../../../environments";
5
5
  import * as core from "../../../../core";
6
- import * as PlanqkServiceApi from "../../..";
6
+ import * as PlanqkServiceApi from "../../../index";
7
7
  export declare namespace ServiceApi {
8
8
  interface Options {
9
9
  environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
@@ -41,7 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.ServiceApi = void 0;
42
42
  const environments = __importStar(require("../../../../environments"));
43
43
  const core = __importStar(require("../../../../core"));
44
- const PlanqkServiceApi = __importStar(require("../../.."));
44
+ const PlanqkServiceApi = __importStar(require("../../../index"));
45
45
  const errors = __importStar(require("../../../../errors"));
46
46
  const url_join_1 = __importDefault(require("url-join"));
47
47
  class ServiceApi {
@@ -4,7 +4,6 @@
4
4
  export interface GetInterimResultsRequest {
5
5
  /**
6
6
  * Either true or false to show only the last or all interim results (default: false).
7
- *
8
7
  */
9
8
  last?: boolean;
10
9
  }
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as PlanqkServiceApi from "../../../..";
4
+ import * as PlanqkServiceApi from "../../../../index";
5
5
  /**
6
6
  * @example
7
7
  * {}
8
8
  */
9
9
  export interface StartExecutionRequest {
10
10
  data?: PlanqkServiceApi.InputData;
11
- dataRef?: PlanqkServiceApi.InputDataRef;
11
+ dataRef?: PlanqkServiceApi.InputRef;
12
12
  params?: PlanqkServiceApi.InputParams;
13
- paramsRef?: PlanqkServiceApi.InputParamsRef;
14
13
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as PlanqkServiceApi from "../../..";
4
+ import * as PlanqkServiceApi from "../../../index";
5
5
  export type GetInterimResultsResponse = PlanqkServiceApi.InterimResultResponse[] | PlanqkServiceApi.InterimResultResponse;
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as PlanqkServiceApi from "../../..";
4
+ import * as PlanqkServiceApi from "../../../index";
5
5
  export type GetResultResponse = PlanqkServiceApi.ObjectResponse | PlanqkServiceApi.StringResponse | PlanqkServiceApi.NumberResponse | PlanqkServiceApi.ArrayResponse;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as environments from "../../../../environments";
5
5
  import * as core from "../../../../core";
6
- import * as PlanqkServiceApi from "../../..";
6
+ import * as PlanqkServiceApi from "../../../index";
7
7
  export declare namespace StatusApi {
8
8
  interface Options {
9
9
  environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export interface InputDataRef {
4
+ export interface InputRef {
5
5
  dataPoolId: string;
6
6
  dataSourceDescriptorId: string;
7
7
  fileId: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- import * as PlanqkServiceApi from "..";
4
+ import * as PlanqkServiceApi from "../index";
5
5
  export interface Job {
6
6
  id?: string;
7
7
  status?: PlanqkServiceApi.JobStatus;
@@ -1,7 +1,6 @@
1
1
  export * from "./InputData";
2
- export * from "./InputDataRef";
3
2
  export * from "./InputParams";
4
- export * from "./InputParamsRef";
3
+ export * from "./InputRef";
5
4
  export * from "./InterimResultResponse";
6
5
  export * from "./ObjectResponse";
7
6
  export * from "./StringResponse";
@@ -15,9 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./InputData"), exports);
18
- __exportStar(require("./InputDataRef"), exports);
19
18
  __exportStar(require("./InputParams"), exports);
20
- __exportStar(require("./InputParamsRef"), exports);
19
+ __exportStar(require("./InputRef"), exports);
21
20
  __exportStar(require("./InterimResultResponse"), exports);
22
21
  __exportStar(require("./ObjectResponse"), exports);
23
22
  __exportStar(require("./StringResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planqk/planqk-service-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Typescript SDK to execute PlanQK Managed Services.",
5
5
  "author": "Kipu Quantum GmbH",
6
6
  "contributors": [
package/src/client.ts CHANGED
@@ -15,12 +15,19 @@ import {ServiceApi} from './sdk/api/resources/serviceApi/client/Client'
15
15
  export class PlanqkServiceClient {
16
16
  private _api: PlanqkServiceApiClient
17
17
 
18
- constructor(serviceEndpoint: string, consumerKey: string, consumerSecret: string, tokenEndpoint: string = DEFAULT_TOKEN_ENDPOINT) {
19
- const auth = new PlanqkServiceAuth(consumerKey, consumerSecret, tokenEndpoint)
20
- this._api = new PlanqkServiceApiClient({
21
- environment: () => serviceEndpoint,
22
- token: async () => auth.getAccessToken(),
23
- })
18
+ constructor(serviceEndpoint: string, consumerKey?: string, consumerSecret?: string, tokenEndpoint: string = DEFAULT_TOKEN_ENDPOINT) {
19
+ if (consumerKey && consumerSecret) {
20
+ const auth = new PlanqkServiceAuth(consumerKey, consumerSecret, tokenEndpoint)
21
+ this._api = new PlanqkServiceApiClient({
22
+ environment: () => serviceEndpoint,
23
+ token: async () => auth.getAccessToken(),
24
+ })
25
+ } else {
26
+ this._api = new PlanqkServiceApiClient({
27
+ environment: () => serviceEndpoint,
28
+ token: async () => Math.random().toString(36).slice(2),
29
+ })
30
+ }
24
31
  }
25
32
 
26
33
  public cancelExecution(jobId: string, requestOptions?: ServiceApi.RequestOptions): Promise<Job> {
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as environments from "../../../../environments";
6
6
  import * as core from "../../../../core";
7
- import * as PlanqkServiceApi from "../../..";
7
+ import * as PlanqkServiceApi from "../../../index";
8
8
  import * as errors from "../../../../errors";
9
9
  import urlJoin from "url-join";
10
10
 
@@ -5,7 +5,6 @@
5
5
  export interface GetInterimResultsRequest {
6
6
  /**
7
7
  * Either true or false to show only the last or all interim results (default: false).
8
- *
9
8
  */
10
9
  last?: boolean;
11
10
  }
@@ -2,7 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- import * as PlanqkServiceApi from "../../../..";
5
+ import * as PlanqkServiceApi from "../../../../index";
6
6
 
7
7
  /**
8
8
  * @example
@@ -10,7 +10,6 @@ import * as PlanqkServiceApi from "../../../..";
10
10
  */
11
11
  export interface StartExecutionRequest {
12
12
  data?: PlanqkServiceApi.InputData;
13
- dataRef?: PlanqkServiceApi.InputDataRef;
13
+ dataRef?: PlanqkServiceApi.InputRef;
14
14
  params?: PlanqkServiceApi.InputParams;
15
- paramsRef?: PlanqkServiceApi.InputParamsRef;
16
15
  }
@@ -2,7 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- import * as PlanqkServiceApi from "../../..";
5
+ import * as PlanqkServiceApi from "../../../index";
6
6
 
7
7
  export type GetInterimResultsResponse =
8
8
  | PlanqkServiceApi.InterimResultResponse[]
@@ -2,7 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- import * as PlanqkServiceApi from "../../..";
5
+ import * as PlanqkServiceApi from "../../../index";
6
6
 
7
7
  export type GetResultResponse =
8
8
  | PlanqkServiceApi.ObjectResponse
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as environments from "../../../../environments";
6
6
  import * as core from "../../../../core";
7
- import * as PlanqkServiceApi from "../../..";
7
+ import * as PlanqkServiceApi from "../../../index";
8
8
  import * as errors from "../../../../errors";
9
9
 
10
10
  export declare namespace StatusApi {
@@ -2,7 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- export interface InputDataRef {
5
+ export interface InputRef {
6
6
  dataPoolId: string;
7
7
  dataSourceDescriptorId: string;
8
8
  fileId: string;
@@ -2,7 +2,7 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- import * as PlanqkServiceApi from "..";
5
+ import * as PlanqkServiceApi from "../index";
6
6
 
7
7
  export interface Job {
8
8
  id?: string;
@@ -1,7 +1,6 @@
1
1
  export * from "./InputData";
2
- export * from "./InputDataRef";
3
2
  export * from "./InputParams";
4
- export * from "./InputParamsRef";
3
+ export * from "./InputRef";
5
4
  export * from "./InterimResultResponse";
6
5
  export * from "./ObjectResponse";
7
6
  export * from "./StringResponse";
@@ -3,21 +3,43 @@ import {PlanqkServiceApiClient} from '../src/sdk'
3
3
  import {JobStatus, StartExecutionRequest} from '../src/sdk/api'
4
4
  import {complexInput} from './fixtures/complex-input'
5
5
 
6
- const serviceEndpoint = process.env.SERVICE_ENDPOINT
6
+ const serviceEndpoint = process.env.SERVICE_ENDPOINT || 'http://localhost:8081'
7
7
  const consumerKey = process.env.CONSUMER_KEY
8
8
  const consumerSecret = process.env.CONSUMER_SECRET
9
9
 
10
- if (!serviceEndpoint || !consumerKey || !consumerSecret) {
11
- throw new Error('Environment variables SERVICE_ENDPOINT, CONSUMER_KEY, or CONSUMER_SECRET are not defined')
12
- }
10
+ test('should use client', async () => {
11
+ const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
12
+
13
+ const health = await client.healthCheck()
14
+ expect(health.status).toBe('Service is up and running')
15
+
16
+ let job = await client.startExecution(complexInput)
17
+ expect(job.id).toBeDefined()
18
+ expect(job.status).toBe(JobStatus.Pending)
19
+
20
+ job = await client.getStatus(job.id!)
13
21
 
14
- test('should use generated client', async () => {
15
- const auth = new PlanqkServiceAuth(consumerKey, consumerSecret)
22
+ const result = await client.getResult(job.id!)
23
+ expect(result).toBeDefined()
16
24
 
17
- const api = new PlanqkServiceApiClient({
18
- environment: () => serviceEndpoint,
19
- token: async () => auth.getAccessToken(),
20
- })
25
+ job = await client.getStatus(job.id!)
26
+ expect(job.status).toBe(JobStatus.Succeeded)
27
+ }, 5 * 60 * 1000)
28
+
29
+ test('should use raw client', async () => {
30
+ let api: PlanqkServiceApiClient
31
+ if (consumerKey && consumerSecret) {
32
+ const auth = new PlanqkServiceAuth(consumerKey, consumerSecret)
33
+ api = new PlanqkServiceApiClient({
34
+ environment: () => serviceEndpoint,
35
+ token: async () => auth.getAccessToken(),
36
+ })
37
+ } else {
38
+ api = new PlanqkServiceApiClient({
39
+ environment: () => serviceEndpoint,
40
+ token: async () => Math.random().toString(36).slice(2),
41
+ })
42
+ }
21
43
 
22
44
  const health = await api.statusApi.healthCheck()
23
45
  expect(health.status).toBe('Service is up and running')
@@ -41,26 +63,7 @@ test('should use generated client', async () => {
41
63
  expect(result).toBeDefined()
42
64
  }, 5 * 60 * 1000)
43
65
 
44
- test('should use client abstraction', async () => {
45
- const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
46
-
47
- const health = await client.healthCheck()
48
- expect(health.status).toBe('Service is up and running')
49
-
50
- let job = await client.startExecution(complexInput)
51
- expect(job.id).toBeDefined()
52
- expect(job.status).toBe(JobStatus.Pending)
53
-
54
- job = await client.getStatus(job.id!)
55
-
56
- const result = await client.getResult(job.id!)
57
- expect(result).toBeDefined()
58
-
59
- job = await client.getStatus(job.id!)
60
- expect(job.status).toBe(JobStatus.Succeeded)
61
- }, 5 * 60 * 1000)
62
-
63
- test('should execute with data pool ref', async () => {
66
+ test('should use client with data pool ref', async () => {
64
67
  const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
65
68
 
66
69
  const health = await client.healthCheck()
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export interface InputParamsRef {
5
- dataPoolId: string;
6
- dataSourceDescriptorId: string;
7
- fileId: string;
8
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
- /**
3
- * This file was auto-generated by Fern from our API Definition.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
-
5
- export interface InputParamsRef {
6
- dataPoolId: string;
7
- dataSourceDescriptorId: string;
8
- fileId: string;
9
- }