@emilgroup/task-sdk 1.0.1-beta.1

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 (139) hide show
  1. package/.openapi-generator/FILES +51 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -0
  5. package/api/categories-api.ts +651 -0
  6. package/api/default-api.ts +124 -0
  7. package/api/hub-spot-api.ts +165 -0
  8. package/api/priorities-api.ts +284 -0
  9. package/api/statuses-api.ts +651 -0
  10. package/api/tasks-api.ts +651 -0
  11. package/api.ts +37 -0
  12. package/base.ts +331 -0
  13. package/common.ts +198 -0
  14. package/configuration.ts +110 -0
  15. package/dist/api/categories-api.d.ts +366 -0
  16. package/dist/api/categories-api.js +626 -0
  17. package/dist/api/default-api.d.ts +70 -0
  18. package/dist/api/default-api.js +200 -0
  19. package/dist/api/hub-spot-api.d.ts +97 -0
  20. package/dist/api/hub-spot-api.js +224 -0
  21. package/dist/api/priorities-api.d.ts +162 -0
  22. package/dist/api/priorities-api.js +324 -0
  23. package/dist/api/statuses-api.d.ts +366 -0
  24. package/dist/api/statuses-api.js +626 -0
  25. package/dist/api/tasks-api.d.ts +366 -0
  26. package/dist/api/tasks-api.js +626 -0
  27. package/dist/api.d.ts +17 -0
  28. package/dist/api.js +35 -0
  29. package/dist/base.d.ts +86 -0
  30. package/dist/base.js +367 -0
  31. package/dist/common.d.ts +91 -0
  32. package/dist/common.js +276 -0
  33. package/dist/configuration.d.ts +89 -0
  34. package/dist/configuration.js +52 -0
  35. package/dist/index.d.ts +15 -0
  36. package/dist/index.js +36 -0
  37. package/dist/models/category-class.d.ts +60 -0
  38. package/dist/models/category-class.js +15 -0
  39. package/dist/models/create-category-request-dto.d.ts +24 -0
  40. package/dist/models/create-category-request-dto.js +15 -0
  41. package/dist/models/create-category-response-class.d.ts +25 -0
  42. package/dist/models/create-category-response-class.js +15 -0
  43. package/dist/models/create-hub-spot-ticket-request-dto.d.ts +31 -0
  44. package/dist/models/create-hub-spot-ticket-request-dto.js +15 -0
  45. package/dist/models/create-hub-spot-ticket-response-class.d.ts +25 -0
  46. package/dist/models/create-hub-spot-ticket-response-class.js +15 -0
  47. package/dist/models/create-priority-request-dto.d.ts +24 -0
  48. package/dist/models/create-priority-request-dto.js +15 -0
  49. package/dist/models/create-priority-response-class.d.ts +25 -0
  50. package/dist/models/create-priority-response-class.js +15 -0
  51. package/dist/models/create-status-request-dto.d.ts +24 -0
  52. package/dist/models/create-status-request-dto.js +15 -0
  53. package/dist/models/create-status-response-class.d.ts +25 -0
  54. package/dist/models/create-status-response-class.js +15 -0
  55. package/dist/models/create-task-request-dto.d.ts +54 -0
  56. package/dist/models/create-task-request-dto.js +15 -0
  57. package/dist/models/create-task-response-class.d.ts +25 -0
  58. package/dist/models/create-task-response-class.js +15 -0
  59. package/dist/models/get-category-response-class.d.ts +25 -0
  60. package/dist/models/get-category-response-class.js +15 -0
  61. package/dist/models/get-priority-response-class.d.ts +25 -0
  62. package/dist/models/get-priority-response-class.js +15 -0
  63. package/dist/models/get-status-response-class.d.ts +25 -0
  64. package/dist/models/get-status-response-class.js +15 -0
  65. package/dist/models/get-task-response-class.d.ts +25 -0
  66. package/dist/models/get-task-response-class.js +15 -0
  67. package/dist/models/hub-spot-ticket-class.d.ts +49 -0
  68. package/dist/models/hub-spot-ticket-class.js +15 -0
  69. package/dist/models/hub-spot-ticket-error-class.d.ts +30 -0
  70. package/dist/models/hub-spot-ticket-error-class.js +15 -0
  71. package/dist/models/hub-spot-ticket-name-value-dto.d.ts +30 -0
  72. package/dist/models/hub-spot-ticket-name-value-dto.js +15 -0
  73. package/dist/models/index.d.ts +32 -0
  74. package/dist/models/index.js +48 -0
  75. package/dist/models/inline-response200.d.ts +54 -0
  76. package/dist/models/inline-response200.js +15 -0
  77. package/dist/models/inline-response503.d.ts +54 -0
  78. package/dist/models/inline-response503.js +15 -0
  79. package/dist/models/list-categories-response-class.d.ts +43 -0
  80. package/dist/models/list-categories-response-class.js +15 -0
  81. package/dist/models/list-statuses-response-class.d.ts +43 -0
  82. package/dist/models/list-statuses-response-class.js +15 -0
  83. package/dist/models/list-tasks-response-class.d.ts +43 -0
  84. package/dist/models/list-tasks-response-class.js +15 -0
  85. package/dist/models/priority-class.d.ts +60 -0
  86. package/dist/models/priority-class.js +15 -0
  87. package/dist/models/status-class.d.ts +60 -0
  88. package/dist/models/status-class.js +15 -0
  89. package/dist/models/task-class.d.ts +99 -0
  90. package/dist/models/task-class.js +15 -0
  91. package/dist/models/update-category-request-dto.d.ts +30 -0
  92. package/dist/models/update-category-request-dto.js +15 -0
  93. package/dist/models/update-category-response-class.d.ts +25 -0
  94. package/dist/models/update-category-response-class.js +15 -0
  95. package/dist/models/update-status-request-dto.d.ts +30 -0
  96. package/dist/models/update-status-request-dto.js +15 -0
  97. package/dist/models/update-status-response-class.d.ts +25 -0
  98. package/dist/models/update-status-response-class.js +15 -0
  99. package/dist/models/update-task-request-dto.d.ts +60 -0
  100. package/dist/models/update-task-request-dto.js +15 -0
  101. package/dist/models/update-task-response-class.d.ts +25 -0
  102. package/dist/models/update-task-response-class.js +15 -0
  103. package/git_push.sh +57 -0
  104. package/index.ts +19 -0
  105. package/models/category-class.ts +66 -0
  106. package/models/create-category-request-dto.ts +30 -0
  107. package/models/create-category-response-class.ts +31 -0
  108. package/models/create-hub-spot-ticket-request-dto.ts +37 -0
  109. package/models/create-hub-spot-ticket-response-class.ts +31 -0
  110. package/models/create-priority-request-dto.ts +30 -0
  111. package/models/create-priority-response-class.ts +31 -0
  112. package/models/create-status-request-dto.ts +30 -0
  113. package/models/create-status-response-class.ts +31 -0
  114. package/models/create-task-request-dto.ts +60 -0
  115. package/models/create-task-response-class.ts +31 -0
  116. package/models/get-category-response-class.ts +31 -0
  117. package/models/get-priority-response-class.ts +31 -0
  118. package/models/get-status-response-class.ts +31 -0
  119. package/models/get-task-response-class.ts +31 -0
  120. package/models/hub-spot-ticket-class.ts +55 -0
  121. package/models/hub-spot-ticket-error-class.ts +36 -0
  122. package/models/hub-spot-ticket-name-value-dto.ts +36 -0
  123. package/models/index.ts +32 -0
  124. package/models/inline-response200.ts +48 -0
  125. package/models/inline-response503.ts +48 -0
  126. package/models/list-categories-response-class.ts +49 -0
  127. package/models/list-statuses-response-class.ts +49 -0
  128. package/models/list-tasks-response-class.ts +49 -0
  129. package/models/priority-class.ts +66 -0
  130. package/models/status-class.ts +66 -0
  131. package/models/task-class.ts +105 -0
  132. package/models/update-category-request-dto.ts +36 -0
  133. package/models/update-category-response-class.ts +31 -0
  134. package/models/update-status-request-dto.ts +36 -0
  135. package/models/update-status-response-class.ts +31 -0
  136. package/models/update-task-request-dto.ts +66 -0
  137. package/models/update-task-response-class.ts +31 -0
  138. package/package.json +26 -0
  139. package/tsconfig.json +23 -0
