@nangohq/node 0.29.4 → 0.29.5-beta.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.
- package/dist/index.cjs +372 -0
- package/dist/index.js +312 -293
- package/package.json +14 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js +0 -8
- package/dist/types.js.map +0 -1
- package/dist/utils.js +0 -17
- package/dist/utils.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// lib/index.ts
|
|
31
|
+
var lib_exports = {};
|
|
32
|
+
__export(lib_exports, {
|
|
33
|
+
Nango: () => Nango,
|
|
34
|
+
SyncType: () => SyncType,
|
|
35
|
+
prodHost: () => prodHost,
|
|
36
|
+
stagingHost: () => stagingHost
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(lib_exports);
|
|
39
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
40
|
+
|
|
41
|
+
// lib/utils.ts
|
|
42
|
+
var validateProxyConfiguration = (config) => {
|
|
43
|
+
const requiredParams = ["endpoint", "providerConfigKey", "connectionId"];
|
|
44
|
+
requiredParams.forEach((param) => {
|
|
45
|
+
if (typeof config[param] === "undefined") {
|
|
46
|
+
throw new Error(`${param} is missing and is required to make a proxy call!`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var validateSyncRecordConfiguration = (config) => {
|
|
51
|
+
const requiredParams = ["model", "providerConfigKey", "connectionId"];
|
|
52
|
+
requiredParams.forEach((param) => {
|
|
53
|
+
if (typeof config[param] === "undefined") {
|
|
54
|
+
throw new Error(`${param} is missing and is required to make a proxy call!`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// lib/index.ts
|
|
60
|
+
var stagingHost = "https://api-staging.nango.dev";
|
|
61
|
+
var prodHost = "https://api.nango.dev";
|
|
62
|
+
var SyncType = /* @__PURE__ */ ((SyncType2) => {
|
|
63
|
+
SyncType2["INITIAL"] = "INITIAL";
|
|
64
|
+
SyncType2["INCREMENTAL"] = "INCREMENTAL";
|
|
65
|
+
return SyncType2;
|
|
66
|
+
})(SyncType || {});
|
|
67
|
+
var Nango = class {
|
|
68
|
+
serverUrl;
|
|
69
|
+
secretKey;
|
|
70
|
+
connectionId;
|
|
71
|
+
providerConfigKey;
|
|
72
|
+
isSync = false;
|
|
73
|
+
dryRun = false;
|
|
74
|
+
activityLogId;
|
|
75
|
+
constructor(config) {
|
|
76
|
+
config.host = config.host || prodHost;
|
|
77
|
+
this.serverUrl = config.host;
|
|
78
|
+
if (this.serverUrl.slice(-1) === "/") {
|
|
79
|
+
this.serverUrl = this.serverUrl.slice(0, -1);
|
|
80
|
+
}
|
|
81
|
+
if (!config.secretKey) {
|
|
82
|
+
throw new Error("You must specify a secret key (cf. documentation).");
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
new URL(this.serverUrl);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
throw new Error(`Invalid URL provided for the Nango host: ${this.serverUrl}`);
|
|
88
|
+
}
|
|
89
|
+
this.secretKey = config.secretKey;
|
|
90
|
+
this.connectionId = config.connectionId || "";
|
|
91
|
+
this.providerConfigKey = config.providerConfigKey || "";
|
|
92
|
+
if (config.isSync) {
|
|
93
|
+
this.isSync = config.isSync;
|
|
94
|
+
}
|
|
95
|
+
if (config.dryRun) {
|
|
96
|
+
this.dryRun = config.dryRun;
|
|
97
|
+
}
|
|
98
|
+
if (config.activityLogId) {
|
|
99
|
+
this.activityLogId = config.activityLogId;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* For OAuth 2: returns the access token directly as a string.
|
|
104
|
+
* For OAuth 2: If you want to obtain a new refresh token from the provider before the current token has expired,
|
|
105
|
+
* you can set the forceRefresh argument to true."
|
|
106
|
+
* For OAuth 1: returns an object with 'oAuthToken' and 'oAuthTokenSecret' fields.
|
|
107
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
108
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
109
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
110
|
+
* you can set the forceRefresh argument to true.
|
|
111
|
+
* */
|
|
112
|
+
async getToken(providerConfigKey, connectionId, forceRefresh) {
|
|
113
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
114
|
+
switch (response.data.credentials.type) {
|
|
115
|
+
case "OAUTH2" /* OAuth2 */:
|
|
116
|
+
return response.data.credentials.access_token;
|
|
117
|
+
case "OAUTH1" /* OAuth1 */:
|
|
118
|
+
return { oAuthToken: response.data.credentials.oauth_token, oAuthTokenSecret: response.data.credentials.oauth_token_secret };
|
|
119
|
+
default:
|
|
120
|
+
return response.data.credentials;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the full (fresh) credentials payload returned by the external API,
|
|
125
|
+
* which also contains access credentials.
|
|
126
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
127
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
128
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
129
|
+
* you can set the forceRefresh argument to true.
|
|
130
|
+
* */
|
|
131
|
+
async getRawTokenResponse(providerConfigKey, connectionId, forceRefresh) {
|
|
132
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
133
|
+
const credentials = response.data.credentials;
|
|
134
|
+
return credentials.raw;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get the Connection object, which also contains access credentials and full credentials payload
|
|
138
|
+
* returned by the external API.
|
|
139
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
140
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
141
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
142
|
+
* you can set the forceRefresh argument to true.
|
|
143
|
+
* @param [refreshToken] - When set this returns the refresh token as part of the response
|
|
144
|
+
*/
|
|
145
|
+
async getConnection(providerConfigKey, connectionId, forceRefresh, refreshToken) {
|
|
146
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh, refreshToken);
|
|
147
|
+
return response.data;
|
|
148
|
+
}
|
|
149
|
+
async proxy(config) {
|
|
150
|
+
if (!config.connectionId && this.connectionId) {
|
|
151
|
+
config.connectionId = this.connectionId;
|
|
152
|
+
}
|
|
153
|
+
if (!config.providerConfigKey && this.providerConfigKey) {
|
|
154
|
+
config.providerConfigKey = this.providerConfigKey;
|
|
155
|
+
}
|
|
156
|
+
validateProxyConfiguration(config);
|
|
157
|
+
const { providerConfigKey, connectionId, method, retries, headers: customHeaders, baseUrlOverride } = config;
|
|
158
|
+
const url = `${this.serverUrl}/proxy${config.endpoint[0] === "/" ? "" : "/"}${config.endpoint}`;
|
|
159
|
+
const customPrefixedHeaders = customHeaders && Object.keys(customHeaders).length > 0 ? Object.keys(customHeaders).reduce((acc, key) => {
|
|
160
|
+
acc[`Nango-Proxy-${key}`] = customHeaders[key];
|
|
161
|
+
return acc;
|
|
162
|
+
}, {}) : {};
|
|
163
|
+
const headers = {
|
|
164
|
+
"Connection-Id": connectionId,
|
|
165
|
+
"Provider-Config-Key": providerConfigKey,
|
|
166
|
+
"Base-Url-Override": baseUrlOverride || "",
|
|
167
|
+
"Nango-Is-Sync": this.isSync,
|
|
168
|
+
"Nango-Is-Dry-Run": this.dryRun,
|
|
169
|
+
"Nango-Activity-Log-Id": this.activityLogId || "",
|
|
170
|
+
...customPrefixedHeaders
|
|
171
|
+
};
|
|
172
|
+
if (retries) {
|
|
173
|
+
headers["Retries"] = retries;
|
|
174
|
+
}
|
|
175
|
+
const options = {
|
|
176
|
+
headers: this.enrichHeaders(headers)
|
|
177
|
+
};
|
|
178
|
+
if (config.params) {
|
|
179
|
+
options.params = config.params;
|
|
180
|
+
}
|
|
181
|
+
if (config.paramsSerializer) {
|
|
182
|
+
options.paramsSerializer = config.paramsSerializer;
|
|
183
|
+
}
|
|
184
|
+
if (this.dryRun) {
|
|
185
|
+
console.log(`Nango Proxy Request: ${method?.toUpperCase()} ${url}`);
|
|
186
|
+
}
|
|
187
|
+
if (method?.toUpperCase() === "POST") {
|
|
188
|
+
return import_axios.default.post(url, config.data, options);
|
|
189
|
+
} else if (method?.toUpperCase() === "PATCH") {
|
|
190
|
+
return import_axios.default.patch(url, config.data, options);
|
|
191
|
+
} else if (method?.toUpperCase() === "PUT") {
|
|
192
|
+
return import_axios.default.put(url, config.data, options);
|
|
193
|
+
} else if (method?.toUpperCase() === "DELETE") {
|
|
194
|
+
return import_axios.default.delete(url, options);
|
|
195
|
+
} else {
|
|
196
|
+
return import_axios.default.get(url, options);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async get(config) {
|
|
200
|
+
return this.proxy({
|
|
201
|
+
...config,
|
|
202
|
+
method: "GET"
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
async post(config) {
|
|
206
|
+
return this.proxy({
|
|
207
|
+
...config,
|
|
208
|
+
method: "POST"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async patch(config) {
|
|
212
|
+
return this.proxy({
|
|
213
|
+
...config,
|
|
214
|
+
method: "PATCH"
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
async delete(config) {
|
|
218
|
+
return this.proxy({
|
|
219
|
+
...config,
|
|
220
|
+
method: "DELETE"
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async getRecords(config) {
|
|
224
|
+
const { connectionId, providerConfigKey, model, delta, offset, limit, includeNangoMetadata } = config;
|
|
225
|
+
validateSyncRecordConfiguration(config);
|
|
226
|
+
const order = config?.order === "asc" ? "asc" : "desc";
|
|
227
|
+
let sortBy = "id";
|
|
228
|
+
switch (config.sortBy) {
|
|
229
|
+
case "createdAt":
|
|
230
|
+
sortBy = "created_at";
|
|
231
|
+
break;
|
|
232
|
+
case "updatedAt":
|
|
233
|
+
sortBy = "updated_at";
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
let filter = "";
|
|
237
|
+
switch (config.filter) {
|
|
238
|
+
case "deleted":
|
|
239
|
+
filter = "deleted";
|
|
240
|
+
break;
|
|
241
|
+
case "updated":
|
|
242
|
+
filter = "updated";
|
|
243
|
+
break;
|
|
244
|
+
case "added":
|
|
245
|
+
filter = "added";
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
const includeMetadata = includeNangoMetadata || false;
|
|
249
|
+
const url = `${this.serverUrl}/sync/records/?model=${model}&order=${order}&delta=${delta || ""}&offset=${offset || ""}&limit=${limit || ""}&sort_by=${sortBy || ""}&include_nango_metadata=${includeMetadata}&filter=${filter}`;
|
|
250
|
+
const headers = {
|
|
251
|
+
"Connection-Id": connectionId,
|
|
252
|
+
"Provider-Config-Key": providerConfigKey
|
|
253
|
+
};
|
|
254
|
+
const options = {
|
|
255
|
+
headers: this.enrichHeaders(headers)
|
|
256
|
+
};
|
|
257
|
+
const response = await import_axios.default.get(url, options);
|
|
258
|
+
return response.data;
|
|
259
|
+
}
|
|
260
|
+
async getConnectionDetails(providerConfigKey, connectionId, forceRefresh = false, refreshToken = false, additionalHeader = {}) {
|
|
261
|
+
const url = `${this.serverUrl}/connection/${connectionId}`;
|
|
262
|
+
const headers = {
|
|
263
|
+
"Content-Type": "application/json",
|
|
264
|
+
"Accept-Encoding": "application/json"
|
|
265
|
+
};
|
|
266
|
+
if (additionalHeader) {
|
|
267
|
+
Object.assign(headers, additionalHeader);
|
|
268
|
+
}
|
|
269
|
+
const params = {
|
|
270
|
+
provider_config_key: providerConfigKey,
|
|
271
|
+
force_refresh: forceRefresh,
|
|
272
|
+
refresh_token: refreshToken
|
|
273
|
+
};
|
|
274
|
+
return import_axios.default.get(url, { params, headers: this.enrichHeaders(headers) });
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get the list of Connections, which does not contain access credentials.
|
|
278
|
+
*/
|
|
279
|
+
async listConnections(connectionId) {
|
|
280
|
+
const response = await this.listConnectionDetails(connectionId);
|
|
281
|
+
return response.data;
|
|
282
|
+
}
|
|
283
|
+
async getIntegration(providerConfigKey, includeIntegrationCredetials = false) {
|
|
284
|
+
const url = `${this.serverUrl}/config/${providerConfigKey}`;
|
|
285
|
+
const response = await import_axios.default.get(url, { headers: this.enrichHeaders({}), params: { include_creds: includeIntegrationCredetials } });
|
|
286
|
+
return response.data;
|
|
287
|
+
}
|
|
288
|
+
async setMetadata(providerConfigKey, connectionId, metadata) {
|
|
289
|
+
if (!providerConfigKey) {
|
|
290
|
+
throw new Error("Provider Config Key is required");
|
|
291
|
+
}
|
|
292
|
+
if (!connectionId) {
|
|
293
|
+
throw new Error("Connection Id is required");
|
|
294
|
+
}
|
|
295
|
+
if (!metadata) {
|
|
296
|
+
throw new Error("Metadata is required");
|
|
297
|
+
}
|
|
298
|
+
const url = `${this.serverUrl}/connection/${connectionId}/metadata?provider_config_key=${providerConfigKey}`;
|
|
299
|
+
const headers = {
|
|
300
|
+
"Provider-Config-Key": providerConfigKey
|
|
301
|
+
};
|
|
302
|
+
return import_axios.default.post(url, metadata, { headers: this.enrichHeaders(headers) });
|
|
303
|
+
}
|
|
304
|
+
async setFieldMapping(_fieldMapping, _optionalProviderConfigKey, _optionalConnectionId) {
|
|
305
|
+
throw new Error("setFieldMapping is deprecated. Please use setMetadata instead.");
|
|
306
|
+
}
|
|
307
|
+
async getMetadata(providerConfigKey, connectionId) {
|
|
308
|
+
if (!providerConfigKey) {
|
|
309
|
+
throw new Error("Provider Config Key is required");
|
|
310
|
+
}
|
|
311
|
+
if (!connectionId) {
|
|
312
|
+
throw new Error("Connection Id is required");
|
|
313
|
+
}
|
|
314
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, false, false, {
|
|
315
|
+
"Nango-Is-Sync": true,
|
|
316
|
+
"Nango-Is-Dry-Run": this.dryRun
|
|
317
|
+
});
|
|
318
|
+
return response.data.metadata;
|
|
319
|
+
}
|
|
320
|
+
async getFieldMapping(_optionalProviderConfigKey, _optionalConnectionId) {
|
|
321
|
+
throw new Error("getFieldMapping is deprecated. Please use getMetadata instead.");
|
|
322
|
+
}
|
|
323
|
+
async triggerSync(providerConfigKey, connectionId, syncs) {
|
|
324
|
+
const url = `${this.serverUrl}/sync/trigger`;
|
|
325
|
+
const headers = {
|
|
326
|
+
"Connection-Id": connectionId,
|
|
327
|
+
"Provider-Config-Key": providerConfigKey
|
|
328
|
+
};
|
|
329
|
+
if (typeof syncs === "string") {
|
|
330
|
+
throw new Error("Syncs must be an array of strings. If it is a single sync, please wrap it in an array.");
|
|
331
|
+
}
|
|
332
|
+
const body = {
|
|
333
|
+
syncs: syncs || []
|
|
334
|
+
};
|
|
335
|
+
return import_axios.default.post(url, body, { headers: this.enrichHeaders(headers) });
|
|
336
|
+
}
|
|
337
|
+
async createConnection(_connectionArgs) {
|
|
338
|
+
throw new Error(
|
|
339
|
+
"This method has been deprecated, please use the REST API to create a connection. See https://docs.nango.dev/api-reference/connection/post"
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
async deleteConnection(providerConfigKey, connectionId) {
|
|
343
|
+
const url = `${this.serverUrl}/connection/${connectionId}?provider_config_key=${providerConfigKey}`;
|
|
344
|
+
const headers = {
|
|
345
|
+
"Content-Type": "application/json",
|
|
346
|
+
"Accept-Encoding": "application/json"
|
|
347
|
+
};
|
|
348
|
+
return import_axios.default.delete(url, { headers: this.enrichHeaders(headers) });
|
|
349
|
+
}
|
|
350
|
+
async listConnectionDetails(connectionId) {
|
|
351
|
+
let url = `${this.serverUrl}/connection?`;
|
|
352
|
+
if (connectionId) {
|
|
353
|
+
url = url.concat(`connectionId=${connectionId}`);
|
|
354
|
+
}
|
|
355
|
+
const headers = {
|
|
356
|
+
"Content-Type": "application/json",
|
|
357
|
+
"Accept-Encoding": "application/json"
|
|
358
|
+
};
|
|
359
|
+
return import_axios.default.get(url, { headers: this.enrichHeaders(headers) });
|
|
360
|
+
}
|
|
361
|
+
enrichHeaders(headers = {}) {
|
|
362
|
+
headers["Authorization"] = "Bearer " + this.secretKey;
|
|
363
|
+
return headers;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
367
|
+
0 && (module.exports = {
|
|
368
|
+
Nango,
|
|
369
|
+
SyncType,
|
|
370
|
+
prodHost,
|
|
371
|
+
stagingHost
|
|
372
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,315 +1,334 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(SyncType || (SyncType = {}));
|
|
11
|
-
export class Nango {
|
|
12
|
-
serverUrl;
|
|
13
|
-
secretKey;
|
|
14
|
-
connectionId;
|
|
15
|
-
providerConfigKey;
|
|
16
|
-
isSync = false;
|
|
17
|
-
dryRun = false;
|
|
18
|
-
activityLogId;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
config.host = config.host || prodHost;
|
|
21
|
-
this.serverUrl = config.host;
|
|
22
|
-
if (this.serverUrl.slice(-1) === '/') {
|
|
23
|
-
this.serverUrl = this.serverUrl.slice(0, -1);
|
|
24
|
-
}
|
|
25
|
-
if (!config.secretKey) {
|
|
26
|
-
throw new Error('You must specify a secret key (cf. documentation).');
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
new URL(this.serverUrl);
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
throw new Error(`Invalid URL provided for the Nango host: ${this.serverUrl}`);
|
|
33
|
-
}
|
|
34
|
-
this.secretKey = config.secretKey;
|
|
35
|
-
this.connectionId = config.connectionId || '';
|
|
36
|
-
this.providerConfigKey = config.providerConfigKey || '';
|
|
37
|
-
if (config.isSync) {
|
|
38
|
-
this.isSync = config.isSync;
|
|
39
|
-
}
|
|
40
|
-
if (config.dryRun) {
|
|
41
|
-
this.dryRun = config.dryRun;
|
|
42
|
-
}
|
|
43
|
-
if (config.activityLogId) {
|
|
44
|
-
this.activityLogId = config.activityLogId;
|
|
45
|
-
}
|
|
1
|
+
// lib/index.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
// lib/utils.ts
|
|
5
|
+
var validateProxyConfiguration = (config) => {
|
|
6
|
+
const requiredParams = ["endpoint", "providerConfigKey", "connectionId"];
|
|
7
|
+
requiredParams.forEach((param) => {
|
|
8
|
+
if (typeof config[param] === "undefined") {
|
|
9
|
+
throw new Error(`${param} is missing and is required to make a proxy call!`);
|
|
46
10
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
55
|
-
* you can set the forceRefresh argument to true.
|
|
56
|
-
* */
|
|
57
|
-
async getToken(providerConfigKey, connectionId, forceRefresh) {
|
|
58
|
-
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
59
|
-
switch (response.data.credentials.type) {
|
|
60
|
-
case AuthModes.OAuth2:
|
|
61
|
-
return response.data.credentials.access_token;
|
|
62
|
-
case AuthModes.OAuth1:
|
|
63
|
-
return { oAuthToken: response.data.credentials.oauth_token, oAuthTokenSecret: response.data.credentials.oauth_token_secret };
|
|
64
|
-
default:
|
|
65
|
-
return response.data.credentials;
|
|
66
|
-
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var validateSyncRecordConfiguration = (config) => {
|
|
14
|
+
const requiredParams = ["model", "providerConfigKey", "connectionId"];
|
|
15
|
+
requiredParams.forEach((param) => {
|
|
16
|
+
if (typeof config[param] === "undefined") {
|
|
17
|
+
throw new Error(`${param} is missing and is required to make a proxy call!`);
|
|
67
18
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// lib/index.ts
|
|
23
|
+
var stagingHost = "https://api-staging.nango.dev";
|
|
24
|
+
var prodHost = "https://api.nango.dev";
|
|
25
|
+
var SyncType = /* @__PURE__ */ ((SyncType2) => {
|
|
26
|
+
SyncType2["INITIAL"] = "INITIAL";
|
|
27
|
+
SyncType2["INCREMENTAL"] = "INCREMENTAL";
|
|
28
|
+
return SyncType2;
|
|
29
|
+
})(SyncType || {});
|
|
30
|
+
var Nango = class {
|
|
31
|
+
serverUrl;
|
|
32
|
+
secretKey;
|
|
33
|
+
connectionId;
|
|
34
|
+
providerConfigKey;
|
|
35
|
+
isSync = false;
|
|
36
|
+
dryRun = false;
|
|
37
|
+
activityLogId;
|
|
38
|
+
constructor(config) {
|
|
39
|
+
config.host = config.host || prodHost;
|
|
40
|
+
this.serverUrl = config.host;
|
|
41
|
+
if (this.serverUrl.slice(-1) === "/") {
|
|
42
|
+
this.serverUrl = this.serverUrl.slice(0, -1);
|
|
80
43
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* returned by the external API.
|
|
84
|
-
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
85
|
-
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
86
|
-
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
87
|
-
* you can set the forceRefresh argument to true.
|
|
88
|
-
* @param [refreshToken] - When set this returns the refresh token as part of the response
|
|
89
|
-
*/
|
|
90
|
-
async getConnection(providerConfigKey, connectionId, forceRefresh, refreshToken) {
|
|
91
|
-
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh, refreshToken);
|
|
92
|
-
return response.data;
|
|
44
|
+
if (!config.secretKey) {
|
|
45
|
+
throw new Error("You must specify a secret key (cf. documentation).");
|
|
93
46
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!config.providerConfigKey && this.providerConfigKey) {
|
|
99
|
-
config.providerConfigKey = this.providerConfigKey;
|
|
100
|
-
}
|
|
101
|
-
validateProxyConfiguration(config);
|
|
102
|
-
const { providerConfigKey, connectionId, method, retries, headers: customHeaders, baseUrlOverride } = config;
|
|
103
|
-
const url = `${this.serverUrl}/proxy${config.endpoint[0] === '/' ? '' : '/'}${config.endpoint}`;
|
|
104
|
-
const customPrefixedHeaders = customHeaders && Object.keys(customHeaders).length > 0
|
|
105
|
-
? Object.keys(customHeaders).reduce((acc, key) => {
|
|
106
|
-
acc[`Nango-Proxy-${key}`] = customHeaders[key];
|
|
107
|
-
return acc;
|
|
108
|
-
}, {})
|
|
109
|
-
: {};
|
|
110
|
-
const headers = {
|
|
111
|
-
'Connection-Id': connectionId,
|
|
112
|
-
'Provider-Config-Key': providerConfigKey,
|
|
113
|
-
'Base-Url-Override': baseUrlOverride || '',
|
|
114
|
-
'Nango-Is-Sync': this.isSync,
|
|
115
|
-
'Nango-Is-Dry-Run': this.dryRun,
|
|
116
|
-
'Nango-Activity-Log-Id': this.activityLogId || '',
|
|
117
|
-
...customPrefixedHeaders
|
|
118
|
-
};
|
|
119
|
-
if (retries) {
|
|
120
|
-
headers['Retries'] = retries;
|
|
121
|
-
}
|
|
122
|
-
const options = {
|
|
123
|
-
headers: this.enrichHeaders(headers)
|
|
124
|
-
};
|
|
125
|
-
if (config.params) {
|
|
126
|
-
options.params = config.params;
|
|
127
|
-
}
|
|
128
|
-
if (config.paramsSerializer) {
|
|
129
|
-
options.paramsSerializer = config.paramsSerializer;
|
|
130
|
-
}
|
|
131
|
-
if (this.dryRun) {
|
|
132
|
-
console.log(`Nango Proxy Request: ${method?.toUpperCase()} ${url}`);
|
|
133
|
-
}
|
|
134
|
-
if (method?.toUpperCase() === 'POST') {
|
|
135
|
-
return axios.post(url, config.data, options);
|
|
136
|
-
}
|
|
137
|
-
else if (method?.toUpperCase() === 'PATCH') {
|
|
138
|
-
return axios.patch(url, config.data, options);
|
|
139
|
-
}
|
|
140
|
-
else if (method?.toUpperCase() === 'PUT') {
|
|
141
|
-
return axios.put(url, config.data, options);
|
|
142
|
-
}
|
|
143
|
-
else if (method?.toUpperCase() === 'DELETE') {
|
|
144
|
-
return axios.delete(url, options);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
return axios.get(url, options);
|
|
148
|
-
}
|
|
47
|
+
try {
|
|
48
|
+
new URL(this.serverUrl);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
throw new Error(`Invalid URL provided for the Nango host: ${this.serverUrl}`);
|
|
149
51
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
52
|
+
this.secretKey = config.secretKey;
|
|
53
|
+
this.connectionId = config.connectionId || "";
|
|
54
|
+
this.providerConfigKey = config.providerConfigKey || "";
|
|
55
|
+
if (config.isSync) {
|
|
56
|
+
this.isSync = config.isSync;
|
|
155
57
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
...config,
|
|
159
|
-
method: 'POST'
|
|
160
|
-
});
|
|
58
|
+
if (config.dryRun) {
|
|
59
|
+
this.dryRun = config.dryRun;
|
|
161
60
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
...config,
|
|
165
|
-
method: 'PATCH'
|
|
166
|
-
});
|
|
61
|
+
if (config.activityLogId) {
|
|
62
|
+
this.activityLogId = config.activityLogId;
|
|
167
63
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* For OAuth 2: returns the access token directly as a string.
|
|
67
|
+
* For OAuth 2: If you want to obtain a new refresh token from the provider before the current token has expired,
|
|
68
|
+
* you can set the forceRefresh argument to true."
|
|
69
|
+
* For OAuth 1: returns an object with 'oAuthToken' and 'oAuthTokenSecret' fields.
|
|
70
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
71
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
72
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
73
|
+
* you can set the forceRefresh argument to true.
|
|
74
|
+
* */
|
|
75
|
+
async getToken(providerConfigKey, connectionId, forceRefresh) {
|
|
76
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
77
|
+
switch (response.data.credentials.type) {
|
|
78
|
+
case "OAUTH2" /* OAuth2 */:
|
|
79
|
+
return response.data.credentials.access_token;
|
|
80
|
+
case "OAUTH1" /* OAuth1 */:
|
|
81
|
+
return { oAuthToken: response.data.credentials.oauth_token, oAuthTokenSecret: response.data.credentials.oauth_token_secret };
|
|
82
|
+
default:
|
|
83
|
+
return response.data.credentials;
|
|
173
84
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
const options = {
|
|
206
|
-
headers: this.enrichHeaders(headers)
|
|
207
|
-
};
|
|
208
|
-
const response = await axios.get(url, options);
|
|
209
|
-
return response.data;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the full (fresh) credentials payload returned by the external API,
|
|
88
|
+
* which also contains access credentials.
|
|
89
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
90
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
91
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
92
|
+
* you can set the forceRefresh argument to true.
|
|
93
|
+
* */
|
|
94
|
+
async getRawTokenResponse(providerConfigKey, connectionId, forceRefresh) {
|
|
95
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
|
|
96
|
+
const credentials = response.data.credentials;
|
|
97
|
+
return credentials.raw;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the Connection object, which also contains access credentials and full credentials payload
|
|
101
|
+
* returned by the external API.
|
|
102
|
+
* @param providerConfigKey - This is the unique Config Key for the integration
|
|
103
|
+
* @param connectionId - This is the unique connection identifier used to identify this connection
|
|
104
|
+
* @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
|
|
105
|
+
* you can set the forceRefresh argument to true.
|
|
106
|
+
* @param [refreshToken] - When set this returns the refresh token as part of the response
|
|
107
|
+
*/
|
|
108
|
+
async getConnection(providerConfigKey, connectionId, forceRefresh, refreshToken) {
|
|
109
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh, refreshToken);
|
|
110
|
+
return response.data;
|
|
111
|
+
}
|
|
112
|
+
async proxy(config) {
|
|
113
|
+
if (!config.connectionId && this.connectionId) {
|
|
114
|
+
config.connectionId = this.connectionId;
|
|
210
115
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const headers = {
|
|
214
|
-
'Content-Type': 'application/json',
|
|
215
|
-
'Accept-Encoding': 'application/json'
|
|
216
|
-
};
|
|
217
|
-
if (additionalHeader) {
|
|
218
|
-
Object.assign(headers, additionalHeader);
|
|
219
|
-
}
|
|
220
|
-
const params = {
|
|
221
|
-
provider_config_key: providerConfigKey,
|
|
222
|
-
force_refresh: forceRefresh,
|
|
223
|
-
refresh_token: refreshToken
|
|
224
|
-
};
|
|
225
|
-
return axios.get(url, { params: params, headers: this.enrichHeaders(headers) });
|
|
116
|
+
if (!config.providerConfigKey && this.providerConfigKey) {
|
|
117
|
+
config.providerConfigKey = this.providerConfigKey;
|
|
226
118
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
119
|
+
validateProxyConfiguration(config);
|
|
120
|
+
const { providerConfigKey, connectionId, method, retries, headers: customHeaders, baseUrlOverride } = config;
|
|
121
|
+
const url = `${this.serverUrl}/proxy${config.endpoint[0] === "/" ? "" : "/"}${config.endpoint}`;
|
|
122
|
+
const customPrefixedHeaders = customHeaders && Object.keys(customHeaders).length > 0 ? Object.keys(customHeaders).reduce((acc, key) => {
|
|
123
|
+
acc[`Nango-Proxy-${key}`] = customHeaders[key];
|
|
124
|
+
return acc;
|
|
125
|
+
}, {}) : {};
|
|
126
|
+
const headers = {
|
|
127
|
+
"Connection-Id": connectionId,
|
|
128
|
+
"Provider-Config-Key": providerConfigKey,
|
|
129
|
+
"Base-Url-Override": baseUrlOverride || "",
|
|
130
|
+
"Nango-Is-Sync": this.isSync,
|
|
131
|
+
"Nango-Is-Dry-Run": this.dryRun,
|
|
132
|
+
"Nango-Activity-Log-Id": this.activityLogId || "",
|
|
133
|
+
...customPrefixedHeaders
|
|
134
|
+
};
|
|
135
|
+
if (retries) {
|
|
136
|
+
headers["Retries"] = retries;
|
|
233
137
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
138
|
+
const options = {
|
|
139
|
+
headers: this.enrichHeaders(headers)
|
|
140
|
+
};
|
|
141
|
+
if (config.params) {
|
|
142
|
+
options.params = config.params;
|
|
238
143
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
throw new Error('Provider Config Key is required');
|
|
242
|
-
}
|
|
243
|
-
if (!connectionId) {
|
|
244
|
-
throw new Error('Connection Id is required');
|
|
245
|
-
}
|
|
246
|
-
if (!metadata) {
|
|
247
|
-
throw new Error('Metadata is required');
|
|
248
|
-
}
|
|
249
|
-
const url = `${this.serverUrl}/connection/${connectionId}/metadata?provider_config_key=${providerConfigKey}`;
|
|
250
|
-
const headers = {
|
|
251
|
-
'Provider-Config-Key': providerConfigKey
|
|
252
|
-
};
|
|
253
|
-
return axios.post(url, metadata, { headers: this.enrichHeaders(headers) });
|
|
144
|
+
if (config.paramsSerializer) {
|
|
145
|
+
options.paramsSerializer = config.paramsSerializer;
|
|
254
146
|
}
|
|
255
|
-
|
|
256
|
-
|
|
147
|
+
if (this.dryRun) {
|
|
148
|
+
console.log(`Nango Proxy Request: ${method?.toUpperCase()} ${url}`);
|
|
257
149
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
});
|
|
269
|
-
return response.data.metadata;
|
|
150
|
+
if (method?.toUpperCase() === "POST") {
|
|
151
|
+
return axios.post(url, config.data, options);
|
|
152
|
+
} else if (method?.toUpperCase() === "PATCH") {
|
|
153
|
+
return axios.patch(url, config.data, options);
|
|
154
|
+
} else if (method?.toUpperCase() === "PUT") {
|
|
155
|
+
return axios.put(url, config.data, options);
|
|
156
|
+
} else if (method?.toUpperCase() === "DELETE") {
|
|
157
|
+
return axios.delete(url, options);
|
|
158
|
+
} else {
|
|
159
|
+
return axios.get(url, options);
|
|
270
160
|
}
|
|
271
|
-
|
|
272
|
-
|
|
161
|
+
}
|
|
162
|
+
async get(config) {
|
|
163
|
+
return this.proxy({
|
|
164
|
+
...config,
|
|
165
|
+
method: "GET"
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async post(config) {
|
|
169
|
+
return this.proxy({
|
|
170
|
+
...config,
|
|
171
|
+
method: "POST"
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async patch(config) {
|
|
175
|
+
return this.proxy({
|
|
176
|
+
...config,
|
|
177
|
+
method: "PATCH"
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async delete(config) {
|
|
181
|
+
return this.proxy({
|
|
182
|
+
...config,
|
|
183
|
+
method: "DELETE"
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
async getRecords(config) {
|
|
187
|
+
const { connectionId, providerConfigKey, model, delta, offset, limit, includeNangoMetadata } = config;
|
|
188
|
+
validateSyncRecordConfiguration(config);
|
|
189
|
+
const order = config?.order === "asc" ? "asc" : "desc";
|
|
190
|
+
let sortBy = "id";
|
|
191
|
+
switch (config.sortBy) {
|
|
192
|
+
case "createdAt":
|
|
193
|
+
sortBy = "created_at";
|
|
194
|
+
break;
|
|
195
|
+
case "updatedAt":
|
|
196
|
+
sortBy = "updated_at";
|
|
197
|
+
break;
|
|
273
198
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
};
|
|
286
|
-
return axios.post(url, body, { headers: this.enrichHeaders(headers) });
|
|
199
|
+
let filter = "";
|
|
200
|
+
switch (config.filter) {
|
|
201
|
+
case "deleted":
|
|
202
|
+
filter = "deleted";
|
|
203
|
+
break;
|
|
204
|
+
case "updated":
|
|
205
|
+
filter = "updated";
|
|
206
|
+
break;
|
|
207
|
+
case "added":
|
|
208
|
+
filter = "added";
|
|
209
|
+
break;
|
|
287
210
|
}
|
|
288
|
-
|
|
289
|
-
|
|
211
|
+
const includeMetadata = includeNangoMetadata || false;
|
|
212
|
+
const url = `${this.serverUrl}/sync/records/?model=${model}&order=${order}&delta=${delta || ""}&offset=${offset || ""}&limit=${limit || ""}&sort_by=${sortBy || ""}&include_nango_metadata=${includeMetadata}&filter=${filter}`;
|
|
213
|
+
const headers = {
|
|
214
|
+
"Connection-Id": connectionId,
|
|
215
|
+
"Provider-Config-Key": providerConfigKey
|
|
216
|
+
};
|
|
217
|
+
const options = {
|
|
218
|
+
headers: this.enrichHeaders(headers)
|
|
219
|
+
};
|
|
220
|
+
const response = await axios.get(url, options);
|
|
221
|
+
return response.data;
|
|
222
|
+
}
|
|
223
|
+
async getConnectionDetails(providerConfigKey, connectionId, forceRefresh = false, refreshToken = false, additionalHeader = {}) {
|
|
224
|
+
const url = `${this.serverUrl}/connection/${connectionId}`;
|
|
225
|
+
const headers = {
|
|
226
|
+
"Content-Type": "application/json",
|
|
227
|
+
"Accept-Encoding": "application/json"
|
|
228
|
+
};
|
|
229
|
+
if (additionalHeader) {
|
|
230
|
+
Object.assign(headers, additionalHeader);
|
|
290
231
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
232
|
+
const params = {
|
|
233
|
+
provider_config_key: providerConfigKey,
|
|
234
|
+
force_refresh: forceRefresh,
|
|
235
|
+
refresh_token: refreshToken
|
|
236
|
+
};
|
|
237
|
+
return axios.get(url, { params, headers: this.enrichHeaders(headers) });
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get the list of Connections, which does not contain access credentials.
|
|
241
|
+
*/
|
|
242
|
+
async listConnections(connectionId) {
|
|
243
|
+
const response = await this.listConnectionDetails(connectionId);
|
|
244
|
+
return response.data;
|
|
245
|
+
}
|
|
246
|
+
async getIntegration(providerConfigKey, includeIntegrationCredetials = false) {
|
|
247
|
+
const url = `${this.serverUrl}/config/${providerConfigKey}`;
|
|
248
|
+
const response = await axios.get(url, { headers: this.enrichHeaders({}), params: { include_creds: includeIntegrationCredetials } });
|
|
249
|
+
return response.data;
|
|
250
|
+
}
|
|
251
|
+
async setMetadata(providerConfigKey, connectionId, metadata) {
|
|
252
|
+
if (!providerConfigKey) {
|
|
253
|
+
throw new Error("Provider Config Key is required");
|
|
298
254
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (connectionId) {
|
|
302
|
-
url = url.concat(`connectionId=${connectionId}`);
|
|
303
|
-
}
|
|
304
|
-
const headers = {
|
|
305
|
-
'Content-Type': 'application/json',
|
|
306
|
-
'Accept-Encoding': 'application/json'
|
|
307
|
-
};
|
|
308
|
-
return axios.get(url, { headers: this.enrichHeaders(headers) });
|
|
255
|
+
if (!connectionId) {
|
|
256
|
+
throw new Error("Connection Id is required");
|
|
309
257
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
return headers;
|
|
258
|
+
if (!metadata) {
|
|
259
|
+
throw new Error("Metadata is required");
|
|
313
260
|
}
|
|
314
|
-
}
|
|
315
|
-
|
|
261
|
+
const url = `${this.serverUrl}/connection/${connectionId}/metadata?provider_config_key=${providerConfigKey}`;
|
|
262
|
+
const headers = {
|
|
263
|
+
"Provider-Config-Key": providerConfigKey
|
|
264
|
+
};
|
|
265
|
+
return axios.post(url, metadata, { headers: this.enrichHeaders(headers) });
|
|
266
|
+
}
|
|
267
|
+
async setFieldMapping(_fieldMapping, _optionalProviderConfigKey, _optionalConnectionId) {
|
|
268
|
+
throw new Error("setFieldMapping is deprecated. Please use setMetadata instead.");
|
|
269
|
+
}
|
|
270
|
+
async getMetadata(providerConfigKey, connectionId) {
|
|
271
|
+
if (!providerConfigKey) {
|
|
272
|
+
throw new Error("Provider Config Key is required");
|
|
273
|
+
}
|
|
274
|
+
if (!connectionId) {
|
|
275
|
+
throw new Error("Connection Id is required");
|
|
276
|
+
}
|
|
277
|
+
const response = await this.getConnectionDetails(providerConfigKey, connectionId, false, false, {
|
|
278
|
+
"Nango-Is-Sync": true,
|
|
279
|
+
"Nango-Is-Dry-Run": this.dryRun
|
|
280
|
+
});
|
|
281
|
+
return response.data.metadata;
|
|
282
|
+
}
|
|
283
|
+
async getFieldMapping(_optionalProviderConfigKey, _optionalConnectionId) {
|
|
284
|
+
throw new Error("getFieldMapping is deprecated. Please use getMetadata instead.");
|
|
285
|
+
}
|
|
286
|
+
async triggerSync(providerConfigKey, connectionId, syncs) {
|
|
287
|
+
const url = `${this.serverUrl}/sync/trigger`;
|
|
288
|
+
const headers = {
|
|
289
|
+
"Connection-Id": connectionId,
|
|
290
|
+
"Provider-Config-Key": providerConfigKey
|
|
291
|
+
};
|
|
292
|
+
if (typeof syncs === "string") {
|
|
293
|
+
throw new Error("Syncs must be an array of strings. If it is a single sync, please wrap it in an array.");
|
|
294
|
+
}
|
|
295
|
+
const body = {
|
|
296
|
+
syncs: syncs || []
|
|
297
|
+
};
|
|
298
|
+
return axios.post(url, body, { headers: this.enrichHeaders(headers) });
|
|
299
|
+
}
|
|
300
|
+
async createConnection(_connectionArgs) {
|
|
301
|
+
throw new Error(
|
|
302
|
+
"This method has been deprecated, please use the REST API to create a connection. See https://docs.nango.dev/api-reference/connection/post"
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
async deleteConnection(providerConfigKey, connectionId) {
|
|
306
|
+
const url = `${this.serverUrl}/connection/${connectionId}?provider_config_key=${providerConfigKey}`;
|
|
307
|
+
const headers = {
|
|
308
|
+
"Content-Type": "application/json",
|
|
309
|
+
"Accept-Encoding": "application/json"
|
|
310
|
+
};
|
|
311
|
+
return axios.delete(url, { headers: this.enrichHeaders(headers) });
|
|
312
|
+
}
|
|
313
|
+
async listConnectionDetails(connectionId) {
|
|
314
|
+
let url = `${this.serverUrl}/connection?`;
|
|
315
|
+
if (connectionId) {
|
|
316
|
+
url = url.concat(`connectionId=${connectionId}`);
|
|
317
|
+
}
|
|
318
|
+
const headers = {
|
|
319
|
+
"Content-Type": "application/json",
|
|
320
|
+
"Accept-Encoding": "application/json"
|
|
321
|
+
};
|
|
322
|
+
return axios.get(url, { headers: this.enrichHeaders(headers) });
|
|
323
|
+
}
|
|
324
|
+
enrichHeaders(headers = {}) {
|
|
325
|
+
headers["Authorization"] = "Bearer " + this.secretKey;
|
|
326
|
+
return headers;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
export {
|
|
330
|
+
Nango,
|
|
331
|
+
SyncType,
|
|
332
|
+
prodHost,
|
|
333
|
+
stagingHost
|
|
334
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nangohq/node",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.5-beta.0",
|
|
4
4
|
"description": "Nango's Node client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.cjs",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"typings": "dist/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup lib/index.ts --format cjs,esm",
|
|
18
|
+
"watch": "npm run build -- --watch lib",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
8
21
|
"keywords": [],
|
|
9
22
|
"repository": {
|
|
10
23
|
"type": "git",
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAO,EACH,SAAS,EAaZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAEzF,MAAM,CAAC,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAiChD,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAChB,+BAAmB,CAAA;IACnB,uCAA2B,CAAA;AAC/B,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB;AAkBD,MAAM,OAAO,KAAK;IACd,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,YAAY,CAAU;IACtB,iBAAiB,CAAU;IAC3B,MAAM,GAAG,KAAK,CAAC;IACf,MAAM,GAAG,KAAK,CAAC;IACf,aAAa,CAAU;IAEvB,YAAY,MAAkB;QAC1B,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,QAA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GAAG,IAAI,CAAC,SAAS,eAAe,YAAY,wBAAwB,iBAAiB,EAAE,CAAC;QAEpG,MAAM,OAAO,GAAG;YACZ,cAAc,EAAE,kBAAkB;YAClC,iBAAiB,EAAE,kBAAkB;SACxC,CAAC;QAEF,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAC,YAAqB;QACrD,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,cAAc,CAAC;QAC1C,IAAI,YAAY,EAAE;YACd,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC;SACpD;QAED,MAAM,OAAO,GAAG;YACZ,cAAc,EAAE,kBAAkB;YAClC,iBAAiB,EAAE,kBAAkB;SACxC,CAAC;QAEF,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;IAEO,aAAa,CAAC,UAAqD,EAAE;QACzE,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAEtD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,4BAAe,CAAA;IACf,+BAAkB,CAAA;AACtB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB"}
|
package/dist/utils.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const validateProxyConfiguration = (config) => {
|
|
2
|
-
const requiredParams = ['endpoint', 'providerConfigKey', 'connectionId'];
|
|
3
|
-
requiredParams.forEach((param) => {
|
|
4
|
-
if (typeof config[param] === 'undefined') {
|
|
5
|
-
throw new Error(`${param} is missing and is required to make a proxy call!`);
|
|
6
|
-
}
|
|
7
|
-
});
|
|
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
|
-
};
|
|
17
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|