nango 0.59.12 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/index.js +103 -22
  2. package/dist/index.js.map +1 -1
  3. package/dist/migrations/toZeroYaml.d.ts +50 -0
  4. package/dist/migrations/toZeroYaml.js +969 -0
  5. package/dist/migrations/toZeroYaml.js.map +1 -0
  6. package/dist/migrations/toZeroYaml.unit.test.d.ts +1 -0
  7. package/dist/migrations/toZeroYaml.unit.test.js +298 -0
  8. package/dist/migrations/toZeroYaml.unit.test.js.map +1 -0
  9. package/dist/services/dryrun.service.d.ts +3 -1
  10. package/dist/services/dryrun.service.js +77 -23
  11. package/dist/services/dryrun.service.js.map +1 -1
  12. package/dist/services/model.service.d.ts +1 -1
  13. package/dist/services/model.service.js +4 -3
  14. package/dist/services/model.service.js.map +1 -1
  15. package/dist/services/model.service.unit.test.js +2 -2
  16. package/dist/services/model.service.unit.test.js.map +1 -1
  17. package/dist/services/sdk.js +2 -1
  18. package/dist/services/sdk.js.map +1 -1
  19. package/dist/services/sdk.service.unit.test.js +2 -1
  20. package/dist/services/sdk.service.unit.test.js.map +1 -1
  21. package/dist/services/verification.service.js +2 -1
  22. package/dist/services/verification.service.js.map +1 -1
  23. package/dist/tests/helpers.js +2 -2
  24. package/dist/tests/helpers.js.map +1 -1
  25. package/dist/types.d.ts +1 -0
  26. package/dist/utils/result.d.ts +1 -17
  27. package/dist/utils/result.js +4 -0
  28. package/dist/utils/result.js.map +1 -1
  29. package/dist/version.d.ts +1 -1
  30. package/dist/version.js +1 -1
  31. package/dist/version.js.map +1 -1
  32. package/dist/zeroYaml/compile.d.ts +36 -0
  33. package/dist/zeroYaml/compile.js +305 -0
  34. package/dist/zeroYaml/compile.js.map +1 -0
  35. package/dist/zeroYaml/compile.unit.cli-test.d.ts +1 -0
  36. package/dist/zeroYaml/compile.unit.cli-test.js +34 -0
  37. package/dist/zeroYaml/compile.unit.cli-test.js.map +1 -0
  38. package/dist/zeroYaml/constants.d.ts +17 -0
  39. package/dist/zeroYaml/constants.js +60 -0
  40. package/dist/zeroYaml/constants.js.map +1 -0
  41. package/dist/zeroYaml/definitions.d.ts +25 -0
  42. package/dist/zeroYaml/definitions.js +142 -0
  43. package/dist/zeroYaml/definitions.js.map +1 -0
  44. package/dist/zeroYaml/definitions.unit.test.d.ts +1 -0
  45. package/dist/zeroYaml/definitions.unit.test.js +105 -0
  46. package/dist/zeroYaml/definitions.unit.test.js.map +1 -0
  47. package/dist/zeroYaml/deploy.d.ts +7 -0
  48. package/dist/zeroYaml/deploy.js +426 -0
  49. package/dist/zeroYaml/deploy.js.map +1 -0
  50. package/dist/zeroYaml/dev.d.ts +4 -0
  51. package/dist/zeroYaml/dev.js +295 -0
  52. package/dist/zeroYaml/dev.js.map +1 -0
  53. package/dist/zeroYaml/init.d.ts +7 -0
  54. package/dist/zeroYaml/init.js +98 -0
  55. package/dist/zeroYaml/init.js.map +1 -0
  56. package/dist/zeroYaml/zodToNango.d.ts +3 -0
  57. package/dist/zeroYaml/zodToNango.js +113 -0
  58. package/dist/zeroYaml/zodToNango.js.map +1 -0
  59. package/dist/zeroYaml/zodToNango.unit.test.d.ts +1 -0
  60. package/dist/zeroYaml/zodToNango.unit.test.js +77 -0
  61. package/dist/zeroYaml/zodToNango.unit.test.js.map +1 -0
  62. package/example/.env.example +16 -0
  63. package/example/.nango/.gitkeep +0 -0
  64. package/example/github/actions/createIssue.ts +39 -0
  65. package/example/github/on-events/pre-connection-deletion.ts +9 -0
  66. package/example/github/syncs/fetchIssues.ts +93 -0
  67. package/example/index.ts +3 -0
  68. package/example/package.json +13 -0
  69. package/example/tsconfig.json +30 -0
  70. package/package.json +27 -24
