@tellescope/sdk 1.3.13 → 1.3.15
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/sdk.d.ts +7 -8
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +3 -3
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/session.d.ts +2 -1
- package/lib/cjs/session.d.ts.map +1 -1
- package/lib/cjs/session.js +3 -3
- package/lib/cjs/session.js.map +1 -1
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +3 -1
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/cjs/tests/webhooks_tests.js +24 -11
- package/lib/cjs/tests/webhooks_tests.js.map +1 -1
- package/lib/esm/enduser.d.ts +0 -1
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/sdk.d.ts +7 -9
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +3 -3
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/session.d.ts +2 -2
- package/lib/esm/session.d.ts.map +1 -1
- package/lib/esm/session.js +3 -3
- package/lib/esm/session.js.map +1 -1
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +3 -1
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/esm/tests/webhooks_tests.js +24 -11
- package/lib/esm/tests/webhooks_tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/sdk.ts +10 -7
- package/src/session.ts +3 -2
- package/src/tests/tests.ts +6 -1
- package/src/tests/webhooks_tests.ts +16 -4
package/src/session.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
S3PresignedPost,
|
|
8
8
|
} from "@tellescope/types-utilities"
|
|
9
9
|
import {
|
|
10
|
-
ClientModelForName,
|
|
10
|
+
ClientModelForName, User,
|
|
11
11
|
} from "@tellescope/types-client"
|
|
12
12
|
import { Indexable } from "@tellescope/utilities"
|
|
13
13
|
import { OrganizationTheme } from "@tellescope/types-models"
|
|
@@ -18,6 +18,7 @@ export interface SessionOptions {
|
|
|
18
18
|
apiKey?: string;
|
|
19
19
|
authToken?: string;
|
|
20
20
|
servicesSecret?: string,
|
|
21
|
+
user?: User,
|
|
21
22
|
businessId?: string,
|
|
22
23
|
host?: string;
|
|
23
24
|
cacheKey?: string;
|
|
@@ -92,7 +93,7 @@ export class Session {
|
|
|
92
93
|
// keep ?? over || to allow '' argument to avoid access_cache
|
|
93
94
|
this.authToken = o.authToken ?? access_cache(o.cacheKey) ?? '';
|
|
94
95
|
|
|
95
|
-
this.userInfo = JSON.parse(access_cache(o.cacheKey + 'userInfo') || '{}');
|
|
96
|
+
this.userInfo = o?.user ?? JSON.parse(access_cache(o.cacheKey + 'userInfo') || '{}');
|
|
96
97
|
if (this.authToken) {
|
|
97
98
|
set_cache(this.cacheKey, this.authToken)
|
|
98
99
|
this.authenticate_socket()
|
package/src/tests/tests.ts
CHANGED
|
@@ -1333,7 +1333,12 @@ const files_tests = async () => {
|
|
|
1333
1333
|
const { presignedUpload, file } = await sdk.api.files.prepare_file_upload({
|
|
1334
1334
|
name: 'Test File', size: buff.byteLength, type: 'text/plain'
|
|
1335
1335
|
})
|
|
1336
|
-
|
|
1336
|
+
|
|
1337
|
+
await sdk.UPLOAD(
|
|
1338
|
+
// @ts-ignore
|
|
1339
|
+
presignedUpload,
|
|
1340
|
+
buff
|
|
1341
|
+
)
|
|
1337
1342
|
|
|
1338
1343
|
const { downloadURL } = await sdk.api.files.file_download_URL({ secureName: file.secureName })
|
|
1339
1344
|
const downloaded: string = await sdk.DOWNLOAD(downloadURL)
|
|
@@ -111,7 +111,12 @@ const check_next_webhook = async (evaluate: (hook: WebhookCall) => boolean, name
|
|
|
111
111
|
|
|
112
112
|
const chats_tests = async (isSubscribed: boolean) => {
|
|
113
113
|
log_header(`Chats Tests, isSubscribed=${isSubscribed}`)
|
|
114
|
-
|
|
114
|
+
|
|
115
|
+
const enduser = await sdk.api.endusers.createOne({ email: 'chatwebhooktest@tellescope.com' })
|
|
116
|
+
const room = await sdk.api.chat_rooms.createOne({
|
|
117
|
+
userIds: [sdk.userInfo.id, nonAdminSdk.userInfo.id],
|
|
118
|
+
enduserIds: [enduser.id]
|
|
119
|
+
})
|
|
115
120
|
|
|
116
121
|
const chat = await sdk.api.chats.createOne({ roomId: room.id, message: "Hello hello hi hello" })
|
|
117
122
|
await check_next_webhook(
|
|
@@ -122,15 +127,22 @@ const chats_tests = async (isSubscribed: boolean) => {
|
|
|
122
127
|
objects_equivalent(record, chat) &&
|
|
123
128
|
relatedRecords[record.roomId] !== undefined &&
|
|
124
129
|
relatedRecords[record.senderId as string] !== undefined &&
|
|
130
|
+
relatedRecords[nonAdminSdk.userInfo.id] !== undefined &&
|
|
131
|
+
relatedRecords[enduser.id] !== undefined &&
|
|
125
132
|
relatedRecords[record.roomId]?.id === room.id &&
|
|
126
|
-
relatedRecords[record.senderId as string]?.id === room.userIds?.[0]
|
|
133
|
+
relatedRecords[record.senderId as string]?.id === room.userIds?.[0] &&
|
|
134
|
+
relatedRecords[nonAdminSdk.userInfo.id]?.id === room.userIds?.[1] &&
|
|
135
|
+
relatedRecords[enduser.id]?.id === room.enduserIds?.[0]
|
|
127
136
|
)
|
|
128
137
|
},
|
|
129
138
|
'Create chat error', 'Create chat webhook', isSubscribed
|
|
130
139
|
)
|
|
131
140
|
|
|
132
141
|
// cleanup
|
|
133
|
-
await
|
|
142
|
+
await Promise.all([
|
|
143
|
+
sdk.api.chat_rooms.deleteOne(room.id),
|
|
144
|
+
sdk.api.endusers.deleteOne(enduser.id)
|
|
145
|
+
])
|
|
134
146
|
|
|
135
147
|
// when chatroom support added for webhooks, check deletion here
|
|
136
148
|
// await check_next_webhook(a => objects_equivalent(a.records, [chat_room]), 'Delete chat room error', 'Delete chat room webhook', isSubscribed)
|
|
@@ -329,8 +341,8 @@ const calendar_event_reminders_tests = async (isSubscribed: boolean) => {
|
|
|
329
341
|
}
|
|
330
342
|
|
|
331
343
|
const tests: { [K in WebhookSupportedModel | 'calendarEventReminders']: (isSubscribed: boolean) => Promise<void> } = {
|
|
332
|
-
calendarEventReminders: calendar_event_reminders_tests,
|
|
333
344
|
chats: chats_tests,
|
|
345
|
+
calendarEventReminders: calendar_event_reminders_tests,
|
|
334
346
|
meetings: meetings_tests,
|
|
335
347
|
}
|
|
336
348
|
|