@iveri/contracts 0.148.0 → 0.150.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 CHANGED
@@ -322,6 +322,11 @@ Conduit's outbox.
322
322
  `UniboxAgents` under `@iveri/contracts/unibox`, so the inbox picks agents by name.
323
323
  - Version `0.139.0` adds a trainer's notes on a member: `GymTrainerNote`, `GymTrainerNotes`, `SaveGymTrainerNoteRequest`,
324
324
  `GymMyTrainerNote` and the `GymRefusal` member `not-their-trainer` under `@iveri/contracts/gym`.
325
+ - Version `0.150.0` adds polls on Ezo posts under `@iveri/contracts/social`: `SocialPoll`, `CreateSocialPollRequest`, `VoteSocialPollRequest`,
326
+ `poll` on `SocialPost` and on creating one, `SocialCaseEvidencePoll` on a case's evidence, and the poll refusals.
327
+ - Version `0.149.0` lets a gym member choose their numbered place in a class: `placeChoice` / `placeColumns` on
328
+ `GymRoom`, `GymSession` and `PublicGymSession`, `spotNumber` on the booking requests, `MoveGymBookingPlaceRequest`,
329
+ `GymSessionPlaces`, `GymMyBooking.canChangePlace` and the `GymRefusal` member `place-taken`.
325
330
  - Version `0.148.0` adds the `ClinicRefusal` member `beyond-booking-horizon`, for a date past how far ahead a clinic
326
331
  takes bookings.
327
332
  - Version `0.146.0` adds the Unibox AI agent's daily token cap (`AiAgentSetting.dailyTokenCap`,
@@ -103,6 +103,8 @@ export interface GymMyBooking {
103
103
  waitlistPosition: Nullable<number>;
104
104
  session: PublicGymSession;
105
105
  canCancel: boolean;
106
+ /** A confirmed place in a class whose room lets members choose, before it starts: it can move to a free one. */
107
+ canChangePlace: boolean;
106
108
  /** Cancelling now would keep what the booking cost. */
107
109
  isLateCancel: boolean;
108
110
  /**
@@ -99,6 +99,10 @@ export interface PublicGymSession {
99
99
  startsAt: IsoDateTime;
100
100
  endsAt: IsoDateTime;
101
101
  capacity: number;
102
+ /** The room lets members choose their numbered place. */
103
+ placeChoice: boolean;
104
+ /** Places per row, to draw the room as a grid; null draws a plain list. */
105
+ placeColumns: Nullable<number>;
102
106
  placesLeft: number;
103
107
  waitlistCount: number;
104
108
  }
@@ -56,5 +56,10 @@ export declare enum GymRefusal {
56
56
  * Only a trainer who has a personal session with the member (booked, attended or missed) writes notes about them;
57
57
  * the screen was stale, for example the only session was called off.
58
58
  */
59
- NOT_THEIR_TRAINER = "not-their-trainer"
59
+ NOT_THEIR_TRAINER = "not-their-trainer",
60
+ /**
61
+ * Somebody else holds that numbered place in the class (or took it a moment ago). The member or the desk picks
62
+ * another; the class itself may still have room.
63
+ */
64
+ PLACE_TAKEN = "place-taken"
60
65
  }
@@ -58,4 +58,9 @@ export var GymRefusal;
58
58
  * the screen was stale, for example the only session was called off.
59
59
  */
60
60
  GymRefusal["NOT_THEIR_TRAINER"] = "not-their-trainer";
61
+ /**
62
+ * Somebody else holds that numbered place in the class (or took it a moment ago). The member or the desk picks
63
+ * another; the class itself may still have room.
64
+ */
65
+ GymRefusal["PLACE_TAKEN"] = "place-taken";
61
66
  })(GymRefusal || (GymRefusal = {}));
@@ -1,4 +1,5 @@
1
1
  import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
+ import type { Nullable } from '../../type/nil.type.js';
2
3
  import type { UUID } from '../../type/uuid.type.js';
3
4
  import type { LocalizedText } from '../clinic/localized-text.type.js';
4
5
  import type { GymResourceStatus } from './gym-resource-status.enum.js';
