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

161 Commits

Author SHA1 Message Date
Aneesh Relan
528748e757
fix: use correct column name for correct member count (#2127) 2022-10-04 10:45:55 +03:00
sjaanus
ddc759ac63
Add some extra fields for profile (#2119)
First version
2022-09-30 14:36:45 +03:00
Tymoteusz Czech
47152cf05b
Feat/invite user (#2061)
* refactor: user creation screen cleanup

* feat: deprecation notice for google sso

* fix: docs openid typo

* invite link bar

* invite link page

* fix prettier docs

* regenerated openapi

* hooks for invite page api

* update openapi

* feat: invite link update

* feat: add public signup token soft-delete

* public signup frontend feature flag

* fix: new user api issues

* feat: allow for creating new user from invite link

* Feat/invite user public controller (#2106)

* added PublicInviteController for public urls

* added PublicInviteController for public urls

* added PublicInviteController for public urls

* added PublicInviteController for public urls

* fix test

* fix test

* update openapi

* refactor: password reset props

* fix: public invite schema and validation

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

* user invite frontend

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

* invite link delete confirmation dialog

* refactor: password reset action

* fix: new user invite loading state

* fix: run ts check with ci

* revert openapi changes

* fix: invite token api interface

* fix: openapi schema index

* fix: update test snapshots

* update frontend snapshot

* fix: prettier ci

* fix: updates after review

Co-authored-by: andreas-unleash <104830839+andreas-unleash@users.noreply.github.com>
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-09-30 13:01:32 +02:00
andreas-unleash
5e2d96593a
sort feature strategies by created_at first and then sort_order (#2116)
* sort feature strategies by created_at first and then sort_order

* fix sorting
2022-09-30 12:50:00 +03:00
sjaanus
ec7e256140
Backend for profile page (#2114)
* First version of profile

* Fix tests

* Fix typings

* Replace where to andwhere to be more clear
2022-09-29 16:27:54 +03:00
sjaanus
d79ace57ec
Personal access token middleware (#2069)
* Middleware first version

* Middleware tests

* Add tests

* Finish middleware tests

* Add type for request

* Add flagresolver

* Fix snapshot

* Update flags and tests

* Put it back as default

* Update snapshot
2022-09-28 16:53:56 +03:00
andreas-unleash
0da2054aa4
fixed missing role by calling get after insert (#2091)
* fixed missing role by calling get after insert

* update snapshot
2022-09-26 16:50:54 +03:00
sjaanus
2a54ace005
Add description to PAT (#2090)
* Add description to PAT

* Add tests
2022-09-26 15:42:39 +03:00
andreas-unleash
aa589b5ff5
Fix/oas response (#2068)
* bug fix

* bug fix

* remove doc file

* store fixes

* bug fix

* rollback deleted file

* fix test

* add url to token

* return all tokens not just active

* add url fix

* PR comment

* PR comment

* PR comment

* add the flag to the experimental options

* fix env var name
2022-09-26 13:06:30 +03:00
Thomas Heartman
97c2b3c089
openapi: improve validation testing (#2058)
## What

This PR adds an extra layer of OpenAPI validation testing to what we already have. It also fixes any issues that make the new tests fail.

## Why

While the current OpenAPI validation takes care of _some_ things, there's also things it misses, as shown by #2055. By adding the OpenAPI Enforcer package, we should hopefully be able to catch more of these errors in the future. The enforcer _does_ flag the issue in #2055 as an error.

## How

By adding the OpenAPI Enforcer package and making whatever changes it picks up on.

By adding location headers to all our 201 endpoints. I also had to change some signatures on `create` store methods so that they actually return something (a lot of them just returned `void`).

## Discussion points

### Code changes

Some of the code changes may not be necessary or we may want to change more code to align with what changes have been done. It may be worth standardizing on a pattern for `*store.create` methods, so that they always return an identifier or the stored object, for instance.

### On relative URIs

The 201 location headers use relative URIs to point to the created resources. This seemed to be the easiest way to me, as we don't need to worry about figuring out what the absolute URL of the instance is (though we could probably just concat it to the request URI?). The algorithm for determining relative URIs is described in [RFC 3986 section 5](https://www.rfc-editor.org/rfc/rfc3986#section-5).

There's also some places where I'm not sure we _can_ provide accurate location url. I think they're supposed to point _directly at_ whatever the resource is, but for some resources (such as api tokens), you can only get it as part of a collection. From [RFC 9110 on the location field](https://httpwg.org/specs/rfc9110.html#field.location) (emphasis mine):

> the Location header field in a [201 (Created)](https://httpwg.org/specs/rfc9110.html#status.201) response is supposed to provide a URI that is **specific** to the created resource.

A link to a collection is not specific. I'm not sure what best to do about this.

### Inline comments

I've added a number of inline PR comments that I'd love to get some feedback on too. Have a look and let me know what you think!

### Unfinished business

I've added some juicy comments to some of the files here. They contain non-blocking issues that I'm tracking (via github issues). We should resolve them in the future, but right now they can stay as they are. 

## Commits

* Feat: add openapi-enforcer + tests; fix _some_ issues

* Test: allow non-standard string formats

* validation: fix _some_ 201 created location header endpoints

* #1391: fix remaining 201 location headers missing

* Refactor: use the ajv options object instead of add* methods

* #1391: flag validation errors and warnings as test failures

* #1391: modify patch schema to specify either object or array

We don't provide many patch endpoints, so we _could_ create separate
patch operation objects for each one. I think that makes sense to do
as part of the larger cleanup. For now, I think it's worth to simply
turn it into one of these. While it's not entirely accurate, it's
better than what we had before.

* Refactor: make tests easier to read

* #1391: use enum for valid token types

This was previously only a description. This may seem like a breaking
change because OpenAPI would previously accept any string. However,
Joi also performs validation on this, so invalid values wouldn't work
previously either.

* #1391: Comment out default parameter values for now

This isn't the _right_ way, but it's the pragmatic solution. It's not
a big deal and this works as a stopgap solution.

* #1391:  add todo note for api token schema fixes

* #1391: update snapshot

* Revert "#1391: modify patch schema to specify either object or array"

This reverts commit 0dd5d0faa1.

Turns out we need to allow much more than just objects and arrays.
I'll leave this as is for now.

* Chore(#1391): update comment explaining api token schema TODO

* #1391: modify some test code and add comment

* #1391: update tests and spec to allow 'any' type in schema

* Chore: remove comment

* #1391: add tests for context field stores

* #1391: add location header for public signup links

* #1391: fix query parameter description.

There was indeed a bug in the package, and this has been addressed
now, so we can go back to describing the params properly.
2022-09-23 15:02:09 +02:00
sjaanus
1cf42d6527
Personal access tokens backend (#2064)
* First version ready

* Final

* Refactor

* Update pat store

* Website revert

* Website revert

* Update

* Revert website

* Revert docs to main

* Revert docs to main

* Fix eslint

* Test

* Fix table name
2022-09-16 10:54:27 +03:00
andreas-unleash
6778d347cd
PublicSignupTokens (#2053)
* PublicSignupTokens

* bug fix

* bug fixes and test

* bug fixes and test

* bug fixes and test

* Add feature flag

* tests

* tests

* Update 20220908093515-add-public-signup-tokens.js

Bug Fix

* task: use swc instead of ts-jest (#2042)

* Add a counter for total number of environments (#1964)

* add groupId to gradual rollout template (#2045)

* add groupId to gradual rollout template

* FMT

* Improve tabs UI on smaller devices (#2014)

* Improve tabs UI on smaller devices

* Improve tabs UI on smaller devices

* bug fix

* add proper scrollable tabs

* removed centered from Tabs (conflicts with scrollable)

* PR comments

* 4.15.0-beta.10

* Fix broken doc links (#2046)

## What

This PR fixes some broken links that have been hanging around in the
docs for what seems like a very long time.

## Why

As discovered by the link check in #1912, there are a fair few broken
links in the docs. Everyone hates broken links because it makes it
harder to understand what they were supposed to be pointing at.

## How

There are 3 types of links that have been fixed:
- Links that should have been internal but were absolute. E.g.
  `https://docs.getunleash.io/path/article` that should have been
  `./article.md`
- External links that have changed, such as Slack's API description
- GitHub links to files that either no longer exist or that have been
  moved. These links generally pointed to `master`/`main`, meaning
  they are subject to change. They have been replaced with permalinks
  pointing to specific commits.

-----

* docs: fix slack api doc link

* docs: update links in migration guide

* docs: fix broken link to ancient feature schema validation

* docs: update links to v3 auth hooks

* docs: update broken link in the go sdk article

* Fix: use permalink for GitHub link

* docs: fix wrong google auth link

* 4.15.0

* 4.15.1

* docs: update link for symfony sdk (#2048)



The doc link appears to have pointed at an address that is no longer reachable. Instead, let's point to the equivalent GitHub link

Relates to and closes #2047

* docs: test broken links in website (#1912)

The action triggers manually as a first step to test this functionality. In the near future, we might schedule it

* Schedule link checker action (#2050)

Runs at 12:30 UTC on Mon, Tue, Wed, Thu and Fri

* fix: add env and project labels to feature updated metrics. (#2043)

* Revert workflow (#2051)

* update snapshot

* PR comments

* Added Events and tests

* Throw error if token not found

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-09-14 15:29:12 +03:00
Christopher Kolstad
4ed05047f3
Add a counter for total number of environments (#1964) 2022-09-06 13:24:13 +02:00
Christopher Kolstad
ae19cae8a9
feat: add count to event list (#2036)
* feat: add count to event list
2022-09-02 08:35:31 +02:00
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
Fredrik Strand Oseberg
874d8459ce
Feat/add alias to api tokens (#1931)
* refactor: remove unused API definition routes

* feat: embed proxy endpoints

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

* fix: rename param

* feat: add test for retrieving token by alias

* fix: update schema

* fix: refactor to alias

* fix: refactor to null

* fix: update snapshot

* fix: update openapi snapshot

* fix: add check to getUserForToken

* refactor: add more token alias tests

* refactor: use timingSafeEqual for token comparisons

Co-authored-by: olav <mail@olav.io>
2022-08-19 10:48:33 +02:00
olav
d2999d816d
refactor: batch feature metric inserts (#1928)
* refactor: batch feature metric inserts

* fix: use startOfHour when collapsing metrics

* refactor: avoid extra loop to sum yes/no values

* refactor: add experimental flag for batching metrics
2022-08-19 10:38:26 +02: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
sjaanus
bf11001d1c
Fix Project members SQL query performance issue (#1911)
* Fix sql query

* Update
2022-08-12 13:34:51 +00: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
sjaanus
c37cbb1819
Add seen to groups (#1894) 2022-08-08 06:02:40 +00: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
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
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
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
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
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
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
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
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
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
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
04c107a26e
refactor: add OpenAPI schemas to more controllers (#1680) 2022-06-08 15:31:34 +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
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
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
Tymoteusz Czech
0f272680ee
fix: project environments order (#1599) 2022-05-23 08:52:50 +00:00