@dev-crew-berlin/enter-js-utils 0.82.1 → 0.83.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/dist/models/attendee.d.ts +2 -0
- package/dist/models/attendee.js +35 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { Checkin } from './checkin';
|
|
|
3
3
|
import { Checkins } from './checkins';
|
|
4
4
|
import { FieldValue } from './field-value';
|
|
5
5
|
import { Rsvp } from './rsvp';
|
|
6
|
+
import { AttendeeUpdatedEvent } from './event';
|
|
6
7
|
export type AttendeeJSON = components['schemas']['PublicAttendee-Output'];
|
|
7
8
|
type AttendeeJSONInput = components['schemas']['PublicAttendee-Input'];
|
|
8
9
|
export declare class Attendee {
|
|
@@ -51,6 +52,7 @@ export declare class Attendee {
|
|
|
51
52
|
branchName: string;
|
|
52
53
|
checkinId: string;
|
|
53
54
|
}): Attendee;
|
|
55
|
+
withUpdates(updates: AttendeeUpdatedEvent['updates']): Attendee;
|
|
54
56
|
getFieldValueString(fieldKey: string): string;
|
|
55
57
|
}
|
|
56
58
|
export {};
|
package/dist/models/attendee.js
CHANGED
|
@@ -124,6 +124,41 @@ export class Attendee {
|
|
|
124
124
|
newAttendee.checkin.set(args.branchName, mergedCheckins);
|
|
125
125
|
return newAttendee;
|
|
126
126
|
}
|
|
127
|
+
withUpdates(updates) {
|
|
128
|
+
const newAttendee = new Attendee(this.toJSON());
|
|
129
|
+
if (updates.userdata) {
|
|
130
|
+
newAttendee.userdata = new Map([...this.userdata, ...Object.entries(updates.userdata)]);
|
|
131
|
+
}
|
|
132
|
+
if (updates.rsvp) {
|
|
133
|
+
const rsvpUpdates = Object.entries(updates.rsvp).map(([branchName, rsvpJSON]) => [branchName, rsvpJSON ? new Rsvp(rsvpJSON) : null]);
|
|
134
|
+
newAttendee.rsvp = new Map([...this.rsvp, ...rsvpUpdates]);
|
|
135
|
+
}
|
|
136
|
+
if (updates.tags) {
|
|
137
|
+
newAttendee.tags = this.tags.union(new Set(updates.tags));
|
|
138
|
+
}
|
|
139
|
+
if (updates.deletedTags) {
|
|
140
|
+
newAttendee.tags = newAttendee.tags.difference(new Set(updates.deletedTags));
|
|
141
|
+
}
|
|
142
|
+
if (updates.branches) {
|
|
143
|
+
newAttendee.branches = this.branches.union(new Set(updates.branches));
|
|
144
|
+
}
|
|
145
|
+
if (updates.deletedBranches) {
|
|
146
|
+
newAttendee.branches = newAttendee.branches.difference(new Set(updates.deletedBranches));
|
|
147
|
+
}
|
|
148
|
+
if (updates.companions) {
|
|
149
|
+
// TODO: updates.companions type is wrong
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
newAttendee.companions = updates.companions;
|
|
153
|
+
}
|
|
154
|
+
if (updates.language) {
|
|
155
|
+
newAttendee.language = updates.language;
|
|
156
|
+
}
|
|
157
|
+
if (updates.payment) {
|
|
158
|
+
newAttendee.payment = updates.payment;
|
|
159
|
+
}
|
|
160
|
+
return newAttendee;
|
|
161
|
+
}
|
|
127
162
|
getFieldValueString(fieldKey) {
|
|
128
163
|
const fieldValue = this.userdata.get(fieldKey);
|
|
129
164
|
return fieldValue?.toString() ?? '';
|