@tellescope/sdk 0.0.21 → 0.0.25

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.
@@ -21,6 +21,7 @@ import {
21
21
  } from "@tellescope/types-models"
22
22
 
23
23
  import { Session } from "../sdk"
24
+ import { ChatMessage } from "@tellescope/types-client"
24
25
 
25
26
  const [email, password] = [process.env.TEST_EMAIL, process.env.TEST_PASSWORD]
26
27
  const [email2, password2] = [process.env.TEST_EMAIL_2, process.env.TEST_PASSWORD_2]
@@ -92,7 +93,20 @@ const chats_tests = async (isSubscribed: boolean) => {
92
93
  const room = await sdk.api.chat_rooms.createOne({ userIds: [sdk.userInfo.id] })
93
94
 
94
95
  const chat = await sdk.api.chats.createOne({ roomId: room.id, message: "Hello hello hi hello" })
95
- await check_next_webhook(a => objects_equivalent(a.records, [chat]), 'Create chat error', 'Create chat webhook', isSubscribed)
96
+ await check_next_webhook(
97
+ ({ records, relatedRecords }) => {
98
+ const record = records[0] as ChatMessage
99
+
100
+ return (
101
+ objects_equivalent(record, chat) &&
102
+ relatedRecords[record.roomId] !== undefined &&
103
+ relatedRecords[record.senderId as string] !== undefined &&
104
+ relatedRecords[record.roomId]?.id === room.id &&
105
+ relatedRecords[record.senderId as string]?.id === room.userIds?.[0]
106
+ )
107
+ },
108
+ 'Create chat error', 'Create chat webhook', isSubscribed
109
+ )
96
110
 
97
111
  // cleanup
98
112
  await sdk.api.chat_rooms.deleteOne(room.id) // also cleans up messages
@@ -143,6 +157,16 @@ const run_tests = async () => {
143
157
  () => sdk.api.webhooks.configure({ url: webhookURL, secret: TEST_SECRET }),
144
158
  { shouldError: true, onError: e => e.message === "Only one webhook configuration is supported per organization. Use /update-webooks to update your configuration." }
145
159
  )
160
+ await async_test(
161
+ 'update webhook (set empty subscription)',
162
+ () => sdk.api.webhooks.update({ subscriptionUpdates: {} }),
163
+ { onResult: _ => true }
164
+ )
165
+ await async_test(
166
+ 'update webhook (set partial subscription)',
167
+ () => sdk.api.webhooks.update({ subscriptionUpdates: { chats: { create: true }} }),
168
+ { onResult: _ => true }
169
+ )
146
170
  await async_test(
147
171
  'update webhook (set subscriptions)',
148
172
  () => sdk.api.webhooks.update({ subscriptionUpdates: fullSubscription }),