1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

Fix: make stickiness accept any string (#3408)

<!-- 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! ❤️ -->
Changes the schema and api to accept any string for defaultStickiness
## 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>
This commit is contained in:
andreas-unleash 2023-03-28 16:42:16 +03:00 committed by GitHub
parent 96e327c84b
commit 0d68febdf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 12 additions and 45 deletions

View File

@ -6,7 +6,7 @@ interface ICreatePayload {
name: string;
description: string;
mode: 'open' | 'protected';
defaultStickiness: 'default' | 'userId' | 'sessionId' | 'random';
defaultStickiness: string;
}
interface IAccessesPayload {

View File

@ -3,7 +3,6 @@ import { Logger, LogProvider } from '../logger';
import NotFoundError from '../error/notfound-error';
import {
DefaultStickiness,
IEnvironment,
IFlagResolver,
IProject,
@ -487,7 +486,7 @@ class ProjectStore implements IProjectStore {
async setProjectSettings(
projectId: string,
defaultStickiness: DefaultStickiness,
defaultStickiness: string,
mode: ProjectMode,
): Promise<void> {
await this.db(SETTINGS_TABLE)

View File

@ -27,7 +27,6 @@ export const healthOverviewSchema = {
},
defaultStickiness: {
type: 'string',
enum: ['default', 'userId', 'sessionId', 'random'],
example: 'userId',
description:
'A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy',

View File

@ -38,7 +38,6 @@ export const projectOverviewSchema = {
},
defaultStickiness: {
type: 'string',
enum: ['default', 'userId', 'sessionId', 'random'],
example: 'userId',
description:
'A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy',

View File

@ -64,7 +64,6 @@ export const projectSchema = {
},
defaultStickiness: {
type: 'string',
enum: ['default', 'userId', 'sessionId', 'random'],
example: 'userId',
description:
'A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy',

View File

@ -8,7 +8,6 @@ import { projectSchema } from './project-schema';
import NotFoundError from '../error/notfound-error';
import {
DEFAULT_PROJECT,
DefaultStickiness,
FEATURE_ENVIRONMENT_ENABLED,
FeatureToggle,
IAccountStore,
@ -860,7 +859,7 @@ export default class ProjectService {
async setProjectSettings(
projectId: string,
defaultStickiness: DefaultStickiness,
defaultStickiness: string,
mode: ProjectMode,
): Promise<void> {
return this.store.setProjectSettings(

View File

@ -2,7 +2,7 @@ import { ITagType } from './stores/tag-type-store';
import { LogProvider } from '../logger';
import { IRole } from './stores/access-store';
import { IUser } from './user';
import { ALL_OPERATORS } from '../util/constants';
import { ALL_OPERATORS } from '../util';
import { IProjectStats } from 'lib/services/project-service';
export type Operator = typeof ALL_OPERATORS[number];
@ -175,8 +175,6 @@ export interface IFeatureOverview {
export type ProjectMode = 'open' | 'protected';
export type DefaultStickiness = 'default' | 'sessionId' | 'userId' | 'random';
export interface IProjectOverview {
name: string;
description: string;
@ -190,7 +188,7 @@ export interface IProjectOverview {
stats?: IProjectStats;
mode: ProjectMode;
defaultStickiness: DefaultStickiness;
defaultStickiness: string;
}
export interface IProjectHealthReport extends IProjectOverview {
@ -374,7 +372,7 @@ export interface IProject {
updatedAt?: Date;
changeRequestsEnabled?: boolean;
mode: ProjectMode;
defaultStickiness?: DefaultStickiness;
defaultStickiness?: string;
}
export interface ICustomRole {

View File

@ -29,7 +29,7 @@ export interface IApiTokenCreate {
expiresAt?: Date;
}
export interface IApiToken extends IApiTokenCreate {
export interface IApiToken extends Omit<IApiTokenCreate, 'alias'> {
createdAt: Date;
seenAt?: Date;
environment: string;

View File

@ -3,7 +3,6 @@ import {
IProjectMembersCount,
} from '../../db/project-store';
import {
DefaultStickiness,
IEnvironment,
IProject,
IProjectWithCount,
@ -22,12 +21,12 @@ export interface IProjectInsert {
export interface IProjectSettings {
mode: ProjectMode;
defaultStickiness: DefaultStickiness;
defaultStickiness: string;
}
export interface IProjectSettingsRow {
project_mode: ProjectMode;
default_stickiness: DefaultStickiness;
default_stickiness: string;
}
export interface IProjectArchived {
@ -101,7 +100,7 @@ export interface IProjectStore extends Store<IProject, string> {
getProjectSettings(projectId: string): Promise<IProjectSettings>;
setProjectSettings(
projectId: string,
defaultStickiness: DefaultStickiness,
defaultStickiness: string,
mode: ProjectMode,
): Promise<void>;
}

View File

@ -1843,12 +1843,6 @@ exports[`should serve the OpenAPI spec 1`] = `
"properties": {
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"enum": [
"default",
"userId",
"sessionId",
"random",
],
"example": "userId",
"type": "string",
},
@ -1916,12 +1910,6 @@ exports[`should serve the OpenAPI spec 1`] = `
},
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"enum": [
"default",
"userId",
"sessionId",
"random",
],
"example": "userId",
"type": "string",
},
@ -2781,12 +2769,6 @@ exports[`should serve the OpenAPI spec 1`] = `
"properties": {
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"enum": [
"default",
"userId",
"sessionId",
"random",
],
"example": "userId",
"type": "string",
},
@ -2874,12 +2856,6 @@ exports[`should serve the OpenAPI spec 1`] = `
},
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"enum": [
"default",
"userId",
"sessionId",
"random",
],
"example": "userId",
"type": "string",
},

View File

@ -5,12 +5,11 @@ import {
IProjectStore,
} from '../../lib/types/stores/project-store';
import {
DefaultStickiness,
IEnvironment,
IProject,
IProjectWithCount,
ProjectMode,
} from '../../lib/types/model';
} from '../../lib/types';
import NotFoundError from '../../lib/error/notfound-error';
import {
IEnvironmentProjectLink,
@ -174,7 +173,7 @@ export default class FakeProjectStore implements IProjectStore {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
projectId: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
defaultStickiness: DefaultStickiness,
defaultStickiness: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
mode: ProjectMode,
): Promise<void> {