-
Notifications
You must be signed in to change notification settings - Fork 25
feat: implement context values #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 38 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
4040bef
feat: wip-working-first-version
Zaimwa9 3503df2
feat: updated-pre-commit-to-generate-types-before-tests
Zaimwa9 1229889
feat: types
Zaimwa9 768440c
feat: generate-types-before-lint
Zaimwa9 ffcb468
feat: improved-typings
Zaimwa9 94e13e8
feat: improved-typings-bis
Zaimwa9 55de0f6
feat: improved-engine-readibility
Zaimwa9 9817c0e
feat: added-unit-tests
Zaimwa9 829f958
feat: removed-unused-functions
Zaimwa9 4bd7cb6
feat: improving-evaluator
Zaimwa9 1b11129
feat: added-json-path
Zaimwa9 b2c7499
feat: added-js-doc-to-evaluators
Zaimwa9 688e764
feat: abstracted-from-segment-result
Zaimwa9 88cddd3
chore: updated-tests-to-new-data
Zaimwa9 dde91bd
feat: removed-hide-disabled-in-local-evaluation
Zaimwa9 88777e6
feat: process-identity-overrides-as-in-segment
Zaimwa9 ac8b546
feat: re-implemented-in-condition
Zaimwa9 2d998ab
feat: pulled-latest-version-of-tests
Zaimwa9 9a89bf7
feat: removed-targeting-reason-identity
Zaimwa9 40355a1
feat: merged-evaluation-context-types
Zaimwa9 a4fe223
feat: removed-unnecessary-abstraction
Zaimwa9 cdbb62c
feat: improved-error-handling
Zaimwa9 5e039c0
feat: reformatted-tests-handling-new-structure
Zaimwa9 2ceb6ce
feat: renamed-and-moved-features-evaluation-to-engine
Zaimwa9 9aa91b3
feat: updated-pre-commit-scripts
Zaimwa9 f1ee3ef
feat: updated-case-extraction-to-use-json-and-separate-each-run
Zaimwa9 45c4594
feat: added-reasons-to-flag-object
Zaimwa9 10621ad
feat: fix-get-identity-segments-returning-identity-overrides
Zaimwa9 d9f4b63
feat: fixed-tests
Zaimwa9 134e00a
feat: disregard-non-primitive-context-values
Zaimwa9 5706078
feat: use-mv-fs-uuid-fallback-for-variant-sorting
Zaimwa9 f5b4c46
feat: added-priority-to-variant-evaluation
Zaimwa9 dc79eeb
feat: synced-submodule-with-main
Zaimwa9 10205ba
feat: map-priority-based-on-ids
Zaimwa9 e022589
Update flagsmith-engine/evaluation/evaluationContext/evaluationContex…
Zaimwa9 d18a318
Merge branch 'feat/implement-context-values' of github.com:Flagsmith/…
Zaimwa9 b7cf143
feat/regenerated-types
Zaimwa9 31b615e
feat: fixed-conflicts
Zaimwa9 1e061fb
feat: simplified-tests
Zaimwa9 fe9db9e
fix: fixed-type
Zaimwa9 778cdc4
feat: use-flagsmith-id-int-for-feature-id
Zaimwa9 d8c2388
feat: use-evaluation-context-generic-with-node-metadata-implementation
Zaimwa9 a475236
feat: use-latest-schemas-with-deduplicated-keys
Zaimwa9 2bbd1d1
feat: reverted-types-to-main-and-bumped-version
Zaimwa9 51dc67a
feat: re-added-fallback
Zaimwa9 b95d127
feat: added-metadata-to-segment-override-features-and-removed-fallback
Zaimwa9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| [submodule "tests/engine/engine-tests/engine-test-data"] | ||
| path = tests/engine/engine-tests/engine-test-data | ||
| url = [email protected]:Flagsmith/engine-test-data.git | ||
| branch = v1.0.0 | ||
| branch = main | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #!/bin/sh | ||
| . "$(dirname "$0")/_/husky.sh" | ||
|
|
||
| npm run generate-engine-types | ||
| npm run lint | ||
| git add ./flagsmith-engine ./sdk ./tests ./index.ts ./.github | ||
| npm run test |
245 changes: 245 additions & 0 deletions
245
flagsmith-engine/evaluation/evaluationContext/evaluationContext.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,245 @@ | ||
| /* eslint-disable */ | ||
| /** | ||
| * This file was automatically generated by json-schema-to-typescript. | ||
| * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
| * and run json-schema-to-typescript to regenerate this file. | ||
| */ | ||
|
|
||
| /** | ||
| * An environment's unique identifier. | ||
| */ | ||
| export type Key = string; | ||
| /** | ||
| * An environment's human-readable name. | ||
| */ | ||
| export type Name = string; | ||
| /** | ||
| * A unique identifier for an identity, used for segment and multivariate feature flag targeting, and displayed in the Flagsmith UI. | ||
| */ | ||
| export type Identifier = string; | ||
| /** | ||
| * Key used when selecting a value for a multivariate feature, or for % split segmentation. Set to an internal identifier or a composite value based on the environment key and identifier, depending on Flagsmith implementation. | ||
| */ | ||
| export type Key1 = string; | ||
| /** | ||
| * Key used for % split segmentation. | ||
| */ | ||
| export type Key2 = string; | ||
| /** | ||
| * The name of the segment. | ||
| */ | ||
| export type Name1 = string; | ||
| /** | ||
| * Segment rule type. Represents a logical quantifier for the conditions and sub-rules. | ||
| */ | ||
| export type Type = 'ALL' | 'ANY' | 'NONE'; | ||
| export type SegmentCondition = SegmentCondition1 | InSegmentCondition; | ||
| /** | ||
| * A reference to the identity trait or value in the evaluation context. | ||
| */ | ||
| export type Property = string; | ||
| /** | ||
| * The operator to use for evaluating the condition. | ||
| */ | ||
| export type Operator = | ||
| | 'EQUAL' | ||
| | 'GREATER_THAN' | ||
| | 'LESS_THAN' | ||
| | 'LESS_THAN_INCLUSIVE' | ||
| | 'CONTAINS' | ||
| | 'GREATER_THAN_INCLUSIVE' | ||
| | 'NOT_CONTAINS' | ||
| | 'NOT_EQUAL' | ||
| | 'REGEX' | ||
| | 'PERCENTAGE_SPLIT' | ||
| | 'MODULO' | ||
| | 'IS_SET' | ||
| | 'IS_NOT_SET' | ||
| | 'IN'; | ||
| /** | ||
| * The value to compare against the trait or context value. | ||
| */ | ||
| export type Value = string; | ||
| /** | ||
| * A reference to the identity trait or value in the evaluation context. | ||
| */ | ||
| export type Property1 = string; | ||
| /** | ||
| * The operator to use for evaluating the condition. | ||
| */ | ||
| export type Operator1 = 'IN'; | ||
| /** | ||
| * The values to compare against the trait or context value. | ||
| */ | ||
| export type Value1 = string[]; | ||
| /** | ||
| * Conditions that must be met for the rule to apply. | ||
| */ | ||
| export type Conditions = SegmentCondition[]; | ||
| /** | ||
| * Sub-rules nested within the segment rule. | ||
| */ | ||
| export type SubRules = SegmentRule[]; | ||
| /** | ||
| * Rules that define the segment. | ||
| */ | ||
| export type Rules = SegmentRule[]; | ||
| /** | ||
| * Key used when selecting a value for a multivariate feature. Set to an internal identifier or a UUID, depending on Flagsmith implementation. | ||
| */ | ||
| export type Key3 = string; | ||
| /** | ||
| * Unique feature identifier. | ||
| */ | ||
| export type FeatureKey = string; | ||
| /** | ||
| * Feature name. | ||
| */ | ||
| export type Name2 = string; | ||
| /** | ||
| * Indicates whether the feature is enabled in the environment. | ||
| */ | ||
| export type Enabled = boolean; | ||
| /** | ||
| * A default environment value for the feature. If the feature is multivariate, this will be the control value. | ||
| */ | ||
| export type Value2 = string | number | boolean | null; | ||
| /** | ||
| * The value of the feature. | ||
| */ | ||
| export type Value3 = string | number | boolean | null; | ||
| /** | ||
| * The weight of the feature value variant, as a percentage number (i.e. 100.0). | ||
| */ | ||
| export type Weight = number; | ||
| /** | ||
| * Priority of the feature flag variant. Lower values indicate a higher priority when multiple variants apply to the same context key. | ||
| */ | ||
| export type Priority = number; | ||
| /** | ||
| * An array of environment default values associated with the feature. Empty for standard features, or contains multiple values for multivariate features. | ||
| */ | ||
| export type Variants = FeatureValue[]; | ||
| /** | ||
| * Priority of the feature context. Lower values indicate a higher priority when multiple contexts apply to the same feature. | ||
| */ | ||
| export type Priority1 = number; | ||
| /** | ||
| * Feature overrides for the segment. | ||
| */ | ||
| export type Overrides = FeatureContext[]; | ||
|
|
||
| /** | ||
| * A context object containing the necessary information to evaluate Flagsmith feature flags. | ||
| */ | ||
| export interface EvaluationContext { | ||
| environment: EnvironmentContext; | ||
| /** | ||
| * Identity context used for identity-based evaluation. | ||
| */ | ||
| identity?: IdentityContext | null; | ||
| segments?: Segments; | ||
| features?: Features; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Environment context required for evaluation. | ||
| */ | ||
| export interface EnvironmentContext { | ||
| key: Key; | ||
| name: Name; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Represents an identity context for feature flag evaluation. | ||
| */ | ||
| export interface IdentityContext { | ||
| identifier: Identifier; | ||
| key: Key1; | ||
| traits?: Traits; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * A map of traits associated with the identity, where the key is the trait name and the value is the trait value. | ||
| */ | ||
| export interface Traits { | ||
| [k: string]: string | number | boolean | null; | ||
| } | ||
| /** | ||
| * Segments applicable to the evaluation context. | ||
| */ | ||
| export interface Segments { | ||
| [k: string]: SegmentContext; | ||
| } | ||
| /** | ||
| * Represents a segment context for feature flag evaluation. | ||
| */ | ||
| export interface SegmentContext { | ||
| key: Key2; | ||
| name: Name1; | ||
| rules: Rules; | ||
| overrides?: Overrides; | ||
| metadata?: Metadata; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Represents a rule within a segment for feature flag evaluation. | ||
| */ | ||
| export interface SegmentRule { | ||
| type: Type; | ||
| conditions?: Conditions; | ||
| rules?: SubRules; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Represents a condition within a segment rule for feature flag evaluation. | ||
| */ | ||
| export interface SegmentCondition1 { | ||
| property: Property; | ||
| operator: Operator; | ||
| value: Value; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Represents an IN condition within a segment rule for feature flag evaluation. | ||
| */ | ||
| export interface InSegmentCondition { | ||
| property: Property1; | ||
| operator: Operator1; | ||
| value: Value1; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Represents a feature context for feature flag evaluation. | ||
| */ | ||
| export interface FeatureContext { | ||
| key: Key3; | ||
| feature_key: FeatureKey; | ||
| name: Name2; | ||
| enabled: Enabled; | ||
| value: Value2; | ||
| variants?: Variants; | ||
| priority?: Priority1; | ||
Zaimwa9 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Represents a multivariate value for a feature flag. | ||
| */ | ||
| export interface FeatureValue { | ||
| value: Value3; | ||
| weight: Weight; | ||
| priority: Priority; | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Additional metadata associated with the segment. | ||
| */ | ||
| export interface Metadata { | ||
| [k: string]: unknown; | ||
| } | ||
| /** | ||
| * Features to be evaluated in the context. | ||
| */ | ||
| export interface Features { | ||
| [k: string]: FeatureContext; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.