Skip to content

Commit

Permalink
chore: Add integration counts to webflow sync (#3506)
Browse files Browse the repository at this point in the history
<!-- Describe the problem and your solution --> 
Added a new field for integration counts in webflow and then added
handling for that to the webflow syncs script. It also adds handling
flows updates since we use that for the integration count data source.

<!-- Issue ticket number and link (if applicable) -->
See
https://linear.app/nango/issue/NAN-2634/api-catalog-show-number-of-pre-built-integrations

<!-- Testing instructions (skip if just adding/editing providers) -->
  • Loading branch information
nalanj authored Feb 11, 2025
1 parent 6cfc647 commit e4d8bd1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/webflow-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- packages/providers/providers.yaml
- docs-v2/integrations/all/*.md
- packages/shared/flows.yaml
workflow_dispatch:

concurrency:
Expand Down
26 changes: 22 additions & 4 deletions scripts/webflow-api-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import yaml from 'js-yaml';
import { setTimeout } from 'node:timers/promises';
import util from 'node:util';
import type { CollectionItem, CollectionItemList } from 'webflow-api/api';
import type { Provider } from '@nangohq/types';
import type { Provider, FlowsYaml } from '@nangohq/types';

const rateLimitSleep = 1000;

Expand All @@ -29,6 +29,10 @@ const providersPath = 'packages/providers/providers.yaml';
// eslint-disable-next-line import/no-named-as-default-member
const providers = yaml.load(await fs.readFile(providersPath, 'utf8')) as Record<string, Provider>;

const flowsPath = 'packages/shared/flows.yaml';
// eslint-disable-next-line import/no-named-as-default-member
const flows = yaml.load(await fs.readFile(flowsPath, 'utf8')) as FlowsYaml;

const docsPath = 'docs-v2/integrations/all';
const files = await fs.readdir(docsPath);

Expand Down Expand Up @@ -111,6 +115,17 @@ for (const [slug, provider] of Object.entries(neededProviders)) {
const logoPath = path.relative(process.cwd(), fullLogoPath);
const logo = `https://raw.githubusercontent.com/NangoHQ/nango/refs/heads/master/${logoPath}`;

let preBuiltCount = 0;
if (flows.integrations[slug]) {
if (flows.integrations[slug].actions) {
preBuiltCount += Object.keys(flows.integrations[slug].actions).length;
}

if (flows.integrations[slug].syncs) {
preBuiltCount += Object.keys(flows.integrations[slug].syncs).length;
}
}

if (apiItemsBySlug[slug]) {
const item = apiItemsBySlug[slug];
if (!item.id) {
Expand All @@ -121,7 +136,8 @@ for (const [slug, provider] of Object.entries(neededProviders)) {
fieldData: {
name: item.fieldData.name,
documentation: item.fieldData['documentation'],
'api-categories': item.fieldData['api-categories']
'api-categories': item.fieldData['api-categories'],
'pre-built-integrations-count': item.fieldData['pre-built-integrations-count']
}
};

Expand All @@ -132,7 +148,8 @@ for (const [slug, provider] of Object.entries(neededProviders)) {
fieldData: {
name: provider.display_name,
documentation: provider.docs,
'api-categories': apiCategories
'api-categories': apiCategories,
'pre-built-integrations-count': preBuiltCount
}
};

Expand Down Expand Up @@ -163,7 +180,8 @@ for (const [slug, provider] of Object.entries(neededProviders)) {
slug: slug,
documentation: provider.docs,
logo,
'api-categories': providerCategories.map((category) => categoriesBySlug[category]?.id)
'api-categories': providerCategories.map((category) => categoriesBySlug[category]?.id),
'pre-built-integrations-count': preBuiltCount
}
});
}
Expand Down

0 comments on commit e4d8bd1

Please sign in to comment.