launchdarkly-node-client-sdk 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/actions/publish-docs/action.yml +16 -0
- package/.github/actions/publish-npm/action.yml +20 -0
- package/.github/workflows/ci.yml +47 -0
- package/.github/workflows/lint-pr-title.yml +12 -0
- package/.github/workflows/release-please.yml +57 -0
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +22 -0
- package/contract-tests/index.js +1 -0
- package/package.json +7 -6
- package/release-please-config.json +10 -0
- package/scripts/publish-npm.sh +11 -0
- package/typedoc.json +17 -0
- package/typings.d.ts +24 -15
- package/docs/Makefile +0 -28
- package/docs/doc.md +0 -7
- package/docs/tsconfig.json +0 -12
- package/docs/typedoc.js +0 -17
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Publish Documentation
|
|
2
|
+
description: 'Publish documentation to github pages.'
|
|
3
|
+
|
|
4
|
+
inputs:
|
|
5
|
+
github_token:
|
|
6
|
+
description: 'The github token to use for committing'
|
|
7
|
+
required: true
|
|
8
|
+
|
|
9
|
+
runs:
|
|
10
|
+
using: composite
|
|
11
|
+
steps:
|
|
12
|
+
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.2
|
|
13
|
+
name: 'Publish to Github pages'
|
|
14
|
+
with:
|
|
15
|
+
docs_path: docs
|
|
16
|
+
github_token: ${{ inputs.github_token }}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish to NPM
|
|
2
|
+
description: Publish an npm package.
|
|
3
|
+
inputs:
|
|
4
|
+
prerelease:
|
|
5
|
+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
|
|
6
|
+
required: false
|
|
7
|
+
dry-run:
|
|
8
|
+
description: 'Is this a dry run. If so no package will be published.'
|
|
9
|
+
required: false
|
|
10
|
+
|
|
11
|
+
runs:
|
|
12
|
+
using: composite
|
|
13
|
+
steps:
|
|
14
|
+
- name: Publish
|
|
15
|
+
shell: bash
|
|
16
|
+
run: |
|
|
17
|
+
./scripts/publish-npm.sh
|
|
18
|
+
env:
|
|
19
|
+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
|
|
20
|
+
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry-run }}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Build and Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths-ignore:
|
|
7
|
+
- '**.md' #Do not need to run CI for markdown changes.
|
|
8
|
+
pull_request:
|
|
9
|
+
branches: [main]
|
|
10
|
+
paths-ignore:
|
|
11
|
+
- '**.md'
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build-test:
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
variations: [
|
|
18
|
+
{os: ubuntu-latest, node: latest},
|
|
19
|
+
{os: ubuntu-latest, node: 18}
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
runs-on: ${{ matrix.variations.os }}
|
|
23
|
+
env:
|
|
24
|
+
TEST_SERVICE_PORT: 8000
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/setup-node@v4
|
|
29
|
+
with:
|
|
30
|
+
node-version: ${{ matrix.variations.node }}
|
|
31
|
+
registry-url: 'https://registry.npmjs.org'
|
|
32
|
+
- name: Install
|
|
33
|
+
run: npm install
|
|
34
|
+
- name: Test
|
|
35
|
+
run: npm test
|
|
36
|
+
- name: Lint
|
|
37
|
+
run: npm run lint:all
|
|
38
|
+
- name: Check typescript
|
|
39
|
+
run: npm run check-typescript
|
|
40
|
+
- name: Run contract test service
|
|
41
|
+
run: npm run contract-test-service 2>&1 &
|
|
42
|
+
- uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1.0.0
|
|
43
|
+
with:
|
|
44
|
+
test_service_port: ${{ env.TEST_SERVICE_PORT }}
|
|
45
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
+
- name: Build Docs
|
|
47
|
+
run: npm run doc
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Release Please
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release-please:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
outputs:
|
|
12
|
+
release_created: ${{ steps.release.outputs.release_created }}
|
|
13
|
+
steps:
|
|
14
|
+
- uses: googleapis/release-please-action@v4
|
|
15
|
+
id: release
|
|
16
|
+
with:
|
|
17
|
+
token: ${{secrets.GITHUB_TOKEN}}
|
|
18
|
+
|
|
19
|
+
publish-package:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
needs: ['release-please']
|
|
22
|
+
permissions:
|
|
23
|
+
id-token: write
|
|
24
|
+
contents: write
|
|
25
|
+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: 20.x
|
|
32
|
+
registry-url: 'https://registry.npmjs.org'
|
|
33
|
+
|
|
34
|
+
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
|
|
35
|
+
name: 'Get NPM token'
|
|
36
|
+
with:
|
|
37
|
+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
|
|
38
|
+
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
|
|
39
|
+
|
|
40
|
+
- name: Install Dependencies
|
|
41
|
+
run: npm install
|
|
42
|
+
|
|
43
|
+
- id: publish-npm
|
|
44
|
+
name: Publish NPM Package
|
|
45
|
+
uses: ./.github/actions/publish-npm
|
|
46
|
+
with:
|
|
47
|
+
dry-run: 'false'
|
|
48
|
+
prerelease: 'false'
|
|
49
|
+
|
|
50
|
+
- name: Build Documentation
|
|
51
|
+
run: npm run doc
|
|
52
|
+
|
|
53
|
+
- id: publish-docs
|
|
54
|
+
name: Publish Documentation
|
|
55
|
+
uses: ./.github/actions/publish-docs
|
|
56
|
+
with:
|
|
57
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the LaunchDarkly Client-Side SDK for Node.js will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [3.3.0](https://github.com/launchdarkly/node-client-sdk/compare/3.2.1...3.3.0) (2024-10-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* Add support for client-side prerequisite events. ([#49](https://github.com/launchdarkly/node-client-sdk/issues/49)) ([7495877](https://github.com/launchdarkly/node-client-sdk/commit/7495877e9bcff857b3ba6cef36e0de8a9120c57e))
|
|
11
|
+
|
|
12
|
+
## [3.2.1] - 2024-05-23
|
|
13
|
+
### Fixed:
|
|
14
|
+
- Updated `launchdarkly-evensource` to version `2.0.3` which includes improvements to error handling and shutdown of SSE streams.
|
|
15
|
+
|
|
16
|
+
## [3.2.0] - 2024-05-01
|
|
17
|
+
### Added:
|
|
18
|
+
- Added an optional timeout to the `waitForInitialization` method. When a timeout is specified the returned promise will be rejected after the timeout elapses if the client has not finished initializing within that time. When no timeout is specified the returned promise will not be resolved or rejected until the initialization either completes or fails.
|
|
19
|
+
|
|
20
|
+
### Changed:
|
|
21
|
+
- The track method now validates that the provided metricValue is a number. If a metric value is provided, and it is not a number, then a warning will be logged.
|
|
22
|
+
|
|
23
|
+
### Fixed:
|
|
24
|
+
- Fixed the documentation for `evaluationReasons` for the `identify` method.
|
|
25
|
+
- Upgraded to launchdarkly-eventsource version 2.0.2. This version contains performance improvements and logging improvements compared the the version that was in use.
|
|
26
|
+
|
|
5
27
|
## [3.1.0] - 2024-03-19
|
|
6
28
|
### Changed:
|
|
7
29
|
- Redact anonymous attributes within feature events
|
package/contract-tests/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "launchdarkly-node-client-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "LaunchDarkly Client-Side SDK for Node.js",
|
|
5
5
|
"author": "LaunchDarkly <team@launchdarkly.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"check-typescript": "node_modules/typescript/bin/tsc",
|
|
19
19
|
"contract-test-service": "npm --prefix contract-tests install && npm --prefix contract-tests start",
|
|
20
20
|
"contract-test-harness": "curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \\ | VERSION=v2 PARAMS=\"-url http://localhost:8000 -debug -stop-service-at-end $TEST_HARNESS_PARAMS\" sh",
|
|
21
|
-
"contract-tests": "npm run contract-test-service & npm run contract-test-harness"
|
|
21
|
+
"contract-tests": "npm run contract-test-service & npm run contract-test-harness",
|
|
22
|
+
"doc": "typedoc"
|
|
22
23
|
},
|
|
23
24
|
"engines": {
|
|
24
25
|
"node": ">= 12.0.0"
|
|
@@ -40,8 +41,8 @@
|
|
|
40
41
|
"jest-junit": "^14.0.1",
|
|
41
42
|
"launchdarkly-js-test-helpers": "1.2.1",
|
|
42
43
|
"prettier": "2.7.1",
|
|
43
|
-
"typescript": "
|
|
44
|
-
"typedoc": "^0.
|
|
44
|
+
"typescript": "~5.4.5",
|
|
45
|
+
"typedoc": "^0.25.13"
|
|
45
46
|
},
|
|
46
47
|
"jest": {
|
|
47
48
|
"rootDir": "src",
|
|
@@ -64,8 +65,8 @@
|
|
|
64
65
|
"outputName": "junit.xml"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"launchdarkly-eventsource": "2.0.
|
|
68
|
-
"launchdarkly-js-sdk-common": "5.
|
|
68
|
+
"launchdarkly-eventsource": "2.0.3",
|
|
69
|
+
"launchdarkly-js-sdk-common": "5.4.0",
|
|
69
70
|
"node-localstorage": "^1.3.1"
|
|
70
71
|
},
|
|
71
72
|
"repository": {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
if $LD_RELEASE_IS_DRYRUN ; then
|
|
3
|
+
echo "Doing a dry run of publishing."
|
|
4
|
+
else
|
|
5
|
+
if $LD_RELEASE_IS_PRERELEASE ; then
|
|
6
|
+
echo "Publishing with prerelease tag."
|
|
7
|
+
npm publish --tag prerelease --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
|
|
8
|
+
else
|
|
9
|
+
npm publish --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
|
|
10
|
+
fi
|
|
11
|
+
fi
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://typedoc.org/schema.json",
|
|
3
|
+
"name": "launchdarkly-node-client-sdk",
|
|
4
|
+
"includeVersion": true,
|
|
5
|
+
"entryPoints": [
|
|
6
|
+
"typings.d.ts",
|
|
7
|
+
],
|
|
8
|
+
"readme": "none",
|
|
9
|
+
"visibilityFilters": {
|
|
10
|
+
"protected": false,
|
|
11
|
+
"private": false,
|
|
12
|
+
"inherited": true,
|
|
13
|
+
"external": true,
|
|
14
|
+
"@alpha": false,
|
|
15
|
+
"@beta": false
|
|
16
|
+
}
|
|
17
|
+
}
|
package/typings.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This is the API reference for the LaunchDarkly Client-Side Node SDK.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* In typical usage, you will call {@link initialize} once at startup time to obtain an instance of
|
|
6
|
+
* {@link LDClient}, which provides access to all of the SDK's functionality.
|
|
7
|
+
*
|
|
8
|
+
* For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
declare module 'launchdarkly-node-client-sdk' {
|
|
4
14
|
export * from 'launchdarkly-js-sdk-common';
|
|
5
15
|
|
|
6
16
|
import {
|
|
@@ -14,7 +24,6 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
14
24
|
LDOptionsBase,
|
|
15
25
|
LDContext
|
|
16
26
|
} from 'launchdarkly-js-sdk-common';
|
|
17
|
-
//// DOCBUILD-END-REPLACE
|
|
18
27
|
|
|
19
28
|
/**
|
|
20
29
|
* The current version string of the SDK.
|
|
@@ -26,13 +35,13 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
26
35
|
*
|
|
27
36
|
* Applications should instantiate a single instance for the lifetime of the application.
|
|
28
37
|
* The client will begin attempting to connect to LaunchDarkly as soon as it is created. To
|
|
29
|
-
* determine when it is ready to use, call
|
|
30
|
-
* event listener for the `"ready"` event using
|
|
38
|
+
* determine when it is ready to use, call {@link LDClient.waitForInitialization}, or register an
|
|
39
|
+
* event listener for the `"ready"` event using {@link LDClient.on}.
|
|
31
40
|
*
|
|
32
41
|
* @param envKey
|
|
33
42
|
* The LaunchDarkly environment ID.
|
|
34
43
|
* @param context
|
|
35
|
-
* The initial context properties. These can be changed later with
|
|
44
|
+
* The initial context properties. These can be changed later with {@link LDClient.identify}.
|
|
36
45
|
* The context must have a `key` property, except that if you omit `context.key` and set `context.anonymous` to
|
|
37
46
|
* true, the SDK will create a randomized unique key (which will be cached in local storage for the
|
|
38
47
|
* current OS user account, so the next initialization will reuse the same key).
|
|
@@ -61,8 +70,8 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
61
70
|
/**
|
|
62
71
|
* Additional parameters to pass to the Node HTTPS API for secure requests. These can include any
|
|
63
72
|
* of the TLS-related parameters supported by `https.request()`, such as `ca`, `cert`, and `key`.
|
|
64
|
-
* This object should be stored in the `tlsParams` property of
|
|
65
|
-
*
|
|
73
|
+
* This object should be stored in the `tlsParams` property of {@link LDOptions}.
|
|
74
|
+
*
|
|
66
75
|
* For more information, see the Node documentation for `https.request()` and `tls.connect()`.
|
|
67
76
|
*/
|
|
68
77
|
export interface LDTLSOptions {
|
|
@@ -81,7 +90,7 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
81
90
|
/**
|
|
82
91
|
* The LaunchDarkly SDK client object.
|
|
83
92
|
*
|
|
84
|
-
* Applications should configure the client at startup time with
|
|
93
|
+
* Applications should configure the client at startup time with {@link initialize}, and reuse the same instance.
|
|
85
94
|
*
|
|
86
95
|
* For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
|
|
87
96
|
*/
|
|
@@ -89,19 +98,19 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
/**
|
|
92
|
-
* Provides a simple
|
|
101
|
+
* Provides a simple {@link LDLogger} implementation.
|
|
93
102
|
*
|
|
94
103
|
* This logging implementation uses a simple format that includes only the log level
|
|
95
104
|
* and the message text. Output is written to the standard error stream (`console.error`).
|
|
96
|
-
* You can filter by log level as described in
|
|
105
|
+
* You can filter by log level as described in {@link BasicLoggerOptions.level}.
|
|
97
106
|
*
|
|
98
|
-
* To use the logger created by this function, put it into
|
|
99
|
-
* you do not set
|
|
107
|
+
* To use the logger created by this function, put it into {@link LDOptions.logger}. If
|
|
108
|
+
* you do not set {@link LDOptions.logger} to anything, the SDK uses a default logger
|
|
100
109
|
* that is equivalent to `ld.basicLogger({ level: 'info' })`.
|
|
101
110
|
*
|
|
102
111
|
* @param options Configuration for the logger. If no options are specified, the
|
|
103
112
|
* logger uses `{ level: 'info' }`.
|
|
104
|
-
*
|
|
113
|
+
*
|
|
105
114
|
* @example
|
|
106
115
|
* This example shows how to use `basicLogger` in your SDK options to enable console
|
|
107
116
|
* logging only at `warn` and `error` levels.
|
|
@@ -120,7 +129,7 @@ declare module 'launchdarkly-node-client-sdk' {
|
|
|
120
129
|
* };
|
|
121
130
|
* ```
|
|
122
131
|
*/
|
|
123
|
-
|
|
132
|
+
export function basicLogger(
|
|
124
133
|
options?: BasicLoggerOptions
|
|
125
134
|
): LDLogger;
|
|
126
135
|
}
|
package/docs/Makefile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# The TypeDoc build for this module is more complicated than for ldclient-node because it takes some of
|
|
3
|
-
# its types from launchdarkly-js-sdk-common. TypeDoc unfortunately does not understand the directive
|
|
4
|
-
# "export * from 'launchdarkly-js-sdk-common'" - so, by default, even though it does see the common types (like
|
|
5
|
-
# LDUser), it will not include them in the output.
|
|
6
|
-
#
|
|
7
|
-
# The current solution is to run TypeDoc on a hacked-together file that puts all of the types directly
|
|
8
|
-
# into one package. The sed commands below create this temporary declaration file by taking our types file
|
|
9
|
-
# and replacing the launchdarkly-js-sdk-common imports with the actual contents of the launchdarkly-js-sdk-common module.
|
|
10
|
-
# We then run TypeDoc from the docs directory, which contains its own tsconfig.json that points to the
|
|
11
|
-
# temporarily file instead of the original files.
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
.PHONY: html prepare
|
|
15
|
-
|
|
16
|
-
html: prepare
|
|
17
|
-
../node_modules/.bin/typedoc --options typedoc.js
|
|
18
|
-
|
|
19
|
-
prepare:
|
|
20
|
-
rm -rf build
|
|
21
|
-
mkdir build
|
|
22
|
-
@# Extract the whole module declaration from launchdarkly-js-sdk-common, then remove the first and last lines
|
|
23
|
-
sed -n '/^declare module/,/^}/p' ../node_modules/launchdarkly-js-sdk-common/typings.d.ts | \
|
|
24
|
-
sed '1d;$$d' \
|
|
25
|
-
>build/common-excerpt
|
|
26
|
-
@# Replace the block from DOCBUILD-START-REPLACE to DOCBUILD-END-REPLACE with that excerpt
|
|
27
|
-
sed -e '/DOCBUILD-END-REPLACE/r build/common-excerpt' ../typings.d.ts | \
|
|
28
|
-
sed -e '/DOCBUILD-START-REPLACE/,/DOCBUILD-END-REPLACE/d' >build/typings.d.ts
|
package/docs/doc.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
This is the API reference for the LaunchDarkly Client-Side Node SDK.
|
|
2
|
-
|
|
3
|
-
In typical usage, you will call [[initialize]] in the main process at startup time to obtain an
|
|
4
|
-
an instance of [[LDClient]].
|
|
5
|
-
|
|
6
|
-
For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
|
|
7
|
-
|
package/docs/tsconfig.json
DELETED
package/docs/typedoc.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Note that the format of this file is barely documented on the TypeDoc site. In general,
|
|
2
|
-
// the properties are equivalent to the command-line options described here:
|
|
3
|
-
// https://typedoc.org/api/
|
|
4
|
-
|
|
5
|
-
let version = process.env.VERSION;
|
|
6
|
-
if (!version) {
|
|
7
|
-
const package = require('../package.json');
|
|
8
|
-
version = package.version;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
out: './build/html',
|
|
13
|
-
name: 'LaunchDarkly Client-Side Node SDK (' + version + ')',
|
|
14
|
-
readme: 'doc.md',
|
|
15
|
-
entryPointStrategy: 'resolve', // Allows us to specify the specific entrypoints.
|
|
16
|
-
entryPoints: ["./build/typings.d.ts"] // This is the updated version created by the makefile.
|
|
17
|
-
};
|