@tellescope/sdk 1.74.2 → 1.75.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/session.ts CHANGED
@@ -366,62 +366,59 @@ export class Session {
366
366
  }
367
367
 
368
368
  authenticate_socket = () => {
369
- if (this.userInfo.requiresMFA) return
370
- if (this.lastSocketConnection + 2500 > Date.now()) return
371
- this.lastSocketConnection = Date.now()
369
+ // if (this.userInfo.requiresMFA) return
370
+ // if (this.lastSocketConnection + 2500 > Date.now()) return
371
+ // this.lastSocketConnection = Date.now()
372
372
 
373
- if (this.enableSocketLogging) console.log('authenticating socket')
373
+ // if (this.enableSocketLogging) console.log('authenticating socket')
374
374
 
375
- this.initialize_socket()
376
- if (!this.socket) {
377
- console.warn("failed to initialize_socket")
378
- return
379
- }
375
+ // this.initialize_socket()
376
+ // if (!this.socket) {
377
+ // console.warn("failed to initialize_socket")
378
+ // return
379
+ // }
380
380
 
381
- this.socket.removeAllListeners()
382
-
383
- this.socket.on('ping', () => {
384
- if (this.enableSocketLogging) { this.socket_log("pong") }
385
- })
386
-
387
- // handle events which are sent when handlers may be off
388
- this.socket?.onAny((e, v)=> {
389
- if (this.handlers[e] && v) {
390
- this.handlers[e](v)
391
- } else if (Array.isArray(v)) {
392
- if (!this.loadedSocketEvents[e]) {
393
- this.loadedSocketEvents[e] = []
394
- }
395
- this.loadedSocketEvents[e].push(...v)
396
- }
397
- })
398
-
399
- this.socket.on('connect', () => {
400
- if (this.enableSocketLogging) { this.socket_log(`connect, authenticated=${this.socketAuthenticated}`) }
401
- })
402
-
403
- this.socket.on('disconnect', () => {
404
- this.socketAuthenticated = false
405
- if (this.enableSocketLogging) { this.socket_log("disconnect") }
406
- })
407
- this.socket.on('authenticated', () => {
408
- this.socketAuthenticated = true
409
- // if (this.enableSocketLogging) {
410
- this.socket_log("authenticated")
411
- // }
412
- })
413
- this.socket.on('error', (error: any) => {
414
- console.warn('socket error: ', error)
415
- })
416
- this.socket.on('connect_error', (error: any) => {
417
- console.warn('connect_error: ', error)
418
- // setTimeout(() => {
419
- // this.socket?.connect()
420
- // })
421
- })
422
-
423
- // no longer necessary
424
- // this.socket.emit('authenticate', this.authToken)
381
+ // this.socket.removeAllListeners()
382
+
383
+ // this.socket.on('ping', () => {
384
+ // if (this.enableSocketLogging) { this.socket_log("pong") }
385
+ // })
386
+
387
+ // // handle events which are sent when handlers may be off
388
+ // this.socket?.onAny((e, v)=> {
389
+ // if (this.handlers[e] && v) {
390
+ // this.handlers[e](v)
391
+ // } else if (Array.isArray(v)) {
392
+ // if (!this.loadedSocketEvents[e]) {
393
+ // this.loadedSocketEvents[e] = []
394
+ // }
395
+ // this.loadedSocketEvents[e].push(...v)
396
+ // }
397
+ // })
398
+
399
+ // this.socket.on('connect', () => {
400
+ // if (this.enableSocketLogging) { this.socket_log(`connect, authenticated=${this.socketAuthenticated}`) }
401
+ // })
402
+
403
+ // this.socket.on('disconnect', () => {
404
+ // this.socketAuthenticated = false
405
+ // if (this.enableSocketLogging) { this.socket_log("disconnect") }
406
+ // })
407
+ // this.socket.on('authenticated', () => {
408
+ // this.socketAuthenticated = true
409
+ // // if (this.enableSocketLogging) {
410
+ // this.socket_log("authenticated")
411
+ // // }
412
+ // })
413
+ // this.socket.on('error', (error: any) => {
414
+ // console.warn('socket error: ', error)
415
+ // })
416
+ // this.socket.on('connect_error', (error: any) => {
417
+ // console.warn('connect_error: ', error)
418
+ // // setTimeout(() => {
419
+ // // this.socket?.connect()
420
+ // // })
421
+ // })
425
422
  }
