nango 0.36.15 → 0.36.16

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.
@@ -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.15
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.15
50
+ image: nangohq/nango-worker:0.36.16
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.15",
3
+ "version": "0.36.16",
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.15",
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",