Skip to content

Commit

Permalink
chore: import error classes from integrations lib (#2719)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravudia authored Nov 10, 2023
1 parent c02370e commit 8eb1e1d
Show file tree
Hide file tree
Showing 251 changed files with 562 additions and 689 deletions.
35 changes: 30 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@koa/router": "^12.0.0",
"@ndhoule/extend": "^2.0.0",
"@pyroscope/nodejs": "^0.2.6",
"@rudderstack/integrations-lib": "^0.1.8",
"@rudderstack/workflow-engine": "^0.5.7",
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/networkhandler/genericNetworkHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { NetworkError } = require('@rudderstack/integrations-lib');
const { isHttpStatusSuccess } = require('../../v0/util/index');
const { proxyRequest, prepareProxyRequest } = require('../network');
const { getDynamicErrorType, processAxiosResponse } = require('../utils/networkUtils');
const { NetworkError } = require('../../v0/util/errorTypes');
const tags = require('../../v0/util/tags');

/**
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/utils/networkUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable eqeqeq */
const lodash = require('lodash');
const { isEmpty } = require('lodash');
const { AbortedError } = require('@rudderstack/integrations-lib');
const {
isHttpStatusRetryable,
isDefinedAndNotNullAndNotEmpty,
Expand All @@ -9,7 +10,6 @@ const {
isHttpStatusSuccess,
getErrorStatusCode,
} = require('../../v0/util');
const { AbortedError } = require('../../v0/util/errorTypes');
const tags = require('../../v0/util/tags');
const { HTTP_STATUS_CODES } = require('../../v0/util/constant');

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v1/autopilot/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { Utils } = require('rudder-transformer-cdk');
const { InstrumentationError } = require('../../../v0/util/errorTypes');
const { InstrumentationError } = require('@rudderstack/integrations-lib');

function identifyPostMapper(event, mappedPayload) {
const { message } = event;
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v1/dcm_floodlight/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
removeUndefinedAndNullValues,
isDefinedAndNotNull,
} = require('rudder-transformer-cdk/build/utils');
const { ConfigurationError, InstrumentationError } = require('@rudderstack/integrations-lib');
const {
getIntegrationsObj,
isEmpty,
Expand All @@ -14,7 +15,6 @@ const {
} = require('../../../v0/util');
const { GENERIC_TRUE_VALUES, GENERIC_FALSE_VALUES } = require('../../../constants');
const { BASE_URL, BLACKLISTED_CHARACTERS } = require('./config');
const { ConfigurationError, InstrumentationError } = require('../../../v0/util/errorTypes');

// append properties to endpoint
// eg: ${BASE_URL}key1=value1;key2=value2;....
Expand Down
8 changes: 4 additions & 4 deletions src/cdk/v1/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const path = require('path');
const basePath = path.resolve(__dirname);
ConfigFactory.init({ basePath, loggingMode: 'production' });

const tags = require('../../v0/util/tags');
const { generateErrorObject } = require('../../v0/util');
const {
InstrumentationError,
TransformationError,
ConfigurationError,
InstrumentationError,
} = require('../../v0/util/errorTypes');
} = require('@rudderstack/integrations-lib');
const tags = require('../../v0/util/tags');
const { generateErrorObject } = require('../../v0/util');

const defTags = {
[tags.TAG_NAMES.IMPLEMENTATION]: tags.IMPLEMENTATIONS.CDK_V1,
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/bindings/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
InstrumentationError,
ConfigurationError,
NetworkError,
} = require('../../../v0/util/errorTypes');
} = require('@rudderstack/integrations-lib');
const { isHttpStatusSuccess } = require('../../../v0/util');
const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const tags = require('../../../v0/util/tags');
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/dcm_floodlight/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const lodash = require('lodash');
const { InstrumentationError } = require('@rudderstack/integrations-lib');
const { getValueFromPropertiesOrTraits, getHashFromArray } = require('../../../../v0/util');
const { GENERIC_TRUE_VALUES, GENERIC_FALSE_VALUES } = require('../../../../constants');
const { InstrumentationError } = require('../../../../v0/util/errorTypes');

// valid flag should be provided [1|true] or [0|false]
const mapFlagValue = (key, value) => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path';
import fs from 'fs/promises';
import { WorkflowExecutionError, WorkflowCreationError } from '@rudderstack/workflow-engine';
import { PlatformError } from '@rudderstack/integrations-lib';
import logger from '../../logger';
import { generateErrorObject } from '../../v0/util';
import { PlatformError } from '../../v0/util/errorTypes';
import tags from '../../v0/util/tags';
import { CatchErr } from '../../util/types';

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/serviceSelector.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PlatformError } from '@rudderstack/integrations-lib';
import { ProcessorTransformationRequest, RouterTransformationRequestData } from '../types/index';
import { INTEGRATION_SERVICE } from '../routes/utils/constants';
import CDKV1DestinationService from '../services/destination/cdkV1Integration';
Expand All @@ -6,7 +7,6 @@ import DestinationService from '../interfaces/DestinationService';
import NativeIntegrationDestinationService from '../services/destination/nativeIntegration';
import SourceService from '../interfaces/SourceService';
import NativeIntegrationSourceService from '../services/source/nativeIntegration';
import { PlatformError } from '../v0/util/errorTypes';
import ComparatorService from '../services/comparator';
import { FixMe } from '../util/types';

