nango 0.69.43 → 0.69.44
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/cli.d.ts +0 -9
- package/dist/cli.js +0 -210
- package/dist/cli.js.map +1 -1
- package/dist/index.js +70 -228
- package/dist/index.js.map +1 -1
- package/dist/migrations/toZeroYaml.js +2 -2
- package/dist/migrations/toZeroYaml.js.map +1 -1
- package/dist/services/docs.service.js +4 -6
- package/dist/services/docs.service.js.map +1 -1
- package/dist/services/dryrun.service.d.ts +1 -3
- package/dist/services/dryrun.service.js +22 -73
- package/dist/services/dryrun.service.js.map +1 -1
- package/dist/services/model.service.js +8 -0
- package/dist/services/model.service.js.map +1 -1
- package/dist/services/test.service.js +2 -2
- package/dist/services/test.service.js.map +1 -1
- package/dist/services/test.service.unit.cli-test.js +8 -1
- package/dist/services/test.service.unit.cli-test.js.map +1 -1
- package/dist/services/verification.service.d.ts +4 -9
- package/dist/services/verification.service.js +14 -80
- package/dist/services/verification.service.js.map +1 -1
- package/dist/sync.unit.cli-test.js +0 -326
- package/dist/sync.unit.cli-test.js.map +1 -1
- package/dist/templates/sync-test-template.ejs +42 -10
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/zeroYaml/compile.d.ts +2 -2
- package/dist/zeroYaml/compile.js +6 -6
- package/dist/zeroYaml/compile.js.map +1 -1
- package/dist/zeroYaml/compile.unit.cli-test.js +3 -3
- package/dist/zeroYaml/compile.unit.cli-test.js.map +1 -1
- package/dist/zeroYaml/definitions.d.ts +17 -13
- package/dist/zeroYaml/definitions.js +98 -56
- package/dist/zeroYaml/definitions.js.map +1 -1
- package/dist/zeroYaml/deploy.js +5 -9
- package/dist/zeroYaml/deploy.js.map +1 -1
- package/dist/zeroYaml/dev.js +2 -2
- package/dist/zeroYaml/dev.js.map +1 -1
- package/dist/zeroYaml/init.js +2 -2
- package/dist/zeroYaml/init.js.map +1 -1
- package/dist/zeroYaml/json-schema.d.ts +14 -0
- package/dist/zeroYaml/json-schema.js +44 -0
- package/dist/zeroYaml/json-schema.js.map +1 -0
- package/example/package.json +1 -1
- package/package.json +7 -7
- package/dist/services/deploy.service.d.ts +0 -33
- package/dist/services/deploy.service.js +0 -467
- package/dist/services/deploy.service.js.map +0 -1
- package/dist/services/deploy.service.unit.cli-test.d.ts +0 -1
- package/dist/services/deploy.service.unit.cli-test.js +0 -88
- package/dist/services/deploy.service.unit.cli-test.js.map +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
1
|
export declare const getVersionOutput: () => string;
|
|
2
|
-
export declare function generate({ fullPath, debug }: {
|
|
3
|
-
fullPath: string;
|
|
4
|
-
debug?: boolean;
|
|
5
|
-
}): void;
|
|
6
|
-
export declare function tscWatch({ fullPath, debug, watchConfigFile }: {
|
|
7
|
-
fullPath: string;
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
watchConfigFile: boolean;
|
|
10
|
-
}): void;
|
package/dist/cli.js
CHANGED
|
@@ -1,219 +1,9 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path, { dirname } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
1
|
import chalk from 'chalk';
|
|
5
|
-
import chokidar from 'chokidar';
|
|
6
2
|
import * as dotenv from 'dotenv';
|
|
7
|
-
import ejs from 'ejs';
|
|
8
|
-
import { getProviderConfigurationFromPath, nangoConfigFile } from '@nangohq/nango-yaml';
|
|
9
|
-
import { TYPES_FILE_NAME, exampleSyncName } from './constants.js';
|
|
10
|
-
import { compileAllFiles, compileSingleFile, getFileToCompile } from './services/compile.service.js';
|
|
11
|
-
import { loadYamlAndGenerate } from './services/model.service.js';
|
|
12
|
-
import { getLayoutMode } from './utils/layoutMode.js';
|
|
13
|
-
import { getNangoRootPath, printDebug } from './utils.js';
|
|
14
3
|
import { NANGO_VERSION } from './version.js';
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
const __dirname = dirname(__filename);
|
|
17
4
|
dotenv.config();
|
|
18
5
|
export const getVersionOutput = () => {
|
|
19
6
|
const version = NANGO_VERSION;
|
|
20
7
|
return `${chalk.green('Nango CLI version:')} ${version}`;
|
|
21
8
|
};
|
|
22
|
-
export function generate({ fullPath, debug = false }) {
|
|
23
|
-
const syncTemplateContents = fs.readFileSync(path.resolve(__dirname, './templates/sync.ejs'), 'utf8');
|
|
24
|
-
const actionTemplateContents = fs.readFileSync(path.resolve(__dirname, './templates/action.ejs'), 'utf8');
|
|
25
|
-
const githubExampleTemplateContents = fs.readFileSync(path.resolve(__dirname, './templates/github.sync.ejs'), 'utf8');
|
|
26
|
-
const onEventTemplateContents = fs.readFileSync(path.resolve(__dirname, './templates/on-event.ejs'), 'utf8');
|
|
27
|
-
const parsed = loadYamlAndGenerate({ fullPath, debug });
|
|
28
|
-
if (!parsed) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const allSyncNames = {};
|
|
32
|
-
for (const integration of parsed.integrations) {
|
|
33
|
-
const { syncs, actions, onEventScripts, providerConfigKey } = integration;
|
|
34
|
-
if (onEventScripts) {
|
|
35
|
-
const type = 'on-event';
|
|
36
|
-
for (const name of Object.values(onEventScripts).flat()) {
|
|
37
|
-
const rendered = ejs.render(onEventTemplateContents, {
|
|
38
|
-
interfaceFileName: TYPES_FILE_NAME.replace('.ts', '')
|
|
39
|
-
});
|
|
40
|
-
const stripped = rendered.replace(/^\s+/, '');
|
|
41
|
-
if (!fs.existsSync(path.resolve(fullPath, `${providerConfigKey}/${type}s/${name}.ts`))) {
|
|
42
|
-
fs.mkdirSync(path.resolve(fullPath, `${providerConfigKey}/${type}s`), { recursive: true });
|
|
43
|
-
fs.writeFileSync(path.resolve(fullPath, `${providerConfigKey}/${type}s/${name}.ts`), stripped);
|
|
44
|
-
if (debug) {
|
|
45
|
-
printDebug(`Created ${name}.ts file`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
if (debug) {
|
|
50
|
-
printDebug(`${name}.ts file already exists, so will not overwrite it.`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
for (const flow of [...syncs, ...actions]) {
|
|
56
|
-
const { name, type, output, input } = flow;
|
|
57
|
-
const layoutMode = getLayoutMode({ fullPath, providerConfigKey, scriptName: name, type });
|
|
58
|
-
const uniqueName = layoutMode === 'root' ? name : `${providerConfigKey}-${name}`;
|
|
59
|
-
if (allSyncNames[uniqueName] === undefined) {
|
|
60
|
-
// a sync and an action within the same provider cannot have the same name
|
|
61
|
-
allSyncNames[uniqueName] = true;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
console.log(chalk.red(`The ${type} name ${name} is duplicated in the ${nangoConfigFile} file. All sync and action names must be unique.`));
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
if (fs.existsSync(path.resolve(fullPath, `${name}.ts`)) || fs.existsSync(path.resolve(fullPath, `${providerConfigKey}/${type}s/${name}.ts`))) {
|
|
68
|
-
if (debug) {
|
|
69
|
-
printDebug(`${name}.ts file already exists, so will not overwrite it.`);
|
|
70
|
-
}
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (debug) {
|
|
74
|
-
printDebug(`Generating ${name} integration in layout mode ${layoutMode}`);
|
|
75
|
-
}
|
|
76
|
-
const flowNameCamel = name
|
|
77
|
-
.split('-')
|
|
78
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
79
|
-
.join('');
|
|
80
|
-
let ejsTemplateContents = '';
|
|
81
|
-
if (name === exampleSyncName && type === 'sync') {
|
|
82
|
-
ejsTemplateContents = githubExampleTemplateContents;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
ejsTemplateContents = type === 'sync' ? syncTemplateContents : actionTemplateContents;
|
|
86
|
-
}
|
|
87
|
-
const models = (output ? [...output, input] : [input]).filter(Boolean);
|
|
88
|
-
const rendered = ejs.render(ejsTemplateContents, {
|
|
89
|
-
syncName: flowNameCamel,
|
|
90
|
-
interfacePath: layoutMode === 'root' ? './' : '../../',
|
|
91
|
-
interfaceFileName: TYPES_FILE_NAME.replace('.ts', ''),
|
|
92
|
-
output: output && output.length > 0 ? output.join(' | ') : null,
|
|
93
|
-
input: input,
|
|
94
|
-
modelNames: models.join(', '),
|
|
95
|
-
hasWebhook: type === 'sync' && flow.webhookSubscriptions && flow.webhookSubscriptions.length > 0
|
|
96
|
-
});
|
|
97
|
-
const stripped = rendered.replace(/^\s+/, '');
|
|
98
|
-
if (layoutMode === 'root') {
|
|
99
|
-
fs.writeFileSync(path.resolve(fullPath, `${name}.ts`), stripped);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
fs.mkdirSync(path.resolve(fullPath, `${providerConfigKey}/${type}s`), { recursive: true });
|
|
103
|
-
fs.writeFileSync(path.resolve(fullPath, `${providerConfigKey}/${type}s/${name}.ts`), stripped);
|
|
104
|
-
}
|
|
105
|
-
if (debug) {
|
|
106
|
-
console.log(chalk.green(`Created ${name}.ts file`));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function showCompilationMessage(failedFiles) {
|
|
112
|
-
if (failedFiles.size === 0) {
|
|
113
|
-
console.log(chalk.green('Compilation success! Watching files…'));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
export function tscWatch({ fullPath, debug = false, watchConfigFile }) {
|
|
117
|
-
const tsconfig = fs.readFileSync(path.resolve(getNangoRootPath(), 'tsconfig.dev.json'), 'utf8');
|
|
118
|
-
const watchPath = ['./**/*.ts'];
|
|
119
|
-
if (watchConfigFile) {
|
|
120
|
-
watchPath.push(`./${nangoConfigFile}`);
|
|
121
|
-
}
|
|
122
|
-
if (debug) {
|
|
123
|
-
printDebug(`Watching ${watchPath.join(', ')}`);
|
|
124
|
-
}
|
|
125
|
-
const watcher = chokidar.watch(watchPath, {
|
|
126
|
-
ignoreInitial: false,
|
|
127
|
-
ignored: (filePath) => {
|
|
128
|
-
const relativePath = path.relative(__dirname, filePath);
|
|
129
|
-
return relativePath.includes('node_modules') || path.basename(filePath) === TYPES_FILE_NAME || relativePath.includes('.nango');
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
const distDir = path.join(fullPath, 'dist');
|
|
133
|
-
if (!fs.existsSync(distDir)) {
|
|
134
|
-
if (debug) {
|
|
135
|
-
printDebug(`Creating ${distDir} directory`);
|
|
136
|
-
}
|
|
137
|
-
fs.mkdirSync(distDir);
|
|
138
|
-
}
|
|
139
|
-
// First parsing of the config file
|
|
140
|
-
let parsed = loadYamlAndGenerate({ fullPath, debug });
|
|
141
|
-
const failedFiles = new Set();
|
|
142
|
-
watcher.on('add', (filePath) => {
|
|
143
|
-
async function onAdd() {
|
|
144
|
-
if (debug) {
|
|
145
|
-
printDebug(`Added ${filePath}`);
|
|
146
|
-
}
|
|
147
|
-
if (filePath === nangoConfigFile || !parsed) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const success = await compileSingleFile({
|
|
151
|
-
fullPath,
|
|
152
|
-
file: getFileToCompile({ fullPath, filePath }),
|
|
153
|
-
tsconfig,
|
|
154
|
-
parsed,
|
|
155
|
-
debug
|
|
156
|
-
});
|
|
157
|
-
if (success) {
|
|
158
|
-
failedFiles.delete(filePath);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
failedFiles.add(filePath);
|
|
162
|
-
}
|
|
163
|
-
showCompilationMessage(failedFiles);
|
|
164
|
-
}
|
|
165
|
-
void onAdd();
|
|
166
|
-
});
|
|
167
|
-
watcher.on('change', (filePath) => {
|
|
168
|
-
async function onChange() {
|
|
169
|
-
if (debug) {
|
|
170
|
-
printDebug(`Changed ${filePath}`);
|
|
171
|
-
}
|
|
172
|
-
if (filePath === nangoConfigFile) {
|
|
173
|
-
parsed = loadYamlAndGenerate({ fullPath, debug });
|
|
174
|
-
if (!parsed) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const { failedFiles: newFailedFiles } = await compileAllFiles({ fullPath, debug });
|
|
178
|
-
failedFiles.clear();
|
|
179
|
-
for (const file of newFailedFiles) {
|
|
180
|
-
failedFiles.add(file);
|
|
181
|
-
}
|
|
182
|
-
showCompilationMessage(failedFiles);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (!parsed) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const success = await compileSingleFile({ fullPath, file: getFileToCompile({ fullPath, filePath }), parsed, debug });
|
|
189
|
-
if (success) {
|
|
190
|
-
failedFiles.delete(filePath);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
failedFiles.add(filePath);
|
|
194
|
-
}
|
|
195
|
-
showCompilationMessage(failedFiles);
|
|
196
|
-
}
|
|
197
|
-
void onChange();
|
|
198
|
-
});
|
|
199
|
-
watcher.on('unlink', (filePath) => {
|
|
200
|
-
if (debug) {
|
|
201
|
-
printDebug(`Unlinked ${filePath}`);
|
|
202
|
-
}
|
|
203
|
-
if (filePath === nangoConfigFile || !parsed) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const providerConfiguration = getProviderConfigurationFromPath({ filePath, parsed });
|
|
207
|
-
const baseName = path.basename(filePath, '.ts');
|
|
208
|
-
const fileName = providerConfiguration ? `${baseName}-${providerConfiguration.providerConfigKey}.js` : `${baseName}.js`;
|
|
209
|
-
const jsFilePath = `./dist/${fileName}`;
|
|
210
|
-
failedFiles.delete(filePath);
|
|
211
|
-
try {
|
|
212
|
-
fs.unlinkSync(jsFilePath);
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
console.log(chalk.red(`Error deleting ${jsFilePath}`));
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
9
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../lib/cli.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../lib/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAW,EAAE;IACzC,MAAM,OAAO,GAAG,aAAa,CAAC;IAC9B,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,OAAO,EAAE,CAAC;AAC7D,CAAC,CAAC"}
|