@nangohq/node 0.21.13 → 0.21.141-beta
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/index.d.ts +86 -2
- package/dist/index.js +249 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +31 -18
- package/dist/types.js +5 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import type { AuthModes, OAuth1Credentials, OAuth2Credentials, ProxyConfiguration, GetRecordsRequestConfig } from './types.js';
|
|
2
|
+
export declare const stagingHost = "https://api-staging.nango.dev";
|
|
3
|
+
export declare const prodHost = "https://api.nango.dev";
|
|
4
|
+
interface NangoProps {
|
|
5
|
+
host?: string;
|
|
6
|
+
secretKey?: string;
|
|
7
|
+
connectionId?: string;
|
|
8
|
+
providerConfigKey?: string;
|
|
9
|
+
isSync?: boolean;
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
activityLogId?: number;
|
|
12
|
+
}
|
|
13
|
+
interface CreateConnectionOAuth1 extends OAuth1Credentials {
|
|
14
|
+
connection_id: string;
|
|
15
|
+
provider_config_key: string;
|
|
16
|
+
type: AuthModes.OAuth1;
|
|
17
|
+
}
|
|
18
|
+
interface CreateConnectionOAuth2 extends OAuth2Credentials {
|
|
19
|
+
connection_id: string;
|
|
20
|
+
provider_config_key: string;
|
|
21
|
+
type: AuthModes.OAuth2;
|
|
22
|
+
}
|
|
23
|
+
export declare class Nango {
|
|
24
|
+
serverUrl: string;
|
|
25
|
+
secretKey: string;
|
|
26
|
+
connectionId?: string;
|
|
27
|
+
providerConfigKey?: string;
|
|
28
|
+
isSync: boolean;
|
|
29
|
+
dryRun: boolean;
|
|
30
|
+
activityLogId?: number;
|
|
31
|
+
constructor(config?: NangoProps);
|
|
32
|
+
/**
|
|
33
|
+
* For OAuth 2: returns the access token directly as a string.
|
|
34
|
+
* For OAuth 2: If you want to obtain a new refresh token from the provider before the current token has expired,
|
|
35
|
+
* you can set the forceRefresh argument to true."
|
|
36
|
+
* For OAuth 1: returns an object with 'oAuthToken' and 'oAuthTokenSecret' fields.
|
|
37
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
38
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
39
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
40
|
+
* you can set the forceRefresh argument to true.
|
|
41
|
+
* */
|
|
42
|
+
getToken(providerConfigKey: string, connectionId: string, forceRefresh?: boolean): Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Get the full (fresh) credentials payload returned by the external API,
|
|
45
|
+
* which also contains access credentials.
|
|
46
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
47
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
48
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
49
|
+
* you can set the forceRefresh argument to true.
|
|
50
|
+
* */
|
|
51
|
+
getRawTokenResponse(providerConfigKey: string, connectionId: string, forceRefresh?: boolean): Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the Connection object, which also contains access credentials and full credentials payload
|
|
54
|
+
* returned by the external API.
|
|
55
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
56
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
57
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
58
|
+
* you can set the forceRefresh argument to true.
|
|
59
|
+
* @param [refreshToken] - When set this returns the refresh token as part of the response
|
|
60
|
+
*/
|
|
61
|
+
getConnection(providerConfigKey: string, connectionId: string, forceRefresh?: boolean, refreshToken?: boolean): Promise<any>;
|
|
62
|
+
proxy(config: ProxyConfiguration): Promise<import("axios").AxiosResponse<any, any>>;
|
|
63
|
+
get(config: ProxyConfiguration): Promise<import("axios").AxiosResponse<any, any>>;
|
|
64
|
+
post(config: ProxyConfiguration): Promise<import("axios").AxiosResponse<any, any>>;
|
|
65
|
+
patch(config: ProxyConfiguration): Promise<import("axios").AxiosResponse<any, any>>;
|
|
66
|
+
delete(config: ProxyConfiguration): Promise<import("axios").AxiosResponse<any, any>>;
|
|
67
|
+
getRecords(config: GetRecordsRequestConfig): Promise<any>;
|
|
68
|
+
private getConnectionDetails;
|
|
69
|
+
/**
|
|
70
|
+
* Get the list of Connections, which does not contain access credentials.
|
|
71
|
+
*/
|
|
72
|
+
listConnections(connectionId?: string): Promise<any>;
|
|
73
|
+
setFieldMapping(fieldMapping: Record<string, string>, optionalProviderConfigKey?: string, optionalConnectionId?: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
74
|
+
getFieldMapping(optionalProviderConfigKey?: string, optionalConnectionId?: string): Promise<any>;
|
|
75
|
+
triggerSync({ connectionId, providerConfigKey }: {
|
|
76
|
+
connectionId: string;
|
|
77
|
+
providerConfigKey: string;
|
|
78
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
79
|
+
createConnection(connectionArgs: CreateConnectionOAuth1 | (CreateConnectionOAuth2 & {
|
|
80
|
+
metadata: string;
|
|
81
|
+
connection_config: string;
|
|
82
|
+
})): Promise<import("axios").AxiosResponse<any, any>>;
|
|
83
|
+
private listConnectionDetails;
|
|
84
|
+
private enrichHeaders;
|
|
85
|
+
}
|
|
86
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,250 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { validateProxyConfiguration, validateSyncRecordConfiguration } from './utils.js';
|
|
3
|
+
export const stagingHost = 'https://api-staging.nango.dev';
|
|
4
|
+
export const prodHost = 'https://api.nango.dev';
|
|
5
|
+
export class Nango {
|
|
6
|
+
serverUrl;
|
|
7
|
+
secretKey;
|
|
8
|
+
connectionId;
|
|
9
|
+
providerConfigKey;
|
|
10
|
+
isSync = false;
|
|
11
|
+
dryRun = false;
|
|
12
|
+
activityLogId;
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
config.host = config.host || prodHost;
|
|
15
|
+
this.serverUrl = config.host;
|
|
16
|
+
if (this.serverUrl.slice(-1) === '/') {
|
|
17
|
+
this.serverUrl = this.serverUrl.slice(0, -1);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
new URL(this.serverUrl);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new Error(`Invalid URL provided for the Nango host: ${this.serverUrl}`);
|
|
24
|
+
}
|
|
25
|
+
this.secretKey = config.secretKey || '';
|
|
26
|
+
this.connectionId = config.connectionId || '';
|
|
27
|
+
this.providerConfigKey = config.providerConfigKey || '';
|
|
28
|
+
if (config.isSync) {
|
|
29
|
+
this.isSync = config.isSync;
|
|
30
|
+
}
|
|
31
|
+
if (config.dryRun) {
|
|
32
|
+
this.dryRun = config.dryRun;
|
|
33
|
+
}
|
|
34
|
+
if (config.activityLogId) {
|
|
35
|
+
this.activityLogId = config.activityLogId;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* For OAuth 2: returns the access token directly as a string.
|
|
40
|
+
* For OAuth 2: If you want to obtain a new refresh token from the provider before the current token has expired,
|
|
41
|
+
* you can set the forceRefresh argument to true."
|
|
42
|
+
* For OAuth 1: returns an object with 'oAuthToken' and 'oAuthTokenSecret' fields.
|
|
43
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
44
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
45
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
46
|
+
* you can set the forceRefresh argument to true.
|
|
47
|
+
* */
|
|
48
|
+
async getToken(providerConfigKey, connectionId, forceRefresh) {
|
|
49
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
50
|
+
switch (response.data.credentials.type) {
|
|
51
|
+
case 'OAUTH2':
|
|
52
|
+
return response.data.credentials.access_token;
|
|
53
|
+
case 'OAUTH1':
|
|
54
|
+
return { oAuthToken: response.data.credentials.oauth_token, oAuthTokenSecret: response.data.credentials.oauth_token_secret };
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Unrecognized OAuth type '${response.data.credentials.type}' in stored credentials.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the full (fresh) credentials payload returned by the external API,
|
|
61
|
+
* which also contains access credentials.
|
|
62
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
63
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
64
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
65
|
+
* you can set the forceRefresh argument to true.
|
|
66
|
+
* */
|
|
67
|
+
async getRawTokenResponse(providerConfigKey, connectionId, forceRefresh) {
|
|
68
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
69
|
+
return response.data.credentials.raw;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the Connection object, which also contains access credentials and full credentials payload
|
|
73
|
+
* returned by the external API.
|
|
74
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
75
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
76
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
77
|
+
* you can set the forceRefresh argument to true.
|
|
78
|
+
* @param [refreshToken] - When set this returns the refresh token as part of the response
|
|
79
|
+
*/
|
|
80
|
+
async getConnection(providerConfigKey, connectionId, forceRefresh, refreshToken) {
|
|
81
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh, refreshToken);
|
|
82
|
+
return response.data;
|
|
83
|
+
}
|
|
84
|
+
async proxy(config) {
|
|
85
|
+
if (!config.connectionId && this.connectionId) {
|
|
86
|
+
config.connectionId = this.connectionId;
|
|
87
|
+
}
|
|
88
|
+
if (!config.providerConfigKey && this.providerConfigKey) {
|
|
89
|
+
config.providerConfigKey = this.providerConfigKey;
|
|
90
|
+
}
|
|
91
|
+
validateProxyConfiguration(config);
|
|
92
|
+
const { providerConfigKey, connectionId, method, retries, headers: customHeaders, baseUrlOverride } = config;
|
|
93
|
+
const url = `${this.serverUrl}/proxy/${config.endpoint}`;
|
|
94
|
+
const headers = {
|
|
95
|
+
'Connection-Id': connectionId,
|
|
96
|
+
'Provider-Config-Key': providerConfigKey,
|
|
97
|
+
'Base-Url-Override': baseUrlOverride || '',
|
|
98
|
+
'Nango-Is-Sync': this.isSync,
|
|
99
|
+
'Nango-Is-Dry-Run': this.dryRun,
|
|
100
|
+
'Nango-Activity-Log-Id': this.activityLogId || '',
|
|
101
|
+
...customHeaders
|
|
102
|
+
};
|
|
103
|
+
if (retries) {
|
|
104
|
+
headers['Retries'] = retries;
|
|
105
|
+
}
|
|
106
|
+
const options = {
|
|
107
|
+
headers: this.enrichHeaders(headers)
|
|
108
|
+
};
|
|
109
|
+
if (config.params) {
|
|
110
|
+
options.params = config.params;
|
|
111
|
+
}
|
|
112
|
+
if (config.paramsSerializer) {
|
|
113
|
+
options.paramsSerializer = config.paramsSerializer;
|
|
114
|
+
}
|
|
115
|
+
if (method?.toUpperCase() === 'POST') {
|
|
116
|
+
return axios.post(url, config.data, options);
|
|
117
|
+
}
|
|
118
|
+
else if (method?.toUpperCase() === 'PATCH') {
|
|
119
|
+
return axios.patch(url, config.data, options);
|
|
120
|
+
}
|
|
121
|
+
else if (method?.toUpperCase() === 'PUT') {
|
|
122
|
+
return axios.put(url, config.data, options);
|
|
123
|
+
}
|
|
124
|
+
else if (method?.toUpperCase() === 'DELETE') {
|
|
125
|
+
return axios.delete(url, options);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return axios.get(url, options);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async get(config) {
|
|
132
|
+
return this.proxy({
|
|
133
|
+
...config,
|
|
134
|
+
method: 'GET'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async post(config) {
|
|
138
|
+
return this.proxy({
|
|
139
|
+
...config,
|
|
140
|
+
method: 'POST'
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async patch(config) {
|
|
144
|
+
return this.proxy({
|
|
145
|
+
...config,
|
|
146
|
+
method: 'PATCH'
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async delete(config) {
|
|
150
|
+
return this.proxy({
|
|
151
|
+
...config,
|
|
152
|
+
method: 'DELETE'
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async getRecords(config) {
|
|
156
|
+
const { connectionId, providerConfigKey, model, delta, offset, limit } = config;
|
|
157
|
+
validateSyncRecordConfiguration(config);
|
|
158
|
+
const url = `${this.serverUrl}/sync/records/?model=${model}&delta=${delta || ''}&offset=${offset || ''}&limit=${limit || ''}`;
|
|
159
|
+
const headers = {
|
|
160
|
+
'Connection-Id': connectionId,
|
|
161
|
+
'Provider-Config-Key': providerConfigKey
|
|
162
|
+
};
|
|
163
|
+
const options = {
|
|
164
|
+
headers: this.enrichHeaders(headers)
|
|
165
|
+
};
|
|
166
|
+
const response = await axios.get(url, options);
|
|
167
|
+
return response.data;
|
|
168
|
+
}
|
|
169
|
+
async getConnectionDetails(providerConfigKey, connectionId, forceRefresh = false, refreshToken = false, additionalHeader = {}) {
|
|
170
|
+
const url = `${this.serverUrl}/connection/${connectionId}`;
|
|
171
|
+
const headers = {
|
|
172
|
+
'Content-Type': 'application/json',
|
|
173
|
+
'Accept-Encoding': 'application/json'
|
|
174
|
+
};
|
|
175
|
+
if (additionalHeader) {
|
|
176
|
+
Object.assign(headers, additionalHeader);
|
|
177
|
+
}
|
|
178
|
+
const params = {
|
|
179
|
+
provider_config_key: providerConfigKey,
|
|
180
|
+
force_refresh: forceRefresh,
|
|
181
|
+
refresh_token: refreshToken
|
|
182
|
+
};
|
|
183
|
+
return axios.get(url, { params: params, headers: this.enrichHeaders(headers) });
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get the list of Connections, which does not contain access credentials.
|
|
187
|
+
*/
|
|
188
|
+
async listConnections(connectionId) {
|
|
189
|
+
const response = await this.listConnectionDetails(connectionId);
|
|
190
|
+
return response.data;
|
|
191
|
+
}
|
|
192
|
+
async setFieldMapping(fieldMapping, optionalProviderConfigKey, optionalConnectionId) {
|
|
193
|
+
const providerConfigKey = optionalProviderConfigKey || this.providerConfigKey;
|
|
194
|
+
const connectionId = optionalConnectionId || this.connectionId;
|
|
195
|
+
const url = `${this.serverUrl}/connection/${connectionId}/field-mapping?provider_config_key=${providerConfigKey}`;
|
|
196
|
+
const headers = {
|
|
197
|
+
'Provider-Config-Key': providerConfigKey
|
|
198
|
+
};
|
|
199
|
+
return axios.post(url, fieldMapping, { headers: this.enrichHeaders(headers) });
|
|
200
|
+
}
|
|
201
|
+
async getFieldMapping(optionalProviderConfigKey, optionalConnectionId) {
|
|
202
|
+
const providerConfigKey = optionalProviderConfigKey || this.providerConfigKey;
|
|
203
|
+
const connectionId = optionalConnectionId || this.connectionId;
|
|
204
|
+
if (!providerConfigKey) {
|
|
205
|
+
throw new Error('Provider Config Key is required');
|
|
206
|
+
}
|
|
207
|
+
if (!connectionId) {
|
|
208
|
+
throw new Error('Connection Id is required');
|
|
209
|
+
}
|
|
210
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, false, false, {
|
|
211
|
+
'Nango-Is-Sync': true,
|
|
212
|
+
'Nango-Is-Dry-Run': this.dryRun
|
|
213
|
+
});
|
|
214
|
+
return response.data.field_mappings;
|
|
215
|
+
}
|
|
216
|
+
async triggerSync({ connectionId, providerConfigKey }) {
|
|
217
|
+
const url = `${this.serverUrl}/sync/trigger`;
|
|
218
|
+
const headers = {
|
|
219
|
+
'Connection-Id': connectionId,
|
|
220
|
+
'Provider-Config-Key': providerConfigKey
|
|
221
|
+
};
|
|
222
|
+
return axios.post(url, {}, { headers: this.enrichHeaders(headers) });
|
|
223
|
+
}
|
|
224
|
+
async createConnection(connectionArgs) {
|
|
225
|
+
const url = `${this.serverUrl}/connection`;
|
|
226
|
+
const body = connectionArgs;
|
|
227
|
+
return axios.post(url, body, { headers: this.enrichHeaders() });
|
|
228
|
+
}
|
|
229
|
+
async listConnectionDetails(connectionId) {
|
|
230
|
+
let url = `${this.serverUrl}/connection?`;
|
|
231
|
+
if (connectionId) {
|
|
232
|
+
url = url.concat(`connectionId=${connectionId}`);
|
|
233
|
+
}
|
|
234
|
+
const headers = {
|
|
235
|
+
'Content-Type': 'application/json',
|
|
236
|
+
'Accept-Encoding': 'application/json'
|
|
237
|
+
};
|
|
238
|
+
return axios.get(url, { headers: this.enrichHeaders(headers) });
|
|
239
|
+
}
|
|
240
|
+
enrichHeaders(headers = {}) {
|
|
241
|
+
if (this.serverUrl === prodHost || this.serverUrl === stagingHost) {
|
|
242
|
+
headers['Authorization'] = 'Bearer ' + this.secretKey;
|
|
243
|
+
}
|
|
244
|
+
else if (this.secretKey) {
|
|
245
|
+
headers['Authorization'] = 'Basic ' + Buffer.from(this.secretKey + ':').toString('base64');
|
|
246
|
+
}
|
|
247
|
+
return headers;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
3
250
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAGlD,OAAO,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAEzF,MAAM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KAAK,WAAW,EAAE;YAC/D,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;SACzD;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE;YACvB,OAAO,CAAC,eAAe,CAAC,GAAG,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC9F;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
1
|
+
import type { ParamsSerializerOptions } from 'axios';
|
|
2
|
+
export declare enum AuthModes {
|
|
3
|
+
OAuth1 = "OAUTH1",
|
|
4
|
+
OAuth2 = "OAUTH2"
|
|
5
|
+
}
|
|
6
|
+
export interface CredentialsCommon {
|
|
7
|
+
type: AuthModes;
|
|
8
|
+
raw: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface OAuth1Credentials extends CredentialsCommon {
|
|
11
|
+
type: AuthModes.OAuth1;
|
|
12
|
+
oauth_token: string;
|
|
13
|
+
oauth_token_secret: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OAuth2Credentials extends CredentialsCommon {
|
|
16
|
+
type: AuthModes.OAuth2;
|
|
17
|
+
access_token: string;
|
|
18
|
+
refresh_token?: string;
|
|
19
|
+
expires_at?: Date | undefined;
|
|
20
|
+
}
|
|
1
21
|
export interface ProxyConfiguration {
|
|
2
|
-
[key: string]: any;
|
|
3
22
|
endpoint: string;
|
|
4
|
-
providerConfigKey
|
|
5
|
-
connectionId
|
|
23
|
+
providerConfigKey?: string;
|
|
24
|
+
connectionId?: string;
|
|
6
25
|
method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'get' | 'post' | 'patch' | 'put' | 'delete';
|
|
7
26
|
headers?: Record<string, string>;
|
|
8
27
|
params?: string | Record<string, string>;
|
|
9
|
-
paramsSerializer?:
|
|
10
|
-
encode?: (param: string) => string;
|
|
11
|
-
serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions) => void;
|
|
12
|
-
indexes?: boolean;
|
|
13
|
-
};
|
|
28
|
+
paramsSerializer?: ParamsSerializerOptions;
|
|
14
29
|
data?: unknown;
|
|
15
30
|
retries?: number;
|
|
31
|
+
baseUrlOverride?: string;
|
|
16
32
|
}
|
|
17
|
-
interface
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
interface CustomParamsSerializer {
|
|
25
|
-
(params: Record<string, any>, options?: ParamsSerializerOptions): string;
|
|
33
|
+
export interface GetRecordsRequestConfig {
|
|
34
|
+
providerConfigKey: string;
|
|
35
|
+
connectionId: string;
|
|
36
|
+
model: string;
|
|
37
|
+
delta?: string;
|
|
38
|
+
offset?: number;
|
|
39
|
+
limit?: number;
|
|
26
40
|
}
|
|
27
|
-
export {};
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACrB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { ProxyConfiguration } from './types';
|
|
1
|
+
import type { ProxyConfiguration, GetRecordsRequestConfig } from './types.js';
|
|
2
2
|
export declare const validateProxyConfiguration: (config: ProxyConfiguration) => void;
|
|
3
|
+
export declare const validateSyncRecordConfiguration: (config: GetRecordsRequestConfig) => void;
|
package/dist/utils.js
CHANGED
|
@@ -6,4 +6,12 @@ export const validateProxyConfiguration = (config) => {
|
|
|
6
6
|
}
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
+
export const validateSyncRecordConfiguration = (config) => {
|
|
10
|
+
const requiredParams = ['model', 'providerConfigKey', 'connectionId'];
|
|
11
|
+
requiredParams.forEach((param) => {
|
|
12
|
+
if (typeof config[param] === 'undefined') {
|
|
13
|
+
throw new Error(`${param} is missing and is required to make a proxy call!`);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
9
17
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAA0B,EAAE,EAAE;IACrE,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAA0B,EAAE,EAAE;IACrE,MAAM,cAAc,GAAoC,CAAC,UAAU,EAAE,mBAAmB,EAAE,cAAc,CAAC,CAAC;IAE1G,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7B,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,mDAAmD,CAAC,CAAC;SAChF;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,MAA+B,EAAE,EAAE;IAC/E,MAAM,cAAc,GAAyC,CAAC,OAAO,EAAE,mBAAmB,EAAE,cAAc,CAAC,CAAC;IAE5G,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7B,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,mDAAmD,CAAC,CAAC;SAChF;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nangohq/node",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.141-beta",
|
|
4
4
|
"description": "Nango's Node client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nangohq/shared": "0.21.13",
|
|
17
16
|
"axios": "^1.2.0"
|
|
18
17
|
},
|
|
19
18
|
"engines": {
|