@tellescope/schema 1.2.4 → 1.3.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.
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 {
@@ -106,6 +109,8 @@ import {
106
109
  previousFormFieldsValidator,
107
110
  numberValidator,
108
111
  organizationThemeValidator,
112
+ managedContentRecordTypeValidator,
113
+ passwordValidator,
109
114
  } from "@tellescope/validation"
110
115
 
111
116
  import {
@@ -313,6 +318,11 @@ export type CustomActions = {
313
318
  form_responses: {
314
319
  prepare_form_response: CustomAction<{ formId: string, enduserId: string, automationStepId?: string }, { accessCode: string, url: string }>,
315
320
  submit_form_response: CustomAction<{ accessCode: string, responses: FormResponseValue[], automationStepId?: string }, { formResponse: FormResponse }>,
321
+ info_for_access_code: CustomAction<{ accessCode: string }, {
322
+ form: Form,
323
+ fields: FormField[],
324
+ response: FormResponse,
325
+ }>,
316
326
  },
317
327
  journeys: {
318
328
  update_state: CustomAction<{ updates: Partial<JourneyState>, id: string, name: string }, { updated: Journey }>,
@@ -336,6 +346,7 @@ export type CustomActions = {
336
346
  chat_rooms: {
337
347
  join_room: CustomAction<{ id: string }, { room: ChatRoom }>,
338
348
  display_info: CustomAction<{ id: string }, { id: string, display_info: { [index: string]: UserDisplayInfo } }>,
349
+ mark_read: CustomAction<{ id: string }, { updated: ChatRoom }>,
339
350
  },
340
351
  meetings: {
341
352
  start_meeting: CustomAction<{ attendees?: UserIdentity[], publicRead?: boolean }, { id: string, meeting: { Meeting: MeetingInfo }, host: Attendee }>,
@@ -344,6 +355,9 @@ export type CustomActions = {
344
355
  add_attendees_to_meeting: CustomAction<{ id: string, attendees: UserIdentity[] }, { }>,
345
356
  my_meetings: CustomAction<{}, { id: string, updatedAt: string, status: MeetingStatus }[]>
346
357
  attendee_info: CustomAction<{ id: string }, { attendee: Attendee, others: UserIdentity[] }>,
358
+ start_meeting_for_event: CustomAction<{ calendarEventId: string }, { id: string, meeting: { Meeting: MeetingInfo }, host: Attendee }>,
359
+ join_meeting_for_event: CustomAction<{ calendarEventId: string }, { meeting: { Meeting: MeetingInfo } }>,
360
+ read: CustomAction<{ id: string }, Meeting>,
347
361
  },
348
362
  webhooks: {
349
363
  configure: CustomAction<{ url: string, secret: string, subscriptions?: WebhookSubscriptionsType }, { }>,
@@ -358,7 +372,7 @@ export type CustomActions = {
358
372
  post_likes: {
359
373
  create: CustomAction<{ postId: string, forumId: string }, { }>,
360
374
  unlike_post: CustomAction<{ postId: string, forumId: string }, { }>,
361
- }
375
+ },
362
376
  }
363
377
 
364
378
  export type PublicActions = {
@@ -368,6 +382,8 @@ export type PublicActions = {
368
382
  { authToken: string }
369
383
  >,
370
384
  register: CustomAction<{ emailConsent?: boolean, fname?: string, lname?: string, email: string, password: string }, { }>,
385
+ request_password_reset: CustomAction<{ email: string, businessId: string }, { }>,
386
+ reset_password: CustomAction<{ resetToken: string, newPassword: string, businessId: string }, { }>,
371
387
  },
372
388
  users: {
373
389
  request_password_reset: CustomAction<{ email: string }, { }>,
@@ -647,8 +663,30 @@ export const schema: SchemaV1 = build_schema({
647
663
  password: { validator: stringValidator100, required: true },
648
664
  },
649
665
  returns: { } //authToken: { validator: stringValidator5000 } },
650
-
651
666
  },
667
+ request_password_reset: {
668
+ op: "custom", access: 'update', method: "post",
669
+ name: 'Request Password Reset',
670
+ path: '/request-enduser-password-reset',
671
+ description: "Sends a password reset email",
672
+ parameters: {
673
+ email: { validator: emailValidator, required: true },
674
+ businessId: { validator: mongoIdStringValidator, required: true },
675
+ },
676
+ returns: { },
677
+ },
678
+ reset_password: {
679
+ op: "custom", access: 'update', method: "post",
680
+ name: 'Reset Password',
681
+ path: '/reset-enduser-password',
682
+ description: "For a code generated by request-enduser-password-reset, sets a new password",
683
+ parameters: {
684
+ resetToken: { validator: stringValidator250, required: true },
685
+ newPassword: { validator: passwordValidator, required: true },
686
+ businessId: { validator: mongoIdStringValidator, required: true },
687
+ },
688
+ returns: { },
689
+ },
652
690
  },
653
691
  },
654
692
  enduser_status_updates: {
@@ -900,8 +938,9 @@ export const schema: SchemaV1 = build_schema({
900
938
  if (method === 'update') return
901
939
 
902
940
  const e = deps[enduserId ?? ''] as Enduser
941
+ if (!e) return // not in cache, permit by default, likely during an update
903
942
  if (!e?.email) return "Missing email"
904
- if (!e?.emailConsent) return "Missing email consent"
943
+ // if (!e?.emailConsent) return "Missing email consent"
905
944
  }
906
945
  }
907
946
  ],
@@ -1026,7 +1065,7 @@ export const schema: SchemaV1 = build_schema({
1026
1065
  const e = deps[enduserId ?? ''] as Enduser
1027
1066
  if (!e) return // not in cache, permit by default, likely during an update
1028
1067
  if (!e.phone) return "Missing phone"
1029
- if (!e.phoneConsent) return "Missing phone consent"
1068
+ // if (!e.phoneConsent) return "Missing phone consent"
1030
1069
  }
1031
1070
  }
1032
1071
  ],
@@ -1161,14 +1200,14 @@ export const schema: SchemaV1 = build_schema({
1161
1200
  validator: dateValidator,
1162
1201
  },
1163
1202
  tags: {
1164
- validator: listOfStringsValidator,
1203
+ validator: listOfStringsValidatorEmptyOk,
1165
1204
  },
1166
1205
  infoForUser: { // todo: access-permissions allow updates for self only (when non-admin)
1167
1206
  validator: chatRoomUserInfoValidator,
1168
1207
  }
1169
1208
  },
1170
1209
  defaultActions: DEFAULT_OPERATIONS,
1171
- enduserActions: { create: {}, read: {}, readMany: {}, display_info: {} },
1210
+ enduserActions: { create: {}, read: {}, readMany: {}, display_info: {}, mark_read: {} },
1172
1211
  customActions: {
1173
1212
  join_room: {
1174
1213
  op: "custom", access: 'update', method: "post",
@@ -1180,6 +1219,16 @@ export const schema: SchemaV1 = build_schema({
1180
1219
  room: { validator: 'Room' },
1181
1220
  } as any // add room eventually, when validator defined
1182
1221
  },
1222
+ mark_read: {
1223
+ op: "custom", access: 'update', method: "post",
1224
+ name: 'Mark Read',
1225
+ path: '/mark-chat-room-read',
1226
+ description: "Marks the conversation read by the authenticated user",
1227
+ parameters: { id: { validator: mongoIdStringValidator, required: true } },
1228
+ returns: {
1229
+ updated: { validator: 'Room' },
1230
+ } as any // add room eventually, when validator defined
1231
+ },
1183
1232
  display_info: {
1184
1233
  op: "custom", access: 'read', method: "get",
1185
1234
  name: 'Attendee display info',
@@ -1283,6 +1332,7 @@ export const schema: SchemaV1 = build_schema({
1283
1332
  }],
1284
1333
  },
1285
1334
  defaultActions: { read: {}, readMany: {}, update: { description: "Users can only be updated by self or an organization admin"} },
1335
+ enduserActions: { display_info: {}, read: {}, readMany: {} },
1286
1336
  customActions: {
1287
1337
  display_info: {
1288
1338
  op: "custom", access: 'read', method: "get",
@@ -1324,28 +1374,31 @@ export const schema: SchemaV1 = build_schema({
1324
1374
  description: "For a code generated by request-password-reset, sets a new password",
1325
1375
  parameters: {
1326
1376
  resetToken: { validator: stringValidator250, required: true },
1327
- newPassword: { validator: stringValidator250, required: true },
1377
+ newPassword: { validator: passwordValidator, required: true },
1328
1378
  },
1329
1379
  returns: { },
1330
1380
  },
1331
1381
  },
1332
- enduserActions: { display_info: {} },
1333
1382
  fields: {
1334
1383
  ...BuiltInFields,
1335
1384
  email: {
1336
1385
  validator: emailValidator,
1337
1386
  required: true,
1338
- examples: ['test@tellescope.com']
1387
+ examples: ['test@tellescope.com'],
1388
+ redactions: ['enduser'],
1339
1389
  },
1340
1390
  phone: {
1341
1391
  validator: phoneValidator,
1392
+ redactions: ['enduser'],
1342
1393
  },
1343
1394
  fields: {
1344
1395
  validator: fieldsValidator,
1396
+ redactions: ['enduser'],
1345
1397
  },
1346
1398
  username: {
1347
1399
  validator: subdomainValidator,
1348
1400
  readonly: true, // able to set once, then not change (for now, due to email configuration)
1401
+ redactions: ['enduser'],
1349
1402
  },
1350
1403
  fname: {
1351
1404
  validator: nameValidator,
@@ -1367,6 +1420,7 @@ export const schema: SchemaV1 = build_schema({
1367
1420
  roles: {
1368
1421
  validator: listOfStringsValidator,
1369
1422
  updatesDisabled: true, // implement with separate endpoint with tight restrictions
1423
+ redactions: ['enduser'],
1370
1424
  },
1371
1425
  skills: {
1372
1426
  validator: listOfStringsValidator,
@@ -1374,9 +1428,11 @@ export const schema: SchemaV1 = build_schema({
1374
1428
  hashedPassword: {
1375
1429
  validator: stringValidator,
1376
1430
  readonly: true, // update via separate password reset function
1431
+ redactions: ['enduser'],
1377
1432
  },
1378
1433
  notificationPreferences: {
1379
1434
  validator: notificationPreferencesValidator,
1435
+ redactions: ['enduser'],
1380
1436
  },
1381
1437
  avatar: {
1382
1438
  validator: stringValidator100,
@@ -1591,6 +1647,9 @@ export const schema: SchemaV1 = build_schema({
1591
1647
  constraints: {
1592
1648
  unique: [],
1593
1649
  relationship: [],
1650
+ access: [
1651
+ { type: 'filter', field: 'attendees.id' },
1652
+ ]
1594
1653
  },
1595
1654
  defaultActions: {
1596
1655
  readMany: {
@@ -1598,7 +1657,16 @@ export const schema: SchemaV1 = build_schema({
1598
1657
  adminOnly: true,
1599
1658
  }
1600
1659
  },
1660
+ enduserActions: { my_meetings: {}, join_meeting_for_event: {}, read: {} },
1601
1661
  customActions: {
1662
+ read: {
1663
+ op: "read", access: 'read', method: "get",
1664
+ description: "Get a meeting",
1665
+ parameters: {
1666
+ id: { validator: mongoIdStringValidator },
1667
+ },
1668
+ returns: 'meeting' as any,
1669
+ },
1602
1670
  start_meeting: {
1603
1671
  op: "custom", access: 'create', method: "post",
1604
1672
  name: 'Start Meeting',
@@ -1664,9 +1732,36 @@ export const schema: SchemaV1 = build_schema({
1664
1732
  description: "Gets meetings for the current user.",
1665
1733
  parameters: {},
1666
1734
  returns: { validator: meetingsListValidator, required: true },
1667
- }
1735
+ },
1736
+ start_meeting_for_event: {
1737
+ op: "custom", access: 'create', method: "post",
1738
+ name: 'Start Scheduled Meeting',
1739
+ path: '/start-meeting-for-event',
1740
+ description: "Generates an video meeting room",
1741
+ parameters: {
1742
+ calendarEventId: { validator: mongoIdStringValidator, required: true },
1743
+ },
1744
+ returns: {
1745
+ id: { validator: mongoIdStringValidator, required: true },
1746
+ meeting: { validator: meetingInfoValidator, required: true },
1747
+ host: { validator: attendeeValidator, required: true },
1748
+ },
1749
+ },
1750
+ join_meeting_for_event: {
1751
+ op: "custom", access: 'update', method: "post",
1752
+ name: 'Join Scheduled Meeting',
1753
+ path: '/join-meeting-for-event',
1754
+ description: "Generates an video meeting room",
1755
+ parameters: {
1756
+ calendarEventId: { validator: mongoIdStringValidator, required: true },
1757
+ },
1758
+ returns: {
1759
+ id: { validator: mongoIdStringValidator, required: true },
1760
+ meeting: { validator: meetingInfoValidator, required: true },
1761
+ attendee: { validator: attendeeValidator, required: true },
1762
+ },
1763
+ },
1668
1764
  },
1669
- enduserActions: { my_meetings: {} },
1670
1765
  fields: {
1671
1766
  ...BuiltInFields,
1672
1767
  // all fields are updatable by custom endpoints only
@@ -1846,6 +1941,7 @@ export const schema: SchemaV1 = build_schema({
1846
1941
  responses: { validator: formResponsesValidator },
1847
1942
  },
1848
1943
  defaultActions: DEFAULT_OPERATIONS,
1944
+ enduserActions: { prepare_form_response: {}, info_for_access_code: {}, submit_form_response: {}, read: {}, readMany: {} },
1849
1945
  customActions: {
1850
1946
  prepare_form_response: {
1851
1947
  op: "custom", access: 'create', method: "post",
@@ -1875,7 +1971,21 @@ export const schema: SchemaV1 = build_schema({
1875
1971
  returns: {
1876
1972
  formResponse: 'form response' as any,
1877
1973
  },
1878
- }
1974
+ },
1975
+ info_for_access_code: {
1976
+ op: "custom", access: 'read', method: "get",
1977
+ name: 'Info for Access Code',
1978
+ path: '/form-info-for-access-code',
1979
+ description: "With an accessCode, retrieves the relevant info for submitting a form",
1980
+ parameters: {
1981
+ accessCode: { validator: stringValidator250, required: true },
1982
+ },
1983
+ returns: {
1984
+ form: 'form' as any,
1985
+ fields: 'form fields' as any,
1986
+ response: 'form response' as any,
1987
+ },
1988
+ },
1879
1989
  },
1880
1990
  publicActions: {
1881
1991
  session_for_public_form: {
@@ -1899,7 +2009,6 @@ export const schema: SchemaV1 = build_schema({
1899
2009
  },
1900
2010
  },
1901
2011
  },
1902
- enduserActions: { prepare_form_response: {}, submit_form_response: {} },
1903
2012
  },
1904
2013
  webhooks: {
1905
2014
  info: {
@@ -2029,7 +2138,23 @@ export const schema: SchemaV1 = build_schema({
2029
2138
  ]
2030
2139
  },
2031
2140
  defaultActions: DEFAULT_OPERATIONS,
2032
- customActions: {},
2141
+ customActions: {
2142
+ start_meeting: {
2143
+ op: "custom", access: 'create', method: "post",
2144
+ name: 'Start Meeting',
2145
+ path: '/start-meeting-for-event',
2146
+ description: "Generates an video meeting room",
2147
+ parameters: {
2148
+ attendees: { validator: listOfUserIndentitiesValidator },
2149
+ publicRead: { validator: booleanValidator },
2150
+ },
2151
+ returns: {
2152
+ id: { validator: mongoIdStringValidator, required: true },
2153
+ meeting: { validator: meetingInfoValidator, required: true },
2154
+ host: { validator: attendeeValidator, required: true },
2155
+ },
2156
+ },
2157
+ },
2033
2158
  enduserActions: { read: {}, readMany: {} },
2034
2159
  fields: {
2035
2160
  ...BuiltInFields,
@@ -2049,6 +2174,8 @@ export const schema: SchemaV1 = build_schema({
2049
2174
  required: true,
2050
2175
  },
2051
2176
  description: { validator: stringValidator5000 },
2177
+ meetingId: { validator: mongoIdStringValidator, readonly: true },
2178
+ meetingStatus: { validator: meetingStatusValidator },
2052
2179
  chatRoomId: {
2053
2180
  validator: mongoIdStringValidator,
2054
2181
  dependencies: [{
@@ -2067,6 +2194,7 @@ export const schema: SchemaV1 = build_schema({
2067
2194
  initializer: () => [],
2068
2195
  },
2069
2196
  publicRead: { validator: booleanValidator },
2197
+ enableVideoCall: { validator: booleanValidator },
2070
2198
  displayImage: { validator: stringValidator },
2071
2199
  fields: { validator: fieldsValidator },
2072
2200
  }
@@ -2409,9 +2537,18 @@ export const schema: SchemaV1 = build_schema({
2409
2537
  validator: stringValidator25000,
2410
2538
  examples: ["This is the template message......"],
2411
2539
  },
2540
+ type: {
2541
+ validator: managedContentRecordTypeValidator,
2542
+ updatesDisabled: true,
2543
+ },
2544
+ attachments: {
2545
+ validator: listOfChatAttachmentsValidator,
2546
+ },
2547
+ headerPhoto: { validator: stringValidator250 },
2548
+ publicRead: { validator: booleanValidator },
2412
2549
  mode: { validator: messageTemplateModeValidator, },
2413
2550
  files: { validator: listOfStringsValidator },
2414
- tags: { validator: listOfStringsValidator },
2551
+ tags: { validator: listOfStringsValidatorEmptyOk },
2415
2552
  }
2416
2553
  },
2417
2554
  forums: {
@@ -2473,6 +2610,11 @@ export const schema: SchemaV1 = build_schema({
2473
2610
  validator: nonNegNumberValidator,
2474
2611
  initializer: () => 0,
2475
2612
  },
2613
+ title: {
2614
+ validator: stringValidator5000,
2615
+ required: true,
2616
+ examples: ["This is the template message......"],
2617
+ },
2476
2618
  textContent: {
2477
2619
  validator: stringValidator25000,
2478
2620
  required: true,
@@ -2574,6 +2716,7 @@ export const schema: SchemaV1 = build_schema({
2574
2716
  access: [{ type: 'dependency', foreignModel: 'forums', foreignField: '_id', accessField: 'forumId' }]
2575
2717
  },
2576
2718
  defaultActions: { read: {}, readMany: {}, delete: {} }, // create is custom
2719
+ enduserActions: { create: {}, unlike_post: {}, readMany: {} },
2577
2720
  customActions: {
2578
2721
  create: {
2579
2722
  op: "custom", access: 'create', method: "post",
@@ -2598,7 +2741,6 @@ export const schema: SchemaV1 = build_schema({
2598
2741
  returns: { } //authToken: { validator: stringValidator5000 } },
2599
2742
  },
2600
2743
  },
2601
- enduserActions: { create: {}, unlike_post: {} },
2602
2744
  fields: {
2603
2745
  ...BuiltInFields,
2604
2746
  // creator: {
@@ -2682,6 +2824,7 @@ export const schema: SchemaV1 = build_schema({
2682
2824
  roles: { validator: listOfStringsValidator },
2683
2825
  skills: { validator: listOfStringsValidator },
2684
2826
  themeColor: { validator: stringValidator100 },
2827
+ customPortalURL: { validator: stringValidator250 },
2685
2828
  },
2686
2829
  },
2687
2830