@unito/integrations-platform-client 0.48.4 → 1.0.1

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.
@@ -33,7 +33,7 @@ const defaults = {
33
33
  headers: {},
34
34
  baseUrl: 'http://localhost:9000',
35
35
  };
36
- const oazapfts = Oazapfts__namespace.runtime(defaults);
36
+ const oazapfts$1 = Oazapfts__namespace.runtime(defaults);
37
37
  const servers = {
38
38
  local: 'http://localhost:9000',
39
39
  staging: 'https://staging-integrations-platform.unito.io',
@@ -43,503 +43,609 @@ const servers = {
43
43
  * Get all the integrations
44
44
  */
45
45
  function getIntegrations({ pagination, unitoOrganizationId, search, } = {}, opts) {
46
- return oazapfts.ok(oazapfts.fetchJson(`/integrations${QS__namespace.query(QS__namespace.explode({
46
+ return oazapfts$1.fetchJson(`/integrations${QS__namespace.query(QS__namespace.explode({
47
47
  pagination,
48
48
  unitoOrganizationId,
49
49
  search,
50
50
  }))}`, {
51
51
  ...opts,
52
- }));
52
+ });
53
53
  }
54
54
  /**
55
55
  * Create an integration
56
56
  */
57
57
  function createIntegration(body, opts) {
58
- return oazapfts.ok(oazapfts.fetchJson('/integrations', oazapfts.json({
58
+ return oazapfts$1.fetchJson('/integrations', oazapfts$1.json({
59
59
  ...opts,
60
60
  method: 'POST',
61
61
  body,
62
- })));
62
+ }));
63
63
  }
64
64
  /**
65
65
  * Publish an integration
66
66
  */
67
67
  function publishIntegration(body, opts) {
68
- return oazapfts.ok(oazapfts.fetchJson('/integrations/publish', oazapfts.multipart({
68
+ return oazapfts$1.fetchJson('/integrations/publish', oazapfts$1.multipart({
69
69
  ...opts,
70
70
  method: 'POST',
71
71
  body,
72
- })));
72
+ }));
73
73
  }
74
74
  /**
75
75
  * Find an integration by exact name
76
76
  */
77
77
  function getIntegrationByName(integrationName, opts) {
78
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/find/${encodeURIComponent(integrationName)}`, {
78
+ return oazapfts$1.fetchJson(`/integrations/find/${encodeURIComponent(integrationName)}`, {
79
79
  ...opts,
80
- }));
80
+ });
81
81
  }
82
82
  /**
83
83
  * Invite a user to an integration
84
84
  */
85
85
  function inviteUser(integrationId, body, opts) {
86
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/users/invite`, oazapfts.json({
86
+ return oazapfts$1.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/users/invite`, oazapfts$1.json({
87
87
  ...opts,
88
88
  method: 'POST',
89
89
  body,
90
- })));
90
+ }));
91
91
  }
92
92
  /**
93
93
  * Invite a unito organization to an integration
94
94
  */
95
95
  function inviteOrganization(integrationId, body, opts) {
96
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/organizations/invite`, oazapfts.json({
96
+ return oazapfts$1.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/organizations/invite`, oazapfts$1.json({
97
97
  ...opts,
98
98
  method: 'POST',
99
99
  body,
100
- })));
100
+ }));
101
101
  }
102
102
  /**
103
103
  * Get an integration
104
104
  */
105
105
  function getIntegrationById(integrationId, opts) {
106
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, {
106
+ return oazapfts$1.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, {
107
107
  ...opts,
108
- }));
108
+ });
109
109
  }
110
110
  /**
111
111
  * Update an integration
112
112
  */
113
113
  function updateIntegration(integrationId, body, opts) {
114
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, oazapfts.json({
114
+ return oazapfts$1.fetchJson(`/integrations/${encodeURIComponent(integrationId)}`, oazapfts$1.json({
115
115
  ...opts,
116
116
  method: 'PATCH',
117
117
  body,
118
- })));
118
+ }));
119
119
  }
