Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 94094fd

Browse files
committed
Merge branch 'v4' into github
* v4: test suite doesn't pass cleanly prepare already runs build v4.0.0-github.0 Ignore package tarballs Resume building non-minified ES entrypoint revert to master Expose an ESM-FULL bundle which includes optimizely deps Standardize ESM bundle Generate both min and non-min esm output exports option for es output is redundant. auto is best Use rollup --config- options for specifying bundles Build-all by default build various bundles using --config-* param chore: Prepare for 4.0.0 release (optimizely#468) fix: Removed React Native client engine temporarily (optimizely#466) chore: Prepare for 4.0.0-rc.2 release (optimizely#465) chore: Add source maps to build output (optimizely#464) fix(project config): Don't mutate the datafile object (optimizely#462) chore: Prepare for 4.0.0-rc.1 release (optimizely#461) chore: Prepare for js-sdk-datafile-manager 0.5.0 release (optimizely#460) chore(datafile manager): Remove react native datafile manager entry from package.json (optimizely#459) fix(datafile manager): Node datafile requests use gzip,deflate compression (optimizely#456) docs(datafile manager): Removed manual dependency installation requirement from docs (optimizely#457) chore(datafile manager): Added async storage as dev dependency (optimizely#455) refactor: Added a separate bundle for Json Schema Validator (optimizely#454) refactor: Convert lib/utils to ES module (Part 2/2) (optimizely#452) refactor: Convert lib/core to ES module (Part 2/2) (optimizely#450) chore(datafile manager): Update years in header comments (optimizely#453) refactor: Convert lib/core to ES module (Part 1/2) (optimizely#449) refactor: Convert lib/utils to ES module (Part 1/2) (optimizely#451) refactor: Convert lib/optimizely/* and lib/tests/* to ES module (optimizely#448) refactor: Convert lib/plugins from CJS to ES module (optimizely#427) chore: Update js-sdk-utils to 0.2.0 (optimizely#447) refactor: Convert entry points to es module and create minified bundles (optimizely#445) chore: Update CHANGELOG.MD for jsonSchemaValidator change (optimizely#443) Change functionality of JSON schema validation by removing skipJSONValidation entirely. Now a user needs to import jsonSchemaValidator from @optimizely/optimizely-sdk/lib/utils/json_schema_validator and pass it to createInstance when validation is desired. (optimizely#442) chore(datafile manager): Lint and formatting fixes for datafile manager tests (optimizely#441) [OASIS-6102]: changed functionality of the JSON schema validator module (optimizely#438) chore(datafile manager): Fix ESLint warnings & errors, apply Prettier formatting (optimizely#440) fix (datafile-manager): Fix boolean types, remove StaticDatafileManager, update READMe, add eslint + prettier (optimizely#436)
2 parents b1f33ed + 5b5a56b commit 94094fd

File tree

108 files changed

+4826
-4312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+4826
-4312
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
npm-debug.log
33
dist
44
node_modules
5+
/packages/*/optimizely-*.tgz
6+
57
lerna-debug.log
68

79
coverage/

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,36 @@ This repository is a monorepo that we manage using [Lerna](https://github.com/le
2727
### Contributing
2828

2929
Please see [CONTRIBUTING](CONTRIBUTING.md).
30+
31+
## Credits
32+
33+
First-party code (under `packages/optimizely-sdk/lib/`, `packages/datafile-manager/lib`, `packages/datafile-manager/src`, `packages/datafile-manager/__test__`, `packages/event-processor/src`, `packages/event-processor/__tests__`, `packages/logging/src`, `packages/logging/__tests__`, `packages/utils/src`, `packages/utils/__tests__`) is copyright Optimizely, Inc. and contributors, licensed under Apache 2.0.
34+
35+
## Additional Code
36+
37+
Prod dependencies are as follows:
38+
39+
```json
40+
{
41+
"json-schema@0.2.3": {
42+
"licenses": [
43+
"AFLv2.1",
44+
"BSD"
45+
],
46+
"publisher": "Kris Zyp",
47+
"repository": "https://github.com/kriszyp/json-schema"
48+
},
49+
"murmurhash@0.0.2": {
50+
"licenses": "MIT*",
51+
"repository": "https://github.com/perezd/node-murmurhash"
52+
},
53+
"uuid@3.3.2": {
54+
"licenses": "MIT",
55+
"repository": "https://github.com/kelektiv/node-uuid"
56+
},
57+
"decompress-response@4.2.1": {
58+
"licenses": "MIT",
59+
"repository": "https://github.com/sindresorhus/decompress-response"
60+
}
61+
}
62+
```
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2020 Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
parserOptions: {
19+
ecmaVersion: 2015,
20+
sourceType: 'module',
21+
},
22+
env: {
23+
browser: true,
24+
es6: true,
25+
jest: true,
26+
mocha: true,
27+
node: true,
28+
},
29+
extends: [
30+
'eslint:recommended',
31+
'plugin:@typescript-eslint/recommended',
32+
'prettier/@typescript-eslint',
33+
34+
// Prettier should always go last so it can trump any rules above
35+
'plugin:prettier/recommended',
36+
'prettier/react',
37+
],
38+
rules: {
39+
'@typescript-eslint/ban-ts-ignore': 'off',
40+
'@typescript-eslint/camelcase': 'off',
41+
'@typescript-eslint/no-empty-function': 'off',
42+
'@typescript-eslint/no-explicit-any': 'off',
43+
'@typescript-eslint/no-non-null-assertion': 'off'
44+
},
45+
};

packages/datafile-manager/.prettierrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"jsxBracketSameLine": false
10+
}

packages/datafile-manager/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## [Unreleased]
88
Changes that have landed but are not yet released.
99

10+
## [0.5.0] - April 17, 2020
11+
12+
### Breaking Changes
13+
- Removed `StaticDatafileManager` from all top level exports
14+
- Dropped support for Node.js version <8
15+
16+
### Fixed
17+
18+
- Node datafile manager requests use gzip,deflate compression
19+
1020
## [0.4.0] - June 12, 2019
1121

1222
### Changed

packages/datafile-manager/README.md

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
# Javascript SDK Datafile Manager
22

3-
This package provides a datafile manager implementations for Node.js and the browser.
3+
This package provides datafile manager implementations for Node.js, browsers, and React Native.
4+
5+
## Requirements
6+
In general, an ES5-compatible environment is required, as well as `Promise` (must be polyfilled if absent).
7+
8+
Platform-specific minimum supported versions:
9+
10+
- Node.js: `8`
11+
- React Native: `0.61.5`
412

513
## Installation
614

715
```sh
8-
npm install @optimizely/js-sdk-datafile-manager
16+
npm i @optimizely/js-sdk-datafile-manager
17+
```
18+
19+
For React Native, installation of peer dependency `@react-native-community/async-storage` is also required:
20+
```sh
21+
npm i @react-native-community/async-storage
922
```
1023

1124
## Usage
1225

1326
```js
14-
const { DatafileManager } = require('@optimizely/js-sdk-datafile-manager')
27+
const { HttpPollingDatafileManager } = require('@optimizely/js-sdk-datafile-manager')
1528

16-
const manager = new DatafileManager({
29+
const manager = new HttpPollingDatafileManager({
1730
sdkKey: '9LCprAQyd1bs1BBXZ3nVji',
1831
autoUpdate: true,
1932
updateInterval: 5000,
@@ -29,3 +42,8 @@ manager.on('update', ({ datafile }) => {
2942
console.log(datafile)
3043
})
3144
```
45+
46+
## Development
47+
- The `lint` package.json script runs ESLint and Prettier. This applies formatting and lint fixes to all `.ts` files in the `src/` directory.
48+
- The `test` package.json script runs our Jest-based test suite.
49+
- The `tsc` package.json script runs the TypeScript compiler to build the final scripts for publishing (into the `lib/` directory).
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019, Optimizely
2+
* Copyright 2019-2020, 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.
@@ -14,50 +14,50 @@
1414
* limitations under the License.
1515
*/
1616

17-
import BackoffController from '../src/backoffController'
17+
import BackoffController from '../src/backoffController';
1818

1919
describe('backoffController', () => {
2020
describe('getDelay', () => {
2121
it('returns 0 from getDelay if there have been no errors', () => {
22-
const controller = new BackoffController()
23-
expect(controller.getDelay()).toBe(0)
24-
})
22+
const controller = new BackoffController();
23+
expect(controller.getDelay()).toBe(0);
24+
});
2525

2626
it('increases the delay returned from getDelay (up to a maximum value) after each call to countError', () => {
27-
const controller = new BackoffController()
28-
controller.countError()
29-
expect(controller.getDelay()).toBeGreaterThanOrEqual(8000)
30-
expect(controller.getDelay()).toBeLessThan(9000)
31-
controller.countError()
32-
expect(controller.getDelay()).toBeGreaterThanOrEqual(16000)
33-
expect(controller.getDelay()).toBeLessThan(17000)
34-
controller.countError()
35-
expect(controller.getDelay()).toBeGreaterThanOrEqual(32000)
36-
expect(controller.getDelay()).toBeLessThan(33000)
37-
controller.countError()
38-
expect(controller.getDelay()).toBeGreaterThanOrEqual(64000)
39-
expect(controller.getDelay()).toBeLessThan(65000)
40-
controller.countError()
41-
expect(controller.getDelay()).toBeGreaterThanOrEqual(128000)
42-
expect(controller.getDelay()).toBeLessThan(129000)
43-
controller.countError()
44-
expect(controller.getDelay()).toBeGreaterThanOrEqual(256000)
45-
expect(controller.getDelay()).toBeLessThan(257000)
46-
controller.countError()
47-
expect(controller.getDelay()).toBeGreaterThanOrEqual(512000)
48-
expect(controller.getDelay()).toBeLessThan(513000)
27+
const controller = new BackoffController();
28+
controller.countError();
29+
expect(controller.getDelay()).toBeGreaterThanOrEqual(8000);
30+
expect(controller.getDelay()).toBeLessThan(9000);
31+
controller.countError();
32+
expect(controller.getDelay()).toBeGreaterThanOrEqual(16000);
33+
expect(controller.getDelay()).toBeLessThan(17000);
34+
controller.countError();
35+
expect(controller.getDelay()).toBeGreaterThanOrEqual(32000);
36+
expect(controller.getDelay()).toBeLessThan(33000);
37+
controller.countError();
38+
expect(controller.getDelay()).toBeGreaterThanOrEqual(64000);
39+
expect(controller.getDelay()).toBeLessThan(65000);
40+
controller.countError();
41+
expect(controller.getDelay()).toBeGreaterThanOrEqual(128000);
42+
expect(controller.getDelay()).toBeLessThan(129000);
43+
controller.countError();
44+
expect(controller.getDelay()).toBeGreaterThanOrEqual(256000);
45+
expect(controller.getDelay()).toBeLessThan(257000);
46+
controller.countError();
47+
expect(controller.getDelay()).toBeGreaterThanOrEqual(512000);
48+
expect(controller.getDelay()).toBeLessThan(513000);
4949
// Maximum reached - additional errors should not increase the delay further
50-
controller.countError()
51-
expect(controller.getDelay()).toBeGreaterThanOrEqual(512000)
52-
expect(controller.getDelay()).toBeLessThan(513000)
53-
})
50+
controller.countError();
51+
expect(controller.getDelay()).toBeGreaterThanOrEqual(512000);
52+
expect(controller.getDelay()).toBeLessThan(513000);
53+
});
5454

5555
it('resets the error count when reset is called', () => {
56-
const controller = new BackoffController()
57-
controller.countError()
58-
expect(controller.getDelay()).toBeGreaterThan(0)
59-
controller.reset()
60-
expect(controller.getDelay()).toBe(0)
61-
})
62-
})
63-
})
56+
const controller = new BackoffController();
57+
controller.countError();
58+
expect(controller.getDelay()).toBeGreaterThan(0);
59+
controller.reset();
60+
expect(controller.getDelay()).toBe(0);
61+
});
62+
});
63+
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019, Optimizely
2+
* Copyright 2019-2020, 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.
@@ -14,22 +14,22 @@
1414
* limitations under the License.
1515
*/
1616

