nango 0.36.15 → 0.36.17
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/templates/action.ejs +39 -0
- package/dist/templates/github.sync.ejs +55 -0
- package/dist/templates/nango.yaml +29 -0
- package/dist/templates/sync.ejs +10 -0
- package/docker/docker-compose.yaml +2 -2
- package/lib/nango.yaml.schema.v1.json +46 -0
- package/lib/nango.yaml.schema.v2.json +196 -0
- package/package.json +4 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const isArrayInterfaceNames = Array.isArray(interfaceNames);
|
|
3
|
+
const isArrayMappings = Array.isArray(mappings);
|
|
4
|
+
const isArrayInputs = Array.isArray(inputs);
|
|
5
|
+
|
|
6
|
+
const formattedInterfaceNames = isArrayInterfaceNames ? interfaceNames.join(', ') : interfaceNames;
|
|
7
|
+
const javascriptPrimitives = ['string', 'number', 'boolean', 'bigint', 'symbol', 'undefined', 'object', 'null'];
|
|
8
|
+
const filteredInputs = isArrayInputs ? inputs.filter(input => !javascriptPrimitives.includes(input)) : inputs;
|
|
9
|
+
|
|
10
|
+
const formattedInputs = isArrayInputs ? filteredInputs.join(', ') : (javascriptPrimitives.includes(inputs) ? '' : inputs);
|
|
11
|
+
|
|
12
|
+
let returnTypes = 'void';
|
|
13
|
+
if (isArrayMappings && mappings.length > 0) {
|
|
14
|
+
if (mappings.length === 1) {
|
|
15
|
+
returnTypes = `${mappings[0].name}[]`;
|
|
16
|
+
} else {
|
|
17
|
+
returnTypes = '{' + mappings.map(mapping => `${mapping.name}: ${mapping.type}[]`).join(', ') + '}';
|
|
18
|
+
}
|
|
19
|
+
} else if (typeof mappings === 'object') {
|
|
20
|
+
returnTypes = `${mappings.name}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let paramInputs = 'object';
|
|
24
|
+
let optionalInput = '?';
|
|
25
|
+
if (inputs) {
|
|
26
|
+
optionalInput = '';
|
|
27
|
+
|
|
28
|
+
if (isArrayInputs) {
|
|
29
|
+
paramInputs = `${inputs}[];`
|
|
30
|
+
} else {
|
|
31
|
+
paramInputs = inputs;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
%>
|
|
35
|
+
import type { NangoAction<%= formattedInterfaceNames ? ', ' + formattedInterfaceNames : '' %><%= formattedInputs ? ', ' + formattedInputs : '' %> } from './<%= interfaceFileName %>';
|
|
36
|
+
|
|
37
|
+
export default async function runAction(nango: NangoAction, input<%= optionalInput %>: <%= paramInputs %>): Promise<<%= returnTypes %>> {
|
|
38
|
+
// Integration code goes here
|
|
39
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NangoSync, GithubIssue } from './models';
|
|
2
|
+
|
|
3
|
+
const LIMIT = 100;
|
|
4
|
+
|
|
5
|
+
export default async function fetchData(nango: NangoSync): Promise<void> {
|
|
6
|
+
const repos: any[] = await getAllRepositories(nango);
|
|
7
|
+
|
|
8
|
+
for (const repo of repos) {
|
|
9
|
+
const proxyConfig = {
|
|
10
|
+
endpoint: `/repos/${repo.owner.login}/${repo.name}/issues`,
|
|
11
|
+
paginate: {
|
|
12
|
+
limit: LIMIT
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
for await (const issueBatch of nango.paginate(proxyConfig)) {
|
|
16
|
+
const issues: any[] = issueBatch.filter((issue: any) => !('pull_request' in issue));
|
|
17
|
+
|
|
18
|
+
const mappedIssues: GithubIssue[] = issues.map((issue: any) => ({
|
|
19
|
+
id: issue.id,
|
|
20
|
+
owner: repo.owner.login,
|
|
21
|
+
repo: repo.name,
|
|
22
|
+
issue_number: issue.number,
|
|
23
|
+
title: issue.title,
|
|
24
|
+
state: issue.state,
|
|
25
|
+
author: issue.user.login,
|
|
26
|
+
author_id: issue.user.id,
|
|
27
|
+
body: issue.body,
|
|
28
|
+
date_created: issue.created_at,
|
|
29
|
+
date_last_modified: issue.updated_at
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
if (mappedIssues.length > 0) {
|
|
33
|
+
await nango.batchSave(mappedIssues, 'GithubIssue');
|
|
34
|
+
await nango.log(`Sent ${mappedIssues.length} issues from ${repo.owner.login}/${repo.name}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function getAllRepositories(nango: NangoSync) {
|
|
41
|
+
const records: any[] = [];
|
|
42
|
+
const proxyConfig = {
|
|
43
|
+
endpoint: '/user/repos',
|
|
44
|
+
paginate: {
|
|
45
|
+
limit: LIMIT
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
for await (const recordBatch of nango.paginate(proxyConfig)) {
|
|
50
|
+
records.push(...recordBatch);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return records;
|
|
54
|
+
}
|
|
55
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
integrations:
|
|
2
|
+
demo-github-integration:
|
|
3
|
+
syncs:
|
|
4
|
+
github-issue-example:
|
|
5
|
+
description: |
|
|
6
|
+
Fetches the Github issues from all a user's repositories.
|
|
7
|
+
Details: full sync, doesn't track deletes, metadata is not required.
|
|
8
|
+
type: sync
|
|
9
|
+
scopes: public_repo
|
|
10
|
+
sync_type: full
|
|
11
|
+
tracks_deletes: false
|
|
12
|
+
runs: every half hour
|
|
13
|
+
auto_start: true
|
|
14
|
+
endpoint: GET /ticketing/issues
|
|
15
|
+
output: GithubIssue
|
|
16
|
+
|
|
17
|
+
models:
|
|
18
|
+
GithubIssue:
|
|
19
|
+
id: integer
|
|
20
|
+
owner: string
|
|
21
|
+
repo: string
|
|
22
|
+
issue_number: number
|
|
23
|
+
title: string
|
|
24
|
+
author: string
|
|
25
|
+
author_id: string
|
|
26
|
+
state: string
|
|
27
|
+
date_created: date
|
|
28
|
+
date_last_modified: date
|
|
29
|
+
body: string
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const formattedInterfaceNames = Array.isArray(interfaceNames) ? interfaceNames.join(', ') : interfaceNames;
|
|
3
|
+
%>
|
|
4
|
+
import type { NangoSync<%= formattedInterfaceNames ? ', ' + formattedInterfaceNames : '' %> } from './<%= interfaceFileName %>';
|
|
5
|
+
|
|
6
|
+
export default async function fetchData(nango: NangoSync): Promise<void> {
|
|
7
|
+
// Integration code goes here
|
|
8
|
+
// to save data use await nango.batchSave
|
|
9
|
+
// to delete data use await nango.batchDelete
|
|
10
|
+
}
|
|
@@ -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.16
|
|
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.16
|
|
51
51
|
container_name: nango-worker
|
|
52
52
|
restart: always
|
|
53
53
|
ports:
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"integrations": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": {
|
|
10
|
+
"anyOf": [
|
|
11
|
+
{
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "null"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"type": { "type": "string" },
|
|
22
|
+
"returns": {
|
|
23
|
+
"oneOf": [
|
|
24
|
+
{ "type": "string" },
|
|
25
|
+
{
|
|
26
|
+
"type": "array",
|
|
27
|
+
"items": { "type": "string" }
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"description": { "type": "string" },
|
|
32
|
+
"runs": { "type": "string", "nullable": true },
|
|
33
|
+
"track_deletes": { "type": "boolean", "nullable": true },
|
|
34
|
+
"auto_start": { "type": "boolean", "nullable": true }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"models": {
|
|
42
|
+
"type": "object"
|
|
43
|
+
},
|
|
44
|
+
"additionalProperties": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"integrations": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"syncs": {
|
|
11
|
+
"errorMessage": {
|
|
12
|
+
"_": " "
|
|
13
|
+
},
|
|
14
|
+
"anyOf": [
|
|
15
|
+
{
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"errorMessage": {
|
|
19
|
+
"_": " "
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "null",
|
|
24
|
+
"errorMessage": {
|
|
25
|
+
"_": " "
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"description": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"errorMessage": {
|
|
36
|
+
"type": "nango yaml schema validation error: description must be a string."
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"sync_type": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": ["incremental", "full"],
|
|
42
|
+
"errorMessage": {
|
|
43
|
+
"enum": "nango yaml schema validation error: sync_type must be either 'incremental' or 'full'."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"auto_start": {
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"errorMessage": {
|
|
49
|
+
"type": "nango yaml schema validation error: auto_start must be a boolean."
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"runs": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"errorMessage": {
|
|
55
|
+
"type": "nango yaml schema validation error: runs must be a string and include the word \"every\"."
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"endpoint": {
|
|
59
|
+
"oneOf": [
|
|
60
|
+
{ "type": "string" },
|
|
61
|
+
{
|
|
62
|
+
"type": "array",
|
|
63
|
+
"items": { "type": "string" }
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"errorMessage": {
|
|
67
|
+
"_": "nango yaml schema validation error: endpoint must be a string or an array of strings."
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"scopes": {
|
|
71
|
+
"oneOf": [
|
|
72
|
+
{ "type": "string" },
|
|
73
|
+
{
|
|
74
|
+
"type": "array",
|
|
75
|
+
"items": { "type": "string" }
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"errorMessage": {
|
|
79
|
+
"_": "nango yaml schema validation error: scopes must be a string or an array of strings."
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"input": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"nullable": true,
|
|
85
|
+
"errorMessage": {
|
|
86
|
+
"type": "nango yaml schema validation error: input must be a string and should define any required metadata for the sync."
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"output": {
|
|
90
|
+
"oneOf": [
|
|
91
|
+
{ "type": "string" },
|
|
92
|
+
{
|
|
93
|
+
"type": "array",
|
|
94
|
+
"items": { "type": "string" }
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"errorMessage": {
|
|
98
|
+
"_": "nango yaml schema validation error: output must be a string or an array of strings."
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"required": ["endpoint", "output"],
|
|
103
|
+
"errorMessage": {
|
|
104
|
+
"required": {
|
|
105
|
+
"endpoint": "nango yaml schema validation error: An endpoint property is required to specify how to retrieve the data from the sync.",
|
|
106
|
+
"output": "nango yaml schema validation error: An output property is required to specify what is the outcome of the sync."
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"actions": {
|
|
114
|
+
"errorMessage": {
|
|
115
|
+
"_": " "
|
|
116
|
+
},
|
|
117
|
+
"anyOf": [
|
|
118
|
+
{
|
|
119
|
+
"type": "null",
|
|
120
|
+
"errorMessage": {
|
|
121
|
+
"_": " "
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "object",
|
|
126
|
+
"additionalProperties": false,
|
|
127
|
+
"errorMessage": {
|
|
128
|
+
"_": " "
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "object",
|
|
133
|
+
"additionalProperties": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"properties": {
|
|
136
|
+
"description": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"errorMessage": {
|
|
139
|
+
"type": "nango yaml schema validation error: description must be a string."
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"endpoint": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"errorMessage": {
|
|
145
|
+
"type": "nango yaml schema validation error: endpoint must be a string, for example \"POST /tickets/ticket\"."
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"scopes": {
|
|
149
|
+
"oneOf": [
|
|
150
|
+
{ "type": "string" },
|
|
151
|
+
{
|
|
152
|
+
"type": "array",
|
|
153
|
+
"items": { "type": "string" }
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"errorMessage": {
|
|
157
|
+
"_": "nango yaml schema validation error: scopes must be a string or an array of strings."
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"input": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"nullable": true,
|
|
163
|
+
"errorMessage": {
|
|
164
|
+
"type": "nango yaml schema validation error: input must be a string and should define any required metadata for the sync."
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"output": {
|
|
168
|
+
"oneOf": [
|
|
169
|
+
{ "type": "string" },
|
|
170
|
+
{
|
|
171
|
+
"type": "array",
|
|
172
|
+
"items": { "type": "string" }
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"errorMessage": {
|
|
176
|
+
"_": "nango yaml schema validation error: output must be a string or an array of strings."
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"required": ["endpoint"],
|
|
181
|
+
"errorMessage": {
|
|
182
|
+
"required": {
|
|
183
|
+
"endpoint": "nango yaml schema validation error: An endpoint property is required to specify how to trigger the action."
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"additionalProperties": false
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"additionalProperties": true
|
|
196
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nango",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.17",
|
|
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.16",
|
|
27
27
|
"@vercel/ncc": "^0.36.1",
|
|
28
28
|
"ajv": "^8.12.0",
|
|
29
29
|
"ajv-errors": "^3.0.0",
|
|
@@ -70,6 +70,8 @@
|
|
|
70
70
|
"files": [
|
|
71
71
|
"dist/**/*",
|
|
72
72
|
"docker/docker-compose.yaml",
|
|
73
|
+
"lib/nango.yaml.schema.v1.json",
|
|
74
|
+
"lib/nango.yaml.schema.v2.json",
|
|
73
75
|
"tsconfig.dev.json",
|
|
74
76
|
"!**/*.json",
|
|
75
77
|
"README.md"
|