120
120
  /**
121
121
  * Delete an integration
122
122
  */
123
123
  function deleteIntegration(integrationId, name, opts) {
124
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}${QS__namespace.query(QS__namespace.explode({
124
+ return oazapfts$1.fetchJson(`/integrations/${encodeURIComponent(integrationId)}${QS__namespace.query(QS__namespace.explode({
125
125
  name,
126
126
  }))}`, {
127
127
  ...opts,
128
128
  method: 'DELETE',
129
- }));
129
+ });
130
130
  }
131
131
  /**
132
132
  * Get the events associated with this integration.
133
133
  */
134
134
  function getIntegrationEvents(integrationId, { search, $from, limit, } = {}, opts) {
135
- return oazapfts.ok(oazapfts.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/events${QS__namespace.query(QS__namespace.explode({
135
+ return oazapfts$1.fetchJson(`/integrations/${encodeURIComponent(integrationId)}/events${QS__namespace.query(QS__namespace.explode({
136
136
  search,
137
137
  from: $from,
138
138
  limit,
139
139
  }))}`, {
140
140
  ...opts,
141
- }));
141
+ });
142
142
  }
143
143
  /**
144
144
  * Get the logo of the integration, in SVG format.
145
145
  */
146
146
  function getIntegrationLogo(integrationName, opts) {
147
- return oazapfts.ok(oazapfts.fetchJson(`/public/${encodeURIComponent(integrationName)}/logo.svg`, {
147
+ return oazapfts$1.fetchJson(`/public/${encodeURIComponent(integrationName)}/logo.svg`, {
148
148
  ...opts,
149
- }));
149
+ });
150
150
  }
151
151
  /**
152
152
  * Get all the credentials
153
153
  */
154
154
  function getCredentials({ pagination, filters, } = {}, opts) {
155
- return oazapfts.ok(oazapfts.fetchJson(`/credentials${QS__namespace.query(QS__namespace.explode({
155
+ return oazapfts$1.fetchJson(`/credentials${QS__namespace.query(QS__namespace.explode({
156
156
  pagination,
157
157
  filters,
158
158
  }))}`, {
159
159
  ...opts,
160
- }));
160
+ });
161
161
  }
162
162
  /**
163
163
  * Create a credential
164
164
  */
165
165
  function createCredential(body, opts) {
166
- return oazapfts.ok(oazapfts.fetchJson('/credentials', oazapfts.json({
166
+ return oazapfts$1.fetchJson('/credentials', oazapfts$1.json({
167
167
  ...opts,
168
168
  method: 'POST',
169
169
  body,
170
- })));
170
+ }));
171
171
  }
172
172
  /**
173
173
  * Get a credential
174
174
  */
175
175
  function getCredentialById(credentialId, opts) {
176
- return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
176
+ return oazapfts$1.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
177
177
  ...opts,
178
- }));
178
+ });
179
179
  }
180
180
  /**
181
181
  * Update a credential
182
182
  */
183
183
  function updateCredential(credentialId, body, opts) {
184
- return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, oazapfts.json({
184
+ return oazapfts$1.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, oazapfts$1.json({
185
185
  ...opts,
186
186
  method: 'PATCH',
187
187
  body,
188
- })));
188
+ }));
189
189
  }
190
190
  /**
191
191
  * Delete a credential
192
192
  */
193
193
  function deleteCredential(credentialId, opts) {
194
- return oazapfts.ok(oazapfts.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
194
+ return oazapfts$1.fetchJson(`/credentials/${encodeURIComponent(credentialId)}`, {
195
195
  ...opts,
196
196
  method: 'DELETE',
197
- }));
197
+ });
198
198
  }
199
199
  /**
200
200
  * Returns the credentialAccount either from the integration's /me endpoint, if available, or the credential's latestCredentialAccount
201
201
  */
202
202
  function getCredentialAccount(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
203
- return oazapfts.ok(oazapfts.fetchJson('/credentialAccount', {
203
+ return oazapfts$1.fetchJson('/credentialAccount', {
204
204
  ...opts,
205
- headers: oazapfts.mergeHeaders(opts?.headers, {
205
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
206
206
  'X-Unito-Credential-Id': xUnitoCredentialId,
207
207
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
208
208
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
209
209
  }),
210
- }));
210
+ });
211
211
  }
212
212
  /**
213
213
  * Used by the frontend to send analytics data
214
214
  */
215
215
  function postTrack(body, opts) {
216
- return oazapfts.ok(oazapfts.fetchJson('/track', oazapfts.json({
216
+ return oazapfts$1.fetchJson('/track', oazapfts$1.json({
217
217
  ...opts,
218
218
  method: 'POST',
219
219
  body,
220
- })));
220
+ }));
221
221
  }
222
222
  /**
223
223
  * Encrypt data
224
224
  */
225
225
  function encryptData(body, opts) {
226
- return oazapfts.ok(oazapfts.fetchJson('/encryptions/encrypt', oazapfts.json({
226
+ return oazapfts$1.fetchJson('/encryptions/encrypt', oazapfts$1.json({
227
227
  ...opts,
228
228
  method: 'POST',
229
229
  body,
230
- })));
230
+ }));
231
231
  }
232
232
  /**
233
233
  * Decrypt data
234
234
  */
235
235
  function decryptData(body, opts) {
236
- return oazapfts.ok(oazapfts.fetchJson('/encryptions/decrypt', oazapfts.json({
236
+ return oazapfts$1.fetchJson('/encryptions/decrypt', oazapfts$1.json({
237
237
  ...opts,
238
238
  method: 'POST',
239
239
  body,
240
- })));
240
+ }));
241
241
  }
242
242
  /**
243
243
  * Decrypt and encrypt data
244
244
  */
245
245
  function reencryptData(body, opts) {
246
- return oazapfts.ok(oazapfts.fetchJson('/encryptions/reencrypt', oazapfts.json({
246
+ return oazapfts$1.fetchJson('/encryptions/reencrypt', oazapfts$1.json({
247
247
  ...opts,
248
248
  method: 'POST',
249
249
  body,
250
- })));
250
+ }));
251
251
  }
252
252
  /**
253
253
  * Get my profile
254
254
  */
255
255
  function getProfile(opts) {
256
- return oazapfts.ok(oazapfts.fetchJson('/profile', {
256
+ return oazapfts$1.fetchJson('/profile', {
257
257
  ...opts,
258
- }));
258
+ });
259
259
  }
260
260
  /**
261
261
  * Update my profile
262
262
  */
263
263
  function updateProfile(body, opts) {
264
- return oazapfts.ok(oazapfts.fetchJson('/profile', oazapfts.json({
264
+ return oazapfts$1.fetchJson('/profile', oazapfts$1.json({
265
265
  ...opts,
266
266
  method: 'PATCH',
267
267
  body,
268
- })));
268
+ }));
269
269
  }
270
270
  /**
271
271
  * Call an integration's me
272
272
  */
273
273
  function getProxyMe(xUnitoCredentialId, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
274
- return oazapfts.ok(oazapfts.fetchJson('/proxy/me', {
274
+ return oazapfts$1.fetchJson('/proxy/me', {
275
275
  ...opts,
276
- headers: oazapfts.mergeHeaders(opts?.headers, {
276
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
277
277
  'X-Unito-Credential-Id': xUnitoCredentialId,
278
278
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
279
279
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
280
280
  }),
281
- }));
281
+ });
282
282
  }
283
283
  /**
284
284
  * Update a webhook subscription
285
285
  */
286
286
  function updateWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
287
- return oazapfts.ok(oazapfts.fetchJson('/proxy/webhooks/subscriptions', oazapfts.json({
287
+ return oazapfts$1.fetchJson('/proxy/webhooks/subscriptions', oazapfts$1.json({
288
288
  ...opts,
289
289
  method: 'PUT',
290
290
  body,
291
- headers: oazapfts.mergeHeaders(opts?.headers, {
291
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
292
292
  'X-Unito-Credential-Id': xUnitoCredentialId,
293
293
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
294
294
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
295
295
  }),
296
- })));
296
+ }));
297
297
  }
298
298
  /**
299
299
  * Call an integration's graph
300
300
  */
301
- function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
302
- return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
301
+ function getProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, accept, } = {}, opts) {
302
+ return oazapfts$1.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
303
303
  path,
304
304
  }))}`, {
305
305
  ...opts,
306
- headers: oazapfts.mergeHeaders(opts?.headers, {
306
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
307
307
  'X-Unito-Credential-Id': xUnitoCredentialId,
308
308
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
309
309
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
310
+ Accept: accept,
310
311
  }),
311
- }));
312
+ });
312
313
  }
