@tellescope/schema 1.2.3 → 1.3.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/src/schema.ts CHANGED
@@ -37,6 +37,9 @@ import {
37
37
  Enduser,
38
38
  Journey,
39
39
  FormResponse,
40
+ FormField,
41
+ Form,
42
+ Meeting,
40
43
  } from "@tellescope/types-client"
41
44
 
42
45
  import {
@@ -313,6 +316,11 @@ export type CustomActions = {
313
316
  form_responses: {
314
317
  prepare_form_response: CustomAction<{ formId: string, enduserId: string, automationStepId?: string }, { accessCode: string, url: string }>,
315
318
  submit_form_response: CustomAction<{ accessCode: string, responses: FormResponseValue[], automationStepId?: string }, { formResponse: FormResponse }>,
319
+ info_for_access_code: CustomAction<{ accessCode: string }, {
320
+ form: Form,
321
+ fields: FormField[],
322
+ response: FormResponse,
323
+ }>,
316
324
  },
317
325
  journeys: {
318
326
  update_state: CustomAction<{ updates: Partial<JourneyState>, id: string, name: string }, { updated: Journey }>,
@@ -336,6 +344,7 @@ export type CustomActions = {
336
344
  chat_rooms: {
337
345
  join_room: CustomAction<{ id: string }, { room: ChatRoom }>,
338
346
  display_info: CustomAction<{ id: string }, { id: string, display_info: { [index: string]: UserDisplayInfo } }>,
347
+ mark_read: CustomAction<{ id: string }, { updated: ChatRoom }>,
339
348
  },
340
349
  meetings: {
341
350
  start_meeting: CustomAction<{ attendees?: UserIdentity[], publicRead?: boolean }, { id: string, meeting: { Meeting: MeetingInfo }, host: Attendee }>,
@@ -344,6 +353,9 @@ export type CustomActions = {
344
353
  add_attendees_to_meeting: CustomAction<{ id: string, attendees: UserIdentity[] }, { }>,
345
354
  my_meetings: CustomAction<{}, { id: string, updatedAt: string, status: MeetingStatus }[]>
346
355
  attendee_info: CustomAction<{ id: string }, { attendee: Attendee, others: UserIdentity[] }>,
356
+ start_meeting_for_event: CustomAction<{ calendarEventId: string }, { id: string, meeting: { Meeting: MeetingInfo }, host: Attendee }>,
357
+ join_meeting_for_event: CustomAction<{ calendarEventId: string }, { meeting: { Meeting: MeetingInfo } }>,
358
+ read: CustomAction<{ id: string }, Meeting>,
347
359
  },
348
360
  webhooks: {
349
361
  configure: CustomAction<{ url: string, secret: string, subscriptions?: WebhookSubscriptionsType }, { }>,
@@ -358,7 +370,7 @@ export type CustomActions = {
358
370
  post_likes: {
359
371
  create: CustomAction<{ postId: string, forumId: string }, { }>,
360
372
  unlike_post: CustomAction<{ postId: string, forumId: string }, { }>,
361
- }
373
+ },
362
374
  }
363
375
 
364
376
  export type PublicActions = {
@@ -900,8 +912,9 @@ export const schema: SchemaV1 = build_schema({
900
912
  if (method === 'update') return
901
913
 
902
914
  const e = deps[enduserId ?? ''] as Enduser
915
+ if (!e) return // not in cache, permit by default, likely during an update
903
916
  if (!e?.email) return "Missing email"
904
- if (!e?.emailConsent) return "Missing email consent"
917
+ // if (!e?.emailConsent) return "Missing email consent"
905
918
  }
906
919
  }
907
920
  ],
@@ -1026,7 +1039,7 @@ export const schema: SchemaV1 = build_schema({
1026
1039
  const e = deps[enduserId ?? ''] as Enduser
1027
1040
  if (!e) return // not in cache, permit by default, likely during an update
1028
1041
  if (!e.phone) return "Missing phone"
1029
- if (!e.phoneConsent) return "Missing phone consent"
1042
+ // if (!e.phoneConsent) return "Missing phone consent"
1030
1043
  }
1031
1044
  }
1032
1045
  ],
@@ -1161,14 +1174,14 @@ export const schema: SchemaV1 = build_schema({
1161
1174
  validator: dateValidator,
1162
1175
  },
1163
1176
  tags: {
1164
- validator: listOfStringsValidator,
1177
+ validator: listOfStringsValidatorEmptyOk,
1165
1178
  },
1166
1179
  infoForUser: { // todo: access-permissions allow updates for self only (when non-admin)
1167
1180
  validator: chatRoomUserInfoValidator,
1168
1181
  }
1169
1182
  },
1170
1183
  defaultActions: DEFAULT_OPERATIONS,
1171
- enduserActions: { create: {}, read: {}, readMany: {}, display_info: {} },
1184
+ enduserActions: { create: {}, read: {}, readMany: {}, display_info: {}, mark_read: {} },
1172
1185
  customActions: {
1173
1186
  join_room: {
1174
1187
  op: "custom", access: 'update', method: "post",
@@ -1180,6 +1193,16 @@ export const schema: SchemaV1 = build_schema({
1180
1193
  room: { validator: 'Room' },
1181
1194
  } as any // add room eventually, when validator defined
1182
1195
  },
1196
+ mark_read: {
1197
+ op: "custom", access: 'update', method: "post",
1198
+ name: 'Mark Read',
1199
+ path: '/mark-chat-room-read',
1200
+ description: "Marks the conversation read by the authenticated user",
1201
+ parameters: { id: { validator: mongoIdStringValidator, required: true } },
1202
+ returns: {
1203
+ updated: { validator: 'Room' },
1204
+ } as any // add room eventually, when validator defined
1205
+ },
1183
1206
  display_info: {
1184
1207
  op: "custom", access: 'read', method: "get",
1185
1208
  name: 'Attendee display info',
@@ -1283,6 +1306,7 @@ export const schema: SchemaV1 = build_schema({
1283
1306
  }],
1284
1307
  },
1285
1308
  defaultActions: { read: {}, readMany: {}, update: { description: "Users can only be updated by self or an organization admin"} },
1309
+ enduserActions: { display_info: {}, read: {}, readMany: {} },
1286
1310
  customActions: {
1287
1311
  display_info: {
1288
1312
  op: "custom", access: 'read', method: "get",
@@ -1329,23 +1353,26 @@ export const schema: SchemaV1 = build_schema({
1329
1353
  returns: { },
1330
1354
  },
1331
1355
  },
1332
- enduserActions: { display_info: {} },
1333
1356
  fields: {
1334
1357
  ...BuiltInFields,
1335
1358
  email: {
1336
1359
  validator: emailValidator,
1337
1360
  required: true,
1338
- examples: ['test@tellescope.com']
1361
+ examples: ['test@tellescope.com'],
1362
+ redactions: ['enduser'],
1339
1363
  },
1340
1364
  phone: {
1341
1365
  validator: phoneValidator,
1366
+ redactions: ['enduser'],
1342
1367
  },
1343
1368
  fields: {
1344
1369
  validator: fieldsValidator,
1370
+ redactions: ['enduser'],
1345
1371
  },
1346
1372
  username: {
1347
1373
  validator: subdomainValidator,
1348
1374
  readonly: true, // able to set once, then not change (for now, due to email configuration)
1375
+ redactions: ['enduser'],
1349
1376
  },
1350
1377
  fname: {
1351
1378
  validator: nameValidator,
@@ -1367,6 +1394,7 @@ export const schema: SchemaV1 = build_schema({
1367
1394
  roles: {
1368
1395
  validator: listOfStringsValidator,
1369
1396
  updatesDisabled: true, // implement with separate endpoint with tight restrictions
1397
+ redactions: ['enduser'],
1370
1398
  },
1371
1399
  skills: {
1372
1400
  validator: listOfStringsValidator,
@@ -1374,9 +1402,11 @@ export const schema: SchemaV1 = build_schema({
1374
1402
  hashedPassword: {
1375
1403
  validator: stringValidator,
1376
1404
  readonly: true, // update via separate password reset function
1405
+ redactions: ['enduser'],
1377
1406
  },
1378
1407
  notificationPreferences: {
1379
1408
  validator: notificationPreferencesValidator,
1409
+ redactions: ['enduser'],
1380
1410
  },
1381
1411
  avatar: {
1382
1412
  validator: stringValidator100,
@@ -1591,6 +1621,9 @@ export const schema: SchemaV1 = build_schema({
1591
1621
  constraints: {
1592
1622
  unique: [],
1593
1623
  relationship: [],
1624
+ access: [
1625
+ { type: 'filter', field: 'attendees.id' },
1626
+ ]
1594
1627
  },
1595
1628
  defaultActions: {
1596
1629
  readMany: {
@@ -1598,7 +1631,16 @@ export const schema: SchemaV1 = build_schema({
1598
1631
  adminOnly: true,
1599
1632
  }
1600
1633
  },
1634
+ enduserActions: { my_meetings: {}, join_meeting_for_event: {}, read: {} },
1601
1635
  customActions: {
1636
+ read: {
1637
+ op: "read", access: 'read', method: "get",
1638
+ description: "Get a meeting",
1639
+ parameters: {
1640
+ id: { validator: mongoIdStringValidator },
1641
+ },
1642
+ returns: 'meeting' as any,
1643
+ },
1602
1644
  start_meeting: {
1603
1645
  op: "custom", access: 'create', method: "post",
1604
1646
  name: 'Start Meeting',
@@ -1664,9 +1706,36 @@ export const schema: SchemaV1 = build_schema({
1664
1706
  description: "Gets meetings for the current user.",
1665
1707
  parameters: {},
1666
1708
  returns: { validator: meetingsListValidator, required: true },
1667
- }
1709
+ },
1710
+ start_meeting_for_event: {
1711
+ op: "custom", access: 'create', method: "post",
1712
+ name: 'Start Scheduled Meeting',
1713
+ path: '/start-meeting-for-event',
1714
+ description: "Generates an video meeting room",
1715
+ parameters: {
1716
+ calendarEventId: { validator: mongoIdStringValidator, required: true },
1717
+ },
1718
+ returns: {
1719
+ id: { validator: mongoIdStringValidator, required: true },
1720
+ meeting: { validator: meetingInfoValidator, required: true },
1721
+ host: { validator: attendeeValidator, required: true },
1722
+ },
1723
+ },
1724
+ join_meeting_for_event: {
1725
+ op: "custom", access: 'update', method: "post",
1726
+ name: 'Join Scheduled Meeting',
1727
+ path: '/join-meeting-for-event',
1728
+ description: "Generates an video meeting room",
1729
+ parameters: {
1730
+ calendarEventId: { validator: mongoIdStringValidator, required: true },
1731
+ },
1732
+ returns: {
1733
+ id: { validator: mongoIdStringValidator, required: true },
1734
+ meeting: { validator: meetingInfoValidator, required: true },
1735
+ attendee: { validator: attendeeValidator, required: true },
1736
+ },
1737
+ },
1668
1738
  },
1669
- enduserActions: { my_meetings: {} },
1670
1739
  fields: {
1671
1740
  ...BuiltInFields,
1672
1741
  // all fields are updatable by custom endpoints only
@@ -1846,6 +1915,7 @@ export const schema: SchemaV1 = build_schema({
1846
1915
  responses: { validator: formResponsesValidator },
1847
1916
  },
1848
1917
  defaultActions: DEFAULT_OPERATIONS,
1918
+ enduserActions: { prepare_form_response: {}, info_for_access_code: {}, submit_form_response: {}, read: {}, readMany: {} },
1849
1919
  customActions: {
1850
1920
  prepare_form_response: {
1851
1921
  op: "custom", access: 'create', method: "post",
@@ -1875,7 +1945,21 @@ export const schema: SchemaV1 = build_schema({
1875
1945
  returns: {
1876
1946
  formResponse: 'form response' as any,
1877
1947
  },
1878
- }
1948
+ },
1949
+ info_for_access_code: {
1950
+ op: "custom", access: 'read', method: "get",
1951
+ name: 'Info for Access Code',
1952
+ path: '/form-info-for-access-code',
1953
+ description: "With an accessCode, retrieves the relevant info for submitting a form",
1954
+ parameters: {
1955
+ accessCode: { validator: stringValidator250, required: true },
1956
+ },
1957
+ returns: {
1958
+ form: 'form' as any,
1959
+ fields: 'form fields' as any,
1960
+ response: 'form response' as any,
1961
+ },
1962
+ },
1879
1963
  },
1880
1964
  publicActions: {
1881
1965
  session_for_public_form: {
@@ -1899,7 +1983,6 @@ export const schema: SchemaV1 = build_schema({
1899
1983
  },
1900
1984
  },
1901
1985
  },
1902
- enduserActions: { prepare_form_response: {}, submit_form_response: {} },
1903
1986
  },
1904
1987
  webhooks: {
1905
1988
  info: {
@@ -2029,7 +2112,23 @@ export const schema: SchemaV1 = build_schema({
2029
2112
  ]
2030
2113
  },
2031
2114
  defaultActions: DEFAULT_OPERATIONS,
2032
- customActions: {},
2115
+ customActions: {
2116
+ start_meeting: {
2117
+ op: "custom", access: 'create', method: "post",
2118
+ name: 'Start Meeting',
2119
+ path: '/start-meeting-for-event',
2120
+ description: "Generates an video meeting room",
2121
+ parameters: {
2122
+ attendees: { validator: listOfUserIndentitiesValidator },
2123
+ publicRead: { validator: booleanValidator },
2124
+ },
2125
+ returns: {
2126
+ id: { validator: mongoIdStringValidator, required: true },
2127
+ meeting: { validator: meetingInfoValidator, required: true },
2128
+ host: { validator: attendeeValidator, required: true },
2129
+ },
2130
+ },
2131
+ },
2033
2132
  enduserActions: { read: {}, readMany: {} },
2034
2133
  fields: {
2035
2134
  ...BuiltInFields,
@@ -2049,6 +2148,8 @@ export const schema: SchemaV1 = build_schema({
2049
2148
  required: true,
2050
2149
  },
2051
2150
  description: { validator: stringValidator5000 },
2151
+ meetingId: { validator: mongoIdStringValidator, readonly: true },
2152
+ meetingStatus: { validator: meetingStatusValidator },
2052
2153
  chatRoomId: {
2053
2154
  validator: mongoIdStringValidator,
2054
2155
  dependencies: [{
@@ -2067,6 +2168,7 @@ export const schema: SchemaV1 = build_schema({
2067
2168
  initializer: () => [],
2068
2169
  },
2069
2170
  publicRead: { validator: booleanValidator },
2171
+ enableVideoCall: { validator: booleanValidator },
2070
2172
  displayImage: { validator: stringValidator },
2071
2173
  fields: { validator: fieldsValidator },
2072
2174
  }
@@ -2409,9 +2511,10 @@ export const schema: SchemaV1 = build_schema({
2409
2511
  validator: stringValidator25000,
2410
2512
  examples: ["This is the template message......"],
2411
2513
  },
2514
+ publicRead: { validator: booleanValidator },
2412
2515
  mode: { validator: messageTemplateModeValidator, },
2413
2516
  files: { validator: listOfStringsValidator },
2414
- tags: { validator: listOfStringsValidator },
2517
+ tags: { validator: listOfStringsValidatorEmptyOk },
2415
2518
  }
2416
2519
  },
2417
2520
  forums: {
@@ -2473,6 +2576,11 @@ export const schema: SchemaV1 = build_schema({
2473
2576
  validator: nonNegNumberValidator,
2474
2577
  initializer: () => 0,
2475
2578
  },
2579
+ title: {
2580
+ validator: stringValidator5000,
2581
+ required: true,
2582
+ examples: ["This is the template message......"],
2583
+ },
2476
2584
  textContent: {
2477
2585
  validator: stringValidator25000,
2478
2586
  required: true,
@@ -2574,6 +2682,7 @@ export const schema: SchemaV1 = build_schema({
2574
2682
  access: [{ type: 'dependency', foreignModel: 'forums', foreignField: '_id', accessField: 'forumId' }]
2575
2683
  },
2576
2684
  defaultActions: { read: {}, readMany: {}, delete: {} }, // create is custom
2685
+ enduserActions: { create: {}, unlike_post: {}, readMany: {} },
2577
2686
  customActions: {
2578
2687
  create: {
2579
2688
  op: "custom", access: 'create', method: "post",
@@ -2598,7 +2707,6 @@ export const schema: SchemaV1 = build_schema({
2598
2707
  returns: { } //authToken: { validator: stringValidator5000 } },
2599
2708
  },
2600
2709
  },
2601
- enduserActions: { create: {}, unlike_post: {} },
2602
2710
  fields: {
2603
2711
  ...BuiltInFields,
2604
2712
  // creator: {