nango 0.36.51 → 0.36.53

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.
@@ -1,60 +0,0 @@
1
- import { NangoError, formatScriptError, localFileService } from '@nangohq/shared';
2
- import * as vm from 'vm';
3
- import * as url from 'url';
4
- import * as crypto from 'crypto';
5
- class IntegrationService {
6
- async runScript(syncName, _activityLogId, nango, _integrationData, _environmentId, _writeToDb, isAction, optionalLoadLocation, input) {
7
- try {
8
- const script = localFileService.getIntegrationFile(syncName, optionalLoadLocation);
9
- if (!script) {
10
- const content = `Unable to find integration file for ${syncName}`;
11
- return { success: false, error: new NangoError(content, 500), response: null };
12
- }
13
- try {
14
- const wrappedScript = `
15
- (function() {
16
- var module = { exports: {} };
17
- var exports = module.exports;
18
- ${script}
19
- return module.exports.default || module.exports;
20
- })();
21
- `;
22
- const scriptObj = new vm.Script(wrappedScript);
23
- const sandbox = {
24
- console: console,
25
- require: (moduleName) => {
26
- switch (moduleName) {
27
- case 'url':
28
- return url;
29
- case 'crypto':
30
- return crypto;
31
- default:
32
- throw new Error(`Module '${moduleName}' is not allowed`);
33
- }
34
- }
35
- };
36
- const context = vm.createContext(sandbox);
37
- const scriptExports = scriptObj.runInContext(context);
38
- if (scriptExports && typeof scriptExports === 'function') {
39
- const results = isAction ? await scriptExports(nango, input) : await scriptExports(nango);
40
- return { success: true, error: null, response: results };
41
- }
42
- else {
43
- const content = `There is no default export that is a function for ${syncName}`;
44
- return { success: false, error: new NangoError(content, 500), response: null };
45
- }
46
- }
47
- catch (err) {
48
- const errorType = isAction ? 'action_script_failure' : 'sync_script_failre';
49
- return formatScriptError(err, errorType, syncName);
50
- }
51
- }
52
- catch (err) {
53
- const errorMessage = JSON.stringify(err, ['message', 'name', 'stack'], 2);
54
- const content = `The script failed to load for ${syncName} with the following error: ${errorMessage}`;
55
- return { success: false, error: new NangoError(content, 500), response: null };
56
- }
57
- }
58
- }
59
- export default new IntegrationService();
60
- //# sourceMappingURL=local-integration.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local-integration.service.js","sourceRoot":"","sources":["../lib/local-integration.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAgE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChJ,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,kBAAkB;IACpB,KAAK,CAAC,SAAS,CACX,QAAgB,EAChB,cAAkC,EAClC,KAAgB,EAChB,gBAAsC,EACtC,cAAsB,EACtB,UAAmB,EACnB,QAAiB,EACjB,oBAA6B,EAC7B,KAAc;QAEd,IAAI;YACA,MAAM,MAAM,GAAkB,gBAAgB,CAAC,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAElG,IAAI,CAAC,MAAM,EAAE;gBACT,MAAM,OAAO,GAAG,uCAAuC,QAAQ,EAAE,CAAC;gBAElE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;aAClF;YAED,IAAI;gBACA,MAAM,aAAa,GAAG;;;;0BAIZ,MAAM;;;iBAGf,CAAC;gBAEF,MAAM,SAAS,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC/C,MAAM,OAAO,GAAG;oBACZ,OAAO,EAAE,OAAO;oBAChB,OAAO,EAAE,CAAC,UAAkB,EAAE,EAAE;wBAC5B,QAAQ,UAAU,EAAE;4BAChB,KAAK,KAAK;gCACN,OAAO,GAAG,CAAC;4BACf,KAAK,QAAQ;gCACT,OAAO,MAAM,CAAC;4BAClB;gCACI,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,kBAAkB,CAAC,CAA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AAE,CAAC;SAClF;IACL,CAAC;CACJ;AAED,eAAe,IAAI,kBAAkB,EAAE,CAAC"}
@@ -1,35 +0,0 @@
1
- const tableName = '<%= tableName %>'';
2
-
3
- exports.up = function (knex, _) {
4
- return knex.schema.withSchema('nango').createTable(tableName, function (table) {
5
- return knex.schema.withSchema('nango').createTable(tableName, function (table) {
6
- table.increments('id').primary();
7
- <% data.forEach(function(model) { %>
8
- <% Object.keys(model).forEach(function(prop) { %>
9
- <% if (prop === 'id') { return; } %>
10
- <% const type = model[prop]; %>
11
- <% switch (type) { %>
12
- <% case 'integer': %>
13
- table.integer('<%= prop %>');
14
- <% break; %>
15
- <% case 'char': %>
16
- table.string('<%= prop %>', 255);
17
- <% break; %>
18
- <% case 'text': %>
19
- table.text('<%= prop %>');
20
- <% break; %>
21
- <% case 'timestamp': %>
22
- table.timestamp('<%= prop %>');
23
- <% break; %>
24
- <% default: %>
25
- throw new Error(`Unknown type <%= type %> for column <%= prop %>`);
26
- <% } %>
27
- <% }); %>
28
- <% }); %>
29
- });
30
- };
31
-
32
- exports.down = function (knex, _) {
33
- return knex.schema.withSchema('nango').dropTable(tableName);
34
- };
35
-
package/dist/sync.d.ts DELETED
@@ -1,35 +0,0 @@
1
- import type { Metadata } from '@nangohq/shared';
2
- import { SyncConfigType } from '@nangohq/shared';
3
- import type { DeployOptions, GlobalOptions } from './types.js';
4
- interface RunArgs extends GlobalOptions {
5
- sync: string;
6
- connectionId: string;
7
- lastSyncDate?: string;
8
- useServerLastSyncDate?: boolean;
9
- input?: object;
10
- metadata?: Metadata;
11
- }
12
- export declare const exampleSyncName = "github-issue-example";
13
- export declare const version: (debug: boolean) => void;
14
- export declare const generate: (debug?: boolean, inParentDirectory?: boolean) => Promise<void>;
15
- /**
16
- * Init
17
- * If we're not currently in the nango-integrations directory create one
18
- * and create an example nango.yaml file
19
- */
20
- export declare const init: (debug?: boolean) => Promise<void>;
21
- export declare const deploy: (options: DeployOptions, environment: string, debug?: boolean) => Promise<void>;
22
- export declare const adminDeploy: (environmentName: string, debug?: boolean) => Promise<void>;
23
- export declare const dryRun: (options: RunArgs, environment: string, debug?: boolean) => Promise<void>;
24
- export declare const tsc: (debug?: boolean, syncName?: string) => Promise<boolean>;
25
- export declare const checkYamlMatchesTsFiles: () => Promise<boolean>;
26
- export declare const nangoCallsAreUsedCorrectly: (filePath: string, type: SyncConfigType | undefined, modelNames: string[]) => boolean;
27
- export declare const tscWatch: (debug?: boolean) => Promise<void>;
28
- export declare const configWatch: (debug?: boolean) => void;
29
- /**
30
- * Docker Run
31
- * @desc spawn a child process to run the docker compose located in the cli
32
- * Look into https://www.npmjs.com/package/docker-compose to avoid dependency maybe?
33
- */
34
- export declare const dockerRun: (debug?: boolean) => Promise<void>;
35
- export {};
package/dist/sync.ejs DELETED
@@ -1,10 +0,0 @@
1
- <%
2
- const formattedInterfaceNames = Array.isArray(interfaceNames) ? interfaceNames.join(', ') : interfaceNames;
3
- %>
4
- import type { NangoSync<%= formattedInterfaceNames ? ', ' + formattedInterfaceNames : '' %> } from './<%= interfaceFileName %>';
5
-
6
- export default async function fetchData(nango: NangoSync): Promise<void> {
7
- // Integration code goes here
8
- // to save data use await nango.batchSave
9
- // to delete data use await nango.batchDelete
10
- }