Skip to content

Commit 28e22ef

Browse files
committed
- Support for feature properties (if any)
- Updated API to 1.8
1 parent 6b3b71a commit 28e22ef

Some content is hidden

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

42 files changed

+321
-129
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM node:18-buster-slim as build
33
ADD . /app
44
WORKDIR /app
55
RUN cd /app/featurehub-javascript-client-sdk && npm install && npm run compile
6-
RUN cd /app/featurehub-javascript-node-sdk && npm install && npm run link && npm run compile
6+
RUN cd /app/featurehub-javascript-node-sdk && npm install && npm run setup && npm run compile && npm run link
77
RUN cd /app/examples/todo-server-tests && npm install && npm run compile
88
RUN cd /app/examples/todo-backend-typescript && npm install && npm run compile
99

examples/todo-backend-typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"license": "MIT",
77
"scripts": {
88
"build": "node_modules/.bin/tsc",
9-
"link": "npm link featurehub-javascript-client-sdk featurehub-javascript-node-sdk",
10-
"compile": "npm run link && npm run build",
9+
"setup": "npm link featurehub-javascript-client-sdk featurehub-javascript-node-sdk",
10+
"compile": "npm run setup && npm run build",
1111
"start": "npm run build && node --trace-deprecation --trace-warnings dist/app.js",
1212
"run": "npm run build && node --trace-deprecation --trace-warnings dist/app.js"
1313
},

examples/todo-server-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"description": "Integration tests for FeatureHub SDKs (server-side)",
55
"scripts": {
66
"build": "node ./node_modules/typescript/bin/tsc",
7-
"link": "npm link featurehub-javascript-client-sdk featurehub-javascript-node-sdk",
8-
"compile": "npm run link && npm run build",
7+
"setup": "npm link featurehub-javascript-client-sdk featurehub-javascript-node-sdk",
8+
"compile": "npm run setup && npm run build",
99
"test": "cucumber-js --require-module ts-node/register --require 'features/support/*.ts' --publish",
1010
"generate:specs": "openapi-generator-cli generate -g typescript-axios -i ../todo-api/todo-api.yaml -o ./src/client-axios"
1111
},

featurehub-javascript-client-sdk/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 1.3.4
2+
- support for Extended Feature Properties from FHOS 1.8.0, see xxx insert documentation link.
3+
14
#### 1.3.3
25
- listeners were not being fired when added to contexts that matched strategies. [bugfix](https://github.com/featurehub-io/featurehub-javascript-sdk/issues/196)
36
- all the getX methods on the Context now have defaults, so you can say fhContext.getFlag("feature", false) and if it isn't set or doesn't exist, it will return false. This is an optional field so it doesn't break existing code. (feature)

featurehub-javascript-client-sdk/app/client_feature_repository.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ export class ClientFeatureRepository implements InternalFeatureRepository {
356356
const fState = holder.getFeatureState()!;
357357
if (fs.version! < fState.version!) {
358358
return false;
359-
} else if (fs.version === fState.version && fs.value === fState.value) {
360-
return false;
361359
}
362360
}
363361

featurehub-javascript-client-sdk/app/feature_state.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,6 @@ export interface FeatureStateHolder<T = any> {
117117
get type(): FeatureValueType | undefined;
118118

119119
withContext(param: ClientContext): FeatureStateHolder;
120+
121+
get featureProperties(): Record<string,string> | undefined;
120122
}

featurehub-javascript-client-sdk/app/feature_state_holders.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FeatureState, FeatureValueType } from './models';
33
import { ClientContext } from './client_context';
44
import { InternalFeatureRepository } from './internal_feature_repository';
55
import { ListenerUtils } from './listener_utils';
6-
import {fhLog} from "./feature_hub_config";
6+
import { fhLog } from './feature_hub_config';
77

88
interface ListenerTracker {
99
listener: FeatureListener;
@@ -88,7 +88,7 @@ export class FeatureStateBaseHolder<T = any> implements FeatureStateHolder<T> {
8888
if (this._ctx !== undefined) {
8989
this.listeners.set(pos, {
9090
listener: () => listener(this), holder: this
91-
} );
91+
});
9292
} else {
9393
this.listeners.set(pos, {
9494
listener: listener, holder: this
@@ -146,7 +146,7 @@ export class FeatureStateBaseHolder<T = any> implements FeatureStateHolder<T> {
146146
this.listeners.forEach((value, key) => {
147147
listenerValues.set(key, {
148148
value: value.holder.value
149-
})
149+
});
150150
});
151151

152152
this.internalFeatureState = fs;
@@ -164,7 +164,7 @@ export class FeatureStateBaseHolder<T = any> implements FeatureStateHolder<T> {
164164
try {
165165
value.listener(value.holder);
166166
} catch (e) {
167-
fhLog.error(`Failed to trigger listener`, e);
167+
fhLog.error('Failed to trigger listener', e);
168168
}
169169
}
170170
});
@@ -293,4 +293,8 @@ export class FeatureStateBaseHolder<T = any> implements FeatureStateHolder<T> {
293293
get value(): T {
294294
return this._getValue(this.getType(), true);
295295
}
296+
297+
get featureProperties(): Record<string, string> | undefined {
298+
return this.featureState()?.fp ?? undefined;
299+
}
296300
}

featurehub-javascript-client-sdk/app/middleware.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class BaggageHolder<T = any> implements FeatureStateHolder<T> {
2222
this.baggageValue = value;
2323
}
2424

25+
// feature properties are not included in baggage, they don't make logical sense.
26+
get featureProperties(): Record<string, string> | undefined {
27+
return undefined;
28+
}
29+
2530
isEnabled(): boolean {
2631
return this.getBoolean() === true;
2732
}

featurehub-javascript-client-sdk/app/models/.openapi-generator/FILES

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
.gitignore
22
.npmignore
3-
.openapi-generator-ignore
43
git_push.sh
54
index.ts
65
models/application-version-info.ts
7-
models/base-rollout-strategy-attribute.ts
6+
models/base-rollout-strategy-all-of.ts
87
models/base-rollout-strategy.ts
8+
models/base-strategy.ts
9+
models/base-uistrategy.ts
910
models/feature-environment-collection.ts
1011
models/feature-rollout-strategy-all-of.ts
1112
models/feature-rollout-strategy-attribute.ts
@@ -16,6 +17,7 @@ models/feature-value-type.ts
1617
models/index.ts
1718
models/role-type.ts
1819
models/rollout-strategy-attribute-conditional.ts
20+
models/rollout-strategy-attribute.ts
1921
models/rollout-strategy-field-type.ts
2022
models/sseresult-state.ts
2123
models/strategy-attribute-country-name.ts
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c1d8832e6a2bf63c1201a9ce0e28f9024bb577984c9ab652a03f4bb27f443f83
1+
357944b3dddaf0986739059920aae8fc5e554ee1d80beffa07e26b38ea4f88ff

0 commit comments

Comments
 (0)