Skip to content

Commit 7ae8d99

Browse files
committed
Merge branch 'main' into sameeran/ff-3566-create-eppoprecomputedclient
2 parents 923ad90 + 8957ebf commit 7ae8d99

14 files changed

+67
-31
lines changed

.github/workflows/lint-test-sdk.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@ on:
77
jobs:
88
lint-test-sdk:
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [ '18', '20', '22', '23' ]
1013
steps:
1114
- uses: actions/checkout@v3
1215
- name: Use Node.js
1316
uses: actions/setup-node@v3
1417
with:
15-
node-version: '18.x'
16-
- uses: actions/cache@v2
18+
node-version: ${{ matrix.node-version }}
19+
- name: Get yarn cache directory path
20+
id: yarn-cache-dir-path
21+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
22+
- uses: actions/cache@v4
23+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
1724
with:
18-
path: './node_modules'
19-
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('./yarn.lock') }}
25+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
26+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-yarn-
2029
- name: 'Set up GCP SDK for downloading test data'
2130
uses: 'google-github-actions/setup-gcloud@v0'
2231
- name: Install SDK dependencies
@@ -30,16 +39,25 @@ jobs:
3039
working-directory: ./
3140
typecheck:
3241
runs-on: ubuntu-latest
42+
strategy:
43+
matrix:
44+
node-version: [ '18', '20', '22', '23' ]
3345
steps:
3446
- uses: actions/checkout@v3
3547
- name: Use Node.js
3648
uses: actions/setup-node@v3
3749
with:
38-
node-version: '18.x'
39-
- uses: actions/cache@v2
50+
node-version: ${{ matrix.node-version }}
51+
- name: Get yarn cache directory path
52+
id: yarn-cache-dir-path
53+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
54+
- uses: actions/cache@v4
55+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
4056
with:
41-
path: './node_modules'
42-
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('./yarn.lock') }}
57+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
58+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
59+
restore-keys: |
60+
${{ runner.os }}-yarn-
4361
- name: Install SDK dependencies
4462
run: yarn --frozen-lockfile
4563
working-directory: ./

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Eppo JS Common SDK for library
1+
# Common library for Eppo's JavasScript SDK
22

33
[![](https://img.shields.io/npm/v/@eppo/js-client-sdk-common)](https://www.npmjs.com/package/@eppo/js-client-sdk-common)
44
[![](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)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@
7272
"md5": "^2.3.0",
7373
"pino": "^8.19.0",
7474
"semver": "^7.5.4"
75-
}
75+
},
76+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
7677
}

src/bandit-evaluator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export interface BanditEvaluation {
2020
}
2121

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

