@apideck/unify 0.40.0 → 0.41.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.
Files changed (96) hide show
  1. package/jsr.json +1 -1
  2. package/lib/config.d.ts +4 -4
  3. package/lib/config.js +4 -4
  4. package/package.json +6 -2
  5. package/src/__tests__/activities.test.ts +1141 -0
  6. package/src/__tests__/agedcreditors.test.ts +280 -0
  7. package/src/__tests__/ageddebtors.test.ts +280 -0
  8. package/src/__tests__/apideckcompanies.test.ts +1082 -0
  9. package/src/__tests__/apideckcustomers.test.ts +364 -0
  10. package/src/__tests__/apideckdepartments.test.ts +497 -0
  11. package/src/__tests__/apiresources.test.ts +62 -0
  12. package/src/__tests__/apis.test.ts +216 -0
  13. package/src/__tests__/applicants.test.ts +1445 -0
  14. package/src/__tests__/applications.test.ts +515 -0
  15. package/src/__tests__/assertions.ts +13 -0
  16. package/src/__tests__/attachments.test.ts +371 -0
  17. package/src/__tests__/balancesheet.test.ts +453 -0
  18. package/src/__tests__/bankaccounts.test.ts +324 -0
  19. package/src/__tests__/bankfeedaccounts.test.ts +343 -0
  20. package/src/__tests__/bankfeedstatements.test.ts +408 -0
  21. package/src/__tests__/billpayments.test.ts +1031 -0
  22. package/src/__tests__/bills.test.ts +1630 -0
  23. package/src/__tests__/categories.test.ts +127 -0
  24. package/src/__tests__/collections.test.ts +120 -0
  25. package/src/__tests__/collectiontags.test.ts +68 -0
  26. package/src/__tests__/collectionticketcomments.test.ts +501 -0
  27. package/src/__tests__/collectiontickets.test.ts +627 -0
  28. package/src/__tests__/collectionusers.test.ts +126 -0
  29. package/src/__tests__/companies.test.ts +1642 -0
  30. package/src/__tests__/companyinfo.test.ts +219 -0
  31. package/src/__tests__/connectionconsent.test.ts +89 -0
  32. package/src/__tests__/connectionconsents.test.ts +31 -0
  33. package/src/__tests__/connectioncustommappings.test.ts +69 -0
  34. package/src/__tests__/connections.test.ts +2127 -0
  35. package/src/__tests__/connectionsettings.test.ts +687 -0
  36. package/src/__tests__/connectordocs.test.ts +29 -0
  37. package/src/__tests__/connectors.test.ts +753 -0
  38. package/src/__tests__/consumerrequestcounts.test.ts +42 -0
  39. package/src/__tests__/consumers.test.ts +523 -0
  40. package/src/__tests__/contacts.test.ts +1421 -0
  41. package/src/__tests__/createcallback.test.ts +36 -0
  42. package/src/__tests__/creditnotes.test.ts +2040 -0
  43. package/src/__tests__/customers.test.ts +1600 -0
  44. package/src/__tests__/customfields.test.ts +52 -0
  45. package/src/__tests__/custommappings.test.ts +65 -0
  46. package/src/__tests__/customobjects.test.ts +408 -0
  47. package/src/__tests__/customobjectschemas.test.ts +734 -0
  48. package/src/__tests__/departments.test.ts +529 -0
  49. package/src/__tests__/drivegroups.test.ts +496 -0
  50. package/src/__tests__/drives.test.ts +487 -0
  51. package/src/__tests__/employeepayrolls.test.ts +491 -0
  52. package/src/__tests__/employees.test.ts +2968 -0
  53. package/src/__tests__/employeeschedules.test.ts +457 -0
  54. package/src/__tests__/eventlogs.test.ts +158 -0
  55. package/src/__tests__/expensecategories.test.ts +324 -0
  56. package/src/__tests__/expensereports.test.ts +634 -0
  57. package/src/__tests__/expenses.test.ts +867 -0
  58. package/src/__tests__/files.test.ts +506 -0
  59. package/src/__tests__/files.ts +56 -0
  60. package/src/__tests__/folders.test.ts +390 -0
  61. package/src/__tests__/invoiceitems.test.ts +855 -0
  62. package/src/__tests__/invoices.test.ts +2173 -0
  63. package/src/__tests__/jobs.test.ts +1150 -0
  64. package/src/__tests__/journalentries.test.ts +1542 -0
  65. package/src/__tests__/leads.test.ts +1341 -0
  66. package/src/__tests__/ledgeraccounts.test.ts +829 -0
  67. package/src/__tests__/locations.test.ts +856 -0
  68. package/src/__tests__/logs.test.ts +137 -0
  69. package/src/__tests__/messages.test.ts +588 -0
  70. package/src/__tests__/notes.test.ts +523 -0
  71. package/src/__tests__/opportunities.test.ts +718 -0
  72. package/src/__tests__/orders.test.ts +854 -0
  73. package/src/__tests__/payments.test.ts +867 -0
  74. package/src/__tests__/payrolls.test.ts +485 -0
  75. package/src/__tests__/pipelines.test.ts +574 -0
  76. package/src/__tests__/products.test.ts +509 -0
  77. package/src/__tests__/profitandloss.test.ts +223 -0
  78. package/src/__tests__/projects.test.ts +480 -0
  79. package/src/__tests__/proxy.test.ts +41 -0
  80. package/src/__tests__/purchaseorders.test.ts +2139 -0
  81. package/src/__tests__/quotes.test.ts +678 -0
  82. package/src/__tests__/refunds.test.ts +812 -0
  83. package/src/__tests__/sessions.test.ts +72 -0
  84. package/src/__tests__/sharedlinks.test.ts +511 -0
  85. package/src/__tests__/stores.test.ts +41 -0
  86. package/src/__tests__/subsidiaries.test.ts +496 -0
  87. package/src/__tests__/suppliers.test.ts +1574 -0
  88. package/src/__tests__/taxrates.test.ts +701 -0
  89. package/src/__tests__/testclient.ts +48 -0
  90. package/src/__tests__/timeoffrequests.test.ts +588 -0
  91. package/src/__tests__/trackingcategories.test.ts +515 -0
  92. package/src/__tests__/uploadsessions.test.ts +221 -0
  93. package/src/__tests__/users.test.ts +1020 -0
  94. package/src/__tests__/validateconnection.test.ts +34 -0
  95. package/src/__tests__/webhooks.test.ts +254 -0
  96. package/src/lib/config.ts +4 -4
