@dev-crew-berlin/enter-js-utils 0.40.3 → 0.40.4
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/api-client/api-base.d.ts +9 -1
- package/dist/api-client/api-base.js +52 -1
- package/dist/generated/api-schema.d.ts +78 -47
- package/dist/models/access-token.d.ts +2 -0
- package/dist/models/access-token.js +1 -0
- package/dist/models/field-value.d.ts +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/permission.d.ts +1 -1
- package/dist/ui/icons/add-guest-icon.js +1 -1
- package/dist/ui/icons/caret-icon.js +1 -1
- package/dist/ui/icons/filter-icon.js +1 -1
- package/dist/ui/icons/search-icon.js +1 -1
- package/dist/ui/icons/settings-icon.js +1 -1
- package/dist/ui/icons/sort-list-icon.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { APIResult } from '../lib';
|
|
2
|
+
import { AccessToken } from '../models/access-token';
|
|
2
3
|
import { paths } from '../generated/api-schema';
|
|
3
4
|
export interface APICredentials {
|
|
4
|
-
accessToken:
|
|
5
|
+
accessToken: AccessToken;
|
|
5
6
|
url: string;
|
|
6
7
|
}
|
|
7
8
|
declare type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
@@ -26,12 +27,19 @@ export default class APIBase {
|
|
|
26
27
|
onLogout: (reason?: string) => void;
|
|
27
28
|
});
|
|
28
29
|
private static fetchResult;
|
|
30
|
+
static fetchAccessToken(args: {
|
|
31
|
+
url: string;
|
|
32
|
+
user: string;
|
|
33
|
+
password: string;
|
|
34
|
+
deviceName: string;
|
|
35
|
+
}): Promise<APIResult<AccessToken>>;
|
|
29
36
|
private fetchFromEnter;
|
|
30
37
|
protected get<Path extends keyof paths>(endpoint: Path): Promise<APIResult<ResponseType<Path, 'get'>>>;
|
|
31
38
|
protected post<Path extends keyof paths>(endpoint: Path, data: RequestBody<Path, 'post'>): Promise<APIResult<ResponseType<Path, 'post'>>>;
|
|
32
39
|
protected put<Path extends keyof paths>(endpoint: Path, data: RequestBody<Path, 'put'>): Promise<APIResult<ResponseType<Path, 'put'>>>;
|
|
33
40
|
protected patch<Path extends keyof paths>(endpoint: Path, data: RequestBody<Path, 'patch'>): Promise<APIResult<ResponseType<Path, 'patch'>>>;
|
|
34
41
|
protected delete<Path extends keyof paths>(endpoint: Path): Promise<APIResult<ResponseType<Path, 'delete'>>>;
|
|
42
|
+
refreshToken(): Promise<APIResult<AccessToken>>;
|
|
35
43
|
logout(): Promise<void>;
|
|
36
44
|
}
|
|
37
45
|
export {};
|
|
@@ -13,10 +13,52 @@ export default class APIBase {
|
|
|
13
13
|
return failure(e);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
static async fetchAccessToken(args) {
|
|
17
|
+
const body = {
|
|
18
|
+
username: args.user,
|
|
19
|
+
password: args.password,
|
|
20
|
+
scope: '',
|
|
21
|
+
client_id: args.deviceName
|
|
22
|
+
};
|
|
23
|
+
const res = await APIBase.fetchResult(`${args.url}/authenticate`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
27
|
+
},
|
|
28
|
+
body: new URLSearchParams(body)
|
|
29
|
+
});
|
|
30
|
+
if (!res.success) {
|
|
31
|
+
return failure([{
|
|
32
|
+
type: 'network-error',
|
|
33
|
+
message: res.error.message,
|
|
34
|
+
endpoint: 'authenticate'
|
|
35
|
+
}]);
|
|
36
|
+
}
|
|
37
|
+
if (res.data.status >= 300) {
|
|
38
|
+
try {
|
|
39
|
+
const error = await res.data.json();
|
|
40
|
+
return failure([{
|
|
41
|
+
type: 'http-error',
|
|
42
|
+
statusCode: res.data.status,
|
|
43
|
+
message: error.error,
|
|
44
|
+
endpoint: 'authenticate'
|
|
45
|
+
}]);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return failure([{
|
|
48
|
+
type: 'http-error',
|
|
49
|
+
statusCode: res.data.status,
|
|
50
|
+
message: 'Could not authenticate',
|
|
51
|
+
endpoint: 'authenticate'
|
|
52
|
+
}]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const payload = await res.data.json();
|
|
56
|
+
return success(payload);
|
|
57
|
+
}
|
|
16
58
|
async fetchFromEnter(endpoint, method, data) {
|
|
17
59
|
const body = data !== null ? JSON.stringify(data) : null;
|
|
18
60
|
const headers = {
|
|
19
|
-
Authorization: `bearer ${this.credentials.accessToken}`,
|
|
61
|
+
Authorization: `bearer ${this.credentials.accessToken.access_token}`,
|
|
20
62
|
'Content-Type': 'application/json'
|
|
21
63
|
};
|
|
22
64
|
const res = await APIBase.fetchResult(`${this.credentials.url}${endpoint}`, {
|
|
@@ -89,8 +131,17 @@ export default class APIBase {
|
|
|
89
131
|
if (!rawResponse.success) return rawResponse;
|
|
90
132
|
return success(rawResponse.data);
|
|
91
133
|
}
|
|
134
|
+
async refreshToken() {
|
|
135
|
+
return this.post('/authenticate/refresh', null);
|
|
136
|
+
}
|
|
92
137
|
async logout() {
|
|
93
138
|
this.isLoggedIn = false;
|
|
94
139
|
this.onLogout();
|
|
140
|
+
try {
|
|
141
|
+
// delete token at api backend so it becomes invalid
|
|
142
|
+
await this.fetchFromEnter('/authenticate', 'delete', undefined);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
console.warn('error deleting the token in the backend, so it is still valid', e);
|
|
145
|
+
}
|
|
95
146
|
}
|
|
96
147
|
}
|
|
@@ -7,6 +7,12 @@ export declare type paths = {
|
|
|
7
7
|
/** healthcheck to see if api server is running */
|
|
8
8
|
get: operations["healthcheck_health_get"];
|
|
9
9
|
};
|
|
10
|
+
"/authenticate": {
|
|
11
|
+
post: operations["login_authenticate_post"];
|
|
12
|
+
};
|
|
13
|
+
"/authenticate/refresh": {
|
|
14
|
+
post: operations["refresh_token_authenticate_refresh_post"];
|
|
15
|
+
};
|
|
10
16
|
"/instances/{instance_name}/checkin_counts": {
|
|
11
17
|
get: operations["checkin_counts_instances__instance_name__checkin_counts_get"];
|
|
12
18
|
};
|
|
@@ -228,6 +234,39 @@ export declare type components = {
|
|
|
228
234
|
/** Value */
|
|
229
235
|
value?: string;
|
|
230
236
|
};
|
|
237
|
+
/** AuthResponse */
|
|
238
|
+
AuthResponse: {
|
|
239
|
+
/**
|
|
240
|
+
* Token Type
|
|
241
|
+
* @enum {string}
|
|
242
|
+
*/
|
|
243
|
+
token_type: "bearer";
|
|
244
|
+
/** Access Token */
|
|
245
|
+
access_token: string;
|
|
246
|
+
/**
|
|
247
|
+
* Expires
|
|
248
|
+
* Format: date-time
|
|
249
|
+
*/
|
|
250
|
+
expires: string;
|
|
251
|
+
};
|
|
252
|
+
/** Body_login_authenticate_post */
|
|
253
|
+
Body_login_authenticate_post: {
|
|
254
|
+
/** Grant Type */
|
|
255
|
+
grant_type?: string;
|
|
256
|
+
/** Username */
|
|
257
|
+
username: string;
|
|
258
|
+
/** Password */
|
|
259
|
+
password: string;
|
|
260
|
+
/**
|
|
261
|
+
* Scope
|
|
262
|
+
* @default
|
|
263
|
+
*/
|
|
264
|
+
scope: string;
|
|
265
|
+
/** Client Id */
|
|
266
|
+
client_id?: string;
|
|
267
|
+
/** Client Secret */
|
|
268
|
+
client_secret?: string;
|
|
269
|
+
};
|
|
231
270
|
/** CheckboxField */
|
|
232
271
|
CheckboxField: {
|
|
233
272
|
/**
|
|
@@ -346,12 +385,8 @@ export declare type components = {
|
|
|
346
385
|
* Format: date-time
|
|
347
386
|
*/
|
|
348
387
|
time: string;
|
|
349
|
-
/**
|
|
350
|
-
|
|
351
|
-
* @default false
|
|
352
|
-
* @enum {boolean}
|
|
353
|
-
*/
|
|
354
|
-
main: false;
|
|
388
|
+
/** Main */
|
|
389
|
+
main: boolean;
|
|
355
390
|
};
|
|
356
391
|
/** CheckinCount */
|
|
357
392
|
CheckinCount: {
|
|
@@ -603,39 +638,8 @@ export declare type components = {
|
|
|
603
638
|
/** Max */
|
|
604
639
|
max?: number;
|
|
605
640
|
};
|
|
606
|
-
/**
|
|
607
|
-
* EmailUnsubscribedEvent
|
|
608
|
-
* @description Attendee unsubscribed from email list.
|
|
609
|
-
*
|
|
610
|
-
* This will add the email_address to a blacklist for all mailings from the domain
|
|
611
|
-
* associated to the instance.
|
|
612
|
-
*/
|
|
613
|
-
EmailUnsubscribedEvent: {
|
|
614
|
-
/**
|
|
615
|
-
* Id
|
|
616
|
-
* Format: uuid
|
|
617
|
-
*/
|
|
618
|
-
id?: string;
|
|
619
|
-
/**
|
|
620
|
-
* Event
|
|
621
|
-
* @default email-unsubscribed
|
|
622
|
-
* @enum {string}
|
|
623
|
-
*/
|
|
624
|
-
event: "email-unsubscribed";
|
|
625
|
-
/** Instancename */
|
|
626
|
-
instanceName: string;
|
|
627
|
-
/** Emailaddress */
|
|
628
|
-
emailAddress: string;
|
|
629
|
-
/** Signature */
|
|
630
|
-
signature: string;
|
|
631
|
-
};
|
|
632
641
|
/** EventList */
|
|
633
|
-
EventList: (components["schemas"]["AttendeeCreatedEvent"] | components["schemas"]["AttendeeUpdatedEvent"] | components["schemas"]["AttendeeRespondedEvent"] | components["schemas"]["
|
|
634
|
-
/** EventResponse */
|
|
635
|
-
EventResponse: {
|
|
636
|
-
/** Created */
|
|
637
|
-
created: number;
|
|
638
|
-
};
|
|
642
|
+
EventList: (components["schemas"]["AttendeeCreatedEvent"] | components["schemas"]["AttendeeUpdatedEvent"] | components["schemas"]["AttendeeRespondedEvent"] | components["schemas"]["AttendeeDeletedEvent"] | components["schemas"]["CheckinCreatedEvent"] | components["schemas"]["CheckinDeletedEvent"] | components["schemas"]["PaymentPaidEvent"])[];
|
|
639
643
|
/** FieldGroup */
|
|
640
644
|
FieldGroup: {
|
|
641
645
|
/** Questions */
|
|
@@ -1033,7 +1037,7 @@ export declare type components = {
|
|
|
1033
1037
|
};
|
|
1034
1038
|
/** Permissions */
|
|
1035
1039
|
permissions: {
|
|
1036
|
-
[key: string]: ("attendees
|
|
1040
|
+
[key: string]: ("attendees" | "add" | "email" | "invites" | "generate" | "edit" | "filter" | "export" | "export-pdf" | "delete" | "delete-final" | "payment" | "checkin" | "api" | "changes" | "private" | "files" | "import" | "bulk" | "email-bulk" | "questions" | "pages" | "templates" | "emails" | "pdfs" | "regflow" | "reg-scripts" | "export-custom" | "regdata" | "setup" | "read-stats" | "write-stats" | "backup" | "read-variables" | "write-variables" | "webhooks")[];
|
|
1037
1041
|
};
|
|
1038
1042
|
};
|
|
1039
1043
|
/** RadioButtonField */
|
|
@@ -1279,8 +1283,8 @@ export declare type components = {
|
|
|
1279
1283
|
/** Rootpath */
|
|
1280
1284
|
rootPath: string;
|
|
1281
1285
|
};
|
|
1282
|
-
/**
|
|
1283
|
-
|
|
1286
|
+
/** UserUpdate */
|
|
1287
|
+
UserUpdate: {
|
|
1284
1288
|
/** Userdata */
|
|
1285
1289
|
userdata: {
|
|
1286
1290
|
[key: string]: unknown;
|
|
@@ -1344,6 +1348,37 @@ export declare type operations = {
|
|
|
1344
1348
|
};
|
|
1345
1349
|
};
|
|
1346
1350
|
};
|
|
1351
|
+
login_authenticate_post: {
|
|
1352
|
+
responses: {
|
|
1353
|
+
/** Successful Response */
|
|
1354
|
+
200: {
|
|
1355
|
+
content: {
|
|
1356
|
+
"application/json": components["schemas"]["AuthResponse"];
|
|
1357
|
+
};
|
|
1358
|
+
};
|
|
1359
|
+
/** Validation Error */
|
|
1360
|
+
422: {
|
|
1361
|
+
content: {
|
|
1362
|
+
"application/json": components["schemas"]["HTTPValidationError"];
|
|
1363
|
+
};
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
requestBody: {
|
|
1367
|
+
content: {
|
|
1368
|
+
"application/x-www-form-urlencoded": components["schemas"]["Body_login_authenticate_post"];
|
|
1369
|
+
};
|
|
1370
|
+
};
|
|
1371
|
+
};
|
|
1372
|
+
refresh_token_authenticate_refresh_post: {
|
|
1373
|
+
responses: {
|
|
1374
|
+
/** Successful Response */
|
|
1375
|
+
200: {
|
|
1376
|
+
content: {
|
|
1377
|
+
"application/json": components["schemas"]["AuthResponse"];
|
|
1378
|
+
};
|
|
1379
|
+
};
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1347
1382
|
checkin_counts_instances__instance_name__checkin_counts_get: {
|
|
1348
1383
|
parameters: {
|
|
1349
1384
|
path: {
|
|
@@ -1371,11 +1406,7 @@ export declare type operations = {
|
|
|
1371
1406
|
create_events_events_post: {
|
|
1372
1407
|
responses: {
|
|
1373
1408
|
/** Successful Response */
|
|
1374
|
-
|
|
1375
|
-
content: {
|
|
1376
|
-
"application/json": components["schemas"]["EventResponse"];
|
|
1377
|
-
};
|
|
1378
|
-
};
|
|
1409
|
+
204: never;
|
|
1379
1410
|
/** Validation Error */
|
|
1380
1411
|
422: {
|
|
1381
1412
|
content: {
|
|
@@ -1445,7 +1476,7 @@ export declare type operations = {
|
|
|
1445
1476
|
};
|
|
1446
1477
|
requestBody: {
|
|
1447
1478
|
content: {
|
|
1448
|
-
"application/json": components["schemas"]["
|
|
1479
|
+
"application/json": components["schemas"]["UserUpdate"];
|
|
1449
1480
|
};
|
|
1450
1481
|
};
|
|
1451
1482
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare type FieldValue = string | number | string[] | null;
|
|
1
|
+
export declare type FieldValue = string | number | string[] | boolean | null;
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { components } from '../generated/api-schema';
|
|
2
|
-
export declare type Permission = components['schemas']['PublicUser']['permissions'][string]
|
|
2
|
+
export declare type Permission = components['schemas']['PublicUser']['permissions'][string];
|
|
@@ -6,7 +6,7 @@ export const AddGuestIcon = ({
|
|
|
6
6
|
return /*#__PURE__*/React.createElement("svg", {
|
|
7
7
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8
8
|
width: "100%",
|
|
9
|
-
height: "
|
|
9
|
+
height: "100%",
|
|
10
10
|
viewBox: "0 0 16.571 13.68"
|
|
11
11
|
}, /*#__PURE__*/React.createElement("path", {
|
|
12
12
|
fill: color,
|
|
@@ -6,7 +6,7 @@ export const FilterIcon = ({
|
|
|
6
6
|
return /*#__PURE__*/React.createElement("svg", {
|
|
7
7
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8
8
|
width: "100%",
|
|
9
|
-
height: "
|
|
9
|
+
height: "100%",
|
|
10
10
|
viewBox: "0 0 10.252 11.956"
|
|
11
11
|
}, /*#__PURE__*/React.createElement("path", {
|
|
12
12
|
fill: color,
|
|
@@ -6,7 +6,7 @@ export const SearchIcon = ({
|
|
|
6
6
|
return /*#__PURE__*/React.createElement("svg", {
|
|
7
7
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8
8
|
width: "100%",
|
|
9
|
-
height: "
|
|
9
|
+
height: "100%",
|
|
10
10
|
viewBox: "0 0 18.9 19.688"
|
|
11
11
|
}, /*#__PURE__*/React.createElement("path", {
|
|
12
12
|
fill: color,
|