@dev-crew-berlin/enter-js-utils 0.23.0 → 0.30.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 +2 -7
- package/dist/api-client/api-base.d.ts +22 -7
- package/dist/api-client/api-base.js +30 -32
- package/dist/api-client/index.d.ts +27 -45
- package/dist/api-client/index.js +58 -46
- package/dist/generated/api-schema.d.ts +1665 -0
- package/dist/generated/api-schema.js +1 -0
- package/dist/lib/api-result.d.ts +1 -8
- package/dist/lib/api-result.js +1 -12
- package/dist/models/access-token.d.ts +2 -11
- package/dist/models/access-token.js +1 -11
- package/dist/models/attendee.d.ts +13 -60
- package/dist/models/attendee.js +41 -87
- package/dist/models/checkin-counts.d.ts +4 -10
- package/dist/models/checkin-counts.js +1 -10
- package/dist/models/checkin.d.ts +9 -0
- package/dist/models/checkin.js +16 -0
- package/dist/models/checkins.d.ts +4 -32
- package/dist/models/checkins.js +14 -42
- package/dist/models/event.d.ts +2 -40
- package/dist/models/field-group.d.ts +5 -448
- package/dist/models/field-group.js +4 -31
- package/dist/models/field-value.d.ts +0 -1
- package/dist/models/field-value.js +1 -3
- package/dist/models/field.d.ts +11 -297
- package/dist/models/field.js +1 -89
- package/dist/models/index.d.ts +2 -3
- package/dist/models/instance.d.ts +10 -53
- package/dist/models/instance.js +23 -65
- package/dist/models/user.d.ts +2 -20
- package/dist/models/user.js +1 -13
- package/dist/models/variable.d.ts +2 -27
- package/dist/models/variable.js +1 -16
- package/dist/ui/companion-info.stories.js +1 -3
- package/dist/ui/guest-card.stories.js +2 -6
- package/dist/ui/icons/caret.d.ts +7 -0
- package/dist/ui/icons/caret.js +20 -0
- package/dist/ui/icons/caret.stories.d.ts +15 -0
- package/dist/ui/icons/caret.stories.js +20 -0
- package/package.json +10 -8
- package/dist/models/_helpers.d.ts +0 -23
- package/dist/models/_helpers.js +0 -89
- package/dist/models/invite.d.ts +0 -33
- package/dist/models/invite.js +0 -21
- package/dist/models/meta-field.d.ts +0 -7
- package/dist/models/meta-field.js +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/lib/api-result.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Validator } from 'fefe';
|
|
2
1
|
import { Result } from './result';
|
|
3
2
|
export declare type NetworkError = {
|
|
4
3
|
type: 'network-error';
|
|
@@ -15,11 +14,5 @@ export declare type ClientError = {
|
|
|
15
14
|
type: 'client-error';
|
|
16
15
|
message: string;
|
|
17
16
|
};
|
|
18
|
-
export declare type
|
|
19
|
-
type: 'validation-error';
|
|
20
|
-
message: string;
|
|
21
|
-
};
|
|
22
|
-
export declare type APIError = NetworkError | HTTPError | ClientError | ValidationError;
|
|
17
|
+
export declare type APIError = NetworkError | HTTPError | ClientError;
|
|
23
18
|
export declare type APIResult<Model> = Result<APIError[], Model>;
|
|
24
|
-
export declare type APIValidator<Model> = (value: unknown) => APIResult<Model>;
|
|
25
|
-
export declare function apiValidator<T>(validate: Validator<T>): APIValidator<T>;
|
package/dist/lib/api-result.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { success, failure } from './result';
|
|
3
|
-
export function apiValidator(validate) {
|
|
4
|
-
return value => {
|
|
5
|
-
const fefeResult = validate(value);
|
|
6
|
-
if (isSuccess(fefeResult)) return success(fefeResult.right);
|
|
7
|
-
return failure([{
|
|
8
|
-
type: 'validation-error',
|
|
9
|
-
message: getErrorString(fefeResult.left)
|
|
10
|
-
}]);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare
|
|
3
|
-
accessToken: import("fefe").Validator<string, import("fefe").LeafError>;
|
|
4
|
-
expires: import("fefe").Pipe<unknown, Date>;
|
|
5
|
-
}>, import("fefe").FefeError>;
|
|
6
|
-
export declare type AccessToken = ValidatorReturnType<typeof accessToken>;
|
|
7
|
-
export declare const parseAccessToken: import("../lib").APIValidator<import("fefe").ObjectResult<{
|
|
8
|
-
accessToken: import("fefe").Validator<string, import("fefe").LeafError>;
|
|
9
|
-
expires: import("fefe").Pipe<unknown, Date>;
|
|
10
|
-
}>>;
|
|
11
|
-
export {};
|
|
1
|
+
import { components } from '../generated/api-schema';
|
|
2
|
+
export declare type AccessToken = components['schemas']['AuthResponse'];
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { apiValidator } from '../lib';
|
|
3
|
-
const accessToken = object({
|
|
4
|
-
accessToken: string(),
|
|
5
|
-
expires: pipe(string()).pipe(parseDate({
|
|
6
|
-
iso: true
|
|
7
|
-
}))
|
|
8
|
-
}, {
|
|
9
|
-
allowExcessProperties: true
|
|
10
|
-
});
|
|
11
|
-
export const parseAccessToken = apiValidator(accessToken);
|
|
1
|
+
export {};
|
|
@@ -1,37 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { components } from '../generated/api-schema';
|
|
2
|
+
import { Checkin } from './checkin';
|
|
3
|
+
import { Checkins } from './checkins';
|
|
4
4
|
import { FieldValue } from './field-value';
|
|
5
|
-
export declare type AttendeeJSON = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
userdata: Record<string, FieldValue>;
|
|
9
|
-
tags: string[] | null;
|
|
10
|
-
language: string | null;
|
|
11
|
-
time: string;
|
|
12
|
-
rsvp: Record<string, number | null>;
|
|
13
|
-
checkin: Record<string, CheckinsJSON>;
|
|
14
|
-
companions: {
|
|
15
|
-
isCompanion: false;
|
|
16
|
-
} | {
|
|
17
|
-
isCompanion: true;
|
|
18
|
-
mainGuestId: string;
|
|
5
|
+
export declare type AttendeeJSON = Omit<components['schemas']['PublicAttendee'], 'rsvp' | 'auth'> & {
|
|
6
|
+
rsvp: {
|
|
7
|
+
[key: string]: number | null;
|
|
19
8
|
};
|
|
20
|
-
payment: {
|
|
21
|
-
paid: boolean;
|
|
22
|
-
provider: 'credit' | 'paypal';
|
|
23
|
-
amount: number;
|
|
24
|
-
testmode: boolean;
|
|
25
|
-
} | null;
|
|
26
|
-
deleted: boolean;
|
|
27
9
|
};
|
|
28
10
|
export declare class Attendee {
|
|
29
11
|
id: string;
|
|
30
|
-
auth: string | null;
|
|
31
12
|
userdata: Record<string, FieldValue>;
|
|
32
|
-
tags: string[]
|
|
33
|
-
language
|
|
34
|
-
time
|
|
13
|
+
tags: string[];
|
|
14
|
+
language?: string;
|
|
15
|
+
time?: Date;
|
|
35
16
|
rsvp: Record<string, number | null>;
|
|
36
17
|
checkin: Record<string, Checkins>;
|
|
37
18
|
companions: {
|
|
@@ -40,15 +21,14 @@ export declare class Attendee {
|
|
|
40
21
|
isCompanion: true;
|
|
41
22
|
mainGuestId: string;
|
|
42
23
|
};
|
|
43
|
-
payment
|
|
24
|
+
payment?: {
|
|
44
25
|
paid: boolean;
|
|
45
|
-
provider: '
|
|
26
|
+
provider: components['schemas']['Payment']['provider'];
|
|
46
27
|
amount: number;
|
|
47
28
|
testmode: boolean;
|
|
48
|
-
}
|
|
29
|
+
};
|
|
49
30
|
deleted: boolean;
|
|
50
|
-
constructor(
|
|
51
|
-
static fromJSON(json: AttendeeJSON): Attendee;
|
|
31
|
+
constructor(args: AttendeeJSON | string);
|
|
52
32
|
toJSON(): AttendeeJSON;
|
|
53
33
|
getRsvpCountForTag(checkinTag: string): number;
|
|
54
34
|
getResponseForTag(checkinTag: string): 'no-response' | 'negative-repsone' | 'positive-response';
|
|
@@ -66,30 +46,3 @@ export declare class Attendee {
|
|
|
66
46
|
checkinTags: string[];
|
|
67
47
|
}): boolean;
|
|
68
48
|
}
|
|
69
|
-
export declare const rawAttendee: import("fefe").Validator<import("fefe").ObjectResult<{
|
|
70
|
-
id: import("fefe").Validator<string, import("fefe").LeafError>;
|
|
71
|
-
auth: import("fefe").Validator<string | null, import("fefe").FefeError>;
|
|
72
|
-
userdata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string | number | string[] | null>, import("fefe").FefeError>;
|
|
73
|
-
tags: import("fefe").Validator<string[] | null, import("fefe").FefeError>;
|
|
74
|
-
language: import("fefe").Validator<string | null, import("fefe").FefeError>;
|
|
75
|
-
time: import("fefe").Pipe<unknown, Date>;
|
|
76
|
-
rsvp: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<number | null>, import("fefe").FefeError>;
|
|
77
|
-
checkin: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<Checkins>, import("fefe").FefeError>;
|
|
78
|
-
companions: import("fefe").Validator<import("fefe").ObjectResult<{
|
|
79
|
-
isCompanion: import("fefe").Validator<false, import("fefe").FefeError>;
|
|
80
|
-
}> | import("fefe").ObjectResult<{
|
|
81
|
-
isCompanion: import("fefe").Validator<true, import("fefe").FefeError>;
|
|
82
|
-
mainGuestId: import("fefe").Validator<string, import("fefe").LeafError>;
|
|
83
|
-
}>, import("fefe").LeafError>;
|
|
84
|
-
payment: import("fefe").Validator<import("fefe").ObjectResult<{
|
|
85
|
-
paid: import("fefe").Validator<boolean, import("fefe").LeafError>;
|
|
86
|
-
provider: import("fefe").Validator<"credit" | "paypal", import("fefe").LeafError>;
|
|
87
|
-
amount: import("fefe").Validator<number, import("fefe").LeafError>;
|
|
88
|
-
testmode: import("fefe").Validator<boolean, import("fefe").LeafError>;
|
|
89
|
-
}> | null, import("fefe").FefeError>;
|
|
90
|
-
deleted: import("fefe").Validator<boolean, import("fefe").FefeError>;
|
|
91
|
-
}>, import("fefe").FefeError>;
|
|
92
|
-
declare type RawAttendee = ValidatorReturnType<typeof rawAttendee>;
|
|
93
|
-
export declare const parseAttendee: (value: unknown) => APIResult<Attendee>;
|
|
94
|
-
export declare const parseAttendeeList: (value: unknown) => APIResult<Attendee[]>;
|
|
95
|
-
export {};
|
package/dist/models/attendee.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { apiValidator, success } from '../lib';
|
|
3
|
-
import { Checkins, checkins } from './checkins';
|
|
4
|
-
import { rawFieldValue } from './field-value';
|
|
5
|
-
import { maybe, dictionary, constant } from './_helpers';
|
|
1
|
+
import { Checkins } from './checkins';
|
|
6
2
|
export class Attendee {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.checkin = rawAttendee.checkin;
|
|
16
|
-
this.companions = rawAttendee.companions;
|
|
17
|
-
this.payment = rawAttendee.payment;
|
|
18
|
-
this.deleted = rawAttendee.deleted;
|
|
19
|
-
}
|
|
3
|
+
userdata = {};
|
|
4
|
+
tags = [];
|
|
5
|
+
rsvp = {};
|
|
6
|
+
checkin = {};
|
|
7
|
+
companions = {
|
|
8
|
+
isCompanion: false
|
|
9
|
+
};
|
|
10
|
+
deleted = false;
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
constructor(args) {
|
|
13
|
+
if (typeof args === 'string') {
|
|
14
|
+
this.id = args;
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const json = args;
|
|
19
|
+
this.id = json.id;
|
|
20
|
+
this.userdata = json.userdata;
|
|
21
|
+
this.tags = json.tags;
|
|
22
|
+
this.language = json.language;
|
|
23
|
+
this.time = json.time ? new Date(json.time) : undefined;
|
|
24
|
+
this.rsvp = json.rsvp;
|
|
25
|
+
this.checkin = Object.fromEntries(new Map(Object.entries(json.checkin).map(([checkinTag, checkin]) => [checkinTag, new Checkins(checkin)])));
|
|
26
|
+
this.companions = json.companions;
|
|
27
|
+
this.payment = json.payment;
|
|
28
|
+
this.deleted = json.deleted;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
toJSON() {
|
|
@@ -34,12 +33,9 @@ export class Attendee {
|
|
|
34
33
|
// but then typescript complains that there is no toJSON function
|
|
35
34
|
// so we implement it here again by hand
|
|
36
35
|
// convert each checkin to its json representation
|
|
37
|
-
const checkin = Object.entries(this.checkin).
|
|
38
|
-
obj[tag] = checkins.toJSON();
|
|
39
|
-
return obj;
|
|
40
|
-
}, {});
|
|
36
|
+
const checkin = Object.fromEntries(new Map(Object.entries(this.checkin).map(([checkinTag, checkin]) => [checkinTag, checkin.toJSON()])));
|
|
41
37
|
return { ...this,
|
|
42
|
-
time: this.time
|
|
38
|
+
time: this.time?.toISOString(),
|
|
43
39
|
checkin
|
|
44
40
|
};
|
|
45
41
|
}
|
|
@@ -71,16 +67,14 @@ export class Attendee {
|
|
|
71
67
|
|
|
72
68
|
addCheckinForTag(args) {
|
|
73
69
|
const exsitingCheckins = this.getCheckinsForTag(args.checkinTag);
|
|
74
|
-
const newCheckins = new Checkins(
|
|
75
|
-
|
|
76
|
-
deleted: []
|
|
77
|
-
});
|
|
70
|
+
const newCheckins = new Checkins();
|
|
71
|
+
newCheckins.checkins = [args.checkin];
|
|
78
72
|
const mergedCheckins = exsitingCheckins.merge(newCheckins);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
const newAttendee = new Attendee(this.toJSON());
|
|
74
|
+
newAttendee.checkin = { ...this.checkin,
|
|
75
|
+
[args.checkinTag]: mergedCheckins
|
|
76
|
+
};
|
|
77
|
+
return newAttendee;
|
|
84
78
|
}
|
|
85
79
|
|
|
86
80
|
deleteCheckinForTag(args) {
|
|
@@ -90,55 +84,15 @@ export class Attendee {
|
|
|
90
84
|
deleted: [args.checkinId]
|
|
91
85
|
});
|
|
92
86
|
const mergedCheckins = exsitingCheckins.merge(deletedCheckins);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
const newAttendee = new Attendee(this.toJSON());
|
|
88
|
+
newAttendee.checkin = { ...this.checkin,
|
|
89
|
+
[args.checkinTag]: mergedCheckins
|
|
90
|
+
};
|
|
91
|
+
return newAttendee;
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
hasRsvp(args) {
|
|
101
95
|
return args.checkinTags.some(checkinTag => this.getResponseForTag(checkinTag) !== 'no-response');
|
|
102
96
|
}
|
|
103
97
|
|
|
104
|
-
}
|
|
105
|
-
export const rawAttendee = object({
|
|
106
|
-
id: string(),
|
|
107
|
-
auth: maybe(string()),
|
|
108
|
-
userdata: dictionary(rawFieldValue),
|
|
109
|
-
tags: maybe(array(string())),
|
|
110
|
-
language: maybe(string()),
|
|
111
|
-
time: pipe(string()).pipe(parseDate({
|
|
112
|
-
iso: true
|
|
113
|
-
})),
|
|
114
|
-
rsvp: dictionary(maybe(number())),
|
|
115
|
-
checkin: dictionary(checkins),
|
|
116
|
-
companions: union(object({
|
|
117
|
-
isCompanion: constant(false)
|
|
118
|
-
}), object({
|
|
119
|
-
isCompanion: constant(true),
|
|
120
|
-
mainGuestId: string()
|
|
121
|
-
})),
|
|
122
|
-
payment: defaultTo(maybe(object({
|
|
123
|
-
paid: boolean(),
|
|
124
|
-
provider: enumerate('credit', 'paypal'),
|
|
125
|
-
amount: number({
|
|
126
|
-
integer: true
|
|
127
|
-
}),
|
|
128
|
-
testmode: boolean()
|
|
129
|
-
})), null),
|
|
130
|
-
deleted: defaultTo(boolean(), false)
|
|
131
|
-
}, {
|
|
132
|
-
allowExcessProperties: true
|
|
133
|
-
});
|
|
134
|
-
const rawAttendeeList = array(rawAttendee);
|
|
135
|
-
export const parseAttendee = value => {
|
|
136
|
-
const result = apiValidator(rawAttendee)(value);
|
|
137
|
-
if (!result.success) return result;
|
|
138
|
-
return success(new Attendee(result.data));
|
|
139
|
-
};
|
|
140
|
-
export const parseAttendeeList = value => {
|
|
141
|
-
const result = apiValidator(rawAttendeeList)(value);
|
|
142
|
-
if (!result.success) return result;
|
|
143
|
-
return success(result.data.map(rawAttendee => new Attendee(rawAttendee)));
|
|
144
|
-
};
|
|
98
|
+
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}>>, import("fefe").FefeError>;
|
|
6
|
-
export declare type CheckinCounts = ValidatorReturnType<typeof checkinCounts>;
|
|
7
|
-
export declare const parseCheckinCounts: import("../lib").APIValidator<import("./_helpers").Dictionary<import("fefe").ObjectResult<{
|
|
8
|
-
checkins: import("fefe").Validator<number, import("fefe").LeafError>;
|
|
9
|
-
rsvp: import("fefe").Validator<number, import("fefe").LeafError>;
|
|
10
|
-
}>>>;
|
|
1
|
+
import { components } from '../generated/api-schema';
|
|
2
|
+
export declare type CheckinCounts = {
|
|
3
|
+
[checkinTag: string]: components['schemas']['CheckinCount'];
|
|
4
|
+
};
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { apiValidator } from '../lib';
|
|
3
|
-
import { dictionary } from './_helpers';
|
|
4
|
-
export const checkinCounts = dictionary(object({
|
|
5
|
-
checkins: number(),
|
|
6
|
-
rsvp: number()
|
|
7
|
-
}, {
|
|
8
|
-
allowExcessProperties: true
|
|
9
|
-
}));
|
|
10
|
-
export const parseCheckinCounts = apiValidator(checkinCounts);
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { components } from '../generated/api-schema';
|
|
2
|
+
export declare type CheckinJSON = components['schemas']['Checkin'];
|
|
3
|
+
export declare class Checkin {
|
|
4
|
+
id: string;
|
|
5
|
+
time: Date;
|
|
6
|
+
main: boolean;
|
|
7
|
+
constructor(json: CheckinJSON);
|
|
8
|
+
toJSON(): CheckinJSON;
|
|
9
|
+
}
|
|
@@ -1,41 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
time: Date;
|
|
5
|
-
main: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare type CheckinsJSON = {
|
|
8
|
-
checkins: {
|
|
9
|
-
id: string;
|
|
10
|
-
time: string;
|
|
11
|
-
main: boolean;
|
|
12
|
-
}[];
|
|
13
|
-
deleted: string[];
|
|
14
|
-
};
|
|
1
|
+
import { components } from '../generated/api-schema';
|
|
2
|
+
import { Checkin } from './checkin';
|
|
3
|
+
export declare type CheckinsJSON = components['schemas']['Checkins'];
|
|
15
4
|
export declare class Checkins {
|
|
16
5
|
checkins: Checkin[];
|
|
17
6
|
deleted: string[];
|
|
18
|
-
constructor(
|
|
19
|
-
static fromJSON(json: CheckinsJSON): Checkins;
|
|
7
|
+
constructor(json?: CheckinsJSON);
|
|
20
8
|
toJSON(): CheckinsJSON;
|
|
21
9
|
getAllCheckins(): Checkin[];
|
|
22
10
|
getOtherCheckins(): Checkin[];
|
|
23
11
|
getMainCheckin(): Checkin | undefined;
|
|
24
12
|
merge(otherCheckin: Checkins): Checkins;
|
|
25
13
|
}
|
|
26
|
-
export declare const checkin: import("fefe").Validator<import("fefe").ObjectResult<{
|
|
27
|
-
id: import("fefe").Validator<string, import("fefe").LeafError>;
|
|
28
|
-
time: import("fefe").Pipe<unknown, Date>;
|
|
29
|
-
main: import("fefe").Validator<boolean, import("fefe").LeafError>;
|
|
30
|
-
}>, import("fefe").FefeError>;
|
|
31
|
-
declare const rawCheckins: import("fefe").Validator<import("fefe").ObjectResult<{
|
|
32
|
-
checkins: import("fefe").Validator<import("fefe").ObjectResult<{
|
|
33
|
-
id: import("fefe").Validator<string, import("fefe").LeafError>;
|
|
34
|
-
time: import("fefe").Pipe<unknown, Date>;
|
|
35
|
-
main: import("fefe").Validator<boolean, import("fefe").LeafError>;
|
|
36
|
-
}>[], import("fefe").FefeError>;
|
|
37
|
-
deleted: import("fefe").Validator<string[], import("fefe").FefeError>;
|
|
38
|
-
}>, import("fefe").FefeError>;
|
|
39
|
-
declare type RawCheckins = ValidatorReturnType<typeof rawCheckins>;
|
|
40
|
-
export declare const checkins: (value: unknown) => FefeResult<Checkins>;
|
|
41
|
-
export {};
|
package/dist/models/checkins.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import { array, boolean, isFailure, object, parseDate, pipe, string, success as fefeSuccess } from 'fefe';
|
|
2
1
|
import { notUndefined } from '../lib';
|
|
2
|
+
import { Checkin } from './checkin';
|
|
3
3
|
export class Checkins {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.deleted = rawCheckins.deleted;
|
|
7
|
-
}
|
|
4
|
+
checkins = [];
|
|
5
|
+
deleted = [];
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
deleted: json.deleted
|
|
15
|
-
});
|
|
7
|
+
constructor(json) {
|
|
8
|
+
// if constructor is called without params use default values
|
|
9
|
+
if (!json) return;
|
|
10
|
+
this.checkins = json.checkins.map(checkinJSON => new Checkin(checkinJSON));
|
|
11
|
+
this.deleted = json.deleted;
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
toJSON() {
|
|
19
15
|
return {
|
|
20
|
-
checkins: this.checkins.map(checkin => (
|
|
21
|
-
id: checkin.id,
|
|
22
|
-
time: checkin.time.toISOString(),
|
|
23
|
-
main: checkin.main
|
|
24
|
-
})),
|
|
16
|
+
checkins: this.checkins.map(checkin => checkin.toJSON()),
|
|
25
17
|
deleted: this.deleted
|
|
26
18
|
};
|
|
27
19
|
}
|
|
@@ -43,30 +35,10 @@ export class Checkins {
|
|
|
43
35
|
merge(otherCheckin) {
|
|
44
36
|
const checkins = new Map([...this.checkins, ...otherCheckin.checkins].map(checkin => [checkin.id, checkin])).values();
|
|
45
37
|
const deleted = new Set([...this.deleted, ...otherCheckin.deleted]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
const newCheckins = new Checkins();
|
|
39
|
+
newCheckins.checkins = Array.from(checkins);
|
|
40
|
+
newCheckins.deleted = Array.from(deleted);
|
|
41
|
+
return newCheckins;
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
}
|
|
53
|
-
export const checkin = object({
|
|
54
|
-
id: string(),
|
|
55
|
-
time: pipe(string()).pipe(parseDate({
|
|
56
|
-
iso: true
|
|
57
|
-
})),
|
|
58
|
-
main: boolean()
|
|
59
|
-
}, {
|
|
60
|
-
allowExcessProperties: true
|
|
61
|
-
});
|
|
62
|
-
const rawCheckins = object({
|
|
63
|
-
checkins: array(checkin),
|
|
64
|
-
deleted: array(string())
|
|
65
|
-
}, {
|
|
66
|
-
allowExcessProperties: true
|
|
67
|
-
});
|
|
68
|
-
export const checkins = value => {
|
|
69
|
-
const result = rawCheckins(value);
|
|
70
|
-
if (isFailure(result)) return result;
|
|
71
|
-
return fefeSuccess(new Checkins(result.right));
|
|
72
|
-
};
|
|
44
|
+
}
|
package/dist/models/event.d.ts
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare type Event = {
|
|
4
|
-
id: string;
|
|
5
|
-
event: 'checkin-created';
|
|
6
|
-
instanceName: string;
|
|
7
|
-
attendeeId: string;
|
|
8
|
-
checkinTag: string;
|
|
9
|
-
checkin: Checkin;
|
|
10
|
-
} | {
|
|
11
|
-
id: string;
|
|
12
|
-
event: 'checkin-deleted';
|
|
13
|
-
instanceName: string;
|
|
14
|
-
attendeeId: string;
|
|
15
|
-
checkinTag: string;
|
|
16
|
-
checkinId: string;
|
|
17
|
-
} | {
|
|
18
|
-
id: string;
|
|
19
|
-
event: 'attendee-created';
|
|
20
|
-
instanceName: string;
|
|
21
|
-
attendee: AttendeeJSON;
|
|
22
|
-
} | {
|
|
23
|
-
id: string;
|
|
24
|
-
event: 'attendee-updated';
|
|
25
|
-
instanceName: string;
|
|
26
|
-
attendeeId: string;
|
|
27
|
-
updates: Partial<Omit<AttendeeJSON, 'id' | 'checkin'>>;
|
|
28
|
-
} | {
|
|
29
|
-
id: string;
|
|
30
|
-
event: 'attendee-responded';
|
|
31
|
-
instanceName: string;
|
|
32
|
-
attendeeId: string;
|
|
33
|
-
rsvp: Record<string, number | null>;
|
|
34
|
-
isEdit?: boolean;
|
|
35
|
-
} | {
|
|
36
|
-
id: string;
|
|
37
|
-
event: 'payment-paid';
|
|
38
|
-
instanceName: string;
|
|
39
|
-
attendeeId: string;
|
|
40
|
-
};
|
|
1
|
+
import { components } from '../generated/api-schema';
|
|
2
|
+
export declare type Event = components['schemas']['EventList'][number];
|