nango 0.36.14 → 0.36.16

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.
Files changed (44) hide show
  1. package/dist/cli.d.ts +16 -0
  2. package/dist/cli.js +338 -0
  3. package/dist/cli.js.map +1 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/constants.js +5 -0
  6. package/dist/constants.js.map +1 -0
  7. package/dist/index.js +25 -16
  8. package/dist/index.js.map +1 -1
  9. package/dist/nango-sync.d.ts +1 -0
  10. package/dist/services/compile.service.d.ts +5 -0
  11. package/dist/services/compile.service.js +72 -0
  12. package/dist/services/compile.service.js.map +1 -0
  13. package/dist/services/config.service.d.ts +8 -0
  14. package/dist/services/config.service.js +73 -0
  15. package/dist/services/config.service.js.map +1 -0
  16. package/dist/services/deploy.service.d.ts +16 -0
  17. package/dist/services/deploy.service.js +237 -0
  18. package/dist/services/deploy.service.js.map +1 -0
  19. package/dist/services/dryrun.service.d.ts +15 -0
  20. package/dist/services/dryrun.service.js +149 -0
  21. package/dist/services/dryrun.service.js.map +1 -0
  22. package/dist/services/local-integration.service.d.ts +6 -0
  23. package/dist/services/local-integration.service.js +62 -0
  24. package/dist/services/local-integration.service.js.map +1 -0
  25. package/dist/services/model.service.d.ts +8 -0
  26. package/dist/services/model.service.js +162 -0
  27. package/dist/services/model.service.js.map +1 -0
  28. package/dist/services/parser.service.d.ts +6 -0
  29. package/dist/services/parser.service.js +79 -0
  30. package/dist/services/parser.service.js.map +1 -0
  31. package/dist/services/verification.service.d.ts +6 -0
  32. package/dist/services/verification.service.js +113 -0
  33. package/dist/services/verification.service.js.map +1 -0
  34. package/dist/sync.unit.test.js +93 -11
  35. package/dist/sync.unit.test.js.map +1 -1
  36. package/dist/templates/action.ejs +39 -0
  37. package/dist/templates/github.sync.ejs +55 -0
  38. package/dist/templates/nango.yaml +29 -0
  39. package/dist/templates/sync.ejs +10 -0
  40. package/dist/utils.d.ts +2 -3
  41. package/dist/utils.js +31 -90
  42. package/dist/utils.js.map +1 -1
  43. package/docker/docker-compose.yaml +2 -2
  44. package/package.json +5 -3
