@planqk/planqk-service-sdk 1.6.0 → 1.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.
- package/dist/client.d.ts +1 -1
- package/dist/client.js +13 -5
- package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +1 -1
- package/dist/sdk/api/resources/serviceApi/client/Client.js +1 -1
- package/dist/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.d.ts +2 -1
- package/dist/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.d.ts +1 -1
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +2 -2
- package/dist/sdk/api/resources/statusApi/client/Client.d.ts +1 -1
- package/dist/sdk/api/types/ArrayResponse.d.ts +4 -0
- package/dist/sdk/api/types/InputRef.d.ts +8 -0
- package/dist/sdk/api/types/Job.d.ts +1 -1
- package/dist/sdk/api/types/{ErrorResponse.d.ts → NumberResponse.d.ts} +1 -1
- package/dist/sdk/api/types/NumberResponse.js +5 -0
- package/dist/sdk/api/types/{ResultResponse.d.ts → ObjectResponse.d.ts} +1 -1
- package/dist/sdk/api/types/ObjectResponse.js +5 -0
- package/dist/sdk/api/types/StringResponse.d.ts +4 -0
- package/dist/sdk/api/types/StringResponse.js +5 -0
- package/dist/sdk/api/types/index.d.ts +5 -2
- package/dist/sdk/api/types/index.js +5 -2
- package/package.json +1 -1
- package/src/client.ts +13 -6
- package/src/sdk/api/resources/serviceApi/client/Client.ts +1 -1
- package/src/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.ts +0 -1
- package/src/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.ts +2 -1
- package/src/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.ts +1 -1
- package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +6 -2
- package/src/sdk/api/resources/statusApi/client/Client.ts +1 -1
- package/src/sdk/api/types/ArrayResponse.ts +5 -0
- package/src/sdk/api/types/InputRef.ts +9 -0
- package/src/sdk/api/types/Job.ts +1 -1
- package/src/sdk/api/types/{ErrorResponse.ts → NumberResponse.ts} +1 -1
- package/src/sdk/api/types/{ResultResponse.ts → ObjectResponse.ts} +1 -1
- package/src/sdk/api/types/StringResponse.ts +5 -0
- package/src/sdk/api/types/index.ts +5 -2
- package/tests/integration.test.ts +44 -13
- /package/dist/sdk/api/types/{ErrorResponse.js → ArrayResponse.js} +0 -0
- /package/dist/sdk/api/types/{ResultResponse.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
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 {
|
|
@@ -1,12 +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.InputRef;
|
|
11
12
|
params?: PlanqkServiceApi.InputParams;
|
|
12
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 "
|
|
5
|
-
export type GetResultResponse = PlanqkServiceApi.
|
|
4
|
+
import * as PlanqkServiceApi from "../../../index";
|
|
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,10 @@
|
|
|
1
1
|
export * from "./InputData";
|
|
2
2
|
export * from "./InputParams";
|
|
3
|
+
export * from "./InputRef";
|
|
3
4
|
export * from "./InterimResultResponse";
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
5
|
+
export * from "./ObjectResponse";
|
|
6
|
+
export * from "./StringResponse";
|
|
7
|
+
export * from "./NumberResponse";
|
|
8
|
+
export * from "./ArrayResponse";
|
|
6
9
|
export * from "./JobStatus";
|
|
7
10
|
export * from "./Job";
|
|
@@ -16,8 +16,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./InputData"), exports);
|
|
18
18
|
__exportStar(require("./InputParams"), exports);
|
|
19
|
+
__exportStar(require("./InputRef"), exports);
|
|
19
20
|
__exportStar(require("./InterimResultResponse"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./ObjectResponse"), exports);
|
|
22
|
+
__exportStar(require("./StringResponse"), exports);
|
|
23
|
+
__exportStar(require("./NumberResponse"), exports);
|
|
24
|
+
__exportStar(require("./ArrayResponse"), exports);
|
|
22
25
|
__exportStar(require("./JobStatus"), exports);
|
|
23
26
|
__exportStar(require("./Job"), exports);
|
package/package.json
CHANGED
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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
|
@@ -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,5 +10,6 @@ import * as PlanqkServiceApi from "../../../..";
|
|
|
10
10
|
*/
|
|
11
11
|
export interface StartExecutionRequest {
|
|
12
12
|
data?: PlanqkServiceApi.InputData;
|
|
13
|
+
dataRef?: PlanqkServiceApi.InputRef;
|
|
13
14
|
params?: PlanqkServiceApi.InputParams;
|
|
14
15
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
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
|
-
export type GetResultResponse =
|
|
7
|
+
export type GetResultResponse =
|
|
8
|
+
| PlanqkServiceApi.ObjectResponse
|
|
9
|
+
| PlanqkServiceApi.StringResponse
|
|
10
|
+
| PlanqkServiceApi.NumberResponse
|
|
11
|
+
| PlanqkServiceApi.ArrayResponse;
|
|
@@ -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 {
|
package/src/sdk/api/types/Job.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./InputData";
|
|
2
2
|
export * from "./InputParams";
|
|
3
|
+
export * from "./InputRef";
|
|
3
4
|
export * from "./InterimResultResponse";
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
5
|
+
export * from "./ObjectResponse";
|
|
6
|
+
export * from "./StringResponse";
|
|
7
|
+
export * from "./NumberResponse";
|
|
8
|
+
export * from "./ArrayResponse";
|
|
6
9
|
export * from "./JobStatus";
|
|
7
10
|
export * from "./Job";
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
import {PlanqkServiceAuth, PlanqkServiceClient} from '../src'
|
|
2
2
|
import {PlanqkServiceApiClient} from '../src/sdk'
|
|
3
|
-
import {JobStatus} from '../src/sdk/api'
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
22
|
+
const result = await client.getResult(job.id!)
|
|
23
|
+
expect(result).toBeDefined()
|
|
24
|
+
|
|
25
|
+
job = await client.getStatus(job.id!)
|
|
26
|
+
expect(job.status).toBe(JobStatus.Succeeded)
|
|
27
|
+
}, 5 * 60 * 1000)
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,13 +63,22 @@ test('should use generated client', async () => {
|
|
|
41
63
|
expect(result).toBeDefined()
|
|
42
64
|
}, 5 * 60 * 1000)
|
|
43
65
|
|
|
44
|
-
test('should use client
|
|
66
|
+
test('should use client with data pool ref', async () => {
|
|
45
67
|
const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
|
|
46
68
|
|
|
47
69
|
const health = await client.healthCheck()
|
|
48
70
|
expect(health.status).toBe('Service is up and running')
|
|
49
71
|
|
|
50
|
-
|
|
72
|
+
const request: StartExecutionRequest = {
|
|
73
|
+
dataRef: {
|
|
74
|
+
dataPoolId: 'e3859bb2-1959-4d3d-852b-62ee81b28a72',
|
|
75
|
+
dataSourceDescriptorId: '1c8d341e-1c86-4e19-acae-2f84bcab55ca',
|
|
76
|
+
fileId: 'f5251675-49c6-49f3-a3a6-de75b8335d76',
|
|
77
|
+
},
|
|
78
|
+
params: {},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let job = await client.startExecution(request)
|
|
51
82
|
expect(job.id).toBeDefined()
|
|
52
83
|
expect(job.status).toBe(JobStatus.Pending)
|
|
53
84
|
|
|
File without changes
|
|
File without changes
|