313
314
  /**
314
315
  * Call an integration's graph
315
316
  */
316
- function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
317
- return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
317
+ function patchProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, contentType, } = {}, opts) {
318
+ return oazapfts$1.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
318
319
  path,
319
- }))}`, oazapfts.json({
320
+ }))}`, oazapfts$1.json({
320
321
  ...opts,
321
322
  method: 'PATCH',
322
323
  body,
323
- headers: oazapfts.mergeHeaders(opts?.headers, {
324
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
324
325
  'X-Unito-Credential-Id': xUnitoCredentialId,
325
326
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
326
327
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
328
+ 'Content-Type': contentType,
327
329
  }),
328
- })));
330
+ }));
329
331
  }
330
332
  /**
331
333
  * Call an integration's graph
332
334
  */
333
- function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
334
- return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
335
+ function postProxyGraph(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, contentType, } = {}, opts) {
336
+ return oazapfts$1.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
335
337
  path,
336
- }))}`, oazapfts.json({
338
+ }))}`, oazapfts$1.json({
337
339
  ...opts,
338
340
  method: 'POST',
339
341
  body,
340
- headers: oazapfts.mergeHeaders(opts?.headers, {
342
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
341
343
  'X-Unito-Credential-Id': xUnitoCredentialId,
342
344
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
343
345
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
346
+ 'Content-Type': contentType,
344
347
  }),
345
- })));
348
+ }));
346
349
  }