17-
import BrowserDatafileManager from '../src/browserDatafileManager'
18-
import * as browserRequest from '../src/browserRequest'
19-
import { Headers, AbortableRequest } from '../src/http'
17+
import BrowserDatafileManager from '../src/browserDatafileManager';
18+
import * as browserRequest from '../src/browserRequest';
19+
import { Headers, AbortableRequest } from '../src/http';
2020
import { advanceTimersByTime, getTimerCount } from './testUtils';
2121

2222
describe('browserDatafileManager', () => {
23-
let makeGetRequestSpy: jest.SpyInstance<AbortableRequest, [string, Headers]>
23+
let makeGetRequestSpy: jest.SpyInstance<AbortableRequest, [string, Headers]>;
2424
beforeEach(() => {
25-
jest.useFakeTimers()
26-
makeGetRequestSpy = jest.spyOn(browserRequest, 'makeGetRequest')
27-
})
25+
jest.useFakeTimers();
26+
makeGetRequestSpy = jest.spyOn(browserRequest, 'makeGetRequest');
27+
});
2828

2929
afterEach(() => {
30-
jest.restoreAllMocks()
31-
jest.clearAllTimers()
32-
})
30+
jest.restoreAllMocks();
31+
jest.clearAllTimers();
32+
});
3333

