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

246 Commits

Author SHA1 Message Date
Ivar Conradi Østhus
f3e8f723a2
Feat/exp flag loader (#1961)
* fix: remove unused exp flag

* fix: remove unused flag

* fix: add support for external flag resolver

* fix: rename flagsresolver to flagresolver

* fix: disable external flag resolver

* fix: refactor a bit

* fix: stop using unleash in server-dev

* fix: remove userGroups flag

* fix: revert bumping frontend
2022-08-26 08:22:42 +02:00
olav
634e188f73
fix: clean up proxy clients on API key deletion (#1950) 2022-08-22 15:02:39 +02:00
olav
0d293929f5
feat: add CORS support to the proxy endpoints (#1936)
* feat: add CORS support to the proxy endpoints

* refactor: remove unused development mode CORS support
2022-08-19 08:09:44 +02:00
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
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
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
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
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
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
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
Christopher Kolstad
2c9f4408bc
task: update health endpoint to only say if express is ready (#1847) 2022-07-22 11:47:58 +02: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
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
andreas-unleash
64082440d4
OAS for client-metrics controller (#1739)
* OAS for client-metrics controller

* bug and tests

* update snapshot

* update snapshot

* update snapshot

* bug fix

* fix PR comments

* refactoring re PR comments

* re order routes

* remove grouped-client-metrics-schema.ts

* remove grouped-client-metrics-schema.ts

* updated response

* updated snapshot

* PR comments

* PR comments

* Added tests

* Added tests

* fix

* fix

* fix
2022-06-27 11:17:44 +03:00
olav
5fff523670
refactor: add schemas to client application registration (#1746) 2022-06-24 15:29:27 +02:00
Nuno Góis
a792594e98
refactor: add OpenAPI schema to simple-password-provider controller (#1734)
* refactor: add OpenAPI schema to simple-password-provider controller

* finish implementation after merge

* refactor: address PR comments
2022-06-23 08:40:25 +01:00
olav
ac3f076a31
refactor: add schemas to strategy controller (#1744)
* refactor: avoid duplicate feature strategy operationIds

* refactor: fix flaky feature tests

* refactor: remove duplicate controller error handling

* refactor: unify feature strategy schemas

* refactor: add schemas to strategy controller
2022-06-23 08:10:20 +02:00
olav
ab75d4085e
refactor: add schemas to user admin controller (#1692)
* refactor: add schemas to user admin controller

* refactor: remove unused SessionService

* refactor: fix search query type confusion

* refactor: add schemas to user controller (#1693)

* refactor: add schemas to user controller

* refactor: fix getAllUserSplashes method name

* refactor: name and email should not be required on create

* refactor: only some user fields may be updated

* refactor: should not require any fields on user update  (#1730)

* refactor: send 400 instead of 500 on missing username and email

* refactor: should not require any fields for user update

* refactor: note that earlier versions required name or email

* refactor: merge roleDescriptionSchema and roleSchema
2022-06-22 14:55:43 +02:00
sellinjaanus
cecca59f65
Task/open api reset password (#1740)
* task: add openapi for reset password

* fix: add respondWithValidation and remove email from tests

* fix: change tags to other
2022-06-22 14:31:41 +03:00
andreas-unleash
66452e2860
open-api addon controller (#1721)
* open-api addon controller

* bug fixes

* bug fixes

* resolve merge conflict

* bug fix

* bug fix

* bug fix

* PR comments

* PR comments

* Resolve merge conflics

* Resolve merge conflics

* bug and tests
2022-06-22 13:49:18 +03:00
Christopher Kolstad
18c720f4e9
Task/open api state (#1738)
* task: add open api to import/export
2022-06-22 09:09:49 +02:00
Christopher Kolstad
32399291e0
task: add OpenApi spec to metrics route (#1725)
* task: add OpenApi spec to metrics route
2022-06-21 09:12:40 +02:00
Christopher Kolstad
1821af8fe7
task: add openapi for tags (#1724)
* task: add openapi for tags
2022-06-21 08:23:30 +02:00
Nuno Góis
123991d28f
refactor: add OpenAPI schema to health-check controller (#1732)
* refactor: add OpenAPI schema to health-check controller

* refactor: address PR comments

* add type to health-check-schema

* fix: update snap
2022-06-20 11:22:41 +01:00
Nuno Góis
2354656632
refactor: add OpenAPI schema to api-token controller (#1716)
* refactor: add OpenAPI schema to api-token controller

* refactor: address PR comments

* fix: status codes on environment toggling

* fix tests

* refactor: address PR comments

* refactor: expiresAtSchema -> update-api-token-schema
2022-06-17 20:35:26 +01:00
Nuno Góis
525fce3e86
refactor: add OpenAPI schema to context controller (#1711)
* refactor: add OpenAPI schema to context controller

* Update src/lib/routes/admin-api/context.ts

Co-authored-by: olav <mail@olav.io>

* address PR comments, misc fixes and improvements

* refactor: address PR comments

* add createdAt to test

* fix: reverted upsert schema after discussion

Co-authored-by: olav <mail@olav.io>
2022-06-17 10:11:55 +01:00
olav
28ecb158a9
refactor: add schemas to feedback controller (#1698)
* refactor: remove previous getProjects route

* refactor: add schemas to feedback controller
2022-06-17 08:15:56 +02:00
Christopher Kolstad
780bb06dba
task: add open-api for tag-types (#1700)
* task: add open-api for tag-types
2022-06-14 09:06:41 +02:00
olav
7ba8cd05eb
fix: do not require Content-Type for requests without body (#1707)
* fix: do not require Content-Type for requests without body

* fix: require Content-Type for feature update requests
2022-06-14 08:16:08 +02:00
olav
47a719238d
refactor: fix duplicate operationIds (#1701) 2022-06-10 15:11:41 +02:00
olav
1264f8cb13
refactor: add schemas to splash controller (#1697) 2022-06-10 15:11:07 +02:00
olav
adface17c7
refactor: add OpenAPI schema to environments controller (#1682)
* refactor: normalize controller file names

* refactor: throw invalid responses in dev mode

* refactor: add OpenAPI schema to environments controller

* refactor: improve JSON schema prop removal code

* refactor: fix empty response specs
2022-06-10 10:04:56 +02:00
olav
d7c450abf8
refactor: remove unused my-sessions endpoint (#1691) 2022-06-09 14:48:03 +02:00
olav
0f11a33e3a
refactor: remove active-sessions endpoint (#1690) 2022-06-09 13:19:20 +02:00
olav
138300ab22
refactor: add OpenAPI schema to feature types controller (#1684)
* refactor: fix feature types id type

* refactor: fix error-hiding Controller imports

* refactor: add OpenAPI schema to feature types controller
2022-06-09 13:17:13 +02:00
olav
1ed8dd0f0d
refactor: add OpenAPI schema to constraints controller (#1683)
* refactor: add OpenAPI schema to constraints controller

* refactor: add more schema tests
2022-06-09 10:35:39 +02:00
olav
04c107a26e
refactor: add OpenAPI schemas to more controllers (#1680) 2022-06-08 15:31:34 +02:00
olav
09a6b578bf
refactor: add OpenAPI schema to UI config controller (#1681) 2022-06-08 14:57:39 +02:00
Christopher Kolstad
37211491e7
feat: default to memoizing client features (#1674) 2022-06-08 09:43:37 +02:00
olav
13ef025fab
refactor: add soft response schema validation (#1657)
* refactor: remove most schema refs

* refactor: generalize request/response schemas

* refactor: simplify schema date formats

* refactor: add soft response schema validation

* refactor: fix emptySchema definition

* refactor: update json-schema-to-ts and use refs
2022-06-08 08:01:14 +02:00
olav
ee35c7ad74
refactor: replace ts-ignore with ts-expect-error (#1675)
* refactor: replace ts-ignore with ts-expect-error

* refactor: remove unused ts-expect-errors
2022-06-07 11:49:17 +02:00
olav
9aa1f39add
refactor: always accept any content type for GET reqs (#1672) 2022-06-07 09:32:18 +02:00
Christopher Kolstad
7895002602
feat: add OpenApi spec to feature variants (#1659)
* feat: add OpenApi spec to feature variants
2022-06-03 13:16:59 +02:00
Ivar Conradi Østhus
3359dd204d
feat: add option to disable 'Clear-Site-Data' header on logout (#1645) 2022-06-03 11:50:58 +02:00
olav
7e3f0329ab
refactor: avoid inlining segments for supported clients (#1640)
* refactor: add semver lib types

* refactor: avoid inlining segments for supported clients

* refactor: fix FeatureController tests

* refactor: use spec version instead of client version

* refactor: improve header validation errors
2022-06-02 14:07:46 +02:00
olav
224b9cb229
refactor: move segment limits to env vars (#1642)
* refactor: improve env var helpers

* refactor: remove unused segments client API

* refactor: remove experimental segment flags

* refactor: move segment limits to env vars

* refactor: add segment limits to UIConfig response

* refactor: fix type name casing
2022-06-02 10:44:45 +02:00
Ivar Conradi Østhus
ddb7b075a8
fix: flag for anonymising user search 2022-05-31 21:51:49 +02:00
Ivar Conradi Østhus
34b2058faa
fix: add flag to annomise event log 2022-05-30 21:01:46 +02:00
sighphyre
0c1213ff81
feat: Add support for global segments (#1577)
feat: Add support for global segments
2022-05-30 09:10:20 +02:00
olav
59060ed3ea
refactor: improve OpenAPI refs (#1620)
* refactor: simplify FeatureEnvironmentSchema name

* refactor: format schema files

* fix: pass nested schemas to FromSchema

* refactor: remove ref order note

* refactor: fix overly strict required fields

* refactor: clean up mapper names and paths

* refactor: replace mappers with optional fields
2022-05-24 08:37:35 +02:00
olav
a8d34d6268
fix: the replaceGroupId field should be optional (#1608) 2022-05-20 11:07:30 +02:00
andreas-unleash
1a27bffe4d
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* bug fix

* bug fix

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* added emptyResponse, patch feature operation schemas and request

* added emptyResponse, patch feature operation schemas and request

* patch strategy

* patch strategy

* update strategy

* update strategy

* fix pr comment

* fix pr comments

* improvements

* added operationId to schema for better generation

* fix pr comment

* fix pr comment

* fix pr comment

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* Update response types to use inferred types

* Update addTag response status to 201

* refactor: move schema ref destructuring into createSchemaObject

* made serialize date handle deep objects

* made serialize date handle deep objects

* add `name` to IFeatureStrategy nad fix tests

* fix pr comments

* fix pr comments

* Add types to IAuthRequest

* Sync StrategySchema for FE and BE - into the rabbit hole

* Sync model with OAS spec

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* bug fix

* bug fix

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* added emptyResponse, patch feature operation schemas and request

* added emptyResponse, patch feature operation schemas and request

* patch strategy

* patch strategy

* update strategy

* update strategy

* fix pr comment

* fix pr comments

* improvements

* added operationId to schema for better generation

* fix pr comment

* fix pr comment

* fix pr comment

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* Update response types to use inferred types

* Update addTag response status to 201

* refactor: move schema ref destructuring into createSchemaObject

* made serialize date handle deep objects

* made serialize date handle deep objects

* add `name` to IFeatureStrategy nad fix tests

* fix pr comments

* fix pr comments

* Add types to IAuthRequest

* Sync StrategySchema for FE and BE - into the rabbit hole

* Sync model with OAS spec

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* bug fix

* bug fix

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* added emptyResponse, patch feature operation schemas and request

* added emptyResponse, patch feature operation schemas and request

* patch strategy

* patch strategy

* update strategy

* update strategy

* fix pr comment

* fix pr comments

* improvements

* added operationId to schema for better generation

* fix pr comment

* fix pr comment

* fix pr comment

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* Update response types to use inferred types

* Update addTag response status to 201

* refactor: move schema ref destructuring into createSchemaObject

* made serialize date handle deep objects

* made serialize date handle deep objects

* add `name` to IFeatureStrategy nad fix tests

* fix pr comments

* fix pr comments

* Add types to IAuthRequest

* Sync StrategySchema for FE and BE - into the rabbit hole

* Sync model with OAS spec

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)

* bug fix

* bug fix

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* fix merge conflicts, some refactoring

* added emptyResponse, patch feature operation schemas and request

* added emptyResponse, patch feature operation schemas and request

* patch strategy

* patch strategy

* update strategy

* update strategy

* fix pr comment

* fix pr comments

* improvements

* added operationId to schema for better generation

* fix pr comment

* fix pr comment

* fix pr comment

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* improvements to generated and dynamic types

* Update response types to use inferred types

* Update addTag response status to 201

* refactor: move schema ref destructuring into createSchemaObject

* made serialize date handle deep objects

* made serialize date handle deep objects

* add `name` to IFeatureStrategy nad fix tests

* fix pr comments

* fix pr comments

* Add types to IAuthRequest

* Sync StrategySchema for FE and BE - into the rabbit hole

* Sync model with OAS spec

* revert

* revert

* revert

* revert

* revert

* mapper

* revert

* revert

* revert

* remove serialize-dates.ts

* remove serialize-dates.ts

* remove serialize-dates.ts

* remove serialize-dates.ts

* remove serialize-dates.ts

* revert

* revert

* add mappers

* add mappers

* fix pr comments

* ignore report.json

* ignore report.json

* Route permission required

Co-authored-by: olav <mail@olav.io>
2022-05-18 16:17:09 +03:00
olav
ac90a3b1c7
fix: remove trailing slash from OpenAPI route (#1564) 2022-05-05 11:45:23 +02:00
olav
56615e91f0
fix: validate the type and length of parameter values (#1559)
* refactor: coerce primitive types in OpenAPI requests

* refactor: avoid broken array args to serializeDates

* refactor: avoid some spec refs to improve generated types

* refactor: remove debug logging

* refactor: fix IExpressOpenApi interface name prefix

* refactor: ensure that parameter values are strings

* refactor: test that parameter values are coerced to strings
2022-05-04 15:16:18 +02:00
Nuno Góis
7e938a21b4
feat: show archived toggles on a project level (#1555)
* feat: show archived toggles on a project level

* refactor: split behaviour in 2 separate routes and methods for clarity

* add e2e test
2022-05-04 07:45:29 +01:00
olav
36922d156d
refactor: fix a few eslint module boundary type overrides (#1542) 2022-04-28 12:40:38 +02:00
olav
d0724afdf5
feat: add READ_API_TOKEN permission (#1528)
* refactor: extract accessibleTokens fn

* feat: add READ_API_TOKEN permission
2022-04-26 10:24:34 +02:00
olav
fdebeef929
feat: add OpenAPI validation to a few endpoints (#1409)
* feat: add OpenAPI validation to a few endpoints (2)

* refactor: use package version as the OpenAPI version

* refactor: keep the existing OpenAPI page for now

* refactor: add snapshots tests for the OpenAPI output

* refactor: validate Content-Type by default

* refactor: update vulnerable deps

* refactor: fix documentation URL to match schema

* refactor: improve external type declaration

* refactor: remove unused package resolutions

* refactor: try express-openapi fork

* Update package.json

* Update src/lib/services/openapi-service.ts

* Update src/lib/types/openapi.d.ts

* Update src/lib/types/openapi.d.ts

Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
2022-04-25 14:17:59 +02:00
Ivar Conradi Østhus
14694fdf04
fix: allow missing instanceId in client metrics (#1522)
* fix: allow missing instanceId in client metrics

* fix: remove ts-ignore
2022-04-22 13:52:27 +02:00
olav
e38f7cf7c2
feat: add context value descriptions (#1496)
* feat: add context value descriptions

* refactor: upcase SQL keywords

* refactor: allow blank descriptions
2022-04-19 08:40:07 +02:00
sighphyre
e889d8e29c feat: Implement multi token support for client tokens
This adds support for multi project tokens to be created. Backward compatibility is handled at 3 different layers here:

- The API is made backwards compatible though a permissive data type that accepts either a project?: string or projects?: string[] property, validation is done through JOI here, which ensures that projects and project are not set together. In the case of neither, this defaults to the previous default of ALL_PROJECTS
- The service layer method to handle adding tokens has been made tolerant to either of the above case and has been deprecated, a new method supporting only the new structure of using projects has been added
- Existing compatibility for consumers of Unleash as a library should not be affected either, the ApiUser constructor is now tolerant to the the first input and will internally map to the new cleaned structure
2022-04-06 08:11:41 +02:00
olav
cf06b562f9
fix: allow instance ID to be empty for metrics (#1471) 2022-04-01 10:34:22 +02:00
olav
66d9d7a6d2
feat: add segments (#1426)
* refactor: fix missing tsconfig path in .eslintrc

* refactor: require contextName and operator

* refactor: fix crash on missing feature strategies

* feat: add segments schema

* feat: add segments client API

* feat: add segments permissions

* refactor: fail migration if things exist

* refactor: remove strategy IDs from responses

* refactor: allow empty description

* refactor: add segment import/export

* refactor: add perf scripts

* refactor: add get segment fn

* refactor: move constraint validation endpoint

* refactor: use a separate id for segment updates

* refactor: use PERF_AUTH_KEY for artillery

* refactor: adjust segment seed size

* refactor: add missing event data await

* refactor: improve method order

* refactor: remove request body limit override
2022-03-29 14:59:14 +02:00
Fredrik Strand Oseberg
6f075e4d1c
Feat/new constraint operators (#1397)
* feat: add migration for currentTime context field

* feat: add tests for number validator

* feat: add validation fields for constraint

* feat: add validation for semver, date and legalvalues

* fix: import paths

* fix: only allow specified operators

* fix: add operator test

* fix: reset db

* fix: remove unused import

* fix: set semver as dependency
2022-03-04 17:29:42 +01:00
Youssef
d4521a1c0c fix: changeRole to assign roles without existing members
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2022-03-03 14:33:32 +01:00
Christopher Kolstad
fc4d95ff5b
fix: configure user endpoint when AuthType is NONE (#1403)
Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-03-01 10:52:22 +01:00
olav
eb08ed0b55
refactor: add an hoursBack query param to the raw metrics endpoint (#1373)
* refactor: add an hoursBack query param to the raw metrics endpoint

* refactor: explicitly return undefined

* refactor: make parseHoursBackQueryParam non-static

* refactor: add test for hoursBack query param

* refactor: improve arg name

* refactor: add a 1 hour test case
2022-02-17 10:47:05 +01:00
Ivar Conradi Østhus
1cad01b97e
fix: welcome-email should not include password-link when disabled (#1302) 2022-01-28 12:50:35 +01:00
Ivar Conradi Østhus
332b94d209
fix: convert simple-password-provider.test.js to ts 2022-01-26 22:44:26 +01:00
Ivar Conradi Østhus
a50d0e2a21
fix: improve API error-handling (#1301)
Unleash is an API and it would simplyfy a lot of the specific
errors could carry the expected HTTP status code for this error.
This would eliminate the need for a gigantic switch/case in the
handle-errors function.
2022-01-26 13:45:22 +01:00
Fredrik Strand Oseberg
8ecacfb89c
Fix/validate context (#1282)
* fix: add context guards

* fix: change error message

* fix: remove console log
2022-01-21 12:02:05 +01:00
Fredrik Strand Oseberg
1989c53fb0
fix: enable tags and validate for legacy api (#1264)
* fix: enable tags and validate for legacy api

* fix: move delete tag

* fix: test name

* fix: move /api/admin/features
2022-01-14 11:16:17 +01:00
sighphyre
0c78980502
feat: custom project roles (#1220)
* wip: environment for permissions

* fix: add migration for roles

* fix: connect environment with access service

* feat: add tests

* chore: Implement scaffolding for new rbac

* fix: add fake store

* feat: Add api endpoints for roles and permissions list

* feat: Add ability to provide permissions when creating a role and rename environmentName to name in the list permissions datastructure

* fix: Make project roles resolve correctly against new environments permissions structure

* fix: Patch migration to also populate permission names

* fix: Make permissions actually work with new environments

* fix: Add back to get permissions working for editor role

* fix: Removed ability to set role type through api during creation - it's now always custom

* feat: Return permissions on get role endpoint

* feat: Add in support for updating roles

* fix: Get a bunch of tests working and delete a few that make no sense anymore

* chore: A few small cleanups - remove logging and restore default on dev server config

* chore: Refactor role/access stores into more logical domains

* feat: Add in validation for roles

* feat: Patch db migration to handle old stucture

* fix: migration for project roles

* fix: patch a few broken tests

* fix: add permissions to editor

* fix: update test name

* fix: update user permission mapping

* fix: create new user

* fix: update root role test

* fix: update tests

* feat: Validation now works when updating a role

* fix: Add in very barebones down migration for rbac so that tests work

* fix: Improve responses from role resolution - getting a non existant role will throw a NotFound error

* fix: remove unused permissions

* fix: add test for connecting roles and deleting project

* fix: add test for adding a project member with a custom role

* fix: add test for changing user role

* fix: add guard for deleting role if the role is in use

* fix: alter migration

* chore: Minor code cleanups

* chore: Small code cleanups

* chore: More minor cleanups of code

* chore: Trim some dead code to make the linter happy

* feat: Schema validation for roles

* fix: setup permission for variant

* fix: remove unused import

* feat: Add cascading delete for role_permissions when deleting a role

* feat: add configuration option for disabling legacy api

* chore: update frontend to beta version

* 4.6.0-beta.0

* fix: export default project constant

* fix: update snapshot

* fix: module pattern ../../lib

* fix: move DEFAULT_PROJECT to types

* fix: remove debug logging

* fix: remove debug log state

* fix: Change permission descriptions

* fix: roles should have unique name

* fix: root roles should be connected to the default project

* fix: typo in role-schema.ts

* fix: Role permission empty string for non environment type

* feat: new permission for moving project

* fix: add event for changeProject

* fix: Removing a user from a project will now check to see if that project has an owner, rather than checking if any project has an owner

* fix: add tests for move project

* fix: Add in missing create/delete tag permissions

* fix: Removed duplicate impl caused by multiple good samaritans putting it back in!

* fix: Trim out add tag permissions, for now at least

* chore: Trim out new add and delete tag permissions - we're going with update feature instead

* chore: update frontend

* 4.6.0-beta.1

* feat: Prevent editing of built in roles

* fix: Patch an issue where permissions for variants/environments didn't match the front end

* fix: lint

Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-01-13 11:14:17 +01:00
Ivar Conradi Østhus
26b7da8b5c
feat: add support for cdnPrefix for static assets (#1191) 2022-01-06 10:31:00 +01:00
Ivar Conradi Østhus
2b59a4219a
fix: Should not remove variants when updating feature toggle metadata (#1234) 2022-01-06 10:23:52 +01:00
Christopher Kolstad
994db02f84
fix: Adds feature-variant-updated event. (#1189)
This triggers when we update or overwrite variants, and will include the
previous variants and the new variants.

Co-authored-by: Ivar Østhus <ivarconr@gmail.com>
2021-12-16 11:07:19 +01:00
Ivar Conradi Østhus
bf1223e07d fix: rename services 2021-12-10 09:31:54 +01:00
Ivar Conradi Østhus
9f13b801eb fix: rename metrics-service to client-instance service 2021-12-10 09:31:54 +01:00
Ivar Conradi Østhus
4a9939ccb1 feat: remove old metrics service 2021-12-10 09:31:54 +01:00
Fredrik Strand Oseberg
98d64fc1e4
fix: open validate endpoint (#1162)
* fix: open validate endpoint

* fix: set validate permission to none
2021-12-06 15:19:25 +01:00
Ivar Conradi Østhus
3c550f157a
fix: always require permission for POST, PATCH, PUT, DELETE (#1152) 2021-12-03 12:46:50 +01:00
Ivar Conradi Østhus
784ddf8fb3
fix: cleanup old user permissions (#1150) 2021-12-01 22:10:09 +01:00
Ivar Conradi Østhus
eb8265922d
Fix/enable standard environments (#1134) 2021-11-26 15:31:36 +01:00
Christopher Kolstad
5cdb3f665a
task: Ban changes to variants through feature (#1130)
* task: Ban changes to variants through feature

After adding the new `/variants` endpoint for features we now have a way
to access control adding/modifying variants, so the /:featureName
endpoint should no longer allow editing/adding variants.

This removes variants as a known field from the featureMetadata schema
and tells joi to stripUnknown, thus making sure we never include
variants in the initial creation or future update calls.

For the old features v1 API we allow it to declare that it has already
validated the data coming with its own schema, so we should use the data
we get from it. Thus keeping the old v1 functionality intact

Co-authored-by: Simon Hornby <simon@getunleash.ai>
2021-11-25 14:53:58 +01:00
Christopher Kolstad
72092e4a1c
fix: make new variant api validate name uniqueness (#1126) 2021-11-24 14:22:28 +01:00
Christopher Kolstad
6c6001619c
Feat/variant api (#1119)
Add a new .../:feature/variants API

This adds
- `GET /api/admin/projects/:projectId/features/:featureName/variants` which returns 
```json
{ version: '1', variants: IVariant[] }
```
- `PATCH /api/admin/projects/:projectId/features/:featureName/variants` which accepts a json patch set and updates the feature's variants field and then returns 
```json
{ version: '1', variants: IVariant[] }
```
- `PUT /api/admin/projects/:projectId/features/:featureName/variants`
 which accepts a IVariant[] and overwrites the current variants list for the feature defined in :featureName and returns
```json
{ version: '1', variants: IVariant[] }

- This also makes sure the total weight of all variants is == 1000
- Validates that there is at least 1 'variable' variant if there are variants
- Validates that 'fix' variants total weight can't exceed 1000
- Adds tests for all these invariants.


Co-authored-by: Simon Hornby <simon@getunleash.ai>
2021-11-24 13:08:04 +01:00
Fredrik Strand Oseberg
c369b77b24
Merge branch 'master' into feat/splash 2021-11-12 13:19:36 +01:00
Ivar Conradi Østhus
d8478dd928
feat: clean up events (#1089)
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2021-11-12 13:15:51 +01:00
Youssef
0199d1f211 fix: remove req.body from the splash object when update 2021-11-12 12:44:33 +01:00
Youssef
c4e56aae09 fix: remove record splash and update sql query in add-splash-entry 2021-11-12 10:49:09 +01:00
Youssef
c4da3e89c5 fix: styling 2021-11-09 20:55:23 +01:00
Youssef
96f2514fc5 send splash data in the user object 2021-11-09 20:39:13 +01:00