Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use generated integration constants #1959

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"unicorn/prefer-array-flat-map": "error",
"unicorn/no-useless-spread": "error",
"unicorn/no-useless-length-check": "error",
"unicorn/prefer-export-from": "error",
"unicorn/prefer-export-from": ["error", { "ignoreUsedVariables": true }],
"sonarjs/prefer-immediate-return": "off",
"sonarjs/no-nested-template-literals": "off",
"sonarjs/max-switch-cases": "off",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"release": "nx affected --base=origin/main --target=version --parallel=1 --skipCommitTypes=docs,ci,chore,test --baseBranch=$BASE_BRANCH",
"release:nx": "nx release --skip-publish --verbose --dry-run",
"release:github": "nx affected --target=github --parallel=1 --skipCommitTypes=docs,ci,chore,test",
"reset:nx": "nx reset",
"deploy:npm": "nx affected --target=deploy --parallel=1 --skipCommitTypes=docs,ci,chore,test"
},
"author": "RudderStack",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-js-common/.size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = [
{
name: 'Common - No bundling',
path: 'dist/npm/**/*.js',
limit: '17.2 KiB',
limit: '18.4 KiB',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { readdirSync, statSync } from 'fs';
import { join } from 'path';

const BaseIntegrationDir = join(__dirname, '../../../src/constants/integrations');
describe('Integration Constants', () => {
let allConstants: Record<string, string>;

beforeAll(async () => {
allConstants = await import(join(BaseIntegrationDir, 'Destinations'));
});

const integrations = readdirSync(BaseIntegrationDir);
integrations
// Skip non integration folders
.filter(dir => ['CommonIntegrationsConstant'].indexOf(dir) === -1)
.filter(dir => statSync(join(BaseIntegrationDir, dir)).isDirectory())
.forEach(integration => {
describe(`${integration} Integration`, () => {
let integrationConstants: { NAME: string; DISPLAY_NAME: string };

beforeAll(async () => {
const modulePath = join(BaseIntegrationDir, integration, 'constants');
integrationConstants = await import(modulePath);
});
koladilip marked this conversation as resolved.
Show resolved Hide resolved

it('should have the same NAME as defined in Destination constants', () => {
const { NAME } = integrationConstants;
expect(NAME).toBeDefined();
expect(NAME).toEqual(allConstants[`${NAME}_NAME`]);
});

it('should have the same DISPLAY_NAME as defined in Destination constants', () => {
const { NAME, DISPLAY_NAME } = integrationConstants;
expect(DISPLAY_NAME).toBeDefined();
expect(DISPLAY_NAME).toEqual(allConstants[`${NAME}_DISPLAY_NAME`]);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
ACTIVE_CAMPAIGN_NAME as NAME,
ACTIVE_CAMPAIGN_DISPLAY_NAME as DISPLAY_NAME,
} from '../Destinations';

const DIR_NAME = 'ActiveCampaign';
const NAME = 'ACTIVE_CAMPAIGN';
const DISPLAY_NAME = 'ActiveCampaign';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
ADOBE_ANALYTICS_NAME as NAME,
ADOBE_ANALYTICS_DISPLAY_NAME as DISPLAY_NAME,
} from '../Destinations';

const DIR_NAME = 'AdobeAnalytics';
const NAME = 'ADOBE_ANALYTICS';
const DISPLAY_NAME = 'Adobe Analytics';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ADROLL_NAME as NAME, ADROLL_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Adroll';
const NAME = 'ADROLL';
const DISPLAY_NAME = 'Adroll';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AM_NAME as NAME, AM_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';
koladilip marked this conversation as resolved.
Show resolved Hide resolved

const DIR_NAME = 'Amplitude';
const NAME = 'AM';
const DISPLAY_NAME = 'Amplitude';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APPCUES_NAME as NAME, APPCUES_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Appcues';
const NAME = 'APPCUES';
const DISPLAY_NAME = 'Appcues';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AXEPTIO_NAME as NAME, AXEPTIO_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Axeptio';
const NAME = 'AXEPTIO';
const DISPLAY_NAME = 'Axeptio';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BINGADS_NAME as NAME, BINGADS_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'BingAds';
const NAME = 'BINGADS';
const DISPLAY_NAME = 'Bing Ads';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BRAZE_NAME as NAME, BRAZE_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Braze';
const NAME = 'BRAZE';
const DISPLAY_NAME = 'Braze';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BUGSNAG_NAME as NAME, BUGSNAG_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Bugsnag';
const NAME = 'BUGSNAG';
const DISPLAY_NAME = 'Bugsnag';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CHARTBEAT_NAME as NAME, CHARTBEAT_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Chartbeat';
const NAME = 'CHARTBEAT';
const DISPLAY_NAME = 'Chartbeat';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CLEVERTAP_NAME as NAME, CLEVERTAP_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Clevertap';
const NAME = 'CLEVERTAP';
const DISPLAY_NAME = 'CleverTap';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { COMMANDBAR_NAME as NAME, COMMANDBAR_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'CommandBar';
const NAME = 'COMMANDBAR';
const DISPLAY_NAME = 'CommandBar';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
[NAME]: NAME,
'Command Bar': NAME,
'Commandbar': NAME,
Commandbar: NAME,
COMMAND_BAR: NAME,
commandbar: NAME,
};

export {
NAME,
CNameMapping,
DISPLAY_NAME_TO_DIR_NAME_MAP,
DISPLAY_NAME,
DIR_NAME,
};

export { NAME, CNameMapping, DISPLAY_NAME_TO_DIR_NAME_MAP, DISPLAY_NAME, DIR_NAME };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
CONVERTFLOW_NAME as NAME,
CONVERTFLOW_DISPLAY_NAME as DISPLAY_NAME,
} from '../Destinations';

const DIR_NAME = 'ConvertFlow';
const NAME = 'CONVERTFLOW';
const DISPLAY_NAME = 'Convertflow';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CRITEO_NAME as NAME, CRITEO_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'Criteo';
const NAME = 'CRITEO';
const DISPLAY_NAME = 'Criteo';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CUSTOMERIO_NAME as NAME, CUSTOMERIO_DISPLAY_NAME as DISPLAY_NAME } from '../Destinations';

const DIR_NAME = 'CustomerIO';
const NAME = 'CUSTOMERIO';
const DISPLAY_NAME = 'Customer IO';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
DCM_FLOODLIGHT_NAME as NAME,
DCM_FLOODLIGHT_DISPLAY_NAME as DISPLAY_NAME,
} from '../Destinations';

const DIR_NAME = 'DCMFloodlight';
const NAME = 'DCM_FLOODLIGHT';
const DISPLAY_NAME = 'DCM Floodlight';

const DISPLAY_NAME_TO_DIR_NAME_MAP = { [DISPLAY_NAME]: DIR_NAME };
const CNameMapping = {
Expand Down
Loading
Loading