nango 0.16.0-beta

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/entry.js ADDED
@@ -0,0 +1,89 @@
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;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,393 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Copyright (c) 2022 Nango, all rights reserved.
4
+ */
5
+ import { Command } from 'commander';
6
+ import axios from 'axios';
7
+ import chalk from 'chalk';
8
+ import figlet from 'figlet';
9
+ import fs from 'fs';
10
+ import path, { dirname } from 'path';
11
+ import { fileURLToPath } from 'url';
12
+ import yaml from 'js-yaml';
13
+ import ejs from 'ejs';
14
+ import glob from 'glob';
15
+ import byots from 'byots';
16
+ import { build } from 'esbuild';
17
+ import { spawn } from 'child_process';
18
+ import * as dotenv from 'dotenv';
19
+ import { loadSimplifiedConfig } from '@nangohq/shared';
20
+ import { init, run, tscWatch, configWatch } from './sync.js';
21
+ import { checkEnvVars, enrichHeaders, httpsAgent, getConnection, configFile, NANGO_INTEGRATIONS_LOCATION, buildInterfaces } from './utils.js';
22
+ const program = new Command();
23
+ let hostport = process.env['NANGO_HOSTPORT'] || 'http://localhost:3003';
24
+ const __filename = fileURLToPath(import.meta.url);
25
+ const __dirname = dirname(__filename);
26
+ if (hostport.slice(-1) === '/') {
27
+ hostport = hostport.slice(0, -1);
28
+ }
29
+ dotenv.config();
30
+ // Test from the package root (/packages/cli) with 'node dist/index.js'
31
+ program
32
+ .name('nango')
33
+ .description(`A CLI tool to configure Nango:\n- By defaults, the CLI assumes that you are running Nango on localhost:3003\n- For Nango Cloud: Set the NANGO_HOSTPORT & NANGO_SECRET_KEY env variables\n- For Self-Hosting: set the NANGO_HOSTPORT env variable`);
34
+ program.addHelpText('before', chalk.green(figlet.textSync('Nango CLI')));
35
+ program
36
+ .command('config:list')
37
+ .description('List all provider configurations.')
38
+ .action(async function () {
39
+ checkEnvVars();
40
+ const url = hostport + '/config';
41
+ await axios
42
+ .get(url, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
43
+ .then((res) => {
44
+ console.table(res.data['configs'].map((o) => {
45
+ return { unique_key: o.unique_key, provider: o.provider, created: o.created_at };
46
+ }));
47
+ })
48
+ .catch((err) => {
49
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
50
+ });
51
+ });
52
+ program
53
+ .command('config:get')
54
+ .description('Get an provider configuration.')
55
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (chosen by you upon creating this provider configuration).')
56
+ .action(async function () {
57
+ checkEnvVars();
58
+ const url = hostport + `/config/${this.args[0]}`;
59
+ await axios
60
+ .get(url, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
61
+ .then((res) => {
62
+ console.table(res.data['config']);
63
+ })
64
+ .catch((err) => {
65
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
66
+ });
67
+ });
68
+ program
69
+ .command('config:create')
70
+ .description('Create an provider configuration.')
71
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (choose a friendly name, e.g. hubspot_staging).')
72
+ .argument('<provider>', 'The provider of the 3rd-party API, must match the template keys in https://nango.dev/oauth-providers (e.g. hubspot).')
73
+ .argument('<oauth_client_id>', 'The OAuth Client ID obtained from the API provider.')
74
+ .argument('<oauth_client_secret>', 'The OAuth Client Secret obtained from the API provider.')
75
+ .argument('<oauth_scopes>', 'The OAuth Scopes obtained from the API provider (comma-separated).')
76
+ .action(async function () {
77
+ checkEnvVars();
78
+ const body = {
79
+ provider_config_key: this.args[0],
80
+ provider: this.args[1],
81
+ oauth_client_id: this.args[2],
82
+ oauth_client_secret: this.args[3],
83
+ oauth_scopes: this.args[4]
84
+ };
85
+ const url = hostport + `/config`;
86
+ await axios
87
+ .post(url, body, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
88
+ .then((_) => {
89
+ console.log('\n\n✅ Successfully created a new provider configuration!\n\n');
90
+ })
91
+ .catch((err) => {
92
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
93
+ });
94
+ });
95
+ program
96
+ .command('config:edit')
97
+ .description('Edit an provider configuration.')
98
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (choose a friendly name, e.g. hubspot_staging).')
99
+ .argument('<provider>', 'The provider of the 3rd-party API, must match the template keys in https://nango.dev/oauth-providers (e.g. hubspot).')
100
+ .argument('<oauth_client_id>', 'The OAuth Client ID obtained from the API provider.')
101
+ .argument('<oauth_client_secret>', 'The OAuth Client Secret obtained from the API provider.')
102
+ .argument('<oauth_scopes>', 'The OAuth Scopes obtained from the API provider (comma-separated).')
103
+ .action(async function () {
104
+ checkEnvVars();
105
+ const body = {
106
+ provider_config_key: this.args[0],
107
+ provider: this.args[1],
108
+ oauth_client_id: this.args[2],
109
+ oauth_client_secret: this.args[3],
110
+ oauth_scopes: this.args[4]
111
+ };
112
+ const url = hostport + `/config`;
113
+ await axios
114
+ .put(url, body, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
115
+ .then((_) => {
116
+ console.log('\n\n✅ Successfully edited an existing provider configuration!\n\n');
117
+ })
118
+ .catch((err) => {
119
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
120
+ });
121
+ });
122
+ program
123
+ .command('config:delete')
124
+ .description('Delete an provider configuration.')
125
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (chosen by you upon creating this provider configuration).')
126
+ .action(async function () {
127
+ checkEnvVars();
128
+ const url = hostport + `/config/${this.args[0]}`;
129
+ await axios
130
+ .delete(url, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
131
+ .then((_) => {
132
+ console.log('\n\n✅ Successfully deleted the provider configuration!\n\n');
133
+ })
134
+ .catch((err) => {
135
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
136
+ });
137
+ });
138
+ program
139
+ .command('connection:get')
140
+ .description('Get a connection with credentials.')
141
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (chosen by you upon creating this provider configuration).')
142
+ .argument('<connection_id>', 'The ID of the Connection.')
143
+ .action(async function () {
144
+ checkEnvVars();
145
+ const [providerConfigKey, connectionId] = this.args;
146
+ if (!providerConfigKey) {
147
+ console.log(chalk.red('Please provide a provider config key.'));
148
+ }
149
+ if (!connectionId) {
150
+ console.log(chalk.red('Please provide a connection ID.'));
151
+ }
152
+ const connection = await getConnection(providerConfigKey, connectionId);
153
+ console.log(connection);
154
+ });
155
+ program
156
+ .command('token:get')
157
+ .description('Get an access token.')
158
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (chosen by you upon creating this provider configuration).')
159
+ .argument('<connection_id>', 'The ID of the Connection.')
160
+ .action(async function () {
161
+ checkEnvVars();
162
+ const url = hostport + `/connection/${this.args[1]}`;
163
+ await axios
164
+ .get(url, { params: { provider_config_key: this.args[0] }, headers: enrichHeaders(), httpsAgent: httpsAgent() })
165
+ .then((response) => {
166
+ switch (response.data.credentials.type) {
167
+ case 'OAUTH2':
168
+ console.table({ token: response.data.credentials.access_token });
169
+ break;
170
+ case 'OAUTH1':
171
+ console.table(`token:${response.data.credentials.oauth_token}\nsecret:${response.data.credentials.oauth_token_secret}`);
172
+ break;
173
+ default:
174
+ throw new Error(`Unrecognized OAuth type '${response.data.credentials.type}' in stored credentials.`);
175
+ }
176
+ })
177
+ .catch((err) => {
178
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
179
+ });
180
+ });
181
+ program
182
+ .command('connection:list')
183
+ .description('List connections without credentials.')
184
+ .action(async function () {
185
+ checkEnvVars();
186
+ const url = hostport + `/connection`;
187
+ await axios
188
+ .get(url, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
189
+ .then((res) => {
190
+ console.table(res.data['connections']);
191
+ })
192
+ .catch((err) => {
193
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
194
+ });
195
+ });
196
+ program
197
+ .command('connection:delete')
198
+ .description('Delete a connection.')
199
+ .argument('<provider_config_key>', 'The unique key of the provider configuration (chosen by you upon creating this provider configuration).')
200
+ .argument('<connection_id>', 'The ID of the Connection.')
201
+ .action(async function () {
202
+ checkEnvVars();
203
+ const url = hostport + `/connection/${this.args[1]}`;
204
+ await axios
205
+ .delete(url, { params: { provider_config_key: this.args[0] }, headers: enrichHeaders(), httpsAgent: httpsAgent() })
206
+ .then((_) => {
207
+ console.log('\n\n✅ Successfully deleted the connection!\n\n');
208
+ })
209
+ .catch((err) => {
210
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
211
+ });
212
+ });
213
+ program
214
+ .command('init')
215
+ .alias('i')
216
+ .description('Initialize a new Nango project')
217
+ .action(() => {
218
+ init();
219
+ });
220
+ program
221
+ .command('generate')
222
+ .alias('g')
223
+ .description('Generate a new Nango integration')
224
+ .action(() => {
225
+ const templateContents = fs.readFileSync(path.resolve(__dirname, './integration.ejs'), 'utf8');
226
+ const cwd = process.cwd();
227
+ const configContents = fs.readFileSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/${configFile}`), 'utf8');
228
+ const configData = yaml.load(configContents);
229
+ const { integrations } = configData;
230
+ const { models } = configData;
231
+ const interfaceDefinitions = buildInterfaces(models);
232
+ fs.writeFileSync(`${NANGO_INTEGRATIONS_LOCATION}/models.ts`, interfaceDefinitions.join('\n'));
233
+ for (let i = 0; i < Object.keys(integrations).length; i++) {
234
+ const providerConfigKey = Object.keys(integrations)[i];
235
+ const syncObject = integrations[providerConfigKey];
236
+ const syncNames = Object.keys(syncObject);
237
+ for (let k = 0; k < syncNames.length; k++) {
238
+ const syncName = syncNames[k];
239
+ const syncData = syncObject[syncName];
240
+ const { returns: models } = syncData;
241
+ const syncNameCamel = syncName
242
+ .split('-')
243
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
244
+ .join('');
245
+ const rendered = ejs.render(templateContents, {
246
+ syncName: syncNameCamel,
247
+ interfaceNames: models.map((model) => {
248
+ const singularModel = model?.charAt(model.length - 1) === 's' ? model.slice(0, -1) : model;
249
+ return `${singularModel.charAt(0).toUpperCase()}${singularModel.slice(1)}`;
250
+ }),
251
+ mappings: models.map((model) => {
252
+ const singularModel = model.charAt(model.length - 1) === 's' ? model.slice(0, -1) : model;
253
+ return {
254
+ name: model,
255
+ type: `${singularModel.charAt(0).toUpperCase()}${singularModel.slice(1)}`
256
+ };
257
+ })
258
+ });
259
+ if (!fs.existsSync(`${NANGO_INTEGRATIONS_LOCATION}/${syncName}.ts`)) {
260
+ fs.writeFileSync(`${NANGO_INTEGRATIONS_LOCATION}/${syncName}.ts`, rendered);
261
+ }
262
+ }
263
+ }
264
+ console.log(chalk.green(`Integration files have been created`));
265
+ });
266
+ program
267
+ .command('tsc')
268
+ .description('Work locally to add integration code')
269
+ .action(() => {
270
+ const cwd = process.cwd();
271
+ const integrationFiles = glob.sync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/*.ts`));
272
+ for (const file of integrationFiles) {
273
+ const tsFileContent = fs.readFileSync(file, 'utf-8');
274
+ const compilerOptions = {
275
+ target: byots.ScriptTarget.ES2022,
276
+ module: byots.ModuleKind.ES2022
277
+ };
278
+ const result = byots.transpileModule(tsFileContent, {
279
+ compilerOptions,
280
+ fileName: file
281
+ });
282
+ const fileNameWithExt = path.basename(file);
283
+ const integrationName = path.parse(fileNameWithExt).name;
284
+ const jsFileContent = result.outputText;
285
+ const distDir = path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist`);
286
+ if (!fs.existsSync(distDir)) {
287
+ fs.mkdirSync(distDir);
288
+ }
289
+ fs.writeFileSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${integrationName}.js`), jsFileContent);
290
+ }
291
+ });
292
+ program
293
+ .command('tsc:watch')
294
+ .description('Watch tsc files while developing. Set --no-compile-interfaces to disable watching the config file')
295
+ .option('--no-compile-interfaces', `Watch the ${configFile} and recompile the interfaces on change`, true)
296
+ .action(async function () {
297
+ const { compileInterfaces } = this.opts();
298
+ tscWatch();
299
+ if (compileInterfaces) {
300
+ configWatch();
301
+ }
302
+ });
303
+ program
304
+ .command('dev')
305
+ .alias('develop')
306
+ .alias('watch')
307
+ .description('Work locally to add integration code')
308
+ .action(() => {
309
+ const cwd = process.cwd();
310
+ tscWatch();
311
+ configWatch();
312
+ // look into
313
+ // https://www.npmjs.com/package/docker-compose
314
+ spawn('docker', ['compose', '-f', 'node_modules/nango/docker/docker-compose.yaml', '--project-directory', '.', 'up', '--build'], {
315
+ cwd,
316
+ detached: false,
317
+ stdio: 'inherit'
318
+ });
319
+ });
320
+ program
321
+ .command('deploy')
322
+ .alias('d')
323
+ .description('Deploy a Nango integration')
324
+ .action(async () => {
325
+ const cwd = process.cwd();
326
+ const integrationFiles = glob.sync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/*.ts`));
327
+ for (const file of integrationFiles) {
328
+ const tsFileContent = fs.readFileSync(file, 'utf-8');
329
+ const compilerOptions = {
330
+ target: byots.ScriptTarget.ES2022,
331
+ module: byots.ModuleKind.ES2022
332
+ };
333
+ const result = byots.transpileModule(tsFileContent, {
334
+ compilerOptions,
335
+ fileName: file
336
+ });
337
+ const jsFileContent = result.outputText;
338
+ // not needed
339
+ const minifiedResult = await build({
340
+ stdin: {
341
+ contents: jsFileContent,
342
+ resolveDir: __dirname,
343
+ sourcefile: file.replace(/\.ts$/, '.js'),
344
+ loader: 'js'
345
+ },
346
+ write: false,
347
+ allowOverwrite: true,
348
+ minify: true
349
+ });
350
+ const snippet = minifiedResult?.outputFiles[0]?.text;
351
+ const fileNameWithExt = path.basename(file);
352
+ const integrationName = path.parse(fileNameWithExt).name;
353
+ // write the file to the integration folder
354
+ fs.writeFileSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/${integrationName}.js`), jsFileContent);
355
+ const body = {
356
+ integrationName,
357
+ snippet,
358
+ provider: 'github' // TODO, grab this from the yaml config
359
+ };
360
+ const url = hostport + `/sync-config`;
361
+ await axios
362
+ .post(url, body, { headers: enrichHeaders(), httpsAgent: httpsAgent() })
363
+ .then((_) => {
364
+ console.log('\n\n✅ Successfully created a new sync configuration!\n\n');
365
+ })
366
+ .catch((err) => {
367
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
368
+ });
369
+ }
370
+ });
371
+ program
372
+ .command('sync:config.check')
373
+ .alias('scc')
374
+ .description('Verify the parsed sync config and output the object for verification')
375
+ .action(async () => {
376
+ const cwd = process.cwd();
377
+ const config = loadSimplifiedConfig(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/${configFile}`));
378
+ console.log(chalk.green(JSON.stringify(config, null, 2)));
379
+ });
380
+ program
381
+ .command('sync:run')
382
+ .alias('sr')
383
+ .description('Run the sync process to help with debugging')
384
+ .option('-s, --sync <syncName>', 'The name of the sync (e.g. account-sync).')
385
+ .option('-p, --provider <provider_config_key>', 'The unique key of the provider configuration (chosen by you upon creating this provider configuration).')
386
+ .option('-c, --connection <connection_id>', 'The ID of the Connection.')
387
+ .option('-l, --lastSyncDate [lastSyncDate]', 'Optional: last sync date to retrieve records greater than this date')
388
+ .action(async function () {
389
+ checkEnvVars();
390
+ run(this.args, this.opts());
391
+ });
392
+ program.parse();
393
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MA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AAuB,EAAE,2CAA2C,CAAC;KAC5E,MAAM,CAAC,sCAAsC,EAAE,yGAAyG,CAAC;KACzJ,MAAM,CAAC,kCAAkC,EAAE,2BAA2B,CAAC;KACvE,MAAM,CAAC,mCAAmC,EAAE,qEAAqE,CAAC;KAClH,MAAM,CAAC,KAAK;IACT,YAAY,EAAE,CAAC;IACf,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { NangoSync, NangoHelper } from '@nangohq/node';
2
+ import { <%= interfaceNames.join(', ') %> } from './models';
3
+
4
+ class <%= syncName %> extends NangoSync {
5
+ override async fetchData(nango: NangoHelper): Promise<{<% for (let i = 0; i < mappings.length; i++) { %><%= mappings[i].name %>: <%= mappings[i].type %>[]<% if (i !== mappings.length - 1) { %>, <% } %><% } %>}> {
6
+ const providerConfigKey = '<%= providerConfigKey %>';
7
+ // Rest of the integration code goes here.
8
+ }
9
+ }
10
+
11
+ export default <%= syncName %>;
@@ -0,0 +1,35 @@
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 ADDED
@@ -0,0 +1,12 @@
1
+ interface RunArgs {
2
+ sync: string;
3
+ provider: string;
4
+ connection: string;
5
+ lastSyncDate?: string;
6
+ }
7
+ export declare const init: () => void;
8
+ export declare const verifyAndChangeDistFilesToJs: () => void;
9
+ export declare const run: (args: string[], options: RunArgs) => Promise<void>;
10
+ export declare const tscWatch: () => void;
11
+ export declare const configWatch: () => void;
12
+ export {};
package/dist/sync.js ADDED
@@ -0,0 +1,198 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import yaml from 'js-yaml';
4
+ import chalk from 'chalk';
5
+ import chokidar from 'chokidar';
6
+ import * as tsNode from 'ts-node';
7
+ import * as dotenv from 'dotenv';
8
+ import { Nango, loadNangoConfig, getIntegrationClass, getServerBaseUrl, getLastSyncDate, syncDataService } from '@nangohq/shared';
9
+ import { getConnection, configFile, NANGO_INTEGRATIONS_LOCATION, buildInterfaces } from './utils.js';
10
+ dotenv.config();
11
+ export const init = () => {
12
+ const data = {
13
+ integrations: {
14
+ 'github-prod': {
15
+ 'github-users': {
16
+ runs: 'every hour',
17
+ returns: ['users']
18
+ },
19
+ 'github-issues': {
20
+ runs: 'every half hour',
21
+ returns: ['issues']
22
+ }
23
+ },
24
+ 'asana-dev': {
25
+ 'asana-projects': {
26
+ runs: 'every hour',
27
+ returns: ['projects']
28
+ }
29
+ }
30
+ },
31
+ models: {
32
+ issues: {
33
+ id: 'integer',
34
+ title: 'char',
35
+ description: 'char',
36
+ status: 'char',
37
+ author: {
38
+ avatar_url: 'char'
39
+ }
40
+ },
41
+ projects: {
42
+ id: 'integer',
43
+ type: 'char'
44
+ },
45
+ users: {
46
+ id: 'integer',
47
+ name: 'char'
48
+ }
49
+ }
50
+ };
51
+ const yamlData = yaml.dump(data);
52
+ if (!fs.existsSync(NANGO_INTEGRATIONS_LOCATION)) {
53
+ fs.mkdirSync(NANGO_INTEGRATIONS_LOCATION);
54
+ }
55
+ fs.writeFileSync(`${NANGO_INTEGRATIONS_LOCATION}/${configFile}`, yamlData);
56
+ console.log(chalk.green(`${configFile} file has been created`));
57
+ };
58
+ export const verifyAndChangeDistFilesToJs = () => {
59
+ const cwd = process.cwd();
60
+ const distFiles = fs.readdirSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist`));
61
+ distFiles.forEach((file) => {
62
+ if (file.endsWith('.mjs')) {
63
+ fs.renameSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${file}`), path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${file.replace('.mjs', '.js')}`));
64
+ }
65
+ });
66
+ };
67
+ export const run = async (args, options) => {
68
+ verifyAndChangeDistFilesToJs();
69
+ let syncName, providerConfigKey, connectionId, suppliedLastSyncDate;
70
+ if (args.length > 0) {
71
+ [syncName, providerConfigKey, connectionId, suppliedLastSyncDate] = args;
72
+ }
73
+ if (Object.keys(options).length > 0) {
74
+ ({ sync: syncName, provider: providerConfigKey, connection: connectionId, lastSyncDate: suppliedLastSyncDate } = options);
75
+ }
76
+ if (!syncName) {
77
+ console.log(chalk.red('Sync name is required'));
78
+ return;
79
+ }
80
+ if (!providerConfigKey) {
81
+ console.log(chalk.red('Provider config key is required'));
82
+ return;
83
+ }
84
+ if (!connectionId) {
85
+ console.log(chalk.red('Connection id is required'));
86
+ return;
87
+ }
88
+ const cwd = process.cwd();
89
+ const config = loadNangoConfig(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/${configFile}`));
90
+ let lastSyncDate;
91
+ if (suppliedLastSyncDate) {
92
+ lastSyncDate = new Date(suppliedLastSyncDate);
93
+ }
94
+ if (config?.integrations?.[providerConfigKey]?.[syncName] &&
95
+ fs.existsSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.js`))) {
96
+ const syncData = config?.integrations[providerConfigKey]?.[syncName];
97
+ // to load a module without having to edit the type in the package.json
98
+ // edit the file to be a mjs then rename it back
99
+ fs.renameSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.js`), path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.mjs`));
100
+ const integrationClass = await getIntegrationClass(syncName, path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.mjs`) + `?v=${Math.random().toString(36).substring(3)}`);
101
+ const nango = new Nango({
102
+ host: getServerBaseUrl(),
103
+ connectionId: String(connectionId),
104
+ providerConfigKey: String(providerConfigKey),
105
+ isSync: true
106
+ });
107
+ try {
108
+ const nangoConnection = (await getConnection(providerConfigKey, connectionId));
109
+ if (!lastSyncDate) {
110
+ lastSyncDate = (await getLastSyncDate(nangoConnection?.id, syncName));
111
+ }
112
+ if (lastSyncDate instanceof Date && !isNaN(lastSyncDate.getTime())) {
113
+ nango.setLastSyncDate(lastSyncDate);
114
+ }
115
+ const userDefinedResults = await integrationClass.fetchData(nango);
116
+ console.log(JSON.stringify(userDefinedResults, null, 2));
117
+ fs.renameSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.mjs`), path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.js`));
118
+ const { returns: models } = syncData;
119
+ for (const model of models) {
120
+ if (userDefinedResults[model]) {
121
+ const { isUnique, nonUniqueKey } = syncDataService.verifyUniqueKeysAreUnique(userDefinedResults[model]);
122
+ if (!isUnique) {
123
+ console.log(chalk.red(`The ${model} model does not have unique id keys! The repeated key is ${nonUniqueKey}. Please resolve this before running the sync on the server.`));
124
+ }
125
+ }
126
+ }
127
+ process.exit(0);
128
+ }
129
+ catch (error) {
130
+ console.error(error);
131
+ fs.renameSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.mjs`), path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist/${syncName}.js`));
132
+ process.exit(1);
133
+ }
134
+ }
135
+ else {
136
+ console.log(chalk.red('Sync not found'));
137
+ }
138
+ };
139
+ export const tscWatch = () => {
140
+ const cwd = process.cwd();
141
+ const tsconfig = fs.readFileSync('./node_modules/nango/tsconfig.dev.json', 'utf8');
142
+ const watchPath = `${NANGO_INTEGRATIONS_LOCATION}/*.ts`;
143
+ const watcher = chokidar.watch(watchPath, {
144
+ ignoreInitial: false,
145
+ ignored: (filePath) => {
146
+ const rawNangoIntegrationLocation = NANGO_INTEGRATIONS_LOCATION.replace('./', '');
147
+ return filePath === `${rawNangoIntegrationLocation}/models.ts`;
148
+ }
149
+ });
150
+ const distDir = path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/dist`);
151
+ if (!fs.existsSync(distDir)) {
152
+ fs.mkdirSync(distDir);
153
+ }
154
+ const compiler = tsNode.create({
155
+ compilerOptions: JSON.parse(tsconfig).compilerOptions
156
+ });
157
+ watcher.on('add', (filePath) => {
158
+ compileFiile(filePath);
159
+ });
160
+ watcher.on('change', (filePath) => {
161
+ compileFiile(filePath);
162
+ });
163
+ function compileFiile(filePath) {
164
+ try {
165
+ const result = compiler.compile(fs.readFileSync(filePath, 'utf8'), filePath);
166
+ const jsFilePath = path.join(path.dirname(filePath), path.basename(filePath, '.ts') + '.js');
167
+ const rawNangoIntegrationLocation = NANGO_INTEGRATIONS_LOCATION.replace('./', '');
168
+ const distJSFilePath = jsFilePath.replace(rawNangoIntegrationLocation, `${rawNangoIntegrationLocation}/dist`);
169
+ fs.writeFileSync(distJSFilePath, result);
170
+ console.log(chalk.green(`Compiled ${filePath} successfully`));
171
+ }
172
+ catch (error) {
173
+ console.error(`Error compiling ${filePath}:`);
174
+ console.error(error);
175
+ return;
176
+ }
177
+ }
178
+ };
179
+ export const configWatch = () => {
180
+ const watchPath = `${NANGO_INTEGRATIONS_LOCATION}/${configFile}`;
181
+ const watcher = chokidar.watch(watchPath, { ignoreInitial: true });
182
+ watcher.on('add', (filePath) => {
183
+ buildInterface(filePath);
184
+ });
185
+ watcher.on('change', (filePath) => {
186
+ buildInterface(filePath);
187
+ });
188
+ function buildInterface(filePath) {
189
+ const cwd = process.cwd();
190
+ const configContents = fs.readFileSync(path.resolve(cwd, `${NANGO_INTEGRATIONS_LOCATION}/${configFile}`), 'utf8');
191
+ const configData = yaml.load(configContents);
192
+ const { models } = configData;
193
+ const interfaces = buildInterfaces(models);
194
+ fs.writeFileSync(`${NANGO_INTEGRATIONS_LOCATION}/models.ts`, interfaces.join('\n'));
195
+ console.log(chalk.green(`${filePath} was updated. The interface file (${NANGO_INTEGRATIONS_LOCATION}/models.ts) was updated to reflect the updated config`));
196
+ }
197
+ };
198
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../lib/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,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,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClI,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAErG,MAAM,CAAC,MAAM,EAAE,CAAC;AAShB,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE;IACrB,MAAM,IAAI,GAAgB;QACtB,YAAY,EAAE;YACV,aAAa,EA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;IACN,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import https from 'https';
3
+ import type { NangoModel } from '@nangohq/shared';
4
+ export declare const configFile = "nango.yaml";
5
+ export declare const NANGO_INTEGRATIONS_LOCATION: string;
6
+ export declare function checkEnvVars(): void;
7
+ export declare function getConnection(providerConfigKey: string, connectionId: string): Promise<any>;
8
+ export declare function enrichHeaders(headers?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
9
+ export declare function httpsAgent(): https.Agent;
10
+ export declare function getFieldType(rawField: string | NangoModel): string;
11
+ export declare function buildInterfaces(models: NangoModel): (string | undefined)[];
package/dist/utils.js ADDED
@@ -0,0 +1,130 @@
1
+ import https from 'https';
2
+ import axios from 'axios';
3
+ import * as dotenv from 'dotenv';
4
+ dotenv.config();
5
+ export const configFile = 'nango.yaml';
6
+ export const NANGO_INTEGRATIONS_LOCATION = process.env['NANGO_INTEGRATIONS_LOCATION'] || './nango-integrations';
7
+ let hostport = process.env['NANGO_HOSTPORT'] || 'http://localhost:3003';
8
+ const cloudHost = 'https://api.nango.dev';
9
+ const stagingHost = 'https://nango-cloud-staging.onrender.com';
10
+ if (hostport.slice(-1) === '/') {
11
+ hostport = hostport.slice(0, -1);
12
+ }
13
+ export function checkEnvVars() {
14
+ if (hostport === 'http://localhost:3003') {
15
+ console.log(`Assuming you are running Nango on localhost:3003 because you did not set the NANGO_HOSTPORT env var.\n\n`);
16
+ }
17
+ else if (hostport === cloudHost || hostport === stagingHost) {
18
+ if (!process.env['NANGO_SECRET_KEY']) {
19
+ console.log(`Assuming you are using Nango Cloud but your are lacking the NANGO_SECRET_KEY env var.`);
20
+ }
21
+ else if (hostport === cloudHost) {
22
+ console.log(`Assuming you are using Nango Cloud (because you set the NANGO_HOSTPORT env var to https://api.nango.dev).`);
23
+ }
24
+ else if (hostport === stagingHost) {
25
+ console.log(`Assuming you are using Nango Cloud (because you set the NANGO_HOSTPORT env var to https://api.staging.nango.dev).`);
26
+ }
27
+ }
28
+ else {
29
+ console.log(`Assuming you are self-hosting Nango (becauses you set the NANGO_HOSTPORT env var to ${hostport}).`);
30
+ }
31
+ }
32
+ export async function getConnection(providerConfigKey, connectionId) {
33
+ checkEnvVars();
34
+ const url = hostport + `/connection/${connectionId}`;
35
+ return await axios
36
+ .get(url, { params: { provider_config_key: providerConfigKey }, headers: enrichHeaders(), httpsAgent: httpsAgent() })
37
+ .then((res) => {
38
+ return res.data;
39
+ })
40
+ .catch((err) => {
41
+ console.log(`❌ ${err.response?.data.error || JSON.stringify(err)}`);
42
+ });
43
+ }
44
+ export function enrichHeaders(headers = {}) {
45
+ if ((process.env['NANGO_HOSTPORT'] === cloudHost || process.env['NANGO_HOSTPORT'] === stagingHost) && process.env['NANGO_SECRET_KEY']) {
46
+ // For Nango Cloud (unified)
47
+ headers['Authorization'] = 'Bearer ' + process.env['NANGO_SECRET_KEY'];
48
+ }
49
+ else if (process.env['NANGO_SECRET_KEY']) {
50
+ // For Nango OSS
51
+ headers['Authorization'] = 'Basic ' + Buffer.from(process.env['NANGO_SECRET_KEY'] + ':').toString('base64');
52
+ }
53
+ headers['Accept-Encoding'] = 'application/json';
54
+ return headers;
55
+ }
56
+ export function httpsAgent() {
57
+ return new https.Agent({
58
+ rejectUnauthorized: false
59
+ });
60
+ }
61
+ export function getFieldType(rawField) {
62
+ if (typeof rawField === 'string') {
63
+ let field = rawField;
64
+ let hasNull = false;
65
+ let hasUndefined = false;
66
+ let tsType = '';
67
+ if (field.indexOf('null') !== -1) {
68
+ field = field.replace(/\s*\|\s*null\s*/g, '');
69
+ hasNull = true;
70
+ }
71
+ if (field.indexOf('undefined') !== -1) {
72
+ field = field.replace(/\s*\|\s*undefined\s*/g, '');
73
+ hasUndefined = true;
74
+ }
75
+ switch (field) {
76
+ case 'boolean':
77
+ case 'bool':
78
+ tsType = 'boolean';
79
+ break;
80
+ case 'string':
81
+ tsType = 'string';
82
+ break;
83
+ case 'char':
84
+ tsType = 'string';
85
+ break;
86
+ case 'integer':
87
+ case 'int':
88
+ case 'number':
89
+ tsType = 'number';
90
+ break;
91
+ case 'date':
92
+ tsType = 'Date';
93
+ break;
94
+ }
95
+ if (hasNull) {
96
+ tsType = `${tsType} | null`;
97
+ }
98
+ if (hasUndefined) {
99
+ tsType = `${tsType} | undefined`;
100
+ }
101
+ return tsType;
102
+ }
103
+ else {
104
+ const nestedFields = Object.keys(rawField)
105
+ .map((fieldName) => ` ${fieldName}: ${getFieldType(rawField[fieldName])};`)
106
+ .join('\n');
107
+ return `{\n${nestedFields}\n}`;
108
+ }
109
+ }
110
+ export function buildInterfaces(models) {
111
+ const interfaceDefinitions = Object.keys(models).map((modelName) => {
112
+ if (modelName.charAt(0) === '_') {
113
+ return;
114
+ }
115
+ const fields = models[modelName];
116
+ const singularModelName = modelName.charAt(modelName.length - 1) === 's' ? modelName.slice(0, -1) : modelName;
117
+ const interfaceName = `${singularModelName.charAt(0).toUpperCase()}${singularModelName.slice(1)}`;
118
+ const fieldDefinitions = Object.keys(fields)
119
+ .map((fieldName) => {
120
+ const fieldModel = fields[fieldName];
121
+ const fieldType = getFieldType(fieldModel);
122
+ return ` ${fieldName}: ${fieldType};`;
123
+ })
124
+ .join('\n');
125
+ const interfaceDefinition = `export interface ${interfaceName} {\n${fieldDefinitions}\n}\n`;
126
+ return interfaceDefinition;
127
+ });
128
+ return interfaceDefinitions;
129
+ }
130
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAA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CAAC;AAChC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "nango",
3
+ "version": "0.16.0-beta",
4
+ "description": "Nango's CLI tool.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": "./dist/index.js",
8
+ "keywords": [],
9
+ "author": "bastien@nango.dev",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/NangoHQ/nango",
13
+ "directory": "packages/cli"
14
+ },
15
+ "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY",
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "copyfiles": "copyfiles -u 1 lib/*.ejs dist",
19
+ "postbuild": "npm run copyfiles",
20
+ "dev": "npm run copyfiles && tsc -w"
21
+ },
22
+ "dependencies": {
23
+ "@nangohq/shared": "^0.17.0",
24
+ "axios": "^1.2.0",
25
+ "byots": "^5.0.0-dev.20221103.1.34",
26
+ "chokidar": "^3.5.3",
27
+ "commander": "^10.0.1",
28
+ "copyfiles": "^2.4.1",
29
+ "dotenv": "^16.0.3",
30
+ "ejs": "^3.1.9",
31
+ "esbuild": "^0.17.19",
32
+ "figlet": "^1.6.0",
33
+ "js-yaml": "^4.1.0",
34
+ "memfs": "^3.5.1",
35
+ "ora": "^6.3.1",
36
+ "ts-node": "^10.9.1",
37
+ "typescript": "^5.0.4",
38
+ "webpack": "^5.82.1"
39
+ },
40
+ "devDependencies": {
41
+ "@types/commander": "^2.12.2",
42
+ "@types/ejs": "^3.1.2",
43
+ "@types/figlet": "^1.5.6",
44
+ "@types/glob": "^8.1.0",
45
+ "@types/node": "^20.1.4"
46
+ },
47
+ "engines": {
48
+ "node": ">=16.7"
49
+ },
50
+ "files": [
51
+ "dist/**/*",
52
+ "!**/*.json",
53
+ "README.md"
54
+ ]
55
+ }