File without changes
@@ -0,0 +1,39 @@
1
+ import { createAction } from 'nango';
2
+ import { z } from 'zod';
3
+
4
+ const issueSchema = z.object({
5
+ id: z.string(),
6
+ owner: z.string(),
7
+ repo: z.string(),
8
+ issue_number: z.number(),
9
+ title: z.string(),
10
+ state: z.string(),
11
+ author: z.string(),
12
+ author_id: z.number(),
13
+ body: z.string(),
14
+ date_created: z.string(),
15
+ date_last_modified: z.string()
16
+ });
17
+
18
+ const action = createAction({
19
+ description: `Create an issue in GitHub`,
20
+ version: '1.0.0',
21
+ endpoint: { method: 'POST', path: '/example/github/issues', group: 'Issues' },
22
+ input: issueSchema,
23
+ output: z.void(),
24
+
25
+ // Action execution
26
+ exec: async (nango, input) => {
27
+ await nango.proxy({
28
+ endpoint: '/repos/NangoHQ/interactive-demo/issues',
29
+ data: {
30
+ title: `[demo] ${input.title}`,
31
+ body: `This issue was created automatically using Nango Action.`,
32
+ labels: ['automatic']
33
+ }
34
+ });
35
+ }
36
+ });
37
+
38
+ export type NangoActionLocal = Parameters<(typeof action)['exec']>[0];
39
+ export default action;
@@ -0,0 +1,9 @@
1
+ import { createOnEvent } from 'nango';
2
+
3
+ export default createOnEvent({
4
+ event: 'pre-connection-deletion',
5
+ description: 'This script is executed before a connection is deleted',
6
+ exec: async (nango) => {
7
+ await nango.log('Executed');
8
+ }
9
+ });
@@ -0,0 +1,93 @@
1
+ import { createSync } from 'nango';
2
+ import { z } from 'zod';
3
+
4
+ const LIMIT = 100;
5
+ const issueSchema = z.object({
6
+ id: z.string(),
7
+ owner: z.string(),
8
+ repo: z.string(),
9
+ issue_number: z.number(),
10
+ title: z.string(),
11
+ state: z.string(),
12
+ author: z.string(),
13
+ author_id: z.number(),
14
+ body: z.string(),
15
+ date_created: z.string(),
16
+ date_last_modified: z.string()
17
+ });
18
+ type GithubIssue = z.infer<typeof issueSchema>;
19
+
20
+ const sync = createSync({
21
+ description: `Fetches the Github issues from all a user's repositories.`,
22
+ version: '1.0.0',
23
+ endpoints: [{ method: 'GET', path: '/example/github/issues', group: 'Issues' }],
24
+ frequency: 'every hour',
25
+ autoStart: true,
26
+ syncType: 'full',
27
+ trackDeletes: true,
28
+
29
+ metadata: z.void(),
30
+ models: {
31
+ GithubIssue: issueSchema
32
+ },
33
+
34
+ // Sync execution
35
+ exec: async (nango) => {
36
+ const repos = await getAllRepositories(nango);
37
+
38
+ for (const repo of repos) {
39
+ const proxyConfig = {
40
+ endpoint: `/repos/${repo.owner.login}/${repo.name}/issues`,
41
+ paginate: {
42
+ limit: LIMIT
43
+ }
44
+ };
45
+ for await (const issueBatch of nango.paginate(proxyConfig)) {
46
+ const issues = issueBatch.filter((issue) => !('pull_request' in issue));
47
+
48
+ const mappedIssues: GithubIssue[] = issues.map((issue) => ({
49
+ id: issue.id,
50
+ owner: repo.owner.login,
51
+ repo: repo.name,
52
+ issue_number: issue.number,
53
+ title: issue.title,
54
+ state: issue.state,
55
+ author: issue.user.login,
56
+ author_id: issue.user.id,
57
+ body: issue.body,
58
+ date_created: issue.created_at,
59
+ date_last_modified: issue.updated_at
60
+ }));
61
+
62
+ if (mappedIssues.length > 0) {
63
+ await nango.batchSave(mappedIssues, 'GithubIssue');
64
+ await nango.log(`Sent ${mappedIssues.length} issues from ${repo.owner.login}/${repo.name}`);
65
+ }
66
+ }
67
+ }
68
+ },
69
+
70
+ // Webhook handler
71
+ onWebhook: async (nango, payload) => {
72
+ await nango.log('This is a webhook script', payload);
73
+ }
74
+ });
75
+
76
+ export type NangoSyncLocal = Parameters<(typeof sync)['exec']>[0];
77
+ export default sync;
78
+
79
+ async function getAllRepositories(nango: NangoSyncLocal): Promise<any[]> {
80
+ const records: any[] = [];
81
+ const proxyConfig = {
82
+ endpoint: '/user/repos',
83
+ paginate: {
84
+ limit: LIMIT
85
+ }
86
+ };
87
+
88
+ for await (const recordBatch of nango.paginate(proxyConfig)) {
89
+ records.push(...recordBatch);
90
+ }
91
+
92
+ return records;
93
+ }
@@ -0,0 +1,3 @@
1
+ import './github/syncs/fetchIssues.js';
2
+ import './github/actions/createIssue.js';
3
+ import './github/on-events/pre-connection-deletion.js';
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "nango-integrations",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=18.0"
8
+ },
9
+ "devDependencies": {
10
+ "nango": "XXX",
11
+ "zod": "3.24.2"
12
+ }
13
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "$comment": "This file is managed by Nango, do not edit it manually.",
4
+ "include": ["index.ts", "**/*.ts"],
5
+ "exclude": ["node_modules", "dist", "build", ".nango"],
6
+ "compilerOptions": {
7
+ "module": "commonjs",
8
+ "target": "esnext",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "moduleResolution": "node16",
14
+ "allowUnusedLabels": false,
15
+ "allowUnreachableCode": false,
16
+ "exactOptionalPropertyTypes": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noImplicitOverride": true,
19
+ "noImplicitReturns": true,
20
+ "noPropertyAccessFromIndexSignature": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "noUnusedLocals": true,
23
+ "noUnusedParameters": true,
24
+ "declaration": false,
25
+ "sourceMap": true,
26
+ "composite": false,
27
+ "checkJs": false,
28
+ "noEmit": true
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nango",
3
- "version": "0.59.12",
3
+ "version": "0.60.0",
4
4
  "description": "Nango's CLI tool.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,56 +28,60 @@
28
28
  "prepublishOnly": "npm run copy:files"
29
29
  },