Expand Down
2 changes: 1 addition & 1 deletion src/services/destination/cdkV1Integration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { ConfigFactory, Executor, RudderBaseConfig } from 'rudder-transformer-cdk';
import path from 'path';
import { TransformationError } from '@rudderstack/integrations-lib';
import IntegrationDestinationService from '../../interfaces/DestinationService';
import {
DeliveryResponse,
Expand All @@ -14,7 +15,6 @@ import {
UserDeletionRequest,
UserDeletionResponse,
} from '../../types/index';
import { TransformationError } from '../../v0/util/errorTypes';
import DestinationPostTransformationService from './postTransformation';
import tags from '../../v0/util/tags';
import { getErrorInfo } from '../../cdk/v1/handler';
Expand Down
2 changes: 1 addition & 1 deletion src/services/destination/cdkV2Integration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable class-methods-use-this */
import groupBy from 'lodash/groupBy';
import { TransformationError } from '@rudderstack/integrations-lib';
import { processCdkV2Workflow } from '../../cdk/v2/handler';
import IntegrationDestinationService from '../../interfaces/DestinationService';
import {
Expand All @@ -15,7 +16,6 @@ import {
UserDeletionRequest,
UserDeletionResponse,
} from '../../types/index';
import { TransformationError } from '../../v0/util/errorTypes';
import tags from '../../v0/util/tags';
import DestinationPostTransformationService from './postTransformation';
import stats from '../../util/stats';
Expand Down
9 changes: 4 additions & 5 deletions src/util/errorNotifier/bugsnag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ const {
DataValidationError,
} = require('rudder-transformer-cdk/build/error/index');
const stackTraceParser = require('stacktrace-parser');
const { logger } = require('../../logger');
const pkg = require('../../../package.json');

const {
BaseError,
TransformationError,
Expand All @@ -23,8 +20,10 @@ const {
UnhandledStatusCodeError,
UnauthorizedError,
NetworkInstrumentationError,
FilteredEventsError,
} = require('../../v0/util/errorTypes');
} = require('@rudderstack/integrations-lib');
const { FilteredEventsError } = require('../../v0/util/errorTypes');
const { logger } = require('../../logger');
const pkg = require('../../../package.json');

const {
BUGSNAG_API_KEY: apiKey,
Expand Down
2 changes: 1 addition & 1 deletion src/util/redis/redisConnector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Redis = require('ioredis');
const { RedisError } = require('../../v0/util/errorTypes');
const { RedisError } = require('@rudderstack/integrations-lib');
const log = require('../../logger');
const stats = require('../stats');

Expand Down
10 changes: 5 additions & 5 deletions src/v0/destinations/active_campaign/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* eslint-disable array-callback-return */
/* eslint-disable no-empty */
const get = require('get-value');
const {
InstrumentationError,
TransformationError,
NetworkError,
} = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');
const { CONFIG_CATEGORIES, MAPPING_CONFIG, getHeader } = require('./config');
const {
Expand All @@ -12,11 +17,6 @@ const {
} = require('../../util');
const { errorHandler } = require('./util');
const { httpGET, httpPOST } = require('../../../adapters/network');
const {
InstrumentationError,
TransformationError,
NetworkError,
} = require('../../util/errorTypes');
const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const tags = require('../../util/tags');

Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/active_campaign/util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { NetworkError } = require('@rudderstack/integrations-lib');
const {
nodeSysErrorToStatus,
getDynamicErrorType,
} = require('../../../adapters/utils/networkUtils');
const { NetworkError } = require('../../util/errorTypes');
const tags = require('../../util/tags');

const errorHandler = (err, message) => {
Expand Down
10 changes: 5 additions & 5 deletions src/v0/destinations/adj/transform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const get = require('get-value');
const {
InstrumentationError,
TransformationError,
ConfigurationError,
} = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');
const { CONFIG_CATEGORIES, MAPPING_CONFIG, baseEndpoint } = require('./config');
const {
Expand All @@ -11,11 +16,6 @@ const {
isAppleFamily,
simpleProcessRouterDest,
} = require('../../util');
const {
InstrumentationError,
TransformationError,
ConfigurationError,
} = require('../../util/errorTypes');

const rejectParams = ['revenue', 'currency'];

Expand Down
10 changes: 5 additions & 5 deletions src/v0/destinations/adobe_analytics/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const jsonxml = require('jsontoxml');
const get = require('get-value');
const {
InstrumentationError,
TransformationError,
ConfigurationError,
} = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');
const { ECOM_PRODUCT_EVENTS, commonConfig, formatDestinationConfig } = require('./config');
const {
Expand All @@ -14,11 +19,6 @@ const {
removeUndefinedAndNullValues,
simpleProcessRouterDest,
} = require('../../util');
const {
InstrumentationError,
TransformationError,
ConfigurationError,
} = require('../../util/errorTypes');

const {
handleContextData,
Expand Down
8 changes: 4 additions & 4 deletions src/v0/destinations/adobe_analytics/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/* eslint-disable unicorn/no-for-loop */
/* eslint-disable no-restricted-syntax */
const get = require('get-value');
const { InstrumentationError } = require('@rudderstack/integrations-lib');
const { isDefinedAndNotNull, getValueFromMessage } = require('../../util');
const { InstrumentationError } = require('../../util/errorTypes');

const SOURCE_KEYS = ['properties', 'traits', 'context.traits', 'context'];

Expand Down Expand Up @@ -147,13 +147,13 @@ function rudderPropToDestMapWithDelimitter(mapping, delimMapping, message, prefi
`${prefix} mapping properties variable is neither a string nor an array`,
);
}

if (typeof val === 'string') {
/* following regex is used to find the one or more commas separated/padded by white spaces.
Example: val = 'r15,faze90R' , 'r1v, bvp, pol'
*/
val = val.replace(/\s*,+\s*/g, delimMapping[key]);
// Above regex is good as for every comma with whitespace padding the no. of steps will increase by 4.
val = val.replace(/\s*,+\s*/g, delimMapping[key]);
// Above regex is good as for every comma with whitespace padding the no. of steps will increase by 4.
} else {
val = val.join(delimMapping[key]);
}
Expand Down
6 changes: 5 additions & 1 deletion src/v0/destinations/af/deleteUsers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-param-reassign */
const {
ConfigurationError,
InstrumentationError,
NetworkError,
} = require('@rudderstack/integrations-lib');
const { httpPOST } = require('../../../adapters/network');
const {
processAxiosResponse,
getDynamicErrorType,
} = require('../../../adapters/utils/networkUtils');
const { generateUUID, isHttpStatusSuccess } = require('../../util');
const { ConfigurationError, InstrumentationError, NetworkError } = require('../../util/errorTypes');
const tags = require('../../util/tags');
const { executeCommonValidations } = require('../../util/regulation-api');

Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/af/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const get = require('get-value');
const set = require('set-value');

const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');
const {
removeUndefinedValues,
Expand All @@ -15,7 +16,6 @@ const {
isDefinedAndNotNullAndNotEmpty,
simpleProcessRouterDest,
} = require('../../util');
const { InstrumentationError, ConfigurationError } = require('../../util/errorTypes');

const { Event, ENDPOINT, ConfigCategory, mappingConfig, nameToEventMap } = require('./config');
const { JSON_MIME_TYPE } = require('../../util/constant');
Expand Down
Loading

0 comments on commit 8eb1e1d

Please sign in to comment.