3434
it('calls makeGetRequest when started', async () => {
3535
makeGetRequestSpy.mockReturnValue({
@@ -38,21 +38,21 @@ describe('browserDatafileManager', () => {
3838
statusCode: 200,
3939
body: '{"foo":"bar"}',
4040
headers: {},
41-
})
42-
})
41+
}),
42+
});
4343

4444
const manager = new BrowserDatafileManager({
4545
sdkKey: '1234',
4646
autoUpdate: false,
47-
})
48-
manager.start()
49-
expect(makeGetRequestSpy).toBeCalledTimes(1)
50-
expect(makeGetRequestSpy.mock.calls[0][0]).toBe('https://cdn.optimizely.com/datafiles/1234.json')
51-
expect(makeGetRequestSpy.mock.calls[0][1]).toEqual({})
47+
});
48+
manager.start();
49+
expect(makeGetRequestSpy).toBeCalledTimes(1);
50+
expect(makeGetRequestSpy.mock.calls[0][0]).toBe('https://cdn.optimizely.com/datafiles/1234.json');
51+
expect(makeGetRequestSpy.mock.calls[0][1]).toEqual({});
5252

53-
await manager.onReady()
54-
await manager.stop()
55-
})
53+
await manager.onReady();
54+
await manager.stop();
55+
});
5656

