Skip to content

Commit d1e447c

Browse files
committed
fix: fix-mv-evaluation
1 parent 014f38b commit d1e447c

6 files changed

Lines changed: 25 additions & 24 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- '*'
77

88
permissions:
9-
id-token: write # Required for OIDC
9+
id-token: write # Required for OIDC
1010
contents: read
1111

1212
jobs:

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "tests/engine/engine-tests/engine-test-data"]
22
path = tests/engine/engine-tests/engine-test-data
33
url = git@github.com:Flagsmith/engine-test-data.git
4-
branch = v3.1.0
4+
branch = v3.4.1

CHANGELOG.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@
22

33
## [6.2.0](https://github.com/Flagsmith/flagsmith-nodejs-client/compare/v6.1.0...v6.2.0) (2025-11-04)
44

5-
65
### Features
76

8-
* add user agent to requests ([#206](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/206)) ([ef2b97a](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/ef2b97a3022a5feeb96c3ccdb8009ae89b582d0b))
7+
- add user agent to requests ([#206](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/206)) ([ef2b97a](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/ef2b97a3022a5feeb96c3ccdb8009ae89b582d0b))
98

109
### Bug Fixes
1110

12-
* handle environment documentation pagination ([#205](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/205)) ([a83d3a5](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/a83d3a5789abbc47abc2a95d07a19756ab7befbb))
13-
11+
- handle environment documentation pagination ([#205](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/205)) ([a83d3a5](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/a83d3a5789abbc47abc2a95d07a19756ab7befbb))
1412

1513
### CI
1614

17-
* add release please configuration ([#190](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/190)) ([946f911](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/946f911e3c9d7df21bd7e5c6df5f9f92927e5e59))
18-
15+
- add release please configuration ([#190](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/190)) ([946f911](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/946f911e3c9d7df21bd7e5c6df5f9f92927e5e59))
1916

2017
### Docs
2118

22-
* removing hero image from SDK readme ([#194](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/194)) ([bc71d40](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/bc71d40bdfa319b5333c18f4f9eacbe90b6fad0d))
23-
19+
- removing hero image from SDK readme ([#194](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/194)) ([bc71d40](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/bc71d40bdfa319b5333c18f4f9eacbe90b6fad0d))
2420

2521
### Other
2622

27-
* add root CODEOWNERS ([#200](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/200)) ([e81cc00](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/e81cc00f1de35e0884b2cfc70c6cf54a75a3426c))
28-
* versioned test data ([#197](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/197)) ([9fb5c12](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/9fb5c127a2b56503ba876da2466c24e5ceff1d3f))
23+
- add root CODEOWNERS ([#200](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/200)) ([e81cc00](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/e81cc00f1de35e0884b2cfc70c6cf54a75a3426c))
24+
- versioned test data ([#197](https://github.com/Flagsmith/flagsmith-nodejs-client/issues/197)) ([9fb5c12](https://github.com/Flagsmith/flagsmith-nodejs-client/commit/9fb5c127a2b56503ba876da2466c24e5ceff1d3f))
2925

3026
<a id="v6.1.0"></a>
3127

flagsmith-engine/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function evaluateSegments(context: EvaluationContextWithMetadata): {
7070
}
7171
}
7272
: {})
73-
}));
73+
})) as EvaluationResultSegments;
7474
const segmentOverrides = processSegmentOverrides(identitySegments);
7575

7676
return { segments, segmentOverrides };
@@ -127,11 +127,11 @@ export function evaluateFeatures(
127127
for (const feature of Object.values(context.features || {})) {
128128
const segmentOverride = segmentOverrides[feature.name];
129129
const finalFeature = segmentOverride ? segmentOverride.feature : feature;
130-
const hasOverride = !!segmentOverride;
131130

132-
const { value: evaluatedValue, reason: evaluatedReason } = hasOverride
133-
? { value: finalFeature.value, reason: undefined }
134-
: evaluateFeatureValue(finalFeature, getIdentityKey(context));
131+
const { value: evaluatedValue, reason: evaluatedReason } = evaluateFeatureValue(
132+
finalFeature,
133+
getIdentityKey(context)
134+
);
135135

136136
flags[finalFeature.name] = {
137137
name: finalFeature.name,

flagsmith-engine/segments/evaluators.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,22 @@ function evaluateRuleConditions(ruleType: string, conditionResults: boolean[]):
131131
function getTraitValue(property: string, context?: GenericEvaluationContext): any {
132132
if (property.startsWith('$.')) {
133133
const contextValue = getContextValue(property, context);
134-
if (contextValue && !isNonPrimitive(contextValue)) {
134+
if (contextValue !== undefined && isPrimitive(contextValue)) {
135135
return contextValue;
136136
}
137137
}
138-
139138
const traits = context?.identity?.traits || {};
139+
140140
return traits[property];
141141
}
142142

143-
function isNonPrimitive(value: any): boolean {
143+
function isPrimitive(value: any): boolean {
144144
if (value === null || value === undefined) {
145-
return false;
145+
return true;
146146
}
147147

148148
// Objects and arrays are non-primitive
149-
return typeof value === 'object';
149+
return typeof value !== 'object';
150150
}
151151

152152
/**
@@ -167,7 +167,8 @@ export function getContextValue(jsonPath: string, context?: GenericEvaluationCon
167167
if (!context || !jsonPath?.startsWith('$.')) return undefined;
168168

169169
try {
170-
const results = jsonpath.query(context, jsonPath);
170+
const normalizedPath = normalizeJsonPath(jsonPath);
171+
const results = jsonpath.query(context, normalizedPath);
171172
return results.length > 0 ? results[0] : undefined;
172173
} catch (error) {
173174
return undefined;
@@ -179,3 +180,7 @@ export function getIdentityKey(context?: GenericEvaluationContext): string | und
179180

180181
return context.identity.key || `${context.environment.key}_${context.identity.identifier}`;
181182
}
183+
184+
function normalizeJsonPath(jsonPath: string): string {
185+
return jsonPath.replace(/\.([^.\[\]]+)$/, "['$1']");
186+
}
Submodule engine-test-data updated 106 files

0 commit comments

Comments
 (0)