Skip to content
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 README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Eppo JS Common SDK for library
# Common library for Eppo's JavasScript SDK

[![](https://img.shields.io/npm/v/@eppo/js-client-sdk-common)](https://www.npmjs.com/package/@eppo/js-client-sdk-common)
[![](https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8)](https://eppo-exp.github.io/js-client-sdk/js-client-sdk-common.html)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"md5": "^2.3.0",
"pino": "^8.19.0",
"semver": "^7.5.4"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
4 changes: 2 additions & 2 deletions src/bandit-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface BanditEvaluation {
}

export class BanditEvaluator {
private assignmentShards = BANDIT_ASSIGNMENT_SHARDS; // We just hard code this for now
private sharder: Sharder = new MD5Sharder();
private readonly assignmentShards = BANDIT_ASSIGNMENT_SHARDS; // We just hard code this for now
private readonly sharder: Sharder = new MD5Sharder();

public evaluateBandit(
flagKey: string,
Expand Down
8 changes: 7 additions & 1 deletion src/client/eppo-client-assignment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MemoryOnlyConfigurationStore } from '../configuration-store/memory.stor
import { AllocationEvaluationCode } from '../flag-evaluation-details-builder';
import { Flag, ObfuscatedFlag, Variation, VariationType } from '../interfaces';
import { OperatorType } from '../rules';
import { AttributeType } from '../types';

import EppoClient, { IAssignmentDetails } from './eppo-client';
import { initConfiguration } from './test-utils';
Expand Down Expand Up @@ -323,7 +324,12 @@ describe('EppoClient get*AssignmentDetails', () => {
[VariationType.STRING]: client.getStringAssignmentDetails.bind(client),
[VariationType.JSON]: client.getJSONAssignmentDetails.bind(client),
};
const assignmentFn = typeAssignmentDetailsFunctions[variationType];
const assignmentFn = typeAssignmentDetailsFunctions[variationType] as (
flagKey: string,
subjectKey: string,
subjectAttributes: Record<string, AttributeType>,
defaultValue: boolean | string | number | object,
) => IAssignmentDetails<boolean | string | number | object>;
if (!assignmentFn) {
throw new Error(`Unknown variation type: ${variationType}`);
}
Expand Down
15 changes: 13 additions & 2 deletions src/client/eppo-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IConfigurationStore } from '../configuration-store/configuration-store'
import { MemoryOnlyConfigurationStore } from '../configuration-store/memory.store';
import { MAX_EVENT_QUEUE_SIZE, DEFAULT_POLL_INTERVAL_MS, POLL_JITTER_PCT } from '../constants';
import { Flag, ObfuscatedFlag, VariationType } from '../interfaces';
import { AttributeType } from '../types';

import EppoClient, { FlagConfigurationRequestParameters, checkTypeMatch } from './eppo-client';
import { initConfiguration } from './test-utils';
Expand Down Expand Up @@ -214,7 +215,12 @@ describe('EppoClient E2E test', () => {
[VariationType.JSON]: client.getJSONAssignment.bind(client),
};

const assignmentFn = typeAssignmentFunctions[variationType];
const assignmentFn = typeAssignmentFunctions[variationType] as (
flagKey: string,
subjectKey: string,
subjectAttributes: Record<string, AttributeType>,
defaultValue: boolean | string | number | object,
) => never;
if (!assignmentFn) {
throw new Error(`Unknown variation type: ${variationType}`);
}
Expand Down Expand Up @@ -258,7 +264,12 @@ describe('EppoClient E2E test', () => {
[VariationType.JSON]: client.getJSONAssignment.bind(client),
};

const assignmentFn = typeAssignmentFunctions[variationType];
const assignmentFn = typeAssignmentFunctions[variationType] as (
flagKey: string,
subjectKey: string,
subjectAttributes: Record<string, AttributeType>,
defaultValue: boolean | string | number | object,
) => never;
if (!assignmentFn) {
throw new Error(`Unknown variation type: ${variationType}`);
}
Expand Down
10 changes: 5 additions & 5 deletions src/client/eppo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
);
evaluationDetails.banditAction = action;
}
} catch (err) {
} catch (err: any) {

Check warning on line 518 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
logger.error('Error determining bandit action', err);
if (!this.isGracefulFailureMode) {
throw err;
Expand Down Expand Up @@ -752,7 +752,7 @@
expectedVariationType,
);
return this.parseVariationWithDetails(result, defaultValue, expectedVariationType);
} catch (error) {
} catch (error: any) {

Check warning on line 755 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
const eppoValue = this.rethrowIfNotGraceful(error, defaultValue);
if (error instanceof FlagEvaluationError && error.flagEvaluationDetails) {
return {
Expand Down Expand Up @@ -790,7 +790,7 @@
eppoValue: EppoValue.valueOf(result.variation.value, expectedVariationType),
flagEvaluationDetails: result.flagEvaluationDetails,
};
} catch (error) {
} catch (error: any) {

Check warning on line 793 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
const eppoValue = this.rethrowIfNotGraceful(error, defaultValue);
return {
eppoValue,
Expand Down Expand Up @@ -1010,7 +1010,7 @@
eventsToFlush.forEach((event) => {
try {
logFunction(event);
} catch (error) {
} catch (error: any) {

Check warning on line 1013 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
logger.error(`[Eppo SDK] Error flushing event to logger: ${error.message}`);
}
});
Expand Down Expand Up @@ -1057,7 +1057,7 @@
allocationKey: allocationKey ?? '__eppo_no_allocation',
variationKey: variation?.key ?? '__eppo_no_variation',
});
} catch (error) {
} catch (error: any) {

Check warning on line 1060 in src/client/eppo-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
logger.error(`[Eppo SDK] Error logging assignment event: ${error.message}`);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

export class Evaluator {
sharder: Sharder;
private readonly sharder: Sharder;

constructor(sharder?: Sharder) {
this.sharder = sharder ?? new MD5Sharder();
Expand Down Expand Up @@ -133,7 +133,7 @@
'No allocations matched. Falling back to "Default Allocation", serving NULL',
),
);
} catch (err) {
} catch (err: any) {

Check warning on line 136 in src/evaluator.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
const flagEvaluationDetails = flagEvaluationDetailsBuilder.gracefulBuild(
'ASSIGNMENT_ERROR',
`Assignment Error: ${err.message}`,
Expand Down
2 changes: 1 addition & 1 deletion src/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
throw new HttpRequestError('Failed to fetch data', response?.status);
}
return await response.json();
} catch (error) {
} catch (error: any) {

Check warning on line 64 in src/http-client.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
if (error.name === 'AbortError') {
throw new HttpRequestError('Request timed out', 408, error);
} else if (error instanceof HttpRequestError) {
Expand Down
4 changes: 2 additions & 2 deletions src/poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
startRequestSuccess = true;
previousPollFailed = false;
logger.info('Eppo SDK successfully requested initial configuration');
} catch (pollingError) {
} catch (pollingError: any) {

Check warning on line 51 in src/poller.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
previousPollFailed = true;
logger.warn(
`Eppo SDK encountered an error with initial poll of configurations: ${pollingError.message}`,
Expand Down Expand Up @@ -116,7 +116,7 @@
previousPollFailed = false;
logger.info('Eppo SDK poll successful; resuming normal polling');
}
} catch (error) {
} catch (error: any) {

Check warning on line 119 in src/poller.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk

Unexpected any. Specify a different type
previousPollFailed = true;
logger.warn(`Eppo SDK encountered an error polling configurations: ${error.message}`);
const maxTries = 1 + (options?.maxPollRetries ?? DEFAULT_POLL_CONFIG_REQUEST_RETRIES);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"target": "es2017",
"outDir": "dist",
"noImplicitAny": true,
"strictNullChecks": true,
"strict": true,
"strictPropertyInitialization": true
},
"include": ["src/**/*.ts"],
Expand Down
Loading