Skip to content

Commit 843c9c4

Browse files
authored
refactor: Integrate code from utils package into optimizely-sdk (#749)
## Summary Integrated code from `@optimizely/js-sdk-utils` into `@optimizely/optimizely-sdk` package to reduce unnecessary external dependency. ## Test plan All existing unit and E2E tests pass.
1 parent 4034c7d commit 843c9c4

File tree

37 files changed

+6637
-2391
lines changed

37 files changed

+6637
-2391
lines changed

packages/optimizely-sdk/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Changed
1111
- Add package.json script for running Karma tests locally using Chrome ([#651](https://github.com/optimizely/javascript-sdk/pull/651)).
12-
- Replaced explicit typescript typings with auto generated ones ([#745](https://github.com/optimizely/javascript-sdk/pull/745))
12+
- Replaced explicit typescript typings with auto generated ones ([#745](https://github.com/optimizely/javascript-sdk/pull/745)).
13+
- Integrated code from `utils` package into `optimizely-sdk` ([#749](https://github.com/optimizely/javascript-sdk/pull/749)).
1314

1415
## [4.9.1] - January 18, 2022
1516

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
"transform": {
3+
"^.+\\.tsx?$": "ts-jest"
4+
},
5+
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.tsx?$",
6+
"moduleFileExtensions": [
7+
"ts",
8+
"tsx",
9+
"js",
10+
"jsx",
11+
"json",
12+
"node"
13+
],
14+
}

packages/optimizely-sdk/lib/core/audience_evaluator/index.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016, 2018-2020, Optimizely
2+
* Copyright 2016, 2018-2020, 2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616
import sinon from 'sinon';
1717
import { assert } from 'chai';
1818
import { getLogger } from '@optimizely/js-sdk-logging';
19-
import { sprintf } from '@optimizely/js-sdk-utils';
19+
import { sprintf } from '../../utils/fns';
2020

2121
import { createAudienceEvaluator } from './index';
2222
import * as conditionTreeEvaluator from '../condition_tree_evaluator';

packages/optimizely-sdk/lib/core/bucketer/index.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017, 2019-2021, Optimizely
2+
* Copyright 2016-2017, 2019-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616
import sinon from 'sinon';
1717
import { assert, expect } from 'chai';
1818
import { cloneDeep } from 'lodash';
19-
import { sprintf } from '@optimizely/js-sdk-utils';
19+
import { sprintf } from '../../utils/fns';
2020

2121
import * as bucketer from './';
2222
import {

packages/optimizely-sdk/lib/core/bucketer/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016, 2019-2021, Optimizely
2+
* Copyright 2016, 2019-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717
/**
1818
* Bucketer API for determining the variation id from the specified parameters
1919
*/
20-
import { sprintf } from '@optimizely/js-sdk-utils';
20+
import { sprintf } from '../../utils/fns';
2121
import murmurhash from 'murmurhash';
2222
import { LogHandler } from '@optimizely/js-sdk-logging';
2323
import {

packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2018-2020, Optimizely, Inc. and contributors *
2+
* Copyright 2018-2020, 2022, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -15,7 +15,7 @@
1515
***************************************************************************/
1616
import sinon from 'sinon';
1717
import { assert } from 'chai';
18-
import { sprintf } from '@optimizely/js-sdk-utils';
18+
import { sprintf } from '../../utils/fns';
1919

2020
import {
2121
LOG_LEVEL,

packages/optimizely-sdk/lib/core/decision_service/index.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2017-2021 Optimizely, Inc. and contributors *
2+
* Copyright 2017-2022 Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -16,7 +16,7 @@
1616
import sinon from 'sinon';
1717
import { assert } from 'chai';
1818
import cloneDeep from 'lodash/cloneDeep';
19-
import { sprintf } from '@optimizely/js-sdk-utils';
19+
import { sprintf } from '../../utils/fns';
2020

2121
import { createDecisionService } from './';
2222
import * as bucketer from '../bucketer';

packages/optimizely-sdk/lib/core/decision_service/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* See the License for the specific language governing permissions and *
1414
* limitations under the License. *
1515
***************************************************************************/
16-
import { sprintf } from '@optimizely/js-sdk-utils';
1716
import { LogHandler } from '@optimizely/js-sdk-logging';
17+
import { sprintf } from '../../utils/fns';
1818

1919
import fns from '../../utils/fns';
2020
import { bucket } from '../bucketer';

packages/optimizely-sdk/lib/core/notification_center/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2020, Optimizely
2+
* Copyright 2020, 2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,9 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { objectValues } from '@optimizely/js-sdk-utils';
1716
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
18-
import { NOTIFICATION_TYPES as notificationTypesEnum } from '@optimizely/js-sdk-utils';
17+
import { objectValues } from '../../utils/fns';
1918
import { NotificationListener, ListenerPayload } from '../../shared_types';
2019

2120
import {
@@ -186,9 +185,9 @@ export class NotificationCenter {
186185

187186
/**
188187
* Remove all previously added notification listeners for the argument type
189-
* @param {notificationTypesEnum} notificationType One of NOTIFICATION_TYPES
188+
* @param {NOTIFICATION_TYPES} notificationType One of NOTIFICATION_TYPES
190189
*/
191-
clearNotificationListeners(notificationType: notificationTypesEnum): void {
190+
clearNotificationListeners(notificationType: NOTIFICATION_TYPES): void {
192191
try {
193192
this.notificationListeners[notificationType] = [];
194193
} catch (e) {
@@ -239,3 +238,9 @@ export class NotificationCenter {
239238
export function createNotificationCenter(options: NotificationCenterOptions): NotificationCenter {
240239
return new NotificationCenter(options);
241240
}
241+
242+
export interface NotificationSender {
243+
// TODO[OASIS-6649]: Don't use any type
244+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
245+
sendNotifications(notificationType: NOTIFICATION_TYPES, notificationData?: any): void
246+
}

packages/optimizely-sdk/lib/core/project_config/index.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2021, Optimizely
2+
* Copyright 2016-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ import sinon from 'sinon';
1717
import { assert } from 'chai';
1818
import { forEach, cloneDeep } from 'lodash';
1919
import { getLogger } from '@optimizely/js-sdk-logging';
20-
import { sprintf } from '@optimizely/js-sdk-utils';
20+
import { sprintf } from '../../utils/fns';
2121

2222
import fns from '../../utils/fns';
2323
import projectConfig from './';

0 commit comments

Comments
 (0)