347
350
  /**
348
351
  * Call an integration's graph
349
352
  */
350
353
  function deleteProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
351
- return oazapfts.ok(oazapfts.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
354
+ return oazapfts$1.fetchJson(`/proxy/graph${QS__namespace.query(QS__namespace.explode({
352
355
  path,
353
356
  }))}`, {
354
357
  ...opts,
355
358
  method: 'DELETE',
356
- headers: oazapfts.mergeHeaders(opts?.headers, {
359
+ headers: oazapfts$1.mergeHeaders(opts?.headers, {
357
360
  'X-Unito-Credential-Id': xUnitoCredentialId,
358
361
  'X-Unito-Correlation-Id': xUnitoCorrelationId,
359
362
  'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
360
363
  }),
361
- }));
364
+ });
362
365
  }
363
366
  /**
364
367
  * Get all the users
365
368
  */
366
369
  function getUsers({ pagination, } = {}, opts) {
367
- return oazapfts.ok(oazapfts.fetchJson(`/users${QS__namespace.query(QS__namespace.explode({
370
+ return oazapfts$1.fetchJson(`/users${QS__namespace.query(QS__namespace.explode({
368
371
  pagination,
369
372
  }))}`, {
370
373
  ...opts,
371
- }));
374
+ });
372
375
  }
373
376
  /**
374
377
  * Create a user
375
378
  */
376
379
  function createUser(body, opts) {
377
- return oazapfts.ok(oazapfts.fetchJson('/users', oazapfts.json({
380
+ return oazapfts$1.fetchJson('/users', oazapfts$1.json({
378
381
  ...opts,
379
382
  method: 'POST',
380
383
  body,
381
- })));
384
+ }));
382
385
  }
383
386
  /**
384
387
  * Get a user
385
388
  */
386
389
  function getUserById(userId, opts) {
387
- return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, {
390
+ return oazapfts$1.fetchJson(`/users/${encodeURIComponent(userId)}`, {
388
391
  ...opts,
389
- }));
392
+ });
390
393
  }
391
394
  /**
392
395
  * Update a user
393
396
  */
394
397
  function updateUser(userId, body, opts) {
395
- return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}`, oazapfts.json({
398
+ return oazapfts$1.fetchJson(`/users/${encodeURIComponent(userId)}`, oazapfts$1.json({
396
399
  ...opts,
397
400
  method: 'PATCH',
398
401
  body,
399
- })));
402
+ }));
400
403
  }
