@unito/integrations-platform-client 1.2.1 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/addons.d.ts +30 -2
- package/dist/src/addons.js +19 -10
- package/dist/src/api.d.ts +4 -0
- package/dist/src/index.cjs +19 -9
- package/package.json +1 -1
package/dist/src/addons.d.ts
CHANGED
|
@@ -39,11 +39,12 @@ export declare function isErrorResponse(object: unknown): object is ErrorRespons
|
|
|
39
39
|
* @param response received from the Integrations Platform Client
|
|
40
40
|
* @returns the response's data, typed, if it's a success
|
|
41
41
|
*/
|
|
42
|
+
export declare function optimistic(asyncResponse: Promise<EmptyResponse | ErrorResponse>): Promise<void>;
|
|
42
43
|
export declare function optimistic<T>(asyncResponse: Promise<Response<T> | ErrorResponse>): Promise<T>;
|
|
43
44
|
/**
|
|
44
45
|
* Represents a successful response from the Integrations Platform Client.
|
|
45
46
|
*/
|
|
46
|
-
type Response<T> = ({
|
|
47
|
+
export type Response<T> = ({
|
|
47
48
|
status: 200;
|
|
48
49
|
} | {
|
|
49
50
|
status: 201;
|
|
@@ -55,10 +56,20 @@ type Response<T> = ({
|
|
|
55
56
|
data: T;
|
|
56
57
|
headers: Headers;
|
|
57
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Represents a successful response from the Integrations Platform Client with no body.
|
|
61
|
+
*/
|
|
62
|
+
export type EmptyResponse = ({
|
|
63
|
+
status: 202;
|
|
64
|
+
} | {
|
|
65
|
+
status: 204;
|
|
66
|
+
}) & {
|
|
67
|
+
headers: Headers;
|
|
68
|
+
};
|
|
58
69
|
/**
|
|
59
70
|
* Represents an error response from the Integrations Platform Client.
|
|
60
71
|
*/
|
|
61
|
-
type ErrorResponse = ({
|
|
72
|
+
export type ErrorResponse = ({
|
|
62
73
|
status: 400;
|
|
63
74
|
} | {
|
|
64
75
|
status: 401;
|
|
@@ -152,6 +163,23 @@ export declare function deleteProxyGraphItem(xUnitoCredentialId: string, path: s
|
|
|
152
163
|
xUnitoAdditionalLoggingContext?: string;
|
|
153
164
|
xUnitoOperationDeadline?: string;
|
|
154
165
|
}, opts?: Oazapfts.RequestOpts): Promise<Response<object> | ErrorResponse>;
|
|
166
|
+
/**
|
|
167
|
+
* Wrapper of updateWebhookSubscription that returns a typed response.
|
|
168
|
+
*
|
|
169
|
+
* @param xUnitoCredentialId The credential ID to use for the request
|
|
170
|
+
* @param body The webhook subscription update payload
|
|
171
|
+
* @param headers The headers to include in the request
|
|
172
|
+
* @param opts Additional options
|
|
173
|
+
* @returns A successful response or an ErrorResponse
|
|
174
|
+
*/
|
|
175
|
+
export declare function updateProxyWebhookSubscription(xUnitoCredentialId: string, body: {
|
|
176
|
+
itemPath: string;
|
|
177
|
+
targetUrl: string;
|
|
178
|
+
action: 'start' | 'stop';
|
|
179
|
+
}, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
|
|
180
|
+
xUnitoCorrelationId?: string;
|
|
181
|
+
xUnitoAdditionalLoggingContext?: string;
|
|
182
|
+
}, opts?: Oazapfts.RequestOpts): Promise<EmptyResponse | ErrorResponse>;
|
|
155
183
|
/**
|
|
156
184
|
* Call an integration's graph and returns the fetch response directly to enable streaming of the body as it comes in.
|
|
157
185
|
*
|
package/dist/src/addons.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as Oazapfts from '@oazapfts/runtime';
|
|
|
3
3
|
import * as QS from '@oazapfts/runtime/query';
|
|
4
4
|
import { HttpError } from '@oazapfts/runtime';
|
|
5
5
|
export { HttpError };
|
|
6
|
-
import { defaults, getProxyGraph, patchProxyGraph, postProxyGraph, deleteProxyGraph } from './api.js';
|
|
6
|
+
import { defaults, getProxyGraph, patchProxyGraph, postProxyGraph, deleteProxyGraph, updateWebhookSubscription, } from './api.js';
|
|
7
7
|
const oazapfts = Oazapfts.runtime(defaults);
|
|
8
8
|
/**
|
|
9
9
|
* Provides a type guard for ItemResponse.
|
|
@@ -45,20 +45,14 @@ export function isErrorResponse(object) {
|
|
|
45
45
|
const status = object.status;
|
|
46
46
|
return !!object && typeof object === 'object' && status && status >= 400 && 'data' in object && 'headers' in object;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Opt-in optimistic mode.
|
|
50
|
-
*
|
|
51
|
-
* Returns the typed response's data if it's a success, otherwise throws an HttpError.
|
|
52
|
-
*
|
|
53
|
-
* @param response received from the Integrations Platform Client
|
|
54
|
-
* @returns the response's data, typed, if it's a success
|
|
55
|
-
*/
|
|
56
48
|
export async function optimistic(asyncResponse) {
|
|
57
49
|
const response = await asyncResponse;
|
|
58
50
|
if (isErrorResponse(response)) {
|
|
59
51
|
throw new HttpError(response.status, response.data, response.headers);
|
|
60
52
|
}
|
|
61
|
-
|
|
53
|
+
if ('data' in response) {
|
|
54
|
+
return response.data;
|
|
55
|
+
}
|
|
62
56
|
}
|
|
63
57
|
/**
|
|
64
58
|
* Wrapper of getProxyGraph that returns a typed response containing an Item upon success.
|
|
@@ -164,6 +158,21 @@ export async function deleteProxyGraphItem(xUnitoCredentialId, path, { xUnitoCor
|
|
|
164
158
|
xUnitoOperationDeadline,
|
|
165
159
|
}, opts);
|
|
166
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Wrapper of updateWebhookSubscription that returns a typed response.
|
|
163
|
+
*
|
|
164
|
+
* @param xUnitoCredentialId The credential ID to use for the request
|
|
165
|
+
* @param body The webhook subscription update payload
|
|
166
|
+
* @param headers The headers to include in the request
|
|
167
|
+
* @param opts Additional options
|
|
168
|
+
* @returns A successful response or an ErrorResponse
|
|
169
|
+
*/
|
|
170
|
+
export async function updateProxyWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
|
|
171
|
+
return await updateWebhookSubscription(xUnitoCredentialId, body, {
|
|
172
|
+
xUnitoCorrelationId,
|
|
173
|
+
xUnitoAdditionalLoggingContext,
|
|
174
|
+
}, opts);
|
|
175
|
+
}
|
|
167
176
|
/**
|
|
168
177
|
* Call an integration's graph and returns the fetch response directly to enable streaming of the body as it comes in.
|
|
169
178
|
*
|
package/dist/src/api.d.ts
CHANGED
|
@@ -554,10 +554,14 @@ export declare function getCredentials({ pagination, filters, }?: {
|
|
|
554
554
|
unitoUserId?: string;
|
|
555
555
|
/** The id of the credential account for which this credential belongs to. */
|
|
556
556
|
credentialAccountId?: string;
|
|
557
|
+
/** The credential was created after the provided date. */
|
|
558
|
+
createdAfter?: string;
|
|
557
559
|
/** The last access to the credential account occured before the provided date. */
|
|
558
560
|
lastCredentialAccountAccessAtBefore?: string;
|
|
559
561
|
/** The first failure to access the credential account occured after the provided date. */
|
|
560
562
|
firstFailedCredentialAccountAccessAtAfter?: string;
|
|
563
|
+
/** Whether to filter archived credentials. */
|
|
564
|
+
isArchived?: boolean;
|
|
561
565
|
};
|
|
562
566
|
}, opts?: Oazapfts.RequestOpts): Promise<Oazapfts.WithHeaders<{
|
|
563
567
|
status: 200;
|
package/dist/src/index.cjs
CHANGED
|
@@ -483,20 +483,14 @@ function isErrorResponse(object) {
|
|
|
483
483
|
const status = object.status;
|
|
484
484
|
return !!object && typeof object === 'object' && status && status >= 400 && 'data' in object && 'headers' in object;
|
|
485
485
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Opt-in optimistic mode.
|
|
488
|
-
*
|
|
489
|
-
* Returns the typed response's data if it's a success, otherwise throws an HttpError.
|
|
490
|
-
*
|
|
491
|
-
* @param response received from the Integrations Platform Client
|
|
492
|
-
* @returns the response's data, typed, if it's a success
|
|
493
|
-
*/
|
|
494
486
|
async function optimistic(asyncResponse) {
|
|
495
487
|
const response = await asyncResponse;
|
|
496
488
|
if (isErrorResponse(response)) {
|
|
497
489
|
throw new Oazapfts.HttpError(response.status, response.data, response.headers);
|
|
498
490
|
}
|
|
499
|
-
|
|
491
|
+
if ('data' in response) {
|
|
492
|
+
return response.data;
|
|
493
|
+
}
|
|
500
494
|
}
|
|
501
495
|
/**
|
|
502
496
|
* Wrapper of getProxyGraph that returns a typed response containing an Item upon success.
|
|
@@ -602,6 +596,21 @@ async function deleteProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelatio
|
|
|
602
596
|
xUnitoOperationDeadline,
|
|
603
597
|
}, opts);
|
|
604
598
|
}
|
|
599
|
+
/**
|
|
600
|
+
* Wrapper of updateWebhookSubscription that returns a typed response.
|
|
601
|
+
*
|
|
602
|
+
* @param xUnitoCredentialId The credential ID to use for the request
|
|
603
|
+
* @param body The webhook subscription update payload
|
|
604
|
+
* @param headers The headers to include in the request
|
|
605
|
+
* @param opts Additional options
|
|
606
|
+
* @returns A successful response or an ErrorResponse
|
|
607
|
+
*/
|
|
608
|
+
async function updateProxyWebhookSubscription(xUnitoCredentialId, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
|
|
609
|
+
return await updateWebhookSubscription(xUnitoCredentialId, body, {
|
|
610
|
+
xUnitoCorrelationId,
|
|
611
|
+
xUnitoAdditionalLoggingContext,
|
|
612
|
+
}, opts);
|
|
613
|
+
}
|
|
605
614
|
/**
|
|
606
615
|
* Call an integration's graph and returns the fetch response directly to enable streaming of the body as it comes in.
|
|
607
616
|
*
|
|
@@ -677,5 +686,6 @@ exports.servers = servers;
|
|
|
677
686
|
exports.updateCredential = updateCredential;
|
|
678
687
|
exports.updateIntegration = updateIntegration;
|
|
679
688
|
exports.updateProfile = updateProfile;
|
|
689
|
+
exports.updateProxyWebhookSubscription = updateProxyWebhookSubscription;
|
|
680
690
|
exports.updateUser = updateUser;
|
|
681
691
|
exports.updateWebhookSubscription = updateWebhookSubscription;
|