30
30
  "dependencies": {
31
- "@babel/parser": "^7.22.5",
32
- "@babel/traverse": "^7.22.5",
33
- "@babel/types": "^7.22.5",
34
- "@nangohq/nango-yaml": "0.59.12",
35
- "@nangohq/node": "0.59.12",
36
- "@nangohq/runner-sdk": "0.59.12",
31
+ "@babel/core": "7.27.3",
32
+ "@babel/parser": "7.27.3",
33
+ "@babel/traverse": "7.27.3",
34
+ "@babel/types": "7.27.3",
35
+ "@babel/preset-typescript": "7.27.1",
36
+ "@nangohq/nango-yaml": "0.60.0",
37
+ "@nangohq/node": "0.60.0",
38
+ "@nangohq/runner-sdk": "0.60.0",
37
39
  "@swc/core": "^1.5.25",
38
- "@types/unzipper": "^0.10.10",
40
+ "@types/unzipper": "^0.10.11",
39
41
  "ajv": "^8.17.1",
40
42
  "ajv-errors": "^3.0.0",
41
43
  "axios": "1.9.0",
42
44
  "chalk": "^5.3.0",
43
45
  "chokidar": "^3.5.3",
46
+ "columnify": "1.6.0",
44
47
  "commander": "^10.0.1",
45
48
  "conf": "12.0.0",
46
49
  "copyfiles": "^2.4.1",
47
- "dotenv": "^16.0.3",
50
+ "dotenv": "^16.5.0",
48
51
  "ejs": "^3.1.10",
52
+ "esbuild": "0.25.5",
49
53
  "figlet": "^1.6.0",
50
54
  "glob": "^10.3.10",
51
55
  "import-meta-resolve": "^4.1.0",
56
+ "jscodeshift": "17.3.0",
52
57
  "js-yaml": "^4.1.0",
53
58
  "npm-package-arg": "^10.1.0",
59
+ "ora": "8.2.0",
54
60
  "promptly": "^3.2.0",
55
61
  "semver": "^7.5.4",
56
62
  "serialize-error": "11.0.3",
57
63
  "ts-json-schema-generator": "^2.3.0",
58
64
  "ts-node": "^10.9.1",
59
- "tsup": "^8.1.0",
60
- "typescript": "5.7.3",
65
+ "tsup": "^8.5.0",
66
+ "typescript": "5.8.3",
61
67
  "unzipper": "^0.12.3",
62
68
  "zod": "3.24.2"
63
69
  },
