@tellescope/schema 0.0.10 → 0.0.14

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/src/schema.ts CHANGED
@@ -13,12 +13,16 @@ import {
13
13
  JSONType,
14
14
  CRUD,
15
15
  HTTPMethod,
16
+ SessionType,
17
+ UserIdentity,
16
18
  } from "@tellescope/types-utilities"
17
19
  import {
18
20
  EnduserSession,
19
- ConfiguredSession,
21
+ ChatRoom,
20
22
  JourneyState,
21
23
  UserSession,
24
+ AttendeeInfo,
25
+ MeetingStatus,
22
26
  } from "@tellescope/types-models"
23
27
 
24
28
  import {
@@ -57,6 +61,13 @@ import {
57
61
  listOfDisplayNameInfo,
58
62
  fileTypeValidator,
59
63
  fileSizeValidator,
64
+ meetingStatusValidator,
65
+ listOfAttendeesValidator,
66
+ meetingInfoValidator,
67
+ listOfUserIndentitiesValidator,
68
+ attendeeInfoValidator,
69
+ listOfObjectAnyFieldsValidator,
70
+ meetingsListValidator,
60
71
  } from "@tellescope/validation"
61
72
 
62
73
  import {
@@ -246,12 +257,23 @@ export type CustomActions = {
246
257
  { isAuthenticated: true, enduser: Enduser } | { isAuthenticated: false, enduser: null }
247
258
  >,
248
259
  refresh_session: CustomAction<{}, { enduser: Enduser, authToken: string }>,
260
+ generate_auth_token: CustomAction<{ id: string }, { authToken: string }>,
249
261
  logout: CustomAction<{ }, { }>,
250
262
  },
251
263
  users: {
252
264
  display_names: CustomAction<{ }, { fname: string, lname: string, id: string }[]>,
253
265
  refresh_session: CustomAction<{}, { user: UserSession, authToken: string }>,
254
- }
266
+ },
267
+ chat_rooms: {
268
+ join_room: CustomAction<{ id: string }, { room: ChatRoom }>,
269
+ },
270
+ meetings: {
271
+ start_meeting: CustomAction<{ }, { id: string, meeting: object, host: AttendeeInfo }>,
272
+ end_meeting: CustomAction<{ id: string }, { }>,
273
+ add_attendees_to_meeting: CustomAction<{ id: string, attendees: UserIdentity[] }, { }>,
274
+ my_meetings: CustomAction<{}, { id: string, updatedAt: string, status: MeetingStatus }[]>
275
+ attendee_info: CustomAction<{ id: string }, { attendee: AttendeeInfo, others: UserIdentity[] }>,
276
+ },
255
277
  }
256
278
 
