@nangohq/node 0.29.5-beta.0 → 0.29.6

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.js CHANGED
@@ -1,334 +1,315 @@
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!`);
1
+ import axios from 'axios';
2
+ import { AuthModes } from './types.js';
3
+ import { validateProxyConfiguration, validateSyncRecordConfiguration } from './utils.js';
4
+ export const stagingHost = 'https://api-staging.nango.dev';
5
+ export const prodHost = 'https://api.nango.dev';
6
+ export var SyncType;
7
+ (function (SyncType) {
8
+ SyncType["INITIAL"] = "INITIAL";
9
+ SyncType["INCREMENTAL"] = "INCREMENTAL";
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
+ }
10
46
  }
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!`);
47
+ /**
48
+ * For OAuth 2: returns the access token directly as a string.
49
+ * For OAuth 2: If you want to obtain a new refresh token from the provider before the current token has expired,
50
+ * you can set the forceRefresh argument to true."
51
+ * For OAuth 1: returns an object with 'oAuthToken' and 'oAuthTokenSecret' fields.
52
+ * @param providerConfigKey - This is the unique Config Key for the integration
53
+ * @param connectionId - This is the unique connection identifier used to identify this connection
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
+ }
18
67
  }
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);
68
+ /**
69
+ * Get the full (fresh) credentials payload returned by the external API,
70
+ * which also contains access credentials.
71
+ * @param providerConfigKey - This is the unique Config Key for the integration
72
+ * @param connectionId - This is the unique connection identifier used to identify this connection
73
+ * @param [forceRefresh] - When set, this is used to obtain a new refresh token from the provider before the current token has expired,
74
+ * you can set the forceRefresh argument to true.
75
+ * */
76
+ async getRawTokenResponse(providerConfigKey, connectionId, forceRefresh) {
77
+ const response = await this.getConnectionDetails(providerConfigKey, connectionId, forceRefresh);
78
+ const credentials = response.data.credentials;
79
+ return credentials.raw;
43
80
  }
