Skip to content

Commit 1d65d78

Browse files
Merge branch 'main' into feat-goff-inprocess
Signed-off-by: Thomas Poignant <[email protected]>
2 parents 312fc00 + 3b052ea commit 1d65d78

File tree

98 files changed

+16756
-5483
lines changed

Some content is hidden

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

98 files changed

+16756
-5483
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
- run: git branch --track main origin/main || true
3232

3333
- run: if ! npx nx format:check ; then echo "Format check failed. Please run 'npx nx format:write'."; fi
34-
- run: npx nx affected --target=lint --parallel=3 --exclude=js-sdk-contrib
35-
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage --exclude=js-sdk-contrib
36-
- run: npx nx affected --target=build --parallel=3 --exclude=js-sdk-contrib
34+
- run: npx nx affected --base=origin/main --target=lint --parallel=3 --exclude=js-sdk-contrib
35+
- run: npx nx affected --base=origin/main --target=test --parallel=3 --ci --code-coverage --exclude=js-sdk-contrib
36+
- run: npx nx affected --base=origin/main --target=build --parallel=3 --exclude=js-sdk-contrib
3737

3838
e2e:
3939
runs-on: ubuntu-latest
@@ -45,7 +45,7 @@ jobs:
4545
submodules: recursive
4646
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
4747
with:
48-
node-version: 20
48+
node-version-file: '.nvmrc'
4949
cache: 'npm'
5050

5151
- name: Install

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
3333
if: ${{ steps.release.outputs.releases_created }}
3434
with:
35-
node-version: 20
35+
node-version-file: '.nvmrc'
3636
registry-url: "https://registry.npmjs.org"
3737
- name: Build Packages
3838
if: ${{ steps.release.outputs.releases_created }}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
24

.release-please-manifest.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
{
2-
"libs/hooks/open-telemetry": "0.4.0",
3-
"libs/providers/go-feature-flag": "0.7.8",
2+
"libs/hooks/open-telemetry": "1.0.0",
3+
"libs/providers/go-feature-flag": "0.7.9",
44
"libs/providers/flagd": "0.13.3",
55
"libs/providers/flagd-web": "0.7.3",
66
"libs/providers/env-var": "0.3.1",
7-
"libs/providers/config-cat": "0.7.6",
8-
"libs/providers/launchdarkly-client": "0.3.2",
7+
"libs/providers/config-cat": "0.8.0",
8+
"libs/providers/launchdarkly-client": "0.3.3",
99
"libs/providers/go-feature-flag-web": "0.2.6",
1010
"libs/shared/flagd-core": "1.1.0",
11-
"libs/shared/ofrep-core": "1.0.1",
11+
"libs/shared/ofrep-core": "1.1.0",
1212
"libs/providers/ofrep": "0.2.1",
1313
"libs/providers/ofrep-web": "0.3.3",
1414
"libs/providers/flipt": "0.1.3",
1515
"libs/providers/flagsmith-client": "0.1.3",
1616
"libs/providers/flipt-web": "0.1.5",
17-
"libs/providers/multi-provider": "0.1.2",
18-
"libs/providers/multi-provider-web": "0.0.3",
17+
"libs/providers/multi-provider": "0.1.3",
18+
"libs/providers/multi-provider-web": "0.0.4",
1919
"libs/providers/growthbook-client": "0.1.2",
20-
"libs/providers/config-cat-web": "0.1.6",
21-
"libs/shared/config-cat-core": "0.1.1",
20+
"libs/providers/config-cat-web": "0.2.0",
21+
"libs/shared/config-cat-core": "0.2.2",
2222
"libs/providers/unleash-web": "0.1.1",
2323
"libs/providers/growthbook": "0.1.2",
24-
"libs/providers/aws-ssm": "0.1.3"
24+
"libs/providers/aws-ssm": "0.1.3",
25+
"libs/providers/flagsmith": "0.1.2",
26+
"libs/hooks/debounce": "0.1.1"
2527
}

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## System Requirements
44

