@unito/integrations-platform-client 0.48.4 → 1.0.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.
@@ -0,0 +1,66 @@
1
+ import * as IntegrationApi from '@unito/integration-api';
2
+ import * as Oazapfts from '@oazapfts/runtime';
3
+ /**
4
+ * Return true if object has the shape of an item, false otherwise.
5
+ * @param object
6
+ */
7
+ export declare function isItemResponse(object: unknown): object is Response<IntegrationApi.Item>;
8
+ /**
9
+ * Return true if object has the shape of an item, false otherwise.
10
+ * @param object
11
+ */
12
+ export declare function isItemSummaryResponse(object: unknown): object is Response<IntegrationApi.ItemSummary>;
13
+ /**
14
+ * Return true if object has the shape of a collection, false otherwise.
15
+ * @param object
16
+ */
17
+ export declare function isCollectionResponse(object: unknown): object is Response<IntegrationApi.Collection>;
18
+ export declare function isErrorResponse(object: unknown): object is ErrorResponse;
19
+ type Response<T> = {
20
+ status: 200;
21
+ data: T;
22
+ headers: Headers;
23
+ };
24
+ type ErrorResponse = ({
25
+ status: 400;
26
+ } | {
27
+ status: 401;
28
+ } | {
29
+ status: 403;
30
+ } | {
31
+ status: 404;
32
+ } | {
33
+ status: 406;
34
+ } | {
35
+ status: 410;
36
+ } | {
37
+ status: 422;
38
+ } | {
39
+ status: 429;
40
+ } | {
41
+ status: 500;
42
+ }) & {
43
+ data: Error;
44
+ headers: Headers;
45
+ };
46
+ export declare function getProxyGraphItem(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
47
+ xUnitoCorrelationId?: string;
48
+ xUnitoAdditionalLoggingContext?: string;
49
+ }, opts?: Oazapfts.RequestOpts): Promise<Response<IntegrationApi.Item> | ErrorResponse>;
50
+ export declare function getProxyGraphCollection(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
51
+ xUnitoCorrelationId?: string;
52
+ xUnitoAdditionalLoggingContext?: string;
53
+ }, opts?: Oazapfts.RequestOpts): Promise<Response<IntegrationApi.Collection> | ErrorResponse>;
54
+ export declare function patchProxyGraphItem(xUnitoCredentialId: string, path: string, body?: object, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
55
+ xUnitoCorrelationId?: string;
56
+ xUnitoAdditionalLoggingContext?: string;
57
+ }, opts?: Oazapfts.RequestOpts): Promise<Response<IntegrationApi.Item> | ErrorResponse>;
58
+ export declare function postProxyGraphCollection(xUnitoCredentialId: string, path: string, body?: object, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
59
+ xUnitoCorrelationId?: string;
60
+ xUnitoAdditionalLoggingContext?: string;
61
+ }, opts?: Oazapfts.RequestOpts): Promise<Response<IntegrationApi.ItemSummary> | ErrorResponse>;
62
+ export declare function deleteProxyGraphItem(xUnitoCredentialId: string, path: string, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, }?: {
63
+ xUnitoCorrelationId?: string;
64
+ xUnitoAdditionalLoggingContext?: string;
65
+ }, opts?: Oazapfts.RequestOpts): Promise<void>;
66
+ export {};
@@ -0,0 +1,84 @@
1
+ // MANUAL ADDONS
2
+ import { getProxyGraph, patchProxyGraph, postProxyGraph, deleteProxyGraph } from './api.js';
3
+ /**
4
+ * Return true if object has the shape of an item, false otherwise.
5
+ * @param object
6
+ */
7
+ export function isItemResponse(object) {
8
+ const data = object.data;
9
+ return !!object && !!data && typeof data === 'object' && 'fields' in data && 'relations' in data;
10
+ }
11
+ /**
12
+ * Return true if object has the shape of an item, false otherwise.
13
+ * @param object
14
+ */
15
+ export function isItemSummaryResponse(object) {
16
+ const data = object.data;
17
+ return !!object && !!data && typeof data === 'object' && 'path' in data;
18
+ }
19
+ /**
20
+ * Return true if object has the shape of a collection, false otherwise.
21
+ * @param object
22
+ */
23
+ export function isCollectionResponse(object) {
24
+ const data = object.data;
25
+ return !!object && !!data && typeof data === 'object' && 'info' in data && 'data' in data && Array.isArray(data.data);
26
+ }
27
+ export function isErrorResponse(object) {
28
+ const status = object.status;
29
+ return !!object && typeof object === 'object' && status && status >= 400 && 'data' in object && 'headers' in object;
30
+ }
31
+ export async function getProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
32
+ const response = await getProxyGraph(xUnitoCredentialId, path, {
33
+ xUnitoCorrelationId,
34
+ xUnitoAdditionalLoggingContext,
35
+ }, opts);
36
+ if (isItemResponse(response) || isErrorResponse(response)) {
37
+ return response;
38
+ }
39
+ else {
40
+ throw new Error(`Response does not match expected Item shape`);
41
+ }
42
+ }
43
+ export async function getProxyGraphCollection(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
44
+ const response = await getProxyGraph(xUnitoCredentialId, path, {
45
+ xUnitoCorrelationId,
46
+ xUnitoAdditionalLoggingContext,
47
+ }, opts);
48
+ if (isCollectionResponse(response) || isErrorResponse(response)) {
49
+ return response;
50
+ }
51
+ else {
52
+ throw new Error(`Response does not match expected Collection shape`);
53
+ }
54
+ }
55
+ export async function patchProxyGraphItem(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
56
+ const response = await patchProxyGraph(xUnitoCredentialId, path, body, {
57
+ xUnitoCorrelationId,
58
+ xUnitoAdditionalLoggingContext,
59
+ }, opts);
60
+ if (isItemResponse(response) || isErrorResponse(response)) {
61
+ return response;
62
+ }
63
+ else {
64
+ throw new Error(`Response does not match expected Item shape`);
65
+ }
66
+ }
67
+ export async function postProxyGraphCollection(xUnitoCredentialId, path, body, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
68
+ const response = await postProxyGraph(xUnitoCredentialId, path, body, {
69
+ xUnitoCorrelationId,
70
+ xUnitoAdditionalLoggingContext,
71
+ }, opts);
72
+ if (isItemSummaryResponse(response) || isErrorResponse(response)) {
73
+ return response;
74
+ }
75
+ else {
76
+ throw new Error(`Response does not match expected ItemSummary shape`);
77
+ }
78
+ }
79
+ export async function deleteProxyGraphItem(xUnitoCredentialId, path, { xUnitoCorrelationId, xUnitoAdditionalLoggingContext, } = {}, opts) {
80
+ await deleteProxyGraph(xUnitoCredentialId, path, {
81
+ xUnitoCorrelationId,
82
+ xUnitoAdditionalLoggingContext,
83
+ }, opts);
84
+ }