@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.
- package/lib/cjs/enduser.d.ts +143 -14
- package/lib/cjs/enduser.d.ts.map +1 -1
- package/lib/cjs/enduser.js +16 -0
- package/lib/cjs/enduser.js.map +1 -1
- package/lib/cjs/sdk.d.ts +139 -10
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +39 -0
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/tests/tests.js +95 -28
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/cjs/tests/webhooks_tests.js +35 -20
- package/lib/cjs/tests/webhooks_tests.js.map +1 -1
- package/lib/esm/enduser.d.ts +143 -14
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/enduser.js +16 -0
- package/lib/esm/enduser.js.map +1 -1
- package/lib/esm/sdk.d.ts +139 -10
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +39 -0
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/tests/tests.js +95 -28
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/esm/tests/webhooks_tests.js +35 -20
- package/lib/esm/tests/webhooks_tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/enduser.ts +14 -6
- package/src/sdk.ts +21 -5
- package/src/tests/tests.ts +61 -4
- package/src/tests/webhooks_tests.ts +25 -1
|
@@ -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(
|
|
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 }),
|