64
70
  "devDependencies": {
65
- "@babel/core": "^7.22.1",
66
- "@babel/preset-env": "^7.22.4",
67
- "@babel/preset-typescript": "^7.21.5",
68
- "@nangohq/types": "0.59.12",
69
- "@types/babel__traverse": "^7.20.1",
70
- "@types/babel-traverse": "^6.25.7",
71
- "@types/commander": "^2.12.2",
72
- "@types/ejs": "^3.1.2",
71
+ "@nangohq/types": "0.60.0",
72
+ "@types/babel__core": "7.20.5",
73
+ "@types/babel__traverse": "7.20.7",
74
+ "@types/columnify": "1.5.4",
75
+ "@types/commander": "^2.12.5",
76
+ "@types/ejs": "^3.1.5",
73
77
  "@types/figlet": "^1.5.6",
74
78
  "@types/glob": "^8.1.0",
79
+ "@types/jscodeshift": "17.3.0",
75
80
  "@types/json-schema": "7.0.15",
76
81
  "@types/node": "^20.1.4",
77
- "@types/npm-package-arg": "^6.1.1",
78
- "@types/promptly": "^3.0.2",
82
+ "@types/npm-package-arg": "^6.1.4",
83
+ "@types/promptly": "^3.0.5",
79
84
  "babel-loader": "^9.1.2",
80
- "esbuild": "^0.25.0",
81
85
  "json-schema": "0.4.0",
82
86
  "strip-ansi": "7.1.0",
83
87
  "vitest": "3.1.2"
@@ -87,12 +91,11 @@
87
91
  },
88
92
  "files": [
89
93
  "dist/**/*",
90
- "docker/docker-compose.yaml",
94
+ "example/**/*",
91
95
  "lib/nango.yaml.schema.v1.json",
92
96
  "lib/nango.yaml.schema.v2.json",
93
97
  "scripts/v1-v2.js",
94
98
  "tsconfig.dev.json",
95
- "!**/*.json",
96
99
  "README.md"
97
100
  ]
98
101
  }