@@ -0,0 +1,73 @@
1
+ import fs from 'fs';
2
+ import Ajv from 'ajv';
3
+ import addErrors from 'ajv-errors';
4
+ import chalk from 'chalk';
5
+ import { loadLocalNangoConfig, loadStandardConfig, nangoConfigFile, determineVersion, NangoError } from '@nangohq/shared';
6
+ import { getNangoRootPath, printDebug } from '../utils.js';
7
+ class ConfigService {
8
+ async load(optionalLoadLocation = '', debug = false) {
9
+ const loadLocation = optionalLoadLocation || './';
10
+ const localConfig = await loadLocalNangoConfig(loadLocation);
11
+ if (!localConfig) {
12
+ return { success: false, error: new NangoError('error_loading_nango_config'), response: null };
13
+ }
14
+ const { success: validationSuccess, error: validationError } = this.validate(localConfig);
15
+ if (!validationSuccess) {
16
+ return { success: false, error: validationError, response: null };
17
+ }
18
+ const { success, error, response: config } = loadStandardConfig(localConfig, true);
19
+ if (!success || !config) {
20
+ return { success: false, error, response: null };
21
+ }
22
+ if (debug) {
23
+ printDebug(`Config file file found`);
24
+ }
25
+ return { success: true, error: null, response: config };
26
+ }
27
+ getModelNames(config) {
28
+ const modelNames = config.reduce((acc, config) => {
29
+ const syncs = config.syncs || [];
30
+ const actions = config.actions || [];
31
+ const allSyncs = [...syncs, ...actions];
32
+ const models = allSyncs.reduce((acc, sync) => {
33
+ const models = sync.models || [];
34
+ const names = models.map((model) => model.name);
35
+ return [...acc, ...names];
36
+ }, []);
37
+ return [...acc, ...models];
38
+ }, []);
39
+ return modelNames;
40
+ }
41
+ validate(config) {
42
+ const ajv = new Ajv({ allErrors: true });
43
+ addErrors(ajv);
44
+ if (!config || !config.integrations) {
45
+ return { success: true, error: null, response: null };
46
+ }
47
+ if (config.integrations['syncs'] || config.integrations['actions']) {
48
+ const error = new NangoError('pass_through_error', `The ${nangoConfigFile} file has an invalid format, syncs or actions should be nested under a provider config key.`);
49
+ return { success: false, error, response: null };
50
+ }
51
+ const version = determineVersion(config);
52
+ const validationFile = version === 'v1' ? 'nango.yaml.schema.v1.json' : 'nango.yaml.schema.v2.json';
53
+ const schema = fs.readFileSync(`${getNangoRootPath()}/lib/${validationFile}`, 'utf8');
54
+ const validate = ajv.compile(JSON.parse(schema));
55
+ if (!validate(config)) {
56
+ const validationMessageStart = 'nango yaml schema validation error:;';
57
+ let messages = validate.errors
58
+ ?.filter((error) => error?.message?.includes(validationMessageStart))
59
+ .map((error) => error.message)
60
+ .join('\n');
61
+ if (messages?.length === 0) {
62
+ messages = validate.errors?.map((error) => error.message).join('\n');
63
+ }
64
+ console.log(chalk.red(`yaml validation failed with: ${messages}`));
65
+ const error = new NangoError('pass_through_error', `Problem validating the ${nangoConfigFile} file.`);
66
+ return { success: false, error, response: null };
67
+ }
68
+ return { success: true, error: null, response: null };
69
+ }
70
+ }
71
+ const configService = new ConfigService();
72
+ export default configService;
73
+ //# sourceMappingURL=config.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.service.js","sourceRoot":"","sources":["../../lib/services/config.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1H,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,aAAa;IACR,KAAK,CAAC,IAAI,CAAC,oBAAoB,GAAG,EAAE,EAAE,KAAK,GAAG,KAAK;QACtD,MAAM,YAAY,GAAG,oBAAoB,IAAI,IAAI,CAAC;QAClD,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC;QAE7D,IAAI,CAAC,WAAW,EAAE;YACd,OAAO,EAAE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,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACnB,MAAM,sBAAsB,GAAG,sCAAsC,CAAC;YACtE,IAAI,QAAQ,GAAG,QAAQ,CAAC,MAAM;gBAC1B,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC;iBACpE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;iBAC7B,IAAI,CAAC,IAAI,CAAC,CAAC;YAEhB,IAAI,QAAQ,EAAE,MAAM,KAAK,CAAC,EAAE;gBACxB,QAAQ,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACxE;YAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACnE,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,oBAAoB,EAAE,0BAA0B,eAAe,QAAQ,CAAC,CAAC;YAEtG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACpD;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;CACJ;AAED,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAC1C,eAAe,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { StandardNangoConfig, IncomingFlowConfig } from '@nangohq/shared';
2
+ import type { DeployOptions } from '../types.js';
3
+ declare class DeployService {
4
+ admin(environmentName: string, debug?: boolean): Promise<void>;
5
+ prep(options: DeployOptions, environment: string, debug?: boolean): Promise<void>;
6
+ run(url: string, body: {
7
+ syncs: IncomingFlowConfig[];
8
+ nangoYamlBody: string | null;
9
+ reconcile: boolean;
10
+ debug: boolean;
11
+ singleDeployMode?: boolean;
12
+ }): Promise<void>;
13
+ package(config: StandardNangoConfig[], debug: boolean, version?: string, optionalSyncName?: string, optionalActionName?: string): IncomingFlowConfig[] | null;
14
+ }
15
+ declare const deployService: DeployService;
16
+ export default deployService;
@@ -0,0 +1,237 @@
1
+ import chalk from 'chalk';
2
+ import promptly from 'promptly';
3
+ import axios from 'axios';
4
+ import { SyncConfigType, localFileService, getInterval, stagingHost, cloudHost } from '@nangohq/shared';
5
+ import configService from './config.service.js';
6
+ import compileService from './compile.service.js';
7
+ import verificationService from './verification.service.js';
8
+ import { printDebug, parseSecretKey, port, enrichHeaders, httpsAgent } from '../utils.js';
9
+ class DeployService {
10
+ async admin(environmentName, debug = false) {
11
+ await verificationService.necessaryFilesExist(false);
12
+ await parseSecretKey(environmentName, debug);
13
+ if (!process.env['NANGO_HOSTPORT']) {
14
+ switch (environmentName) {
15
+ case 'local':
16
+ process.env['NANGO_HOSTPORT'] = `http://localhost:${port}`;
17
+ break;
18
+ case 'staging':
19
+ process.env['NANGO_HOSTPORT'] = stagingHost;
20
+ break;
21
+ default:
22
+ process.env['NANGO_HOSTPORT'] = cloudHost;
23
+ break;
24
+ }
25
+ }
26
+ if (debug) {
27
+ printDebug(`NANGO_HOSTPORT is set to ${process.env['NANGO_HOSTPORT']}.`);
28
+ printDebug(`Environment is set to ${environmentName}`);
29
+ }
30
+ await compileService.run(debug);
31
+ const { success, error, response: config } = await configService.load('', debug);
32
+ if (!success || !config) {
33
+ console.log(chalk.red(error?.message));
34
+ return;
35
+ }
36
+ const flowData = this.package(config, debug);
37
+ if (!flowData) {
38
+ return;
39
+ }
40
+ const targetAccountUUID = await promptly.prompt('Input the account uuid to deploy to: ');
41
+ if (!targetAccountUUID) {
42
+ console.log(chalk.red('Account uuid is required. Exiting'));
43
+ return;
44
+ }
45
+ const url = process.env['NANGO_HOSTPORT'] + `/admin/flow/deploy/pre-built`;
46
+ const nangoYamlBody = localFileService.getNangoYamlFileContents('./');
47
+ try {
48
+ await axios
49
+ .post(url, { targetAccountUUID, targetEnvironment: environmentName, config: flowData, nangoYamlBody }, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
50
+ .then(() => {
51
+ console.log(chalk.green(`Successfully deployed the syncs/actions to the users account.`));
52
+ })
53
+ .catch((err) => {
54
+ const errorMessage = JSON.stringify(err.response.data, null, 2);
55
+ console.log(chalk.red(`Error deploying the syncs/actions with the following error: ${errorMessage}`));
56
+ process.exit(1);
57
+ });
58
+ }
59
+ catch (e) {
60
+ console.log(e);
61
+ }
62
+ }
63
+ async prep(options, environment, debug = false) {
64
+ const { env, version, sync: optionalSyncName, action: optionalActionName, autoConfirm } = options;
65
+ await verificationService.necessaryFilesExist(autoConfirm);
66
+ await parseSecretKey(environment, debug);
67
+ if (!process.env['NANGO_HOSTPORT']) {
68
+ switch (env) {
69
+ case 'local':
70
+ process.env['NANGO_HOSTPORT'] = `http://localhost:${port}`;
71
+ break;
72
+ case 'staging':
73
+ process.env['NANGO_HOSTPORT'] = stagingHost;
74
+ break;
75
+ default:
76
+ process.env['NANGO_HOSTPORT'] = cloudHost;
77
+ break;
78
+ }
79
+ }
80
+ if (debug) {
81
+ printDebug(`NANGO_HOSTPORT is set to ${process.env['NANGO_HOSTPORT']}.`);
82
+ printDebug(`Environment is set to ${environment}`);
83
+ }
84
+ const singleDeployMode = Boolean(optionalSyncName || optionalActionName);
85
+ await compileService.run(debug);
86
+ const { success, error, response: config } = await configService.load('', debug);
87
+ if (!success || !config) {
88
+ console.log(chalk.red(error?.message));
89
+ return;
90
+ }
91
+ const postData = this.package(config, debug, version, optionalSyncName, optionalActionName);
92
+ if (!postData) {
93
+ return;
94
+ }
95
+ const url = process.env['NANGO_HOSTPORT'] + `/sync/deploy`;
96
+ const nangoYamlBody = localFileService.getNangoYamlFileContents('./');
97
+ if (process.env['NANGO_DEPLOY_AUTO_CONFIRM'] !== 'true' && !autoConfirm) {
98
+ const confirmationUrl = process.env['NANGO_HOSTPORT'] + `/sync/deploy/confirmation`;
99
+ try {
100
+ const response = await axios.post(confirmationUrl, { syncs: postData, reconcile: false, debug, singleDeployMode }, { headers: enrichHeaders(), httpsAgent: httpsAgent() });
101
+ console.log(JSON.stringify(response.data, null, 2));
102
+ const { newSyncs, deletedSyncs } = response.data;
103
+ for (const sync of newSyncs) {
104
+ const actionMessage = sync.connections === 0 || sync.auto_start === false
105
+ ? 'The sync will be added to your Nango instance if you deploy.'
106
+ : `Nango will start syncing the corresponding data for ${sync.connections} existing connections.`;
107
+ console.log(chalk.yellow(`Sync "${sync.name}" is new. ${actionMessage}`));
108
+ }
109
+ for (const sync of deletedSyncs) {
110
+ console.log(chalk.red(`Sync "${sync.name}" has been removed. It will stop running and the corresponding data will be deleted for ${sync.connections} existing connections.`));
111
+ }
112
+ const confirmation = await promptly.confirm('Do you want to continue y/n?');
113
+ if (confirmation) {
114
+ await this.run(url, { syncs: postData, nangoYamlBody, reconcile: true, debug, singleDeployMode });
115
+ }
116
+ else {
117
+ console.log(chalk.red('Syncs/Actions were not deployed. Exiting'));
118
+ process.exit(0);
119
+ }
120
+ }
121
+ catch (err) {
122
+ let errorMessage;
123
+ if (!err?.response?.data) {
124
+ const { message, stack, config: { method }, code, status } = err?.toJSON();
125
+ const errorObject = { message, stack, code, status, url, method };
126
+ errorMessage = JSON.stringify(errorObject, null, 2);
127
+ }
128
+ else {
129
+ errorMessage = JSON.stringify(err.response.data, null, 2);
130
+ }
131
+ console.log(chalk.red(`Error deploying the syncs/actions with the following error: ${errorMessage}`));
132
+ process.exit(1);
133
+ }
134
+ }
135
+ else {
136
+ if (debug) {
137
+ printDebug(`Auto confirm is set so deploy will start without confirmation`);
138
+ }
139
+ await this.run(url, { syncs: postData, nangoYamlBody, reconcile: true, debug, singleDeployMode });
140
+ }
141
+ }
142
+ async run(url, body) {
143
+ await axios
144
+ .post(url, body, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
145
+ .then((response) => {
146
+ const results = response.data;
147
+ if (results.length === 0) {
148
+ console.log(chalk.green(`Successfully removed the syncs/actions.`));
149
+ }
150
+ else {
151
+ const nameAndVersions = results.map((result) => `${result.sync_name || result.name}@v${result.version}`);
152
+ console.log(chalk.green(`Successfully deployed the syncs/actions: ${nameAndVersions.join(', ')}!`));
153
+ }
154
+ })
155
+ .catch((err) => {
156
+ const errorMessage = JSON.stringify(err.response.data, null, 2);
157
+ console.log(chalk.red(`Error deploying the syncs/actions with the following error: ${errorMessage}`));
158
+ process.exit(1);
159
+ });
160
+ }
161
+ package(config, debug, version = '', optionalSyncName = '', optionalActionName = '') {
162
+ const postData = [];
163
+ for (const integration of config) {
164
+ const { providerConfigKey } = integration;
165
+ let { syncs, actions } = integration;
166
+ let flows = [...syncs, ...actions];
167
+ if (optionalSyncName) {
168
+ syncs = syncs.filter((sync) => sync.name === optionalSyncName);
169
+ flows = syncs;
170
+ }
171
+ if (optionalActionName) {
172
+ actions = actions.filter((action) => action.name === optionalActionName);
173
+ flows = actions;
174
+ }
175
+ if (optionalSyncName && optionalActionName) {
176
+ flows = [...syncs, ...actions];
177
+ }
178
+ for (const flow of flows) {
179
+ const { name: syncName, runs = '', returns: models, models: model_schema, type = SyncConfigType.SYNC } = flow;
180
+ const { path: integrationFilePath, result: integrationFileResult } = localFileService.checkForIntegrationDistFile(syncName, './');
181
+ const metadata = {};
182
+ if (flow.description) {
183
+ metadata['description'] = flow.description;
184
+ }
185
+ if (flow.scopes) {
186
+ metadata['scopes'] = flow.scopes;
187
+ }
188
+ if (!integrationFileResult) {
189
+ console.log(chalk.red(`No integration file found for ${syncName} at ${integrationFilePath}. Skipping...`));
190
+ continue;
191
+ }
192
+ if (type !== SyncConfigType.SYNC && type !== SyncConfigType.ACTION) {
193
+ console.log(chalk.red(`The sync ${syncName} has an invalid type "${type}". The type must be either ${SyncConfigType.SYNC} or${SyncConfigType.ACTION}. Skipping...`));
194
+ }
195
+ if (type === SyncConfigType.SYNC && !runs) {
196
+ console.log(chalk.red(`The sync ${syncName} is missing the "runs" property. Skipping...`));
197
+ continue;
198
+ }
199
+ if (runs && type === SyncConfigType.SYNC) {
200
+ const { success, error } = getInterval(runs, new Date());
201
+ if (!success) {
202
+ console.log(chalk.red(`The sync ${syncName} has an issue with the sync interval "${runs}": ${error?.message}`));
203
+ return null;
204
+ }
205
+ }
206
+ if (debug) {
207
+ printDebug(`Integration file found for ${syncName} at ${integrationFilePath}`);
208
+ }
209
+ const body = {
210
+ syncName,
211
+ providerConfigKey,
212
+ models: Array.isArray(models) ? models : [models],
213
+ version: version,
214
+ runs,
215
+ track_deletes: flow.track_deletes || false,
216
+ auto_start: flow.auto_start === false ? false : true,
217
+ attributes: flow.attributes || {},
218
+ metadata: metadata || {},
219
+ input: flow?.input?.name || '',
220
+ sync_type: flow.sync_type,
221
+ type,
222
+ fileBody: {
223
+ js: localFileService.getIntegrationFile(syncName, './'),
224
+ ts: localFileService.getIntegrationTsFile(syncName, './')
225
+ },
226
+ model_schema: JSON.stringify(model_schema),
227
+ endpoints: flow.endpoints
228
+ };
229
+ postData.push(body);
230
+ }
231
+ }
232
+ return postData;
233
+ }
234
+ }
235
+ const deployService = new DeployService();
236
+ export default deployService;
237
+ //# sourceMappingURL=deploy.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.service.js","sourceRoot":"","sources":["../../lib/services/deploy.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,aAAa,MA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CAAC;gBAEF,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACvB;SACJ;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAED,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAC1C,eAAe,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Metadata } from '@nangohq/shared';
2
+ import type { GlobalOptions } from '../types.js';
3
+ interface RunArgs extends GlobalOptions {
4
+ sync: string;
5
+ connectionId: string;
6
+ lastSyncDate?: string;
7
+ useServerLastSyncDate?: boolean;
8
+ input?: object;
9
+ metadata?: Metadata;
10
+ }
11
+ declare class DryRunService {
12
+ run(options: RunArgs, environment: string, debug?: boolean): Promise<void>;
13
+ }
14
+ declare const dryRunService: DryRunService;
15
+ export default dryRunService;
@@ -0,0 +1,149 @@
1
+ import promptly from 'promptly';
2
+ import chalk from 'chalk';
3
+ import { SyncConfigType, SyncType, syncRunService, cloudHost, stagingHost } from '@nangohq/shared';
4
+ import { parseSecretKey, printDebug, hostport, getConnection } from '../utils.js';
5
+ import configService from './config.service.js';
6
+ import compileService from './compile.service.js';
7
+ import integrationService from './local-integration.service.js';
8
+ class DryRunService {
9
+ async run(options, environment, debug = false) {
10
+ let syncName = '';
11
+ let connectionId, suppliedLastSyncDate, actionInput, rawStubbedMetadata;
12
+ await parseSecretKey(environment, debug);
13
+ if (!process.env['NANGO_HOSTPORT']) {
14
+ if (debug) {
15
+ printDebug(`NANGO_HOSTPORT is not set. Setting the default to ${hostport}`);
16
+ }
17
+ process.env['NANGO_HOSTPORT'] = hostport;
18
+ }
19
+ if (debug) {
20
+ printDebug(`NANGO_HOSTPORT is set to ${process.env['NANGO_HOSTPORT']}`);
21
+ }
22
+ if (Object.keys(options).length > 0) {
23
+ ({ sync: syncName, connectionId, lastSyncDate: suppliedLastSyncDate, input: actionInput, metadata: rawStubbedMetadata } = options);
24
+ }
25
+ if (!syncName) {
26
+ console.log(chalk.red('Sync name is required'));
27
+ return;
28
+ }
29
+ if (!connectionId) {
30
+ console.log(chalk.red('Connection id is required'));
31
+ return;
32
+ }
33
+ const { success, error, response: config } = await configService.load('', debug);
34
+ if (!success || !config) {
35
+ console.log(chalk.red(error?.message));
36
+ return;
37
+ }
38
+ const providerConfigKey = config.find((config) => [...config.syncs, ...config.actions].find((sync) => sync.name === syncName))?.providerConfigKey;
39
+ if (!providerConfigKey) {
40
+ console.log(chalk.red(`Provider config key not found, please check that the provider exists for this sync name: ${syncName}`));
41
+ return;
42
+ }
43
+ const foundConfig = config.find((configItem) => {
44
+ const syncsArray = configItem.syncs || [];
45
+ const actionsArray = configItem.actions || [];
46
+ return [...syncsArray, ...actionsArray].some((sync) => sync.name === syncName);
47
+ });
48
+ const syncInfo = foundConfig
49
+ ? (foundConfig.syncs || []).find((sync) => sync.name === syncName) || (foundConfig.actions || []).find((action) => action.name === syncName)
50
+ : null;
51
+ if (debug) {
52
+ printDebug(`Provider config key found to be ${providerConfigKey}`);
53
+ }
54
+ const nangoConnection = (await getConnection(providerConfigKey, connectionId, {
55
+ 'Nango-Is-Sync': true,
56
+ 'Nango-Is-Dry-Run': true
57
+ }, debug));
58
+ if (!nangoConnection) {
59
+ console.log(chalk.red('Connection not found'));
60
+ return;
61
+ }
62
+ if (debug) {
63
+ printDebug(`Connection found with ${JSON.stringify(nangoConnection, null, 2)}`);
64
+ }
65
+ if (process.env['NANGO_HOSTPORT'] === cloudHost || process.env['NANGO_HOSTPORT'] === stagingHost) {
66
+ process.env['NANGO_CLOUD'] = 'true';
67
+ }
68
+ let lastSyncDate = null;
69
+ if (suppliedLastSyncDate) {
70
+ if (debug) {
71
+ printDebug(`Last sync date supplied as ${suppliedLastSyncDate}`);
72
+ }
73
+ lastSyncDate = new Date(suppliedLastSyncDate);
74
+ }
75
+ const result = await compileService.run(debug, syncName);
76
+ if (!result) {
77
+ console.log(chalk.red('The sync/action did not compile successfully. Exiting'));
78
+ return;
79
+ }
80
+ let normalizedInput;
81
+ let stubbedMetadata;
82
+ try {
83
+ normalizedInput = JSON.parse(actionInput);
84
+ }
85
+ catch (e) {
86
+ normalizedInput = actionInput;
87
+ }
88
+ try {
89
+ stubbedMetadata = JSON.parse(rawStubbedMetadata);
90
+ }
91
+ catch (e) {
92
+ stubbedMetadata = rawStubbedMetadata;
93
+ }
94
+ const logMessages = [];
95
+ const syncRun = new syncRunService({
96
+ integrationService,
97
+ writeToDb: false,
98
+ nangoConnection,
99
+ input: normalizedInput,
100
+ isAction: syncInfo?.type === SyncConfigType.ACTION,
101
+ syncId: 'abc',
102
+ activityLogId: -1,
103
+ syncJobId: -1,
104
+ syncName,
105
+ syncType: SyncType.INITIAL,
106
+ loadLocation: './',
107
+ debug,
108
+ logMessages,
109
+ stubbedMetadata
110
+ });
111
+ try {
112
+ const secretKey = process.env['NANGO_SECRET_KEY'];
113
+ const results = await syncRun.run(lastSyncDate, true, secretKey, process.env['NANGO_HOSTPORT']);
114
+ if (results) {
115
+ console.log(JSON.stringify(results, null, 2));
116
+ }
117
+ if (syncRun.logMessages && syncRun.logMessages.length > 0) {
118
+ const logMessages = syncRun.logMessages;
119
+ let index = 0;
120
+ const batchCount = 10;
121
+ const displayBatch = () => {
122
+ for (let i = 0; i < batchCount && index < logMessages.length; i++, index++) {
123
+ const logs = logMessages[index];
124
+ console.log(chalk.yellow(JSON.stringify(logs, null, 2)));
125
+ }
126
+ };
127
+ console.log(chalk.yellow('The following log messages were generated:'));
128
+ displayBatch();
129
+ while (index < syncRun.logMessages.length) {
130
+ const remaining = syncRun.logMessages.length - index;
131
+ const confirmation = await promptly.confirm(`There are ${remaining} logs messages remaining. Would you like to see the next 10 log messages? (y/n)`);
132
+ if (confirmation) {
133
+ displayBatch();
134
+ }
135
+ else {
136
+ break;
137
+ }
138
+ }
139
+ }
140
+ process.exit(0);
141
+ }
142
+ catch (e) {
143
+ process.exit(1);
144
+ }
145
+ }
146
+ }
147
+ const dryRunService = new DryRunService();
148
+ export default dryRunService;
149
+ //# sourceMappingURL=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;yBAAM;wBACH,MAAM;qBACT;iBACJ;aACJ;YAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;IACL,CAAC;CACJ;AAED,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAC1C,eAAe,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { IntegrationServiceInterface, NangoIntegrationData, NangoSync } from '@nangohq/shared';
2
+ declare class IntegrationService implements IntegrationServiceInterface {
3
+ runScript(syncName: string, _activityLogId: number | undefined, nango: NangoSync, _integrationData: NangoIntegrationData, _environmentId: number, _writeToDb: boolean, isAction: boolean, optionalLoadLocation?: string, input?: object): Promise<any>;
4
+ }
5
+ declare const _default: IntegrationService;
6
+ export default _default;
@@ -0,0 +1,62 @@
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
+ import { Buffer } from 'buffer';
6
+ class IntegrationService {
7
+ async runScript(syncName, _activityLogId, nango, _integrationData, _environmentId, _writeToDb, isAction, optionalLoadLocation, input) {
8
+ try {
9
+ const script = localFileService.getIntegrationFile(syncName, optionalLoadLocation);
10
+ if (!script) {
11
+ const content = `Unable to find integration file for ${syncName}`;
12
+ return { success: false, error: new NangoError(content, 500), response: null };
13
+ }
14
+ try {
15
+ const wrappedScript = `
16
+ (function() {
17
+ var module = { exports: {} };
18
+ var exports = module.exports;
19
+ ${script}
20
+ return module.exports.default || module.exports;
21
+ })();
22
+ `;
23
+ const scriptObj = new vm.Script(wrappedScript);
24
+ const sandbox = {
25
+ console,
26
+ require: (moduleName) => {
27
+ switch (moduleName) {
28
+ case 'url':
29
+ return url;
30
+ case 'crypto':
31
+ return crypto;
32
+ default:
33
+ throw new Error(`Module '${moduleName}' is not allowed`);
34
+ }
35
+ },
36
+ Buffer
37
+ };
38
+ const context = vm.createContext(sandbox);
39
+ const scriptExports = scriptObj.runInContext(context);
40
+ if (scriptExports && typeof scriptExports === 'function') {
41
+ const results = isAction ? await scriptExports(nango, input) : await scriptExports(nango);
42
+ return { success: true, error: null, response: results };
43
+ }
44
+ else {
45
+ const content = `There is no default export that is a function for ${syncName}`;
46
+ return { success: false, error: new NangoError(content, 500), response: null };
47
+ }
48
+ }
49
+ catch (err) {
50
+ const errorType = isAction ? 'action_script_failure' : 'sync_script_failre';
51
+ return formatScriptError(err, errorType, syncName);
52
+ }
53
+ }
54
+ catch (err) {
55
+ const errorMessage = JSON.stringify(err, ['message', 'name', 'stack'], 2);
56
+ const content = `The script failed to load for ${syncName} with the following error: ${errorMessage}`;
57
+ return { success: false, error: new NangoError(content, 500), response: null };
58
+ }
59
+ }
60
+ }
61
+ export default new IntegrationService();
62
+ //# sourceMappingURL=local-integration.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-integration.service.js","sourceRoot":"","sources":["../../lib/services/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;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,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,GAA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AE,QAAQ,EAAE,IAAI,EAAE,CAAC;iBAClF;aACJ;YAAC,OAAO,GAAQ,EAAE;gBACf,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,oBAAoB,CAAC;gBAE5E,OAAO,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;aACtD;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1E,MAAM,OAAO,GAAG,iCAAiC,QAAQ,8BAA8B,YAAY,EAAE,CAAC;YAEtG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SAClF;IACL,CAAC;CACJ;AAED,eAAe,IAAI,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { NangoModel, NangoIntegration } from '@nangohq/shared';
2
+ declare class ModelService {
3
+ build(models: NangoModel, integrations: NangoIntegration, debug?: boolean): (string | undefined)[] | null;
4
+ private getFieldType;
5
+ createModelFile(notify?: boolean): Promise<void>;
6
+ }
7
+ declare const modelService: ModelService;
8
+ export default modelService;