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

758 Commits

Author SHA1 Message Date
Christopher Kolstad
f937e80272
fix: Updated event to include project (#2491)
### What
Our EnvironmentVariant needs project name so this PR makes sure our
service accepts the project id as one of the arguments.
2022-11-22 09:57:12 +01:00
Gastón Fournier
97372cf48c
fix: flaky tests on segments order (#2472)
## About the changes
This test fails randomly, example:
https://github.com/Unleash/unleash/actions/runs/3496006349/jobs/5853415518#step:5:376

It's not so frequent but I tested locally one out of 4 or 8 runs fails
because the rows returned are in the wrong order.

## Discussion points
If the order of segments is relevant, we should look into how we're
fetching them or applying a `sort()` before returning from the query.
I've validated on my machine that even if the segments are sent in
order, when pulled from the db sometimes they are processed in a
different order
2022-11-21 14:39:15 +01:00
andreas-unleash
6e5b214475
implement proxy all endpoint (#2460)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

This PR implements the `all` endpoint of unleash-proxy, by adding an
experimental flag that can control the behaviour

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2022-11-21 12:57:07 +02:00
Gastón Fournier
efd47b72a8
feat: Add variants per env (#2471)
## About the changes
Variants are now stored in each environment rather than in the feature
toggle. This enables RBAC, suggest changes, etc to also apply to
variants.

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#2254

### Important files
- **src/lib/db/feature-strategy-store.ts** a complex query was moved to
a view named `features_view`
- **src/lib/services/state-service.ts** export version number increased
due to the new format

## Discussion points
We're keeping the old column as a safeguard to be able to go back

Co-authored-by: sighphyre <liquidwicked64@gmail.com>
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2022-11-21 10:37:16 +01:00
andreas-unleash
a165eb191c
add back removed permissions and eventType from module exports (#2476)
Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
This PR adds (back) the permissions and eventType module exports

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2022-11-21 10:42:43 +02:00
Nuno Góis
93bd9d869a
Variants per environment (frontend) (#2453)
![image](https://user-images.githubusercontent.com/14320932/202286759-b9c30228-59cc-4c58-a7b0-3c6c3d0ecba6.png)
## About the changes

https://linear.app/unleash/issue/2-425/variants-crud-new-environment-cards-with-tables-inside-add-edit-and

Basically created parallel components for the **variants per
environments** feature, so both flows should work correctly depending on
the feature flag state. Some of the duplication means that cleanup
should be straightforward - Once we're happy with this feature it should
be enough to delete
`frontend/src/component/feature/FeatureView/FeatureVariants/FeatureVariantsList`
and do some little extra cleanup.

I noticed we had some legacy-looking code in variants, so this involved
*some* rewriting of the current variants logic. Hopefully this new code
looks nicer, more maintainable, and more importantly **doesn't break
anything**.

Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#2254

### Important files
Everything inside the
`frontend/src/component/feature/FeatureView/FeatureVariants/FeatureEnvironmentVariants`
folder.
2022-11-18 11:43:24 +00:00
Mateusz Kwasniewski
ac65778cfa
separate protected and unprotected routes (#2466) 2022-11-18 09:29:26 +01:00
Gastón Fournier
8e1fc73221
fix: flaky test on number of projects statistic (#2463) 2022-11-17 14:42:01 +01:00
Gastón Fournier
dc08f1dadd
fix: broken UI after import (#2447)
fix: broken UI when importing features into environments which are not linked to the feature's project

## Related to
- PR: https://github.com/Unleash/unleash/pull/2209
- Issue: https://github.com/Unleash/unleash/issues/2186
- Issue: https://github.com/Unleash/unleash/issues/2193

## Expected behaviour:
After importing we should see:

![image](https://user-images.githubusercontent.com/455064/202149719-fa74b3b7-3936-443b-9d0e-8f1ca2e779f4.png)

## About the changes
**The problem:** when we import we have projects, features and
environments. Each feature belongs to a project (this is by default and
the imported file enforces that). The links between projects and
features, or projects and environments, depend on us creating those
relationships. When we add a feature to an environment we're not
validating that the project and the environment are connected. Because
of that, in some situations (like in this test), we can end up with a
project with features but no environment.

This breaks a weak constraint we had which is that all projects should
have at least one environment.

**This PR makes the following assumption when importing**: _if a feature
is added to an environment, and that environment is still not linked to
the project that feature belongs to, then the project and environments
have to be linked_. The rationale behind this is that the user couldn't
have generated this export file without the project and environment
being linked together.
2022-11-17 14:05:57 +01:00
andreas-unleash
726ede5cbe
Define exports for enterprise (#2435)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
This PR sets up exports so that we can import in enterprise with just
"unleash-server".
This will free us to refactor unleash internals without breaking
enterprise

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2022-11-17 13:02:40 +02:00
sjaanus
9176ffae1e
Change requests - add multiple reviewers (#2448)
This PR adds implements the frontend and migrations part of multiple
reviewers.

2 UI parts:

1. Configuration to add the count of required approvals
2. Handle multiple approvers in review page.
2022-11-17 11:08:29 +02:00
Fredrik Strand Oseberg
978674e33a
feat: update strategy segments with edit / create strategy (#2420)
* Refactors how we add / edit segments to make it more ergonomic to work with in regards to change requests
2022-11-16 15:35:39 +01:00
sjaanus
3ef0ca580a
Remove change request api protection (#2434)
Remove change request api protection
2022-11-15 14:13:09 +02:00
Nuno Góis
1ddc46011c
Feature toggles: Filtering by tags (#2396)
https://linear.app/unleash/issue/UNL-140/experiment-with-filtering-feature-toggles-by-tags-on-the-ui

Going with a naïve approach for now, tags can be searchable the same way
we search for text. The tags column only shows up if at least one toggle
has tags set. There's a simple highlightable component that lets us know
a match was found and then shows all the tags on a tooltip:
<img width="1289" alt="image"
src="https://user-images.githubusercontent.com/14320932/201155093-b8605ff2-5bf7-45c5-b240-a33da254c278.png">
2022-11-15 10:24:36 +00:00
Tymoteusz Czech
a191313956
refactor: remove public signup link feature flag (#2423)
## About the changes
Cleanup: remove feature flag.

Closes
[1-356/remove-feature-flag-from-the-code](https://linear.app/unleash/issue/1-356/remove-feature-flag-from-the-code)
2022-11-15 10:03:20 +01:00
Mateusz Kwasniewski
4f65ad555f
Changeset comments schema (#2425) 2022-11-15 09:15:56 +01:00
sjaanus
131ebb931a
Permission guards in existing endpoints interacting with feature toggle configuration (#2418)
This PR adds permission guards for operations.

1. Toggling feature flag
2. Adding a strategy
3. Updating a strategy
4. Deleting a strategy
2022-11-14 15:05:26 +02:00
Nuno Góis
2fa154a3e4
Update environments (#2339)
https://linear.app/unleash/issue/2-357/update-environments-pages
2022-11-11 10:24:56 +00:00
andreas-unleash
74c5189159
Feat/add change request settings (#2390)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Add change_request_settings table 
Remove change_request_enabled column

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2022-11-11 10:09:25 +02:00
Thomas Heartman
665638b9da
fix: Fix broken OpenAPI (#2379)
## What

This change removes the use of double quotes in the
'addPublicSignupTokenUser' endpoint summary. It also changes the
original summary to a description and adds a new, shorter summary.

## Why

The OpenAPI / docusaurus integration errors out (refer to [this failed
build](https://github.com/Unleash/unleash/actions/runs/3434792557/jobs/5726445104))
if the frontmatter contains invalid characters. In this case, it's
because the automatic sidebar label contains double quotes, which it
interprets as a new key having been declared:

```
Error:  Error while parsing Markdown front matter.
This can happen if you use special characters in front matter values (try using double quotes around that value).
Error:  Loading of version failed for version current
Error:  Unable to build website for locale en.
Error:  YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 4, column 12:
    description: "Create a user with the 'viewe ...
               ^
```

For some reason, I cannot reproduce this error locally. Instead, the
generation goes as expected.

---

Regarding using description instead of summary: summaries should be very
short and sweet, especially because they're also used in the generated
sidebar. Descriptions can be a bit wordier, so I added a shorter summary
for going forward.

## Generated output

This is what the old configuration would generate. Notice the
`sidedar_label` key on line 2:

```md
---
id: add-public-signup-token-user
sidebar_label: Create a user with the "viewer" root role and link them to a signup token
hide_title: true
hide_table_of_contents: true
api: {'tags': ['Public signup tokens'], 'operationId': 'addPublicSignupTokenUser', 'requestBody': {'description': 'createInvitedUserSchema', 'required': true, 'content': {'application/json': {'schema': {'type': 'object', 'additionalProperties': false, 'required': ['email', 'name', 'password'], 'properties': {'username': { 'type': 'string' }, 'email': { 'type': 'string' }, 'name': { 'type': 'string' }, 'password': { 'type': 'string' },},},},},}, 'responses': {'200': {'description': 'userSchema', 'content': {'application/json': {'schema': {'type': 'object', 'additionalProperties': false, 'required': ['id'], 'properties': {'id': {'type': 'number',}, 'isAPI': {'type': 'boolean',}, 'name': {'type': 'string',}, 'email': {'type': 'string',}, 'username': {'type': 'string',}, 'imageUrl': {'type': 'string',}, 'inviteLink': {'type': 'string',}, 'loginAttempts': {'type': 'number',}, 'emailSent': {'type': 'boolean',}, 'rootRole': {'type': 'number',}, 'seenAt': {'type': 'string', 'format': 'date-time', 'nullable': true,}, 'createdAt': {'type': 'string', 'format': 'date-time',},},},},},}, '400': {'description': 'The request data does not match what we expect.',}, '409': {'description': 'The provided resource can not be created or updated because it would conflict with the current state of the resource or with an already existing resource, respectively.',},}, 'parameters': [{'name': 'token', 'in': 'path', 'required': true, 'schema': { 'type': 'string' },},], 'description': 'Create a user with the "viewer" root role and link them to a signup token', 'method': 'post', 'path': '/invite/{token}/signup', 'servers': [{ 'url': '<your-unleash-url>' }], 'security': [{ 'apiKey': [] }], 'securitySchemes': {'apiKey': {'type': 'apiKey', 'in': 'header', 'name': 'Authorization',},}, 'jsonRequestBodyExample': {'username': 'string', 'email': 'string', 'name': 'string', 'password': 'string',}, 'info': { 'title': 'Unleash API', 'version': '4.17.2' }, 'postman': {'name': 'Create a user with the "viewer" root role and link them to a signup token', 'description': { 'type': 'text/plain' }, 'url': {'path': ['invite', ':token', 'signup'], 'host': ['{{baseUrl}}'], 'query': [], 'variable': [{'disabled': false, 'description': {'content': '(Required) ', 'type': 'text/plain',}, 'type': 'any', 'value': '', 'key': 'token',},],}, 'header': [{ 'key': 'Content-Type', 'value': 'application/json' }, { 'key': 'Accept', 'value': 'application/json' },], 'method': 'POST', 'body': {'mode': 'raw', 'raw': '""', 'options': { 'raw': { 'language': 'json' } }}}}
sidebar_class_name: 'post api-method'
info_path: docs/reference/api/unleash/unleash-api
---

import ApiTabs from "@theme/ApiTabs"; import MimeTabs from "@theme/MimeTabs"; import ParamsItem from "@theme/ParamsItem"; import ResponseSamples from "@theme/ResponseSamples"; import SchemaItem from "@theme/SchemaItem" import SchemaTabs from "@theme/SchemaTabs"; import DiscriminatorTabs from "@theme/DiscriminatorTabs"; import TabItem from "@theme/TabItem";

## Create a user with the &quot;viewer&quot; root role and link them to a signup token

Create a user with the &quot;viewer&quot; root role and link them to a signup token

<!-- And much much more! -->
```
2022-11-10 22:55:01 +01:00
sjaanus
e5a5d7ded9
Fix async issue (#2387)
Currently rows were returned as a list of promise, but we need to await
for them.
2022-11-10 14:27:09 +02:00
Mateusz Kwasniewski
076ce027ed
Extract gravatar URL fn (#2386) 2022-11-10 12:13:45 +01:00
Fredrik Strand Oseberg
ac78c8f732
Feat/change request permissions (#2382)
* Adds two new permissions for the new enterprise level change request: APPROVE_CHANGE_REQUEST and APPLY_CHANGE_REQUEST
2022-11-10 11:08:58 +01:00
Ivar Conradi Østhus
1312579bf6
fix: upgrade @types/node to v16.18.3 (#2365)
This pr upgrade @types/node to v16.18.3.
This also detected some inconsitent retrun types that I decided to fix.
2022-11-10 08:20:15 +01:00
Ivar Conradi Østhus
325cd34c0c
fix: remove 'fixHourMetrics' flag 2022-11-09 22:45:30 +01:00
andreas-unleash
47a617c78b
Add changeRequestEnabled to project and project_environments (#2357)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

- Add `change_request_enabled` column to `projects` and
`project_environments`
- Modified the store to include the new column
- Added new column to Project open api schema 

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2022-11-09 14:44:53 +02:00
Sebastian Bury
f316e99dca
Authorization header webhook (#2356)
Added unit test and made code prettier in 
webhook.ts
webhook.test.ts
2022-11-09 11:45:30 +01:00
sjaanus
5e14e80ae3
Change request approvals table (#2347)
1. Added database table for change request approvals
2. Removed separate endpoint for applying. **Now all state changes will
go through same endpoint.**
2022-11-09 10:40:47 +02:00
Christopher Kolstad
5b3d95cc3a
If baseUriPath is set format it, but if it's not, don't override default with empty string (#2118)
From Thomas and mine testing. BaseUriPath can't be set as an environment
variable because we override it when trying to format the URI from the
server config. This PR makes sure we only format if the custom server
options actually have baseUriPath set.

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-11-08 15:29:14 +01:00
Thomas Heartman
d5e33ab1f2
Fix(export API): accept true and false as param values (#2349)
## What

This PR updates the `paramToBool` function to first check whether the
incoming argument is a boolean. This fixes the bug where using `true` or
`false` (e.g. `Strategies=false`) in the query would cause the server to
crash.

I've also added a test case to check for these values.

## Why

While working on the import/export API docs, I noticed that using
`false` in an export request caused the server to crash.

As we want to allow `true` and `false` (and use these values in the
documentation), we should ensure that they work as expected.

## Background

It's likely that this bug was introduced when we added the new OpenAPI
query parameters to the export endpoint. Because of the way that the
OpenAPI service we use does conversion, we now get `true` and `false`
converted to actual boolean values instead of strings. The `paramToBool`
function didn't account for that previously, which is why it caused the
server to crash.
2022-11-08 15:25:02 +01:00
Thomas Heartman
f5fb7b66d1
Fix: validate that the project is correct when getting feature by project (#2344)
## What

This PR fixes a bug where fetching a feature toggle via the
`/api/admin/projects/:projectId/features/:featureName` endpoint doesn't
validate that the feature belongs to the provided project. The same
thing applies to the archive functionality. This has also been fixed.

In doing so, it also adds corresponding tests to check for edge cases,
updates the 403 error response we use to provide clearer steps for the
user, and adds more error responses to the OpenAPI documentation.

## Why

As mentioned in #2337, it's unexpected that the provided project
shouldn't matter at all, and after discussions internally, it was also
discovered that this was never intended to be the case.

## Discussion points

It might be worth rethinking this for Unleash v5. Why does the features
API need the projects part at all when features are unique across the
entire instance? Would it be worth reverting to a simpler feature API
later or would that introduce issues with regards to how different
projects can have different active environments and so on?

### Further improvements

I have _not_ provided schemas for the error responses for the endpoints
at this time. I considered it, but because it would introduce new schema
code, more tests, etc, I decided to leave it for later. There's a
thorough OpenAPI walkthrough coming up, so I think it makes sense to do
it as part of that work instead. I am happy to be challenged on this,
however, and will implement it if you think it's better.

### Why 403 when the project is wrong?

We could also have used the 404 status code for when the feature exists
but doesn't belong to this project, but this would require more (and
more complex) code. We also already use 403 for cases like this for
post, patch, and put. Finally, the [HTTP spec's section on the 403
status code](https://httpwg.org/specs/rfc9110.html#status.403) says the
following (emphasis mine):

> The 403 (Forbidden) status code indicates that the server
**_understood the request but refuses to fulfill it_**. A server that
wishes to make public why the request has been forbidden can describe
that reason in the response content (if any).
>
> If authentication credentials were provided in the request, the server
considers them insufficient to grant access. The client SHOULD NOT
automatically repeat the request with the same credentials. The client
MAY repeat the request with new or different credentials. However, **_a
request might be forbidden for reasons unrelated to the credentials_**.

As such, I think using 403 makes sense in this case.

---

Closes #2337.
2022-11-08 13:34:01 +01:00
Fredrik Strand Oseberg
f76ac0edb3
Fix/embedded proxy memory leak (#2345)
* Fixes a memory leak where events would trigger the data polling to restart. Any event would setup another polling interval, which would strain our database. Separated the logic for fetching the data and the polling, and made sure that the polling was only initialized once.
2022-11-08 12:35:53 +01:00
Ivar Conradi Østhus
bf521b58fd
fix: merge order for UI config 2022-11-04 14:43:12 +01:00
sjaanus
102713eeca
Remove uniqueness from change requests merging (#2332)
Remove uniqueness
2022-11-04 10:57:45 +02:00
Ivar Conradi Østhus
2d2d6f268a
fix: generate all hour buckets if missing (#2319) 2022-11-04 09:30:02 +01:00
sjaanus
0de0da8f97
Remove manually added migrations and fix the scripts (#2324)
* Fix migrations

* Fix migrations
2022-11-03 14:05:47 +02:00
Nuno Góis
9fb431aab7
fix: limit total of PATs a user can have (#2301)
* fix: limit total of PATs a user can have

* increase PAT limit to 10

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

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

* disable button on the front-end when PAT limit is reached

* import from server instead of repeating ourselves

Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>
2022-11-02 08:11:35 +00:00
sjaanus
5dd8616c74
Rename suggest changes to change request (#2311)
* Rename change request

* Merge with review status

* Move events and permissions
2022-11-02 08:34:14 +02:00
sjaanus
e3a185d650
Hard cap expiry date of public signup token (#2308)
Validate expiry
2022-11-01 11:38:18 +02:00
sjaanus
c501fb221c
Hyperlink Injection in People Invitation Emails (#2307)
* Strip special characters

* Allow hyphens
2022-11-01 10:38:33 +02:00
Fredrik Strand Oseberg
8f37f9fcc9
fix: re export knex (#2300) 2022-10-31 10:49:12 +01:00
Nuno Góis
07821174a5
refactor: remove PAT experimental flag (#2299) 2022-10-31 09:38:30 +00:00
Fredrik Strand Oseberg
3029564304
Feat/enterprise stores (#2289)
* feat: add capabilities for stores in enterprise

* fix: remove unused files
2022-10-31 10:35:59 +01:00
Simon Hornby
0553976240
add support for cloning environments (#2205)
* Add support for cloning environments

Co-authored-by: Nuno Góis <github@nunogois.com>
2022-10-28 11:27:11 +02:00
Fredrik Strand Oseberg
b2c099a1c0
Feat/apply changes api (#2276)
* feat: initial setup

* fix: add types for suggest changes payload

* feat: add types for change events

* fix: change param order

* fix: remove enum

* fix: remove unused method

* fix: remove method from interface
2022-10-28 09:29:00 +02:00
sjaanus
dda1f19c70
Suggest changes updates (#2273)
* Make domain type and schema match

* Deleting change from changeset

* Add ability to merge
2022-10-27 15:47:46 +03:00
Thomas Heartman
5cef605272
OpenAPI(feat): add new 'Segments' tag (#2241)
* OpenAPI(feat): add new 'Segments' tag

## What

This change adds a new Segments tag to the list of valid OpenAPI tags.

## Why

When updating tags for the enterprise version of Unleash, I realized
we didn't have any tags that were appropriate for the segments
endpoints.

* chore: Update snapshot
2022-10-27 10:40:32 +02:00
sjaanus
3daef1d00c
Suggest change - update status and get per project (#2266)
Set change status
2022-10-27 10:53:47 +03:00
Fredrik Strand Oseberg
929f824a3a
fix: refactor conditional middleware (#2261)
* fix: refactor conditional middleware

* fix: update tests

* test: update snapshot to hide things behing flag from openapi

Co-authored-by: kwasniew <kwasniewski.mateusz@gmail.com>
2022-10-26 13:00:49 +02:00
sjaanus
2c95dfefd1
Suggest changes refactoring and schema fixes (#2250)
* Draft done

* Update GET endpoint

* Update to latest schema

* Fixes
2022-10-26 13:26:15 +03:00
renovate[bot]
d8df7e5815
fix(deps): update dependency unleash-client to v3.16.0 (#2235)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-10-26 10:23:33 +02:00
Ivar Conradi Østhus
cf4fc2303b
Feat/stats service (#2211)
Introduces an instance stats service exposing usage metrics of the Unleash installation.
2022-10-25 13:10:27 +02:00
andreas-unleash
85631b9951
Add suggest-change-store.ts and db migration (#2201)
* Add suggest-change-store.ts and db migration

* Add suggest-change-store.ts and db migration

* change payload and event data type

* Update src/lib/db/suggest-change-store.ts

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

* split to 3 tables, create event on every change

* split to 3 tables, create event on every change

* Move service to enterprise
PR Comments

* PR Comments

* replacy createdBy string with User

* replace createdBy string with User

* added event to docs

* return entire changeset after adding a change

* bug fix

* bug fix

* move add change return to service layer

* PR comments

* added user id to user objects

* added user id to user objects

* added user id to user objects

* bug fix

* Rework

* Remove event and fix queries

* Update snapshot

* Remove console logs

* Fix

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-10-24 20:07:29 +03:00
sellinjaanus
8270166286
Review your changes - approval flow (#2215)
* Initial changes

* Fix

* continue styling changes review draft

* fix: remove unused import

* update flags snapshot

Co-authored-by: sjaanus <sellinjaanus@gmail.com>
Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai>
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
2022-10-24 19:15:22 +03:00
Nuno Góis
d696863a51
feat: convert environment actions to a popover menu, add clone option (#2214)
* feat: convert environment actions to a popover menu, add clone option

* add cloneEnviroment feature flag, hide the clone option behind it

* fix: update snap
2022-10-21 08:11:14 +01:00
Tymoteusz Czech
b8c3833ae4
Suggest changes - initial frontend (#2213)
* feat: add initial controller

* feat: add fe

* feat: return status codes

* remove backend experiment

* refactor standalone route for project banner

* update suggest changeset type

* refactor changeset mock

* suggest changes banner feature flag

* fix: update routes snapshot

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-10-20 14:00:48 +02:00
sellinjaanus
726674ea3e
UX additions to groups SSO syncing (#2200)
* Initial commit

* Fix snapshot

* Fixes

* Small fix

Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-10-20 10:47:19 +03:00
sellinjaanus
8618cec832
Import of feature still showing env on feature, when environment is disabled on project (#2209)
* Import state test

* Update importer

Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-10-19 15:05:07 +03:00
Fredrik Strand Oseberg
b0626d46bc
fix: respect environment if set on context (#2206)
When using the frontend api (embedded proxy) we should allow the use to self-define the environment on the proxy.
2022-10-19 12:29:00 +02:00
sellinjaanus
4068e4749f
Fix all groups being removed, even when no external groups were defined (#2197)
* Syncing groups

* Add tests

* Fix all groups being removed

Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2022-10-17 11:44:36 +03:00
Ivar Conradi Østhus
1f0fa6abfe
fix: filter empty metrics before we collect last seen toggles. (#2172)
* fix: filter empty metrics before we collect last seen toggles.

fixes: #2104

* fix: add a last-seen service to batch last-seen toggle updates

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-10-17 09:06:59 +02:00
Nuno Góis
076a007b42
fix: PATs should have an unique description (per user) (#2191)
* fix: PATs should have an unique description

* add pat validation on the back-end service

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

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

* fix: only consider current user's PATs

* fix tests

* cleanup

* Update frontend/src/component/user/Profile/PersonalAPITokensTab/CreatePersonalAPIToken/CreatePersonalAPIToken.tsx

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

* Update src/test/e2e/api/admin/user/pat.e2e.test.ts

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

Co-authored-by: Simon Hornby <liquidwicked64@gmail.com>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-10-14 13:28:29 +01:00
sjaanus
06ebe4fca0
Syncing external groups with unleash group (#2194)
* Syncing groups

* Add tests
2022-10-14 13:08:14 +03:00
Nuno Góis
a3bf564100
feat: add SSO mappings to groups (#2175)
* feat: add SSO mappings to groups

* add feature flag to conditionally render

* fix EditGroupUsers

* fix: update snap
2022-10-13 11:34:47 +01:00
Simon Hornby
33c084dd0f
feat: Add group sync settings to front end (#2183)
* feat: Add group sync settings to front end

Co-authored-by: Nuno Góis <github@nunogois.com>
2022-10-13 10:13:41 +02:00
Fredrik Strand Oseberg
b341018b1d
fix: CORS options path (#2165)
* fix: path

* fix: path typo
2022-10-11 09:20:29 +02:00
Nuno Góis
2fa86ef97f
fix: PAT not taking into account expires_at (#2167) 2022-10-10 15:38:47 +01:00
andreas-unleash
0651c83bd1
Docs/public signup (#2070)
* update snapshot

* add api doc

* describe api

* reference initial

* updated public signup api docs
created public invite api docs

* docs

* docs update

* docs update

* add description to openapi endpoints

* add description to openapi endpoints

* fix snapshot

* Update src/lib/openapi/spec/public-signup-token-create-schema.ts

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

* Update src/lib/openapi/spec/public-signup-token-schema.ts

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

* Update src/lib/routes/admin-api/public-signup.ts

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

* Update src/lib/routes/public-invite.ts

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

* Update src/lib/openapi/spec/public-signup-token-schema.ts

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

* Update src/lib/routes/admin-api/public-signup.ts

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

* Update website/docs/reference/public-signup.mdx

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

* PR comments

* delete api docs

* fix snapshot

* Update src/lib/routes/admin-api/public-signup.ts

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

* bug fix

* bug fix

* bug fix

* Update src/lib/openapi/spec/public-signup-token-create-schema.ts

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

* Update src/lib/openapi/spec/public-signup-token-schema.ts

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

* Update src/lib/openapi/spec/public-signup-token-update-schema.ts

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

* Update src/lib/routes/admin-api/public-signup.ts

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

* Update src/lib/routes/admin-api/public-signup.ts

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

* Update src/lib/routes/public-invite.ts

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

* bug fix

* fix links

* update snapshot

* update snapshot

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-10-10 16:12:11 +03:00
andreas-unleash
64b8df7ee0
fixed segments not being copied (#2105)
* fixed segments not being copied

* fix fmt

* bug fix

* return segmentId[] when getting a feature strategy

* do not return segments if they are not there

* Update src/lib/services/feature-toggle-service.ts

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

* fix lint

* fix: more explicit column sorting and bug fix

* update snapshot

* rollback

* add segment ids to feature strategies

* bug fix

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2022-10-10 15:32:34 +03:00
sjaanus
c105ca02f1
Change PAT primary key from string to number (#2163)
* Update primary key

* Fix tests
2022-10-10 13:35:12 +03:00
Thomas Heartman
003b0e7a4e
#1391: ensure all tags are valid (#2124)
## What

This PR does two things:

1. Add tests to ensure that all OpenAPI tags are listed in the root-level `tags` property of the spec.
2. Changes the tags for endpoints that use any of the deprecated tags (specifically `admin`).

## Why

When we moved to using the docusaurus OpenAPI doc generator, we made some changes to existing tags. Moving away from having just 'admin', 'client', and one or two more, we now use a more granular system, which makes it easier to find an endpoint by category.

However, there's currently nothing enforcing this and this bit of knowledge hasn't been clearly communicated to anyone. Because of this, we have some endpoints that are currently just grouped under a general 'admin' tag.

This has two drawbacks:

-   In Swagger UI, all these endpoints are grouped together. This means that they break with the expectation that each endpoint has its own category. Further, being lumped together means that the 'admin' group is hard to read.
-   The 'admin' tag is (on purpose) not included in the root-level `tags` property of the generated OpenAPI spec. This means that the OpenAPI docusaurus generator doesn't pick up those endpoints, which means that they're not included in the docs on docs.getunleash.io.

## How

By implementing tests that:

1. Check that the tags included in the spec are a subset of the "approved" tags

2. By checking each path in the OpenAPI spec and making sure that all its tags are listed in the root-level tag list. If this is not the case, the test fails and it logs an error explaining what is wrong to the console. An example of such a message is:

```
The OpenAPI spec contains path-level tags that are not listed in the root-level tags object. The relevant paths, operation ids, and tags are as follows:

POST /api/admin/feedback (operation id: createFeedback) has the following invalid tags: "admin"

PUT /api/admin/feedback/{id} (operation id: updateFeedback) has the following invalid tags: "admin"

For reference, the root-level tags are: "Addons", "Admin UI", "API tokens", "Archive", "Auth", "Client", "Context", "Edge", "Environments", "Events", "Features", "Import/Export", "Metrics", "Operational", "Playground", "Projects", "Public signup tokens", "Strategies", "Tags", "Unstable", "Users"
```

## Commits

* fix: ensure that all root-level tags in the spec are 'approved tags'

* fix: test that all listed path tags exist in the root-level tags

* fix: use "API tokens" tag for PAT endpoints

* fix: add comment explaining why tags test is there

* fix: Update snapshot

* fix: ensure that spec tags are a subset of the approved Tags

* fix: improve error message when tags don't match

* fix: further tweaks in log format
2022-10-06 15:01:12 +00:00
sjaanus
3ec1241412
Update how project member count works (#2132)
Update project member counts
2022-10-06 10:19:19 +03:00
Ivar Conradi Østhus
a09c6313b1
fix: auto add stratgy when enabling empty env. (#2137) 2022-10-05 23:33:36 +02:00
Aneesh Relan
1d5249eddc
fix: slack back link url to point to the feature page (#2128)
* fix: slack back link url to point to the feature page

* update snapshots

* update feature link in case project info is available in event

* update missing snapshot
2022-10-05 11:30:51 +02:00
Aneesh Relan
528748e757
fix: use correct column name for correct member count (#2127) 2022-10-04 10:45:55 +03:00
Nuno Góis
ddcfe132e4
feat: new profile page and PATs front-end (#2109)
* feat: new user dropdown and profile page

* fix: add popup boxShadow to dark-theme

* fix: update routes snap

* refactor: move some tab specific logic into tabs component

* add useProfile hook example

* fix profile tab header (no name)

* fix: hide user popup when clicking profile link

* - add PATs to profile;
- add route logic to profile;
- refactor TimeAgoCell title;
- misc fixes and refactoring;

* add profile info to profile tab

* simplify req paths

* add PAT flag to the front-end

* fix: some UI adjustments

* change user popup buttons to links

* fix profile on front-end, add role description

* update delete PAT text

* address some PR comments

* address PR comments

* some more UI fixes and refactoring

* move password request to API hook
2022-10-03 10:49:52 +01:00
Ivar Conradi Østhus
5141e77bce
fix: add appName to http response time metrics (#2117) 2022-09-30 15:28:50 +02:00
andreas-unleash
bd9172b7a0
Update public signup migration files (#2120)
Update
2022-09-30 15:20:24 +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
d5f621f3b2
Add test for api-token-middleware to not make database call when using PAT (#2110)
* 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

* Add middleware test
2022-09-29 08:53:29 +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
Fredrik Strand Oseberg
7fbe227e0f
Fix/frontendapi synchronization (#2100)
* feat: add db fetch polling for proxy endpoints

* feat: add test for retrieving cache on interval

* feat: configurable interval

* fix: add config options

* feat: docs

* fix: add config to proxy-repository

* fix: update snapshots

* Update website/docs/reference/front-end-api.md

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

* fix: update docs

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

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

* Update website/docs/reference/front-end-api.md

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

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-28 14:23:41 +02:00
Tymoteusz Czech
0086f2f19f
Fix: prevent password reset email flooding (#2076)
* fix: prevent password reset email flooding

* feat: add tests to user service for password reset
2022-09-28 10:24:43 +02:00
Gard Rimestad
9aa1c7aeb0
fix: client registration events are on eventStore (#2093)
Client registration events are on eventStore and not on eventBus. This
change makes us have sdk name and version metrics in unleash.
2022-09-27 11:06:06 +02: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
b206d582ed
Fix snapshot so tests will work (#2092)
Fix snapshot
2022-09-26 16:30:18 +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
sjaanus
1426d5be33
Added login endpoint rate limit (#2074)
* Added login rate limit

* Make more pretty

* Make more pretty

* Fix

* Remove double after all
2022-09-26 10:58:58 +03:00
sjaanus
74c5db60be
Fix openapi snapshot so tests will not fail (#2085)
Fix openapi
2022-09-26 10:15:29 +03:00
Thomas Heartman
f131d5a7f8
fix: Revert breaking change for incoming token creation reqs (#2084)
## What

This change reverts the spec change to create-api-token-schema that
was introduced in 97c2b3c089

That commit changed the endpoint from allowing any string to only
allowing strings that match the values of the ApiTokenType value.

## Why

Because we already validate this on the backend, I didn't think it
would break anything. However, because OpenAPI enums are case
sensitive (and do not currently support anything else), it _did_ break
the API. ([stack overflow post that explains how this
works](https://stackoverflow.com/questions/60772786/case-insensitive-string-parameter-in-schema-of-openapi))

## Of note

This should have been caught by the tests, but it didn't show up until
it was merged to the main branch. I think it might be worth looking
into how we do the PR testing.
2022-09-23 16:01:47 +02: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
Christopher Kolstad
667fb9a8cf
fix: deletes all sessions for user on logout (#2071)
* fix: deletes all sessions for user on logout
2022-09-23 14:19:17 +02:00
Thomas Heartman
8869e6f04d
Refactor(#1391): don't check for OpenAPI version in snapshot tests (#2072)
* Refactor(#1391): don't check for OpenAPI version in snapshot tests

remove the version from the received specification. The version
_is_ a required field, but having the version listed in automated
testing causes issues when trying to deploy new versions of the
API (due to mismatch between new tag versions etc). That's why we
remove it.

* #1391: test that the "semver" property is present

* #1391: test that the openapi version is valid semver

* Chore(#1391): comment formatting
2022-09-19 09:07:26 +00: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
Thomas Heartman
ca6c5854f4
Fix(#1391): Expose API version even when not running via npm/yarn (#2062)
* Fix(#1391): Expose API version even when not running via npm/yarn

## What

Expose the current Unleash version in the generated OpenAPI docs, even
when running via docker or other processes.

## Why

An OpenAPI spec without a version isn't valid. This causes some of our
generation tools (such as the one for documentation) to fail.

## How

By changing how we fetch the current version:

Previously, we used `process.env.npm_package_version!`. However, when
you're not running with yarn or npm, this is `undefined`. That causes
the version number to not be included when running tests and when
running using the official docker image.

Instead, we now use `version` from `lib/util/version`. This is the
same version as the one used by the UI config endpoint, so it should
be the same one as what the front end displays. To the best of my
knowledge, this _is_ the version of the API.

## Discussion

It _may_ be that I have misunderstood what the version represents, but
from what I can tell, it just exports what's listed as the version in
package.json.

The source code of the `lib/util/version` file is:

```ts
// export module version
require('pkginfo')(module, 'version');

const { version } = module.exports;
export default version;
module.exports = version;
```

* Refactor(#1391): rename imported variable for clarity
2022-09-15 10:22:21 +00:00
andreas-unleash
616ce5a93c
Fix/oas tags (#2065)
* bug fix

* update snapshot
2022-09-15 11:18:54 +02:00
Christopher Kolstad
c52cec5df4
fix: Do not call store function in constructor 2022-09-15 09:48:14 +02: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
Florian Bunsmann
3a0113d16a
Add support for req.logout with passport version 0.6.0 and onwards (#2041)
Handle logout based on passport version
2022-09-13 09:59:34 +02:00
Thomas Heartman
518fee1a8c
Fix validate-edge-tokens OpenAPI schema (#2055)
* fix: varidate-edge-tokens-schema tokens type

This change fixes the description of the 'tokens' array of the
validate edge tokens schema.

The source of the error was a simple inverson of anyOf and items.

* fix: update snapshot
2022-09-12 15:51:52 +02:00
Fredrik Strand Oseberg
721cd20b5d
feat: add method for migrating proxies without environment validation (#2056) 2022-09-12 13:22:23 +00:00
Ivar Conradi Østhus
a7ed7557ec
fix: add env and project labels to feature updated metrics. (#2043) 2022-09-08 11:01:27 +02:00
Christopher Kolstad
4ed05047f3
Add a counter for total number of environments (#1964) 2022-09-06 13:24:13 +02:00
Christopher Kolstad
8648649047
task: use swc instead of ts-jest (#2042) 2022-09-06 13:22:41 +02:00
Tymoteusz Czech
18fc5eebd2
fix: show addon event select validation (#2031)
* fix: show addon event select validation

* fix: addon form parameters error not clearing

* fix: addon required parameter field indicators
2022-09-05 11:00:59 +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
sjaanus
ad546a054f
Create endpoint that validates tokens for edge (#2039)
* Create new endpoint

* Change edge url

* Fix snapshot
2022-09-01 13:26:26 +00:00
olav
30dab4f367
fix: use correct proxy logger name (#2027) 2022-08-31 16:02:22 +02:00
olav
f06470dfa7
fix: attempt to unflake version service tests (#2008) 2022-08-31 08:06:25 +02:00
Ivar Conradi Østhus
8ef7789769
fix: Sliding window functionality for summaries (#1999)
Make the percentile metrics more adaptive to changes.
https://github.com/siimon/prom-client#summary
2022-08-30 13:53:28 +02:00
Gastón Fournier
47532dee7f
chore: upgrade @unleash/express-openapi (#1976) 2022-08-29 12:23:06 +02:00
Fredrik Strand Oseberg
85b45b9965
Feat/unleash flags embedded proxy (#1974)
* feat: use unleash flags for embedded proxy

* feat: add a separate flag for the proxy frontend

* fix: setup unleash in dev

* fix: check flagResolver on each request

* fix: remove unleash client setup

* refactor: update frontend routes snapshot

* refactor: make batchMetrics flag dynamic

* fix: always check dynamic CORS origins config

* fix: make conditionalMiddleware work with the OpenAPI schema generation

Co-authored-by: olav <mail@olav.io>
2022-08-26 15:16:29 +02:00
Fredrik Strand Oseberg
1821bb881a
fix: proxy api check (#1965)
* fix: proxy api check

* fix: add await

* fix: revert async setup for prehook

* fix: stricter endpoint checks
2022-08-26 11:44:12 +02:00
sjaanus
709c142a87 Merge main 2022-08-26 09:09:18 +00:00
sjaanus
a1ce89bedc
Merge frontend with backend (#1962)
* fix: use the frontend dir from the backend

* Build is now working

* Fix workflows

* Fix workflows

* Fix build PRs

* Test coverage workflow

* Test coverage

* Test coverage run

* Fix jest report

* refactor: add missing frontend build

* refactor: ignore frontend dir for coverage

* refactor: run frontend build in PRs

* refactor: run backend tests in PRs

* Revert "refactor: run backend tests in PRs"

This reverts commit 22cabddfd1.

* refactor: remove unused frontend build file

* refactor: test workflows in PR

* refactor: use a prepare script for the frontend

* refactor: simplify yarn build scripts

* refactor: fix check-release script

* Revert "refactor: test workflows in PR"

This reverts commit 496ae19404.

* refactor: remove unused gitignore lines

* refactor: remove renovate config from the frontend repo

* refactor: remove frontend repo license

* refactor: remove frontend repo changelog

* refactor: update frontend repo readme

* refactor: add frontend node_modules to dockerignore

* refactor: update the docker yarn.lock snapshot

Co-authored-by: olav <mail@olav.io>
2022-08-26 07:25:31 +00:00
olav
42d64c8803
feat: add CORS instance settings (#1957)
* feat: add CORS instance settings

* refactor: disallow arbitrary asterisks in CORS origins
2022-08-26 09:09:48 +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
Christopher Kolstad
72b48bbe81
fix: enforce non-nullability for createdBy/modifiedBy arguments (#1959) 2022-08-25 08:39:28 +02:00
Gastón Fournier
2eff58bd71
docs: add 403 standard error (#1927) 2022-08-23 13:34:16 +02:00
olav
c42bbe4919
refactor: test segments in embedded proxy (#1952) 2022-08-22 16:35:43 +02:00
olav
634e188f73
fix: clean up proxy clients on API key deletion (#1950) 2022-08-22 15:02:39 +02:00
olav
655c0dea2c
fix: resolve correct environment for admin tokens (#1951) 2022-08-22 14:44:38 +02:00
olav
651994a5a0
refactor: fix missing IEventStore event emitter methods (#1948) 2022-08-22 09:18:29 +02:00
olav
f39f3d59ae
fix: use correct project field for proxy features (#1946) 2022-08-19 12:54:40 +02:00
Gastón Fournier
b8b802c8ed
refactor: improve performance of collapseHourlyMetrics (#1945) 2022-08-19 11:45:41 +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
Gastón Fournier
d91b91b56f
chore: type improvements (#1941)
Simplify the type to its minimum so it matches the API spec
2022-08-19 10:28:53 +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
olav
831380333e
fix: attempt to unflake the feature e2e tests (#1940) 2022-08-18 12:35:45 +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
Tymoteusz Czech
3266e9c22a
Refactor: rename frontend api key (#1935)
* refactor: rename frontend api key

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

* Fix

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

* feat: embed proxy endpoints

* feat: add metadata

* feat: update schema

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

* refactor: add api token metadata test coverage

* refactor: proxy key validation and default values

* refactor: update snapshot

Co-authored-by: olav <mail@olav.io>
Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2022-08-17 10:55:52 +02:00
Tymoteusz Czech
45c6464587
Migration for API key metadata (#1930)
* feat: add metadata to api_keys

* fix: default to empty object for metadata

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

* feat: add support for proxy keys

* feat: support listening for any event

* feat: embed proxy endpoints

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

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

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

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

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

## Commits

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

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

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

* Wip: current status

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

* Move openapi into own sidebar; generate from localhost

* Chore: Update docusaurus plugin for OpenAPI

* Add website/yarn.lock to git

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

* docs: make openapi generated code work again

* docs: make tags work properly with openapi sidebar

* Docs/chore: update OpenAPI tag scheme.

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

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

* docs: typo

* Docs:  link restructure

* docs: add operation indicators to openapi docs

* docs: change badge color for operations

* docs: update openapi-docs package

It now sorts tags the same as the schema

* docs: pluralize APIs in slug

* docs: update links to generated api docs

* docs: update openapi snapshot tests with new tags

* docs: conditionally load spec from localhost or from file

* docs: Remove changes relating to immediate switchover

* refactor: rename types; extract into separate file

* docs: fix api doc links
2022-08-12 11:37:57 +02:00
Simon Hornby
38e428dacf
Fix/remove group owner concept (#1905)
* fix: remove group user role
2022-08-11 08:23:08 +02:00
sjaanus
59b8a06968
Deleting project does not delete entry group_role table (#1896)
* Add constraint for project

* Add constraint for project

* Add constraint for project

* Add constraint for project

* Add constraint for project

* Revert eslint

* Fix eslint

* Fix tests
2022-08-10 07:45:59 +00:00
sjaanus
84a932043e
Remove joins (#1898) 2022-08-10 06:56:57 +00:00
olav
a34c674971
feat: add event search endpoint (#1893)
* feat: add event search endpoint

* refactor: expand variable names

* refactor: add table type to query builder

* refactor: improve schema limit/offset types

* refactor: describe searchEventsSchema fields
2022-08-09 16:14:50 +02:00
olav
49095025ff
refactor: remove bootstrap endpoint (#1900) 2022-08-09 15:58:27 +02:00
Fredrik Strand Oseberg
47addb31cb
fix: parameter naming (#1899) 2022-08-09 13:13:05 +02:00