@emilgroup/partner-portal-sdk 1.1.0 → 1.1.1-beta.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/README.md CHANGED
@@ -17,11 +17,11 @@ Although this package can be used in both TypeScript and JavaScript, it is inten
17
17
  Navigate to the folder of your consuming project and run one of the following commands:
18
18
 
19
19
  ```
20
- npm install @emilgroup/partner-portal-sdk@1.1.0 --save
20
+ npm install @emilgroup/partner-portal-sdk@1.1.1-beta.0 --save
21
21
  ```
22
22
  or
23
23
  ```
24
- yarn add @emilgroup/partner-portal-sdk@1.1.0
24
+ yarn add @emilgroup/partner-portal-sdk@1.1.1-beta.0
25
25
  ```
26
26
 
27
27
  And then you can import `IntermediaryApi`.
package/base.ts CHANGED
@@ -37,6 +37,16 @@ export interface LoginClass {
37
37
  permissions: string;
38
38
  }
39
39
 
40
+ export interface SwitchWorkspaceRequest {
41
+ username: string;
42
+ targetWorkspace: string;
43
+ }
44
+
45
+ export interface SwitchWorkspaceResponseClass {
46
+ accessToken: string;
47
+ permissions: string;
48
+ }
49
+
40
50
  export enum Environment {
41
51
  Production = 'https://apiv2.emil.de',
42
52
  Test = 'https://apiv2-test.emil.de',
@@ -87,9 +97,14 @@ export class BaseAPI {
87
97
  this.loadTokenData();
88
98
 
89
99
  if (configuration) {
100
+ const { accessToken } = this.tokenData;
90
101
  this.configuration = configuration;
91
102
  this.basePath = configuration.basePath || this.basePath;
92
- this.configuration.accessToken = this.tokenData.accessToken ? `Bearer ${this.tokenData.accessToken}` : '';
103
+
104
+ // Use config token if provided, otherwise use tokenData token
105
+ const configToken = this.configuration.accessToken;
106
+ const storedToken = accessToken ? `Bearer ${accessToken}` : '';
107
+ this.configuration.accessToken = configToken || storedToken;
93
108
  } else {
94
109
  const { accessToken, username } = this.tokenData;
95
110
 
@@ -119,7 +134,7 @@ export class BaseAPI {
119
134
  return this.tokenData.permissions.split(',');
120
135
  }
121
136
 
122
- async authorize(username: string, password: string): Promise<void> {
137
+ async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
123
138
  const options: AxiosRequestConfig = {
124
139
  method: 'POST',
125
140
  url: `${this.configuration.basePath}/authservice/v1/login`,
@@ -141,6 +156,40 @@ export class BaseAPI {
141
156
  this.tokenData.accessToken = accessToken;
142
157
  this.tokenData.permissions = permissions;
143
158
 
159
+ // Switch workspace if provided
160
+ if (targetWorkspace) {
161
+ await this.switchWorkspace(targetWorkspace);
162
+ } else {
163
+ // Only store if no workspace switch (since switchWorkspace will store after switching)
164
+ this.storeTokenData({
165
+ ...this.tokenData
166
+ });
167
+ }
168
+ }
169
+
170
+ async switchWorkspace(targetWorkspace: string): Promise<void> {
171
+ const options: AxiosRequestConfig = {
172
+ method: 'POST',
173
+ url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
174
+ headers: {
175
+ 'Content-Type': 'application/json',
176
+ 'Authorization': `Bearer ${this.configuration.accessToken}`,
177
+ },
178
+ data: {
179
+ username: this.configuration.username,
180
+ targetWorkspace,
181
+ } as SwitchWorkspaceRequest,
182
+ withCredentials: true,
183
+ };
184
+
185
+ const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
186
+
187
+ const { data: { accessToken, permissions } } = response;
188
+
189
+ this.configuration.accessToken = `Bearer ${accessToken}`;
190
+ this.tokenData.accessToken = accessToken;
191
+ this.tokenData.permissions = permissions;
192
+
144
193
  this.storeTokenData({
145
194
  ...this.tokenData
146
195
  });
@@ -270,7 +319,7 @@ export class BaseAPI {
270
319
  * @extends {Error}
271
320
  */
272
321
  export class RequiredError extends Error {
273
- name: "RequiredError" = "RequiredError";
322
+ override name: "RequiredError" = "RequiredError";
274
323
  constructor(public field: string, msg?: string) {
275
324
  super(msg);
276
325
  }
package/dist/base.d.ts CHANGED
@@ -26,6 +26,14 @@ export interface LoginClass {
26
26
  accessToken: string;
27
27
  permissions: string;
28
28
  }
29
+ export interface SwitchWorkspaceRequest {
30
+ username: string;
31
+ targetWorkspace: string;
32
+ }
33
+ export interface SwitchWorkspaceResponseClass {
34
+ accessToken: string;
35
+ permissions: string;
36
+ }
29
37
  export declare enum Environment {
30
38
  Production = "https://apiv2.emil.de",
31
39
  Test = "https://apiv2-test.emil.de",
@@ -57,7 +65,8 @@ export declare class BaseAPI {
57
65
  selectEnvironment(env: Environment): void;
58
66
  selectBasePath(path: string): void;
59
67
  getPermissions(): Array<string>;
60
- authorize(username: string, password: string): Promise<void>;
68
+ authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
69
+ switchWorkspace(targetWorkspace: string): Promise<void>;
61
70
  refreshTokenInternal(): Promise<LoginClass>;
62
71
  private storeTokenData;
63
72
  loadTokenData(): void;
package/dist/base.js CHANGED
@@ -124,9 +124,13 @@ var BaseAPI = /** @class */ (function () {
124
124
  this.axios = axios;
125
125
  this.loadTokenData();
126
126
  if (configuration) {
127
+ var accessToken = this.tokenData.accessToken;
127
128
  this.configuration = configuration;
128
129
  this.basePath = configuration.basePath || this.basePath;
129
- this.configuration.accessToken = this.tokenData.accessToken ? "Bearer ".concat(this.tokenData.accessToken) : '';
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;
130
134
  }
131
135
  else {
132
136
  var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
@@ -151,7 +155,7 @@ var BaseAPI = /** @class */ (function () {
151
155
  }
152
156
  return this.tokenData.permissions.split(',');
153
157
  };
154
- BaseAPI.prototype.authorize = function (username, password) {
158
+ BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
155
159
  return __awaiter(this, void 0, void 0, function () {
156
160
  var options, response, _a, accessToken, permissions;
157
161
  return __generator(this, function (_b) {
@@ -176,6 +180,46 @@ var BaseAPI = /** @class */ (function () {
176
180
  this.tokenData.username = username;
177
181
  this.tokenData.accessToken = accessToken;
178
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: return [2 /*return*/];
193
+ }
194
+ });
195
+ });
196
+ };
197
+ BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
198
+ return __awaiter(this, void 0, void 0, function () {
199
+ var options, response, _a, accessToken, permissions;
200
+ return __generator(this, function (_b) {
201
+ switch (_b.label) {
202
+ case 0:
203
+ options = {
204
+ method: 'POST',
205
+ url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
206
+ headers: {
207
+ 'Content-Type': 'application/json',
208
+ 'Authorization': "Bearer ".concat(this.configuration.accessToken),
209
+ },
210
+ data: {
211
+ username: this.configuration.username,
212
+ targetWorkspace: targetWorkspace,
213
+ },
214
+ withCredentials: true,
215
+ };
216
+ return [4 /*yield*/, axios_1.default.request(options)];
217
+ case 1:
218
+ response = _b.sent();
219
+ _a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
220
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
221
+ this.tokenData.accessToken = accessToken;
222
+ this.tokenData.permissions = permissions;
179
223
  this.storeTokenData(__assign({}, this.tokenData));
180
224
  return [2 /*return*/];
181
225
  }
@@ -146,5 +146,7 @@ export type InvoiceClassTypeEnum = typeof InvoiceClassTypeEnum[keyof typeof Invo
146
146
  export declare const InvoiceClassStatusEnum: {
147
147
  readonly Open: "open";
148
148
  readonly Paid: "paid";
149
+ readonly PartiallyPaid: "partially-paid";
150
+ readonly Refunded: "refunded";
149
151
  };
150
152
  export type InvoiceClassStatusEnum = typeof InvoiceClassStatusEnum[keyof typeof InvoiceClassStatusEnum];
@@ -26,5 +26,7 @@ exports.InvoiceClassTypeEnum = {
26
26
  };
27
27
  exports.InvoiceClassStatusEnum = {
28
28
  Open: 'open',
29
- Paid: 'paid'
29
+ Paid: 'paid',
30
+ PartiallyPaid: 'partially-paid',
31
+ Refunded: 'refunded'
30
32
  };
@@ -43,5 +43,7 @@ export interface InvoiceStatusClass {
43
43
  export declare const InvoiceStatusClassStatusEnum: {
44
44
  readonly Open: "open";
45
45
  readonly Paid: "paid";
46
+ readonly PartiallyPaid: "partially-paid";
47
+ readonly Refunded: "refunded";
46
48
  };
47
49
  export type InvoiceStatusClassStatusEnum = typeof InvoiceStatusClassStatusEnum[keyof typeof InvoiceStatusClassStatusEnum];
@@ -16,5 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.InvoiceStatusClassStatusEnum = void 0;
17
17
  exports.InvoiceStatusClassStatusEnum = {
18
18
  Open: 'open',
19
- Paid: 'paid'
19
+ Paid: 'paid',
20
+ PartiallyPaid: 'partially-paid',
21
+ Refunded: 'refunded'
20
22
  };
@@ -152,7 +152,9 @@ export const InvoiceClassTypeEnum = {
152
152
  export type InvoiceClassTypeEnum = typeof InvoiceClassTypeEnum[keyof typeof InvoiceClassTypeEnum];
153
153
  export const InvoiceClassStatusEnum = {
154
154
  Open: 'open',
155
- Paid: 'paid'
155
+ Paid: 'paid',
156
+ PartiallyPaid: 'partially-paid',
157
+ Refunded: 'refunded'
156
158
  } as const;
157
159
 
158
160
  export type InvoiceClassStatusEnum = typeof InvoiceClassStatusEnum[keyof typeof InvoiceClassStatusEnum];
@@ -48,7 +48,9 @@ export interface InvoiceStatusClass {
48
48
 
49
49
  export const InvoiceStatusClassStatusEnum = {
50
50
  Open: 'open',
51
- Paid: 'paid'
51
+ Paid: 'paid',
52
+ PartiallyPaid: 'partially-paid',
53
+ Refunded: 'refunded'
52
54
  } as const;
53
55
 
54
56
  export type InvoiceStatusClassStatusEnum = typeof InvoiceStatusClassStatusEnum[keyof typeof InvoiceStatusClassStatusEnum];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/partner-portal-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.1-beta.0",
4
4
  "description": "OpenAPI client for @emilgroup/partner-portal-sdk",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [
package/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "module": "CommonJS",
6
6
  "noImplicitAny": true,
7
7
  "esModuleInterop": true,
8
+ "noImplicitOverride": true,
8
9
  "outDir": "dist",
9
10
  "rootDir": ".",
10
11
  "lib": [