@tellescope/sdk 1.3.14 → 1.3.19
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 +1 -0
- 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/webhooks_tests.js +24 -11
- package/lib/cjs/tests/webhooks_tests.js.map +1 -1
- package/lib/esm/sdk.d.ts +1 -0
- 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 -1
- 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/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 +3 -3
- package/src/session.ts +3 -2
- package/src/tests/webhooks_tests.ts +16 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.19",
|
|
4
4
|
"description": "Code for interacting with the Tellescope API",
|
|
5
5
|
"main": "./lib/cjs/sdk.js",
|
|
6
6
|
"module": "./lib/esm/sdk.js",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/tellescope-os/tellescope#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tellescope/constants": "^1.3.
|
|
36
|
-
"@tellescope/schema": "^1.3.
|
|
35
|
+
"@tellescope/constants": "^1.3.19",
|
|
36
|
+
"@tellescope/schema": "^1.3.19",
|
|
37
37
|
"@tellescope/testing": "^1.3.10",
|
|
38
|
-
"@tellescope/types-client": "^1.3.
|
|
39
|
-
"@tellescope/types-models": "^1.3.
|
|
38
|
+
"@tellescope/types-client": "^1.3.19",
|
|
39
|
+
"@tellescope/types-models": "^1.3.19",
|
|
40
40
|
"@tellescope/types-utilities": "^1.3.10",
|
|
41
|
-
"@tellescope/utilities": "^1.3.
|
|
42
|
-
"@tellescope/validation": "^1.3.
|
|
41
|
+
"@tellescope/utilities": "^1.3.19",
|
|
42
|
+
"@tellescope/validation": "^1.3.19",
|
|
43
43
|
"axios": "^0.21.1",
|
|
44
44
|
"dotenv": "^14.2.0",
|
|
45
45
|
"express": "^4.17.1",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "359f30207e7d9dcfd72653be0b25cb463c1e2215"
|
|
62
62
|
}
|
package/src/sdk.ts
CHANGED
|
@@ -340,9 +340,9 @@ export class Session extends SessionManager {
|
|
|
340
340
|
await this.POST('/logout-api').catch(console.error)
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
prepare_and_upload_file = async (details: FileDetails & { publicRead?: boolean }, file: Blob | Buffer | ReactNativeFile) => {
|
|
344
|
-
const { name, size, type, enduserId, publicRead } = details
|
|
345
|
-
const { presignedUpload, file: createdFile } = await this.api.files.prepare_file_upload({ name, size, type, enduserId, publicRead })
|
|
343
|
+
prepare_and_upload_file = async (details: FileDetails & { publicRead?: boolean, publicName?: string, }, file: Blob | Buffer | ReactNativeFile) => {
|
|
344
|
+
const { name, size, type, enduserId, publicRead, publicName } = details
|
|
345
|
+
const { presignedUpload, file: createdFile } = await this.api.files.prepare_file_upload({ name, size, type, enduserId, publicRead, publicName })
|
|
346
346
|
await this.UPLOAD(presignedUpload as any, file)
|
|
347
347
|
return createdFile
|
|
348
348
|
}
|
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()
|
|
@@ -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
|
|