nango 0.36.30 → 0.36.33
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/docker/docker-compose.yaml +2 -2
- package/package.json +2 -2
- package/dist/action.ejs +0 -5
- package/dist/entry.js +0 -89
- package/dist/github.sync.ejs +0 -58
- package/dist/integration.ejs +0 -5
- package/dist/integration.github.ejs +0 -61
- package/dist/migration.ejs +0 -35
- package/dist/sync.d.ts +0 -30
- package/dist/sync.ejs +0 -7
- package/dist/sync.js +0 -815
- package/dist/sync.js.map +0 -1
|
@@ -15,7 +15,7 @@ services:
|
|
|
15
15
|
- nango
|
|
16
16
|
|
|
17
17
|
nango-server:
|
|
18
|
-
image: nangohq/nango-server:0.36.
|
|
18
|
+
image: nangohq/nango-server:0.36.33
|
|
19
19
|
container_name: nango-server
|
|
20
20
|
environment:
|
|
21
21
|
- TEMPORAL_ADDRESS=temporal:7233
|
|
@@ -47,7 +47,7 @@ services:
|
|
|
47
47
|
- nango
|
|
48
48
|
|
|
49
49
|
nango-worker:
|
|
50
|
-
image: nangohq/nango-worker:0.36.
|
|
50
|
+
image: nangohq/nango-worker:0.36.33
|
|
51
51
|
container_name: nango-worker
|
|
52
52
|
restart: always
|
|
53
53
|
ports:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nango",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.33",
|
|
4
4
|
"description": "Nango's CLI tool.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/traverse": "^7.22.5",
|
|
25
25
|
"@inquirer/prompts": "^2.3.0",
|
|
26
|
-
"@nangohq/shared": "0.36.
|
|
26
|
+
"@nangohq/shared": "0.36.33",
|
|
27
27
|
"@vercel/ncc": "^0.36.1",
|
|
28
28
|
"ajv": "^8.12.0",
|
|
29
29
|
"ajv-errors": "^3.0.0",
|
package/dist/action.ejs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { NangoAction<%= interfaceNames.length > 0 ? ', ' + interfaceNames.join(', ') : '' %>} from './<%= interfaceFileName %>';
|
|
2
|
-
|
|
3
|
-
export default async function runAction(nango: NangoAction, input?: object): Promise<<%= mappings.length > 0 ? '{' : 'void' %><% for (let i = 0; i < mappings.length; i++) { %><%= mappings[i].name %>: <%= mappings[i].type %>[]<% if (i !== mappings.length - 1) { %>, <% } %><% } %><%= mappings.length > 0 ? '}' : '' %>> {
|
|
4
|
-
// Integration code goes here
|
|
5
|
-
}
|
package/dist/entry.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var node_1 = require("@nangohq/node");
|
|
55
|
-
// TODO this will be a local interface created by the config yaml file
|
|
56
|
-
//import { ticket } from '@nangohq/models';
|
|
57
|
-
var GithubTicketSync = /** @class */ (function (_super) {
|
|
58
|
-
__extends(GithubTicketSync, _super);
|
|
59
|
-
function GithubTicketSync() {
|
|
60
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
-
}
|
|
62
|
-
//async fetchData(nango: NangoHelper): { [ticket.name]: [ticket.type] } {
|
|
63
|
-
GithubTicketSync.prototype.fetchData = function (nango) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var issues, tickets;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, nango.get({
|
|
69
|
-
endpoint: 'repos/NangoHQ/nango/issues'
|
|
70
|
-
})];
|
|
71
|
-
case 1:
|
|
72
|
-
issues = _a.sent();
|
|
73
|
-
tickets = issues.map(function (issue) { return ({
|
|
74
|
-
id: issue.id,
|
|
75
|
-
title: issue.title,
|
|
76
|
-
description: issue.body,
|
|
77
|
-
status: issue.state,
|
|
78
|
-
author: {
|
|
79
|
-
avatar_url: issue.user.avatar_url
|
|
80
|
-
}
|
|
81
|
-
}); });
|
|
82
|
-
return [2 /*return*/, tickets];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
return GithubTicketSync;
|
|
88
|
-
}(node_1.NangoSync));
|
|
89
|
-
exports.default = GithubSync;
|
package/dist/github.sync.ejs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { NangoSync, <%= interfaceNames.join(', ') %> } from './<%= interfaceFileName %>';
|
|
2
|
-
|
|
3
|
-
export default async function fetchData(nango: NangoSync): Promise<void> {
|
|
4
|
-
|
|
5
|
-
const repos = await paginate(nango, '/user/repos');
|
|
6
|
-
|
|
7
|
-
for (let repo of repos) {
|
|
8
|
-
let issues = await paginate(nango, `/repos/${repo.owner.login}/${repo.name}/issues`);
|
|
9
|
-
|
|
10
|
-
// Filter out pull requests
|
|
11
|
-
issues = issues.filter(issue => !('pull_request' in issue));
|
|
12
|
-
|
|
13
|
-
const mappedIssues: GithubIssue[] = issues.map(issue => ({
|
|
14
|
-
id: issue.id,
|
|
15
|
-
owner: repo.owner.login,
|
|
16
|
-
repo: repo.name,
|
|
17
|
-
issue_number: issue.number,
|
|
18
|
-
title: issue.title,
|
|
19
|
-
state: issue.state,
|
|
20
|
-
author: issue.user.login,
|
|
21
|
-
author_id: issue.user.id,
|
|
22
|
-
body: issue.body,
|
|
23
|
-
date_created: issue.created_at,
|
|
24
|
-
date_last_modified: issue.updated_at
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
if (mappedIssues.length > 0) {
|
|
28
|
-
await nango.batchSave<GithubIssue>(mappedIssues, 'GithubIssue');
|
|
29
|
-
await nango.log(`Sent ${mappedIssues.length} issues from ${repo.owner.login}/${repo.name}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function paginate(nango: NangoSync, endpoint: string) {
|
|
35
|
-
const MAX_PAGE = 100;
|
|
36
|
-
|
|
37
|
-
let results: any[] = [];
|
|
38
|
-
let page = 1;
|
|
39
|
-
while (true) {
|
|
40
|
-
const resp = await nango.get({
|
|
41
|
-
endpoint: endpoint,
|
|
42
|
-
params: {
|
|
43
|
-
limit: `${MAX_PAGE}`,
|
|
44
|
-
page: `${page}`
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
results = results.concat(resp.data);
|
|
49
|
-
|
|
50
|
-
if (resp.data.length == MAX_PAGE) {
|
|
51
|
-
page += 1;
|
|
52
|
-
} else {
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return results;
|
|
58
|
-
}
|
package/dist/integration.ejs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { NangoSync, <%= interfaceNames.join(', ') %> } from './<%= interfaceFileName %>';
|
|
2
|
-
|
|
3
|
-
export default async function fetchData(nango: NangoSync): Promise<{<% for (let i = 0; i < mappings.length; i++) { %><%= mappings[i].name %>: <%= mappings[i].type %>[]<% if (i !== mappings.length - 1) { %>, <% } %><% } %>}> {
|
|
4
|
-
// Integration code goes here, be sure to follow the return signature type
|
|
5
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { NangoSync, <%= interfaceNames.join(', ') %> } from './<%= interfaceFileName %>';
|
|
2
|
-
|
|
3
|
-
export default async function fetchData(nango: NangoSync): Promise<{<% for (let i = 0; i < mappings.length; i++) { %><%= mappings[i].name %>: <%= mappings[i].type %>[]<% if (i !== mappings.length - 1) { %>, <% } %><% } %>}> {
|
|
4
|
-
|
|
5
|
-
const repos = await paginate(nango, '/user/repos');
|
|
6
|
-
|
|
7
|
-
for (let repo of repos) {
|
|
8
|
-
let issues = await paginate(nango, `/repos/${repo.owner.login}/${repo.name}/issues`);
|
|
9
|
-
|
|
10
|
-
// Filter out pull requests
|
|
11
|
-
issues = issues.filter(issue => !('pull_request' in issue));
|
|
12
|
-
|
|
13
|
-
const mappedIssues: GithubIssue[] = issues.map(issue => ({
|
|
14
|
-
id: issue.id,
|
|
15
|
-
owner: repo.owner.login,
|
|
16
|
-
repo: repo.name,
|
|
17
|
-
issue_number: issue.number,
|
|
18
|
-
title: issue.title,
|
|
19
|
-
state: issue.state,
|
|
20
|
-
author: issue.user.login,
|
|
21
|
-
author_id: issue.user.id,
|
|
22
|
-
body: issue.body,
|
|
23
|
-
date_created: issue.created_at,
|
|
24
|
-
date_last_modified: issue.updated_at
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
if (mappedIssues.length > 0) {
|
|
28
|
-
await nango.batchSave<GithubIssue>(mappedIssues, 'GithubIssue');
|
|
29
|
-
await nango.log(`Sent ${mappedIssues.length} issues from ${repo.owner.login}/${repo.name}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Return empty array with the model key to indicate success
|
|
34
|
-
return { GithubIssue: [] };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function paginate(nango: NangoSync, endpoint: string) {
|
|
38
|
-
const MAX_PAGE = 100;
|
|
39
|
-
|
|
40
|
-
let results: any[] = [];
|
|
41
|
-
let page = 1;
|
|
42
|
-
while (true) {
|
|
43
|
-
const resp = await nango.get({
|
|
44
|
-
endpoint: endpoint,
|
|
45
|
-
params: {
|
|
46
|
-
limit: `${MAX_PAGE}`,
|
|
47
|
-
page: `${page}`
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
results = results.concat(resp.data);
|
|
52
|
-
|
|
53
|
-
if (resp.data.length == MAX_PAGE) {
|
|
54
|
-
page += 1;
|
|
55
|
-
} else {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return results;
|
|
61
|
-
}
|
package/dist/migration.ejs
DELETED
|
@@ -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,30 +0,0 @@
|
|
|
1
|
-
import type { DeployOptions, GlobalOptions } from './types.js';
|
|
2
|
-
interface RunArgs extends GlobalOptions {
|
|
3
|
-
sync: string;
|
|
4
|
-
connectionId: string;
|
|
5
|
-
lastSyncDate?: string;
|
|
6
|
-
useServerLastSyncDate?: boolean;
|
|
7
|
-
input?: object;
|
|
8
|
-
}
|
|
9
|
-
export declare const version: (debug: boolean) => void;
|
|
10
|
-
export declare const generate: (debug?: boolean, inParentDirectory?: boolean) => Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Init
|
|
13
|
-
* If we're not currently in the nango-integrations directory create one
|
|
14
|
-
* and create an example nango.yaml file
|
|
15
|
-
*/
|
|
16
|
-
export declare const init: (debug?: boolean) => Promise<void>;
|
|
17
|
-
export declare const deploy: (options: DeployOptions, environment: string, debug?: boolean) => Promise<void>;
|
|
18
|
-
export declare const adminDeploy: (environmentName: string, debug?: boolean) => Promise<void>;
|
|
19
|
-
export declare const dryRun: (options: RunArgs, environment: string, debug?: boolean) => Promise<void>;
|
|
20
|
-
export declare const tsc: (debug?: boolean, syncName?: string) => Promise<boolean>;
|
|
21
|
-
export declare const checkYamlMatchesTsFiles: () => Promise<boolean>;
|
|
22
|
-
export declare const tscWatch: (debug?: boolean) => Promise<void>;
|
|
23
|
-
export declare const configWatch: (debug?: boolean) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Docker Run
|
|
26
|
-
* @desc spawn a child process to run the docker compose located in the cli
|
|
27
|
-
* Look into https://www.npmjs.com/package/docker-compose to avoid dependency maybe?
|
|
28
|
-
*/
|
|
29
|
-
export declare const dockerRun: (debug?: boolean) => Promise<void>;
|
|
30
|
-
export {};
|
package/dist/sync.ejs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { NangoSync, <%= interfaceNames.join(', ') %> } from './<%= interfaceFileName %>';
|
|
2
|
-
|
|
3
|
-
export default async function fetchData(nango: NangoSync): Promise<void> {
|
|
4
|
-
// Integration code goes here
|
|
5
|
-
// to save data use await nango.batchSave
|
|
6
|
-
// to delete data use await nango.batchDelete
|
|
7
|
-
}
|
package/dist/sync.js
DELETED
|
@@ -1,815 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path, { dirname } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
import yaml from 'js-yaml';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import chokidar from 'chokidar';
|
|
8
|
-
import * as tsNode from 'ts-node';
|
|
9
|
-
import glob from 'glob';
|
|
10
|
-
import ejs from 'ejs';
|
|
11
|
-
import * as dotenv from 'dotenv';
|
|
12
|
-
import { spawn } from 'child_process';
|
|
13
|
-
import parser from '@babel/parser';
|
|
14
|
-
import traverse from '@babel/traverse';
|
|
15
|
-
import promptly from 'promptly';
|
|
16
|
-
import { getInterval, analytics, loadSimplifiedConfig, cloudHost, stagingHost, SyncType, syncRunService, nangoConfigFile, localFileService, SyncConfigType } from '@nangohq/shared';
|
|
17
|
-
import { hostport, port, httpsAgent, verifyNecessaryFiles, getConnection, NANGO_INTEGRATIONS_NAME, buildInterfaces, enrichHeaders, getNangoRootPath, printDebug } from './utils.js';
|
|
18
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
-
const __dirname = dirname(__filename);
|
|
20
|
-
dotenv.config();
|
|
21
|
-
const TYPES_FILE_NAME = 'models.ts';
|
|
22
|
-
const NangoSyncTypesFileLocation = 'dist/nango-sync.d.ts';
|
|
23
|
-
const exampleSyncName = 'github-issue-example';
|
|
24
|
-
export const version = (debug) => {
|
|
25
|
-
if (debug) {
|
|
26
|
-
printDebug('Looking up the version first for a local path first then globally');
|
|
27
|
-
}
|
|
28
|
-
const packageJson = JSON.parse(fs.readFileSync(path.resolve(getNangoRootPath(debug), 'package.json'), 'utf8'));
|
|
29
|
-
const dockerComposeYaml = fs.readFileSync(path.resolve(getNangoRootPath(), 'docker/docker-compose.yaml'), 'utf8');
|
|
30
|
-
const dockerCompose = yaml.load(dockerComposeYaml);
|
|
31
|
-
const nangoServerImage = dockerCompose.services['nango-server'].image;
|
|
32
|
-
const nangoWorkerImage = dockerCompose.services['nango-worker'].image;
|
|
33
|
-
const nangoServerVersion = nangoServerImage.split(':').pop();
|
|
34
|
-
const nangoWorkerVersion = nangoWorkerImage.split(':').pop();
|
|
35
|
-
console.log(chalk.green('Nango Server version:'), nangoServerVersion);
|
|
36
|
-
console.log(chalk.green('Nango Worker version:'), nangoWorkerVersion);
|
|
37
|
-
console.log(chalk.green('Nango CLI version:'), packageJson.version);
|
|
38
|
-
};
|
|
39
|
-
export const generate = async (debug = false, inParentDirectory = false) => {
|
|
40
|
-
const dirPrefix = inParentDirectory ? `./${NANGO_INTEGRATIONS_NAME}` : '.';
|
|
41
|
-
const syncTemplateContents = fs.readFileSync(path.resolve(__dirname, './sync.ejs'), 'utf8');
|
|
42
|
-
const actionTemplateContents = fs.readFileSync(path.resolve(__dirname, './action.ejs'), 'utf8');
|
|
43
|
-
const githubExampleTemplateContents = fs.readFileSync(path.resolve(__dirname, './github.sync.ejs'), 'utf8');
|
|
44
|
-
const configContents = fs.readFileSync(`${dirPrefix}/${nangoConfigFile}`, 'utf8');
|
|
45
|
-
const configData = yaml.load(configContents);
|
|
46
|
-
const { integrations } = configData;
|
|
47
|
-
const { models } = configData;
|
|
48
|
-
const interfaceDefinitions = buildInterfaces(models, integrations, debug);
|
|
49
|
-
fs.writeFileSync(`${dirPrefix}/${TYPES_FILE_NAME}`, interfaceDefinitions.join('\n'));
|
|
50
|
-
if (debug) {
|
|
51
|
-
printDebug(`Interfaces from the ${nangoConfigFile} file written to ${TYPES_FILE_NAME}`);
|
|
52
|
-
}
|
|
53
|
-
// insert NangoSync types to the bottom of the file
|
|
54
|
-
const typesContent = fs.readFileSync(`${getNangoRootPath()}/${NangoSyncTypesFileLocation}`, 'utf8');
|
|
55
|
-
fs.writeFileSync(`${dirPrefix}/${TYPES_FILE_NAME}`, typesContent, { flag: 'a' });
|
|
56
|
-
if (debug) {
|
|
57
|
-
printDebug(`NangoSync types written to ${TYPES_FILE_NAME}`);
|
|
58
|
-
}
|
|
59
|
-
const allSyncNames = {};
|
|
60
|
-
for (let i = 0; i < Object.keys(integrations).length; i++) {
|
|
61
|
-
const providerConfigKey = Object.keys(integrations)[i];
|
|
62
|
-
if (debug) {
|
|
63
|
-
printDebug(`Generating ${providerConfigKey} integrations`);
|
|
64
|
-
}
|
|
65
|
-
const syncObject = integrations[providerConfigKey];
|
|
66
|
-
const syncNames = Object.keys(syncObject);
|
|
67
|
-
for (let k = 0; k < syncNames.length; k++) {
|
|
68
|
-
const syncName = syncNames[k];
|
|
69
|
-
if (allSyncNames[syncName] === undefined) {
|
|
70
|
-
allSyncNames[syncName] = true;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
console.log(chalk.red(`The sync name ${syncName} is duplicated in the ${nangoConfigFile} file. All sync names must be unique.`));
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
if (debug) {
|
|
77
|
-
printDebug(`Generating ${syncName} integration`);
|
|
78
|
-
}
|
|
79
|
-
const syncData = syncObject[syncName];
|
|
80
|
-
if (syncData.type !== SyncConfigType.ACTION && !syncData.returns) {
|
|
81
|
-
console.log(chalk.red(`The ${syncName} integration is missing a returns property for what models the sync returns. Make sure you have "returns" instead of "return"`));
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
const { returns: models, type = SyncConfigType.SYNC } = syncData;
|
|
85
|
-
const syncNameCamel = syncName
|
|
86
|
-
.split('-')
|
|
87
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
88
|
-
.join('');
|
|
89
|
-
let ejsTeamplateContents = '';
|
|
90
|
-
if (syncName === exampleSyncName && type === SyncConfigType.SYNC) {
|
|
91
|
-
ejsTeamplateContents = githubExampleTemplateContents;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
ejsTeamplateContents = type === SyncConfigType.SYNC ? syncTemplateContents : actionTemplateContents;
|
|
95
|
-
}
|
|
96
|
-
const rendered = ejs.render(ejsTeamplateContents, {
|
|
97
|
-
syncName: syncNameCamel,
|
|
98
|
-
interfaceFileName: TYPES_FILE_NAME.replace('.ts', ''),
|
|
99
|
-
interfaceNames: models
|
|
100
|
-
? models?.map((model) => {
|
|
101
|
-
const singularModel = model?.charAt(model.length - 1) === 's' ? model.slice(0, -1) : model;
|
|
102
|
-
return `${singularModel.charAt(0).toUpperCase()}${singularModel.slice(1)}`;
|
|
103
|
-
})
|
|
104
|
-
: [],
|
|
105
|
-
mappings: models
|
|
106
|
-
? models?.map((model) => {
|
|
107
|
-
const singularModel = model.charAt(model.length - 1) === 's' ? model.slice(0, -1) : model;
|
|
108
|
-
return {
|
|
109
|
-
name: model,
|
|
110
|
-
type: `${singularModel.charAt(0).toUpperCase()}${singularModel.slice(1)}`
|
|
111
|
-
};
|
|
112
|
-
})
|
|
113
|
-
: []
|
|
114
|
-
});
|
|
115
|
-
if (!fs.existsSync(`${dirPrefix}/${syncName}.ts`)) {
|
|
116
|
-
fs.writeFileSync(`${dirPrefix}/${syncName}.ts`, rendered);
|
|
117
|
-
if (debug) {
|
|
118
|
-
printDebug(`Created ${syncName}.ts file`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
if (debug) {
|
|
123
|
-
printDebug(`${syncName}.ts file already exists, so will not overwrite it.`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
console.log(chalk.green(`Integration files have been created`));
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Init
|
|
132
|
-
* If we're not currently in the nango-integrations directory create one
|
|
133
|
-
* and create an example nango.yaml file
|
|
134
|
-
*/
|
|
135
|
-
export const init = async (debug = false) => {
|
|
136
|
-
const data = {
|
|
137
|
-
integrations: {
|
|
138
|
-
'demo-github-integration': {
|
|
139
|
-
[exampleSyncName]: {
|
|
140
|
-
type: SyncConfigType.SYNC,
|
|
141
|
-
runs: 'every half hour',
|
|
142
|
-
returns: ['GithubIssue']
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
models: {
|
|
147
|
-
GithubIssue: {
|
|
148
|
-
id: 'integer',
|
|
149
|
-
owner: 'string',
|
|
150
|
-
repo: 'string',
|
|
151
|
-
issue_number: 'number',
|
|
152
|
-
title: 'string',
|
|
153
|
-
author: 'string',
|
|
154
|
-
author_id: 'string',
|
|
155
|
-
state: 'string',
|
|
156
|
-
date_created: 'date',
|
|
157
|
-
date_last_modified: 'date',
|
|
158
|
-
body: 'string'
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const yamlData = yaml.dump(data);
|
|
163
|
-
// if currently in the nango-integrations directory then don't create another one
|
|
164
|
-
const cwd = process.cwd();
|
|
165
|
-
const currentDirectorySplit = cwd.split('/');
|
|
166
|
-
const currentDirectory = currentDirectorySplit[currentDirectorySplit.length - 1];
|
|
167
|
-
let dirExists = false;
|
|
168
|
-
let inParentDirectory = true;
|
|
169
|
-
if (currentDirectory === NANGO_INTEGRATIONS_NAME) {
|
|
170
|
-
dirExists = true;
|
|
171
|
-
inParentDirectory = false;
|
|
172
|
-
if (debug) {
|
|
173
|
-
printDebug(`Currently in the ${NANGO_INTEGRATIONS_NAME} directory so the directory will not be created`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (fs.existsSync(`./${NANGO_INTEGRATIONS_NAME}`)) {
|
|
177
|
-
dirExists = true;
|
|
178
|
-
console.log(chalk.red(`The ${NANGO_INTEGRATIONS_NAME} directory already exists. You should run commands from within this directory`));
|
|
179
|
-
}
|
|
180
|
-
if (!dirExists) {
|
|
181
|
-
if (debug) {
|
|
182
|
-
printDebug(`Creating the nango integrations directory at ./${NANGO_INTEGRATIONS_NAME}`);
|
|
183
|
-
}
|
|
184
|
-
fs.mkdirSync(`./${NANGO_INTEGRATIONS_NAME}`);
|
|
185
|
-
}
|
|
186
|
-
const configFileLocation = inParentDirectory ? `./${NANGO_INTEGRATIONS_NAME}/${nangoConfigFile}` : `./${nangoConfigFile}`;
|
|
187
|
-
if (!fs.existsSync(configFileLocation)) {
|
|
188
|
-
if (debug) {
|
|
189
|
-
printDebug(`Creating the ${nangoConfigFile} file at ${configFileLocation}`);
|
|
190
|
-
}
|
|
191
|
-
fs.writeFileSync(configFileLocation, yamlData);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
if (debug) {
|
|
195
|
-
printDebug(`Nango config file already exists at ${configFileLocation} so not creating a new one`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const envFileLocation = inParentDirectory ? `./${NANGO_INTEGRATIONS_NAME}/.env` : './.env';
|
|
199
|
-
if (!fs.existsSync(envFileLocation)) {
|
|
200
|
-
if (debug) {
|
|
201
|
-
printDebug(`Creating the .env file at ${envFileLocation}`);
|
|
202
|
-
}
|
|
203
|
-
fs.writeFileSync(envFileLocation, `# Authenticates the CLI (get the keys in the dashboard's Projects Settings).
|
|
204
|
-
#NANGO_SECRET_KEY_DEV=xxxx-xxx-xxxx
|
|
205
|
-
#NANGO_SECRET_KEY_PROD=xxxx-xxx-xxxx
|
|
206
|
-
|
|
207
|
-
# Nango's instance URL (OSS: change to http://localhost:3003 or your instance URL).
|
|
208
|
-
NANGO_HOSTPORT=https://api.nango.dev # Default value
|
|
209
|
-
|
|
210
|
-
# How to handle CLI upgrades ("prompt", "auto" or "ignore").
|
|
211
|
-
NANGO_CLI_UPGRADE_MODE=prompt # Default value
|
|
212
|
-
|
|
213
|
-
# Whether to prompt before deployments.
|
|
214
|
-
NANGO_DEPLOY_AUTO_CONFIRM=false # Default value`);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
if (debug) {
|
|
218
|
-
printDebug(`.env file already exists at ${envFileLocation} so not creating a new one`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
await generate(debug, inParentDirectory);
|
|
222
|
-
console.log(chalk.green(`Nango integrations initialized!`));
|
|
223
|
-
};
|
|
224
|
-
const createModelFile = (notify = false) => {
|
|
225
|
-
const configContents = fs.readFileSync(`./${nangoConfigFile}`, 'utf8');
|
|
226
|
-
const configData = yaml.load(configContents);
|
|
227
|
-
const { models, integrations } = configData;
|
|
228
|
-
const interfaceDefinitions = buildInterfaces(models, integrations);
|
|
229
|
-
fs.writeFileSync(`./${TYPES_FILE_NAME}`, interfaceDefinitions.join('\n'));
|
|
230
|
-
// insert NangoSync types to the bottom of the file
|
|
231
|
-
const typesContent = fs.readFileSync(`${getNangoRootPath()}/${NangoSyncTypesFileLocation}`, 'utf8');
|
|
232
|
-
fs.writeFileSync(`./${TYPES_FILE_NAME}`, typesContent, { flag: 'a' });
|
|
233
|
-
if (notify) {
|
|
234
|
-
console.log(chalk.green(`The ${nangoConfigFile} was updated. The interface file (${TYPES_FILE_NAME}) was updated to reflect the updated config`));
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const getConfig = async (debug = false) => {
|
|
238
|
-
const config = await loadSimplifiedConfig('./');
|
|
239
|
-
if (!config) {
|
|
240
|
-
throw new Error(`Error loading the ${nangoConfigFile} file`);
|
|
241
|
-
}
|
|
242
|
-
if (debug) {
|
|
243
|
-
printDebug(`Config file file found`);
|
|
244
|
-
}
|
|
245
|
-
return config;
|
|
246
|
-
};
|
|
247
|
-
async function parseSecretKey(environment, debug = false) {
|
|
248
|
-
if (process.env['NANGO_SECRET_KEY_PROD'] && environment === 'prod') {
|
|
249
|
-
if (debug) {
|
|
250
|
-
printDebug(`Environment is set to prod, setting NANGO_SECRET_KEY to NANGO_SECRET_KEY_PROD.`);
|
|
251
|
-
}
|
|
252
|
-
process.env['NANGO_SECRET_KEY'] = process.env['NANGO_SECRET_KEY_PROD'];
|
|
253
|
-
}
|
|
254
|
-
if (process.env['NANGO_SECRET_KEY_DEV'] && environment === 'dev') {
|
|
255
|
-
if (debug) {
|
|
256
|
-
printDebug(`Environment is set to dev, setting NANGO_SECRET_KEY to NANGO_SECRET_KEY_DEV.`);
|
|
257
|
-
}
|
|
258
|
-
process.env['NANGO_SECRET_KEY'] = process.env['NANGO_SECRET_KEY_DEV'];
|
|
259
|
-
}
|
|
260
|
-
if (!process.env['NANGO_SECRET_KEY']) {
|
|
261
|
-
console.log(chalk.red(`NANGO_SECRET_KEY environment variable is not set. Please set it now`));
|
|
262
|
-
try {
|
|
263
|
-
const secretKey = await promptly.prompt('Secret Key: ');
|
|
264
|
-
if (secretKey) {
|
|
265
|
-
process.env['NANGO_SECRET_KEY'] = secretKey;
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
catch (error) {
|
|
272
|
-
console.log('Error occurred while trying to prompt for secret key:', error);
|
|
273
|
-
process.exit(1);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
export const deploy = async (options, environment, debug = false) => {
|
|
278
|
-
const { env, version, sync: optionalSyncName, autoConfirm } = options;
|
|
279
|
-
await verifyNecessaryFiles(autoConfirm);
|
|
280
|
-
await parseSecretKey(environment, debug);
|
|
281
|
-
if (!process.env['NANGO_HOSTPORT']) {
|
|
282
|
-
switch (env) {
|
|
283
|
-
case 'local':
|
|
284
|
-
process.env['NANGO_HOSTPORT'] = `http://localhost:${port}`;
|
|
285
|
-
break;
|
|
286
|
-
case 'staging':
|
|
287
|
-
process.env['NANGO_HOSTPORT'] = stagingHost;
|
|
288
|
-
break;
|
|
289
|
-
default:
|
|
290
|
-
process.env['NANGO_HOSTPORT'] = cloudHost;
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
if (debug) {
|
|
295
|
-
printDebug(`NANGO_HOSTPORT is set to ${process.env['NANGO_HOSTPORT']}.`);
|
|
296
|
-
printDebug(`Environment is set to ${environment}`);
|
|
297
|
-
}
|
|
298
|
-
await tsc(debug);
|
|
299
|
-
const config = await getConfig(debug);
|
|
300
|
-
const postData = packageIntegrationData(config, debug, optionalSyncName, version);
|
|
301
|
-
if (!postData) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
const url = process.env['NANGO_HOSTPORT'] + `/sync/deploy`;
|
|
305
|
-
const nangoYamlBody = localFileService.getNangoYamlFileContents('./');
|
|
306
|
-
if (process.env['NANGO_DEPLOY_AUTO_CONFIRM'] !== 'true' && !autoConfirm) {
|
|
307
|
-
const confirmationUrl = process.env['NANGO_HOSTPORT'] + `/sync/deploy/confirmation`;
|
|
308
|
-
try {
|
|
309
|
-
const response = await axios.post(confirmationUrl, { syncs: postData, reconcile: false, debug }, { headers: enrichHeaders(), httpsAgent: httpsAgent() });
|
|
310
|
-
console.log(JSON.stringify(response.data, null, 2));
|
|
311
|
-
const { newSyncs, deletedSyncs } = response.data;
|
|
312
|
-
for (const sync of newSyncs) {
|
|
313
|
-
const actionMessage = sync.connections === 0 || sync.auto_start === false
|
|
314
|
-
? 'The sync will be added to your Nango instance if you deploy.'
|
|
315
|
-
: `Nango will start syncing the corresponding data for ${sync.connections} existing connections.`;
|
|
316
|
-
console.log(chalk.yellow(`Sync "${sync.name}" is new. ${actionMessage}`));
|
|
317
|
-
}
|
|
318
|
-
for (const sync of deletedSyncs) {
|
|
319
|
-
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.`));
|
|
320
|
-
}
|
|
321
|
-
const confirmation = await promptly.confirm('Do you want to continue y/n?');
|
|
322
|
-
if (confirmation) {
|
|
323
|
-
await deploySyncs(url, { syncs: postData, nangoYamlBody, reconcile: true, debug });
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
console.log(chalk.red('Syncs/Actions were not deployed. Exiting'));
|
|
327
|
-
process.exit(0);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
catch (err) {
|
|
331
|
-
let errorMessage;
|
|
332
|
-
if (!err?.response?.data) {
|
|
333
|
-
const { message, stack, config: { method }, code, status } = err?.toJSON();
|
|
334
|
-
const errorObject = { message, stack, code, status, url, method };
|
|
335
|
-
errorMessage = JSON.stringify(errorObject, null, 2);
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
errorMessage = JSON.stringify(err.response.data, null, 2);
|
|
339
|
-
}
|
|
340
|
-
console.log(chalk.red(`Error deploying the syncs/actions with the following error: ${errorMessage}`));
|
|
341
|
-
process.exit(1);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
if (debug) {
|
|
346
|
-
printDebug(`Auto confirm is set so deploy will start without confirmation`);
|
|
347
|
-
}
|
|
348
|
-
await deploySyncs(url, { syncs: postData, nangoYamlBody, reconcile: true, debug });
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
async function deploySyncs(url, body) {
|
|
352
|
-
await axios
|
|
353
|
-
.post(url, body, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
|
|
354
|
-
.then((response) => {
|
|
355
|
-
const results = response.data;
|
|
356
|
-
if (results.length === 0) {
|
|
357
|
-
console.log(chalk.green(`Successfully removed the syncs/actions.`));
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
const nameAndVersions = results.map((result) => `${result.sync_name || result.name}@v${result.version}`);
|
|
361
|
-
console.log(chalk.green(`Successfully deployed the syncs/actions: ${nameAndVersions.join(', ')}!`));
|
|
362
|
-
}
|
|
363
|
-
})
|
|
364
|
-
.catch((err) => {
|
|
365
|
-
const errorMessage = JSON.stringify(err.response.data, null, 2);
|
|
366
|
-
console.log(chalk.red(`Error deploying the syncs/actions with the following error: ${errorMessage}`));
|
|
367
|
-
process.exit(1);
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
export const adminDeploy = async (environmentName, debug = false) => {
|
|
371
|
-
await verifyNecessaryFiles(false);
|
|
372
|
-
await parseSecretKey(environmentName, debug);
|
|
373
|
-
if (!process.env['NANGO_HOSTPORT']) {
|
|
374
|
-
switch (environmentName) {
|
|
375
|
-
case 'local':
|
|
376
|
-
process.env['NANGO_HOSTPORT'] = `http://localhost:${port}`;
|
|
377
|
-
break;
|
|
378
|
-
case 'staging':
|
|
379
|
-
process.env['NANGO_HOSTPORT'] = stagingHost;
|
|
380
|
-
break;
|
|
381
|
-
default:
|
|
382
|
-
process.env['NANGO_HOSTPORT'] = cloudHost;
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (debug) {
|
|
387
|
-
printDebug(`NANGO_HOSTPORT is set to ${process.env['NANGO_HOSTPORT']}.`);
|
|
388
|
-
printDebug(`Environment is set to ${environmentName}`);
|
|
389
|
-
}
|
|
390
|
-
await tsc(debug);
|
|
391
|
-
const config = await getConfig(debug);
|
|
392
|
-
const flowData = packageIntegrationData(config, debug);
|
|
393
|
-
if (!flowData) {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
const targetAccountUUID = await promptly.prompt('Input the account uuid to deploy to: ');
|
|
397
|
-
if (!targetAccountUUID) {
|
|
398
|
-
console.log(chalk.red('Account uuid is required. Exiting'));
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
const url = process.env['NANGO_HOSTPORT'] + `/admin/flow/deploy/pre-built`;
|
|
402
|
-
const nangoYamlBody = localFileService.getNangoYamlFileContents('./');
|
|
403
|
-
try {
|
|
404
|
-
await axios
|
|
405
|
-
.post(url, { targetAccountUUID, targetEnvironment: environmentName, config: flowData, nangoYamlBody }, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
|
|
406
|
-
.then(() => {
|
|
407
|
-
console.log(chalk.green(`Successfully deployed the syncs/actions to the users account.`));
|
|
408
|
-
})
|
|
409
|
-
.catch((err) => {
|
|
410
|
-
const errorMessage = JSON.stringify(err.response.data, null, 2);
|
|
411
|
-
console.log(chalk.red(`Error deploying the syncs/actions with the following error: ${errorMessage}`));
|
|
412
|
-
process.exit(1);
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
catch (e) {
|
|
416
|
-
console.log(e);
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
export const dryRun = async (options, environment, debug = false) => {
|
|
420
|
-
let syncName = '';
|
|
421
|
-
let connectionId, suppliedLastSyncDate, actionInput;
|
|
422
|
-
await parseSecretKey(environment, debug);
|
|
423
|
-
if (!process.env['NANGO_HOSTPORT']) {
|
|
424
|
-
if (debug) {
|
|
425
|
-
printDebug(`NANGO_HOSTPORT is not set. Setting the default to ${hostport}`);
|
|
426
|
-
}
|
|
427
|
-
process.env['NANGO_HOSTPORT'] = hostport;
|
|
428
|
-
}
|
|
429
|
-
if (debug) {
|
|
430
|
-
printDebug(`NANGO_HOSTPORT is set to ${process.env['NANGO_HOSTPORT']}`);
|
|
431
|
-
}
|
|
432
|
-
if (Object.keys(options).length > 0) {
|
|
433
|
-
({ sync: syncName, connectionId, lastSyncDate: suppliedLastSyncDate, input: actionInput } = options);
|
|
434
|
-
}
|
|
435
|
-
if (!syncName) {
|
|
436
|
-
console.log(chalk.red('Sync name is required'));
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
if (!connectionId) {
|
|
440
|
-
console.log(chalk.red('Connection id is required'));
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
const config = await getConfig(debug);
|
|
444
|
-
const providerConfigKey = config.find((config) => config.syncs.find((sync) => sync.name === syncName))?.providerConfigKey;
|
|
445
|
-
if (!providerConfigKey) {
|
|
446
|
-
console.log(chalk.red(`Provider config key not found, please check that the provider exists for this sync name: ${syncName}`));
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
const syncInfo = config.find((config) => config.syncs.find((sync) => sync.name === syncName))?.syncs.find((sync) => sync.name === syncName);
|
|
450
|
-
if (debug) {
|
|
451
|
-
printDebug(`Provider config key found to be ${providerConfigKey}`);
|
|
452
|
-
}
|
|
453
|
-
const nangoConnection = (await getConnection(providerConfigKey, connectionId, {
|
|
454
|
-
'Nango-Is-Sync': true,
|
|
455
|
-
'Nango-Is-Dry-Run': true
|
|
456
|
-
}, debug));
|
|
457
|
-
if (!nangoConnection) {
|
|
458
|
-
console.log(chalk.red('Connection not found'));
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (debug) {
|
|
462
|
-
printDebug(`Connection found with ${JSON.stringify(nangoConnection, null, 2)}`);
|
|
463
|
-
}
|
|
464
|
-
if (process.env['NANGO_HOSTPORT'] === cloudHost || process.env['NANGO_HOSTPORT'] === stagingHost) {
|
|
465
|
-
process.env['NANGO_CLOUD'] = 'true';
|
|
466
|
-
}
|
|
467
|
-
let lastSyncDate = null;
|
|
468
|
-
if (suppliedLastSyncDate) {
|
|
469
|
-
if (debug) {
|
|
470
|
-
printDebug(`Last sync date supplied as ${suppliedLastSyncDate}`);
|
|
471
|
-
}
|
|
472
|
-
lastSyncDate = new Date(suppliedLastSyncDate);
|
|
473
|
-
}
|
|
474
|
-
const result = await tsc(debug, syncName);
|
|
475
|
-
if (!result) {
|
|
476
|
-
console.log(chalk.red('The sync/action did not compile successfully. Exiting'));
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
let normalizedInput;
|
|
480
|
-
try {
|
|
481
|
-
normalizedInput = JSON.parse(actionInput);
|
|
482
|
-
}
|
|
483
|
-
catch (e) {
|
|
484
|
-
normalizedInput = actionInput;
|
|
485
|
-
}
|
|
486
|
-
const syncRun = new syncRunService({
|
|
487
|
-
writeToDb: false,
|
|
488
|
-
nangoConnection,
|
|
489
|
-
input: normalizedInput,
|
|
490
|
-
isAction: syncInfo?.type === SyncConfigType.ACTION,
|
|
491
|
-
syncId: 'abc',
|
|
492
|
-
activityLogId: -1,
|
|
493
|
-
syncJobId: -1,
|
|
494
|
-
syncName,
|
|
495
|
-
syncType: SyncType.INITIAL,
|
|
496
|
-
loadLocation: './',
|
|
497
|
-
debug
|
|
498
|
-
});
|
|
499
|
-
try {
|
|
500
|
-
const secretKey = process.env['NANGO_SECRET_KEY'];
|
|
501
|
-
const results = await syncRun.run(lastSyncDate, true, secretKey, process.env['NANGO_HOSTPORT']);
|
|
502
|
-
analytics.trackByEnvironmentId('sync:cli_dry_run_performed', nangoConnection.environment_id, {
|
|
503
|
-
connection_id: nangoConnection.id,
|
|
504
|
-
sync_name: syncName,
|
|
505
|
-
provider_config_key: providerConfigKey,
|
|
506
|
-
last_sync_date: lastSyncDate?.toISOString()
|
|
507
|
-
});
|
|
508
|
-
if (results) {
|
|
509
|
-
console.log(JSON.stringify(results, null, 2));
|
|
510
|
-
}
|
|
511
|
-
process.exit(0);
|
|
512
|
-
}
|
|
513
|
-
catch (e) {
|
|
514
|
-
process.exit(1);
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
export const tsc = async (debug = false, syncName) => {
|
|
518
|
-
const tsconfig = fs.readFileSync(`${getNangoRootPath()}/tsconfig.dev.json`, 'utf8');
|
|
519
|
-
const distDir = './dist';
|
|
520
|
-
if (!fs.existsSync(distDir)) {
|
|
521
|
-
if (debug) {
|
|
522
|
-
printDebug(`Creating ${distDir} directory`);
|
|
523
|
-
}
|
|
524
|
-
fs.mkdirSync(distDir);
|
|
525
|
-
}
|
|
526
|
-
if (!fs.existsSync(`./${TYPES_FILE_NAME}`)) {
|
|
527
|
-
if (debug) {
|
|
528
|
-
printDebug(`Creating ${TYPES_FILE_NAME} file`);
|
|
529
|
-
}
|
|
530
|
-
createModelFile();
|
|
531
|
-
}
|
|
532
|
-
const compiler = tsNode.create({
|
|
533
|
-
compilerOptions: JSON.parse(tsconfig).compilerOptions
|
|
534
|
-
});
|
|
535
|
-
if (debug) {
|
|
536
|
-
printDebug(`Compiler options: ${JSON.stringify(JSON.parse(tsconfig).compilerOptions, null, 2)}`);
|
|
537
|
-
}
|
|
538
|
-
const integrationFiles = syncName ? [`./${syncName}.ts`] : glob.sync(`./*.ts`);
|
|
539
|
-
let success = true;
|
|
540
|
-
const config = await getConfig();
|
|
541
|
-
for (const filePath of integrationFiles) {
|
|
542
|
-
try {
|
|
543
|
-
const providerConfiguration = config.find((config) => config.syncs.find((sync) => sync.name === path.basename(filePath, '.ts')));
|
|
544
|
-
const syncConfig = providerConfiguration?.syncs.find((sync) => sync.name === path.basename(filePath, '.ts'));
|
|
545
|
-
const type = syncConfig?.type || SyncConfigType.SYNC;
|
|
546
|
-
if (!nangoCallsAreUsedCorrectly(filePath, type)) {
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
const result = compiler.compile(fs.readFileSync(filePath, 'utf8'), filePath);
|
|
550
|
-
const jsFilePath = filePath.replace(/\/[^\/]*$/, `/dist/${path.basename(filePath.replace('.ts', '.js'))}`);
|
|
551
|
-
fs.writeFileSync(jsFilePath, result);
|
|
552
|
-
console.log(chalk.green(`Compiled "${filePath}" successfully`));
|
|
553
|
-
}
|
|
554
|
-
catch (error) {
|
|
555
|
-
console.error(`Error compiling "${filePath}":`);
|
|
556
|
-
console.error(error);
|
|
557
|
-
success = false;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
return success;
|
|
561
|
-
};
|
|
562
|
-
export const checkYamlMatchesTsFiles = async () => {
|
|
563
|
-
const config = await getConfig();
|
|
564
|
-
const syncNames = config.map((provider) => provider.syncs.map((sync) => sync.name)).flat();
|
|
565
|
-
const tsFiles = glob.sync(`./*.ts`);
|
|
566
|
-
const tsFileNames = tsFiles.filter((file) => !file.includes('models.ts')).map((file) => path.basename(file, '.ts'));
|
|
567
|
-
const missingSyncs = syncNames.filter((syncName) => !tsFileNames.includes(syncName));
|
|
568
|
-
if (missingSyncs.length > 0) {
|
|
569
|
-
console.log(chalk.red(`The following syncs are missing a corresponding .ts file: ${missingSyncs.join(', ')}`));
|
|
570
|
-
throw new Error('Syncs missing .ts files');
|
|
571
|
-
}
|
|
572
|
-
const extraSyncs = tsFileNames.filter((syncName) => !syncNames.includes(syncName));
|
|
573
|
-
if (extraSyncs.length > 0) {
|
|
574
|
-
console.log(chalk.red(`The following .ts files do not have a corresponding sync in the config: ${extraSyncs.join(', ')}`));
|
|
575
|
-
throw new Error('Extra .ts files');
|
|
576
|
-
}
|
|
577
|
-
return true;
|
|
578
|
-
};
|
|
579
|
-
const nangoCallsAreUsedCorrectly = (filePath, type = SyncConfigType.SYNC) => {
|
|
580
|
-
const code = fs.readFileSync(filePath, 'utf-8');
|
|
581
|
-
let areAwaited = true;
|
|
582
|
-
let usedCorrectly = true;
|
|
583
|
-
const ast = parser.parse(code, { sourceType: 'module', plugins: ['typescript'] });
|
|
584
|
-
const awaitMessage = (call, lineNumber) => console.log(chalk.red(`nango.${call}() calls must be awaited in "${filePath}:${lineNumber}". Not awaiting can lead to unexpected results.`));
|
|
585
|
-
const disallowedMessage = (call, lineNumber) => console.log(chalk.red(`nango.${call}() calls are not allowed in an action script. Please remove it at "${filePath}:${lineNumber}".`));
|
|
586
|
-
const nangoCalls = [
|
|
587
|
-
'batchSend',
|
|
588
|
-
'batchSave',
|
|
589
|
-
'batchDelete',
|
|
590
|
-
'log',
|
|
591
|
-
'getFieldMapping',
|
|
592
|
-
'setFieldMapping',
|
|
593
|
-
'getMetadata',
|
|
594
|
-
'setMetadata',
|
|
595
|
-
'get',
|
|
596
|
-
'post',
|
|
597
|
-
'put',
|
|
598
|
-
'patch',
|
|
599
|
-
'delete',
|
|
600
|
-
'getConnection',
|
|
601
|
-
'setLastSyncDate',
|
|
602
|
-
'getEnvironmentVariables'
|
|
603
|
-
];
|
|
604
|
-
const disallowedActionCalls = ['batchSend', 'batchSave', 'batchDelete', 'setLastSyncDate'];
|
|
605
|
-
const deprecatedCalls = {
|
|
606
|
-
batchSend: 'batchSave',
|
|
607
|
-
getFieldMapping: 'getMetadata',
|
|
608
|
-
setFieldMapping: 'setMetadata'
|
|
609
|
-
};
|
|
610
|
-
// @ts-ignore
|
|
611
|
-
traverse.default(ast, {
|
|
612
|
-
CallExpression(path) {
|
|
613
|
-
const lineNumber = path.node.loc?.start.line;
|
|
614
|
-
const callee = path.node.callee;
|
|
615
|
-
if (callee.object?.type === 'Identifier' && callee.object.name === 'nango' && callee.property?.type === 'Identifier') {
|
|
616
|
-
if (deprecatedCalls[callee.property.name]) {
|
|
617
|
-
console.warn(chalk.yellow(`nango.${callee.property.name}() used at line ${lineNumber} is deprecated. Use nango.${deprecatedCalls[callee.property.name]}() instead.`));
|
|
618
|
-
}
|
|
619
|
-
if (type === SyncConfigType.ACTION) {
|
|
620
|
-
if (disallowedActionCalls.includes(callee.property.name)) {
|
|
621
|
-
disallowedMessage(callee.property.name, lineNumber);
|
|
622
|
-
usedCorrectly = false;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (path.parent.type !== 'AwaitExpression') {
|
|
626
|
-
if (nangoCalls.includes(callee.property.name)) {
|
|
627
|
-
awaitMessage(callee.property.name, lineNumber);
|
|
628
|
-
areAwaited = false;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
return areAwaited && usedCorrectly;
|
|
635
|
-
};
|
|
636
|
-
export const tscWatch = async (debug = false) => {
|
|
637
|
-
const tsconfig = fs.readFileSync(`${getNangoRootPath()}/tsconfig.dev.json`, 'utf8');
|
|
638
|
-
const config = await getConfig();
|
|
639
|
-
const watchPath = [`./*.ts`, `./${nangoConfigFile}`];
|
|
640
|
-
if (debug) {
|
|
641
|
-
printDebug(`Watching ${watchPath.join(', ')}`);
|
|
642
|
-
}
|
|
643
|
-
const watcher = chokidar.watch(watchPath, {
|
|
644
|
-
ignoreInitial: false,
|
|
645
|
-
ignored: (filePath) => {
|
|
646
|
-
return filePath === TYPES_FILE_NAME;
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
const distDir = './dist';
|
|
650
|
-
if (!fs.existsSync(distDir)) {
|
|
651
|
-
if (debug) {
|
|
652
|
-
printDebug(`Creating ${distDir} directory`);
|
|
653
|
-
}
|
|
654
|
-
fs.mkdirSync(distDir);
|
|
655
|
-
}
|
|
656
|
-
if (!fs.existsSync(`./${TYPES_FILE_NAME}`)) {
|
|
657
|
-
if (debug) {
|
|
658
|
-
printDebug(`Creating ${TYPES_FILE_NAME} file`);
|
|
659
|
-
}
|
|
660
|
-
createModelFile();
|
|
661
|
-
}
|
|
662
|
-
watcher.on('add', (filePath) => {
|
|
663
|
-
if (filePath === nangoConfigFile) {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
compileFile(filePath);
|
|
667
|
-
});
|
|
668
|
-
watcher.on('unlink', (filePath) => {
|
|
669
|
-
if (filePath === nangoConfigFile) {
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
const jsFilePath = `./dist/${path.basename(filePath.replace('.ts', '.js'))}`;
|
|
673
|
-
fs.unlinkSync(jsFilePath);
|
|
674
|
-
});
|
|
675
|
-
watcher.on('change', (filePath) => {
|
|
676
|
-
if (filePath === nangoConfigFile) {
|
|
677
|
-
// config file changed, re-compile each ts file
|
|
678
|
-
const integrationFiles = glob.sync(`./*.ts`);
|
|
679
|
-
for (const file of integrationFiles) {
|
|
680
|
-
// strip the file to just the last part
|
|
681
|
-
const strippedFile = file.replace(/^.*[\\\/]/, '');
|
|
682
|
-
compileFile(strippedFile);
|
|
683
|
-
}
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
compileFile(filePath);
|
|
687
|
-
});
|
|
688
|
-
function compileFile(filePath) {
|
|
689
|
-
const compiler = tsNode.create({
|
|
690
|
-
compilerOptions: JSON.parse(tsconfig).compilerOptions
|
|
691
|
-
});
|
|
692
|
-
try {
|
|
693
|
-
const providerConfiguration = config.find((config) => config.syncs.find((sync) => sync.name === path.basename(filePath, '.ts')));
|
|
694
|
-
const syncConfig = providerConfiguration?.syncs.find((sync) => sync.name === path.basename(filePath, '.ts'));
|
|
695
|
-
const type = syncConfig?.type || SyncConfigType.SYNC;
|
|
696
|
-
if (!nangoCallsAreUsedCorrectly(filePath, type)) {
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
const result = compiler.compile(fs.readFileSync(filePath, 'utf8'), filePath);
|
|
700
|
-
const jsFilePath = `./dist/${path.basename(filePath.replace('.ts', '.js'))}`;
|
|
701
|
-
fs.writeFileSync(jsFilePath, result);
|
|
702
|
-
console.log(chalk.green(`Compiled ${filePath} successfully`));
|
|
703
|
-
}
|
|
704
|
-
catch (error) {
|
|
705
|
-
console.error(`Error compiling ${filePath}:`);
|
|
706
|
-
console.error(error);
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
export const configWatch = (debug = false) => {
|
|
712
|
-
const watchPath = `./${nangoConfigFile}`;
|
|
713
|
-
if (debug) {
|
|
714
|
-
printDebug(`Watching ${watchPath}`);
|
|
715
|
-
}
|
|
716
|
-
const watcher = chokidar.watch(watchPath, { ignoreInitial: true });
|
|
717
|
-
watcher.on('change', () => {
|
|
718
|
-
createModelFile(true);
|
|
719
|
-
});
|
|
720
|
-
};
|
|
721
|
-
let child;
|
|
722
|
-
process.on('SIGINT', () => {
|
|
723
|
-
if (child) {
|
|
724
|
-
const dockerDown = spawn('docker', ['compose', '-f', `${getNangoRootPath()}/docker/docker-compose.yaml`, '--project-directory', '.', 'down'], {
|
|
725
|
-
stdio: 'inherit'
|
|
726
|
-
});
|
|
727
|
-
dockerDown.on('exit', () => {
|
|
728
|
-
process.exit();
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
process.exit();
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
/**
|
|
736
|
-
* Docker Run
|
|
737
|
-
* @desc spawn a child process to run the docker compose located in the cli
|
|
738
|
-
* Look into https://www.npmjs.com/package/docker-compose to avoid dependency maybe?
|
|
739
|
-
*/
|
|
740
|
-
export const dockerRun = async (debug = false) => {
|
|
741
|
-
const cwd = process.cwd();
|
|
742
|
-
const args = ['compose', '-f', `${getNangoRootPath()}/docker/docker-compose.yaml`, '--project-directory', '.', 'up', '--build'];
|
|
743
|
-
if (debug) {
|
|
744
|
-
printDebug(`Running docker with args: ${args.join(' ')}`);
|
|
745
|
-
}
|
|
746
|
-
child = spawn('docker', args, {
|
|
747
|
-
cwd,
|
|
748
|
-
detached: false,
|
|
749
|
-
stdio: 'inherit'
|
|
750
|
-
});
|
|
751
|
-
await new Promise((resolve, reject) => {
|
|
752
|
-
child?.on('exit', (code) => {
|
|
753
|
-
if (code !== 0) {
|
|
754
|
-
reject(new Error(`Error with the nango docker containers, please check your containers using 'docker ps''`));
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
resolve(true);
|
|
758
|
-
});
|
|
759
|
-
child?.on('error', reject);
|
|
760
|
-
});
|
|
761
|
-
};
|
|
762
|
-
function packageIntegrationData(config, debug, version = '', optionalSyncName = '') {
|
|
763
|
-
const postData = [];
|
|
764
|
-
for (const integration of config) {
|
|
765
|
-
const { providerConfigKey } = integration;
|
|
766
|
-
let { syncs } = integration;
|
|
767
|
-
if (optionalSyncName) {
|
|
768
|
-
syncs = syncs.filter((sync) => sync.name === optionalSyncName);
|
|
769
|
-
}
|
|
770
|
-
for (const sync of syncs) {
|
|
771
|
-
const { name: syncName, runs = '', returns: models, models: model_schema, type = SyncConfigType.SYNC } = sync;
|
|
772
|
-
const { path: integrationFilePath, result: integrationFileResult } = localFileService.checkForIntegrationDistFile(syncName, './');
|
|
773
|
-
if (!integrationFileResult) {
|
|
774
|
-
console.log(chalk.red(`No integration file found for ${syncName} at ${integrationFilePath}. Skipping...`));
|
|
775
|
-
continue;
|
|
776
|
-
}
|
|
777
|
-
if (type !== SyncConfigType.SYNC && type !== SyncConfigType.ACTION) {
|
|
778
|
-
console.log(chalk.red(`The sync ${syncName} has an invalid type "${type}". The type must be either ${SyncConfigType.SYNC} or${SyncConfigType.ACTION}. Skipping...`));
|
|
779
|
-
}
|
|
780
|
-
if (type === SyncConfigType.SYNC && !runs) {
|
|
781
|
-
console.log(chalk.red(`The sync ${syncName} is missing the "runs" property. Skipping...`));
|
|
782
|
-
continue;
|
|
783
|
-
}
|
|
784
|
-
if (runs && type === SyncConfigType.SYNC) {
|
|
785
|
-
const { success, error } = getInterval(runs, new Date());
|
|
786
|
-
if (!success) {
|
|
787
|
-
console.log(chalk.red(`The sync ${syncName} has an issue with the sync interval "${runs}": ${error?.message}`));
|
|
788
|
-
return null;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
if (debug) {
|
|
792
|
-
printDebug(`Integration file found for ${syncName} at ${integrationFilePath}`);
|
|
793
|
-
}
|
|
794
|
-
const body = {
|
|
795
|
-
syncName,
|
|
796
|
-
providerConfigKey,
|
|
797
|
-
models,
|
|
798
|
-
version: version,
|
|
799
|
-
runs,
|
|
800
|
-
track_deletes: sync.track_deletes || false,
|
|
801
|
-
auto_start: sync.auto_start === false ? false : true,
|
|
802
|
-
attributes: sync.attributes || {},
|
|
803
|
-
type,
|
|
804
|
-
fileBody: {
|
|
805
|
-
js: localFileService.getIntegrationFile(syncName, './'),
|
|
806
|
-
ts: localFileService.getIntegrationTsFile(syncName, './')
|
|
807
|
-
},
|
|
808
|
-
model_schema: JSON.stringify(model_schema)
|
|
809
|
-
};
|
|
810
|
-
postData.push(body);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
return postData;
|
|
814
|
-
}
|
|
815
|
-
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../lib/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,QAAsB,MAAM,iBAAiB,CAAC;AAErD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAYhC,OAAO,EACH,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,QAAQ,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB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