@dev-crew-berlin/enter-js-utils 0.35.1 → 0.37.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.
|
@@ -78,7 +78,8 @@ export default class APIBase {
|
|
|
78
78
|
return failure([{
|
|
79
79
|
type: 'http-error',
|
|
80
80
|
statusCode: 401,
|
|
81
|
-
endpoint
|
|
81
|
+
endpoint,
|
|
82
|
+
message: res.data.statusText
|
|
82
83
|
}]);
|
|
83
84
|
}
|
|
84
85
|
if (res.data.status >= 300) {
|
|
@@ -87,14 +88,14 @@ export default class APIBase {
|
|
|
87
88
|
return failure([{
|
|
88
89
|
type: 'http-error',
|
|
89
90
|
statusCode: res.data.status,
|
|
90
|
-
message: error.error,
|
|
91
|
+
message: error.error ?? res.data.statusText,
|
|
91
92
|
endpoint
|
|
92
93
|
}]);
|
|
93
94
|
} catch (e) {
|
|
94
95
|
return failure([{
|
|
95
96
|
type: 'http-error',
|
|
96
97
|
statusCode: res.data.status,
|
|
97
|
-
message: `invalid response from backend: ${res.data.status} for: ${endpoint}`,
|
|
98
|
+
message: `invalid response from backend: ${res.data.status} (${res.data.statusText}) for: ${endpoint}`,
|
|
98
99
|
endpoint
|
|
99
100
|
}]);
|
|
100
101
|
}
|
package/dist/lib/api-result.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ export declare class Attendee {
|
|
|
25
25
|
};
|
|
26
26
|
deleted: boolean;
|
|
27
27
|
constructor(args: AttendeeJSON | string);
|
|
28
|
+
/**
|
|
29
|
+
* creates a bse36 encoded uuid
|
|
30
|
+
* we use base36 encoding because it is more human readable and also shorter
|
|
31
|
+
* so it fits better into an QR-Code
|
|
32
|
+
* @param prefix A prefix - ussually the 1st 3 letters of the instance name are used
|
|
33
|
+
* @returns base36 encoded uuid string
|
|
34
|
+
*/
|
|
35
|
+
static generateID(prefix: string): string;
|
|
28
36
|
toJSON(): AttendeeJSON;
|
|
29
37
|
getRsvpCountForTag(checkinTag: string): number;
|
|
30
38
|
getResponseForTag(checkinTag: string): 'no-response' | 'negative-response' | 'positive-response';
|
package/dist/models/attendee.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
1
2
|
import { Checkins } from './checkins';
|
|
2
3
|
export class Attendee {
|
|
3
4
|
userdata = {};
|
|
@@ -25,6 +26,20 @@ export class Attendee {
|
|
|
25
26
|
this.payment = json.payment;
|
|
26
27
|
this.deleted = json.deleted;
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* creates a bse36 encoded uuid
|
|
32
|
+
* we use base36 encoding because it is more human readable and also shorter
|
|
33
|
+
* so it fits better into an QR-Code
|
|
34
|
+
* @param prefix A prefix - ussually the 1st 3 letters of the instance name are used
|
|
35
|
+
* @returns base36 encoded uuid string
|
|
36
|
+
*/
|
|
37
|
+
static generateID(prefix) {
|
|
38
|
+
const uuid = uuidv4();
|
|
39
|
+
const guid = BigInt(`0x${uuid.replaceAll('-', '')}`);
|
|
40
|
+
const encoded = guid.toString(36).toUpperCase();
|
|
41
|
+
return `${prefix}-${encoded}`;
|
|
42
|
+
}
|
|
28
43
|
toJSON() {
|
|
29
44
|
// this is exactly what js also provides out of the box
|
|
30
45
|
// but then typescript complains that there is no toJSON function
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-crew-berlin/enter-js-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "utils such as vaildation and other helpers to work with data from the enter app",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@storybook/react": "^6.5.15",
|
|
54
54
|
"@storybook/testing-library": "^0.0.13",
|
|
55
55
|
"@types/node": "^17.0.38",
|
|
56
|
+
"@types/uuid": "^8.3.4",
|
|
56
57
|
"@types/react": "^18.0.10",
|
|
57
58
|
"@types/react-dom": "^18.0.5",
|
|
58
59
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
@@ -70,8 +71,8 @@
|
|
|
70
71
|
"react-dom": "^18.1.0"
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
|
-
"fefe": "^3.2.0",
|
|
74
74
|
"fp-ts": "^2.12.1",
|
|
75
|
-
"styled-jsx": "^5.0.2"
|
|
75
|
+
"styled-jsx": "^5.0.2",
|
|
76
|
+
"uuid": "^9.0.0"
|
|
76
77
|
}
|
|
77
78
|
}
|