@tellescope/sdk 1.4.105 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/sdk",
3
- "version": "1.4.105",
3
+ "version": "1.5.0",
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.4.104",
36
- "@tellescope/schema": "^1.4.105",
35
+ "@tellescope/constants": "^1.5.0",
36
+ "@tellescope/schema": "^1.5.0",
37
37
  "@tellescope/testing": "^1.4.48",
38
- "@tellescope/types-client": "^1.4.104",
39
- "@tellescope/types-models": "^1.4.104",
38
+ "@tellescope/types-client": "^1.5.0",
39
+ "@tellescope/types-models": "^1.5.0",
40
40
  "@tellescope/types-utilities": "^1.4.27",
41
- "@tellescope/utilities": "^1.4.105",
42
- "@tellescope/validation": "^1.4.105",
41
+ "@tellescope/utilities": "^1.5.0",
42
+ "@tellescope/validation": "^1.5.0",
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": "f0dd59b66f81a25758d01848a94a211f1cebf6a4"
61
+ "gitHead": "0af3617ae250979882abad9d943b67430534e4d3"
62
62
  }
package/src/sdk.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  SearchOptions,
14
14
  AccessPermissions,
15
15
  OrganizationLimits,
16
+ SortBy,
16
17
  } from "@tellescope/types-models"
17
18
 
18
19
  import {
@@ -38,6 +39,7 @@ export interface LoadFunctionArguments <T> {
38
39
  lastId?: string,
39
40
  limit?: number,
40
41
  sort?: SortOption,
42
+ sortBy?: SortBy,
41
43
  from?: Date | number,
42
44
  threadKey?: string,
43
45
  filter?: ReadFilter<T>,
@@ -293,6 +293,74 @@ const sub_organization_tests = async (isSubscribed: boolean) => {
293
293
  await sdk.api.endusers.deleteOne(enduserSub.id)
294
294
  }
295
295
 
296
+
297
+ const form_response_tests = async (isSubscribed: boolean) => {
298
+ log_header(`Form Response Tests, isSubscribed=${isSubscribed}`)
299
+
300
+ if (isSubscribed) {
301
+ await sdk.api.webhooks.update({ subscriptionUpdates: {
302
+ ...emptySubscription,
303
+ form_responses: { create: true },
304
+ }})
305
+ }
306
+
307
+ const form = await sdk.api.forms.createOne({ title: 'test form' })
308
+ const field = await sdk.api.form_fields.createOne({
309
+ title: 'test',
310
+ formId: form.id,
311
+ type: 'string',
312
+ previousFields: [],
313
+ })
314
+
315
+ const enduser = await sdk.api.endusers.createOne({ email: 'deleteme@tellescope.com' })
316
+ const { accessCode } = await sdk.api.form_responses.prepare_form_response({
317
+ enduserId: enduser.id,
318
+ formId: form.id,
319
+ })
320
+
321
+ const { formResponse } = await sdk.api.form_responses.submit_form_response({
322
+ accessCode,
323
+ responses: [
324
+ {
325
+ fieldId: field.id,
326
+ fieldTitle: 'test',
327
+ answer: {
328
+ type: 'string',
329
+ value: 'testing value',
330
+ }
331
+ }
332
+ ]
333
+ })
334
+
335
+ await check_next_webhook(
336
+ a => {
337
+ const hook = a.records[0]
338
+
339
+ return (
340
+ hook.id === formResponse.id
341
+ && hook.businessId === formResponse.businessId
342
+ && hook.enduserId === formResponse.enduserId
343
+ && objects_equivalent(formResponse.responses, hook.responses)
344
+ )
345
+ },
346
+ 'Form response on submit error', 'Form response on submit', isSubscribed
347
+ )
348
+
349
+ // cleanup
350
+ if (isSubscribed) {
351
+ await sdk.api.webhooks.update({ subscriptionUpdates: {
352
+ ...emptySubscription,
353
+ chats: { create: true },
354
+ meetings: { create: true, update: true, delete: false },
355
+ }})
356
+ }
357
+
358
+ await Promise.all([
359
+ sdk.api.endusers.deleteOne(enduser.id),
360
+ sdk.api.forms.deleteOne(form.id),
361
+ ])
362
+ }
363
+
296
364
  const AUTOMATION_POLLING_DELAY_MS = 3000 - CHECK_WEBHOOK_DELAY_MS
297
365
  const test_automation_webhooks = async () => {
298
366
  log_header("Automation Events")
@@ -437,6 +505,7 @@ const calendar_event_reminders_tests = async (isSubscribed: boolean) => {
437
505
  }
438
506
 
439
507
  const tests: { [K in WebhookSupportedModel | 'calendarEventReminders' | 'sub']?: (isSubscribed: boolean) => Promise<void> } = {
508
+ form_responses: form_response_tests,
440
509
  sub: sub_organization_tests,
441
510
  endusers: endusers_tests,
442
511
  chats: chats_tests,