@@ -0,0 +1,2127 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { expect, test } from "vitest";
6
+ import { Apideck } from "../index.js";
7
+ import { createTestHTTPClient } from "./testclient.js";
8
+
9
+ test("Connections Vault Connections All", async () => {
10
+ const testHttpClient = createTestHTTPClient("vault.connectionsAll");
11
+
12
+ const apideck = new Apideck({
13
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
14
+ httpClient: testHttpClient,
15
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
16
+ });
17
+
18
+ const result = await apideck.vault.connections.list({
19
+ consumerId: "test-consumer",
20
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
21
+ api: "crm",
22
+ configured: true,
23
+ });
24
+ expect(result.httpMeta.response.status).toBe(200);
25
+ expect(result.getConnectionsResponse).toBeDefined();
26
+ expect(result.getConnectionsResponse).toEqual({
27
+ statusCode: 200,
28
+ status: "OK",
29
+ data: [
30
+ {
31
+ id: "crm+salesforce",
32
+ serviceId: "salesforce",
33
+ name: "Salesforce",
34
+ tagLine:
35
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
36
+ unifiedApi: "crm",
37
+ state: "authorized",
38
+ integrationState: "configured",
39
+ authType: "oauth2",
40
+ oauthGrantType: "authorization_code",
41
+ enabled: true,
42
+ website: "https://www.salesforce.com",
43
+ icon:
44
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
45
+ logo:
46
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
47
+ authorizeUrl:
48
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
49
+ revokeUrl:
50
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
51
+ settings: {
52
+ "instance_url": "https://eu28.salesforce.com",
53
+ "api_key": "12345xxxxxx",
54
+ },
55
+ metadata: {
56
+ "account": {
57
+ "name": "My Company",
58
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
59
+ },
60
+ "plan": "enterprise",
61
+ },
62
+ formFields: [
63
+ {
64
+ id: "instance_url",
65
+ label: "Instance url",
66
+ placeholder: "",
67
+ type: "text",
68
+ required: true,
69
+ customField: false,
70
+ allowCustomValues: false,
71
+ disabled: false,
72
+ sensitive: false,
73
+ },
74
+ {
75
+ id: "api_key",
76
+ label: "API Key",
77
+ placeholder: "",
78
+ type: "text",
79
+ required: true,
80
+ customField: false,
81
+ allowCustomValues: false,
82
+ disabled: false,
83
+ sensitive: true,
84
+ },
85
+ ],
86
+ configuration: [
87
+ {
88
+ resource: "leads",
89
+ defaults: [
90
+ {
91
+ target: "custom_fields",
92
+ id: "ProductInterest",
93
+ options: [
94
+ {
95
+ label: "General Channel",
96
+ value: "general",
97
+ optionType: "simple",
98
+ },
99
+ ],
100
+ value: true,
101
+ },
102
+ {
103
+ target: "custom_fields",
104
+ id: "ProductInterest",
105
+ options: [
106
+ {
107
+ label: "General Channel",
108
+ value: true,
109
+ optionType: "simple",
110
+ },
111
+ {
112
+ label: "General Channel",
113
+ value: "general",
114
+ optionType: "simple",
115
+ },
116
+ ],
117
+ value: true,
118
+ },
119
+ {
120
+ target: "custom_fields",
121
+ id: "ProductInterest",
122
+ options: [
123
+ {
124
+ id: "1234",
125
+ label: "General Channel",
126
+ options: [],
127
+ optionType: "group",
128
+ },
129
+ {
130
+ label: "General Channel",
131
+ value: 123,
132
+ optionType: "simple",
133
+ },
134
+ ],
135
+ value: 10.5,
136
+ },
137
+ ],
138
+ },
139
+ {
140
+ resource: "leads",
141
+ defaults: [
142
+ {
143
+ target: "custom_fields",
144
+ id: "ProductInterest",
145
+ options: [
146
+ {
147
+ id: "1234",
148
+ label: "General Channel",
149
+ options: [
150
+ {
151
+ label: "General Channel",
152
+ value: 12.5,
153
+ optionType: "simple",
154
+ },
155
+ {
156
+ label: "General Channel",
157
+ value: "general",
158
+ optionType: "simple",
159
+ },
160
+ {
161
+ label: "General Channel",
162
+ value: 123,
163
+ optionType: "simple",
164
+ },
165
+ ],
166
+ optionType: "group",
167
+ },
168
+ {
169
+ id: "1234",
170
+ label: "General Channel",
171
+ options: [],
172
+ optionType: "group",
173
+ },
174
+ {
175
+ id: "1234",
176
+ label: "General Channel",
177
+ options: [
178
+ {
179
+ label: "General Channel",
180
+ value: [
181
+ "team",
182
+ "general",
183
+ ],
184
+ optionType: "simple",
185
+ },
186
+ ],
187
+ optionType: "group",
188
+ },
189
+ ],
190
+ value: "GC5000 series",
191
+ },
192
+ ],
193
+ },
194
+ ],
195
+ configurableResources: [
196
+ "opportunities",
197
+ "companies",
198
+ "contacts",
199
+ "leads",
200
+ ],
201
+ resourceSchemaSupport: [
202
+ "leads",
203
+ ],
204
+ resourceSettingsSupport: [
205
+ "leads",
206
+ ],
207
+ settingsRequiredForAuthorization: [
208
+ "client_id",
209
+ "client_secret",
210
+ ],
211
+ subscriptions: [
212
+ {
213
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
214
+ unifyEventTypes: [
215
+ "crm.contact.created",
216
+ ],
217
+ downstreamEventTypes: [
218
+ "contacts.CREATED",
219
+ ],
220
+ executeUrl:
221
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
222
+ createdAt: "2020-10-01T12:00:00.000Z",
223
+ },
224
+ ],
225
+ hasGuide: true,
226
+ customMappings: [
227
+ {
228
+ id: "hris+employees+first_aid_training",
229
+ label: "First Aid Training",
230
+ description: "First Aid Training completed after 2019-01-01",
231
+ value: "$.root.training.first_aid",
232
+ key: "first_aid_training",
233
+ required: false,
234
+ customField: true,
235
+ consumerId: "test_user_id",
236
+ example: "Some value",
237
+ },
238
+ {
239
+ id: "hris+employees+first_aid_training",
240
+ label: "First Aid Training",
241
+ description: "First Aid Training completed after 2019-01-01",
242
+ value: "$.root.training.first_aid",
243
+ key: "first_aid_training",
244
+ required: false,
245
+ customField: true,
246
+ consumerId: "test_user_id",
247
+ example: "Some value",
248
+ },
249
+ {
250
+ id: "hris+employees+first_aid_training",
251
+ label: "First Aid Training",
252
+ description: "First Aid Training completed after 2019-01-01",
253
+ value: "$.root.training.first_aid",
254
+ key: "first_aid_training",
255
+ required: false,
256
+ customField: true,
257
+ consumerId: "test_user_id",
258
+ example: "Some value",
259
+ },
260
+ ],
261
+ createdAt: 1615563533390,
262
+ updatedAt: 1616662325753,
263
+ },
264
+ {
265
+ id: "crm+salesforce",
266
+ serviceId: "salesforce",
267
+ name: "Salesforce",
268
+ tagLine:
269
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
270
+ unifiedApi: "crm",
271
+ state: "authorized",
272
+ integrationState: "configured",
273
+ authType: "oauth2",
274
+ oauthGrantType: "authorization_code",
275
+ enabled: true,
276
+ website: "https://www.salesforce.com",
277
+ icon:
278
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
279
+ logo:
280
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
281
+ authorizeUrl:
282
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
283
+ revokeUrl:
284
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
285
+ settings: {
286
+ "instance_url": "https://eu28.salesforce.com",
287
+ "api_key": "12345xxxxxx",
288
+ },
289
+ metadata: {
290
+ "account": {
291
+ "name": "My Company",
292
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
293
+ },
294
+ "plan": "enterprise",
295
+ },
296
+ formFields: [
297
+ {
298
+ id: "instance_url",
299
+ label: "Instance url",
300
+ placeholder: "",
301
+ type: "text",
302
+ required: true,
303
+ customField: false,
304
+ allowCustomValues: false,
305
+ disabled: false,
306
+ sensitive: false,
307
+ },
308
+ {
309
+ id: "api_key",
310
+ label: "API Key",
311
+ placeholder: "",
312
+ type: "text",
313
+ required: true,
314
+ customField: false,
315
+ allowCustomValues: false,
316
+ disabled: false,
317
+ sensitive: true,
318
+ },
319
+ ],
320
+ configuration: [
321
+ {
322
+ resource: "leads",
323
+ defaults: [
324
+ {
325
+ target: "custom_fields",
326
+ id: "ProductInterest",
327
+ options: [
328
+ {
329
+ label: "General Channel",
330
+ value: 12.5,
331
+ optionType: "simple",
332
+ },
333
+ {
334
+ label: "General Channel",
335
+ value: 12.5,
336
+ optionType: "simple",
337
+ },
338
+ ],
339
+ value: [
340
+ 10.5,
341
+ ],
342
+ },
343
+ {
344
+ target: "custom_fields",
345
+ id: "ProductInterest",
346
+ options: [
347
+ {
348
+ label: "General Channel",
349
+ value: "general",
350
+ optionType: "simple",
351
+ },
352
+ ],
353
+ value: "GC5000 series",
354
+ },
355
+ ],
356
+ },
357
+ ],
358
+ configurableResources: [
359
+ "opportunities",
360
+ "companies",
361
+ "contacts",
362
+ "leads",
363
+ ],
364
+ resourceSchemaSupport: [
365
+ "leads",
366
+ ],
367
+ resourceSettingsSupport: [
368
+ "leads",
369
+ ],
370
+ settingsRequiredForAuthorization: [
371
+ "client_id",
372
+ "client_secret",
373
+ ],
374
+ subscriptions: [
375
+ {
376
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
377
+ unifyEventTypes: [
378
+ "crm.contact.created",
379
+ ],
380
+ downstreamEventTypes: [
381
+ "contacts.CREATED",
382
+ ],
383
+ executeUrl:
384
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
385
+ createdAt: "2020-10-01T12:00:00.000Z",
386
+ },
387
+ {
388
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
389
+ unifyEventTypes: [
390
+ "crm.contact.created",
391
+ ],
392
+ downstreamEventTypes: [
393
+ "contacts.CREATED",
394
+ ],
395
+ executeUrl:
396
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
397
+ createdAt: "2020-10-01T12:00:00.000Z",
398
+ },
399
+ {
400
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
401
+ unifyEventTypes: [
402
+ "crm.contact.created",
403
+ ],
404
+ downstreamEventTypes: [
405
+ "contacts.CREATED",
406
+ ],
407
+ executeUrl:
408
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
409
+ createdAt: "2020-10-01T12:00:00.000Z",
410
+ },
411
+ ],
412
+ hasGuide: true,
413
+ customMappings: [
414
+ {
415
+ id: "hris+employees+first_aid_training",
416
+ label: "First Aid Training",
417
+ description: "First Aid Training completed after 2019-01-01",
418
+ value: "$.root.training.first_aid",
419
+ key: "first_aid_training",
420
+ required: false,
421
+ customField: true,
422
+ consumerId: "test_user_id",
423
+ example: "Some value",
424
+ },
425
+ ],
426
+ createdAt: 1615563533390,
427
+ updatedAt: 1616662325753,
428
+ },
429
+ {
430
+ id: "crm+salesforce",
431
+ serviceId: "salesforce",
432
+ name: "Salesforce",
433
+ tagLine:
434
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
435
+ unifiedApi: "crm",
436
+ state: "authorized",
437
+ integrationState: "configured",
438
+ authType: "oauth2",
439
+ oauthGrantType: "authorization_code",
440
+ enabled: true,
441
+ website: "https://www.salesforce.com",
442
+ icon:
443
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
444
+ logo:
445
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
446
+ authorizeUrl:
447
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
448
+ revokeUrl:
449
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
450
+ settings: {
451
+ "instance_url": "https://eu28.salesforce.com",
452
+ "api_key": "12345xxxxxx",
453
+ },
454
+ metadata: {
455
+ "account": {
456
+ "name": "My Company",
457
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
458
+ },
459
+ "plan": "enterprise",
460
+ },
461
+ formFields: [
462
+ {
463
+ id: "instance_url",
464
+ label: "Instance url",
465
+ placeholder: "",
466
+ type: "text",
467
+ required: true,
468
+ customField: false,
469
+ allowCustomValues: false,
470
+ disabled: false,
471
+ sensitive: false,
472
+ },
473
+ {
474
+ id: "api_key",
475
+ label: "API Key",
476
+ placeholder: "",
477
+ type: "text",
478
+ required: true,
479
+ customField: false,
480
+ allowCustomValues: false,
481
+ disabled: false,
482
+ sensitive: true,
483
+ },
484
+ ],
485
+ configuration: [
486
+ {
487
+ resource: "leads",
488
+ defaults: [
489
+ {
490
+ target: "custom_fields",
491
+ id: "ProductInterest",
492
+ options: [
493
+ {
494
+ label: "General Channel",
495
+ value: true,
496
+ optionType: "simple",
497
+ },
498
+ {
499
+ id: "1234",
500
+ label: "General Channel",
501
+ options: [
502
+ {
503
+ label: "General Channel",
504
+ value: [
505
+ "team",
506
+ "general",
507
+ ],
508
+ optionType: "simple",
509
+ },
510
+ {
511
+ label: "General Channel",
512
+ value: [
513
+ "team",
514
+ "general",
515
+ ],
516
+ optionType: "simple",
517
+ },
518
+ {
519
+ label: "General Channel",
520
+ value: "general",
521
+ optionType: "simple",
522
+ },
523
+ ],
524
+ optionType: "group",
525
+ },
526
+ {
527
+ label: "General Channel",
528
+ value: "general",
529
+ optionType: "simple",
530
+ },
531
+ ],
532
+ value: [
533
+ "GC6000 series",
534
+ 10,
535
+ "GC6000 series",
536
+ ],
537
+ },
538
+ {
539
+ target: "custom_fields",
540
+ id: "ProductInterest",
541
+ options: [
542
+ {
543
+ id: "1234",
544
+ label: "General Channel",
545
+ options: [],
546
+ optionType: "group",
547
+ },
548
+ {
549
+ label: "General Channel",
550
+ value: 123,
551
+ optionType: "simple",
552
+ },
553
+ {
554
+ id: "1234",
555
+ label: "General Channel",
556
+ options: [
557
+ {
558
+ label: "General Channel",
559
+ value: 123,
560
+ optionType: "simple",
561
+ },
562
+ {
563
+ label: "General Channel",
564
+ value: 123,
565
+ optionType: "simple",
566
+ },
567
+ ],
568
+ optionType: "group",
569
+ },
570
+ ],
571
+ value: "GC5000 series",
572
+ },
573
+ {
574
+ target: "custom_fields",
575
+ id: "ProductInterest",
576
+ options: [
577
+ {
578
+ label: "General Channel",
579
+ value: "general",
580
+ optionType: "simple",
581
+ },
582
+ {
583
+ id: "1234",
584
+ label: "General Channel",
585
+ options: [
586
+ {
587
+ label: "General Channel",
588
+ value: true,
589
+ optionType: "simple",
590
+ },
591
+ {
592
+ label: "General Channel",
593
+ value: 12.5,
594
+ optionType: "simple",
595
+ },
596
+ {
597
+ label: "General Channel",
598
+ value: [
599
+ "team",
600
+ "general",
601
+ ],
602
+ optionType: "simple",
603
+ },
604
+ ],
605
+ optionType: "group",
606
+ },
607
+ {
608
+ id: "1234",
609
+ label: "General Channel",
610
+ options: [],
611
+ optionType: "group",
612
+ },
613
+ ],
614
+ value: 10.5,
615
+ },
616
+ ],
617
+ },
618
+ {
619
+ resource: "leads",
620
+ defaults: [
621
+ {
622
+ target: "custom_fields",
623
+ id: "ProductInterest",
624
+ options: [
625
+ {
626
+ id: "1234",
627
+ label: "General Channel",
628
+ options: [
629
+ {
630
+ label: "General Channel",
631
+ value: "general",
632
+ optionType: "simple",
633
+ },
634
+ ],
635
+ optionType: "group",
636
+ },
637
+ {
638
+ id: "1234",
639
+ label: "General Channel",
640
+ options: [
641
+ {
642
+ label: "General Channel",
643
+ value: true,
644
+ optionType: "simple",
645
+ },
646
+ {
647
+ label: "General Channel",
648
+ value: 12.5,
649
+ optionType: "simple",
650
+ },
651
+ ],
652
+ optionType: "group",
653
+ },
654
+ {
655
+ label: "General Channel",
656
+ value: [
657
+ "team",
658
+ "general",
659
+ ],
660
+ optionType: "simple",
661
+ },
662
+ ],
663
+ value: 10,
664
+ },
665
+ {
666
+ target: "custom_fields",
667
+ id: "ProductInterest",
668
+ options: [
669
+ {
670
+ label: "General Channel",
671
+ value: "general",
672
+ optionType: "simple",
673
+ },
674
+ {
675
+ id: "1234",
676
+ label: "General Channel",
677
+ options: [
678
+ {
679
+ label: "General Channel",
680
+ value: 12.5,
681
+ optionType: "simple",
682
+ },
683
+ {
684
+ label: "General Channel",
685
+ value: 123,
686
+ optionType: "simple",
687
+ },
688
+ {
689
+ label: "General Channel",
690
+ value: 12.5,
691
+ optionType: "simple",
692
+ },
693
+ ],
694
+ optionType: "group",
695
+ },
696
+ ],
697
+ value: 10,
698
+ },
699
+ {
700
+ target: "custom_fields",
701
+ id: "ProductInterest",
702
+ options: [
703
+ {
704
+ label: "General Channel",
705
+ value: true,
706
+ optionType: "simple",
707
+ },
708
+ {
709
+ label: "General Channel",
710
+ value: "general",
711
+ optionType: "simple",
712
+ },
713
+ {
714
+ label: "General Channel",
715
+ value: 123,
716
+ optionType: "simple",
717
+ },
718
+ ],
719
+ value: "GC5000 series",
720
+ },
721
+ ],
722
+ },
723
+ ],
724
+ configurableResources: [
725
+ "opportunities",
726
+ "companies",
727
+ "contacts",
728
+ "leads",
729
+ ],
730
+ resourceSchemaSupport: [
731
+ "leads",
732
+ ],
733
+ resourceSettingsSupport: [
734
+ "leads",
735
+ ],
736
+ settingsRequiredForAuthorization: [
737
+ "client_id",
738
+ "client_secret",
739
+ ],
740
+ subscriptions: [
741
+ {
742
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
743
+ unifyEventTypes: [
744
+ "crm.contact.created",
745
+ ],
746
+ downstreamEventTypes: [
747
+ "contacts.CREATED",
748
+ ],
749
+ executeUrl:
750
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
751
+ createdAt: "2020-10-01T12:00:00.000Z",
752
+ },
753
+ {
754
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
755
+ unifyEventTypes: [
756
+ "crm.contact.created",
757
+ ],
758
+ downstreamEventTypes: [
759
+ "contacts.CREATED",
760
+ ],
761
+ executeUrl:
762
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
763
+ createdAt: "2020-10-01T12:00:00.000Z",
764
+ },
765
+ {
766
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
767
+ unifyEventTypes: [
768
+ "crm.contact.created",
769
+ ],
770
+ downstreamEventTypes: [
771
+ "contacts.CREATED",
772
+ ],
773
+ executeUrl:
774
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
775
+ createdAt: "2020-10-01T12:00:00.000Z",
776
+ },
777
+ ],
778
+ hasGuide: true,
779
+ customMappings: [
780
+ {
781
+ id: "hris+employees+first_aid_training",
782
+ label: "First Aid Training",
783
+ description: "First Aid Training completed after 2019-01-01",
784
+ value: "$.root.training.first_aid",
785
+ key: "first_aid_training",
786
+ required: false,
787
+ customField: true,
788
+ consumerId: "test_user_id",
789
+ example: "Some value",
790
+ },
791
+ {
792
+ id: "hris+employees+first_aid_training",
793
+ label: "First Aid Training",
794
+ description: "First Aid Training completed after 2019-01-01",
795
+ value: "$.root.training.first_aid",
796
+ key: "first_aid_training",
797
+ required: false,
798
+ customField: true,
799
+ consumerId: "test_user_id",
800
+ example: "Some value",
801
+ },
802
+ {
803
+ id: "hris+employees+first_aid_training",
804
+ label: "First Aid Training",
805
+ description: "First Aid Training completed after 2019-01-01",
806
+ value: "$.root.training.first_aid",
807
+ key: "first_aid_training",
808
+ required: false,
809
+ customField: true,
810
+ consumerId: "test_user_id",
811
+ example: "Some value",
812
+ },
813
+ ],
814
+ createdAt: 1615563533390,
815
+ updatedAt: 1616662325753,
816
+ },
817
+ ],
818
+ });
819
+ });
820
+
821
+ test("Connections Vault Connections One", async () => {
822
+ const testHttpClient = createTestHTTPClient("vault.connectionsOne");
823
+
824
+ const apideck = new Apideck({
825
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
826
+ httpClient: testHttpClient,
827
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
828
+ });
829
+
830
+ const result = await apideck.vault.connections.get({
831
+ consumerId: "test-consumer",
832
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
833
+ serviceId: "pipedrive",
834
+ unifiedApi: "crm",
835
+ });
836
+ expect(result.httpMeta.response.status).toBe(200);
837
+ expect(result.getConnectionResponse).toBeDefined();
838
+ expect(result.getConnectionResponse).toEqual({
839
+ statusCode: 200,
840
+ status: "OK",
841
+ data: {
842
+ id: "crm+salesforce",
843
+ serviceId: "salesforce",
844
+ name: "Salesforce",
845
+ tagLine:
846
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
847
+ unifiedApi: "crm",
848
+ state: "authorized",
849
+ integrationState: "configured",
850
+ authType: "oauth2",
851
+ oauthGrantType: "authorization_code",
852
+ enabled: true,
853
+ website: "https://www.salesforce.com",
854
+ icon:
855
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
856
+ logo:
857
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
858
+ authorizeUrl:
859
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
860
+ revokeUrl:
861
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
862
+ settings: {
863
+ "instance_url": "https://eu28.salesforce.com",
864
+ "api_key": "12345xxxxxx",
865
+ },
866
+ metadata: {
867
+ "account": {
868
+ "name": "My Company",
869
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
870
+ },
871
+ "plan": "enterprise",
872
+ },
873
+ formFields: [
874
+ {
875
+ id: "instance_url",
876
+ label: "Instance url",
877
+ placeholder: "",
878
+ type: "text",
879
+ required: true,
880
+ customField: false,
881
+ allowCustomValues: false,
882
+ disabled: false,
883
+ sensitive: false,
884
+ },
885
+ {
886
+ id: "api_key",
887
+ label: "API Key",
888
+ placeholder: "",
889
+ type: "text",
890
+ required: true,
891
+ customField: false,
892
+ allowCustomValues: false,
893
+ disabled: false,
894
+ sensitive: true,
895
+ },
896
+ ],
897
+ configuration: [
898
+ {
899
+ resource: "leads",
900
+ defaults: [
901
+ {
902
+ target: "custom_fields",
903
+ id: "ProductInterest",
904
+ options: [
905
+ {
906
+ id: "1234",
907
+ label: "General Channel",
908
+ options: [
909
+ {
910
+ label: "General Channel",
911
+ value: 12.5,
912
+ optionType: "simple",
913
+ },
914
+ {
915
+ label: "General Channel",
916
+ value: 12.5,
917
+ optionType: "simple",
918
+ },
919
+ {
920
+ label: "General Channel",
921
+ value: 123,
922
+ optionType: "simple",
923
+ },
924
+ ],
925
+ optionType: "group",
926
+ },
927
+ {
928
+ label: "General Channel",
929
+ value: [
930
+ "team",
931
+ "general",
932
+ ],
933
+ optionType: "simple",
934
+ },
935
+ ],
936
+ value: 10.5,
937
+ },
938
+ {
939
+ target: "custom_fields",
940
+ id: "ProductInterest",
941
+ options: [
942
+ {
943
+ label: "General Channel",
944
+ value: 123,
945
+ optionType: "simple",
946
+ },
947
+ {
948
+ label: "General Channel",
949
+ value: "general",
950
+ optionType: "simple",
951
+ },
952
+ {
953
+ id: "1234",
954
+ label: "General Channel",
955
+ options: [
956
+ {
957
+ label: "General Channel",
958
+ value: 123,
959
+ optionType: "simple",
960
+ },
961
+ {
962
+ label: "General Channel",
963
+ value: true,
964
+ optionType: "simple",
965
+ },
966
+ {
967
+ label: "General Channel",
968
+ value: true,
969
+ optionType: "simple",
970
+ },
971
+ ],
972
+ optionType: "group",
973
+ },
974
+ ],
975
+ value: 10.5,
976
+ },
977
+ ],
978
+ },
979
+ {
980
+ resource: "leads",
981
+ defaults: [
982
+ {
983
+ target: "custom_fields",
984
+ id: "ProductInterest",
985
+ options: [
986
+ {
987
+ label: "General Channel",
988
+ value: 123,
989
+ optionType: "simple",
990
+ },
991
+ ],
992
+ value: true,
993
+ },
994
+ ],
995
+ },
996
+ {
997
+ resource: "leads",
998
+ defaults: [
999
+ {
1000
+ target: "custom_fields",
1001
+ id: "ProductInterest",
1002
+ options: [
1003
+ {
1004
+ id: "1234",
1005
+ label: "General Channel",
1006
+ options: [
1007
+ {
1008
+ label: "General Channel",
1009
+ value: [
1010
+ "team",
1011
+ "general",
1012
+ ],
1013
+ optionType: "simple",
1014
+ },
1015
+ {
1016
+ label: "General Channel",
1017
+ value: 123,
1018
+ optionType: "simple",
1019
+ },
1020
+ ],
1021
+ optionType: "group",
1022
+ },
1023
+ {
1024
+ label: "General Channel",
1025
+ value: [
1026
+ "team",
1027
+ "general",
1028
+ ],
1029
+ optionType: "simple",
1030
+ },
1031
+ {
1032
+ label: "General Channel",
1033
+ value: 12.5,
1034
+ optionType: "simple",
1035
+ },
1036
+ ],
1037
+ value: "GC5000 series",
1038
+ },
1039
+ ],
1040
+ },
1041
+ ],
1042
+ configurableResources: [
1043
+ "opportunities",
1044
+ "companies",
1045
+ "contacts",
1046
+ "leads",
1047
+ ],
1048
+ resourceSchemaSupport: [
1049
+ "leads",
1050
+ ],
1051
+ resourceSettingsSupport: [
1052
+ "leads",
1053
+ ],
1054
+ settingsRequiredForAuthorization: [
1055
+ "client_id",
1056
+ "client_secret",
1057
+ ],
1058
+ subscriptions: [
1059
+ {
1060
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
1061
+ unifyEventTypes: [
1062
+ "crm.contact.created",
1063
+ ],
1064
+ downstreamEventTypes: [
1065
+ "contacts.CREATED",
1066
+ ],
1067
+ executeUrl:
1068
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
1069
+ createdAt: "2020-10-01T12:00:00.000Z",
1070
+ },
1071
+ ],
1072
+ hasGuide: true,
1073
+ customMappings: [
1074
+ {
1075
+ id: "hris+employees+first_aid_training",
1076
+ label: "First Aid Training",
1077
+ description: "First Aid Training completed after 2019-01-01",
1078
+ value: "$.root.training.first_aid",
1079
+ key: "first_aid_training",
1080
+ required: false,
1081
+ customField: true,
1082
+ consumerId: "test_user_id",
1083
+ example: "Some value",
1084
+ },
1085
+ {
1086
+ id: "hris+employees+first_aid_training",
1087
+ label: "First Aid Training",
1088
+ description: "First Aid Training completed after 2019-01-01",
1089
+ value: "$.root.training.first_aid",
1090
+ key: "first_aid_training",
1091
+ required: false,
1092
+ customField: true,
1093
+ consumerId: "test_user_id",
1094
+ example: "Some value",
1095
+ },
1096
+ ],
1097
+ createdAt: 1615563533390,
1098
+ updatedAt: 1616662325753,
1099
+ },
1100
+ });
1101
+ });
1102
+
1103
+ test("Connections Vault Connections Update", async () => {
1104
+ const testHttpClient = createTestHTTPClient("vault.connectionsUpdate");
1105
+
1106
+ const apideck = new Apideck({
1107
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1108
+ httpClient: testHttpClient,
1109
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1110
+ });
1111
+
1112
+ const result = await apideck.vault.connections.update({
1113
+ consumerId: "test-consumer",
1114
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1115
+ serviceId: "pipedrive",
1116
+ unifiedApi: "crm",
1117
+ connection: {
1118
+ enabled: true,
1119
+ settings: {
1120
+ "api_key": "12345xxxxxx",
1121
+ "instance_url": "https://eu28.salesforce.com",
1122
+ },
1123
+ metadata: {
1124
+ "account": {
1125
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
1126
+ "name": "My Company",
1127
+ },
1128
+ "plan": "enterprise",
1129
+ },
1130
+ configuration: [
1131
+ {
1132
+ resource: "leads",
1133
+ defaults: [
1134
+ {
1135
+ id: "ProductInterest",
1136
+ options: [
1137
+ {
1138
+ id: "1234",
1139
+ label: "General Channel",
1140
+ options: [
1141
+ {
1142
+ label: "General Channel",
1143
+ value: 12.5,
1144
+ optionType: "simple",
1145
+ },
1146
+ {
1147
+ label: "General Channel",
1148
+ value: [
1149
+ "team",
1150
+ "general",
1151
+ ],
1152
+ optionType: "simple",
1153
+ },
1154
+ ],
1155
+ optionType: "group",
1156
+ },
1157
+ {
1158
+ label: "General Channel",
1159
+ value: [
1160
+ "team",
1161
+ "general",
1162
+ ],
1163
+ optionType: "simple",
1164
+ },
1165
+ ],
1166
+ value: 10.5,
1167
+ },
1168
+ {
1169
+ id: "ProductInterest",
1170
+ options: [
1171
+ {
1172
+ label: "General Channel",
1173
+ value: "general",
1174
+ optionType: "simple",
1175
+ },
1176
+ ],
1177
+ value: true,
1178
+ },
1179
+ ],
1180
+ },
1181
+ {
1182
+ resource: "leads",
1183
+ defaults: [
1184
+ {
1185
+ id: "ProductInterest",
1186
+ options: [
1187
+ {
1188
+ label: "General Channel",
1189
+ value: true,
1190
+ optionType: "simple",
1191
+ },
1192
+ ],
1193
+ value: true,
1194
+ },
1195
+ {
1196
+ id: "ProductInterest",
1197
+ options: [
1198
+ {
1199
+ label: "General Channel",
1200
+ value: true,
1201
+ optionType: "simple",
1202
+ },
1203
+ {
1204
+ id: "1234",
1205
+ label: "General Channel",
1206
+ options: [
1207
+ {
1208
+ label: "General Channel",
1209
+ value: 12.5,
1210
+ optionType: "simple",
1211
+ },
1212
+ ],
1213
+ optionType: "group",
1214
+ },
1215
+ ],
1216
+ value: "GC5000 series",
1217
+ },
1218
+ {
1219
+ id: "ProductInterest",
1220
+ options: [
1221
+ {
1222
+ label: "General Channel",
1223
+ value: [
1224
+ "team",
1225
+ "general",
1226
+ ],
1227
+ optionType: "simple",
1228
+ },
1229
+ ],
1230
+ value: [
1231
+ 10.5,
1232
+ 10,
1233
+ "GC6000 series",
1234
+ ],
1235
+ },
1236
+ ],
1237
+ },
1238
+ {
1239
+ resource: "leads",
1240
+ defaults: [
1241
+ {
1242
+ id: "ProductInterest",
1243
+ options: [
1244
+ {
1245
+ id: "1234",
1246
+ label: "General Channel",
1247
+ options: [
1248
+ {
1249
+ label: "General Channel",
1250
+ value: "general",
1251
+ optionType: "simple",
1252
+ },
1253
+ {
1254
+ label: "General Channel",
1255
+ value: "general",
1256
+ optionType: "simple",
1257
+ },
1258
+ {
1259
+ label: "General Channel",
1260
+ value: 123,
1261
+ optionType: "simple",
1262
+ },
1263
+ ],
1264
+ optionType: "group",
1265
+ },
1266
+ {
1267
+ id: "1234",
1268
+ label: "General Channel",
1269
+ options: [],
1270
+ optionType: "group",
1271
+ },
1272
+ ],
1273
+ value: true,
1274
+ },
1275
+ {
1276
+ id: "ProductInterest",
1277
+ options: [
1278
+ {
1279
+ label: "General Channel",
1280
+ value: "general",
1281
+ optionType: "simple",
1282
+ },
1283
+ ],
1284
+ value: true,
1285
+ },
1286
+ ],
1287
+ },
1288
+ ],
1289
+ customMappings: [
1290
+ {
1291
+ value: "$.root.training.first_aid",
1292
+ },
1293
+ {
1294
+ value: "$.root.training.first_aid",
1295
+ },
1296
+ ],
1297
+ },
1298
+ });
1299
+ expect(result.httpMeta.response.status).toBe(200);
1300
+ expect(result.updateConnectionResponse).toBeDefined();
1301
+ expect(result.updateConnectionResponse).toEqual({
1302
+ statusCode: 200,
1303
+ status: "OK",
1304
+ data: {
1305
+ id: "crm+salesforce",
1306
+ serviceId: "salesforce",
1307
+ name: "Salesforce",
1308
+ tagLine:
1309
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
1310
+ unifiedApi: "crm",
1311
+ state: "authorized",
1312
+ integrationState: "configured",
1313
+ authType: "oauth2",
1314
+ oauthGrantType: "authorization_code",
1315
+ enabled: true,
1316
+ website: "https://www.salesforce.com",
1317
+ icon:
1318
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
1319
+ logo:
1320
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
1321
+ authorizeUrl:
1322
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
1323
+ revokeUrl:
1324
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
1325
+ settings: {
1326
+ "instance_url": "https://eu28.salesforce.com",
1327
+ "api_key": "12345xxxxxx",
1328
+ },
1329
+ metadata: {
1330
+ "account": {
1331
+ "name": "My Company",
1332
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
1333
+ },
1334
+ "plan": "enterprise",
1335
+ },
1336
+ formFields: [
1337
+ {
1338
+ id: "instance_url",
1339
+ label: "Instance url",
1340
+ placeholder: "",
1341
+ type: "text",
1342
+ required: true,
1343
+ customField: false,
1344
+ allowCustomValues: false,
1345
+ disabled: false,
1346
+ sensitive: false,
1347
+ },
1348
+ {
1349
+ id: "api_key",
1350
+ label: "API Key",
1351
+ placeholder: "",
1352
+ type: "text",
1353
+ required: true,
1354
+ customField: false,
1355
+ allowCustomValues: false,
1356
+ disabled: false,
1357
+ sensitive: true,
1358
+ },
1359
+ ],
1360
+ configuration: [
1361
+ {
1362
+ resource: "leads",
1363
+ defaults: [
1364
+ {
1365
+ target: "custom_fields",
1366
+ id: "ProductInterest",
1367
+ options: [
1368
+ {
1369
+ id: "1234",
1370
+ label: "General Channel",
1371
+ options: [
1372
+ {
1373
+ label: "General Channel",
1374
+ value: 12.5,
1375
+ optionType: "simple",
1376
+ },
1377
+ {
1378
+ label: "General Channel",
1379
+ value: 123,
1380
+ optionType: "simple",
1381
+ },
1382
+ {
1383
+ label: "General Channel",
1384
+ value: 123,
1385
+ optionType: "simple",
1386
+ },
1387
+ ],
1388
+ optionType: "group",
1389
+ },
1390
+ ],
1391
+ value: 10.5,
1392
+ },
1393
+ {
1394
+ target: "custom_fields",
1395
+ id: "ProductInterest",
1396
+ options: [
1397
+ {
1398
+ id: "1234",
1399
+ label: "General Channel",
1400
+ options: [
1401
+ {
1402
+ label: "General Channel",
1403
+ value: true,
1404
+ optionType: "simple",
1405
+ },
1406
+ {
1407
+ label: "General Channel",
1408
+ value: 123,
1409
+ optionType: "simple",
1410
+ },
1411
+ {
1412
+ label: "General Channel",
1413
+ value: true,
1414
+ optionType: "simple",
1415
+ },
1416
+ ],
1417
+ optionType: "group",
1418
+ },
1419
+ {
1420
+ label: "General Channel",
1421
+ value: 123,
1422
+ optionType: "simple",
1423
+ },
1424
+ {
1425
+ label: "General Channel",
1426
+ value: 123,
1427
+ optionType: "simple",
1428
+ },
1429
+ ],
1430
+ value: true,
1431
+ },
1432
+ ],
1433
+ },
1434
+ {
1435
+ resource: "leads",
1436
+ defaults: [
1437
+ {
1438
+ target: "custom_fields",
1439
+ id: "ProductInterest",
1440
+ options: [
1441
+ {
1442
+ label: "General Channel",
1443
+ value: "general",
1444
+ optionType: "simple",
1445
+ },
1446
+ ],
1447
+ value: 10.5,
1448
+ },
1449
+ ],
1450
+ },
1451
+ ],
1452
+ configurableResources: [
1453
+ "opportunities",
1454
+ "companies",
1455
+ "contacts",
1456
+ "leads",
1457
+ ],
1458
+ resourceSchemaSupport: [
1459
+ "leads",
1460
+ ],
1461
+ resourceSettingsSupport: [
1462
+ "leads",
1463
+ ],
1464
+ settingsRequiredForAuthorization: [
1465
+ "client_id",
1466
+ "client_secret",
1467
+ ],
1468
+ subscriptions: [
1469
+ {
1470
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
1471
+ unifyEventTypes: [
1472
+ "crm.contact.created",
1473
+ ],
1474
+ downstreamEventTypes: [
1475
+ "contacts.CREATED",
1476
+ ],
1477
+ executeUrl:
1478
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
1479
+ createdAt: "2020-10-01T12:00:00.000Z",
1480
+ },
1481
+ ],
1482
+ hasGuide: true,
1483
+ customMappings: [
1484
+ {
1485
+ id: "hris+employees+first_aid_training",
1486
+ label: "First Aid Training",
1487
+ description: "First Aid Training completed after 2019-01-01",
1488
+ value: "$.root.training.first_aid",
1489
+ key: "first_aid_training",
1490
+ required: false,
1491
+ customField: true,
1492
+ consumerId: "test_user_id",
1493
+ example: "Some value",
1494
+ },
1495
+ {
1496
+ id: "hris+employees+first_aid_training",
1497
+ label: "First Aid Training",
1498
+ description: "First Aid Training completed after 2019-01-01",
1499
+ value: "$.root.training.first_aid",
1500
+ key: "first_aid_training",
1501
+ required: false,
1502
+ customField: true,
1503
+ consumerId: "test_user_id",
1504
+ example: "Some value",
1505
+ },
1506
+ ],
1507
+ createdAt: 1615563533390,
1508
+ updatedAt: 1616662325753,
1509
+ },
1510
+ });
1511
+ });
1512
+
1513
+ test("Connections Vault Connections Delete", async () => {
1514
+ const testHttpClient = createTestHTTPClient("vault.connectionsDelete");
1515
+
1516
+ const apideck = new Apideck({
1517
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1518
+ httpClient: testHttpClient,
1519
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1520
+ });
1521
+
1522
+ const result = await apideck.vault.connections.delete({
1523
+ consumerId: "test-consumer",
1524
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1525
+ serviceId: "pipedrive",
1526
+ unifiedApi: "crm",
1527
+ });
1528
+ expect([
1529
+ 204,
1530
+ 400,
1531
+ 401,
1532
+ 402,
1533
+ 404,
1534
+ 422,
1535
+ 400,
1536
+ 401,
1537
+ 402,
1538
+ 403,
1539
+ 404,
1540
+ 405,
1541
+ 406,
1542
+ 407,
1543
+ 408,
1544
+ 409,
1545
+ 410,
1546
+ 411,
1547
+ 412,
1548
+ 413,
1549
+ 414,
1550
+ 415,
1551
+ 416,
1552
+ 417,
1553
+ 418,
1554
+ 421,
1555
+ 422,
1556
+ 423,
1557
+ 424,
1558
+ 425,
1559
+ 426,
1560
+ 428,
1561
+ 429,
1562
+ 431,
1563
+ 451,
1564
+ 500,
1565
+ 501,
1566
+ 502,
1567
+ 503,
1568
+ 504,
1569
+ 505,
1570
+ 506,
1571
+ 507,
1572
+ 508,
1573
+ 510,
1574
+ 511,
1575
+ ]).not.toContain(result.httpMeta.response.status);
1576
+ expect(result.unexpectedErrorResponse).toBeDefined();
1577
+ expect(result.unexpectedErrorResponse).toEqual({
1578
+ statusCode: 400,
1579
+ error: "Bad Request",
1580
+ typeName: "RequestHeadersValidationError",
1581
+ message: "Invalid Params",
1582
+ detail: {
1583
+ "missing": [
1584
+ {
1585
+ "x-apideck-consumer-id": "required",
1586
+ },
1587
+ ],
1588
+ },
1589
+ ref: "https://developers.apideck.com/errors#unauthorizederror",
1590
+ });
1591
+ });
1592
+
1593
+ test("Connections Vault Connections Import", async () => {
1594
+ const testHttpClient = createTestHTTPClient("vault.connectionsImport");
1595
+
1596
+ const apideck = new Apideck({
1597
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1598
+ httpClient: testHttpClient,
1599
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1600
+ });
1601
+
1602
+ const result = await apideck.vault.connections.imports({
1603
+ consumerId: "test-consumer",
1604
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1605
+ serviceId: "pipedrive",
1606
+ unifiedApi: "crm",
1607
+ connectionImportData: {
1608
+ credentials: {
1609
+ refreshToken:
1610
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.cThIIoDvwdueQB468K5xDc5633seEFoqwxjF_xSJyQQ",
1611
+ accessToken:
1612
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
1613
+ },
1614
+ metadata: {
1615
+ "account": {
1616
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
1617
+ "name": "My Company",
1618
+ },
1619
+ "plan": "enterprise",
1620
+ },
1621
+ },
1622
+ });
1623
+ expect(result.httpMeta.response.status).toBe(200);
1624
+ expect(result.createConnectionResponse).toBeDefined();
1625
+ expect(result.createConnectionResponse).toEqual({
1626
+ statusCode: 201,
1627
+ status: "OK",
1628
+ data: {
1629
+ id: "crm+salesforce",
1630
+ serviceId: "salesforce",
1631
+ name: "Salesforce",
1632
+ tagLine:
1633
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
1634
+ unifiedApi: "crm",
1635
+ state: "authorized",
1636
+ integrationState: "configured",
1637
+ authType: "oauth2",
1638
+ oauthGrantType: "authorization_code",
1639
+ enabled: true,
1640
+ website: "https://www.salesforce.com",
1641
+ icon:
1642
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
1643
+ logo:
1644
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
1645
+ authorizeUrl:
1646
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
1647
+ revokeUrl:
1648
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
1649
+ settings: {
1650
+ "instance_url": "https://eu28.salesforce.com",
1651
+ "api_key": "12345xxxxxx",
1652
+ },
1653
+ metadata: {
1654
+ "account": {
1655
+ "name": "My Company",
1656
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
1657
+ },
1658
+ "plan": "enterprise",
1659
+ },
1660
+ formFields: [
1661
+ {
1662
+ id: "instance_url",
1663
+ label: "Instance url",
1664
+ placeholder: "",
1665
+ type: "text",
1666
+ required: true,
1667
+ customField: false,
1668
+ allowCustomValues: false,
1669
+ disabled: false,
1670
+ sensitive: false,
1671
+ },
1672
+ {
1673
+ id: "api_key",
1674
+ label: "API Key",
1675
+ placeholder: "",
1676
+ type: "text",
1677
+ required: true,
1678
+ customField: false,
1679
+ allowCustomValues: false,
1680
+ disabled: false,
1681
+ sensitive: true,
1682
+ },
1683
+ ],
1684
+ configuration: [
1685
+ {
1686
+ resource: "leads",
1687
+ defaults: [
1688
+ {
1689
+ target: "custom_fields",
1690
+ id: "ProductInterest",
1691
+ options: [
1692
+ {
1693
+ id: "1234",
1694
+ label: "General Channel",
1695
+ options: [
1696
+ {
1697
+ label: "General Channel",
1698
+ value: true,
1699
+ optionType: "simple",
1700
+ },
1701
+ {
1702
+ label: "General Channel",
1703
+ value: 12.5,
1704
+ optionType: "simple",
1705
+ },
1706
+ {
1707
+ label: "General Channel",
1708
+ value: true,
1709
+ optionType: "simple",
1710
+ },
1711
+ ],
1712
+ optionType: "group",
1713
+ },
1714
+ ],
1715
+ value: 10,
1716
+ },
1717
+ {
1718
+ target: "custom_fields",
1719
+ id: "ProductInterest",
1720
+ options: [
1721
+ {
1722
+ id: "1234",
1723
+ label: "General Channel",
1724
+ options: [
1725
+ {
1726
+ label: "General Channel",
1727
+ value: true,
1728
+ optionType: "simple",
1729
+ },
1730
+ {
1731
+ label: "General Channel",
1732
+ value: [
1733
+ "team",
1734
+ "general",
1735
+ ],
1736
+ optionType: "simple",
1737
+ },
1738
+ {
1739
+ label: "General Channel",
1740
+ value: "general",
1741
+ optionType: "simple",
1742
+ },
1743
+ ],
1744
+ optionType: "group",
1745
+ },
1746
+ {
1747
+ label: "General Channel",
1748
+ value: true,
1749
+ optionType: "simple",
1750
+ },
1751
+ {
1752
+ label: "General Channel",
1753
+ value: 123,
1754
+ optionType: "simple",
1755
+ },
1756
+ ],
1757
+ value: 10,
1758
+ },
1759
+ ],
1760
+ },
1761
+ {
1762
+ resource: "leads",
1763
+ defaults: [
1764
+ {
1765
+ target: "custom_fields",
1766
+ id: "ProductInterest",
1767
+ options: [
1768
+ {
1769
+ id: "1234",
1770
+ label: "General Channel",
1771
+ options: [
1772
+ {
1773
+ label: "General Channel",
1774
+ value: true,
1775
+ optionType: "simple",
1776
+ },
1777
+ {
1778
+ label: "General Channel",
1779
+ value: "general",
1780
+ optionType: "simple",
1781
+ },
1782
+ {
1783
+ label: "General Channel",
1784
+ value: true,
1785
+ optionType: "simple",
1786
+ },
1787
+ ],
1788
+ optionType: "group",
1789
+ },
1790
+ {
1791
+ id: "1234",
1792
+ label: "General Channel",
1793
+ options: [
1794
+ {
1795
+ label: "General Channel",
1796
+ value: true,
1797
+ optionType: "simple",
1798
+ },
1799
+ {
1800
+ label: "General Channel",
1801
+ value: true,
1802
+ optionType: "simple",
1803
+ },
1804
+ ],
1805
+ optionType: "group",
1806
+ },
1807
+ {
1808
+ id: "1234",
1809
+ label: "General Channel",
1810
+ options: [],
1811
+ optionType: "group",
1812
+ },
1813
+ ],
1814
+ value: "GC5000 series",
1815
+ },
1816
+ {
1817
+ target: "custom_fields",
1818
+ id: "ProductInterest",
1819
+ options: [
1820
+ {
1821
+ label: "General Channel",
1822
+ value: [
1823
+ "team",
1824
+ "general",
1825
+ ],
1826
+ optionType: "simple",
1827
+ },
1828
+ ],
1829
+ value: "GC5000 series",
1830
+ },
1831
+ {
1832
+ target: "custom_fields",
1833
+ id: "ProductInterest",
1834
+ options: [
1835
+ {
1836
+ id: "1234",
1837
+ label: "General Channel",
1838
+ options: [
1839
+ {
1840
+ label: "General Channel",
1841
+ value: true,
1842
+ optionType: "simple",
1843
+ },
1844
+ {
1845
+ label: "General Channel",
1846
+ value: 12.5,
1847
+ optionType: "simple",
1848
+ },
1849
+ {
1850
+ label: "General Channel",
1851
+ value: 12.5,
1852
+ optionType: "simple",
1853
+ },
1854
+ ],
1855
+ optionType: "group",
1856
+ },
1857
+ {
1858
+ label: "General Channel",
1859
+ value: "general",
1860
+ optionType: "simple",
1861
+ },
1862
+ {
1863
+ id: "1234",
1864
+ label: "General Channel",
1865
+ options: [
1866
+ {
1867
+ label: "General Channel",
1868
+ value: [
1869
+ "team",
1870
+ "general",
1871
+ ],
1872
+ optionType: "simple",
1873
+ },
1874
+ ],
1875
+ optionType: "group",
1876
+ },
1877
+ ],
1878
+ value: [
1879
+ 10,
1880
+ ],
1881
+ },
1882
+ ],
1883
+ },
1884
+ {
1885
+ resource: "leads",
1886
+ defaults: [
1887
+ {
1888
+ target: "custom_fields",
1889
+ id: "ProductInterest",
1890
+ options: [
1891
+ {
1892
+ label: "General Channel",
1893
+ value: "general",
1894
+ optionType: "simple",
1895
+ },
1896
+ ],
1897
+ value: [
1898
+ "GC6000 series",
1899
+ 10.5,
1900
+ 10,
1901
+ ],
1902
+ },
1903
+ ],
1904
+ },
1905
+ ],
1906
+ configurableResources: [
1907
+ "opportunities",
1908
+ "companies",
1909
+ "contacts",
1910
+ "leads",
1911
+ ],
1912
+ resourceSchemaSupport: [
1913
+ "leads",
1914
+ ],
1915
+ resourceSettingsSupport: [
1916
+ "leads",
1917
+ ],
1918
+ settingsRequiredForAuthorization: [
1919
+ "client_id",
1920
+ "client_secret",
1921
+ ],
1922
+ subscriptions: [
1923
+ {
1924
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
1925
+ unifyEventTypes: [
1926
+ "crm.contact.created",
1927
+ ],
1928
+ downstreamEventTypes: [
1929
+ "contacts.CREATED",
1930
+ ],
1931
+ executeUrl:
1932
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
1933
+ createdAt: "2020-10-01T12:00:00.000Z",
1934
+ },
1935
+ ],
1936
+ hasGuide: true,
1937
+ customMappings: [
1938
+ {
1939
+ id: "hris+employees+first_aid_training",
1940
+ label: "First Aid Training",
1941
+ description: "First Aid Training completed after 2019-01-01",
1942
+ value: "$.root.training.first_aid",
1943
+ key: "first_aid_training",
1944
+ required: false,
1945
+ customField: true,
1946
+ consumerId: "test_user_id",
1947
+ example: "Some value",
1948
+ },
1949
+ ],
1950
+ createdAt: 1615563533390,
1951
+ updatedAt: 1616662325753,
1952
+ },
1953
+ });
1954
+ });
1955
+
1956
+ test("Connections Vault Connections Token", async () => {
1957
+ const testHttpClient = createTestHTTPClient("vault.connectionsToken");
1958
+
1959
+ const apideck = new Apideck({
1960
+ serverURL: process.env["TEST_SERVER_URL"] ?? "http://localhost:18080",
1961
+ httpClient: testHttpClient,
1962
+ apiKey: process.env["APIDECK_API_KEY"] ?? "value",
1963
+ });
1964
+
1965
+ const result = await apideck.vault.connections.token({
1966
+ consumerId: "test-consumer",
1967
+ appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
1968
+ serviceId: "pipedrive",
1969
+ unifiedApi: "crm",
1970
+ });
1971
+ expect(result.httpMeta.response.status).toBe(200);
1972
+ expect(result.getConnectionResponse).toBeDefined();
1973
+ expect(result.getConnectionResponse).toEqual({
1974
+ statusCode: 200,
1975
+ status: "OK",
1976
+ data: {
1977
+ id: "crm+salesforce",
1978
+ serviceId: "salesforce",
1979
+ name: "Salesforce",
1980
+ tagLine:
1981
+ "CRM software solutions and enterprise cloud computing from Salesforce, the leader in customer relationship management (CRM) and PaaS. Free 30 day trial.",
1982
+ unifiedApi: "crm",
1983
+ state: "authorized",
1984
+ integrationState: "configured",
1985
+ authType: "oauth2",
1986
+ oauthGrantType: "authorization_code",
1987
+ enabled: true,
1988
+ website: "https://www.salesforce.com",
1989
+ icon:
1990
+ "https://res.cloudinary.com/apideck/image/upload/v1529456047/catalog/salesforce/icon128x128.png",
1991
+ logo:
1992
+ "https://c1.sfdcstatic.com/content/dam/web/en_us/www/images/home/logo-salesforce-m.svg",
1993
+ authorizeUrl:
1994
+ "https://unify.apideck.com/vault/authorize/salesforce/<application-id>?state=<state>",
1995
+ revokeUrl:
1996
+ "https://unify.apideck.com/vault/revoke/salesforce/<application-id>?state=<state>",
1997
+ settings: {
1998
+ "instance_url": "https://eu28.salesforce.com",
1999
+ "api_key": "12345xxxxxx",
2000
+ },
2001
+ metadata: {
2002
+ "account": {
2003
+ "name": "My Company",
2004
+ "id": "c01458a5-7276-41ce-bc19-639906b0450a",
2005
+ },
2006
+ "plan": "enterprise",
2007
+ },
2008
+ formFields: [
2009
+ {
2010
+ id: "instance_url",
2011
+ label: "Instance url",
2012
+ placeholder: "",
2013
+ type: "text",
2014
+ required: true,
2015
+ customField: false,
2016
+ allowCustomValues: false,
2017
+ disabled: false,
2018
+ sensitive: false,
2019
+ },
2020
+ {
2021
+ id: "api_key",
2022
+ label: "API Key",
2023
+ placeholder: "",
2024
+ type: "text",
2025
+ required: true,
2026
+ customField: false,
2027
+ allowCustomValues: false,
2028
+ disabled: false,
2029
+ sensitive: true,
2030
+ },
2031
+ ],
2032
+ configuration: [
2033
+ {
2034
+ resource: "leads",
2035
+ defaults: [
2036
+ {
2037
+ target: "custom_fields",
2038
+ id: "ProductInterest",
2039
+ options: [
2040
+ {
2041
+ label: "General Channel",
2042
+ value: true,
2043
+ optionType: "simple",
2044
+ },
2045
+ {
2046
+ label: "General Channel",
2047
+ value: true,
2048
+ optionType: "simple",
2049
+ },
2050
+ ],
2051
+ value: [],
2052
+ },
2053
+ {
2054
+ target: "custom_fields",
2055
+ id: "ProductInterest",
2056
+ options: [
2057
+ {
2058
+ label: "General Channel",
2059
+ value: true,
2060
+ optionType: "simple",
2061
+ },
2062
+ ],
2063
+ value: "GC5000 series",
2064
+ },
2065
+ ],
2066
+ },
2067
+ ],
2068
+ configurableResources: [
2069
+ "opportunities",
2070
+ "companies",
2071
+ "contacts",
2072
+ "leads",
2073
+ ],
2074
+ resourceSchemaSupport: [
2075
+ "leads",
2076
+ ],
2077
+ resourceSettingsSupport: [
2078
+ "leads",
2079
+ ],
2080
+ settingsRequiredForAuthorization: [
2081
+ "client_id",
2082
+ "client_secret",
2083
+ ],
2084
+ subscriptions: [
2085
+ {
2086
+ downstreamId: "5f5f5f5f5f5f5f5f5f5f5f5f",
2087
+ unifyEventTypes: [
2088
+ "crm.contact.created",
2089
+ ],
2090
+ downstreamEventTypes: [
2091
+ "contacts.CREATED",
2092
+ ],
2093
+ executeUrl:
2094
+ "https://unify.apideck.com/webhook/w/{lookupIdToken}/{serviceId}?e={downstreamEventType}",
2095
+ createdAt: "2020-10-01T12:00:00.000Z",
2096
+ },
2097
+ ],
2098
+ hasGuide: true,
2099
+ customMappings: [
2100
+ {
2101
+ id: "hris+employees+first_aid_training",
2102
+ label: "First Aid Training",
2103
+ description: "First Aid Training completed after 2019-01-01",
2104
+ value: "$.root.training.first_aid",
2105
+ key: "first_aid_training",
2106
+ required: false,
2107
+ customField: true,
2108
+ consumerId: "test_user_id",
2109
+ example: "Some value",
2110
+ },
2111
+ {
2112
+ id: "hris+employees+first_aid_training",
2113
+ label: "First Aid Training",
2114
+ description: "First Aid Training completed after 2019-01-01",
2115
+ value: "$.root.training.first_aid",
2116
+ key: "first_aid_training",
2117
+ required: false,
2118
+ customField: true,
2119
+ consumerId: "test_user_id",
2120
+ example: "Some value",
2121
+ },
2122
+ ],
2123
+ createdAt: 1615563533390,
2124
+ updatedAt: 1616662325753,
2125
+ },
2126
+ });
2127
+ });