-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.js
More file actions
208 lines (187 loc) · 5.57 KB
/
Copy pathinterface.js
File metadata and controls
208 lines (187 loc) · 5.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**
* @typedef {Object} RideMessage
* @property {number} messageId
* @property {number} chatId
* @property {number} [messageThreadId]
* @property {string} [language]
* @property {boolean} [isForCreator]
*/
/**
* @typedef {Object} RideRoute
* @property {string} url
* @property {string} [label]
*/
/**
* @typedef {Object} RideSettings
* @property {boolean} notifyParticipation
* @property {boolean} allowReposts
*/
/**
* @typedef {Object} Ride
* @property {string} id
* @property {RideMessage[]} messages
* @property {string} title
* @property {string} [category]
* @property {string} [organizer]
* @property {Date} date
* @property {RideRoute[]} [routes]
* @property {string} [routeLink]
* @property {string} [meetingPoint]
* @property {number} [distance]
* @property {number} [duration]
* @property {number} [speedMin]
* @property {number} [speedMax]
* @property {number} [cruisingSpeedMin]
* @property {number} [cruisingSpeedMax]
* @property {string} [additionalInfo]
* @property {boolean} [cancelled]
* @property {RideSettings} [settings]
* @property {number} [groupId] - Telegram chat ID of the attached group
* @property {Object} [metadata] - Arbitrary metadata (e.g. { stravaId: '123' })
* @property {Participation} participation - User participation in different states
* @property {Date} createdAt
* @property {number} createdBy
* @property {Date} [updatedAt]
* @property {number} [updatedBy]
*/
/**
* @typedef {Object} Participant
* @property {number} userId
* @property {string} [username]
* @property {string} [firstName]
* @property {string} [lastName]
* @property {Date} createdAt
*/
/**
* @typedef {Object} Participation
* @property {Participant[]} joined - Users who have joined the ride
* @property {Participant[]} thinking - Users who are thinking about joining
* @property {Participant[]} skipped - Users who have skipped the ride
*/
/**
* @typedef {Object} RidesList
* @property {number} total - Total number of rides
* @property {Array<Ride>} rides - Array of rides for current page
*/
/**
* @typedef {Object} UserSettings
* @property {Object} rideDefaults
* @property {boolean} rideDefaults.notifyParticipation
* @property {boolean} rideDefaults.allowReposts
* @property {'all'|'membership'} [participationNotificationLevel]
*/
/**
* @typedef {Object} UserEntity
* @property {number} userId
* @property {string} [username]
* @property {string} [firstName]
* @property {string} [lastName]
* @property {UserSettings} settings
* @property {Date} createdAt
* @property {Date} updatedAt
*/
export class StorageInterface {
/**
* Create a new ride
* @param {Omit<Ride, 'id' | 'createdAt'>} ride
* @returns {Promise<Ride>}
*/
async createRide(ride) {
throw new Error('Not implemented');
}
/**
* Update an existing ride
* @param {string} rideId
* @param {Partial<Omit<Ride, 'id' | 'createdAt'>>} updates
* @returns {Promise<Ride>}
*/
async updateRide(rideId, updates) {
throw new Error('Not implemented');
}
/**
* Get a ride by ID
* @param {string} rideId
* @returns {Promise<Ride>}
*/
async getRide(rideId) {
throw new Error('Not implemented');
}
/**
* Set user participation state for a ride
* @param {string} rideId - Ride ID
* @param {'joined'|'thinking'|'skipped'} state - Participation state
* @param {Participant} participantProfile - Participant data
* @returns {Promise<{ride: Ride}>} - Updated ride
*/
async setParticipation(rideId, state, participantProfile) {
throw new Error('Not implemented');
}
/**
* Get user's current participation state for a ride
* @param {string} rideId - Ride ID
* @param {number} userId - User ID
* @returns {Promise<'joined'|'thinking'|'skipped'|null>} - Current participation state or null if not found
*/
async getParticipation(rideId, userId) {
throw new Error('Not implemented');
}
/**
* Get all participants for a ride across all states
* @param {string} rideId - Ride ID
* @returns {Promise<Participation>} - All participation data
*/
async getAllParticipants(rideId) {
throw new Error('Not implemented');
}
/**
* Delete a ride and all its participants
* @param {string} rideId
* @returns {Promise<boolean>}
*/
async deleteRide(rideId) {
throw new Error('Not implemented');
}
/**
* Get rides created by user
* @param {number} userId - Creator's user ID
* @param {number} skip - Number of items to skip
* @param {number} limit - Maximum number of items to return
* @returns {Promise<RidesList>}
*/
async getRidesByCreator(userId, skip, limit) {
throw new Error('Not implemented');
}
/**
* Get a ride by its attached group ID
* @param {number} groupId - Telegram chat ID of the attached group
* @returns {Promise<Ride|null>}
*/
async getRideByGroupId(groupId) {
throw new Error('Not implemented');
}
/**
* Get a ride by Strava event ID and creator user ID
* @param {string} stravaId - Strava event ID string
* @param {number} createdBy - Creator's Telegram user ID
* @returns {Promise<Ride|null>}
*/
async getRideByStravaId(stravaId, createdBy) {
throw new Error('Not implemented');
}
/**
* Get a persisted user by Telegram user ID.
* @param {number} userId
* @returns {Promise<UserEntity|null>}
*/
async getUser(userId) {
throw new Error('Not implemented');
}
/**
* Create or update a persisted user record.
* @param {Partial<UserEntity> & { userId: number }} user
* @returns {Promise<UserEntity>}
*/
async upsertUser(user) {
throw new Error('Not implemented');
}
}