44
- if (!config.secretKey) {
45
- throw new Error("You must specify a secret key (cf. documentation).");
81
+ /**
82
+ * Get the Connection object, which also contains access credentials and full credentials payload
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;
46
93
  }
47
- try {
48
- new URL(this.serverUrl);
49
- } catch (err) {
50
- throw new Error(`Invalid URL provided for the Nango host: ${this.serverUrl}`);
94
+ async proxy(config) {
95
+ if (!config.connectionId && this.connectionId) {
96
+ config.connectionId = this.connectionId;
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
+ }
51
149
  }
52
- this.secretKey = config.secretKey;
53
- this.connectionId = config.connectionId || "";
54
- this.providerConfigKey = config.providerConfigKey || "";
55
- if (config.isSync) {
56
- this.isSync = config.isSync;
150
+ async get(config) {
151
+ return this.proxy({
152
+ ...config,
153
+ method: 'GET'
154
+ });
57
155
  }
58
- if (config.dryRun) {
59
- this.dryRun = config.dryRun;
156
+ async post(config) {
157
+ return this.proxy({
158
+ ...config,
159
+ method: 'POST'
160
+ });
60
161
  }
61
- if (config.activityLogId) {
62
- this.activityLogId = config.activityLogId;
162
+ async patch(config) {
163
+ return this.proxy({
164
+ ...config,
165
+ method: 'PATCH'
166
+ });
63
167
  }
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;
168
+ async delete(config) {
169
+ return this.proxy({
170
+ ...config,
171
+ method: 'DELETE'
172
+ });
84
173
  }
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;
174
+ async getRecords(config) {
175
+ const { connectionId, providerConfigKey, model, delta, offset, limit, includeNangoMetadata } = config;
176
+ validateSyncRecordConfiguration(config);
177
+ const order = config?.order === 'asc' ? 'asc' : 'desc';
178
+ let sortBy = 'id';
179
+ switch (config.sortBy) {
180
+ case 'createdAt':
181
+ sortBy = 'created_at';
182
+ break;
183
+ case 'updatedAt':
184
+ sortBy = 'updated_at';
185
+ break;
186
+ }
187
+ let filter = '';
188
+ switch (config.filter) {
189
+ case 'deleted':
190
+ filter = 'deleted';
191
+ break;
192
+ case 'updated':
193
+ filter = 'updated';
194
+ break;
195
+ case 'added':
196
+ filter = 'added';
197
+ break;
198
+ }
199
+ const includeMetadata = includeNangoMetadata || false;
200
+ 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}`;
201
+ const headers = {
202
+ 'Connection-Id': connectionId,
203
+ 'Provider-Config-Key': providerConfigKey
204
+ };
205
+ const options = {
206
+ headers: this.enrichHeaders(headers)
207
+ };
208
+ const response = await axios.get(url, options);
209
+ return response.data;
115
210
  }
116
- if (!config.providerConfigKey && this.providerConfigKey) {
117
- config.providerConfigKey = this.providerConfigKey;
211
+ async getConnectionDetails(providerConfigKey, connectionId, forceRefresh = false, refreshToken = false, additionalHeader = {}) {
212
+ const url = `${this.serverUrl}/connection/${connectionId}`;
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) });
118
226
  }
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;
227
+ /**
228
+ * Get the list of Connections, which does not contain access credentials.
229
+ */
230
+ async listConnections(connectionId) {
231
+ const response = await this.listConnectionDetails(connectionId);
232
+ return response.data;
137
233
  }
138
- const options = {
139
- headers: this.enrichHeaders(headers)
140
- };
141
- if (config.params) {
142
- options.params = config.params;
234
+ async getIntegration(providerConfigKey, includeIntegrationCredetials = false) {
235
+ const url = `${this.serverUrl}/config/${providerConfigKey}`;
236
+ const response = await axios.get(url, { headers: this.enrichHeaders({}), params: { include_creds: includeIntegrationCredetials } });
237
+ return response.data;
143
238
  }
144
- if (config.paramsSerializer) {
145
- options.paramsSerializer = config.paramsSerializer;
239
+ async setMetadata(providerConfigKey, connectionId, metadata) {
240
+ if (!providerConfigKey) {
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) });
146
254
  }
147
- if (this.dryRun) {
148
- console.log(`Nango Proxy Request: ${method?.toUpperCase()} ${url}`);
255
+ async setFieldMapping(_fieldMapping, _optionalProviderConfigKey, _optionalConnectionId) {
256
+ throw new Error('setFieldMapping is deprecated. Please use setMetadata instead.');
149
257
  }
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);
258
+ async getMetadata(providerConfigKey, connectionId) {
259
+ if (!providerConfigKey) {
260
+ throw new Error('Provider Config Key is required');
261
+ }
262
+ if (!connectionId) {
263
+ throw new Error('Connection Id is required');
264
+ }
265
+ const response = await this.getConnectionDetails(providerConfigKey, connectionId, false, false, {
266
+ 'Nango-Is-Sync': true,
267
+ 'Nango-Is-Dry-Run': this.dryRun
268
+ });
269
+ return response.data.metadata;
160
270
  }
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;
271
+ async getFieldMapping(_optionalProviderConfigKey, _optionalConnectionId) {
272
+ throw new Error('getFieldMapping is deprecated. Please use getMetadata instead.');
198
273
  }
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;
274
+ async triggerSync(providerConfigKey, connectionId, syncs) {
275
+ const url = `${this.serverUrl}/sync/trigger`;
276
+ const headers = {
277
+ 'Connection-Id': connectionId,
278
+ 'Provider-Config-Key': providerConfigKey
279
+ };
280
+ if (typeof syncs === 'string') {
281
+ throw new Error('Syncs must be an array of strings. If it is a single sync, please wrap it in an array.');
282
+ }
283
+ const body = {
284
+ syncs: syncs || []
285
+ };
286
+ return axios.post(url, body, { headers: this.enrichHeaders(headers) });
210
287
  }
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);
288
+ async createConnection(_connectionArgs) {
289
+ throw new Error('This method has been deprecated, please use the REST API to create a connection. See https://docs.nango.dev/api-reference/connection/post');
231
290
  }
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");
291
+ async deleteConnection(providerConfigKey, connectionId) {
292
+ const url = `${this.serverUrl}/connection/${connectionId}?provider_config_key=${providerConfigKey}`;
293
+ const headers = {
294
+ 'Content-Type': 'application/json',
295
+ 'Accept-Encoding': 'application/json'
296
+ };
297
+ return axios.delete(url, { headers: this.enrichHeaders(headers) });
254
298
  }
255
- if (!connectionId) {
256
- throw new Error("Connection Id is required");
299
+ async listConnectionDetails(connectionId) {
300
+ let url = `${this.serverUrl}/connection?`;
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) });
257
309
  }
258
- if (!metadata) {
259
- throw new Error("Metadata is required");
310
+ enrichHeaders(headers = {}) {
311
+ headers['Authorization'] = 'Bearer ' + this.secretKey;
312
+ return headers;
260
313
  }
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
- };
314
+ }
315
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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,QAAQ,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;QAE7B,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;SACzE;QAED,IAAI;YACA,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC3B;QAAC,OAAO,G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AAC,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 ADDED
@@ -0,0 +1,8 @@
1
+ export var AuthModes;
2
+ (function (AuthModes) {
3
+ AuthModes["OAuth1"] = "OAUTH1";
4
+ AuthModes["OAuth2"] = "OAUTH2";
5
+ AuthModes["Basic"] = "BASIC";
6
+ AuthModes["ApiKey"] = "API_KEY";
7
+ })(AuthModes || (AuthModes = {}));
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,17 @@
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
@@ -0,0 +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,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,23 +1,10 @@
1
1
  {
2
2
  "name": "@nangohq/node",
3
- "version": "0.29.5-beta.0",
3
+ "version": "0.29.6",
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
- },
15
7
  "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
- },
21
8
  "keywords": [],
22
9
  "repository": {
23
10
  "type": "git",