package/dist/api.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL TaskService
6
+ * The EMIL Task API description
7
+ *
8
+ * The version of the OpenAPI document: 1.0
9
+ * Contact: kontakt@emil.de
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ __exportStar(require("./api/categories-api"), exports);
31
+ __exportStar(require("./api/default-api"), exports);
32
+ __exportStar(require("./api/hub-spot-api"), exports);
33
+ __exportStar(require("./api/priorities-api"), exports);
34
+ __exportStar(require("./api/statuses-api"), exports);
35
+ __exportStar(require("./api/tasks-api"), exports);
package/dist/base.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * EMIL TaskService
3
+ * The EMIL Task API description
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ * Contact: kontakt@emil.de
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { Configuration } from "./configuration";
13
+ import { AxiosInstance, AxiosRequestConfig } from 'axios';
14
+ export declare const BASE_PATH: string;
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const COLLECTION_FORMATS: {
20
+ csv: string;
21
+ ssv: string;
22
+ tsv: string;
23
+ pipes: string;
24
+ };
25
+ export interface LoginClass {
26
+ accessToken: string;
27
+ permissions: string;
28
+ }
29
+ export interface SwitchWorkspaceRequest {
30
+ username: string;
31
+ targetWorkspace: string;
32
+ }
33
+ export interface SwitchWorkspaceResponseClass {
34
+ accessToken: string;
35
+ permissions: string;
36
+ }
37
+ export declare enum Environment {
38
+ Production = "https://apiv2.emil.de",
39
+ Test = "https://apiv2-test.emil.de",
40
+ Staging = "https://apiv2-staging.emil.de",
41
+ Development = "https://apiv2-dev.emil.de",
42
+ ProductionZurich = "https://eu-central-2.apiv2.emil.de"
43
+ }
44
+ export declare function resetRetry(): void;
45
+ /**
46
+ *
47
+ * @export
48
+ * @interface RequestArgs
49
+ */
50
+ export interface RequestArgs {
51
+ url: string;
52
+ options: AxiosRequestConfig;
53
+ }
54
+ /**
55
+ *
56
+ * @export
57
+ * @class BaseAPI
58
+ */
59
+ export declare class BaseAPI {
60
+ protected basePath: string;
61
+ protected axios: AxiosInstance;
62
+ protected configuration: Configuration | undefined;
63
+ private tokenData?;
64
+ constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
65
+ selectEnvironment(env: Environment): void;
66
+ selectBasePath(path: string): void;
67
+ getPermissions(): Array<string>;
68
+ authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
69
+ switchWorkspace(targetWorkspace: string): Promise<void>;
70
+ refreshTokenInternal(): Promise<LoginClass>;
71
+ private storeTokenData;
72
+ loadTokenData(): void;
73
+ cleanTokenData(): void;
74
+ private attachInterceptor;
75
+ }
76
+ /**
77
+ *
78
+ * @export
79
+ * @class RequiredError
80
+ * @extends {Error}
81
+ */
82
+ export declare class RequiredError extends Error {
83
+ field: string;
84
+ name: "RequiredError";
85
+ constructor(field: string, msg?: string);
86
+ }
package/dist/base.js ADDED
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL TaskService
6
+ * The EMIL Task API description
7
+ *
8
+ * The version of the OpenAPI document: 1.0
9
+ * Contact: kontakt@emil.de
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __extends = (this && this.__extends) || (function () {
16
+ var extendStatics = function (d, b) {
17
+ extendStatics = Object.setPrototypeOf ||
18
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
20
+ return extendStatics(d, b);
21
+ };
22
+ return function (d, b) {
23
+ if (typeof b !== "function" && b !== null)
24
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
+ extendStatics(d, b);
26
+ function __() { this.constructor = d; }
27
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28
+ };
29
+ })();
30
+ var __assign = (this && this.__assign) || function () {
31
+ __assign = Object.assign || function(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
35
+ t[p] = s[p];
36
+ }
37
+ return t;
38
+ };
39
+ return __assign.apply(this, arguments);
40
+ };
41
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
+ return new (P || (P = Promise))(function (resolve, reject) {
44
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+ var __generator = (this && this.__generator) || function (thisArg, body) {
51
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
52
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
53
+ function verb(n) { return function (v) { return step([n, v]); }; }
54
+ function step(op) {
55
+ if (f) throw new TypeError("Generator is already executing.");
56
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
57
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
+ if (y = 0, t) op = [op[0] & 2, t.value];
59
+ switch (op[0]) {
60
+ case 0: case 1: t = op; break;
61
+ case 4: _.label++; return { value: op[1], done: false };
62
+ case 5: _.label++; y = op[1]; op = [0]; continue;
63
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
64
+ default:
65
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
66
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
67
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
68
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
69
+ if (t[2]) _.ops.pop();
70
+ _.trys.pop(); continue;
71
+ }
72
+ op = body.call(thisArg, _);
73
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
74
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
75
+ }
76
+ };
77
+ var __importDefault = (this && this.__importDefault) || function (mod) {
78
+ return (mod && mod.__esModule) ? mod : { "default": mod };
79
+ };
80
+ Object.defineProperty(exports, "__esModule", { value: true });
81
+ exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
82
+ var configuration_1 = require("./configuration");
83
+ var common_1 = require("./common");
84
+ // Some imports not used depending on template conditions
85
+ // @ts-ignore
86
+ var axios_1 = __importDefault(require("axios"));
87
+ exports.BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
88
+ /**
89
+ *
90
+ * @export
91
+ */
92
+ exports.COLLECTION_FORMATS = {
93
+ csv: ",",
94
+ ssv: " ",
95
+ tsv: "\t",
96
+ pipes: "|",
97
+ };
98
+ var Environment;
99
+ (function (Environment) {
100
+ Environment["Production"] = "https://apiv2.emil.de";
101
+ Environment["Test"] = "https://apiv2-test.emil.de";
102
+ Environment["Staging"] = "https://apiv2-staging.emil.de";
103
+ Environment["Development"] = "https://apiv2-dev.emil.de";
104
+ Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
105
+ })(Environment = exports.Environment || (exports.Environment = {}));
106
+ var _retry_count = 0;
107
+ var _retry = null;
108
+ function resetRetry() {
109
+ _retry_count = 0;
110
+ }
111
+ exports.resetRetry = resetRetry;
112
+ var NETWORK_ERROR_MESSAGE = "Network Error";
113
+ var TOKEN_DATA = 'APP_TOKEN';
114
+ /**
115
+ *
116
+ * @export
117
+ * @class BaseAPI
118
+ */
119
+ var BaseAPI = /** @class */ (function () {
120
+ function BaseAPI(configuration, basePath, axios) {
121
+ if (basePath === void 0) { basePath = exports.BASE_PATH; }
122
+ if (axios === void 0) { axios = axios_1.default; }
123
+ this.basePath = basePath;
124
+ this.axios = axios;
125
+ this.loadTokenData();
126
+ if (configuration) {
127
+ var accessToken = this.tokenData.accessToken;
128
+ this.configuration = configuration;
129
+ this.basePath = configuration.basePath || this.basePath;
130
+ // Use config token if provided, otherwise use tokenData token
131
+ var configToken = this.configuration.accessToken;
132
+ var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
133
+ this.configuration.accessToken = configToken || storedToken;
134
+ }
135
+ else {
136
+ var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
137
+ this.configuration = new configuration_1.Configuration({
138
+ basePath: this.basePath,
139
+ accessToken: accessToken ? "Bearer ".concat(accessToken) : '',
140
+ username: username,
141
+ });
142
+ }
143
+ this.attachInterceptor(axios);
144
+ }
145
+ BaseAPI.prototype.selectEnvironment = function (env) {
146
+ this.selectBasePath(env);
147
+ };
148
+ BaseAPI.prototype.selectBasePath = function (path) {
149
+ this.configuration.basePath = path;
150
+ };
151
+ BaseAPI.prototype.getPermissions = function () {
152
+ var _a;
153
+ if (!((_a = this.tokenData) === null || _a === void 0 ? void 0 : _a.permissions)) {
154
+ return [];
155
+ }
156
+ return this.tokenData.permissions.split(',');
157
+ };
158
+ BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
159
+ return __awaiter(this, void 0, void 0, function () {
160
+ var options, response, _a, accessToken, permissions;
161
+ return __generator(this, function (_b) {
162
+ switch (_b.label) {
163
+ case 0:
164
+ options = {
165
+ method: 'POST',
166
+ url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
167
+ headers: { 'Content-Type': 'application/json' },
168
+ data: {
169
+ username: username,
170
+ password: password,
171
+ },
172
+ withCredentials: true,
173
+ };
174
+ return [4 /*yield*/, axios_1.default.request(options)];
175
+ case 1:
176
+ response = _b.sent();
177
+ _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
178
+ this.configuration.username = username;
179
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
180
+ this.tokenData.username = username;
181
+ this.tokenData.accessToken = accessToken;
182
+ this.tokenData.permissions = permissions;
183
+ if (!targetWorkspace) return [3 /*break*/, 3];
184
+ return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
185
+ case 2:
186
+ _b.sent();
187
+ return [3 /*break*/, 4];
188
+ case 3:
189
+ // Only store if no workspace switch (since switchWorkspace will store after switching)
190
+ this.storeTokenData(__assign({}, this.tokenData));
191
+ _b.label = 4;
192
+ case 4:
193
+ this.storeTokenData(__assign({}, this.tokenData));
194
+ return [2 /*return*/];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var options, response, _a, accessToken, permissions;
202
+ return __generator(this, function (_b) {
203
+ switch (_b.label) {
204
+ case 0:
205
+ options = {
206
+ method: 'POST',
207
+ url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
208
+ headers: {
209
+ 'Content-Type': 'application/json',
210
+ 'Authorization': "Bearer ".concat(this.configuration.accessToken),
211
+ },
212
+ data: {
213
+ username: this.configuration.username,
214
+ targetWorkspace: targetWorkspace,
215
+ },
216
+ withCredentials: true,
217
+ };
218
+ return [4 /*yield*/, axios_1.default.request(options)];
219
+ case 1:
220
+ response = _b.sent();
221
+ _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
222
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
223
+ this.tokenData.accessToken = accessToken;
224
+ this.tokenData.permissions = permissions;
225
+ this.storeTokenData(__assign({}, this.tokenData));
226
+ return [2 /*return*/];
227
+ }
228
+ });
229
+ });
230
+ };
231
+ BaseAPI.prototype.refreshTokenInternal = function () {
232
+ return __awaiter(this, void 0, void 0, function () {
233
+ var username, refreshTokenAxios, options, response;
234
+ var _this = this;
235
+ return __generator(this, function (_a) {
236
+ switch (_a.label) {
237
+ case 0:
238
+ username = this.configuration.username;
239
+ if (!username) {
240
+ throw new Error('Failed to refresh token.');
241
+ }
242
+ refreshTokenAxios = axios_1.default.create();
243
+ refreshTokenAxios.interceptors.response.use(function (response) {
244
+ var permissions = response.data.permissions;
245
+ _this.tokenData.permissions = permissions;
246
+ _this.storeTokenData(_this.tokenData);
247
+ return response;
248
+ });
249
+ options = {
250
+ method: 'POST',
251
+ url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
252
+ headers: {
253
+ 'Content-Type': 'application/json',
254
+ },
255
+ data: { username: username },
256
+ withCredentials: true,
257
+ };
258
+ return [4 /*yield*/, refreshTokenAxios.request(options)];
259
+ case 1:
260
+ response = _a.sent();
261
+ return [2 /*return*/, response.data];
262
+ }
263
+ });
264
+ });
265
+ };
266
+ BaseAPI.prototype.storeTokenData = function (tokenData) {
267
+ if (typeof window !== 'undefined') {
268
+ (0, common_1.defaultStorage)().set(TOKEN_DATA, tokenData);
269
+ }
270
+ };
271
+ BaseAPI.prototype.loadTokenData = function () {
272
+ if (typeof window !== 'undefined') {
273
+ this.tokenData = (0, common_1.defaultStorage)().get(TOKEN_DATA) || {};
274
+ }
275
+ else {
276
+ this.tokenData = {};
277
+ }
278
+ };
279
+ BaseAPI.prototype.cleanTokenData = function () {
280
+ this.storeTokenData(null);
281
+ };
282
+ BaseAPI.prototype.attachInterceptor = function (axios) {
283
+ var _this = this;
284
+ axios.interceptors.response.use(function (res) {
285
+ return res;
286
+ }, function (err) { return __awaiter(_this, void 0, void 0, function () {
287
+ var originalConfig, _a, tokenString, permissions, accessToken, _error_1, _b, tokenString, permissions, accessToken, _error_2;
288
+ return __generator(this, function (_c) {
289
+ switch (_c.label) {
290
+ case 0:
291
+ originalConfig = err.config;
292
+ if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
293
+ if (!((err.response.status === 401 || err.response.status === 403)
294
+ && !originalConfig._retry)) return [3 /*break*/, 4];
295
+ originalConfig._retry = true;
296
+ _c.label = 1;
297
+ case 1:
298
+ _c.trys.push([1, 3, , 4]);
299
+ return [4 /*yield*/, this.refreshTokenInternal()];
300
+ case 2:
301
+ _a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
302
+ accessToken = "Bearer ".concat(tokenString);
303
+ this.tokenData.permissions = permissions;
304
+ delete originalConfig.headers['Authorization'];
305
+ originalConfig.headers['Authorization'] = accessToken;
306
+ this.configuration.accessToken = accessToken;
307
+ this.tokenData.accessToken = tokenString;
308
+ this.storeTokenData(this.tokenData);
309
+ return [2 /*return*/, axios(originalConfig)];
310
+ case 3:
311
+ _error_1 = _c.sent();
312
+ if (_error_1.response && _error_1.response.data) {
313
+ return [2 /*return*/, Promise.reject(_error_1.response.data)];
314
+ }
315
+ return [2 /*return*/, Promise.reject(_error_1)];
316
+ case 4: return [3 /*break*/, 9];
317
+ case 5:
318
+ if (!(err.message === NETWORK_ERROR_MESSAGE
319
+ && originalConfig.headers.hasOwnProperty('Authorization')
320
+ && _retry_count < 4)) return [3 /*break*/, 9];
321
+ _retry_count++;
322
+ _c.label = 6;
323
+ case 6:
324
+ _c.trys.push([6, 8, , 9]);
325
+ return [4 /*yield*/, this.refreshTokenInternal()];
326
+ case 7:
327
+ _b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
328
+ accessToken = "Bearer ".concat(tokenString);
329
+ this.tokenData.permissions = permissions;
330
+ _retry = true;
331
+ originalConfig.headers['Authorization'] = accessToken;
332
+ this.configuration.accessToken = accessToken;
333
+ this.tokenData.accessToken = tokenString;
334
+ this.storeTokenData(this.tokenData);
335
+ return [2 /*return*/, axios.request(__assign({}, originalConfig))];
336
+ case 8:
337
+ _error_2 = _c.sent();
338
+ if (_error_2.response && _error_2.response.data) {
339
+ return [2 /*return*/, Promise.reject(_error_2.response.data)];
340
+ }
341
+ return [2 /*return*/, Promise.reject(_error_2)];
342
+ case 9: return [2 /*return*/, Promise.reject(err)];
343
+ }
344
+ });
345
+ }); });
346
+ };
347
+ return BaseAPI;
348
+ }());
349
+ exports.BaseAPI = BaseAPI;
350
+ ;
351
+ /**
352
+ *
353
+ * @export
354
+ * @class RequiredError
355
+ * @extends {Error}
356
+ */
357
+ var RequiredError = /** @class */ (function (_super) {
358
+ __extends(RequiredError, _super);
359
+ function RequiredError(field, msg) {
360
+ var _this = _super.call(this, msg) || this;
361
+ _this.field = field;
362
+ _this.name = "RequiredError";
363
+ return _this;
364
+ }
365
+ return RequiredError;
366
+ }(Error));
367
+ exports.RequiredError = RequiredError;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * EMIL TaskService
3
+ * The EMIL Task API description
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ * Contact: kontakt@emil.de
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { Configuration } from "./configuration";
13
+ import { RequestArgs } from "./base";
14
+ import { AxiosInstance, AxiosResponse } from 'axios';
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const DUMMY_BASE_URL = "https://example.com";
20
+ /**
21
+ *
22
+ * @throws {RequiredError}
23
+ * @export
24
+ */
25
+ export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
26
+ /**
27
+ *
28
+ * @export
29
+ */
30
+ export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
31
+ /**
32
+ *
33
+ * @export
34
+ */
35
+ export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
36
+ /**
37
+ *
38
+ * @export
39
+ */
40
+ export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
41
+ /**
42
+ *
43
+ * @export
44
+ */
45
+ export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
46
+ /**
47
+ *
48
+ * @export
49
+ */
50
+ export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
51
+ /**
52
+ *
53
+ * @export
54
+ */
55
+ export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
56
+ /**
57
+ *
58
+ * @export
59
+ */
60
+ export declare const toPathString: (url: URL) => string;
61
+ /**
62
+ *
63
+ * @export
64
+ */
65
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any, {}>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
66
+ /**
67
+ * EMIL TaskService
68
+ * The EMIL Task API description
69
+ *
70
+ * The version of the OpenAPI document: 1.0
71
+ * Contact: kontakt@emil.de
72
+ *
73
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
74
+ * https://openapi-generator.tech
75
+ * Do not edit the class manually.
76
+ */
77
+ export interface IStorageConverter<D, SD> {
78
+ toStorageData(data: D): SD;
79
+ fromStorageData(storageData: SD): D;
80
+ }
81
+ export interface IStorage {
82
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
83
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
84
+ }
85
+ export declare class LocalStorage implements IStorage {
86
+ readonly storage: Storage;
87
+ constructor();
88
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
89
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
90
+ }
91
+ export declare const defaultStorage: () => IStorage;