1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-04 01:18:20 +02:00
unleash.unleash/src/lib/db
Thomas Heartman e55ad1a21e
feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839)
* Feat: return reasons why a feature evaluated to true or false

Note: this is very rough and just straight ripped from the nodejs
client. It will need a lot of work, but is a good place to start

* Feat: add suggested shape for new payload

* Chore: minor cleanup

* Wip: make server compile again

* Remove unused schema ref

* Export new schemas

* Chore: fix some tests to use sub property

* Fix: fix some tests

* Refactor: rename some variables, uncomment some stuff

* Add segments type to bootstrap options

* Add segments capability to offline feature evaluator

* Fix function calls after turning params into an option abject

* Feat: test strategy order, etc

* Feat: add test to check that all strats are returned correctly

* Feat: allow you to include strategy ids in clients

* Wip: hook up segments in the offline client.

Note: compared to regular clients, they still fail

* Feat: add segments validation

* Fix: fix test case invariant.

* Chore: revert to returning only `boolean` from strategies.

This _should_ make it work with custom strategies too 🤞

* Feat: make more properties of the returned feature required

* Wip: add some comments and unfinished tests for edge cases

* Feat: add `isEnabledInCurrentEnvironment` prop

* Feat: consider more strategy failure cases

* Feat: test that isenabledinenvironment matches expectations

* Feat: add unknown strategies

* Fix: fix property access typo

* Feat: add unknown strategy for fallback purposes

* Feat: test edge case: all unknown strategies

* Feat: add custom strategy to arbitrary

* Feat: test that features can be true, even if not enabled in env

* Chore: add some comments

* Wip: fix sdk tests

* Remove comments, improve test logging

* Feat: add descriptions and examples to playground feature schema

* Switch `examples` for `example`

* Update schemas with descriptions and examples

* Fix: update snapshot

* Fix: openapi example

* Fix: merge issues

* Fix: fix issue where feature evaluation state was wrong

* Chore: update openapi spec

* Fix: fix broken offline client tests

* Refactor: move schemas into separate files

* Refactor: remove "reason" for incomplete evaluation.

The only instances where evaluation is incomplete is when we don't
know what the strategy is.

* Refactor: move unleash node client into test and dev dependencies

* Wip: further removal of stuff

* Chore: remove a bunch of code that we don't use

* Chore: remove comment

* Chore: remove unused code

* Fix: fix some prettier errors

* Type parameters in strategies to avoid `any`

* Fix: remove commented out code

* Feat: make `id` required on playground strategies

* Chore: remove redundant type

* Fix: remove redundant if and fix fallback evaluation

* Refactor: reduce nesting and remove duplication

* Fix: remove unused helper function

* Refactor: type `parameters` as `unknown`

* Chore: remove redundant comment

* Refactor: move constraint code into a separate file

* Refactor: rename `unleash` -> `feature-evaluator`

* Rename class `Unleash` -> `FeatureEvaluator`

* Refactor: remove this.ready and sync logic from feature evaluator

* Refactor: remove unused code, rename config type

* Refactor: remove event emission from the Unleash client

* Remove unlistened-for events in feature evaluator

* Refactor: make offline client synchronous; remove code

* Fix: update openapi snapshot after adding required strategy ids

* Feat: change `strategies` format.

This commit changes the format of a playground feature's `strategies`
properties from a list of strategies to an object with properties
`result` and `data`. It looks a bit like this:

```ts
type Strategies = {
  result: boolean | "unknown",
  data: Strategy[]
}
```

The reason is that this allows us to avoid the breaking change that
was previously suggested in the PR:

`feature.isEnabled` used to be a straight boolean. Then, when we found
out we couldn't necessarily evaluate all strategies (custom strats are
hard!) we changed it to `boolean | 'unevaluated'`. However, this is
confusing on a few levels as the playground results are no longer the
same as the SDK would be, nor are they strictly boolean anymore.

This change reverts the `isEnabled` functionality to what it was
before (so it's always a mirror of what the SDK would show).
The equivalent of `feature.isEnabled === 'unevaluated'` now becomes
`feature.isEnabled && strategy.result === 'unknown'`.

* Fix: Fold long string descriptions over multiple lines.

* Fix: update snapshot after adding line breaks to descriptions
2022-08-04 15:41:52 +02:00
..
access-store.ts Feat/grouping (#1845) 2022-07-21 16:23:56 +02:00
addon-store.ts fix: add projects and environments field to addon select 2022-07-12 14:32:24 +02:00
api-token-store.ts fix: Issue #1444 - API import with drop=true deletes existing client keys (#1668) 2022-06-09 15:56:13 +01:00
client-applications-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
client-instance-store.ts fix: uintroduce call to update last_seen on client-instance 2021-12-10 09:31:54 +01:00
client-metrics-store-v2.ts fix: metric counters should use bigint (#1313) 2022-01-31 08:50:11 +01:00
context-field-store.ts feat: add context value descriptions (#1496) 2022-04-19 08:40:07 +02:00
db-pool.ts feat: add "application_name" as an optional DB option #1170 (#1478) 2022-04-07 20:55:56 +02:00
environment-store.ts feat: enabled environments override now also moves projects and toggles to new environments 2022-03-11 15:52:13 +02:00
event-store.test.ts fix: add missing awaits (#1472) 2022-04-01 11:10:21 +02:00
event-store.ts task: Add events for setting-service (#1814) 2022-07-21 15:40:31 +02:00
feature-environment-store.ts fix: require equal environments when moving toggles (#1595) 2022-05-18 11:07:01 +02:00
feature-strategy-store.ts Strategy sort order endpoint (#1855) 2022-07-26 14:16:30 +02:00
feature-tag-store.ts fix: tag validation duplicate message (#1756) 2022-06-28 08:04:43 +02:00
feature-toggle-client-store.ts feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839) 2022-08-04 15:41:52 +02:00
feature-toggle-store.ts Added missing archivedAt to featureSchema (#1779) 2022-07-01 11:51:26 +00:00
feature-type-store.ts refactor: add OpenAPI schema to feature types controller (#1684) 2022-06-09 13:17:13 +02:00
group-store.ts Implement group access edit for project (#1854) 2022-07-25 10:11:16 +00:00
index.ts Feat/grouping (#1845) 2022-07-21 16:23:56 +02:00
project-store.ts refactor: add OpenAPI schemas to more controllers (#1680) 2022-06-08 15:31:34 +02:00
reset-token-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
role-store.ts Feat/grouping (#1845) 2022-07-21 16:23:56 +02:00
segment-store.ts fix: reject duplicate segment names (#1475) 2022-04-06 14:01:50 +01:00
session-store.ts fix: be explicit when specifying time & replace moment with date-fns (#1072) 2021-11-02 15:13:46 +01:00
setting-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
strategy-store.ts fix: import should not drop built-in strategies 2021-08-26 22:41:51 +02:00
tag-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
tag-type-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
user-feedback-store.ts fix: Stores as typescript and with interfaces. (#902) 2021-08-12 15:04:37 +02:00
user-splash-store.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
user-store.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00