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

537 Commits

Author SHA1 Message Date
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
olav
b2b0958573
fix: ensure that param values from /api/admin/features are strings (#1761)
* refactor: improve parameter value string casting

* fix: ensure that param values from /api/admin/features are strings
2022-06-29 10:11:34 +02:00
olav
88dc83ed6f
refactor: log event type when an event can't be saved (#1763)
* refactor: log event type when an event can't be saved

* Update src/lib/db/event-store.ts

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-06-28 16:13:25 +02:00
Nuno Góis
b49654c3f0
fix: copy feature variants (#1750)
* fix: copy feature variants

* add e2e test for cloning with variants
2022-06-28 07:54:09 +01:00
Tymoteusz Czech
f96b4525a5
fix: tag validation duplicate message (#1756) 2022-06-28 08:04:43 +02:00
Christopher Kolstad
54d28471f7
fix: openapi spec should only include base path once (#1755)
* fix: openapi spec should only include base path once
2022-06-27 15:39:08 +02: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
olav
286b016b04
refactor: remove response data from schema validation logging (#1748)
* refactor: remove response data from schema validation logging

* refactor: update validation error snapshots

* refactor: add missing segments field to featureStrategySchema
2022-06-24 13:44:16 +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
e013a72ddd
refactor: add missing tokenUserSchema fields (#1742) 2022-06-22 15:37:26 +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
olav
5bae11a3fb
fix: avoid 400s for unknown request body fields (#1737) 2022-06-21 10:33:03 +02:00
olav
7ee8892704
fix: add missing environments field to uiConfigSchema (#1736)
* fix: add missing environment field to uiConfigSchema

* refactor: avoid throwing when unleash-server is a dependency in dev mode
2022-06-21 09:34:07 +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
e6b49e4bce
refactor: improve token type error message (#1709) 2022-06-17 09:00:13 +02: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
nya1
fb711b4d4a
fix: when payload type is 'json' validate value on toggle variable validation (#1704)
* fix: when payload type is 'json' validate value on toggle variable validation

* test: add missing feature toggle creation with variant type json

Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896476042

* refractor: remove verbose comment on validateJsonString

Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896482210

* test: add missing feature toggle creation with variant type string

Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896476042

* refractor: move variant value joi validation

Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896478563
2022-06-14 13:08:38 +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
0a53d67859
refactor: add tests for the schemas list (#1705)
* refactor: move schemas list to the top

* refactor: add tests for the schemas list
2022-06-13 11:23:36 +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
sighphyre
18e63d5ea3
feat: add support for handling non standard postgres dates (#1689)
* feat: add support for handling non standard postgres dates

* docs: update some http docs links to point to their respective https versions

* chore: refactor non standard date handling callback code to be a little clearer

* Update website/docs/deploy/configuring-unleash-v3.md

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-06-10 08:47:31 +02:00
Dennis Szczepanski
7ead887147
fix: Issue #1444 - API import with drop=true deletes existing client keys (#1668)
* fix: Does not delete api_tokens on drop-Import

* feat: Cleans unused apiTokens on environment import

* refactor: Moves ALL_PROJECTS and ALL_ENVIRONMENTS to constants

* refactor: Renames migration 20220528143630 for a more precise name

* refactor: Removes unecessary console.log

* fix: Adds correct down-script for migration 20220528143630
2022-06-09 15:56:13 +01: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
6adcf103f0
fix: clone segments when cloning a toggle (#1678)
* refactor: merge segment test files

* fix: clone segments when cloning a toggle
2022-06-08 15:41:02 +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
dadbc3addc
fix: add missing segment-deleted event data (#1677) 2022-06-07 14:06:45 +02:00
Thomas Heartman
fa74f81aa5
fix: env drop event data.name + /api/admin/events docs (#1662)
* docs: add all /events endpoints and query params

* docs: events page skeleton structure

* docs: correct description of event payloads

* docs: add table with event properties.

* docs: remove duplicate table.

* docs: sort property table

* docs: more work on adding events: feature events

* docs: add examples for most feature events

Still missing are: events that require imports, and
feature-project-change

* docs: scaffold out all events descriptions

* docs: normalize casing

* docs: add brief descriptions to strategy and context events

* docs: Add remaining non-import event descriptions and examples

* docs: add code sample annotations for all example events.

* docs: remove all references to myself

* docs: change "toggle" -> "feature", adjust headings

The headings aren't semantic for this doc yet. We'll need to create a
new document for this.

* docs: update event type description table

* docs: change header level of event type section

* docs: add details around feature-project-change event

* docs: add import type events

* docs: use a better `createdBy` name

* docs: "sort" events so that they're in a consistent order.

* docs: remove reference to ID in addon-config-created event

* fix: drop-environments data.name all-projects -> all-environments

This is probably a bug. Should be double checked.

* docs: clarify that `data.name` is always `all-x` on drop events

* Apply suggestions from code review

Co-authored-by: sighphyre <liquidwicked64@gmail.com>

Co-authored-by: sighphyre <liquidwicked64@gmail.com>
2022-06-07 11:33:30 +01: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
Christopher Kolstad
00c84f3c75
fix: use getCreatedBy to set created by on events stored (#1648) 2022-06-02 13:52:10 +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
Christopher Kolstad
606270d86a
feat: Allow extra CSP domains (#1610)
* feat: Allow extra CSP domains

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

* fix: eslint:

* fix: allow partial csp domains

* fix: add option and config type

* fix: snapshot

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-05-31 11:32:15 +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
sighphyre
6273d0d924
fix: Allow project roles to be changed when the relevant user has a root role (#1632) 2022-05-26 16:20:36 +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
Tymoteusz Czech
0f272680ee
fix: project environments order (#1599) 2022-05-23 08:52:50 +00:00
olav
b53912aef9
refactor: add regression test for long parameter values (#1617)
* refactor: add regression test for long parameter values

* refactor: format file
2022-05-20 15:44:41 +02:00
olav
05808745a7
fix: remove parametersSchema maxLength requirement (#1616) 2022-05-20 11:31:34 +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
8c1d4838b8
fix: require equal environments when moving toggles (#1595)
* fix: apply query from checkProjectsCompatibility

* fix: require equal environments when moving toggles

* refactor: clean up project service tests

* refactor: add test for project compatibility check

* refactor: improve arraysHaveSameItems name
2022-05-18 11:07:01 +02:00
Wilco Schoneveld
c30e92dc49
Added ability to set additional transport options to email service (#1589)
Co-authored-by: Wilco Schoneveld <wilco.schoneveld@politie.nl>
2022-05-13 09:06:10 +02:00
olav
3bea8a9931
refactor: use static as the asset dir name (#1586)
* refactor: use static as the asset dir name

* chore: update unleash-frontend

* refactor: use the real index.html in tests
2022-05-10 15:47:54 +02:00
olav
3b46bfb83a
refactor: fix CDN prefix rewrite (#1585)
* fix: change folder path

* refactor: revert cdnPrefix test config

* refactor: fix rewriteHTML test data

* refactor: add rewriteHTML cdnPrefix test

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-05-10 14:05:53 +02:00
Ivar Conradi Østhus
d711c4749d
fix: correct types used in addon.ts 2022-05-10 09:35:39 +02:00
sighphyre
5ef8dba7a7
fix: Upgrade knex to 2.0.0 and patch some stores to correctly order their count queries so they compile (#1579) 2022-05-09 15:20:12 +02:00
Connor Teague
e67c0d115b
1568 fix datadog type/value order in addon (#1569) 2022-05-06 09:07:19 +02:00
Nuno Góis
ce2714713a
refactor: use vite html in test (#1561) 2022-05-05 16:14:47 +01: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
Fredrik Strand Oseberg
42e32a9118
fix: set favicon icon to CDN if prefix is set (#1553) 2022-05-02 12:49:48 +02:00
Martin Lehmann
a36a19c33a
Don't import from root URL (#1540) 2022-04-29 10:44:01 +02:00
olav
c02865504e
refactor: disallow additionalProperties in response schemas (#1543) 2022-04-29 08:09:27 +02:00
olav
36922d156d
refactor: fix a few eslint module boundary type overrides (#1542) 2022-04-28 12:40:38 +02:00
Christopher Kolstad
3e40cb935e
task: Use make-fetch-happen (#1500)
closes #739
2022-04-28 10:57:52 +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
renovate[bot]
f52f1cadac
chore(deps): update dependency eslint-config-airbnb-typescript to v16.1.0 (#1147)
* chore(deps): update dependency eslint-config-airbnb-typescript to v16.1.0

* chore: Update a few places with eslint-ignore due to new linter rules for optional parameters

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: sighphyre <liquidwicked64@gmail.com>
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
2022-04-25 13:14:43 +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
c9b44b6546
Merge pull request #1476 from Unleash/feat/multi-project-tokens
feat: Implement multi token support for client tokens
2022-04-08 11:51:31 +02:00
Salvatore Novelli
7ddbff2669
feat: add "application_name" as an optional DB option #1170 (#1478)
* implemented changes to resolve issue 1170

* added applicationName to the list of db options in the documentation'

Co-authored-by: Daniele Casal <daniele.casal@lloydsbanking.com>
Co-authored-by: Sukhvinder Panesar <79143027+esspee-lbg@users.noreply.github.com>
2022-04-07 20:55:56 +02:00
abhinav1708
66c66c7e4a
feat: events for feature tag and untag (#1355) 2022-04-06 20:51:01 +02:00
Nuno Góis
794327f8e0
fix: reject duplicate segment names (#1475)
* fix: reject duplicate segment names

* refactor: remove unnecessary comment

* refactor: improve validateName logic with existsByName

* fix: removed unused NotFoundError import
2022-04-06 14:01:50 +01: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
9f7d878422
fix: add missing awaits (#1472)
* refactor: silence expected console.error call

* fix: add missing access service awaits

* fix: add missing constraint validation await
2022-04-01 11:10:21 +02:00
olav
1da38781d5
feat: add segment limits (#1469)
* feat: add segment limits

* refactor: move segment limits to constants
2022-04-01 10:53:52 +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
Youssef Khedher
d11d0e712b
refactor: block creating token for disabled environment (#1464)
* refactor: block creating token for disabled environment

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

* refactore: remove unused deps

Co-authored-by: olav <mail@olav.io>
2022-03-24 11:26:00 +01:00
olav
1cc43c0a4a
refactor: always add values to constraints (#1448) 2022-03-17 12:32:04 +01:00
sighphyre
8f60dd6958
Merge pull request #1431 from Unleash/enabled-environments-override
Add enabled environments override flag
2022-03-16 14:45:55 +02:00
Fredrik Strand Oseberg
a236a61623
Fix/user added event (#1437)
* 4.9.0-beta.1

* chore: update unleash frontend

* 4.9.0-beta.2

* fix: add user email to project user events
2022-03-16 08:44:30 +01:00
sighphyre
91fa0ed296 fix: update config tests for enabled environments 2022-03-14 10:01:05 +02:00
sighphyre
8410a8e3ac feat: enabled environments override now also moves projects and toggles to new environments 2022-03-11 15:52:13 +02:00
sighphyre
c3b064adfc feat: Add environment variable to set override enabled environments 2022-03-11 11:16:58 +02:00
Fredrik Strand Oseberg
55469801cf
feat: validate strategies (#1429)
* feat: validate strategies

* fix: optional coalescing on constraints

* fix: update test
2022-03-10 14:43:53 +01:00
sighphyre
3910e23d2d
Merge pull request #1408 from Unleash/feat/init-client-tokens
Load Client Tokens From Environment on Startup
2022-03-09 09:53:47 +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
Ivar Conradi Østhus
d514356030 fix: avoid scope issues 2022-03-03 08:52:44 +01:00
Ivar Conradi Østhus
faa87469ff Update src/lib/types/events.ts
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-03-03 08:52:44 +01:00
Ivar Conradi Østhus
7f391e2b48 Update src/lib/types/events.ts
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-03-03 08:52:44 +01:00
Ivar Conradi Østhus
f0abc0e0d6 Update src/lib/types/events.ts
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-03-03 08:52:44 +01:00
Ivar Conradi Østhus
017bd75c9c Update src/lib/services/project-service.ts
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-03-03 08:52:44 +01:00
Ivar Conradi Østhus
2f189db394 Update src/lib/services/project-service.ts
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-03-03 08:52:44 +01:00
Ivar Conradi Østhus
8364c3b396 fix: add method to change role for project memeber 2022-03-03 08:52:44 +01:00
sighphyre
6de5fdb565 feat: allow startup to load client tokens from env var 2022-03-02 13:44:46 +02: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
Christopher Kolstad
3704f93ff5
fix: readd orderBy statement to project query (#1394) 2022-02-25 08:32:12 +01:00
Christopher Kolstad
34e5034547
fix: reduce project overview query count to 2. (#1356)
* fix: reduce project overview query count to 2.

Previously we've been doing N+1 queries for projects, this now changes to doing one query for projects with feature counts, and then one query for membercounts for all projects and merging that with the first query.
2022-02-21 12:46:28 +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
Fredrik Strand Oseberg
6520aa1b0c
Feat/impression data (#1310)
* feat: add impression data column

* fix: add default value to impressionData

* fix: allow client api to return impressionData

* fix: add tests for impressionData

* fix: reset server-dev

* fix: add test for adding a toggle with impression data on a different project

* fix: update tests
2022-02-03 11:06:51 +01:00
Ivar Conradi Østhus
e5035f96e1
fix: rbac should pick up projectId from path if available 2022-02-01 22:58:52 +01:00
Ivar Conradi Østhus
19cb991cc9
fix: metric counters should use bigint (#1313) 2022-01-31 08:50:11 +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