5-
node 16+, npm 8+ are recommended.
5+
node 24+, npm 8+ are recommended.
66

77
## Compilation target(s)
88

libs/hooks/debounce/.eslintrc.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": "../../../.eslintrc.json",
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["*.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/dependency-checks": [
22+
"error",
23+
{
24+
"ignoredFiles": ["{projectRoot}/eslint.config.{js,cjs,mjs}"]
25+
}
26+
]
27+
}
28+
}
29+
]
30+
}

libs/hooks/debounce/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
## [0.1.1](https://github.com/open-feature/js-sdk-contrib/compare/debounce-hook-v0.1.0...debounce-hook-v0.1.1) (2025-10-13)
4+
5+
6+
### ✨ New Features
7+
8+
* add debounce hook ([#1389](https://github.com/open-feature/js-sdk-contrib/issues/1389)) ([c3c18be](https://github.com/open-feature/js-sdk-contrib/commit/c3c18bec7c7c0e767da7bda63b0356eafcf3d676))

libs/hooks/debounce/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Debounce Hook
2+
3+
This is a utility "meta" hook, which can be used to effectively debounce or rate limit other hooks based on various parameters.
4+
This can be especially useful for certain UI frameworks and SDKs that frequently re-render and re-evaluate flags (React, Angular, etc).
5+
6+
## Installation
7+
8+
```
9+
$ npm install @openfeature/debounce-hook
10+
```
11+
12+
### Peer dependencies
13+
14+
This package only requires the `@openfeature/core` dependency, which is installed automatically no matter which OpenFeature JavaScript SDK you are using.
15+
16+
## Usage
17+
18+
Simply wrap your hook with the debounce hook by passing it as a constructor arg, and then configure the remaining options.
19+
In the example below, we wrap a logging hook.
20+
This debounces all its stages, so it only logs a maximum of once a minute for each flag key, no matter how many times that flag is evaluated.
21+
22+
```ts
23+
const debounceHook = new DebounceHook(loggingHook, {
24+
debounceTime: 60_000, // how long to wait before the hook can fire again
25+
maxCacheItems: 100, // max amount of items to keep in the cache; if exceeded, the oldest item is dropped
26+
});
27+
28+
// add the hook globally
29+
OpenFeature.addHooks(debounceHook);
30+
31+
// or at a specific client
32+
client.addHooks(debounceHook);
33+
```
34+
35+
The hook maintains a simple expiring cache with a fixed max size and keeps a record of recent evaluations based on an optional key-generation function (cacheKeySupplier).
36+
Be default, the key-generation function is purely based on the flag key.
37+
Particularly in server use-cases, you may want to take the targetingKey or other contextual information into account in your debouncing.
38+
Below we see an example using this, as well as other advanced options:
39+
40+
```ts
41+
const debounceHook = new DebounceHook<string>(loggingHook, {
42+
cacheKeySupplier: (flagKey, context) => flagKey + context.targetingKey, // cache on a combination of user and flag key
43+
debounceTime: 60_000, // debounce for 60 seconds (per user due to our cacheKeySupplier above)
44+
maxCacheItems: 1000, // cache a maximum of 1000 records
45+
cacheErrors: false, // don't debounce errors; always re-run if the last run threw
46+
logger: console, // optional logger
47+
});
48+
```
49+
50+
## Development
51+
52+
### Building
53+
54+
Run `nx package hooks-debounce` to build the library.
55+
56+
### Running unit tests
57+
58+
Run `nx test hooks-debounce` to execute the unit tests via [Jest](https://jestjs.io).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": [["minify", { "builtIns": false }]]
3+
}

libs/hooks/debounce/jest.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default {
2+
displayName: 'debounce',
3+
preset: '../../../jest.preset.js',
4+
transform: {
5+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
6+
},
7+
moduleFileExtensions: ['ts', 'js', 'html'],
8+
coverageDirectory: '../coverage/hooks',
9+
};

0 commit comments

Comments
 (0)