5757
it('calls makeGetRequest for live update requests', async () => {
5858
makeGetRequestSpy.mockReturnValue({
@@ -63,23 +63,23 @@ describe('browserDatafileManager', () => {
6363
headers: {
6464
'last-modified': 'Fri, 08 Mar 2019 18:57:17 GMT',
6565
},
66-
})
67-
})
66+
}),
67+
});
6868
const manager = new BrowserDatafileManager({
6969
sdkKey: '1234',
7070
autoUpdate: true,
71-
})
72-
manager.start()
73-
await manager.onReady()
74-
await advanceTimersByTime(300000)
75-
expect(makeGetRequestSpy).toBeCalledTimes(2)
76-
expect(makeGetRequestSpy.mock.calls[1][0]).toBe('https://cdn.optimizely.com/datafiles/1234.json')
71+
});
72+
manager.start();
73+
await manager.onReady();
74+
await advanceTimersByTime(300000);
75+
expect(makeGetRequestSpy).toBeCalledTimes(2);
76+
expect(makeGetRequestSpy.mock.calls[1][0]).toBe('https://cdn.optimizely.com/datafiles/1234.json');
7777
expect(makeGetRequestSpy.mock.calls[1][1]).toEqual({
78-
'if-modified-since': 'Fri, 08 Mar 2019 18:57:17 GMT'
79-
})
78+
'if-modified-since': 'Fri, 08 Mar 2019 18:57:17 GMT',
79+
});
8080

81-
await manager.stop()
82-
})
81+
await manager.stop();
82+
});
8383

8484
it('defaults to false for autoUpdate', async () => {
8585
makeGetRequestSpy.mockReturnValue({
@@ -90,16 +90,16 @@ describe('browserDatafileManager', () => {
9090
headers: {
9191
'last-modified': 'Fri, 08 Mar 2019 18:57:17 GMT',
9292
},
93-
})
94-
})
93+
}),
94+
});
9595
const manager = new BrowserDatafileManager({
9696
sdkKey: '1234',
97-
})
98-
manager.start()
99-
await manager.onReady()
97+
});
98+
manager.start();
99+
await manager.onReady();
100100
// Should not set a timeout for a later update
101-
expect(getTimerCount()).toBe(0)
101+
expect(getTimerCount()).toBe(0);
102102

103-
await manager.stop()
104-
})
105-
})
103+
await manager.stop();
104+
});
105+
});

0 commit comments

Comments
 (0)