1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/openapi/spec
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
..
__snapshots__ Strategy sort order endpoint (#1855) 2022-07-26 14:16:30 +02:00
addon-parameter-schema.ts open-api addon controller (#1721) 2022-06-22 13:49:18 +03:00
addon-schema.test.ts open-api addon controller (#1721) 2022-06-22 13:49:18 +03:00
addon-schema.ts
addon-type-schema.ts open-api addon controller (#1721) 2022-06-22 13:49:18 +03:00
addons-schema.test.ts
addons-schema.ts
api-token-schema.test.ts
api-token-schema.ts
api-tokens-schema.ts
application-schema.ts task: add OpenApi spec to metrics route (#1725) 2022-06-21 09:12:40 +02:00
applications-schema.ts
bootstrap-ui-schema.test.ts
bootstrap-ui-schema.ts
change-password-schema.test.ts Task/open api reset password (#1740) 2022-06-22 14:31:41 +03:00
change-password-schema.ts
client-application-schema.test.ts refactor: add schemas to client application registration (#1746) 2022-06-24 15:29:27 +02:00
client-application-schema.ts
client-feature-schema.ts
client-features-query-schema.test.ts
client-features-query-schema.ts
client-features-schema.test.ts
client-features-schema.ts
client-metrics-schema.test.ts OAS for client-api metrics.ts (#1753) 2022-06-30 13:27:12 +03:00
client-metrics-schema.ts
client-variant-schema.ts
clone-feature-schema.ts
constraint-schema.test.ts
constraint-schema.ts feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839) 2022-08-04 15:41:52 +02:00
context-field-schema.test.ts refactor: add OpenAPI schema to context controller (#1711) 2022-06-17 10:11:55 +01:00
context-field-schema.ts
context-fields-schema.ts refactor: add OpenAPI schema to context controller (#1711) 2022-06-17 10:11:55 +01:00
create-api-token-schema.ts fix: avoid 400s for unknown request body fields (#1737) 2022-06-21 10:33:03 +02:00
create-feature-schema.ts
create-feature-strategy-schema.ts refactor: add schemas to strategy controller (#1744) 2022-06-23 08:10:20 +02:00
create-user-schema.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
date-schema.ts
email-schema.test.ts
email-schema.ts
environment-schema.ts
environments-schema.ts
event-schema.test.ts
event-schema.ts
events-schema.test.ts
events-schema.ts
export-query-parameters.ts
feature-environment-metrics-schema.ts OAS for client-metrics controller (#1739) 2022-06-27 11:17:44 +03:00
feature-environment-schema.test.ts refactor: add schemas to strategy controller (#1744) 2022-06-23 08:10:20 +02:00
feature-environment-schema.ts refactor: add schemas to strategy controller (#1744) 2022-06-23 08:10:20 +02:00
feature-events-schema.test.ts
feature-events-schema.ts
feature-metrics-schema.test.ts OAS for client-metrics controller (#1739) 2022-06-27 11:17:44 +03:00
feature-metrics-schema.ts
feature-schema.test.ts
feature-schema.ts
feature-strategy-schema.ts open api implementation - client features controller (#1745) 2022-06-30 12:54:14 +03:00
feature-strategy-segment-schema.ts
feature-tag-schema.ts
feature-type-schema.test.ts refactor: add OpenAPI schema to feature types controller (#1684) 2022-06-09 13:17:13 +02:00
feature-type-schema.ts
feature-types-schema.ts
feature-usage-schema.test.ts
feature-usage-schema.ts OAS for client-metrics controller (#1739) 2022-06-27 11:17:44 +03:00
feature-variants-schema.ts refactor: add soft response schema validation (#1657) 2022-06-08 08:01:14 +02:00
features-schema.test.ts
features-schema.ts
feedback-schema.ts
group-schema.ts
group-user-model-schema.ts
groups-schema.test.ts
groups-schema.ts
health-check-schema.ts refactor: add OpenAPI schema to health-check controller (#1732) 2022-06-20 11:22:41 +01:00
health-overview-schema.ts
health-report-schema.ts refactor: add OpenAPI schemas to more controllers (#1680) 2022-06-08 15:31:34 +02:00
id-schema.ts
legal-value-schema.ts
login-schema.ts refactor: add OpenAPI schema to simple-password-provider controller (#1734) 2022-06-23 08:40:25 +01:00
me-schema.test.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
me-schema.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
name-schema.ts
override-schema.ts refactor: add soft response schema validation (#1657) 2022-06-08 08:01:14 +02:00
parameters-schema.ts
password-schema.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
patch-schema.ts
patches-schema.ts
permission-schema.ts
playground-constraint-schema.ts feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839) 2022-08-04 15:41:52 +02:00
playground-feature-schema.test.ts feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839) 2022-08-04 15:41:52 +02:00
playground-feature-schema.ts feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839) 2022-08-04 15:41:52 +02:00
playground-request-schema.test.ts feat: add playground API post endpoint (#1791) 2022-07-12 13:01:10 +02:00
playground-request-schema.ts
playground-response-schema.test.ts feat: add all feature variants to the playground payload (#1835) 2022-07-20 08:54:34 +02:00
playground-response-schema.ts
playground-segment-schema.ts feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839) 2022-08-04 15:41:52 +02:00
playground-strategy-schema.ts
project-environment-schema.ts
project-schema.ts refactor: add OpenAPI schemas to more controllers (#1680) 2022-06-08 15:31:34 +02:00
projects-schema.ts refactor: add OpenAPI schemas to more controllers (#1680) 2022-06-08 15:31:34 +02:00
reset-password-schema.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
role-schema.test.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
role-schema.ts
sdk-context-schema.test.ts
sdk-context-schema.ts
segment-schema.ts open api implementation - client features controller (#1745) 2022-06-30 12:54:14 +03:00
set-strategy-sort-order-schema.test.ts Strategy sort order endpoint (#1855) 2022-07-26 14:16:30 +02:00
set-strategy-sort-order-schema.ts
sort-order-schema.test.ts
sort-order-schema.ts
splash-schema.ts refactor: add schemas to splash controller (#1697) 2022-06-10 15:11:07 +02:00
state-schema.ts
strategies-schema.ts
strategy-schema.test.ts
strategy-schema.ts refactor: add schemas to strategy controller (#1744) 2022-06-23 08:10:20 +02:00
tag-schema.ts
tag-type-schema.ts
tag-types-schema.ts task: add open-api for tag-types (#1700) 2022-06-14 09:06:41 +02:00
tag-with-version-schema.ts task: add openapi for tags (#1724) 2022-06-21 08:23:30 +02:00
tags-schema.ts
token-user-schema.test.ts refactor: add missing tokenUserSchema fields (#1742) 2022-06-22 15:37:26 +02:00
token-user-schema.ts
ui-config-schema.test.ts
ui-config-schema.ts
update-api-token-schema.ts fix: avoid 400s for unknown request body fields (#1737) 2022-06-21 10:33:03 +02:00
update-feature-schema.ts refactor: add soft response schema validation (#1657) 2022-06-08 08:01:14 +02:00
update-feature-strategy-schema.ts refactor: add schemas to strategy controller (#1744) 2022-06-23 08:10:20 +02:00
update-tag-type-schema.ts fix: avoid 400s for unknown request body fields (#1737) 2022-06-21 10:33:03 +02:00
update-user-schema.ts fix: Make additionalProperties true (#1861) 2022-07-27 09:02:02 +02:00
upsert-context-field-schema.ts fix: avoid 400s for unknown request body fields (#1737) 2022-06-21 10:33:03 +02:00
upsert-strategy-schema.ts
user-schema.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
users-groups-base-schema.test.ts Grouping access endpoing (#1858) 2022-07-26 11:39:55 +00:00
users-groups-base-schema.ts Grouping access endpoing (#1858) 2022-07-26 11:39:55 +00:00
users-schema.test.ts
users-schema.ts
users-search-schema.test.ts
users-search-schema.ts refactor: add schemas to user admin controller (#1692) 2022-06-22 14:55:43 +02:00
validate-password-schema.test.ts
validate-password-schema.ts
validate-tag-type-schema.ts fix: avoid 400s for unknown request body fields (#1737) 2022-06-21 10:33:03 +02:00
variant-schema.ts refactor: add soft response schema validation (#1657) 2022-06-08 08:01:14 +02:00
variants-schema.ts
version-schema.ts refactor: add OpenAPI schema to UI config controller (#1681) 2022-06-08 14:57:39 +02:00