401
404
  /**
402
405
  * Regenerate the api key of a user
403
406
  */
404
407
  function regenerateApiKey(userId, opts) {
405
- return oazapfts.ok(oazapfts.fetchJson(`/users/${encodeURIComponent(userId)}/apiKey`, {
408
+ return oazapfts$1.fetchJson(`/users/${encodeURIComponent(userId)}/apiKey`, {
406
409
  ...opts,
407
410
  method: 'POST',
408
- }));
411
+ });
409
412
  }
410
413
  /**
411
414
  * Get a user by its email address
412
415
  */
413
416
  function getUserByEmail(email, opts) {
414
- return oazapfts.ok(oazapfts.fetchJson(`/users/find/${encodeURIComponent(email)}`, {
417
+ return oazapfts$1.fetchJson(`/users/find/${encodeURIComponent(email)}`, {
415
418
  ...opts,
416
- }));
419
+ });
417
420
  }
421
+
422
+ // MANUAL ADDONS
423
+ const oazapfts = Oazapfts__namespace.runtime(defaults);
418
424
  /**
425
+ * Provides a type guard for ItemResponse.
426
+ *
419
427
  * Return true if object has the shape of an item, false otherwise.
420
428
  * @param object
421
429
  */
422
- function isIntegrationApiItem(object) {
423
- return object && typeof object === 'object' && 'fields' in object && 'relations' in object;
430
+ function isItemResponse(object) {
431
+ const data = object.data;
432
+ return !!object && !!data && typeof data === 'object' && 'fields' in data && 'relations' in data;
424
433
  }
425
434
  /**
426
- * Return true if object has the shape of an item, false otherwise.
435
+ * Provides a type guard for ItemSummaryResponse.
436
+ *
437
+ * Return true if object has the shape of an item summary, false otherwise.
427
438
  * @param object
428
439
  */
429
- function isIntegrationApiItemSummary(object) {
430
- return object && typeof object === 'object' && 'path' in object;
440
+ function isItemSummaryResponse(object) {
441
+ const data = object.data;
442
+ return !!object && !!data && typeof data === 'object' && 'path' in data;
431
443
  }
432
444
  /**
445
+ * Provides a type guard for CollectionResponse.
446
+ *
433
447
  * Return true if object has the shape of a collection, false otherwise.
434
448
  * @param object
435
449
  */
436
- function isIntegrationApiCollection(object) {
437
- return object && typeof object === 'object' && 'info' in object && 'data' in object && Array.isArray(object.data);
450
+ function isCollectionResponse(object) {
451
+ const data = object.data;
452
+ return !!object && !!data && typeof data === 'object' && 'info' in data && 'data' in data && Array.isArray(data.data);
453
+ }
454
+ /**
455
+ * Provides a type guard for ErrorResponse.
456
+ *
457
+ * Return true if object has the shape of an error response, false otherwise.
458
+ * @param object
459
+ */
460
+ function isErrorResponse(object) {
461
+ const status = object.status;
462
+ return !!object && typeof object === 'object' && status && status >= 400 && 'data' in object && 'headers' in object;
463
+ }
464
+ /**
465
+ * Opt-in optimistic mode.
466
+ *
467
+ * Returns the typed response's data if it's a success, otherwise throws an HttpError.
468
+ *
469
+ * @param response received from the Integrations Platform Client
470
+ * @returns the response's data, typed, if it's a success
471
+ */
472
+ async function optimistic(asyncResponse) {
473
+ const response = await asyncResponse;
474
+ if (isErrorResponse(response)) {
475
+ throw new Oazapfts.HttpError(response.status, response.data, response.headers);
476
+ }
477
+ return response.data;
438
478
  }
479
+ /**
480
+ * Wrapper of getProxyGraph that returns a typed response containing an Item upon success.
481
+ *
482
+ * @param xUnitoCredentialId The credential ID to use for the request
483
+ * @param path The path to the item to fetch
484
+ * @param headers The headers to include in the request
485
+ * @param opts Additional options
486
+ * @returns A successful response containing an Item, or an ErrorResponse
487
+ */
439
488
  async function getProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
440
489
  const response = await getProxyGraph(xUnitoCredentialId, path, {
441
490
  xUnitoCorrelationId,
442
491
  xUnitoAdditionalLoggingContext,
443
492
  }, opts);
444
- if (isIntegrationApiItem(response)) {
493
+ if (isItemResponse(response) || isErrorResponse(response)) {
445
494
  return response;
446
495
  }
447
496
  else {
448
497
  throw new Error(`Response does not match expected Item shape`);
449
498
  }
450
499
  }
500
+ /**
501
+ * Wrapper of getProxyGraph that returns a typed response containing a Collection upon success.
502
+ *
503
+ * @param xUnitoCredentialId The credential ID to use for the request
504
+ * @param path The path to the item to fetch
505
+ * @param headers The headers to include in the request
506
+ * @param opts Additional options
507
+ * @returns A successful response containing an Collection, or an ErrorResponse
508
+ */
451
509
  async function getProxyGraphCollection(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
452
510
  const response = await getProxyGraph(xUnitoCredentialId, path, {
453
511
  xUnitoCorrelationId,
454
512
  xUnitoAdditionalLoggingContext,
455
513
  }, opts);
456
- if (isIntegrationApiCollection(response)) {
514
+ if (isCollectionResponse(response) || isErrorResponse(response)) {
457
515
  return response;
458
516
  }
459
517
  else {
460
518
  throw new Error(`Response does not match expected Collection shape`);
461
519
  }
462
520
  }
521
+ /**
522
+ * Wrapper of patchProxyGraph that returns a typed response containing the updated Item upon success.
523
+ *
524
+ * @param xUnitoCredentialId The credential ID to use for the request
525
+ * @param path The path to the item to fetch
526
+ * @param headers The headers to include in the request
527
+ * @param opts Additional options
528
+ * @returns A successful response containing an Item, or an ErrorResponse
529
+ */
463
530
  async function patchProxyGraphItem(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
464
531
  const response = await patchProxyGraph(xUnitoCredentialId, path, body, {
465
532
  xUnitoCorrelationId,
466
533
  xUnitoAdditionalLoggingContext,
467
534
  }, opts);
468
- if (isIntegrationApiItem(response)) {
535
+ if (isItemResponse(response) || isErrorResponse(response)) {
469
536
  return response;
470
537
  }
471
538
  else {
472
539
  throw new Error(`Response does not match expected Item shape`);
473
540
  }
474
541
  }
542
+ /**
543
+ * Wrapper of postProxyGraph that returns a typed response containing the created ItemSummary upon success.
544
+ *
545
+ * @param xUnitoCredentialId The credential ID to use for the request
546
+ * @param path The path to the item to fetch
547
+ * @param headers The headers to include in the request
548
+ * @param opts Additional options
549
+ * @returns A successful response containing an ItemSummary, or an ErrorResponse
550
+ */
475
551
  async function postProxyGraphCollection(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
476
552
  const response = await postProxyGraph(xUnitoCredentialId, path, body, {
477
553
  xUnitoCorrelationId,
478
554
  xUnitoAdditionalLoggingContext,
479
555
  }, opts);
480
- if (isIntegrationApiItemSummary(response)) {
556
+ if (isItemSummaryResponse(response) || isErrorResponse(response)) {
481
557
  return response;
482
558
  }
483
559
  else {
484
560
  throw new Error(`Response does not match expected ItemSummary shape`);
485
561
  }
486
562
  }
563
+ /**
564
+ * Wrapper of deleteProxyGraph added for uniformity, doesn't provide much typing help.
565
+ *
566
+ * @param xUnitoCredentialId The credential ID to use for the request
567
+ * @param path The path to the item to fetch
568
+ * @param headers The headers to include in the request
569
+ * @param opts Additional options
570
+ */
487
571
  async function deleteProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
488
572
  await deleteProxyGraph(xUnitoCredentialId, path, {
489
573
  xUnitoCorrelationId,
490
574
  xUnitoAdditionalLoggingContext,
491
575
  }, opts);
492
576
  }
577
+ /**
578
+ * Call an integration's graph and returns the fetch response directly to enable streaming of the body as it comes in.
579
+ *
580
+ * @param xUnitoCredentialId The credential ID to use for the request
581
+ * @param path The path to the item to fetch
582
+ * @param headers Base headers to add to the request
583
+ * @param additionalHeaders Additional headers to add to the request
584
+ * @returns fetch's response
585
+ */
586
+ async function fetchProxyGraph(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, accept, } = {}, init) {
587
+ return fetch(`${defaults.baseUrl}/proxy/graph${QS__namespace.query(QS__namespace.explode({ path }))}`, {
588
+ ...(init ?? {}),
589
+ headers: oazapfts.mergeHeaders({
590
+ ...defaults.headers,
591
+ ...(init?.headers ?? {}),
592
+ 'X-Unito-Credential-Id': xUnitoCredentialId,
593
+ 'X-Unito-Correlation-Id': xUnitoCorrelationId,
594
+ 'X-Unito-Additional-Logging-Context': xUnitoAdditionalLoggingContext,
595
+ Accept: accept,
596
+ }),
597
+ });
598
+ }
493
599
 
494
- var api = {
495
- __proto__: null,
496
- HttpError: Oazapfts.HttpError,
497
- createCredential: createCredential,
498
- createIntegration: createIntegration,
499
- createUser: createUser,
500
- decryptData: decryptData,
501
- defaults: defaults,
502
- deleteCredential: deleteCredential,
503
- deleteIntegration: deleteIntegration,
504
- deleteProxyGraph: deleteProxyGraph,
505
- deleteProxyGraphItem: deleteProxyGraphItem,
506
- encryptData: encryptData,
507
- getCredentialAccount: getCredentialAccount,
508
- getCredentialById: getCredentialById,
509
- getCredentials: getCredentials,
510
- getIntegrationById: getIntegrationById,
511
- getIntegrationByName: getIntegrationByName,
512
- getIntegrationEvents: getIntegrationEvents,
513
- getIntegrationLogo: getIntegrationLogo,
514
- getIntegrations: getIntegrations,
515
- getProfile: getProfile,
516
- getProxyGraph: getProxyGraph,
517
- getProxyGraphCollection: getProxyGraphCollection,
518
- getProxyGraphItem: getProxyGraphItem,
519
- getProxyMe: getProxyMe,
520
- getUserByEmail: getUserByEmail,
521
- getUserById: getUserById,
522
- getUsers: getUsers,
523
- inviteOrganization: inviteOrganization,
524
- inviteUser: inviteUser,
525
- isIntegrationApiCollection: isIntegrationApiCollection,
526
- isIntegrationApiItem: isIntegrationApiItem,
527
- isIntegrationApiItemSummary: isIntegrationApiItemSummary,
528
- patchProxyGraph: patchProxyGraph,
529
- patchProxyGraphItem: patchProxyGraphItem,
530
- postProxyGraph: postProxyGraph,
531
- postProxyGraphCollection: postProxyGraphCollection,
532
- postTrack: postTrack,
533
- publishIntegration: publishIntegration,
534
- reencryptData: reencryptData,
535
- regenerateApiKey: regenerateApiKey,
536
- servers: servers,
537
- updateCredential: updateCredential,
538
- updateIntegration: updateIntegration,
539
- updateProfile: updateProfile,
540
- updateUser: updateUser,
541
- updateWebhookSubscription: updateWebhookSubscription
542
- };
543
-
544
- module.exports = api;
545
- module.exports.default = api;
600
+ Object.defineProperty(exports, "HttpError", {
601
+ enumerable: true,
602
+ get: function () { return Oazapfts.HttpError; }
603
+ });
604
+ exports.createCredential = createCredential;
605
+ exports.createIntegration = createIntegration;
606
+ exports.createUser = createUser;
607
+ exports.decryptData = decryptData;
608
+ exports.defaults = defaults;
609
+ exports.deleteCredential = deleteCredential;
610
+ exports.deleteIntegration = deleteIntegration;
611
+ exports.deleteProxyGraph = deleteProxyGraph;
612
+ exports.deleteProxyGraphItem = deleteProxyGraphItem;
613
+ exports.encryptData = encryptData;
614
+ exports.fetchProxyGraph = fetchProxyGraph;
615
+ exports.getCredentialAccount = getCredentialAccount;
616
+ exports.getCredentialById = getCredentialById;
617
+ exports.getCredentials = getCredentials;
618
+ exports.getIntegrationById = getIntegrationById;
619
+ exports.getIntegrationByName = getIntegrationByName;
620
+ exports.getIntegrationEvents = getIntegrationEvents;
621
+ exports.getIntegrationLogo = getIntegrationLogo;
622
+ exports.getIntegrations = getIntegrations;
623
+ exports.getProfile = getProfile;
624
+ exports.getProxyGraph = getProxyGraph;
625
+ exports.getProxyGraphCollection = getProxyGraphCollection;
626
+ exports.getProxyGraphItem = getProxyGraphItem;
627
+ exports.getProxyMe = getProxyMe;
628
+ exports.getUserByEmail = getUserByEmail;
629
+ exports.getUserById = getUserById;
630
+ exports.getUsers = getUsers;
631
+ exports.inviteOrganization = inviteOrganization;
632
+ exports.inviteUser = inviteUser;
633
+ exports.isCollectionResponse = isCollectionResponse;
634
+ exports.isErrorResponse = isErrorResponse;
635
+ exports.isItemResponse = isItemResponse;
636
+ exports.isItemSummaryResponse = isItemSummaryResponse;
637
+ exports.optimistic = optimistic;
638
+ exports.patchProxyGraph = patchProxyGraph;
639
+ exports.patchProxyGraphItem = patchProxyGraphItem;
640
+ exports.postProxyGraph = postProxyGraph;
641
+ exports.postProxyGraphCollection = postProxyGraphCollection;
642
+ exports.postTrack = postTrack;
643
+ exports.publishIntegration = publishIntegration;
644
+ exports.reencryptData = reencryptData;
645
+ exports.regenerateApiKey = regenerateApiKey;
646
+ exports.servers = servers;
647
+ exports.updateCredential = updateCredential;
648
+ exports.updateIntegration = updateIntegration;
649
+ exports.updateProfile = updateProfile;
650
+ exports.updateUser = updateUser;
651
+ exports.updateWebhookSubscription = updateWebhookSubscription;