257
279
  export type PublicActions = {
@@ -326,6 +348,9 @@ export const schema: SchemaV1 = {
326
348
  lname: {
327
349
  validator: nameValidator,
328
350
  },
351
+ dateOfBirth: {
352
+ validator: dateValidator,
353
+ },
329
354
  journeys: {
330
355
  validator: journeysValidator,
331
356
  dependencies: [
@@ -413,6 +438,14 @@ export const schema: SchemaV1 = {
413
438
  enduser: { validator: 'enduser' },
414
439
  } as any // todo: add enduser eventually, when validator defined
415
440
  },
441
+ generate_auth_token: {
442
+ op: "custom", access: 'create', method: "get",
443
+ name: 'Generate authToken',
444
+ path: '/generate-enduser-auth-token',
445
+ description: "Generates an authToken for use by an enduser. Useful for integrating a 3rd-party authentication process or creating a session for an enduser without a set password in Tellescope.",
446
+ parameters: { id: { validator: mongoIdStringValidator } },
447
+ returns: { authToken: { validator: stringValidator100 } },
448
+ },
416
449
  logout: {
417
450
  op: "custom", access: 'update', method: "post",
418
451
  name: 'Logout enduser',
@@ -835,8 +868,8 @@ export const schema: SchemaV1 = {
835
868
  },
836
869
  userIds: {
837
870
  validator: listOfMongoIdStringValidator,
838
- required: true,
839
871
  examples: [[PLACEHOLDER_ID]],
872
+ // required: true, // no longer required
840
873
  // add pull dependency for user deletion?
841
874
  },
842
875
  enduserIds: {
@@ -852,11 +885,31 @@ export const schema: SchemaV1 = {
852
885
  validator: mongoIdStringValidator,
853
886
  initializer: () => '',
854
887
  readonly: true,
855
- }
888
+ },
889
+ ticketId: {
890
+ validator: mongoIdStringValidator,
891
+ },
892
+ endedAt: {
893
+ validator: dateValidator,
894
+ },
895
+ tags: {
896
+ validator: listOfStringsValidator,
897
+ },
856
898
  },
857
899
  defaultActions: DEFAULT_OPERATIONS,
858
900
  enduserActions: { create: {}, read: {}, readMany: {} },
859
- customActions: {},
901
+ customActions: {
902
+ join_room: {
903
+ op: "custom", access: 'update', method: "post",
904
+ name: 'Join chat room',
905
+ path: '/join-chat-room',
906
+ description: "Allows a user to join a chat room with no other users, for use in accepting support chats.",
907
+ parameters: { id: { validator: mongoIdStringValidator } },
908
+ returns: {
909
+ room: { validator: 'Room' },
910
+ } as any // add room eventually, when validator defined
911
+ },
912
+ },
860
913
  },
861
914
  chats: {
862
915
  info: {
@@ -892,7 +945,7 @@ export const schema: SchemaV1 = {
892
945
  senderId: {
893
946
  validator: mongoIdStringValidator,
894
947
  readonly: true, // create a separate endpoint for storing enduser chats
895
- initializer: (a, s) => (s as UserSession).id ?? (s as EnduserSession).id,
948
+ initializer: (a, s) => s.id,
896
949
  examples: [PLACEHOLDER_ID],
897
950
  dependencies: [{ // can be userId or enduserId
898
951
  dependsOn: ['users', 'endusers'],
@@ -951,7 +1004,6 @@ export const schema: SchemaV1 = {
951
1004
  enduser: { validator: 'user' },
952
1005
  } as any // add enduser eventually, when validator defined
953
1006
  },
954
-
955
1007
  },
956
1008
  enduserActions: { display_names: {} },
957
1009
  fields: {
@@ -1129,9 +1181,11 @@ export const schema: SchemaV1 = {
1129
1181
  required: true,
1130
1182
  examples: [PLACEHOLDER_ID],
1131
1183
  },
1132
- closed: {
1133
- validator: booleanValidator,
1134
- initializer: () => false,
1184
+ chatRoomId: {
1185
+ validator: mongoIdStringValidator,
1186
+ },
1187
+ closedAt: {
1188
+ validator: dateValidator,
1135
1189
  },
1136
1190
  owner: {
1137
1191
  validator: mongoIdStringValidator,
@@ -1148,4 +1202,92 @@ export const schema: SchemaV1 = {
1148
1202
  },
1149
1203
  }
1150
1204
  },
1205
+ meetings: {
1206
+ info: {},
1207
+ constraints: {
1208
+ unique: [],
1209
+ relationship: [],
1210
+ },
1211
+ defaultActions: { },
1212
+ customActions: {
1213
+ start_meeting: {
1214
+ op: "custom", access: 'create', method: "post",
1215
+ name: 'Start Meeting',
1216
+ path: '/start-meeting',
1217
+ description: "Generates an video meeting room",
1218
+ parameters: { },
1219
+ returns: {
1220
+ id: {
1221
+ validator: mongoIdStringValidator,
1222
+ },
1223
+ meeting: {
1224
+ validator: objectAnyFieldsValidator,
1225
+ },
1226
+ host: {
1227
+ validator: attendeeInfoValidator,
1228
+ },
1229
+ },
1230
+ },
1231
+ end_meeting: {
1232
+ op: "custom", access: 'update', method: "post",
1233
+ name: "End Meeting",
1234
+ path: '/end-meeting',
1235
+ description: "Ends a video meeting",
1236
+ parameters: { id: { validator: mongoIdStringValidator } },
1237
+ returns: { },
1238
+ },
1239
+ add_attendees_to_meeting: {
1240
+ op: "custom", access: 'update', method: "post",
1241
+ name: 'Add Attendees to Meeting',
1242
+ path: '/add-attendees-to-meeting',
1243
+ description: "Adds other attendees to a meeting",
1244
+ parameters: {
1245
+ id: { validator: mongoIdStringValidator },
1246
+ attendees: { validator: listOfUserIndentitiesValidator },
1247
+ },
1248
+ returns: { },
1249
+ },
1250
+ attendee_info: {
1251
+ op: "custom", access: 'read', method: "get",
1252
+ name: 'Get attendee info for meeting',
1253
+ path: '/attendee-info',
1254
+ description: "Gets meeting info for the current user, and details about other attendees",
1255
+ parameters: {
1256
+ id: { validator: mongoIdStringValidator },
1257
+ },
1258
+ returns: {
1259
+ attendee: { validator: attendeeInfoValidator },
1260
+ others: { validator: listOfUserIndentitiesValidator },
1261
+ },
1262
+ },
1263
+ my_meetings: {
1264
+ op: "custom", access: 'read', method: "get",
1265
+ name: 'Get list of meetings',
1266
+ path: '/my-meetings',
1267
+ description: "Gets meetings for the current user.",
1268
+ parameters: {
1269
+ id: { validator: mongoIdStringValidator },
1270
+ },
1271
+ returns: { validator: meetingsListValidator },
1272
+ }
1273
+ },
1274
+ enduserActions: { my_meetings: {} },
1275
+ fields: {
1276
+ ...BuiltInFields,
1277
+ // all fields are updatable by custom endpoints only
1278
+ status: {
1279
+ validator: meetingStatusValidator,
1280
+ readonly: true,
1281
+ initializer: () => 'scheduled',
1282
+ },
1283
+ attendees: {
1284
+ validator: listOfAttendeesValidator,
1285
+ readonly: true,
1286
+ },
1287
+ meetingInfo: {
1288
+ validator: meetingInfoValidator,
1289
+ readonly: true
1290
+ }
1291
+ }
1292
+ },
1151
1293
  }