@tellescope/sdk 1.74.0 → 1.74.2

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.74.0",
3
+ "version": "1.74.2",
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.74.0",
36
- "@tellescope/schema": "^1.74.0",
35
+ "@tellescope/constants": "^1.74.2",
36
+ "@tellescope/schema": "^1.74.2",
37
37
  "@tellescope/testing": "^1.69.3",
38
- "@tellescope/types-client": "^1.74.0",
39
- "@tellescope/types-models": "^1.74.0",
38
+ "@tellescope/types-client": "^1.74.2",
39
+ "@tellescope/types-models": "^1.74.2",
40
40
  "@tellescope/types-utilities": "^1.69.3",
41
- "@tellescope/utilities": "^1.74.0",
42
- "@tellescope/validation": "^1.74.0",
41
+ "@tellescope/utilities": "^1.74.2",
42
+ "@tellescope/validation": "^1.74.2",
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": "d79c620038c8c1aaf3d02e087fadffd21e2a47e8"
61
+ "gitHead": "f4bc81378a92dcd29e715c151cbab1c13e2b9cb5"
62
62
  }
package/src/sdk.ts CHANGED
@@ -532,6 +532,9 @@ type Queries = { [K in keyof ClientModelForName]: APIQuery<K> } & {
532
532
  deliver_via_iterable: (args: extractFields<CustomActions['emails']['deliver_via_iterable']['parameters']>) => (
533
533
  Promise<extractFields<CustomActions['emails']['deliver_via_iterable']['returns']>>
534
534
  ),
535
+ send_with_template: (args: extractFields<CustomActions['emails']['send_with_template']['parameters']>) => (
536
+ Promise<extractFields<CustomActions['emails']['send_with_template']['returns']>>
537
+ ),
535
538
  },
536
539
  calendar_events: {
537
540
  get_events_for_user: (args: extractFields<CustomActions['calendar_events']['get_events_for_user']['parameters']>) => (
@@ -764,6 +767,7 @@ export class Session extends SessionManager {
764
767
  queries.emails.sync_integrations = a => this._POST(`/v1/${schema.emails.customActions.sync_integrations.path}`, a)
765
768
  queries.emails.deliver_via_outlook = a => this._POST(`/v1/${schema.emails.customActions.deliver_via_outlook.path}`, a)
766
769
  queries.emails.deliver_via_iterable = a => this._POST(`/v1/${schema.emails.customActions.deliver_via_iterable.path}`, a)
770
+ queries.emails.send_with_template = a => this._POST(`/v1/${schema.emails.customActions.send_with_template.path}`, a)
767
771
 
768
772
  queries.calendar_events.get_events_for_user = a => this._GET(`/v1/${schema.calendar_events.customActions.get_events_for_user.path}`, a)
769
773
  queries.calendar_events.load_events = a => this._GET(`/v1/${schema.calendar_events.customActions.load_events.path}`, a)
@@ -6534,6 +6534,67 @@ export const ticket_reminder_tests = async () => {
6534
6534
  await Promise.all(toDelete.map(t => sdk.api.tickets.deleteOne(t.id)))
6535
6535
  }
6536
6536
 
6537
+ const bulk_read_tests = async () => {
6538
+ log_header("Bulk Read (ID-lookup) Tests")
6539
+
6540
+ const numEndusers = 101
6541
+ const endusers = (
6542
+ await sdk.api.endusers.createSome(
6543
+ Array.from(Array(numEndusers).keys()).map(() => 0).map(() => ({ }))
6544
+ )
6545
+ ).created
6546
+
6547
+ await async_test(
6548
+ "bulk id lookup isn't limited to 100 (default for backend)",
6549
+ () => sdk.api.endusers.getByIds({ ids: endusers.map(e => e.id )}),
6550
+ { onResult: result => (
6551
+ result.matches.length === numEndusers
6552
+ && result.matches.filter(e => endusers.find(_e => _e.id === e.id)).length === result.matches.length
6553
+ )}
6554
+ )
6555
+
6556
+ await async_test(
6557
+ "bulk id lookup limited to 1000 (success)",
6558
+ () => sdk.api.endusers.getByIds({ ids: Array.from(Array(1000).keys()).map(() => endusers[0].id) }),
6559
+ passOnAnyResult
6560
+ )
6561
+ await async_test(
6562
+ "bulk id lookup limited to 1000",
6563
+ () => sdk.api.endusers.getByIds({ ids: Array.from(Array(1001).keys()).map(() => endusers[0].id) }),
6564
+ {
6565
+ shouldError: true,
6566
+ onError: e => e.message === 'Error parsing field ids: Arrays should not contain more than 1000 elements'
6567
+ }
6568
+ )
6569
+
6570
+ // cleanup
6571
+ for (const e of endusers) {
6572
+ await sdk.api.endusers.deleteOne(e.id)
6573
+ }
6574
+ }
6575
+
6576
+ const test_send_with_template = async () => {
6577
+ log_header("test_send_with_template")
6578
+
6579
+ const [enduser, template] = await Promise.all([
6580
+ sdk.api.endusers.createOne({ email: 'sebass192@gmail.com' }),
6581
+ sdk.api.templates.createOne({ message: 'Text Message', subject: "test_send_with_template", title: 'test_send_with_template', html: "HTML Message" }),
6582
+ ])
6583
+
6584
+ await async_test(
6585
+ "send with template",
6586
+ () => sdk.api.emails.send_with_template({
6587
+ enduserId: enduser.id, templateId: template.id, senderId: sdk.userInfo.id,
6588
+ }),
6589
+ { onResult: ({ email }) => !!email.id && email.enduserId === enduser.id && email.templateId === template.id }
6590
+ )
6591
+
6592
+ await wait(undefined, 3000)
6593
+ await Promise.all([
6594
+ sdk.api.endusers.deleteOne(enduser.id),
6595
+ sdk.api.templates.deleteOne(template.id),
6596
+ ])
6597
+ }
6537
6598
 
6538
6599
  (async () => {
6539
6600
  log_header("API")
@@ -6577,6 +6638,8 @@ export const ticket_reminder_tests = async () => {
6577
6638
  await mfa_tests()
6578
6639
  await setup_tests()
6579
6640
  await multi_tenant_tests() // should come right after setup tests
6641
+ // await test_send_with_template()
6642
+ await bulk_read_tests()
6580
6643
  await ticket_reminder_tests()
6581
6644
  await enduser_access_tags_tests()
6582
6645
  await marketing_email_unsubscribe_tests()
@@ -160,8 +160,8 @@ const meetings_tests = async (isSubscribed: boolean) => {
160
160
  const meeting = await sdk.api.meetings.start_meeting()
161
161
 
162
162
  await check_next_webhook(a => (
163
- objects_equivalent(a.records[0]?.meetingInfo, meeting.meeting)
164
- && (a.records[0] as Meeting).attendees?.length === 1
163
+ // objects_equivalent(a.records[0]?.meetingInfo, meeting.meeting)
164
+ (a.records[0] as Meeting).attendees?.length === 1
165
165
  && (a.records[0] as Meeting).attendees?.[0].id === sdk.userInfo.id
166
166
  ),
167
167
  'Create meeting error', 'Create meeting webhook', isSubscribed
Binary file