2626
public evaluateBandit(
2727
flagKey: string,

src/client/eppo-client-assignment-details.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { MemoryOnlyConfigurationStore } from '../configuration-store/memory.stor
99
import { AllocationEvaluationCode } from '../flag-evaluation-details-builder';
1010
import { Flag, ObfuscatedFlag, Variation, VariationType } from '../interfaces';
1111
import { OperatorType } from '../rules';
12+
import { AttributeType } from '../types';
1213

1314
import EppoClient, { IAssignmentDetails } from './eppo-client';
1415
import { initConfiguration } from './test-utils';
@@ -323,7 +324,12 @@ describe('EppoClient get*AssignmentDetails', () => {
323324
[VariationType.STRING]: client.getStringAssignmentDetails.bind(client),
324325
[VariationType.JSON]: client.getJSONAssignmentDetails.bind(client),
325326
};
326-
const assignmentFn = typeAssignmentDetailsFunctions[variationType];
327+
const assignmentFn = typeAssignmentDetailsFunctions[variationType] as (
328+
flagKey: string,
329+
subjectKey: string,
330+
subjectAttributes: Record<string, AttributeType>,
331+
defaultValue: boolean | string | number | object,
332+
) => IAssignmentDetails<boolean | string | number | object>;
327333
if (!assignmentFn) {
328334
throw new Error(`Unknown variation type: ${variationType}`);
329335
}

src/client/eppo-client-with-bandits.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ describe('EppoClient Bandits E2E test', () => {
163163
expect(banditEvent.action).toBe('adidas');
164164
expect(banditEvent.actionProbability).toBeCloseTo(0.099);
165165
expect(banditEvent.optimalityGap).toBe(7.1);
166-
expect(banditEvent.modelVersion).toBe('v123');
166+
expect(banditEvent.modelVersion).toBe('123');
167167
expect(banditEvent.subjectNumericAttributes).toStrictEqual({ age: 25 });
168168
expect(banditEvent.subjectCategoricalAttributes).toStrictEqual({
169169
country: 'USA',

src/client/eppo-client.spec.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IConfigurationStore } from '../configuration-store/configuration-store'
1717
import { MemoryOnlyConfigurationStore } from '../configuration-store/memory.store';
1818
import { MAX_EVENT_QUEUE_SIZE, DEFAULT_POLL_INTERVAL_MS, POLL_JITTER_PCT } from '../constants';
1919
import { Flag, ObfuscatedFlag, VariationType } from '../interfaces';
20+
import { AttributeType } from '../types';
2021

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

217-
const assignmentFn = typeAssignmentFunctions[variationType];
218+
const assignmentFn = typeAssignmentFunctions[variationType] as (
219+
flagKey: string,
220+
subjectKey: string,
221+
subjectAttributes: Record<string, AttributeType>,
222+
defaultValue: boolean | string | number | object,
223+
) => never;
218224
if (!assignmentFn) {
219225
throw new Error(`Unknown variation type: ${variationType}`);
220226
}
@@ -258,7 +264,12 @@ describe('EppoClient E2E test', () => {
258264
[VariationType.JSON]: client.getJSONAssignment.bind(client),
259265
};
260266

261-
const assignmentFn = typeAssignmentFunctions[variationType];
267+
const assignmentFn = typeAssignmentFunctions[variationType] as (
268+
flagKey: string,
269+
subjectKey: string,
270+
subjectAttributes: Record<string, AttributeType>,
271+
defaultValue: boolean | string | number | object,
272+
) => never;
262273
if (!assignmentFn) {
263274
throw new Error(`Unknown variation type: ${variationType}`);
264275
}

src/client/eppo-client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ export default class EppoClient {
515515
);
516516
evaluationDetails.banditAction = action;
517517
}
518-
} catch (err) {
518+
} catch (err: any) {
519519
logger.error('Error determining bandit action', err);
520520
if (!this.isGracefulFailureMode) {
521521
throw err;
@@ -752,7 +752,7 @@ export default class EppoClient {
752752
expectedVariationType,
753753
);
754754
return this.parseVariationWithDetails(result, defaultValue, expectedVariationType);
755-
} catch (error) {
755+
} catch (error: any) {
756756
const eppoValue = this.rethrowIfNotGraceful(error, defaultValue);
757757
if (error instanceof FlagEvaluationError && error.flagEvaluationDetails) {
758758
return {
@@ -790,7 +790,7 @@ export default class EppoClient {
790790
eppoValue: EppoValue.valueOf(result.variation.value, expectedVariationType),
791791
flagEvaluationDetails: result.flagEvaluationDetails,
792792
};
793-
} catch (error) {
793+
} catch (error: any) {
794794
const eppoValue = this.rethrowIfNotGraceful(error, defaultValue);
795795
return {
796796
eppoValue,
@@ -1010,7 +1010,7 @@ export default class EppoClient {
10101010
eventsToFlush.forEach((event) => {
10111011
try {
10121012
logFunction(event);
1013-
} catch (error) {
1013+
} catch (error: any) {
10141014
logger.error(`[Eppo SDK] Error flushing event to logger: ${error.message}`);
10151015
}
10161016
});
@@ -1057,7 +1057,7 @@ export default class EppoClient {
10571057
allocationKey: allocationKey ?? '__eppo_no_allocation',
10581058
variationKey: variation?.key ?? '__eppo_no_variation',
10591059
});
1060-
} catch (error) {
1060+
} catch (error: any) {
10611061
logger.error(`[Eppo SDK] Error logging assignment event: ${error.message}`);
10621062
}
10631063
}

src/configuration-requestor.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe('ConfigurationRequestor', () => {
141141
const bannerBandit = banditModelStore.get('banner_bandit');
142142
expect(bannerBandit?.banditKey).toBe('banner_bandit');
143143
expect(bannerBandit?.modelName).toBe('falcon');
144-
expect(bannerBandit?.modelVersion).toBe('v123');
144+
expect(bannerBandit?.modelVersion).toBe('123');
145145
const bannerModelData = bannerBandit?.modelData;
146146
expect(bannerModelData?.gamma).toBe(1);
147147
expect(bannerModelData?.defaultActionScore).toBe(0);

src/evaluator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface FlagEvaluation extends FlagEvaluationWithoutDetails {
3535
}
3636

3737
export class Evaluator {
38-
sharder: Sharder;
38+
private readonly sharder: Sharder;
3939

4040
constructor(sharder?: Sharder) {
4141
this.sharder = sharder ?? new MD5Sharder();
@@ -136,7 +136,7 @@ export class Evaluator {
136136
'No allocations matched. Falling back to "Default Allocation", serving NULL',
137137
),
138138
);
139-
} catch (err) {
139+
} catch (err: any) {
140140
const flagEvaluationDetails = flagEvaluationDetailsBuilder.gracefulBuild(
141141
'ASSIGNMENT_ERROR',
142142
`Assignment Error: ${err.message}`,

0 commit comments

Comments
 (0)