Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit a38d913

Browse files
LaunchDarklyReleaseBoteli-darklyLaunchDarklyCIbwoskow-ldmaxwellgerber
authored
prepare 6.3.0 release (#236)
* fix tests * object shorthand * add more end-to-end tests, improve HTTP test helpers, general cleanup * rm nock * Node 6 compatibility * remove redundant helper, misc cleanup * Node 6 compatibility * fix comment * change asyncify to promisifySingle * misc fixes * add Windows CircleCI job * fix config * syntax * diagnostic events, part 2: initial event and stats, except for stream inits * comments * add test for stats event * capture stream connection stats in diagnostic events * fix test * remove eventReportingDisabled from diagnostic event; only create diagnosticsManager if needed * revise tests to use new helper package * misc cleanup * use launchdarkly-js-test-helpers 1.0.0 * fix package reference * minor fixes to config validation messages + add comment * diagnostic eventsInQueue counter should be # of events at last flush * rename eventsInQueue to eventsInLastBatch * don't let user fall outside of last bucket in rollout * add unit tests for basic bucketing logic and edge case * avoid redundant property lookups * fix Redis client parameter to match TS declaration (but still support old incorrect parameter) * add event payload ID * remove mistakenly checked-in test code (note, this SDK key was only valid on staging) * add mention of singleton usage * update diagnostic event info for OS name, data store type, Node version * standardize linting * disallow window and document * fix null/undef checks * misc linting fixes * inlineUsersInEvents is not an unknown option * drop node-sha1 dependency * don't omit streamInits.failed when it's false * bump request dependency to get security patch; loosen some exact dependencies * remove request package; improve polling cache logic + add test * bump typescript version to fix build error in Node 6 * update @types/node to fix TypeScript check step * lint * make sure we keep polling regardless of whether we got new data * use launchdarkly-eventsource, make stream retry behavior consistent * stream retry delay option should be in seconds & should be included in diagnostics * minor test fix * fix: Throw an error on malformed user-supplied logger * don't call unref() on Redis client; ensure that database integration tests close the store * update Redis driver to major version 3 * add test case * allow redisOpts parameter to be omitted * add logger adapter shim + tests * minor cleanup and comments for ch74741 fix (logger wrapper) * fix proxy tunnel configuration and make sure it's used in streaming * change some string concatenation expressions to use interpolation * feat: upgrade winston (#189) * fix merge * remove support for indirect/patch and indirect/put (#182) * reuse same Promise and same event listeners for all waitForInitialization calls * better docs for waitForInitialization + misc doc cleanup (#184) * update js-eventsource to 1.3.1 for stream parsing bugfix (#185) * fix broken logger format (#186) * retroactively update changelog for bugfix in 5.13.2 release * allow get/getAll Redis queries to be queued if Redis client hasn't yet connected * set stream read timeout * adding the alias functionality (#190) * Removed the guides link * remove monkey-patching of setImmediate * Persist contextKind property during feature and custom event transformations (#194) * add inlineUsersInEvents option in TypeScript * Add support for seed to bucketUser * Add note for incorporating seed into evaluation * Send events when the evaluation is from an experiment * Use seed to evaluate. * Clean up test descriptions * Rename variable to be less confusing * Use ternary to eliminate mutation * Make return signature more consistent * Un-prettier the tests * redis lower bounds bump (#199) * update launchdarkly-js-test-helpers to fix TLS tests (#200) * update js-eventsource to remove vulnerability warning (#201) * add CI jobs for all compatible Node versions * CI fixes * more CI fixes * comment * use default value to simplify config * (6.0 - #1) stop saying we're compatible with Node <12 (#203) * add CI jobs for all compatible Node versions (#202) * (6.0 - #2) remove Redis integration (#204) * allow feature store to be specified as a factory (so it can get our logger) * (6.0 - #3) remove Winston (#205) * remove deprecated things for 6.0 (#206) * update node-cache to 5.x (drops old Node compat) * update semver to 7.x (drops old Node compat) * update uuid to 8.x (Node compat, perf improvements, bugfixes) * update dev dependencies * linter * replace lrucache package with lru-cache (#209) * make yaml dependency optional (#210) * update release metadata to include maintenance branch * remove package-lock.json (#211) * rm prerelease changelog * (big segments #1) add interfaces for big segments (#212) * (big segments #2) add all components for big segments except evaluation (#213) * (big segments #3) implement big segments in flag evaluation (#214) * (big segments #4) add standard test suite for big segment store tests + refactor feature store tests (#215) * move new interfaces to a module instead of a namespace (#216) * fix TS export of CachingStoreWrapper * use Releaser v2 config * fix overly specific test expectation that breaks in Node 17 * Initial work on FlagBuilder (#219) * Add TestData factory(with some dummy methods); Initial work on FlagBuilder * fixed indentation and linter errors; fixed an error in update; fixed incorrect test label * fixed typo in TestData store * converted boolean variation constants to be file variables instead of class variables Co-authored-by: charukiewicz <christian@foxhound.systems> Co-authored-by: belevy <ben@foxhound.systems> * implemented FlagRuleBuilder; added .build() methods to FlagBuilder/FlagRuleBuilder and changed tests to avoid using private interface * converted _targets to be Map instead of object literal; changed variationForBoolean to be a module-scoped function instead class-scoped * Implement stream processor(data source) interface for test data * Add TestData to index.js and write out the types for TestData and friends * added testdata documentation to index.d.ts; fix linter errors; changed flag default behavior to create boolean flag * Fix the interface file: reindented to 2 spaces, corrected definition of functions from properties to functions in interfaces; corrected issues in JSDoc comments * modify tests to fix capitalization and actually test the test datasource works as an LDClient updateProcessor. * Fix linter error on defaulted callback * explicitly enable JSDOM types in TypeScript build to avoid errors when jsdom is referenced for some reason * capitalize Big Segments in docs & logs * documentation comment fixes for TestData * pin TypeScript to 4.4.x * move TestData and FIleDataSource to integrations module * lint * rename types used by TestData for clarity (#229) * use varargs semantics for TestFlagBuilder.variations() and add it to the TS interface (#230) * don't ever use for...in (#232) * don't ever use for...in * add null guard * bump launchdarkly-eventsource dependency for sc-136154 fix * use TestData in our own tests (#231) * use TestData in our own tests * update TS interface * lint * typo * fix allFlagsState behavior regarding experimentation * lint * allow "secondary" to be referenced in clauses * don't throw an exception for non-string in semver comparison * correctly handle "client not ready" condition in allFlagsState * lint Co-authored-by: Eli Bishop <eli@launchdarkly.com> Co-authored-by: LaunchDarklyCI <dev@launchdarkly.com> Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com> Co-authored-by: Maxwell Gerber <maxwell.gerber@mulesoft.com> Co-authored-by: Chris West <solo-github@goeswhere.com> Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com> Co-authored-by: Mike Zorn <mike@launchdarkly.com> Co-authored-by: Robert J. Neal <rneal@launchdarkly.com> Co-authored-by: Ben Levy <benjaminlevy007@gmail.com> Co-authored-by: charukiewicz <christian@foxhound.systems> Co-authored-by: belevy <ben@foxhound.systems> Co-authored-by: charukiewicz <charukiewicz@protonmail.com> Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com>
1 parent 1268551 commit a38d913

13 files changed

+1186
-211
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ env:
77
es6: true
88
node: true
99
parserOptions:
10-
ecmaVersion: 2017 # allows us to use async/await, now that our Node version is always >= 8
10+
ecmaVersion: 2018
1111
plugins:
1212
#- babel
1313
- prettier

index.d.ts

Lines changed: 403 additions & 2 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ const newClient = function (sdkKey, originalConfig) {
435435
module.exports = {
436436
init: newClient,
437437
basicLogger: basicLogger,
438-
FileDataSource: FileDataSource,
438+
FileDataSource: FileDataSource, // deprecated entry point - should use integrations module now
439439
errors: errors,
440440
};
441441

integrations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const FileDataSource = require('./file_data_source');
2+
const TestData = require('./test_data');
3+
4+
module.exports = {
5+
FileDataSource,
6+
TestData,
7+
};

test-types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// developer can use all of the SDK features.
66

77
import * as ld from 'launchdarkly-node-server-sdk';
8+
import * as integrations from 'launchdarkly-node-server-sdk/integrations';
89
import * as interfaces from 'launchdarkly-node-server-sdk/interfaces';
910

1011
var logger: ld.LDLogger = {
@@ -96,6 +97,24 @@ var logger1: ld.LDLogger = ld.basicLogger();
9697
var logger2: ld.LDLogger = ld.basicLogger({ level: 'info' });
9798
var logger3: ld.LDLogger = ld.basicLogger({ destination: console.log });
9899

100+
// integrations module:
101+
102+
// FileDataSource
103+
const fdsOptions: integrations.FileDataSourceOptions = {
104+
paths: [ 'filepath' ],
105+
autoUpdate: true,
106+
logger: ld.basicLogger(),
107+
};
108+
const fds = integrations.FileDataSource(fdsOptions);
109+
110+
// TestData
111+
const td: integrations.TestData = integrations.TestData();
112+
const fb: integrations.TestDataFlagBuilder = td.flag('key');
113+
td.update(fb);
114+
fb.ifMatch('name', 'x').thenReturn(true);
115+
116+
// interfaces module:
117+
99118
// BigSegmentStoreStatusProvider
100119
var bsssp: interfaces.BigSegmentStoreStatusProvider = client.bigSegmentStoreStatusProvider
101120
var bssStatus: interfaces.BigSegmentStoreStatus | undefined = bsssp.getStatus();

test/LDClient-big-segments-test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const { hashForUserKey } = require('../big_segments');
22
const { makeBigSegmentRef } = require('../evaluator');
3-
const InMemoryFeatureStore = require('../feature_store');
4-
const dataKind = require('../versioned_data_kind');
3+
const { TestData } = require('../integrations');
54
const stubs = require('./stubs');
65
const { makeSegmentMatchClause } = require('./evaluator_helpers');
7-
const { promisifySingle, withCloseable } = require('launchdarkly-js-test-helpers');
6+
const { withCloseable } = require('launchdarkly-js-test-helpers');
87

98
describe('LDClient - big segments', () => {
109

@@ -26,18 +25,16 @@ describe('LDClient - big segments', () => {
2625
}
2726

2827
async function makeClient(bigSegmentsStore, config) {
29-
const dataStore = InMemoryFeatureStore();
30-
const initData = {
31-
[dataKind.features.namespace]: { [flag.key]: flag },
32-
[dataKind.segments.namespace]: { [bigSegment.key]: bigSegment },
33-
};
34-
await promisifySingle(dataStore.init)(initData);
28+
const td = TestData();
29+
td.usePreconfiguredFlag(flag);
30+
td.usePreconfiguredSegment(bigSegment);
3531

3632
const bigSegmentsConfig = {
3733
store: bigSegmentsStore && (() => bigSegmentsStore),
3834
...(config && config.bigSegments),
3935
};
40-
return stubs.createClient({ ...config, featureStore: dataStore, bigSegments: bigSegmentsConfig });
36+
37+
return stubs.createClient({ ...config, updateProcessor: td, bigSegments: bigSegmentsConfig });
4138
}
4239

4340
it('user not found in big segment store', async () => {

test/LDClient-evaluation-all-flags-test.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { TestData } = require('../integrations');
12
const stubs = require('./stubs');
23

34
describe('LDClient.allFlagsState', () => {
@@ -31,8 +32,12 @@ describe('LDClient.allFlagsState', () => {
3132
trackEvents: false,
3233
trackEventsFallthrough: true
3334
};
35+
const td = TestData();
36+
td.usePreconfiguredFlag(flag1);
37+
td.usePreconfiguredFlag(flag2);
38+
td.usePreconfiguredFlag(flag3);
3439

35-
const client = stubs.createClient({}, { [flag1.key]: flag1, [flag2.key]: flag2, [flag3.key]: flag3 });
40+
const client = stubs.createClient({ updateProcessor: td });
3641
await client.waitForInitialization();
3742
const state = await client.allFlagsState(defaultUser);
3843
expect(state.valid).toEqual(true);
@@ -66,29 +71,29 @@ describe('LDClient.allFlagsState', () => {
6671
});
6772

6873
it('can filter for only client-side flags', async () => {
69-
const flag1 = { key: 'server-side-1', on: false, offVariation: 0, variations: ['a'], clientSide: false };
70-
const flag2 = { key: 'server-side-2', on: false, offVariation: 0, variations: ['b'], clientSide: false };
71-
const flag3 = { key: 'client-side-1', on: false, offVariation: 0, variations: ['value1'], clientSide: true };
72-
const flag4 = { key: 'client-side-2', on: false, offVariation: 0, variations: ['value2'], clientSide: true };
73-
const client = stubs.createClient({}, {
74-
'server-side-1': flag1, 'server-side-2': flag2, 'client-side-1': flag3, 'client-side-2': flag4
75-
});
74+
const td = TestData();
75+
td.usePreconfiguredFlag({ key: 'server-side-1', on: false, offVariation: 0, variations: ['a'], clientSide: false });
76+
td.usePreconfiguredFlag({ key: 'server-side-2', on: false, offVariation: 0, variations: ['b'], clientSide: false });
77+
td.usePreconfiguredFlag({ key: 'client-side-1', on: false, offVariation: 0, variations: ['value1'], clientSide: true });
78+
td.usePreconfiguredFlag({ key: 'client-side-2', on: false, offVariation: 0, variations: ['value2'], clientSide: true });
79+
const client = stubs.createClient({ updateProcessor: td });
7680
await client.waitForInitialization();
7781
const state = await client.allFlagsState(defaultUser, { clientSideOnly: true });
7882
expect(state.valid).toEqual(true);
7983
expect(state.allValues()).toEqual({ 'client-side-1': 'value1', 'client-side-2': 'value2' });
8084
});
8185

8286
it('can include reasons', async () => {
83-
const flag = {
87+
const td = TestData();
88+
td.usePreconfiguredFlag({
8489
key: 'feature',
8590
version: 100,
8691
offVariation: 1,
8792
variations: ['a', 'b'],
8893
trackEvents: true,
8994
debugEventsUntilDate: 1000
90-
};
91-
const client = stubs.createClient({}, { feature: flag });
95+
});
96+
const client = stubs.createClient({ updateProcessor: td });
9297
await client.waitForInitialization();
9398
const state = await client.allFlagsState(defaultUser, { withReasons: true });
9499
expect(state.valid).toEqual(true);
@@ -130,9 +135,12 @@ describe('LDClient.allFlagsState', () => {
130135
variations: ['value3'],
131136
debugEventsUntilDate: 1000
132137
};
138+
const td = TestData();
139+
td.usePreconfiguredFlag(flag1);
140+
td.usePreconfiguredFlag(flag2);
141+
td.usePreconfiguredFlag(flag3);
133142

134-
const client = stubs.createClient({}, { flag1: flag1, flag2: flag2, flag3: flag3 });
135-
const user = { key: 'user' };
143+
const client = stubs.createClient({ updateProcessor: td });
136144
await client.waitForInitialization();
137145
const state = await client.allFlagsState(defaultUser, { withReasons: true, detailsOnlyForTrackedFlags: true });
138146
expect(state.valid).toEqual(true);
@@ -169,8 +177,10 @@ describe('LDClient.allFlagsState', () => {
169177
on: false,
170178
offVariation: null
171179
};
180+
const td = TestData();
181+
td.usePreconfiguredFlag(flag);
172182
const logger = stubs.stubLogger();
173-
const client = stubs.createClient({ offline: true, logger: logger }, { flagkey: flag });
183+
const client = stubs.createClient({ offline: true, logger: logger, updateProcessor: td });
174184
await client.waitForInitialization();
175185
const state = await client.allFlagsState(defaultUser);
176186
expect(state.valid).toEqual(false);
@@ -180,17 +190,15 @@ describe('LDClient.allFlagsState', () => {
180190

181191
it('does not overflow the call stack when evaluating a huge number of flags', async () => {
182192
const flagCount = 5000;
183-
const flags = {};
193+
const td = TestData();
184194
for (let i = 0; i < flagCount; i++) {
185-
const key = 'feature' + i;
186-
const flag = {
187-
key: key,
195+
td.usePreconfiguredFlag({
196+
key: 'feature' + i,
188197
version: 1,
189198
on: false
190-
};
191-
flags[key] = flag;
199+
});
192200
}
193-
const client = stubs.createClient({}, flags);
201+
const client = stubs.createClient({ updateProcessor: td });
194202
await client.waitForInitialization();
195203
const state = await client.allFlagsState(defaultUser);
196204
expect(Object.keys(state.allValues()).length).toEqual(flagCount);

0 commit comments

Comments
 (0)