Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
554 commits
Select commit Hold shift + click to select a range
7ca8250
rm nock
eli-darkly Nov 20, 2019
60222a2
Node 6 compatibility
eli-darkly Nov 20, 2019
96f0352
remove redundant helper, misc cleanup
eli-darkly Nov 20, 2019
a351318
Node 6 compatibility
eli-darkly Nov 20, 2019
e9c869e
fix comment
eli-darkly Nov 20, 2019
a556934
change asyncify to promisifySingle
eli-darkly Nov 20, 2019
ea227eb
misc fixes
eli-darkly Nov 20, 2019
42603da
add Windows CircleCI job
eli-darkly Nov 20, 2019
382ee93
fix config
eli-darkly Nov 20, 2019
193f2d4
syntax
eli-darkly Nov 20, 2019
dc2755a
Merge pull request #159 from launchdarkly/eb/ch56746/windows-ci
eli-darkly Nov 21, 2019
c6d3079
Merge branch 'master' into diag-events-merged
eli-darkly Nov 21, 2019
4cce49e
Merge branch 'eb/ch56656/better-async-helper' into diag-events-merged
eli-darkly Nov 21, 2019
3d8bd18
diagnostic events, part 2: initial event and stats, except for stream…
eli-darkly Nov 21, 2019
9b6fe96
comments
eli-darkly Nov 21, 2019
638d011
add test for stats event
eli-darkly Nov 21, 2019
5dd0195
capture stream connection stats in diagnostic events
eli-darkly Nov 21, 2019
a5338c2
fix test
eli-darkly Nov 21, 2019
b187af3
remove eventReportingDisabled from diagnostic event; only create diag…
eli-darkly Nov 22, 2019
cdefc53
Merge branch 'eb/ch56381/diag-events-2-initial' into eb/ch56381/diag-…
eli-darkly Nov 22, 2019
3da81f7
Merge pull request #157 from launchdarkly/eb/ch56656/http-test-cleanup
eli-darkly Nov 23, 2019
14f5f61
Merge pull request #158 from launchdarkly/eb/ch56656/better-async-helper
eli-darkly Nov 23, 2019
4f16b1d
revise tests to use new helper package
eli-darkly Nov 23, 2019
79db3e0
Merge branch 'master' into diag-events-merged
eli-darkly Nov 23, 2019
af8e51e
Merge branch 'diagnostic-events' into eb/ch56381/diag-events-2-initial
eli-darkly Nov 23, 2019
9630ddb
misc cleanup
eli-darkly Nov 23, 2019
31a9b41
Merge pull request #160 from launchdarkly/eb/ch56381/diag-events-2-in…
eli-darkly Nov 23, 2019
75a9cd2
Merge branch 'diagnostic-events' into eb/ch56381/diag-events-3-stream
eli-darkly Nov 23, 2019
81d5249
Merge pull request #161 from launchdarkly/eb/ch56381/diag-events-3-st…
eli-darkly Nov 23, 2019
90ef205
Merge branch 'master' into eb/ch57131/new-test-package
eli-darkly Nov 23, 2019
677e1b2
use launchdarkly-js-test-helpers 1.0.0
eli-darkly Nov 26, 2019
438cf91
fix package reference
eli-darkly Nov 26, 2019
d7208df
minor fixes to config validation messages + add comment
eli-darkly Dec 4, 2019
cc9dbed
Merge pull request #163 from launchdarkly/eb/ch56521/config-validatio…
eli-darkly Dec 4, 2019
c015310
Merge branch 'master' into diagnostic-events
eli-darkly Dec 5, 2019
1f75d71
Merge pull request #162 from launchdarkly/eb/ch57131/new-test-package
eli-darkly Dec 6, 2019
1eea22e
Merge branch 'master' into diagnostic-events
eli-darkly Dec 9, 2019
aace735
diagnostic eventsInQueue counter should be # of events at last flush
eli-darkly Dec 9, 2019
1fb38d1
rename eventsInQueue to eventsInLastBatch
eli-darkly Dec 10, 2019
d270a35
Merge pull request #164 from launchdarkly/eb/ch56381-ch58405/diagnost…
eli-darkly Dec 11, 2019
f866ab4
merge from public after release
LaunchDarklyCI Dec 11, 2019
24b85c3
don't let user fall outside of last bucket in rollout
bwoskow-ld Dec 24, 2019
561ed34
add unit tests for basic bucketing logic and edge case
eli-darkly Dec 30, 2019
359678e
avoid redundant property lookups
eli-darkly Dec 30, 2019
787c9e3
Merge pull request #165 from launchdarkly/bw/ch43307/bucket-issue
eli-darkly Jan 3, 2020
cea2d8a
merge from public after release
LaunchDarklyCI Jan 6, 2020
e9d2cfd
fix Redis client parameter to match TS declaration (but still support…
eli-darkly Jan 13, 2020
cc98785
Merge pull request #166 from launchdarkly/eb/ch61188/redis-params
eli-darkly Jan 13, 2020
cc96ab8
merge from public after release
LaunchDarklyCI Jan 13, 2020
b099acf
add event payload ID
eli-darkly Jan 14, 2020
68fc8f8
remove mistakenly checked-in test code (note, this SDK key was only v…
eli-darkly Jan 14, 2020
603d788
Merge pull request #167 from launchdarkly/eb/ch61092/payload-id
eli-darkly Jan 14, 2020
b0f4e0b
merge from public after release
LaunchDarklyCI Jan 15, 2020
8bad3d5
add mention of singleton usage
eli-darkly Feb 11, 2020
50c3497
Merge pull request #168 from launchdarkly/eb/ch65200/singleton-comment
eli-darkly Feb 11, 2020
47e13c8
Merge branch 'master' into diagnostic-events
eli-darkly Feb 11, 2020
315e9ba
update diagnostic event info for OS name, data store type, Node version
eli-darkly Feb 11, 2020
e012522
standardize linting
eli-darkly Feb 11, 2020
6af8688
disallow window and document
eli-darkly Feb 11, 2020
d600230
fix null/undef checks
eli-darkly Feb 11, 2020
c80f85e
misc linting fixes
eli-darkly Feb 12, 2020
5feaef6
Merge pull request #170 from launchdarkly/eb/ch65303/linting
eli-darkly Feb 12, 2020
3d1a4dd
Merge pull request #169 from launchdarkly/eb/ch62088/spec-updates
eli-darkly Feb 12, 2020
62304d2
inlineUsersInEvents is not an unknown option
eli-darkly Feb 12, 2020
d008bc6
drop node-sha1 dependency
eli-darkly Feb 12, 2020
2965a25
Merge pull request #171 from launchdarkly/eb/ch65544/unknown-option
eli-darkly Feb 12, 2020
9a8bc0f
Merge pull request #172 from launchdarkly/eb/ch65523/sha1-module
eli-darkly Feb 12, 2020
e4849e0
Merge branch 'master' into diagnostic-events
eli-darkly Feb 12, 2020
d80cb60
merge from public after release
LaunchDarklyCI Feb 12, 2020
66b65f0
don't omit streamInits.failed when it's false
eli-darkly Feb 14, 2020
0387358
Merge pull request #173 from launchdarkly/eb/ch65817/diagnostic-expli…
eli-darkly Feb 14, 2020
9913d25
merge from public after release
LaunchDarklyCI Feb 14, 2020
59c9687
bump request dependency to get security patch; loosen some exact depe…
eli-darkly Feb 20, 2020
aff36e4
remove request package; improve polling cache logic + add test
eli-darkly Feb 20, 2020
f2e68a4
bump typescript version to fix build error in Node 6
eli-darkly Feb 20, 2020
e754252
update @types/node to fix TypeScript check step
eli-darkly Feb 20, 2020
23e02c0
Merge pull request #174 from launchdarkly/eb/ch66555/request-dep
eli-darkly Feb 20, 2020
a99c572
Merge branch 'master' into eb/ch66553/drop-request-package
eli-darkly Feb 20, 2020
9b30917
lint
eli-darkly Feb 20, 2020
8cc01d2
merge from public after release
LaunchDarklyCI Feb 20, 2020
37196b9
make sure we keep polling regardless of whether we got new data
eli-darkly Mar 9, 2020
12c8594
Merge pull request #175 from launchdarkly/eb/ch66553/drop-request-pac…
eli-darkly Mar 9, 2020
5ef755f
merge from public after release
LaunchDarklyCI Mar 9, 2020
4aaaf65
use launchdarkly-eventsource, make stream retry behavior consistent
eli-darkly Apr 3, 2020
e213d02
Merge pull request #176 from launchdarkly/eb/ch69693/stream-retry
eli-darkly Apr 3, 2020
ef5de0b
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Apr 3, 2020
b626468
stream retry delay option should be in seconds & should be included i…
eli-darkly Apr 3, 2020
9dd0e9c
Merge pull request #177 from launchdarkly/eb/ch72241/stream-retry-option
eli-darkly Apr 7, 2020
7d143b6
minor test fix
eli-darkly Apr 7, 2020
b2a8a1d
merge from public after release
LaunchDarklyCI Apr 7, 2020
2e084b2
fix: Throw an error on malformed user-supplied logger
maxwellgerber Apr 22, 2020
c666c0f
don't call unref() on Redis client; ensure that database integration …
eli-darkly Apr 22, 2020
40f9754
Merge pull request #178 from launchdarkly/eb/ch25282/redis-unref
eli-darkly Apr 22, 2020
3d558cf
update Redis driver to major version 3
eli-darkly Apr 22, 2020
00c6da8
add test case
maxwellgerber Apr 22, 2020
bfcd711
allow redisOpts parameter to be omitted
eli-darkly Apr 23, 2020
66353c2
add logger adapter shim + tests
maxwellgerber Apr 23, 2020
cf98f97
Merge pull request #179 from launchdarkly/eb/ch74036/redis3
eli-darkly Apr 23, 2020
ac46536
Merge pull request #185 from maxwellgerber/fix/throw-err-on-malformed…
eli-darkly Apr 23, 2020
7c08df2
Merge branch 'contrib' of github.com:launchdarkly/node-server-sdk
eli-darkly Apr 23, 2020
1b94b45
minor cleanup and comments for ch74741 fix (logger wrapper)
eli-darkly Apr 23, 2020
194fc9e
fix proxy tunnel configuration and make sure it's used in streaming
eli-darkly Apr 24, 2020
11210de
Merge pull request #181 from launchdarkly/eb/ch74739/streaming-proxy
eli-darkly Apr 24, 2020
10ab5ab
merge from public after release
LaunchDarklyCI Apr 25, 2020
12949a2
change some string concatenation expressions to use interpolation
eli-darkly May 4, 2020
9f16efb
Merge branch 'master' into eb/ch74741/logger-wrapper-followup
eli-darkly May 4, 2020
a3b70cc
Merge pull request #180 from launchdarkly/eb/ch74741/logger-wrapper-f…
eli-darkly May 4, 2020
a1762e2
feat: upgrade winston (#189)
FauxFaux Jun 23, 2020
02e90a3
Merge branch 'contrib' of github.com:launchdarkly/node-server-sdk
eli-darkly Jun 23, 2020
3fbcf83
fix merge
eli-darkly Jun 24, 2020
a4ae3ad
remove support for indirect/patch and indirect/put (#182)
eli-darkly Jun 25, 2020
2780797
reuse same Promise and same event listeners for all waitForInitializa…
eli-darkly Jun 26, 2020
b73ca82
Merge pull request #183 from launchdarkly/eb/ch80833/wait-for-init-li…
eli-darkly Jun 26, 2020
64b8869
better docs for waitForInitialization + misc doc cleanup (#184)
eli-darkly Jun 30, 2020
2f0c4c0
update js-eventsource to 1.3.1 for stream parsing bugfix (#185)
eli-darkly Jun 30, 2020
179d838
merge from public after release
LaunchDarklyCI Jun 30, 2020
5c52e9e
fix broken logger format (#186)
eli-darkly Jun 30, 2020
804c424
merge from public after release
LaunchDarklyCI Jun 30, 2020
09d03b6
retroactively update changelog for bugfix in 5.13.2 release
eli-darkly Jul 8, 2020
a16805c
Merge pull request #187 from launchdarkly/eb/ch80833/bugfix-changelog
eli-darkly Jul 8, 2020
b858395
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Aug 5, 2020
0a28e52
allow get/getAll Redis queries to be queued if Redis client hasn't ye…
eli-darkly Aug 27, 2020
9bedee0
Merge pull request #188 from launchdarkly/eb/ch87993/redis-connect-state
eli-darkly Aug 27, 2020
1e90630
merge from public after release
LaunchDarklyCI Aug 28, 2020
abfcf7f
set stream read timeout
eli-darkly Jan 26, 2021
4f8774e
Merge pull request #189 from launchdarkly/eb/ch73764/stream-read-timeout
eli-darkly Jan 26, 2021
0882774
merge from public after release
LaunchDarklyCI Jan 26, 2021
c4b9f3a
adding the alias functionality (#190)
bwoskow-ld Jan 29, 2021
0e24961
merge from public after release
LaunchDarklyCI Jan 29, 2021
26ebc52
Removed the guides link
bwoskow-ld Feb 3, 2021
4307257
remove monkey-patching of setImmediate
eli-darkly Feb 8, 2021
ad3e106
Merge pull request #191 from launchdarkly/eb/ch100514/no-monkey-patch
eli-darkly Feb 8, 2021
43eee0e
merge from public after release
LaunchDarklyCI Feb 9, 2021
4b3ad52
Persist contextKind property during feature and custom event transfor…
bwoskow-ld Feb 11, 2021
5210f46
merge from public after release
LaunchDarklyCI Feb 11, 2021
d9b7597
add inlineUsersInEvents option in TypeScript
eli-darkly Mar 30, 2021
8e425a0
Merge pull request #197 from launchdarkly/eb/ch103585/inline-property
eli-darkly Apr 1, 2021
3e3db9c
merge from public after release
LaunchDarklyCI Apr 1, 2021
05d80fc
Add support for seed to bucketUser
Apr 16, 2021
70277ce
Add note for incorporating seed into evaluation
Apr 21, 2021
94a1016
Send events when the evaluation is from an experiment
Apr 22, 2021
8da6541
Use seed to evaluate.
Apr 22, 2021
db5c28c
Clean up test descriptions
Apr 22, 2021
520da38
Rename variable to be less confusing
Apr 23, 2021
48af02d
Use ternary to eliminate mutation
Apr 23, 2021
10a2377
Make return signature more consistent
Apr 23, 2021
8707999
Un-prettier the tests
Apr 23, 2021
d8e7cbb
Add traffic allocation support (#198)
Apr 26, 2021
293c6a5
redis lower bounds bump (#199)
bwoskow-ld Apr 28, 2021
6330aef
merge from public after release
LaunchDarklyCI Apr 29, 2021
7b450e3
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
bwoskow-ld May 11, 2021
8bfea5f
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
bwoskow-ld May 24, 2021
c1a91f8
Merge branch 'master' into exp-alloc
robertjneal Jun 4, 2021
71b3579
update launchdarkly-js-test-helpers to fix TLS tests (#200)
eli-darkly Jun 9, 2021
473a1c1
update js-eventsource to remove vulnerability warning (#201)
eli-darkly Jun 10, 2021
ae3a860
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Jun 10, 2021
d937730
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
bwoskow-ld Jun 11, 2021
3e55ee1
add CI jobs for all compatible Node versions
eli-darkly Jun 12, 2021
895a7b7
CI fixes
eli-darkly Jun 12, 2021
b42ac5d
more CI fixes
eli-darkly Jun 12, 2021
da29df1
comment
eli-darkly Jun 12, 2021
439c16b
use default value to simplify config
eli-darkly Jun 12, 2021
6aed521
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
bwoskow-ld Jun 14, 2021
7520d6c
Merge branch 'master' into 6.0
eli-darkly Jun 14, 2021
9b534c7
(6.0 - #1) stop saying we're compatible with Node <12 (#203)
eli-darkly Jun 14, 2021
b6da495
add CI jobs for all compatible Node versions (#202)
eli-darkly Jun 14, 2021
23eda3b
Merge branch 'master' into 6.0
eli-darkly Jun 14, 2021
847a903
(6.0 - #2) remove Redis integration (#204)
eli-darkly Jun 14, 2021
679f879
allow feature store to be specified as a factory (so it can get our l…
eli-darkly Jun 14, 2021
ecf5135
(6.0 - #3) remove Winston (#205)
eli-darkly Jun 14, 2021
19cc663
remove deprecated things for 6.0 (#206)
eli-darkly Jun 14, 2021
2381b91
Merge pull request #207 from launchdarkly/eb/ch111387/data-store-factory
eli-darkly Jun 14, 2021
868128b
update node-cache to 5.x (drops old Node compat)
eli-darkly Jun 15, 2021
1191c2e
update semver to 7.x (drops old Node compat)
eli-darkly Jun 15, 2021
38ead49
update uuid to 8.x (Node compat, perf improvements, bugfixes)
eli-darkly Jun 15, 2021
4930fc7
update dev dependencies
eli-darkly Jun 15, 2021
2ad6d55
linter
eli-darkly Jun 15, 2021
010a1a5
Merge pull request #208 from launchdarkly/eb/ch111699/update-deps
eli-darkly Jun 15, 2021
3ae053a
replace lrucache package with lru-cache (#209)
eli-darkly Jun 15, 2021
59e2f82
make yaml dependency optional (#210)
eli-darkly Jun 15, 2021
d292f74
update release metadata to include maintenance branch
eli-darkly Jun 15, 2021
4a5dc99
Merge branch '6.0'
eli-darkly Jun 15, 2021
6a1c746
remove package-lock.json (#211)
eli-darkly Jun 17, 2021
a95ddfe
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Jun 17, 2021
e74c640
rm prerelease changelog
eli-darkly Jun 17, 2021
4237116
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Jun 17, 2021
bb0a957
Merge branch 'exp-alloc'
eli-darkly Jun 17, 2021
117273c
merge from public after release
LaunchDarklyCI Jun 21, 2021
6b60b95
(big segments #1) add interfaces for big segments (#212)
eli-darkly Jul 6, 2021
50e62ce
(big segments #2) add all components for big segments except evaluati…
eli-darkly Jul 7, 2021
5c35f86
(big segments #3) implement big segments in flag evaluation (#214)
eli-darkly Jul 16, 2021
b984806
(big segments #4) add standard test suite for big segment store tests…
eli-darkly Jul 16, 2021
393c631
move new interfaces to a module instead of a namespace (#216)
eli-darkly Jul 19, 2021
042ecc1
fix TS export of CachingStoreWrapper
eli-darkly Jul 19, 2021
ed7ddf3
Merge pull request #217 from launchdarkly/eb/ch108418/fix-caching-sto…
eli-darkly Jul 19, 2021
89a8709
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Jul 22, 2021
9de933b
Merge branch 'master' of github.com:launchdarkly/node-server-sdk
eli-darkly Aug 13, 2021
d778b68
use Releaser v2 config
eli-darkly Sep 21, 2021
d451fb0
Merge pull request #218 from launchdarkly/eb/ch118712/releaser-v2
eli-darkly Sep 21, 2021
fe75863
fix overly specific test expectation that breaks in Node 17
eli-darkly Nov 16, 2021
81d571c
Merge pull request #220 from launchdarkly/eb/sc-131661/fix-test
eli-darkly Nov 17, 2021
093070c
Initial work on FlagBuilder (#219)
belevy Nov 18, 2021
6679f53
implemented FlagRuleBuilder; added .build() methods to FlagBuilder/Fl…
charukiewicz Nov 17, 2021
c72c4b7
converted _targets to be Map instead of object literal; changed varia…
charukiewicz Nov 18, 2021
2bfe43d
Implement stream processor(data source) interface for test data
belevy Nov 18, 2021
1758a5f
Add TestData to index.js and write out the types for TestData and fri…
belevy Nov 18, 2021
eca4ebe
added testdata documentation to index.d.ts; fix linter errors; change…
charukiewicz Nov 18, 2021
03684bf
Merge pull request #221 from launchdarkly/cc/sc-130601/test-data-flag…
charukiewicz Nov 24, 2021
6cd3148
Fix the interface file: reindented to 2 spaces, corrected definition …
belevy Nov 24, 2021
174c870
modify tests to fix capitalization and actually test the test datasou…
belevy Nov 24, 2021
c14fcaf
Fix linter error on defaulted callback
belevy Nov 29, 2021
2cf0e26
explicitly enable JSDOM types in TypeScript build to avoid errors whe…
eli-darkly Nov 29, 2021
cae489f
capitalize Big Segments in docs & logs
eli-darkly Nov 30, 2021
dce0a1d
Merge branch 'eb/sc-132761/typescript-jsdom-errors' into eb/sc-120149…
eli-darkly Nov 30, 2021
69a98dd
Merge pull request #223 from launchdarkly/eb/sc-132761/typescript-jsd…
eli-darkly Nov 30, 2021
91988cc
Merge pull request #224 from launchdarkly/eb/sc-120149/big-segments-n…
eli-darkly Nov 30, 2021
d7f500e
Merge branch 'master' into test-data
eli-darkly Nov 30, 2021
c965023
Merge branch 'test-data' into bl/sc-130601/test-data-data-source
eli-darkly Nov 30, 2021
9e268ad
Merge pull request #222 from launchdarkly/bl/sc-130601/test-data-data…
belevy Nov 30, 2021
3e2bf09
documentation comment fixes for TestData
eli-darkly Dec 6, 2021
6900fb1
Merge pull request #226 from launchdarkly/eb/sc-130601/comment-fixes
belevy Dec 7, 2021
930700e
pin TypeScript to 4.4.x
eli-darkly Dec 8, 2021
00b0e42
Merge pull request #227 from launchdarkly/eb/sc-72228/pin-typescript-…
eli-darkly Dec 8, 2021
82830ce
move TestData and FIleDataSource to integrations module
eli-darkly Dec 8, 2021
8ce8686
lint
eli-darkly Dec 8, 2021
715000b
Merge pull request #228 from launchdarkly/eb/sc-130601/test-data-module
eli-darkly Dec 8, 2021
9ef8b01
rename types used by TestData for clarity (#229)
eli-darkly Dec 8, 2021
a8b19f3
use varargs semantics for TestFlagBuilder.variations() and add it to …
eli-darkly Dec 9, 2021
2d688ce
don't ever use for...in (#232)
eli-darkly Dec 10, 2021
6577fa8
merge from public after release
Dec 11, 2021
4054d85
bump launchdarkly-eventsource dependency for sc-136154 fix
eli-darkly Jan 4, 2022
94af72c
use TestData in our own tests (#231)
eli-darkly Jan 4, 2022
f4b88da
Merge pull request #233 from launchdarkly/eb/sc-136154/js-eventsource…
eli-darkly Jan 4, 2022
91b19a3
merge from public after release
Jan 4, 2022
11a92fb
fix allFlagsState behavior regarding experimentation
eli-darkly Feb 2, 2022
5310a45
lint
eli-darkly Feb 2, 2022
0b81dbf
allow "secondary" to be referenced in clauses
eli-darkly Feb 2, 2022
5a6b089
don't throw an exception for non-string in semver comparison
eli-darkly Feb 2, 2022
c1a98b8
correctly handle "client not ready" condition in allFlagsState
eli-darkly Feb 2, 2022
b144ac0
lint
eli-darkly Feb 2, 2022
2aad9b0
Merge pull request #235 from launchdarkly/eb/sc-140526/misc-test-fixes
eli-darkly Feb 4, 2022
33ac182
Merge pull request #234 from launchdarkly/eb/sc-137721/all-flags-expe…
eli-darkly Feb 4, 2022
4b01f5d
merge from public after release
Feb 4, 2022
5a13869
Merge branch 'master' into test-data
eli-darkly Feb 19, 2022
2d86ee7
merge from public after release
Feb 19, 2022
d4ab468
Flags with a version of 0 reported as 'unknown' in summary events. (#…
kinyoklion Mar 2, 2022
897ae8b
implement contract test service, not including big segments (#242)
kinyoklion Mar 4, 2022
663bd06
Implement Application tags for the node SDK. (#241)
kinyoklion Mar 10, 2022
f98493c
update js-eventsource to 1.4.4 for security fix
eli-darkly Mar 10, 2022
e7b6981
Merge pull request #245 from launchdarkly/eb/sc-145320/eventsource-up…
eli-darkly Mar 10, 2022
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
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
default: false
docker-image:
type: string
run-contract-tests:
type: boolean
default: true
docker:
- image: <<parameters.docker-image>>
steps:
Expand All @@ -56,6 +59,14 @@ jobs:
condition: <<parameters.run-lint>>
steps:
- run: npm run lint
- when:
condition: <<parameters.run-contract-tests>>
steps:
- run:
command: npm run contract-test-service
background: true
- run: mkdir -p reports/junit
- run: TEST_HARNESS_PARAMS="-junit reports/junit/contract-test-results.xml -skip-from contract-tests/testharness-suppressions.txt" npm run contract-test-harness
- run:
name: dependency audit
command: ./scripts/better-audit.sh
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package-lock.json
/docs/build/
/local/
/node_modules/
**/node_modules/
junit.xml
npm-debug.log
test-types.js
Expand Down
73 changes: 69 additions & 4 deletions configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = (function () {
const typesForPropertiesWithNoDefault = {
// Add a value here if we add a configuration property whose type cannot be determined by looking
// in baseDefaults (for instance, the default is null but if the value isn't null it should be a
// string). The allowable values are 'boolean', 'string', 'number', 'object', 'function', or
// string). The allowable values are 'boolean', 'string', 'number', 'object', 'function', 'array' or
// 'factory' (the last one means it can be either a function or an object).
bigSegments: 'object',
eventProcessor: 'object',
Expand All @@ -48,6 +48,42 @@ module.exports = (function () {
wrapperVersion: 'string',
};

/**
* Expression to validate characters that are allowed in tag keys and values.
*/
const allowedTagCharacters = /^(\w|\.|-)+$/;

/**
* Verify that a value meets the requirements for a tag value.
* @param {Object} config
* @param {string} tagValue
*/
function validateTagValue(name, config, tagValue) {
if (typeof tagValue !== 'string' || !tagValue.match(allowedTagCharacters)) {
config.logger.warn(messages.invalidTagValue(name));
return undefined;
}
return tagValue;
}

const optionsWithValidatorsOrConversions = {
// Add a value here if we add a configuration property which requires custom validation
// and/or type conversion.
// The validator should log a message for any validation issues encountered.
// The validator should return undefined, or the validated value.

application: (name, config, value) => {
const validated = {};
if (value.id) {
validated.id = validateTagValue(`${name}.id`, config, value.id);
}
if (value.version) {
validated.version = validateTagValue(`${name}.version`, config, value.version);
}
return validated;
},
};

/* eslint-disable camelcase */
const deprecatedOptions = {};
/* eslint-enable camelcase */
Expand Down Expand Up @@ -102,8 +138,16 @@ module.exports = (function () {
if (value !== null && value !== undefined) {
const defaultValue = defaultConfig[name];
const typeDesc = typesForPropertiesWithNoDefault[name];
if (defaultValue === undefined && typeDesc === undefined) {
const validator = optionsWithValidatorsOrConversions[name];
if (defaultValue === undefined && typeDesc === undefined && validator === undefined) {
config.logger.warn(messages.unknownOption(name));
} else if (validator !== undefined) {
const validated = validator(name, config, config[name]);
if (validated !== undefined) {
config[name] = validated;
} else {
delete config[name];
}
} else {
const expectedType = typeDesc || typeDescForValue(defaultValue);
const actualType = typeDescForValue(value);
Expand Down Expand Up @@ -156,8 +200,29 @@ module.exports = (function () {
return config;
}

/**
* Get tags for the specified configuration.
*
* If any additional tags are added to the configuration, then the tags from
* this method should be extended with those.
* @param {Object} config The already valiated configuration.
* @returns {Object} The tag configuration.
*/
function getTags(config) {
const tags = {};
if (config.application && config.application.id !== undefined && config.application.id !== null) {
tags['application-id'] = [config.application.id];
}
if (config.application && config.application.version !== undefined && config.application.id !== null) {
tags['application-version'] = [config.application.version];
}

return tags;
}

return {
validate: validate,
defaults: defaults,
validate,
defaults,
getTags,
};
})();
7 changes: 7 additions & 0 deletions contract-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SDK contract test service

This directory contains an implementation of the cross-platform SDK testing protocol defined by https://github.com/launchdarkly/sdk-test-harness. See that project's `README` for details of this protocol, and the kinds of SDK capabilities that are relevant to the contract tests. This code should not need to be updated unless the SDK has added or removed such capabilities.

To run these tests locally, run `npm run contract-tests` from the SDK project root directory. This will start the test service, download the correct version of the test harness tool, and run the tests.

Or, to test against an in-progress local version of the test harness, run `npm run contract-test-service` from the SDK project root directory; then, in the root directory of the `sdk-test-harness` project, build the test harness and run it from the command line.
108 changes: 108 additions & 0 deletions contract-tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const express = require('express');
const bodyParser = require('body-parser');

const { Log } = require('./log');
const { newSdkClientEntity, badCommandError } = require('./sdkClientEntity');

const app = express();
let server = null;

const port = 8000;

let clientCounter = 0;
const clients = {};

const mainLog = Log('service');

app.use(bodyParser.json());

app.get('/', (req, res) => {
res.header('Content-Type', 'application/json');
res.json({
capabilities: [
'server-side',
'all-flags-client-side-only',
'all-flags-details-only-for-tracked-flags',
'all-flags-with-reasons',
'tags',
],
});
});

app.delete('/', (req, res) => {
mainLog.info('Test service has told us to exit');
res.status(204);
res.send();

// Defer the following actions till after the response has been sent
setTimeout(() => {
server.close(() => process.exit());
// We force-quit with process.exit because, even after closing the server, there could be some
// scheduled tasks lingering if an SDK instance didn't get cleaned up properly, and we don't want
// that to prevent us from quitting.
}, 1);
});

app.post('/', async (req, res) => {
const options = req.body;

clientCounter += 1;
const clientId = clientCounter.toString();
const resourceUrl = `/clients/${clientId}`;

try {
const client = await newSdkClientEntity(options);
clients[clientId] = client;

res.status(201);
res.set('Location', resourceUrl);
} catch (e) {
res.status(500);
const message = e.message || JSON.stringify(e);
mainLog.error('Error creating client: ' + message);
res.write(message);
}
res.send();
});

app.post('/clients/:id', async (req, res) => {
const client = clients[req.params.id];
if (!client) {
res.status(404);
} else {
try {
const respValue = await client.doCommand(req.body);
if (respValue) {
res.status(200);
res.write(JSON.stringify(respValue));
} else {
res.status(204);
}
} catch (e) {
const isBadRequest = e === badCommandError;
res.status(isBadRequest ? 400 : 500);
res.write(e.message || JSON.stringify(e));
if (!isBadRequest && e.stack) {
console.log(e.stack);
}
}
}
res.send();
});

app.delete('/clients/:id', async (req, res) => {
const client = clients[req.params.id];
if (!client) {
res.status(404);
res.send();
} else {
client.close();
delete clients[req.params.id];
res.status(204);
res.send();
}
});

server = app.listen(port, () => {
console.log('Listening on port %d', port);
});
23 changes: 23 additions & 0 deletions contract-tests/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const ld = require('launchdarkly-node-server-sdk');

function Log(tag) {
function doLog(level, message) {
console.log(new Date().toISOString() + ` [${tag}] ${level}: ${message}`);
}
return {
info: message => doLog('info', message),
error: message => doLog('error', message),
};
}

function sdkLogger(tag) {
return ld.basicLogger({
level: 'debug',
destination: line => {
console.log(new Date().toISOString() + ` [${tag}.sdk] ${line}`);
},
});
}

module.exports.Log = Log;
module.exports.sdkLogger = sdkLogger;
15 changes: 15 additions & 0 deletions contract-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "node-server-sdk-contract-tests",
"version": "0.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"launchdarkly-node-server-sdk": "file:.."
}
}
Loading