@@ -9,6 +10,13 @@ export interface GymRoom {
9
10
  capacity: number;
10
11
  /** An open area like the gym floor, where two sessions can run at once. */
11
12
  isShared: boolean;
13
+ /**
14
+ * Members choose which numbered place they get when they book a class here (bikes, mats, reformers). Off, the
15
+ * lowest free place is given, as it always was.
16
+ */
17
+ placeChoice: boolean;
18
+ /** How many places stand in one row, to draw the room as a grid; null draws them as a plain list. */
19
+ placeColumns: Nullable<number>;
12
20
  status: GymResourceStatus;
13
21
  createdAt: IsoDateTime;
14
22
  updatedAt: IsoDateTime;
@@ -18,10 +26,15 @@ export interface CreateGymRoomRequest {
18
26
  name: LocalizedText;
19
27
  capacity: number;
20
28
  isShared?: boolean;
29
+ placeChoice?: boolean;
30
+ /** 1 to 20. */
31
+ placeColumns?: Nullable<number>;
21
32
  }
22
33
  export interface UpdateGymRoomRequest {
23
34
  name?: LocalizedText;
24
35
  capacity?: number;
25
36
  isShared?: boolean;
37
+ placeChoice?: boolean;
38
+ placeColumns?: Nullable<number>;
26
39
  status?: GymResourceStatus;
27
40
  }
@@ -58,6 +58,10 @@ export interface GymSession {
58
58
  startsAt: IsoDateTime;
59
59
  endsAt: IsoDateTime;
60
60
  capacity: number;
61
+ /** The room lets members choose their numbered place; always false for personal training. */
62
+ placeChoice: boolean;
63
+ /** The room's places per row, to draw it as a grid; null draws a plain list. */
64
+ placeColumns: Nullable<number>;
61
65
  bookedCount: number;
62
66
  waitlistCount: number;
63
67
  status: GymSessionStatus;
@@ -130,6 +134,34 @@ export interface CreateGymPersonalSessionRequest {
130
134
  }
131
135
  export interface CreateGymBookingRequest {
132
136
  memberId: UUID;
137
+ /**
138
+ * The place to give, where the room lets members choose (`placeChoice`). Omitted, the lowest free place is given.
139
+ * A place somebody holds is refused with `GymRefusal.PLACE_TAKEN`.
140
+ */
141
+ spotNumber?: number;
142
+ }
143
+ /** A member taking a place in a class. Both fields are optional; a body is not needed at all. */
144
+ export interface BookMyGymSessionRequest {
145
+ /** As `CreateGymBookingRequest.spotNumber`; ignored where the room gives places itself. */
146
+ spotNumber?: number;
147
+ }
148
+ /** Moving a confirmed place to another free one in the same class, before it starts. */
149
+ export interface MoveGymBookingPlaceRequest {
150
+ spotNumber: number;
151
+ }
152
+ /**
153
+ * Which places of a class are taken, for a member choosing one. It names nobody: only the numbers, and which one is the
154
+ * reader's own.
155
+ */
156
+ export interface GymSessionPlaces {
157
+ sessionId: UUID;
158
+ placeChoice: boolean;
159
+ capacity: number;
160
+ placeColumns: Nullable<number>;
161
+ /** Every place held by somebody else, ascending. */
162
+ takenSpotNumbers: number[];
163
+ /** The reader's own place, or null when they hold none. */
164
+ mySpotNumber: Nullable<number>;
133
165
  }
134
166
  export interface SetGymAttendanceRequest {
135
167
  status: GymBookingStatus.ATTENDED | GymBookingStatus.NO_SHOW;
@@ -13,6 +13,7 @@ export * from './social-member-status.enum.js';
13
13
  export * from './social-member.type.js';
14
14
  export * from './social-moderation-reason.enum.js';
15
15
  export * from './social-moderation.type.js';
16
+ export * from './social-poll.type.js';
16
17
  export * from './social-post.type.js';
17
18
  export * from './social-refusal.enum.js';
18
19
  export * from './social-report-reason.enum.js';
@@ -13,6 +13,7 @@ export * from './social-member-status.enum.js';
13
13
  export * from './social-member.type.js';
14
14
  export * from './social-moderation-reason.enum.js';
15
15
  export * from './social-moderation.type.js';
16
+ export * from './social-poll.type.js';
16
17
  export * from './social-post.type.js';
17
18
  export * from './social-refusal.enum.js';
18
19
  export * from './social-report-reason.enum.js';
@@ -17,6 +17,14 @@ export declare const SOCIAL_LIMITS: {
17
17
  readonly VIDEO_BYTES_MAX: number;
18
18
  /** A longer video is refused, never cut short. */
19
19
  readonly VIDEO_SECONDS_MAX: 60;
20
+ readonly POLL_QUESTION_MAX: 140;
21
+ readonly POLL_OPTION_MAX: 80;
22
+ readonly POLL_OPTIONS_MIN: 2;
23
+ readonly POLL_OPTIONS_MAX: 4;
24
+ readonly POLL_HOURS_MIN: 1;
25
+ /** Seven days. */
26
+ readonly POLL_HOURS_MAX: 168;
27
+ readonly POLL_HOURS_DEFAULT: 24;
20
28
  readonly MINIMUM_AGE: 16;
21
29
  };
22
30
  /** The characters a handle may use, in the form they are stored. */
@@ -17,6 +17,14 @@ export const SOCIAL_LIMITS = {
17
17
  VIDEO_BYTES_MAX: 100 * 1024 * 1024,
18
18
  /** A longer video is refused, never cut short. */
19
19
  VIDEO_SECONDS_MAX: 60,
20
+ POLL_QUESTION_MAX: 140,
21
+ POLL_OPTION_MAX: 80,
22
+ POLL_OPTIONS_MIN: 2,
23
+ POLL_OPTIONS_MAX: 4,
24
+ POLL_HOURS_MIN: 1,
25
+ /** Seven days. */
26
+ POLL_HOURS_MAX: 168,
27
+ POLL_HOURS_DEFAULT: 24,
20
28
  MINIMUM_AGE: 16,
21
29
  };
22
30
  /** The characters a handle may use, in the form they are stored. */
@@ -38,8 +38,14 @@ export interface SocialCaseEvidence {
38
38
  imageUrls: string[];
39
39
  /** A reported video's poster only. Playing it goes through `SocialCaseVideoView`, which is logged. */
40
40
  videos: SocialCaseVideo[];
41
+ /** A reported post's poll, its question and answers. How anybody voted is not part of a case. */
42
+ poll: Nullable<SocialCaseEvidencePoll>;
41
43
  createdAt: Nullable<IsoDateTime>;
42
44
  }
45
+ export interface SocialCaseEvidencePoll {
46
+ question: string;
47
+ options: string[];
48
+ }
43
49
  export interface SocialCaseVideo {
44
50
  id: UUID;
45
51
  state: SocialVideoState;
@@ -0,0 +1,47 @@
1
+ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
+ import type { Nullable } from '../../type/nil.type.js';
3
+ import type { UUID } from '../../type/uuid.type.js';
4
+ /**
5
+ * One answer a poll offers.
6
+ *
7
+ * `voteCount` and `percent` are null while the viewer may not see results yet: before they have voted,
8
+ * while the poll is open, unless it is their own. `percent` is a whole number and the options of one poll
9
+ * add up to 100 (or all read 0 when nobody voted), so every client shows the same figures.
10
+ */
11
+ export interface SocialPollOption {
12
+ id: UUID;
13
+ text: string;
14
+ voteCount: Nullable<number>;
15
+ percent: Nullable<number>;
16
+ }
17
+ /**
18
+ * A question with two to four answers, attached to a post.
19
+ *
20
+ * A vote is anonymous to everybody, the author included, and final once cast. Nobody is ever told who
21
+ * voted for what; the author sees only the totals.
22
+ */
23
+ export interface SocialPoll {
24
+ id: UUID;
25
+ question: string;
26
+ options: SocialPollOption[];
27
+ closesAt: IsoDateTime;
28
+ isClosed: boolean;
29
+ /** Null while results are hidden from this viewer, as on the options. */
30
+ totalVotes: Nullable<number>;
31
+ /** The option this viewer chose, or null. Only ever their own. */
32
+ viewerOptionId: Nullable<UUID>;
33
+ /** The poll is open, not the viewer's own, and they have not voted yet. */
34
+ canVote: boolean;
35
+ resultsVisible: boolean;
36
+ }
37
+ /** A poll as it is posted. It cannot be changed afterwards. */
38
+ export interface CreateSocialPollRequest {
39
+ question: string;
40
+ /** Two to four answers, each different from the others. */
41
+ options: string[];
42
+ /** How long it stays open, in whole hours. A day when left out. */
43
+ durationHours?: number;
44
+ }
45
+ export interface VoteSocialPollRequest {
46
+ optionId: UUID;
47
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -3,6 +3,7 @@ import type { Nullable } from '../../type/nil.type.js';
3
3
  import type { UUID } from '../../type/uuid.type.js';
4
4
  import type { SocialImage } from './social-image.type.js';
5
5
  import type { SocialMemberCard } from './social-member.type.js';
6
+ import type { CreateSocialPollRequest, SocialPoll } from './social-poll.type.js';
6
7
  import type { SocialVideo } from './social-video.type.js';
7
8
  export interface SocialPost {
8
9
  id: UUID;
@@ -11,6 +12,8 @@ export interface SocialPost {
11
12
  images: SocialImage[];
12
13
  /** A post carries photographs or one video, never both. */
13
14
  video: Nullable<SocialVideo>;
15
+ /** A post with a poll carries no photograph or video. */
16
+ poll: Nullable<SocialPoll>;
14
17
  commentsDisabled: boolean;
15
18
  likeCount: number;
16
19
  commentCount: number;
@@ -28,8 +31,11 @@ export interface CreateSocialPostMedia {
28
31
  export interface CreateSocialPostRequest {
29
32
  caption?: Nullable<string>;
30
33
  media?: CreateSocialPostMedia[];
34
+ /** Words may go with a poll; photographs and a video may not. */
35
+ poll?: Nullable<CreateSocialPollRequest>;
31
36
  commentsDisabled?: boolean;
32
37
  }
38
+ /** A poll is fixed once posted, so an edit cannot reach it. */
33
39
  export interface UpdateSocialPostRequest {
34
40
  caption?: Nullable<string>;
35
41
  commentsDisabled?: boolean;
@@ -28,6 +28,14 @@ export declare enum SocialRefusal {
28
28
  /** A post carries photographs or one video, never both and never two videos. */
29
29
  POST_MEDIA_MIXED = "post-media-mixed",
30
30
  POST_EMPTY = "post-empty",
31
+ /** A post with a poll carries words at most, never a photograph or a video. */
32
+ POLL_WITH_MEDIA = "poll-with-media",
33
+ /** The poll has closed, so it takes no more votes. */
34
+ POLL_CLOSED = "poll-closed",
35
+ /** A vote is final: this member already chose another answer. */
36
+ POLL_ALREADY_VOTED = "poll-already-voted",
37
+ /** Nobody votes in their own poll. */
38
+ POLL_OWN = "poll-own",
31
39
  COMMENTS_DISABLED = "comments-disabled",
32
40
  CANNOT_FOLLOW_SELF = "cannot-follow-self",
33
41
  CANNOT_MESSAGE = "cannot-message",
@@ -29,6 +29,14 @@ export var SocialRefusal;
29
29
  /** A post carries photographs or one video, never both and never two videos. */
30
30
  SocialRefusal["POST_MEDIA_MIXED"] = "post-media-mixed";
31
31
  SocialRefusal["POST_EMPTY"] = "post-empty";
32
+ /** A post with a poll carries words at most, never a photograph or a video. */
33
+ SocialRefusal["POLL_WITH_MEDIA"] = "poll-with-media";
34
+ /** The poll has closed, so it takes no more votes. */
35
+ SocialRefusal["POLL_CLOSED"] = "poll-closed";
36
+ /** A vote is final: this member already chose another answer. */
37
+ SocialRefusal["POLL_ALREADY_VOTED"] = "poll-already-voted";
38
+ /** Nobody votes in their own poll. */
39
+ SocialRefusal["POLL_OWN"] = "poll-own";
32
40
  SocialRefusal["COMMENTS_DISABLED"] = "comments-disabled";
33
41
  SocialRefusal["CANNOT_FOLLOW_SELF"] = "cannot-follow-self";
34
42
  SocialRefusal["CANNOT_MESSAGE"] = "cannot-message";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iveri/contracts",
3
- "version": "0.148.0",
3
+ "version": "0.150.0",
4
4
  "description": "Wire contracts shared by every Iveri backend and frontend. Zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "repository": {