1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
Commit Graph

458 Commits

Author SHA1 Message Date
Tymoteusz Czech
14b1540715
feat: add feature flag for embedded proxy (#1939)
* feat: add feature flag for embedded proxy

* update snapshot for config
2022-08-18 11:26:31 +02:00
Tymoteusz Czech
3266e9c22a
Refactor: rename frontend api key (#1935)
* refactor: rename frontend api key

* fix: api token schema tests
2022-08-18 08:20:51 +00:00
sjaanus
037b8eacd3
Wrong number on the project page regarding members in that project (#1917)
* Fix project member count

* Fix

* Add editors to projects
2022-08-17 09:05:41 +00:00
Tymoteusz Czech
9676165de9
Feat: Create frontend API key (#1932)
* refactor: remove unused API definition routes

* feat: embed proxy endpoints

* feat: add metadata

* feat: update schema

* feat: check token metadata for alias if none is found

* refactor: add api token metadata test coverage

* refactor: proxy key validation and default values

* refactor: update snapshot

Co-authored-by: olav <mail@olav.io>
Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-08-17 10:55:52 +02:00
olav
e8d542af0f
feat: embed proxy endpoints (#1926)
* refactor: remove unused API definition routes

* feat: add support for proxy keys

* feat: support listening for any event

* feat: embed proxy endpoints

* refactor: add an experimental flag for the embedded proxy
2022-08-16 15:33:33 +02:00
Fredrik Strand Oseberg
c82318d4c5
fix: check variants before mapping (#1922)
* fix: check variants before mapping

* fix: default to empty array
2022-08-16 13:39:20 +02:00
sjaanus
bf11001d1c
Fix Project members SQL query performance issue (#1911)
* Fix sql query

* Update
2022-08-12 13:34:51 +00:00
Thomas Heartman
b04920602b
fix: Add deprecated openapi tags as valid tags for operations (#1916)
## PR text

I realized that the tag changes we introduced in #1907 would be breaking for people who use the unleash-server package and implement their own endpoints on top of it (as we do in unleash-enterprise).

This change makes it possible to still use the old tags. However, these tags are purposefully not added to the root schema or the list of OpenAPI tag types. Any of our endpoints still using them (I think there is one in Unleash enterprise, see ivarconr/unleash-enterprise#109) should switch over when possible.

## Commits

* fix: Add deprecated openapi tags as valid tags for operations

* Docs: add explanatory comment for why the type exists.
2022-08-12 12:06:21 +00:00
Thomas Heartman
9448461aaa
docs: prep to add OpenAPI spec to Unleash docs (#1907)
* Docs: start experimenting with OpenAPI and docusaurus

* Docs: add docusaurus-theme-openapi-docs pkg

* Wip: current status

* Docs: Add 'docusaurus-plugin-api-docs'

* Move openapi into own sidebar; generate from localhost

* Chore: Update docusaurus plugin for OpenAPI

* Add website/yarn.lock to git

* Fix: fix CSS warning by using flex-end instead of end

* docs: make openapi generated code work again

* docs: make tags work properly with openapi sidebar

* Docs/chore: update OpenAPI tag scheme.

Add a whole bunch of new tags to make it easier to understand
available tags in OpenAPI.

* docs: point to new openapi docs from old api docs

* docs: typo

* Docs:  link restructure

* docs: add operation indicators to openapi docs

* docs: change badge color for operations

* docs: update openapi-docs package

It now sorts tags the same as the schema

* docs: pluralize APIs in slug

* docs: update links to generated api docs

* docs: update openapi snapshot tests with new tags

* docs: conditionally load spec from localhost or from file

* docs: Remove changes relating to immediate switchover

* refactor: rename types; extract into separate file

* docs: fix api doc links
2022-08-12 11:37:57 +02:00
Simon Hornby
38e428dacf
Fix/remove group owner concept (#1905)
* fix: remove group user role
2022-08-11 08:23:08 +02:00
sjaanus
84a932043e
Remove joins (#1898) 2022-08-10 06:56:57 +00:00
olav
a34c674971
feat: add event search endpoint (#1893)
* feat: add event search endpoint

* refactor: expand variable names

* refactor: add table type to query builder

* refactor: improve schema limit/offset types

* refactor: describe searchEventsSchema fields
2022-08-09 16:14:50 +02:00
olav
49095025ff
refactor: remove bootstrap endpoint (#1900) 2022-08-09 15:58:27 +02:00
Fredrik Strand Oseberg
47addb31cb
fix: parameter naming (#1899) 2022-08-09 13:13:05 +02:00
olav
f846b8da18
refactor: use the same variant schema for the admin and client APIs (#1882) 2022-08-08 16:21:57 +02:00
olav
df910cc20c
fix: return 400 on invalid JSON instead of 404 (#1897) 2022-08-08 14:44:57 +02:00
Gastón Fournier
d4b9ca443c
feat: change log level for OpenAPI to debug (#1895) 2022-08-08 08:27:53 +00:00
sjaanus
c37cbb1819
Add seen to groups (#1894) 2022-08-08 06:02:40 +00:00
Gastón Fournier
678e3f9c93
feat: add new standard errors (#1890)
* feat: add new standard errors for 404 and 409

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-08-05 12:10:25 +00:00
Thomas Heartman
98a6cd05c6
Feat(#1873): return 'unknown' for application hostname strategies (#1889)
The hostname strategy will not work correctly with the playground because it depends on external state. In its constructor, it tries to query the environment or use the os.hostname function to determine what its current hostname is. This means that no matter what the user does in the playground, they can’t affect the results of this strategy. It’s also unlikely that it will be true. And if it is, it probably won’t be true for their clients.

In theory, we could accept a hostname property on the Unleash context and use the provided hostname in the address. However, I’m afraid that it’ll make users think that they can impact the hostname strategy by setting the property on their context, when that doesn’t do anything outside of the playground. It would also make the playground evaluate things differently from a regular SDK and I’m not sure that that’s something we want.

Instead, this change to the API makes the feature evaluate to 'unknown' or `false` (depending on constraints).
2022-08-05 11:09:55 +02:00
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
olav
666ca1935c
fix: add missing client variant schema fields (#1880)
* refactor: format file

* fix: use correct variants schema reference

* fix: add missing client variant schema fields
2022-08-02 13:06:10 +02:00
Christopher Kolstad
05efe1414e
fix: sortOrder updates needs to be async
Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>
2022-07-28 17:31:46 +02:00
Christopher Kolstad
482754e9f5
fix: Remove unneeded ts-expect-error now that types in knex are in sync (#1866)
* fix: Remove unneeded ts-expect-error now that types in knex are in sync
2022-07-28 10:34:19 +02:00
Thomas Heartman
6afc0a6954
fix: fix broken OpenAPI spec (#1846)
* Wip: fix openapi spec

* Feat: add openapi enforcer for enforcing the generated schema

* Chore: Allow the example keyword in params

* Feat: add validator tests and fix some errors

* Use @apidevtools/swagger-parser for schema validation

* Wip: refactor tests for updated schema name

* Feat: update request params creation method

* Feat: add query params to state

* Refactor: move mapping test into separate function

* Refactor: rename request-parameters -> query-parameters

* Refactor: expose only finished query parameters

* Wip: fixup param types

* Refactor: remove unused types

* Chore: rename and cleanup

* Chore: cleanup

* Fix: Update snapshot

* Fix: use ?? Instead of paramToBool to get defaults

* Wip: generate query param object type from openapi params list

* Wip: use generated types for export query params

* Revert "Fix: use ?? Instead of paramToBool to get defaults"

This reverts commit 842567500b.

Because we accept bools, strings, and numbers, this is the only way to
do it.

* Chore: update and pin json-schema-to-ts

* Fix: use `&` to merge types

* Update snapshot

* Chore: rename export-parameters-schema -> export-query-parameters

When it ends in `schema`, the tests expect it to be included in the
openapi index file.
2022-07-28 09:19:58 +02:00
Christopher Kolstad
ee295ee765
fix: Make additionalProperties true (#1861)
* fix: Make additionalProperties true
2022-07-27 09:02:02 +02:00
Tymoteusz Czech
25fdefc4d1
Strategy sort order endpoint (#1855)
* strategy sort order endpoint

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>

* feat: add e2e test for happy path

* add tests to features strategies order

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>

* feat: add tests for sort-order

* fix: update snapshot

* fix: lint

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-07-26 14:16:30 +02:00
sjaanus
5f8b88aa0b
Grouping access endpoing (#1858)
* Grouping access endpoing

* Add username
2022-07-26 11:39:55 +00:00
sjaanus
b9c95c5272
Fix full outer joins to left joins (#1856) 2022-07-26 08:02:28 +00:00
sjaanus
33ed72716f
Implement group access edit for project (#1854) 2022-07-25 10:11:16 +00:00
Christopher Kolstad
2c9f4408bc
task: update health endpoint to only say if express is ready (#1847) 2022-07-22 11:47:58 +02:00
Christopher Kolstad
5bacc7ba36
task: add sdk version metric (#1828)
* task: add sdk version metric
2022-07-22 09:00:22 +00:00
sighphyre
5806b6748f
Feat/grouping (#1845)
* Implement user grouping feature for permissions

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
Co-authored-by: Jaanus Sellin <sellinjaanus@gmail.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-07-21 16:23:56 +02:00
Christopher Kolstad
09fa031e0f
task: Add events for setting-service (#1814)
* task: Add events for setting-service
2022-07-21 15:40:31 +02:00
Thomas Heartman
012da8469f
feat: add all feature variants to the playground payload (#1835)
* Chore: extract variant creation arbitrary.

* Feat: add "variants" as a required property on playground response

* Wip: fix up some schema generation

* Fix remaining openapi schemas

* Fix: add missing variants property

* Feat: test for variants

* Feat: add `variants` property to playground response

* Chore: update openapi snapshot
2022-07-20 08:54:34 +02:00
Thomas Heartman
05c390e893
fix: Playground variants don't show correctly (#1829)
* Refactor: use the `ALL` constant for tests

* Fix: context is not passed to `getVariant` call

This commit fixes a bug wherein a toggle with variants would show as
enabled but without variants. This was because the `getVariant` call
didn't receive the provided context as an argument.
2022-07-18 13:15:27 +02:00
sellinjaanus
9e7f05fb35
Fix error and add test (#1825)
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-07-18 07:30:04 +00:00
sellinjaanus
7da461cc9f
Fix full outer join bug (#1820)
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-07-14 13:11:22 +02:00
Christopher Kolstad
8848610e1e
fix: addon filtering supports wildcards
Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>
2022-07-12 15:53:57 +02:00
Christopher Kolstad
783a039980
fix: add projects and environments field to addon select 2022-07-12 14:32:24 +02:00
Christopher Kolstad
e3c9eaae3a
feat: support filtering on project and environment fields for events (#1801)
* feat: support filtering on project and environment fields for events

Co-authored-by: Nuno Góis <github@nunogois.com>
2022-07-12 12:13:25 +00:00
Thomas Heartman
847119f964
feat: add playground API post endpoint (#1791)
* Chore: add unleash-client dependency

* Feat: add openapi specs for basic sdk contexts and playground reqs

* Feat: add openapi spec for response

* Feat: add openAPI entry for playground endpoint

* Fix: remove required 'projects' property that doesn't exist

* Refactor: add test placeholders for playground api

* Chore: improve openAPI description for playground request

* Refactor: align example project names

* Fix: update openapi snapshot

* Fix: summary -> description; example -> examples

* Feat: add fast-check and stub out one test.

The test doesn't work yet.

* Feat: add test and generator for sdk context schema

* Feat: add generators and tests for all new schemas

* Feat: test that the same input is returned exactly

* Feat: add more tests and more schemas

* Refactor: clean up tests some

* Refactor: simplify url friendliness check

* Refactor: fix types for playground request schema generator

* Feat: add bad request test

* Fix: make parameters the correct shape in generator

* Feat: scaffold out tests for service and endpoint

Liberal use of @ts-expect-error

* Fix: update snapshot with new model

* Add missing appName

* wip: stub out some extra tests

* Feat: model strategies for testing

* Feat: model variant payloads better

* Refactor: input params for function

* Refactor: use email address for user id generation

* Chore: update comment

* Wip: start stubbing out e2e tests

* Refactor: move tests requiring db to e2e file

* Fix: make e2e tests run as expected

* Fix: make toggle generator test work as expected

* Fix: increase timeout for long-running e2e test

* Wip: map toggles test

* Wip: test movement and cleanup

* Refactor: remove `AllowedStrings` in favor of typeof X[number]

* Wip: add e2e tests for the service

* Wip: tests in progress

* Feat: return fuller variant value

* Wip: delete redundant test.

Both those tests were testing versions of the same thing, so let's
delete one of them

* Feat: update openAPI snapshot

* Feat: hook up the playground service

* Feat: fix test cases for e2e api

* Refactor: get rid of _one_ 'as unknown as x' cast

* Fix: wait for the client to be ready before we pass it back

* Fix: weights go to 1000!

* Fix: fix some test assertions, add one more test to be sure

* Wip: add some test parameters to hopefully avoid timeouts

* Fix: don't init the client if there are no toggles

If you don't provide it with any toggles to bootstrap, then the client
will never be ready. This avoids that.

This adds two ways around it because we'll probably get away with a
bit less computation if we don't even try to initialize it. However,
we also don't want anyone else to make this mistake.

* Chore: modify test params

* Feat: use the type system to avoid empty lists for initialization

* Refactor: make tests simpler

* Feat: test basic context values

* Feat: test dynamic context values

* Fix: make custom context field test more reliable

* Feat: use unique arrays for toggles

* Feat: make `appName` required in context

* Fix: sdk context schema arbitrary: make appName at least 1 char long

* Fix: add a minimum length on appName in the context schema

* Fix: fix tests that fail due to new requirements

* Fix: update a test: remove variant mapping testing

* Fix: fix remaining tests

* Feat: rename response.toggles -> response.features

* Refactor: avoid single-letter predicate variables

* Refactor: extract offlineclient into its own file

* Refactor: move arbitraries into separate file

* Refactor: move playground requests into util function

* Fix: remove duplicate declaration of urlFriendlyString

* Chore: update comment

* Refactor: align on arbitrary generator naming

* Feat: Export single strategy arbitrary
2022-07-12 13:01:10 +02:00
sellinjaanus
04fb065df4
Added missing archivedAt to featureSchema (#1779)
* Added missing archivedAt to featureSchema

* Added archivedAt to feature toggle.
Added archived_at to db

* Add test

* Add test

* Bug fix

* Bug fix

* update archivedAt to date-time

* Code refactoring done

* Conver to static and remove unused methods

* Add tests

* Fixes

* Fix

* Removed docker file from linting

* Fix segment test

* Fix failing test

* Make fixes

Co-authored-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: andreas-unleash <104830839+andreas-unleash@users.noreply.github.com>
2022-07-01 11:51:26 +00:00
Thomas Heartman
1a5749ca08
Refactor: move openapi utils into /util directory (#1777)
* Refactor: move openapi utils into /util directory

* Refactor: move utils test into `util` directory

* Refactor: don't expose standard responses tied to status codes

* Feat: update empty response description + make it const

* Chore: update snapshot with new response descriptions
2022-07-01 08:06:33 +02:00
olav
98c7b915c9
refactor: fix empty response usage (#1783)
* refactor: fix empty response usage

* refactor: move emptyResponse into standard-responses.ts
2022-06-30 14:48:39 +02:00
Tymoteusz Czech
2729999bed
Feat: OpenAPI controller - Bootstrap UI (#1773)
* rename bootstrap ui controller

* sort openapi schema imports

* add bootstrap ui json schema

* test bootstrap ui schema

* openapi bootstrap ui route

* fix: bootstrap ui schema type

* bootstrap ui e2e test

* simplify bootstrap-ui testing mock

* fix: update after review
2022-06-30 12:21:40 +00:00
andreas-unleash
a607dea284
OAS for client-api metrics.ts (#1753)
* OAS for client-api metrics.ts

* Fix PR comments

* Fix PR comments

* Fix test

* Renamed and synced with proxy

* Renamed and synced with proxy

* Renamed and synced with proxy

* add tests

* Update python.md

Revert doc

* added 400 response, more tests

* PR comment

* PR comment
2022-06-30 13:27:12 +03:00
andreas-unleash
e875e67d24
open api implementation - client features controller (#1745)
* open api implementation - client features controller

* open api implementation - client features controller

* bug fix

* test fix

* PR comments

* OAS for client-api metrics.ts

* Refactoring

* Refactoring

* bug fix

* fix PR comments

* PR comment

* PR comment
2022-06-30 12:54:14 +03:00
olav
b67aca8fbf
fix: rename duplicate operation IDs (#1778) 2022-06-30 10:51:26 +02:00
Thomas Heartman
4dec126199
feat: add OpenAPI spec to events controller. (#1754)
* Feat: add initial event schema

* Feat: add events-schema plus tests

* Feat(broken): add openapi validation to getEvents endpoint

* Add schema to basic events endpoint

* Feat: Add openapi for feature events

* Fix: fix recursive schema inclusion

* Feat: add test for recursive function

* Fix: make nullable fields nullable

* Fix: remove `ADMIN` permission for toggle events.

* fix: add new schemas to the snapshot

* Fix: remove recursive schema inclusion

* Feat: test feature events schema

* Fix: add correct permissions for feature events endpoint.

* Refactor: rename "name" to "featureName" for clearer docs

* Fix: Add missing "version" field to feature events

* Feat: add descriptions and extra responses to events endpoints.

* Fix: update openapi snapshot

* Simplify standard responses function

* Refactor: move endpoint descriptions into own file.

* Refactor: simplify type signature.

* Feat: specify type of data and preData properties to object

* Fix: update snapshot

* Refactor: move standard-responses into /util/ directory.
2022-06-30 08:12:34 +00:00