426
423
 
427
424
  /** @deprecated */
@@ -4147,6 +4147,28 @@ export const self_serve_appointment_booking_tests = async () => {
4147
4147
  }),
4148
4148
  { onResult: r => r.availabilityBlocks.length === 2 }, // 1 providers with 1 hour availability for 30 minute meetings
4149
4149
  )
4150
+ await async_test(
4151
+ '30 minute slots for state restriction with 15 min interval',
4152
+ () => enduserSDK.api.calendar_events.get_appointment_availability({
4153
+ calendarEventTemplateId: event30min.id,
4154
+ from: new Date(Date.now() - 10000),
4155
+ to: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000),
4156
+ restrictedByState: true,
4157
+ intervalInMinutes: 15,
4158
+ }),
4159
+ { onResult: r => r.availabilityBlocks.length === 3 }, // 1 providers with 1 hour availability for 30 minute meetings
4160
+ )
4161
+ await async_test(
4162
+ '30 minute slots for state restriction with 10 min interval',
4163
+ () => enduserSDK.api.calendar_events.get_appointment_availability({
4164
+ calendarEventTemplateId: event30min.id,
4165
+ from: new Date(Date.now() - 10000),
4166
+ to: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000),
4167
+ restrictedByState: true,
4168
+ intervalInMinutes: 10,
4169
+ }),
4170
+ { onResult: r => r.availabilityBlocks.length === 4 }, // 1 providers with 1 hour availability for 30 minute meetings
4171
+ )
4150
4172
  await async_test(
4151
4173
  '30 minute slots for no state restrictions',
4152
4174
  () => enduserSDK.api.calendar_events.get_appointment_availability({
@@ -5828,6 +5850,7 @@ export const alternate_phones_tests = async () => {
5828
5850
 
5829
5851
  const NO_TEST = () => {}
5830
5852
  const tests: { [K in keyof ClientModelForName]: () => void } = {
5853
+ enduser_encounters: NO_TEST,
5831
5854
  enduser_orders: NO_TEST,
5832
5855
  ticket_queues: NO_TEST,
5833
5856
  phone_trees: NO_TEST,
@@ -6596,6 +6619,33 @@ const test_send_with_template = async () => {
6596
6619
  ])
6597
6620
  }
6598
6621
 
6622
+ const delete_user_tests = async () => {
6623
+ // delete if previous test failed and user still exists
6624
+ const existing = await sdk.api.users.getSome({ filter: { email: 'deleteme@tellescope.com'}})
6625
+ if (existing[0]?.email === 'deleteme@tellescope.com') {
6626
+ await sdk.api.users.deleteOne(existing[0].id)
6627
+ }
6628
+
6629
+ const u = await sdk.api.users.createOne({ email: 'deleteme@tellescope.com', verifiedEmail: true })
6630
+
6631
+ const { authToken } = await sdk.api.users.generate_auth_token({ id: u.id })
6632
+ const createdUserSDK = new Session({ host, authToken })
6633
+
6634
+ await async_test(
6635
+ "Authenticated",
6636
+ createdUserSDK.test_authenticated,
6637
+ passOnAnyResult
6638
+ )
6639
+
6640
+ await sdk.api.users.deleteOne(u.id)
6641
+ await wait(undefined, 250)
6642
+ await async_test(
6643
+ "De-authenticated after deletion",
6644
+ createdUserSDK.test_authenticated,
6645
+ handleAnyError
6646
+ )
6647
+ }
6648
+
6599
6649
  (async () => {
6600
6650
  log_header("API")
6601
6651
 
@@ -6638,13 +6688,14 @@ const test_send_with_template = async () => {
6638
6688
  await mfa_tests()
6639
6689
  await setup_tests()
6640
6690
  await multi_tenant_tests() // should come right after setup tests
6691
+ await delete_user_tests()
6641
6692
  // await test_send_with_template()
6693
+ await self_serve_appointment_booking_tests()
6642
6694
  await bulk_read_tests()
6643
6695
  await ticket_reminder_tests()
6644
6696
  await enduser_access_tags_tests()
6645
6697
  await marketing_email_unsubscribe_tests()
6646
6698
  await unique_strings_tests()
6647
- await self_serve_appointment_booking_tests()
6648
6699
  await alternate_phones_tests()
6649
6700
  await ticket_queue_tests()
6650
6701
  await no_chained_triggers_tests()
Binary file