@dev-crew-berlin/enter-js-utils 0.70.1 → 0.70.2

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.
@@ -4,6 +4,7 @@ import { Checkins } from './checkins';
4
4
  import { FieldValue } from './field-value';
5
5
  import { Rsvp } from './rsvp';
6
6
  export declare type AttendeeJSON = components['schemas']['PublicAttendee-Output'];
7
+ declare type AttendeeJSONInput = components['schemas']['PublicAttendee-Input'];
7
8
  export declare class Attendee {
8
9
  id: string;
9
10
  userdata: Record<string, FieldValue>;
@@ -25,7 +26,7 @@ export declare class Attendee {
25
26
  testmode: boolean;
26
27
  } | null;
27
28
  deleted: boolean;
28
- constructor(args: AttendeeJSON | string);
29
+ constructor(args: AttendeeJSONInput | string);
29
30
  /**
30
31
  * creates a bse36 encoded uuid
31
32
  * we use base36 encoding because it is more human readable and also shorter
@@ -51,3 +52,4 @@ export declare class Attendee {
51
52
  checkinTags: string[];
52
53
  }): boolean;
53
54
  }
55
+ export {};
@@ -21,14 +21,19 @@ export class Attendee {
21
21
  const json = args;
22
22
  this.id = json.id;
23
23
  this.userdata = json.userdata;
24
- this.tags = json.tags;
24
+ this.tags = json.tags ?? [];
25
25
  this.language = json.language;
26
- this.time = new Date(json.time);
27
- this.rsvp = Object.fromEntries(new Map(Object.entries(json.rsvp).map(([checkinTag, rsvp]) => [checkinTag, rsvp ? new Rsvp(rsvp) : null])));
28
- this.checkin = Object.fromEntries(new Map(Object.entries(json.checkin).map(([checkinTag, checkin]) => [checkinTag, new Checkins(checkin)])));
29
- this.companions = json.companions;
30
- this.payment = json.payment;
31
- this.deleted = json.deleted;
26
+ this.time = json.time ? new Date(json.time) : new Date();
27
+ this.rsvp = Object.fromEntries(new Map(Object.entries(json.rsvp ?? {}).map(([checkinTag, rsvp]) => [checkinTag, rsvp ? new Rsvp(rsvp) : null])));
28
+ this.checkin = Object.fromEntries(new Map(Object.entries(json.checkin ?? {}).map(([checkinTag, checkin]) => [checkinTag, new Checkins(checkin)])));
29
+ this.companions = json.companions?.isCompanion ? {
30
+ isCompanion: true,
31
+ ...json.companions
32
+ } : {
33
+ isCompanion: false
34
+ };
35
+ this.payment = json.payment ?? null;
36
+ this.deleted = json.deleted ?? false;
32
37
  }
33
38
 
34
39
  /**
@@ -1,11 +1,13 @@
1
1
  import { components } from '../generated/api-schema';
2
2
  import { Checkin } from './checkin';
3
3
  export declare type CheckinsJSON = components['schemas']['Checkins-Output'];
4
+ declare type CheckinsJSONInput = components['schemas']['Checkins-Input'];
4
5
  export declare class Checkins {
5
6
  checkins: Checkin[];
6
7
  deleted: string[];
7
- constructor(json?: CheckinsJSON);
8
+ constructor(json?: CheckinsJSONInput);
8
9
  toJSON(): CheckinsJSON;
9
10
  getActiveCheckins(): Checkin[];
10
11
  merge(otherCheckin: Checkins): Checkins;
11
12
  }
13
+ export {};
@@ -5,8 +5,8 @@ export class Checkins {
5
5
  constructor(json) {
6
6
  // if constructor is called without params use default values
7
7
  if (!json) return;
8
- this.checkins = json.checkins.map(checkinJSON => new Checkin(checkinJSON));
9
- this.deleted = json.deleted;
8
+ this.checkins = (json.checkins ?? []).map(checkinJSON => new Checkin(checkinJSON));
9
+ this.deleted = json.deleted ?? [];
10
10
  }
11
11
  toJSON() {
12
12
  return {
@@ -1,10 +1,11 @@
1
1
  import { components } from '../generated/api-schema';
2
2
  export declare type RsvpJSON = components['schemas']['RSVP-Output'];
3
+ export declare type RsvpJSONInput = components['schemas']['RSVP-Input'];
3
4
  export declare class Rsvp {
4
5
  tieBreaker: string;
5
6
  time: Date | null;
6
7
  personCount: number;
7
- constructor(args: RsvpJSON | number);
8
+ constructor(args: RsvpJSONInput | number);
8
9
  static confirm(personCount?: number): Rsvp;
9
10
  static decline(): Rsvp;
10
11
  get confirmed(): boolean;
@@ -7,7 +7,7 @@ export class Rsvp {
7
7
  this.personCount = args;
8
8
  return;
9
9
  }
10
- this.tieBreaker = args.tieBreaker;
10
+ this.tieBreaker = args.tieBreaker ?? uuidv4();
11
11
  this.time = args.time ? new Date(args.time) : null;
12
12
  this.personCount = args.personCount;
13
13
  }
@@ -17,7 +17,6 @@ const mainGuest = new Attendee({
17
17
  time: new Date('2022-01-01').toISOString(),
18
18
  rsvp: {
19
19
  default: {
20
- confirmed: true,
21
20
  personCount: 1,
22
21
  time: new Date('2022-01-01').toISOString(),
23
22
  tieBreaker: '1'
@@ -18,7 +18,6 @@ const attendee = new Attendee({
18
18
  time: new Date('2022-01-01').toISOString(),
19
19
  rsvp: {
20
20
  default: {
21
- confirmed: true,
22
21
  personCount: 1,
23
22
  time: new Date('2022-01-01').toISOString(),
24
23
  tieBreaker: '1'
@@ -41,7 +40,6 @@ const attendeeWithMultipleTags = new Attendee({
41
40
  time: new Date('2022-01-01').toISOString(),
42
41
  rsvp: {
43
42
  default: {
44
- confirmed: true,
45
43
  personCount: 1,
46
44
  time: new Date('2022-01-01').toISOString(),
47
45
  tieBreaker: '1'
@@ -64,7 +62,6 @@ const companion = new Attendee({
64
62
  time: new Date('2022-01-01').toISOString(),
65
63
  rsvp: {
66
64
  default: {
67
- confirmed: true,
68
65
  personCount: 1,
69
66
  time: new Date('2022-01-01').toISOString(),
70
67
  tieBreaker: '1'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-crew-berlin/enter-js-utils",
3
- "version": "0.70.1",
3
+ "version": "0.70.2",
4
4
  "description": "utils such as vaildation and other helpers to work with data from the enter app",
5
5
  "files": [
6
6
  "dist",