@elevasis/sdk 0.7.11 → 0.7.12

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.
@@ -1,907 +0,0 @@
1
- ---
2
- title: Typed Adapters
3
- description: Type-safe wrappers over platform.call() for all integrations and platform tools -- Attio, Stripe, Notion, Google Sheets, and more -- with full autocomplete, compile-time checking, and zero boilerplate
4
- loadWhen: "Using typed adapters instead of raw platform.call(), or needs to know what adapter methods are available"
5
- ---
6
-
7
- Typed adapters are ergonomic wrappers over `platform.call()` that provide full TypeScript autocomplete and compile-time type checking. They eliminate stringly-typed method names, manual `as Promise<T>` casts, and repeated credential passing.
8
-
9
- Both patterns work simultaneously -- adapters compile down to `platform.call()` with zero runtime overhead.
10
-
11
- **Coverage:** 12 integration adapters (58 methods) + 9 platform tool adapters (57 methods) = 115 total typed methods.
12
-
13
- ```typescript
14
- // Before: raw platform.call()
15
- const records = await platform.call({
16
- tool: 'attio',
17
- method: 'listRecords',
18
- credential: 'my-attio',
19
- params: { object: 'deals' }
20
- }) as unknown as QueryRecordsResult
21
-
22
- // After: typed adapter
23
- const attio = createAttioAdapter('my-attio')
24
- const records = await attio.listRecords({ object: 'deals' })
25
- // ^-- QueryRecordsResult (fully typed, autocomplete on params)
26
- ```
27
-
28
- All adapters are imported from `@elevasis/sdk/worker` -- the same subpath as `platform`.
29
-
30
- ---
31
-
32
- ## Quick Reference
33
-
34
- ### Integration Adapters (factory pattern, credential required)
35
-
36
- | Import | Methods |
37
- | --------------------------------- | ------- |
38
- | `createAttioAdapter(cred)` | 12 |
39
- | `createStripeAdapter(cred)` | 6 |
40
- | `createNotionAdapter(cred)` | 8 |
41
- | `createGoogleSheetsAdapter(cred)` | 13 |
42
- | `createInstantlyAdapter(cred)` | 5 |
43
- | `createSignatureApiAdapter(cred)` | 4 |
44
- | `createResendAdapter(cred)` | 2 |
45
- | `createDropboxAdapter(cred)` | 2 |
46
- | `createApifyAdapter(cred)` | 1 |
47
- | `createGmailAdapter(cred)` | 1 |
48
- | `createMailsoAdapter(cred)` | 1 |
49
- | `createTombaAdapter(cred)` | 3 |
50
-
51
- ### Platform Adapters (singletons, no credential)
52
-
53
- | Import | Methods |
54
- | --------------- | ------- |
55
- | `acqDb` | 35 |
56
- | `scheduler` | 9 |
57
- | `storage` | 5 |
58
- | `pdf` | 2 |
59
- | `approval` | 2 |
60
- | `notifications` | 1 |
61
- | `llm` | 1 |
62
- | `execution` | 1 |
63
- | `email` | 1 |
64
-
65
- ### Generic Factory
66
-
67
- | Import | Description |
68
- | --------------------------------------------- | ---------------------------------- |
69
- | `createAdapter<TMap>(tool, methods, cred?)` | Build custom adapters for any tool |
70
-
71
- ```typescript
72
- import {
73
- // Integration adapters
74
- createAttioAdapter, createStripeAdapter, createNotionAdapter,
75
- createGoogleSheetsAdapter, createInstantlyAdapter,
76
- createSignatureApiAdapter, createResendAdapter, createDropboxAdapter,
77
- createApifyAdapter, createGmailAdapter, createMailsoAdapter,
78
- createTombaAdapter,
79
- // Platform adapters
80
- acqDb, scheduler, storage, pdf, approval, notifications, llm, execution, email,
81
- // Generic factory
82
- createAdapter,
83
- } from '@elevasis/sdk/worker'
84
- ```
85
-
86
- ---
87
-
88
- ## Attio CRM Adapter
89
-
90
- Factory pattern -- bind a credential once, use 12 typed methods.
91
-
92
- ```typescript
93
- const attio = createAttioAdapter('my-attio-credential')
94
- ```
95
-
96
- ### Methods
97
-
98
- | Method | Params | Returns |
99
- | ----------------- | ----------------------- | ----------------------- |
100
- | `createRecord` | `CreateRecordParams` | `CreateRecordResult` |
101
- | `updateRecord` | `UpdateRecordParams` | `UpdateRecordResult` |
102
- | `listRecords` | `QueryRecordsParams` | `QueryRecordsResult` |
103
- | `getRecord` | `GetRecordParams` | `GetRecordResult` |
104
- | `deleteRecord` | `DeleteRecordParams` | `DeleteRecordResult` |
105
- | `listObjects` | none | `ListObjectsResult` |
106
- | `listAttributes` | `ListAttributesParams` | `ListAttributesResult` |
107
- | `createAttribute` | `CreateAttributeParams` | `CreateAttributeResult` |
108
- | `updateAttribute` | `UpdateAttributeParams` | `UpdateAttributeResult` |
109
- | `createNote` | `CreateNoteParams` | `CreateNoteResult` |
110
- | `listNotes` | `ListNotesParams` | `ListNotesResult` |
111
- | `deleteNote` | `DeleteNoteParams` | `DeleteNoteResult` |
112
-
113
- ### Examples
114
-
115
- ```typescript
116
- // Create a company record
117
- const company = await attio.createRecord({
118
- object: 'companies',
119
- values: {
120
- name: [{ value: 'Acme Corp' }],
121
- domains: [{ domain: 'acme.com' }],
122
- },
123
- })
124
-
125
- // Query deals with filters
126
- const deals = await attio.listRecords({
127
- object: 'deals',
128
- filter: {
129
- operator: 'and',
130
- filters: [
131
- { field: 'stage', operator: 'equals', value: 'proposal' },
132
- ],
133
- },
134
- sorts: [{ field: 'created_at', direction: 'desc' }],
135
- limit: 20,
136
- })
137
-
138
- // Get a specific record
139
- const record = await attio.getRecord({
140
- object: 'people',
141
- recordId: 'rec_abc123',
142
- })
143
-
144
- // List all objects (no params)
145
- const objects = await attio.listObjects()
146
-
147
- // Create a note on a record
148
- await attio.createNote({
149
- parentObject: 'deals',
150
- parentRecordId: 'rec_abc123',
151
- title: 'Discovery call notes',
152
- content: 'Key takeaways from the call...',
153
- })
154
- ```
155
-
156
- Multiple adapters with different credentials work simultaneously:
157
-
158
- ```typescript
159
- const prodAttio = createAttioAdapter('prod-attio')
160
- const testAttio = createAttioAdapter('test-attio')
161
- ```
162
-
163
- ---
164
-
165
- ## Stripe Adapter
166
-
167
- Factory pattern -- 6 methods for payment links and checkout sessions.
168
-
169
- ```typescript
170
- const stripe = createStripeAdapter('my-stripe-credential')
171
- ```
172
-
173
- ### Methods
174
-
175
- | Method | Params | Returns |
176
- | ----------------------- | ----------------------------- | ----------------------------- |
177
- | `createPaymentLink` | `CreatePaymentLinkParams` | `CreatePaymentLinkResult` |
178
- | `getPaymentLink` | `GetPaymentLinkParams` | `GetPaymentLinkResult` |
179
- | `updatePaymentLink` | `UpdatePaymentLinkParams` | `UpdatePaymentLinkResult` |
180
- | `listPaymentLinks` | `ListPaymentLinksParams` | `ListPaymentLinksResult` |
181
- | `createAutoPaymentLink` | `CreateAutoPaymentLinkParams` | `CreateAutoPaymentLinkResult` |
182
- | `createCheckoutSession` | `CreateCheckoutSessionParams` | `CreateCheckoutSessionResult` |
183
-
184
- ---
185
-
186
- ## Notion Adapter
187
-
188
- Factory pattern -- 8 methods for page and block operations.
189
-
190
- ```typescript
191
- const notion = createNotionAdapter('my-notion-credential')
192
- ```
193
-
194
- ### Methods
195
-
196
- | Method | Params | Returns |
197
- | ----------------- | ----------------------- | ----------------------- |
198
- | `listAllPages` | none | `ListAllPagesResult` |
199
- | `readPage` | `ReadPageParams` | `ReadPageResult` |
200
- | `createPage` | `CreatePageParams` | `CreatePageResult` |
201
- | `updatePageTitle` | `UpdatePageTitleParams` | `UpdatePageTitleResult` |
202
- | `appendBlocks` | `AppendBlocksParams` | `AppendBlocksResult` |
203
- | `updateBlocks` | `UpdateBlocksParams` | `UpdateBlocksResult` |
204
- | `deletePage` | `DeletePageParams` | `DeletePageResult` |
205
- | `deleteBlocks` | `DeleteBlocksParams` | `DeleteBlocksResult` |
206
-
207
- ---
208
-
209
- ## Google Sheets Adapter
210
-
211
- Factory pattern -- 13 methods including workflow-friendly helpers (getRowByValue, upsertRow, filterRows).
212
-
213
- ```typescript
214
- const sheets = createGoogleSheetsAdapter('my-google-credential')
215
- ```
216
-
217
- ### Methods
218
-
219
- | Method | Params | Returns |
220
- | ------------------------ | ------------------------------ | ------------------------------ |
221
- | `readSheet` | `ReadSheetParams` | `ReadSheetResult` |
222
- | `writeSheet` | `WriteSheetParams` | `WriteSheetResult` |
223
- | `appendRows` | `AppendRowsParams` | `AppendRowsResult` |
224
- | `clearRange` | `ClearRangeParams` | `ClearRangeResult` |
225
- | `getSpreadsheetMetadata` | `GetSpreadsheetMetadataParams` | `GetSpreadsheetMetadataResult` |
226
- | `batchUpdate` | `BatchUpdateParams` | `BatchUpdateResult` |
227
- | `getHeaders` | `GetHeadersParams` | `GetHeadersResult` |
228
- | `getLastRow` | `GetLastRowParams` | `GetLastRowResult` |
229
- | `getRowByValue` | `GetRowByValueParams` | `GetRowByValueResult` |
230
- | `updateRowByValue` | `UpdateRowByValueParams` | `UpdateRowByValueResult` |
231
- | `upsertRow` | `UpsertRowParams` | `UpsertRowResult` |
232
- | `filterRows` | `FilterRowsParams` | `FilterRowsResult` |
233
- | `deleteRowByValue` | `DeleteRowByValueParams` | `DeleteRowByValueResult` |
234
-
235
- ---
236
-
237
- ## Instantly Adapter
238
-
239
- Factory pattern -- 5 methods for email campaign management.
240
-
241
- ```typescript
242
- const instantly = createInstantlyAdapter('my-instantly-credential')
243
- ```
244
-
245
- ### Methods
246
-
247
- | Method | Params | Returns |
248
- | ----------------------- | ----------------------------- | ----------------------------- |
249
- | `sendReply` | `SendReplyParams` | `SendReplyResult` |
250
- | `removeFromSubsequence` | `RemoveFromSubsequenceParams` | `RemoveFromSubsequenceResult` |
251
- | `getEmails` | `GetEmailsParams` | `GetEmailsResult` |
252
- | `updateInterestStatus` | `UpdateInterestStatusParams` | `UpdateInterestStatusResult` |
253
- | `addToCampaign` | `AddToCampaignParams` | `AddToCampaignResult` |
254
-
255
- ---
256
-
257
- ## SignatureAPI Adapter
258
-
259
- Factory pattern -- 4 methods for eSignature envelope operations.
260
-
261
- ```typescript
262
- const signatureApi = createSignatureApiAdapter('my-signatureapi-credential')
263
- ```
264
-
265
- ### Methods
266
-
267
- | Method | Params | Returns |
268
- | ------------------ | ------------------------ | ------------------------ |
269
- | `createEnvelope` | `CreateEnvelopeParams` | `CreateEnvelopeResult` |
270
- | `voidEnvelope` | `VoidEnvelopeParams` | `VoidEnvelopeResult` |
271
- | `downloadDocument` | `DownloadDocumentParams` | `DownloadDocumentResult` |
272
- | `getEnvelope` | `GetEnvelopeParams` | `GetEnvelopeResult` |
273
-
274
- ---
275
-
276
- ## Resend Adapter
277
-
278
- Factory pattern -- 2 methods for transactional email.
279
-
280
- ```typescript
281
- const resend = createResendAdapter('my-resend-credential')
282
- ```
283
-
284
- ### Methods
285
-
286
- | Method | Params | Returns |
287
- | ----------- | ----------------------- | ----------------------- |
288
- | `sendEmail` | `ResendSendEmailParams` | `ResendSendEmailResult` |
289
- | `getEmail` | `ResendGetEmailParams` | `ResendGetEmailResult` |
290
-
291
- ---
292
-
293
- ## Dropbox Adapter
294
-
295
- Factory pattern -- 2 methods for file operations.
296
-
297
- ```typescript
298
- const dropbox = createDropboxAdapter('my-dropbox-credential')
299
- ```
300
-
301
- ### Methods
302
-
303
- | Method | Params | Returns |
304
- | -------------- | -------------------- | -------------------- |
305
- | `uploadFile` | `UploadFileParams` | `UploadFileResult` |
306
- | `createFolder` | `CreateFolderParams` | `CreateFolderResult` |
307
-
308
- ---
309
-
310
- ## Apify Adapter
311
-
312
- Factory pattern -- 1 method for running web scraping actors.
313
-
314
- ```typescript
315
- const apify = createApifyAdapter('my-apify-credential')
316
- ```
317
-
318
- ### Methods
319
-
320
- | Method | Params | Returns |
321
- | ---------- | ---------------- | ---------------- |
322
- | `runActor` | `RunActorParams` | `RunActorResult` |
323
-
324
- ---
325
-
326
- ## Gmail Adapter
327
-
328
- Factory pattern -- 1 method for sending email via Gmail API.
329
-
330
- ```typescript
331
- const gmail = createGmailAdapter('my-gmail-credential')
332
- ```
333
-
334
- ### Methods
335
-
336
- | Method | Params | Returns |
337
- | ----------- | ---------------------- | ---------------------- |
338
- | `sendEmail` | `GmailSendEmailParams` | `GmailSendEmailResult` |
339
-
340
- ---
341
-
342
- ## Mailso Adapter
343
-
344
- Factory pattern -- 1 method for email verification.
345
-
346
- ```typescript
347
- const mailso = createMailsoAdapter('my-mailso-credential')
348
- ```
349
-
350
- ### Methods
351
-
352
- | Method | Params | Returns |
353
- | ------------- | ------------------------- | ------------------------- |
354
- | `verifyEmail` | `MailsoVerifyEmailParams` | `MailsoVerifyEmailResult` |
355
-
356
- ---
357
-
358
- ## Tomba Adapter
359
-
360
- Factory pattern -- 3 methods for email discovery and verification.
361
-
362
- ```typescript
363
- const tomba = createTombaAdapter('elevasis-tomba')
364
- ```
365
-
366
- **Credential type:** `api-key-secret` (requires both API Key and API Secret)
367
-
368
- ### Methods
369
-
370
- | Method | Params | Returns |
371
- | --------------- | -------------------------- | -------------------------- |
372
- | `emailFinder` | `TombaEmailFinderParams` | `TombaEmailFinderResult` |
373
- | `domainSearch` | `TombaDomainSearchParams` | `TombaDomainSearchResult` |
374
- | `emailVerifier` | `TombaEmailVerifierParams` | `TombaEmailVerifierResult` |
375
-
376
- ### Examples
377
-
378
- ```typescript
379
- // Find email by name + domain
380
- const found = await tomba.emailFinder({
381
- domain: 'stripe.com',
382
- firstName: 'John',
383
- lastName: 'Doe',
384
- })
385
-
386
- // List all emails at a domain (up to 10)
387
- const results = await tomba.domainSearch({ domain: 'stripe.com' })
388
-
389
- // Verify a known email address
390
- const verified = await tomba.emailVerifier({ email: 'john@stripe.com' })
391
- ```
392
-
393
- ---
394
-
395
- ## Scheduler Adapter
396
-
397
- Singleton -- 9 methods for task schedule management.
398
-
399
- ```typescript
400
- import { scheduler } from '@elevasis/sdk/worker'
401
- ```
402
-
403
- ### Methods
404
-
405
- | Method | Params | Returns |
406
- | -------------------------------- | ------------------------------ | ---------------------- |
407
- | `createSchedule` | `CreateScheduleInput` | `TaskSchedule` |
408
- | `updateAnchor` | `{ scheduleId, anchorAt }` | `TaskSchedule` |
409
- | `deleteSchedule` | `{ scheduleId }` | `void` |
410
- | `findByIdempotencyKey` | `{ idempotencyKey }` | `TaskSchedule | null` |
411
- | `deleteScheduleByIdempotencyKey` | `{ idempotencyKey }` | `void` |
412
- | `listSchedules` | `{ status?, limit?, offset? }` | `TaskSchedule[]` |
413
- | `getSchedule` | `{ scheduleId }` | `TaskSchedule` |
414
- | `cancelSchedule` | `{ scheduleId }` | `void` |
415
- | `cancelSchedulesByMetadata` | `{ metadata }` | `{ cancelledCount }` |
416
-
417
- ### Examples
418
-
419
- ```typescript
420
- // Create a relative schedule (follow-up sequence)
421
- const schedule = await scheduler.createSchedule({
422
- organizationId: context.organizationId,
423
- name: 'Proposal follow-up',
424
- target: { resourceType: 'workflow', resourceId: 'send-followup' },
425
- scheduleConfig: {
426
- type: 'relative',
427
- anchorAt: '2026-03-15T10:00:00Z',
428
- anchorLabel: 'proposal_sent_date',
429
- items: [
430
- { offset: '+3d', payload: { step: 'first-followup' }, label: 'First follow-up' },
431
- { offset: '+7d', payload: { step: 'second-followup' }, label: 'Second follow-up' },
432
- ],
433
- },
434
- metadata: { dealId: 'deal-123', contactEmail: 'jane@acme.com' },
435
- idempotencyKey: 'proposal-followup-deal-123',
436
- })
437
-
438
- // Reschedule (update anchor)
439
- await scheduler.updateAnchor({
440
- scheduleId: schedule.id,
441
- anchorAt: '2026-03-20T10:00:00Z',
442
- })
443
-
444
- // Find by idempotency key (check if already created)
445
- const existing = await scheduler.findByIdempotencyKey({
446
- idempotencyKey: 'proposal-followup-deal-123',
447
- })
448
-
449
- // Cancel all schedules matching metadata
450
- await scheduler.cancelSchedulesByMetadata({
451
- metadata: { dealId: 'deal-123' },
452
- })
453
-
454
- // List active schedules
455
- const schedules = await scheduler.listSchedules({
456
- status: 'active',
457
- limit: 50,
458
- })
459
- ```
460
-
461
- ---
462
-
463
- ## Storage Adapter
464
-
465
- Singleton -- 5 methods for file storage operations.
466
-
467
- ```typescript
468
- import { storage } from '@elevasis/sdk/worker'
469
- ```
470
-
471
- All paths are relative to the organization's storage prefix. The platform injects the organization prefix server-side.
472
-
473
- ### Methods
474
-
475
- | Method | Params | Returns |
476
- | ----------------- | ----------------------- | ------------------------ |
477
- | `upload` | `StorageUploadInput` | `StorageUploadOutput` |
478
- | `download` | `StorageDownloadInput` | `StorageDownloadOutput` |
479
- | `createSignedUrl` | `StorageSignedUrlInput` | `StorageSignedUrlOutput` |
480
- | `delete` | `StorageDeleteInput` | `StorageDeleteOutput` |
481
- | `list` | `StorageListInput` | `StorageListOutput` |
482
-
483
- ### Examples
484
-
485
- ```typescript
486
- // Upload a PDF
487
- await storage.upload({
488
- bucket: 'acquisition',
489
- path: 'proposals/deal-123/proposal.pdf',
490
- content: base64PdfContent,
491
- contentType: 'application/pdf',
492
- })
493
-
494
- // Generate a signed URL (temporary access)
495
- const { signedUrl } = await storage.createSignedUrl({
496
- bucket: 'acquisition',
497
- path: 'proposals/deal-123/proposal.pdf',
498
- })
499
-
500
- // Download a file
501
- const file = await storage.download({
502
- bucket: 'acquisition',
503
- path: 'proposals/deal-123/proposal.pdf',
504
- })
505
-
506
- // List files under a prefix
507
- const files = await storage.list({
508
- bucket: 'acquisition',
509
- path: 'proposals/deal-123/',
510
- })
511
-
512
- // Delete a file
513
- await storage.delete({
514
- bucket: 'acquisition',
515
- path: 'proposals/deal-123/old-proposal.pdf',
516
- })
517
- ```
518
-
519
- ---
520
-
521
- ## Notification Adapter
522
-
523
- Singleton -- 1 method for sending in-app team notifications.
524
-
525
- ```typescript
526
- import { notifications } from '@elevasis/sdk/worker'
527
- ```
528
-
529
- `userId` and `organizationId` are injected server-side from the execution context -- you never pass them.
530
-
531
- ### Method
532
-
533
- | Method | Params | Returns |
534
- | -------- | ---------------------- | ------- |
535
- | `create` | `NotificationSDKInput` | `void` |
536
-
537
- `NotificationSDKInput` fields: `category`, `title`, `message`, `actionUrl?`, `metadata?`
538
-
539
- ### Example
540
-
541
- ```typescript
542
- await notifications.create({
543
- category: 'acquisition',
544
- title: 'New lead qualified',
545
- message: 'Acme Corp has been qualified and moved to proposal stage.',
546
- actionUrl: '/deals/deal-123',
547
- })
548
- ```
549
-
550
- ---
551
-
552
- ## LLM Adapter
553
-
554
- Singleton -- 1 method with a generic `<T>` for typed structured output.
555
-
556
- ```typescript
557
- import { llm } from '@elevasis/sdk/worker'
558
- ```
559
-
560
- No API keys needed -- keys are resolved server-side from environment variables.
561
-
562
- ### Method
563
-
564
- | Method | Params | Returns |
565
- | --------------- | -------------------------------------- | -------------------------- |
566
- | `generate<T>` | `Omit<LLMGenerateRequest, 'signal'>` | `LLMGenerateResponse<T>` |
567
-
568
- The `signal` property (AbortSignal) is not serializable over the postMessage boundary. Abort is handled at the worker level via the parent process sending an abort message.
569
-
570
- ### Example
571
-
572
- ```typescript
573
- interface Classification {
574
- category: 'interested' | 'not-interested' | 'bounced'
575
- confidence: number
576
- summary: string
577
- }
578
-
579
- const response = await llm.generate<Classification>({
580
- provider: 'anthropic',
581
- model: 'claude-sonnet-4-5',
582
- messages: [
583
- { role: 'system', content: 'Classify this email reply.' },
584
- { role: 'user', content: emailText },
585
- ],
586
- responseSchema: {
587
- type: 'object',
588
- properties: {
589
- category: { type: 'string', enum: ['interested', 'not-interested', 'bounced'] },
590
- confidence: { type: 'number', minimum: 0, maximum: 1 },
591
- summary: { type: 'string' },
592
- },
593
- required: ['category', 'confidence', 'summary'],
594
- },
595
- temperature: 0.1,
596
- })
597
-
598
- // response.output is typed as Classification
599
- const { category, confidence, summary } = response.output
600
- ```
601
-
602
- ---
603
-
604
- ## AcqDb Adapter
605
-
606
- Singleton -- 35 methods for acquisition database management (lists, companies, contacts, deals, deal-sync). `organizationId` is injected server-side -- never pass it.
607
-
608
- ```typescript
609
- import { acqDb } from '@elevasis/sdk/worker'
610
- ```
611
-
612
- ### Methods
613
-
614
- **List operations:**
615
-
616
- | Method | Params | Returns |
617
- | ------------ | -------------------------------------------- | ----------- |
618
- | `listLists` | none | `AcqList[]` |
619
- | `createList` | `Omit<CreateListParams, 'organizationId'>` | `AcqList` |
620
- | `updateList` | `{ id } & UpdateListParams` | `AcqList` |
621
- | `deleteList` | `{ id }` | `void` |
622
-
623
- **Company operations:**
624
-
625
- | Method | Params | Returns |
626
- | --------------- | ----------------------------------------------- | -------------------- |
627
- | `createCompany` | `Omit<CreateCompanyParams, 'organizationId'>` | `AcqCompany` |
628
- | `upsertCompany` | `Omit<UpsertCompanyParams, 'organizationId'>` | `AcqCompany` |
629
- | `updateCompany` | `{ id } & UpdateCompanyParams` | `AcqCompany` |
630
- | `getCompany` | `{ id }` | `AcqCompany | null` |
631
- | `listCompanies` | `{ filters? }` | `AcqCompany[]` |
632
- | `deleteCompany` | `{ id }` | `void` |
633
-
634
- **Contact operations:**
635
-
636
- | Method | Params | Returns |
637
- | -------------------- | ----------------------------------------------- | ------------------------------- |
638
- | `createContact` | `Omit<CreateContactParams, 'organizationId'>` | `AcqContact` |
639
- | `upsertContact` | `Omit<UpsertContactParams, 'organizationId'>` | `AcqContact` |
640
- | `updateContact` | `{ id } & UpdateContactParams` | `AcqContact` |
641
- | `getContact` | `{ id }` | `AcqContact | null` |
642
- | `getContactByEmail` | `{ email }` | `AcqContact | null` |
643
- | `listContacts` | `{ filters?, pagination? }` | `PaginatedResult<AcqContact>` |
644
- | `deleteContact` | `{ id }` | `void` |
645
- | `bulkImportContacts` | `Omit<BulkImportParams, 'organizationId'>` | `BulkImportResult` |
646
-
647
- **Deal operations:**
648
-
649
- | Method | Params | Returns |
650
- | ---------------------- | -------------------------------------------- | ----------------- |
651
- | `upsertDeal` | `Omit<UpsertDealParams, 'organizationId'>` | `AcqDeal` |
652
- | `getDealByEmail` | `{ email }` | `AcqDeal | null` |
653
- | `getDealByEnvelopeId` | `{ envelopeId }` | `AcqDeal | null` |
654
- | `updateDealEnvelopeId` | `{ attioDealId, envelopeId }` | `AcqDeal | null` |
655
- | `getDealByAttioId` | `{ attioDealId }` | `AcqDeal | null` |
656
-
657
- **Deal-sync operations:**
658
-
659
- | Method | Params | Returns |
660
- | ------------------------------- | ------------------------------------------------------- | ------------------------------------- |
661
- | `updateDiscoveryData` | `Omit<UpdateDiscoveryDataParams, 'organizationId'>` | `void` |
662
- | `updateProposalData` | `Omit<UpdateProposalDataParams, 'organizationId'>` | `void` |
663
- | `markProposalSent` | `Omit<MarkProposalSentParams, 'organizationId'>` | `void` |
664
- | `markProposalReviewed` | `Omit<MarkProposalReviewedParams, 'organizationId'>` | `void` |
665
- | `updateCloseLostReason` | `Omit<UpdateCloseLostReasonParams, 'organizationId'>` | `void` |
666
- | `updateFees` | `Omit<UpdateFeesParams, 'organizationId'>` | `void` |
667
- | `syncDealStage` | `Omit<SyncDealStageParams, 'organizationId'>` | `void` |
668
- | `setContactNurture` | `Omit<SetContactNurtureParams, 'organizationId'>` | `void` |
669
- | `cancelSchedulesAndHitlByEmail` | `Omit<..., 'organizationId'>` | `{ schedulesCancelled, hitlDeleted }` |
670
- | `cancelHitlByDealId` | `Omit<..., 'organizationId'>` | `{ hitlDeleted }` |
671
- | `clearDealFields` | `Omit<ClearDealFieldsParams, 'organizationId'>` | `void` |
672
- | `deleteDeal` | `Omit<DeleteDealParams, 'organizationId'>` | `void` |
673
-
674
- ### Example
675
-
676
- ```typescript
677
- const deal = await acqDb.getDealByEmail({ email: 'jane@acme.com' })
678
- if (!deal) {
679
- await acqDb.upsertDeal({
680
- attioDealId: 'deal-123',
681
- contactEmail: 'jane@acme.com',
682
- })
683
- }
684
-
685
- // Bulk import contacts
686
- await acqDb.bulkImportContacts({
687
- listId: 'list-abc',
688
- contacts: [
689
- { email: 'a@example.com', firstName: 'Alice' },
690
- { email: 'b@example.com', firstName: 'Bob' },
691
- ],
692
- })
693
- ```
694
-
695
- ---
696
-
697
- ## PDF Adapter
698
-
699
- Singleton -- 2 methods for rendering PDFDocument structures to files or buffers. No credential required.
700
-
701
- ```typescript
702
- import { pdf } from '@elevasis/sdk/worker'
703
- ```
704
-
705
- ### Methods
706
-
707
- | Method | Params | Returns |
708
- | ---------------- | ------------------------------------------------- | --------------------------- |
709
- | `render` | `{ document, theme?, storage: { bucket, path } }` | `{ success, pdfUrl, size }` |
710
- | `renderToBuffer` | `{ document, theme? }` | `{ buffer }` |
711
-
712
- ### Example
713
-
714
- ```typescript
715
- // Render to storage (returns a URL)
716
- const result = await pdf.render({
717
- document: proposalDocument,
718
- storage: { bucket: 'acquisition', path: 'proposals/deal-123/proposal.pdf' },
719
- })
720
- console.log(result.pdfUrl)
721
-
722
- // Render to buffer (for inline processing)
723
- const { buffer } = await pdf.renderToBuffer({
724
- document: proposalDocument,
725
- })
726
- ```
727
-
728
- ---
729
-
730
- ## Approval Adapter
731
-
732
- Singleton -- 2 methods for creating and managing human-in-the-loop (HITL) approval tasks. No credential required.
733
-
734
- ```typescript
735
- import { approval } from '@elevasis/sdk/worker'
736
- ```
737
-
738
- ### Methods
739
-
740
- | Method | Params | Returns |
741
- | ------------------ | ---------------------------------------------------------------------------------------- | ------------- |
742
- | `create` | `{ actions, context, description?, priority?, humanCheckpoint?, metadata?, expiresAt? }` | `{ id }` |
743
- | `deleteByMetadata` | `{ metadata, status? }` | `{ deleted }` |
744
-
745
- ### Example
746
-
747
- ```typescript
748
- // Create an approval gate
749
- const task = await approval.create({
750
- actions: [
751
- { id: 'approve', label: 'Approve', type: 'primary' },
752
- { id: 'reject', label: 'Reject', type: 'danger' },
753
- ],
754
- context: { dealId: 'deal-123', proposalUrl: 'https://...' },
755
- description: 'Review proposal for Acme Corp',
756
- humanCheckpoint: 'proposal-review',
757
- metadata: { dealId: 'deal-123' },
758
- })
759
-
760
- // Clean up stale tasks
761
- await approval.deleteByMetadata({
762
- metadata: { dealId: 'deal-123' },
763
- status: 'pending',
764
- })
765
- ```
766
-
767
- ---
768
-
769
- ## Execution Adapter
770
-
771
- Singleton -- 1 method for triggering another resource (workflow or agent) as a nested child execution. No credential required.
772
-
773
- ```typescript
774
- import { execution } from '@elevasis/sdk/worker'
775
- ```
776
-
777
- ### Method
778
-
779
- | Method | Params | Returns |
780
- | --------- | ------------------------ | ------------------------------------------ |
781
- | `trigger` | `{ resourceId, input? }` | `{ success, executionId, output, error? }` |
782
-
783
- ### Example
784
-
785
- ```typescript
786
- const result = await execution.trigger({
787
- resourceId: 'send-welcome-sequence',
788
- input: { userId: newUser.id, email: newUser.email },
789
- })
790
-
791
- if (!result.success) {
792
- throw new Error(`Child workflow failed: ${result.error}`)
793
- }
794
- ```
795
-
796
- Nested executions are tracked with depth up to a maximum of 5 levels.
797
-
798
- ---
799
-
800
- ## Email Adapter
801
-
802
- Singleton -- 1 method for sending platform emails to organization members (from `notifications@elevasis.io`). For client-facing emails, use the Resend or Instantly integration adapters instead.
803
-
804
- ```typescript
805
- import { email } from '@elevasis/sdk/worker'
806
- ```
807
-
808
- ### Method
809
-
810
- | Method | Params | Returns |
811
- | ------ | ------------------------------------------------------------------------------- | --------------------------- |
812
- | `send` | `{ subject, html?, text?, userIds?, targetRole?, targetAll?, replyTo?, tags? }` | `{ sent, failed, errors? }` |
813
-
814
- ### Example
815
-
816
- ```typescript
817
- // Notify all org members
818
- await email.send({
819
- subject: 'New deal closed',
820
- text: 'Acme Corp has signed the contract.',
821
- targetAll: true,
822
- })
823
-
824
- // Notify specific users
825
- await email.send({
826
- subject: 'Action required',
827
- html: '\<p\>Please review the proposal.\</p\>',
828
- userIds: ['user-abc', 'user-def'],
829
- })
830
- ```
831
-
832
- ---
833
-
834
- ## Custom Adapters with `createAdapter`
835
-
836
- The generic `createAdapter` factory is exported for building adapters for any tool. Define a type map and call the factory.
837
-
838
- ```typescript
839
- import { createAdapter } from '@elevasis/sdk/worker'
840
-
841
- // 1. Define a type map
842
- type MyToolMap = {
843
- doSomething: { params: { input: string }; result: { output: string } }
844
- listItems: { params: { limit?: number }; result: { items: string[] } }
845
- getStatus: { params: Record<string, never>; result: { healthy: boolean } }
846
- }
847
-
848
- // 2. Create the adapter
849
- const myTool = createAdapter<MyToolMap>('my-tool', [
850
- 'doSomething', 'listItems', 'getStatus',
851
- ], 'my-credential') // credential is optional
852
-
853
- // 3. Use it (fully typed)
854
- const result = await myTool.doSomething({ input: 'hello' })
855
- // ^-- { output: string }
856
- const status = await myTool.getStatus()
857
- // ^-- { healthy: boolean } (zero-arg because params is Record<string, never>)
858
- ```
859
-
860
- Method names are compile-time checked against the type map keys -- misspelling a method name is a compile error.
861
-
862
- ---
863
-
864
- All typed adapters compile to `platform.call()` internally -- you can use either interchangeably.
865
-
866
- ## When to Use Adapters vs `platform.call()`
867
-
868
- | Scenario | Use |
869
- | --------------------------------------------------------------------- | ----------------- |
870
- | Tool has a typed adapter (all integrations + platform tools) | Adapter |
871
- | Need autocomplete and type safety | Adapter |
872
- | New dispatcher method added server-side, no SDK update yet | `platform.call()` |
873
- | Tool without a typed adapter (supabase, session-memory, status, http) | `platform.call()` |
874
-
875
- `platform.call()` remains the universal escape hatch. Every adapter call compiles down to it. Both approaches work simultaneously with no conflicts.
876
-
877
- ---
878
-
879
- For the full inventory of all platform tools (including those without typed adapters), see [Platform Tools](index.mdx).
880
-
881
- ---
882
-
883
- ## Error Handling
884
-
885
- All adapter calls throw `PlatformToolError` on failure, with a `code` field and `retryable` flag:
886
-
887
- ```typescript
888
- import { PlatformToolError } from '@elevasis/sdk/worker'
889
-
890
- try {
891
- await attio.listRecords({ object: 'deals' })
892
- } catch (err) {
893
- if (err instanceof PlatformToolError) {
894
- console.log(err.message) // Human-readable error
895
- console.log(err.code) // e.g., 'rate_limit_exceeded', 'credentials_missing'
896
- console.log(err.retryable) // true for transient errors
897
- }
898
- }
899
- ```
900
-
901
- Retryable error codes: `rate_limit_exceeded`, `network_error`, `timeout_error`, `api_error`, `service_unavailable`, `server_unavailable`.
902
-
903
- Timeouts: LLM calls have a 120s timeout. All other tool calls have a 60s timeout.
904
-
905
- ---
906
-
907
- **Last Updated:** 2026-03-05