@mittwald/api-client 3.1.1 → 3.1.2
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/{react.d.ts → cjs/generated/v2/client-react.d.ts} +263 -268
- package/dist/cjs/generated/v2/client-react.js +343 -0
- package/dist/cjs/generated/v2/client.d.ts +9897 -0
- package/dist/cjs/generated/v2/client.js +674 -0
- package/dist/cjs/generated/v2/descriptors.d.ts +589 -0
- package/dist/cjs/generated/v2/descriptors.js +1760 -0
- package/dist/cjs/generated/v2/types.d.ts +14741 -0
- package/dist/cjs/generated/v2/types.js +2 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/react.d.ts +1 -0
- package/dist/cjs/react.js +5 -0
- package/dist/{index.d.ts → cjs/v2/default.d.ts} +4 -8
- package/dist/cjs/v2/default.js +70 -0
- package/dist/cjs/v2/react.d.ts +3 -0
- package/dist/cjs/v2/react.js +7 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +4 -0
- package/dist/{react.d.cts → esm/generated/v2/client-react.d.ts} +263 -268
- package/dist/esm/generated/v2/client-react.js +347 -0
- package/dist/esm/generated/v2/client.d.ts +9897 -0
- package/dist/esm/generated/v2/client.js +644 -0
- package/dist/esm/generated/v2/descriptors.d.ts +589 -0
- package/dist/esm/generated/v2/descriptors.js +1752 -0
- package/dist/esm/generated/v2/types.d.ts +14741 -0
- package/dist/esm/generated/v2/types.js +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/react.d.ts +1 -0
- package/dist/esm/react.js +1 -0
- package/dist/{index.d.cts → esm/v2/default.d.ts} +4 -8
- package/dist/esm/v2/default.js +53 -0
- package/dist/esm/v2/react.d.ts +3 -0
- package/dist/esm/v2/react.js +3 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +25 -17
- package/dist/chunk-LELXC74W.js +0 -1770
- package/dist/client-739be67c.d.ts +0 -25271
- package/dist/index.cjs +0 -2627
- package/dist/index.js +0 -1440
- package/dist/react.cjs +0 -1360
- package/dist/react.js +0 -830
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MittwaldAPIV2Client = exports.assertStatus = void 0;
|
|
4
|
+
var api_client_commons_1 = require("@mittwald/api-client-commons");
|
|
5
|
+
Object.defineProperty(exports, "assertStatus", { enumerable: true, get: function () { return api_client_commons_1.assertStatus; } });
|
|
6
|
+
var default_js_1 = require("./v2/default.js");
|
|
7
|
+
Object.defineProperty(exports, "MittwaldAPIV2Client", { enumerable: true, get: function () { return default_js_1.MittwaldAPIClient; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MittwaldAPIClientReact as MittwaldAPIV2ClientReact } from "./v2/react.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MittwaldAPIV2ClientReact = void 0;
|
|
4
|
+
var react_js_1 = require("./v2/react.js");
|
|
5
|
+
Object.defineProperty(exports, "MittwaldAPIV2ClientReact", { enumerable: true, get: function () { return react_js_1.MittwaldAPIClientReact; } });
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
import 'axios';
|
|
5
|
-
|
|
6
|
-
declare class MittwaldAPIClient extends MittwaldAPIV2Client {
|
|
1
|
+
import MittwaldApiV2Client from "../generated/v2/client.js";
|
|
2
|
+
export type { MittwaldAPIV2 } from "../generated/v2/types.js";
|
|
3
|
+
export declare class MittwaldAPIClient extends MittwaldApiV2Client {
|
|
7
4
|
private readonly apiToken;
|
|
8
5
|
private constructor();
|
|
9
6
|
private static createAxiosDefaults;
|
|
@@ -12,5 +9,4 @@ declare class MittwaldAPIClient extends MittwaldAPIV2Client {
|
|
|
12
9
|
static newWithToken(apiToken: string): MittwaldAPIClient;
|
|
13
10
|
static newWithCredentials(email: string, password: string): Promise<MittwaldAPIClient>;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
export { MittwaldAPIClient as MittwaldAPIV2Client };
|
|
12
|
+
export default MittwaldAPIClient;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
const version_js_1 = require("../version.js");
|
|
19
|
+
const browser_or_node_1 = require("browser-or-node");
|
|
20
|
+
const defaultUserAgent = "mittwald-api-client/" + version_js_1.MittwaldAPIClientVersion;
|
|
21
|
+
class MittwaldAPIClient extends client_js_1.default {
|
|
22
|
+
constructor(apiToken) {
|
|
23
|
+
super(MittwaldAPIClient.createAxiosDefaults());
|
|
24
|
+
this.apiToken = apiToken;
|
|
25
|
+
this.setupInterceptors();
|
|
26
|
+
}
|
|
27
|
+
static createAxiosDefaults() {
|
|
28
|
+
const headers = {};
|
|
29
|
+
// Setting user agent is not allowed in browser environment
|
|
30
|
+
if (!browser_or_node_1.isBrowser) {
|
|
31
|
+
headers["User-Agent"] = defaultUserAgent;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
baseURL: "https://api.mittwald.de/",
|
|
35
|
+
headers: headers,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
setupInterceptors() {
|
|
39
|
+
this.axios.interceptors.request.use((conf) => {
|
|
40
|
+
const token = this.apiToken;
|
|
41
|
+
if (token) {
|
|
42
|
+
conf.headers.set("x-access-token", token);
|
|
43
|
+
}
|
|
44
|
+
return conf;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
static newUnauthenticated() {
|
|
48
|
+
return new MittwaldAPIClient();
|
|
49
|
+
}
|
|
50
|
+
static newWithToken(apiToken) {
|
|
51
|
+
return new MittwaldAPIClient(apiToken);
|
|
52
|
+
}
|
|
53
|
+
static newWithCredentials(email, password) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const client = MittwaldAPIClient.newUnauthenticated();
|
|
56
|
+
const authResult = yield client.user.authenticate({
|
|
57
|
+
data: {
|
|
58
|
+
email,
|
|
59
|
+
password,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (authResult.status === 200) {
|
|
63
|
+
return new MittwaldAPIClient(authResult.data.token);
|
|
64
|
+
}
|
|
65
|
+
throw api_client_commons_1.ApiClientError.fromResponse("Login failed", authResult);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.MittwaldAPIClient = MittwaldAPIClient;
|
|
70
|
+
exports.default = MittwaldAPIClient;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MittwaldAPIClientReact = void 0;
|
|
4
|
+
const client_react_js_1 = require("../generated/v2/client-react.js");
|
|
5
|
+
var client_react_js_2 = require("../generated/v2/client-react.js");
|
|
6
|
+
Object.defineProperty(exports, "MittwaldAPIClientReact", { enumerable: true, get: function () { return client_react_js_2.MittwaldAPIV2ClientReact; } });
|
|
7
|
+
exports.default = client_react_js_1.MittwaldAPIV2ClientReact;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MittwaldAPIClientVersion = "0.0.0-development";
|