@mittwald/api-client 1.0.0-alpha.16 → 1.0.0-alpha.18
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/README.md +2 -2
- package/dist/generated/v2/client.d.ts +55 -4
- package/dist/generated/v2/client.js +7 -1
- package/dist/generated/v2/descriptors.d.ts +15 -7
- package/dist/generated/v2/descriptors.js +27 -3
- package/dist/generated/v2/types.d.ts +177 -3
- package/dist/v2.js +1 -1
- package/dist-cjs/generated/v2/client.d.ts +5995 -0
- package/dist-cjs/generated/v2/client.js +712 -0
- package/dist-cjs/generated/v2/descriptors.d.ts +637 -0
- package/dist-cjs/generated/v2/descriptors.js +1905 -0
- package/dist-cjs/index.d.ts +1 -0
- package/dist-cjs/index.js +2 -0
- package/dist-cjs/v2.d.ts +10 -0
- package/dist-cjs/v2.js +58 -0
- package/package.json +20 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist-cjs/v2.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import MittwaldApiV2Client from "./generated/v2/client.js";
|
|
2
|
+
export declare class MittwaldAPIClient extends MittwaldApiV2Client {
|
|
3
|
+
private readonly apiToken;
|
|
4
|
+
private constructor();
|
|
5
|
+
private setupInterceptors;
|
|
6
|
+
static newUnauthenticated(): MittwaldAPIClient;
|
|
7
|
+
static newWithToken(apiToken: string): MittwaldAPIClient;
|
|
8
|
+
static newWithCredentials(email: string, password: string): Promise<MittwaldAPIClient>;
|
|
9
|
+
}
|
|
10
|
+
export default MittwaldAPIClient;
|
package/dist-cjs/v2.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MittwaldAPIClient = void 0;
|
|
16
|
+
const api_client_commons_1 = require("@mittwald/api-client-commons");
|
|
17
|
+
const client_js_1 = __importDefault(require("./generated/v2/client.js"));
|
|
18
|
+
class MittwaldAPIClient extends client_js_1.default {
|
|
19
|
+
constructor(apiToken) {
|
|
20
|
+
super({
|
|
21
|
+
baseURL: "https://api.mittwald.de/",
|
|
22
|
+
});
|
|
23
|
+
this.apiToken = apiToken;
|
|
24
|
+
this.setupInterceptors();
|
|
25
|
+
}
|
|
26
|
+
setupInterceptors() {
|
|
27
|
+
this.axios.interceptors.request.use((conf) => {
|
|
28
|
+
const token = this.apiToken;
|
|
29
|
+
if (token) {
|
|
30
|
+
conf.headers.set("x-access-token", token);
|
|
31
|
+
}
|
|
32
|
+
return conf;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
static newUnauthenticated() {
|
|
36
|
+
return new MittwaldAPIClient();
|
|
37
|
+
}
|
|
38
|
+
static newWithToken(apiToken) {
|
|
39
|
+
return new MittwaldAPIClient(apiToken);
|
|
40
|
+
}
|
|
41
|
+
static newWithCredentials(email, password) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const client = MittwaldAPIClient.newUnauthenticated();
|
|
44
|
+
const authResult = yield client.user.authenticate({
|
|
45
|
+
data: {
|
|
46
|
+
email,
|
|
47
|
+
password,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
if (authResult.status === 200) {
|
|
51
|
+
return new MittwaldAPIClient(authResult.data.token);
|
|
52
|
+
}
|
|
53
|
+
throw api_client_commons_1.ApiClientError.fromResponse("Login failed", authResult);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.MittwaldAPIClient = MittwaldAPIClient;
|
|
58
|
+
exports.default = MittwaldAPIClient;
|
package/package.json
CHANGED
|
@@ -1,38 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/api-client",
|
|
3
3
|
"description": "Auto-generated client for the mittwald API",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.18",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:mittwald/api-client-js",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Mittwald CM Service GmbH & Co. KG",
|
|
9
|
+
"email": "opensource@mittwald.de"
|
|
10
|
+
},
|
|
7
11
|
"homepage": "https://developer.mittwald.de",
|
|
8
12
|
"bugs": {
|
|
9
13
|
"url": "https://github.com/mittwald/api-client-js/issues"
|
|
10
14
|
},
|
|
11
15
|
"type": "module",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
16
|
+
"exports": {
|
|
17
|
+
"./v2": {
|
|
18
|
+
"import": "./dist/v2.js",
|
|
19
|
+
"default": "./dist-cjs/v2.js"
|
|
20
|
+
}
|
|
15
21
|
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"mittwald",
|
|
18
|
-
"api",
|
|
19
|
-
"client",
|
|
20
|
-
"sdk",
|
|
21
|
-
"rest"
|
|
22
|
-
],
|
|
23
22
|
"scripts": {
|
|
24
23
|
"copy:dts": "yarn run -T copyfiles -u 1 src/**/*.d.ts dist",
|
|
25
24
|
"generate:client": "yarn generate:client:v2 && yarn post:generate",
|
|
26
25
|
"generate:client-dev": "yarn generate:client-dev:v2 && yarn post:generate",
|
|
27
26
|
"generate:client-dev:v2": "curl --silent https://api-public.dev.mittwald.systems/openapi | ./transform-openapi.sh | yarn acg generate --name MittwaldAPIV2 - src/generated/v2 --optionalHeader x-access-token",
|
|
28
27
|
"generate:client:v2": "curl --silent https://api.mittwald.de/openapi | ./transform-openapi.sh | yarn acg generate --name MittwaldAPIV2 - src/generated/v2 --optionalHeader x-access-token",
|
|
29
|
-
"post:generate": "yarn run -T compile && yarn copy:dts"
|
|
28
|
+
"post:generate": "yarn run -T compile && yarn run -T compile:cjs && yarn copy:dts"
|
|
30
29
|
},
|
|
31
30
|
"files": [
|
|
32
|
-
"dist/**/*.{js,d.ts}"
|
|
31
|
+
"{dist,dist-cjs}/**/*.{js,d.ts}"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"mittwald",
|
|
35
|
+
"api",
|
|
36
|
+
"client",
|
|
37
|
+
"sdk",
|
|
38
|
+
"rest"
|
|
33
39
|
],
|
|
34
40
|
"dependencies": {
|
|
35
|
-
"@mittwald/api-client-commons": "^
|
|
41
|
+
"@mittwald/api-client-commons": "^2.0.0"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
38
44
|
"@mittwald/api-code-generator": "^1.0.0"
|