@dev-crew-berlin/enter-js-utils 0.40.4 → 0.41.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.
- package/dist/api-client/api-base.d.ts +1 -9
- package/dist/api-client/api-base.js +1 -52
- package/dist/generated/api-schema.d.ts +53 -86
- package/dist/models/index.d.ts +0 -1
- package/dist/models/instance.d.ts +1 -2
- package/dist/models/instance.js +2 -2
- package/dist/models/permission.d.ts +1 -1
- package/package.json +1 -1
- package/dist/models/access-token.d.ts +0 -2
- package/dist/models/access-token.js +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { APIResult } from '../lib';
|
|
2
|
-
import { AccessToken } from '../models/access-token';
|
|
3
2
|
import { paths } from '../generated/api-schema';
|
|
4
3
|
export interface APICredentials {
|
|
5
|
-
accessToken:
|
|
4
|
+
accessToken: string;
|
|
6
5
|
url: string;
|
|
7
6
|
}
|
|
8
7
|
declare type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
@@ -27,19 +26,12 @@ export default class APIBase {
|
|
|
27
26
|
onLogout: (reason?: string) => void;
|
|
28
27
|
});
|
|
29
28
|
private static fetchResult;
|
|
30
|
-
static fetchAccessToken(args: {
|
|
31
|
-
url: string;
|
|
32
|
-
user: string;
|
|
33
|
-
password: string;
|
|
34
|
-
deviceName: string;
|
|
35
|
-
}): Promise<APIResult<AccessToken>>;
|
|
36
29
|
private fetchFromEnter;
|
|
37
30
|
protected get<Path extends keyof paths>(endpoint: Path): Promise<APIResult<ResponseType<Path, 'get'>>>;
|
|
38
31
|
protected post<Path extends keyof paths>(endpoint: Path, data: RequestBody<Path, 'post'>): Promise<APIResult<ResponseType<Path, 'post'>>>;
|
|
39
32
|
protected put<Path extends keyof paths>(endpoint: Path, data: RequestBody<Path, 'put'>): Promise<APIResult<ResponseType<Path, 'put'>>>;
|
|
40
33
|
protected patch<Path extends keyof paths>(endpoint: Path, data: RequestBody<Path, 'patch'>): Promise<APIResult<ResponseType<Path, 'patch'>>>;
|
|
41
34
|
protected delete<Path extends keyof paths>(endpoint: Path): Promise<APIResult<ResponseType<Path, 'delete'>>>;
|
|
42
|
-
refreshToken(): Promise<APIResult<AccessToken>>;
|
|
43
35
|
logout(): Promise<void>;
|
|
44
36
|
}
|
|
45
37
|
export {};
|
|
@@ -13,52 +13,10 @@ 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
|
-
}
|
|
58
16
|
async fetchFromEnter(endpoint, method, data) {
|
|
59
17
|
const body = data !== null ? JSON.stringify(data) : null;
|
|
60
18
|
const headers = {
|
|
61
|
-
Authorization: `bearer ${this.credentials.accessToken
|
|
19
|
+
Authorization: `bearer ${this.credentials.accessToken}`,
|
|
62
20
|
'Content-Type': 'application/json'
|
|
63
21
|
};
|
|
64
22
|
const res = await APIBase.fetchResult(`${this.credentials.url}${endpoint}`, {
|
|
@@ -131,17 +89,8 @@ export default class APIBase {
|
|
|
131
89
|
if (!rawResponse.success) return rawResponse;
|
|
132
90
|
return success(rawResponse.data);
|
|
133
91
|
}
|
|
134
|
-
async refreshToken() {
|
|
135
|
-
return this.post('/authenticate/refresh', null);
|
|
136
|
-
}
|
|
137
92
|
async logout() {
|
|
138
93
|
this.isLoggedIn = false;
|
|
139
94
|
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
|
-
}
|
|
146
95
|
}
|
|
147
96
|
}
|
|
@@ -7,12 +7,6 @@ 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
|
-
};
|
|
16
10
|
"/instances/{instance_name}/checkin_counts": {
|
|
17
11
|
get: operations["checkin_counts_instances__instance_name__checkin_counts_get"];
|
|
18
12
|
};
|
|
@@ -234,39 +228,6 @@ export declare type components = {
|
|
|
234
228
|
/** Value */
|
|
235
229
|
value?: string;
|
|
236
230
|
};
|
|
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
|
-
};
|
|
270
231
|
/** CheckboxField */
|
|
271
232
|
CheckboxField: {
|
|
272
233
|
/**
|
|
@@ -385,8 +346,12 @@ export declare type components = {
|
|
|
385
346
|
* Format: date-time
|
|
386
347
|
*/
|
|
387
348
|
time: string;
|
|
388
|
-
/**
|
|
389
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Main
|
|
351
|
+
* @default false
|
|
352
|
+
* @enum {boolean}
|
|
353
|
+
*/
|
|
354
|
+
main: false;
|
|
390
355
|
};
|
|
391
356
|
/** CheckinCount */
|
|
392
357
|
CheckinCount: {
|
|
@@ -638,8 +603,39 @@ export declare type components = {
|
|
|
638
603
|
/** Max */
|
|
639
604
|
max?: number;
|
|
640
605
|
};
|
|
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
|
+
};
|
|
641
632
|
/** EventList */
|
|
642
|
-
EventList: (components["schemas"]["AttendeeCreatedEvent"] | components["schemas"]["AttendeeUpdatedEvent"] | components["schemas"]["AttendeeRespondedEvent"] | components["schemas"]["AttendeeDeletedEvent"] | components["schemas"]["CheckinCreatedEvent"] | components["schemas"]["CheckinDeletedEvent"] | components["schemas"]["PaymentPaidEvent"])[];
|
|
633
|
+
EventList: (components["schemas"]["AttendeeCreatedEvent"] | components["schemas"]["AttendeeUpdatedEvent"] | components["schemas"]["AttendeeRespondedEvent"] | components["schemas"]["EmailUnsubscribedEvent"] | components["schemas"]["AttendeeDeletedEvent"] | components["schemas"]["CheckinCreatedEvent"] | components["schemas"]["CheckinDeletedEvent"] | components["schemas"]["PaymentPaidEvent"])[];
|
|
634
|
+
/** EventResponse */
|
|
635
|
+
EventResponse: {
|
|
636
|
+
/** Created */
|
|
637
|
+
created: number;
|
|
638
|
+
};
|
|
643
639
|
/** FieldGroup */
|
|
644
640
|
FieldGroup: {
|
|
645
641
|
/** Questions */
|
|
@@ -715,6 +711,11 @@ export declare type components = {
|
|
|
715
711
|
/** Ext */
|
|
716
712
|
ext?: string[];
|
|
717
713
|
};
|
|
714
|
+
/** FrontendJSON */
|
|
715
|
+
FrontendJSON: {
|
|
716
|
+
/** Domain */
|
|
717
|
+
domain: string;
|
|
718
|
+
};
|
|
718
719
|
/** HTTPValidationError */
|
|
719
720
|
HTTPValidationError: {
|
|
720
721
|
/** Detail */
|
|
@@ -1011,7 +1012,7 @@ export declare type components = {
|
|
|
1011
1012
|
description: string;
|
|
1012
1013
|
/** Thumbnail */
|
|
1013
1014
|
thumbnail: boolean;
|
|
1014
|
-
|
|
1015
|
+
frontend: components["schemas"]["FrontendJSON"];
|
|
1015
1016
|
registration: components["schemas"]["RegistrationInfo"];
|
|
1016
1017
|
/** Guestnamefields */
|
|
1017
1018
|
guestNameFields: string[];
|
|
@@ -1037,7 +1038,7 @@ export declare type components = {
|
|
|
1037
1038
|
};
|
|
1038
1039
|
/** Permissions */
|
|
1039
1040
|
permissions: {
|
|
1040
|
-
[key: string]: ("attendees" | "
|
|
1041
|
+
[key: string]: ("attendees:read" | "attendees:create" | "attendees:write" | "attendees:write:bulk" | "attendees:import" | "attendees:export" | "attendees:delete:soft" | "attendees:delete:final" | "emails:send" | "emails:send:bulk" | "email-config:write" | "pdfs:write" | "pdfs:export" | "payment:write" | "checkins:write" | "files:write" | "fields:write" | "fields:read" | "templates:write" | "register-flow:write" | "export-scripts:write" | "registration-code:write" | "instance-info:read" | "instance-info:write" | "domains:manage" | "stats:read" | "stats:write" | "backup:write" | "variables:read" | "variables:write" | "webhooks:read" | "webhooks:write")[];
|
|
1041
1042
|
};
|
|
1042
1043
|
};
|
|
1043
1044
|
/** RadioButtonField */
|
|
@@ -1276,15 +1277,8 @@ export declare type components = {
|
|
|
1276
1277
|
/** Max */
|
|
1277
1278
|
max?: number;
|
|
1278
1279
|
};
|
|
1279
|
-
/**
|
|
1280
|
-
|
|
1281
|
-
/** Domain */
|
|
1282
|
-
domain: string;
|
|
1283
|
-
/** Rootpath */
|
|
1284
|
-
rootPath: string;
|
|
1285
|
-
};
|
|
1286
|
-
/** UserUpdate */
|
|
1287
|
-
UserUpdate: {
|
|
1280
|
+
/** UserPreferencesUpdate */
|
|
1281
|
+
UserPreferencesUpdate: {
|
|
1288
1282
|
/** Userdata */
|
|
1289
1283
|
userdata: {
|
|
1290
1284
|
[key: string]: unknown;
|
|
@@ -1348,37 +1342,6 @@ export declare type operations = {
|
|
|
1348
1342
|
};
|
|
1349
1343
|
};
|
|
1350
1344
|
};
|
|
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
|
-
};
|
|
1382
1345
|
checkin_counts_instances__instance_name__checkin_counts_get: {
|
|
1383
1346
|
parameters: {
|
|
1384
1347
|
path: {
|
|
@@ -1406,7 +1369,11 @@ export declare type operations = {
|
|
|
1406
1369
|
create_events_events_post: {
|
|
1407
1370
|
responses: {
|
|
1408
1371
|
/** Successful Response */
|
|
1409
|
-
|
|
1372
|
+
201: {
|
|
1373
|
+
content: {
|
|
1374
|
+
"application/json": components["schemas"]["EventResponse"];
|
|
1375
|
+
};
|
|
1376
|
+
};
|
|
1410
1377
|
/** Validation Error */
|
|
1411
1378
|
422: {
|
|
1412
1379
|
content: {
|
|
@@ -1476,7 +1443,7 @@ export declare type operations = {
|
|
|
1476
1443
|
};
|
|
1477
1444
|
requestBody: {
|
|
1478
1445
|
content: {
|
|
1479
|
-
"application/json": components["schemas"]["
|
|
1446
|
+
"application/json": components["schemas"]["UserPreferencesUpdate"];
|
|
1480
1447
|
};
|
|
1481
1448
|
};
|
|
1482
1449
|
};
|
package/dist/models/index.d.ts
CHANGED
package/dist/models/instance.js
CHANGED
|
@@ -5,7 +5,7 @@ export class Instance {
|
|
|
5
5
|
this.description = json.description;
|
|
6
6
|
this.checkinTags = json.checkins;
|
|
7
7
|
this.hasTumbnail = json.thumbnail;
|
|
8
|
-
this.
|
|
8
|
+
this.frontend = json.frontend;
|
|
9
9
|
this.registration = {
|
|
10
10
|
start: json.registration.start ? new Date(json.registration.start) : undefined,
|
|
11
11
|
end: json.registration.end ? new Date(json.registration.end) : undefined,
|
|
@@ -23,7 +23,7 @@ export class Instance {
|
|
|
23
23
|
description: this.description,
|
|
24
24
|
checkins: this.checkinTags,
|
|
25
25
|
thumbnail: this.hasTumbnail,
|
|
26
|
-
|
|
26
|
+
frontend: this.frontend,
|
|
27
27
|
registration: {
|
|
28
28
|
start: this.registration.start?.toISOString(),
|
|
29
29
|
end: this.registration.end?.toISOString(),
|
|
@@ -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][number];
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|