From 8f278cb7265606042d9bd6651243d0ae1750007b Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Fri, 7 Apr 2023 11:16:00 +0200 Subject: [PATCH] Fix: feature schema (#3456) --- .../FeatureToggleList.test.jsx.snap | 368 ------------------ .../src/openapi/models/createProjectSchema.ts | 5 + .../openapi/models/createProjectSchemaMode.ts | 17 + .../models/environmentProjectSchema.ts | 18 +- .../src/openapi/models/environmentSchema.ts | 9 +- .../models/environmentsProjectSchema.ts | 3 + frontend/src/openapi/models/featureSchema.ts | 10 +- .../openapi/models/healthOverviewSchema.ts | 5 +- .../healthOverviewSchemaDefaultStickiness.ts | 19 - .../models/healthOverviewSchemaMode.ts | 3 +- .../src/openapi/models/healthReportSchema.ts | 5 +- .../healthReportSchemaDefaultStickiness.ts | 19 - .../openapi/models/healthReportSchemaMode.ts | 3 +- frontend/src/openapi/models/index.ts | 8 +- .../openapi/models/projectCreatedSchema.ts | 5 + .../models/projectCreatedSchemaMode.ts | 17 + frontend/src/openapi/models/projectSchema.ts | 5 +- .../models/projectSchemaDefaultStickiness.ts | 19 - .../src/openapi/models/projectSchemaMode.ts | 2 +- .../openapi/models/projectSettingsSchema.ts | 13 + .../projectSettingsSchemaDefaultStickiness.ts | 20 + .../models/projectSettingsSchemaMode.ts | 15 + src/lib/db/feature-strategy-store.ts | 36 +- src/lib/openapi/spec/feature-schema.ts | 5 +- .../admin-api/project/project-features.ts | 5 +- .../__snapshots__/openapi.e2e.test.ts.snap | 4 +- 26 files changed, 166 insertions(+), 472 deletions(-) delete mode 100644 frontend/src/component/feature/FeatureToggleList/__snapshots__/FeatureToggleList.test.jsx.snap create mode 100644 frontend/src/openapi/models/createProjectSchemaMode.ts delete mode 100644 frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts delete mode 100644 frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts create mode 100644 frontend/src/openapi/models/projectCreatedSchemaMode.ts delete mode 100644 frontend/src/openapi/models/projectSchemaDefaultStickiness.ts create mode 100644 frontend/src/openapi/models/projectSettingsSchema.ts create mode 100644 frontend/src/openapi/models/projectSettingsSchemaDefaultStickiness.ts create mode 100644 frontend/src/openapi/models/projectSettingsSchemaMode.ts diff --git a/frontend/src/component/feature/FeatureToggleList/__snapshots__/FeatureToggleList.test.jsx.snap b/frontend/src/component/feature/FeatureToggleList/__snapshots__/FeatureToggleList.test.jsx.snap deleted file mode 100644 index 1b3a7d58b5..0000000000 --- a/frontend/src/component/feature/FeatureToggleList/__snapshots__/FeatureToggleList.test.jsx.snap +++ /dev/null @@ -1,368 +0,0 @@ -// Vitest Snapshot v1 - -exports[`renders correctly with one feature 1`] = ` -[ -
-
-
-
- - - -
- -
-
-
- - Archive - -
-
-
-
-
-

- Feature toggles -

-
-
-
-
-

- Sorted by: -

- -
-
-
-
-
-
-
    - -
-
-
-
, -
, -] -`; - -exports[`renders correctly with one feature without permissions 1`] = ` -[ -
-
-
-
- - - -
- -
-
-
- - Archive - -
-
-
-
-
-

- Feature toggles -

-
-
-
-
-

- Sorted by: -

- -
-
-
-
-
-
-
    - -
-
-
-
, -
- Navigated to Feature toggles -
, -] -`; diff --git a/frontend/src/openapi/models/createProjectSchema.ts b/frontend/src/openapi/models/createProjectSchema.ts index 492c9f28f4..7445d2ab5e 100644 --- a/frontend/src/openapi/models/createProjectSchema.ts +++ b/frontend/src/openapi/models/createProjectSchema.ts @@ -3,9 +3,14 @@ * Do not edit manually. * See `gen:api` script in package.json */ +import type { CreateProjectSchemaMode } from './createProjectSchemaMode'; export interface CreateProjectSchema { id: string; name: string; description?: string; + /** A mode of the project affecting what actions are possible in this project */ + mode?: CreateProjectSchemaMode; + /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ + defaultStickiness?: string; } diff --git a/frontend/src/openapi/models/createProjectSchemaMode.ts b/frontend/src/openapi/models/createProjectSchemaMode.ts new file mode 100644 index 0000000000..62668abced --- /dev/null +++ b/frontend/src/openapi/models/createProjectSchemaMode.ts @@ -0,0 +1,17 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A mode of the project affecting what actions are possible in this project + */ +export type CreateProjectSchemaMode = + typeof CreateProjectSchemaMode[keyof typeof CreateProjectSchemaMode]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const CreateProjectSchemaMode = { + open: 'open', + protected: 'protected', +} as const; diff --git a/frontend/src/openapi/models/environmentProjectSchema.ts b/frontend/src/openapi/models/environmentProjectSchema.ts index 74aa9f4895..180e6ae78a 100644 --- a/frontend/src/openapi/models/environmentProjectSchema.ts +++ b/frontend/src/openapi/models/environmentProjectSchema.ts @@ -4,12 +4,22 @@ * See `gen:api` script in package.json */ +/** + * Describes a project's configuration in a given environment. + */ export interface EnvironmentProjectSchema { + /** The name of the environment */ name: string; + /** The [type of environment](https://docs.getunleash.io/reference/environments#environment-types). */ type: string; + /** `true` if the environment is enabled for the project, otherwise `false` */ enabled: boolean; - protected?: boolean; - sortOrder?: number; - projectApiTokenCount?: number | null; - projectEnabledToggleCount?: number | null; + /** `true` if the environment is protected, otherwise `false`. A *protected* environment can not be deleted. */ + protected: boolean; + /** Priority of the environment in a list of environments, the lower the value, the higher up in the list the environment will appear */ + sortOrder: number; + /** The number of client and front-end API tokens that have access to this project */ + projectApiTokenCount?: number; + /** The number of features enabled in this environment for this project */ + projectEnabledToggleCount?: number; } diff --git a/frontend/src/openapi/models/environmentSchema.ts b/frontend/src/openapi/models/environmentSchema.ts index 8a5f47f236..05795d9252 100644 --- a/frontend/src/openapi/models/environmentSchema.ts +++ b/frontend/src/openapi/models/environmentSchema.ts @@ -10,13 +10,14 @@ export interface EnvironmentSchema { /** The name of the environment */ name: string; - /** The type of the environment */ + /** The [type of environment](https://docs.getunleash.io/reference/environments#environment-types). */ type: string; /** `true` if the environment is enabled for the project, otherwise `false`. */ enabled: boolean; - protected?: boolean; - /** The sort order of the environment in the environments list */ - sortOrder?: number; + /** `true` if the environment is protected, otherwise `false`. A *protected* environment can not be deleted. */ + protected: boolean; + /** Priority of the environment in a list of environments, the lower the value, the higher up in the list the environment will appear. Needs to be an integer */ + sortOrder: number; /** The number of projects with this environment */ projectCount?: number | null; /** The number of API tokens for the project environment */ diff --git a/frontend/src/openapi/models/environmentsProjectSchema.ts b/frontend/src/openapi/models/environmentsProjectSchema.ts index 4fcdc5ebea..0e021b845e 100644 --- a/frontend/src/openapi/models/environmentsProjectSchema.ts +++ b/frontend/src/openapi/models/environmentsProjectSchema.ts @@ -5,6 +5,9 @@ */ import type { EnvironmentProjectSchema } from './environmentProjectSchema'; +/** + * Environments defined for a given project + */ export interface EnvironmentsProjectSchema { version: number; environments: EnvironmentProjectSchema[]; diff --git a/frontend/src/openapi/models/featureSchema.ts b/frontend/src/openapi/models/featureSchema.ts index 6156179d2e..6d478c2e4a 100644 --- a/frontend/src/openapi/models/featureSchema.ts +++ b/frontend/src/openapi/models/featureSchema.ts @@ -31,9 +31,15 @@ export interface FeatureSchema { lastSeenAt?: string | null; /** The list of environments where the feature can be used */ environments?: FeatureEnvironmentSchema[]; - /** The list of feature variants */ + /** + * The list of feature variants + * @deprecated + */ variants?: VariantSchema[]; - /** This is a legacy field that will be deprecated */ + /** + * This is a legacy field that will be deprecated + * @deprecated + */ strategies?: FeatureSchemaStrategiesItem[]; /** The list of feature tags */ tags?: TagSchema[] | null; diff --git a/frontend/src/openapi/models/healthOverviewSchema.ts b/frontend/src/openapi/models/healthOverviewSchema.ts index 65bb9ebbc1..06075b7c94 100644 --- a/frontend/src/openapi/models/healthOverviewSchema.ts +++ b/frontend/src/openapi/models/healthOverviewSchema.ts @@ -3,7 +3,6 @@ * Do not edit manually. * See `gen:api` script in package.json */ -import type { HealthOverviewSchemaDefaultStickiness } from './healthOverviewSchemaDefaultStickiness'; import type { HealthOverviewSchemaMode } from './healthOverviewSchemaMode'; import type { FeatureSchema } from './featureSchema'; import type { ProjectStatsSchema } from './projectStatsSchema'; @@ -13,8 +12,8 @@ export interface HealthOverviewSchema { name: string; description?: string | null; /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ - defaultStickiness?: HealthOverviewSchemaDefaultStickiness; - /** A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` */ + defaultStickiness?: string; + /** The project's [collaboration mode](https://docs.getunleash.io/reference/project-collaboration-mode). Determines whether non-project members can submit change requests or not. */ mode?: HealthOverviewSchemaMode; members?: number; health?: number; diff --git a/frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts b/frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts deleted file mode 100644 index fe2d414ecb..0000000000 --- a/frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by Orval - * Do not edit manually. - * See `gen:api` script in package.json - */ - -/** - * A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy - */ -export type HealthOverviewSchemaDefaultStickiness = - typeof HealthOverviewSchemaDefaultStickiness[keyof typeof HealthOverviewSchemaDefaultStickiness]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const HealthOverviewSchemaDefaultStickiness = { - default: 'default', - userId: 'userId', - sessionId: 'sessionId', - random: 'random', -} as const; diff --git a/frontend/src/openapi/models/healthOverviewSchemaMode.ts b/frontend/src/openapi/models/healthOverviewSchemaMode.ts index 7aed36692b..d713b33ad5 100644 --- a/frontend/src/openapi/models/healthOverviewSchemaMode.ts +++ b/frontend/src/openapi/models/healthOverviewSchemaMode.ts @@ -5,7 +5,7 @@ */ /** - * A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` + * The project's [collaboration mode](https://docs.getunleash.io/reference/project-collaboration-mode). Determines whether non-project members can submit change requests or not. */ export type HealthOverviewSchemaMode = typeof HealthOverviewSchemaMode[keyof typeof HealthOverviewSchemaMode]; @@ -14,5 +14,4 @@ export type HealthOverviewSchemaMode = export const HealthOverviewSchemaMode = { open: 'open', protected: 'protected', - null: null, } as const; diff --git a/frontend/src/openapi/models/healthReportSchema.ts b/frontend/src/openapi/models/healthReportSchema.ts index d8cc23703f..fe4c16b715 100644 --- a/frontend/src/openapi/models/healthReportSchema.ts +++ b/frontend/src/openapi/models/healthReportSchema.ts @@ -3,7 +3,6 @@ * Do not edit manually. * See `gen:api` script in package.json */ -import type { HealthReportSchemaDefaultStickiness } from './healthReportSchemaDefaultStickiness'; import type { HealthReportSchemaMode } from './healthReportSchemaMode'; import type { FeatureSchema } from './featureSchema'; import type { ProjectStatsSchema } from './projectStatsSchema'; @@ -13,8 +12,8 @@ export interface HealthReportSchema { name: string; description?: string | null; /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ - defaultStickiness?: HealthReportSchemaDefaultStickiness; - /** A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` */ + defaultStickiness?: string; + /** The project's [collaboration mode](https://docs.getunleash.io/reference/project-collaboration-mode). Determines whether non-project members can submit change requests or not. */ mode?: HealthReportSchemaMode; members?: number; health?: number; diff --git a/frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts b/frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts deleted file mode 100644 index d23c534db2..0000000000 --- a/frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by Orval - * Do not edit manually. - * See `gen:api` script in package.json - */ - -/** - * A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy - */ -export type HealthReportSchemaDefaultStickiness = - typeof HealthReportSchemaDefaultStickiness[keyof typeof HealthReportSchemaDefaultStickiness]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const HealthReportSchemaDefaultStickiness = { - default: 'default', - userId: 'userId', - sessionId: 'sessionId', - random: 'random', -} as const; diff --git a/frontend/src/openapi/models/healthReportSchemaMode.ts b/frontend/src/openapi/models/healthReportSchemaMode.ts index fa3c26ba01..e267d99201 100644 --- a/frontend/src/openapi/models/healthReportSchemaMode.ts +++ b/frontend/src/openapi/models/healthReportSchemaMode.ts @@ -5,7 +5,7 @@ */ /** - * A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` + * The project's [collaboration mode](https://docs.getunleash.io/reference/project-collaboration-mode). Determines whether non-project members can submit change requests or not. */ export type HealthReportSchemaMode = typeof HealthReportSchemaMode[keyof typeof HealthReportSchemaMode]; @@ -14,5 +14,4 @@ export type HealthReportSchemaMode = export const HealthReportSchemaMode = { open: 'open', protected: 'protected', - null: null, } as const; diff --git a/frontend/src/openapi/models/index.ts b/frontend/src/openapi/models/index.ts index a4608458e9..5c4e9c519d 100644 --- a/frontend/src/openapi/models/index.ts +++ b/frontend/src/openapi/models/index.ts @@ -78,6 +78,7 @@ export * from './createFeatureSchema'; export * from './createFeatureStrategySchema'; export * from './createInvitedUserSchema'; export * from './createProjectSchema'; +export * from './createProjectSchemaMode'; export * from './createRoleWithPermissionsSchema'; export * from './createRoleWithPermissionsSchemaPermissionsItem'; export * from './createServiceAccountSchema'; @@ -120,10 +121,8 @@ export * from './groupsSchema'; export * from './healthCheckSchema'; export * from './healthCheckSchemaHealth'; export * from './healthOverviewSchema'; -export * from './healthOverviewSchemaDefaultStickiness'; export * from './healthOverviewSchemaMode'; export * from './healthReportSchema'; -export * from './healthReportSchemaDefaultStickiness'; export * from './healthReportSchemaMode'; export * from './idSchema'; export * from './importTogglesSchema'; @@ -179,11 +178,14 @@ export * from './playgroundStrategySchemaResultAnyOfFourEvaluationStatus'; export * from './profileSchema'; export * from './projectAccessSchema'; export * from './projectCreatedSchema'; +export * from './projectCreatedSchemaMode'; export * from './projectEnvironmentSchema'; export * from './projectOverviewSchema'; export * from './projectSchema'; -export * from './projectSchemaDefaultStickiness'; export * from './projectSchemaMode'; +export * from './projectSettingsSchema'; +export * from './projectSettingsSchemaDefaultStickiness'; +export * from './projectSettingsSchemaMode'; export * from './projectStatsSchema'; export * from './projectUsers'; export * from './projectsSchema'; diff --git a/frontend/src/openapi/models/projectCreatedSchema.ts b/frontend/src/openapi/models/projectCreatedSchema.ts index 07e24cbe18..07a52b9551 100644 --- a/frontend/src/openapi/models/projectCreatedSchema.ts +++ b/frontend/src/openapi/models/projectCreatedSchema.ts @@ -3,6 +3,7 @@ * Do not edit manually. * See `gen:api` script in package.json */ +import type { ProjectCreatedSchemaMode } from './projectCreatedSchemaMode'; /** * Details about the newly created project. @@ -14,4 +15,8 @@ export interface ProjectCreatedSchema { name: string; /** The project's description. */ description?: string | null; + /** A mode of the project affecting what actions are possible in this project */ + mode?: ProjectCreatedSchemaMode; + /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ + defaultStickiness?: string; } diff --git a/frontend/src/openapi/models/projectCreatedSchemaMode.ts b/frontend/src/openapi/models/projectCreatedSchemaMode.ts new file mode 100644 index 0000000000..7954c43e7d --- /dev/null +++ b/frontend/src/openapi/models/projectCreatedSchemaMode.ts @@ -0,0 +1,17 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A mode of the project affecting what actions are possible in this project + */ +export type ProjectCreatedSchemaMode = + typeof ProjectCreatedSchemaMode[keyof typeof ProjectCreatedSchemaMode]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ProjectCreatedSchemaMode = { + open: 'open', + protected: 'protected', +} as const; diff --git a/frontend/src/openapi/models/projectSchema.ts b/frontend/src/openapi/models/projectSchema.ts index 220f95cf81..dfe337c384 100644 --- a/frontend/src/openapi/models/projectSchema.ts +++ b/frontend/src/openapi/models/projectSchema.ts @@ -4,7 +4,6 @@ * See `gen:api` script in package.json */ import type { ProjectSchemaMode } from './projectSchemaMode'; -import type { ProjectSchemaDefaultStickiness } from './projectSchemaDefaultStickiness'; /** * A definition of the project used for projects listing purposes @@ -26,8 +25,8 @@ export interface ProjectSchema { updatedAt?: string | null; /** `true` if the project was favorited, otherwise `false`. */ favorite?: boolean; - /** A mode of the project affecting what actions are possible in this project */ + /** The project's [collaboration mode](https://docs.getunleash.io/reference/project-collaboration-mode). Determines whether non-project members can submit change requests or not. */ mode?: ProjectSchemaMode; /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ - defaultStickiness?: ProjectSchemaDefaultStickiness; + defaultStickiness?: string; } diff --git a/frontend/src/openapi/models/projectSchemaDefaultStickiness.ts b/frontend/src/openapi/models/projectSchemaDefaultStickiness.ts deleted file mode 100644 index 2a5b5e0eef..0000000000 --- a/frontend/src/openapi/models/projectSchemaDefaultStickiness.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Generated by Orval - * Do not edit manually. - * See `gen:api` script in package.json - */ - -/** - * A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy - */ -export type ProjectSchemaDefaultStickiness = - typeof ProjectSchemaDefaultStickiness[keyof typeof ProjectSchemaDefaultStickiness]; - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const ProjectSchemaDefaultStickiness = { - default: 'default', - userId: 'userId', - sessionId: 'sessionId', - random: 'random', -} as const; diff --git a/frontend/src/openapi/models/projectSchemaMode.ts b/frontend/src/openapi/models/projectSchemaMode.ts index c6977498c2..7291f72213 100644 --- a/frontend/src/openapi/models/projectSchemaMode.ts +++ b/frontend/src/openapi/models/projectSchemaMode.ts @@ -5,7 +5,7 @@ */ /** - * A mode of the project affecting what actions are possible in this project + * The project's [collaboration mode](https://docs.getunleash.io/reference/project-collaboration-mode). Determines whether non-project members can submit change requests or not. */ export type ProjectSchemaMode = typeof ProjectSchemaMode[keyof typeof ProjectSchemaMode]; diff --git a/frontend/src/openapi/models/projectSettingsSchema.ts b/frontend/src/openapi/models/projectSettingsSchema.ts new file mode 100644 index 0000000000..c1ff65f52d --- /dev/null +++ b/frontend/src/openapi/models/projectSettingsSchema.ts @@ -0,0 +1,13 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ +import type { ProjectSettingsSchemaDefaultStickiness } from './projectSettingsSchemaDefaultStickiness'; +import type { ProjectSettingsSchemaMode } from './projectSettingsSchemaMode'; + +export interface ProjectSettingsSchema { + /** Default stickiness for project */ + defaultStickiness: ProjectSettingsSchemaDefaultStickiness; + mode: ProjectSettingsSchemaMode; +} diff --git a/frontend/src/openapi/models/projectSettingsSchemaDefaultStickiness.ts b/frontend/src/openapi/models/projectSettingsSchemaDefaultStickiness.ts new file mode 100644 index 0000000000..2304debc15 --- /dev/null +++ b/frontend/src/openapi/models/projectSettingsSchemaDefaultStickiness.ts @@ -0,0 +1,20 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * Default stickiness for project + */ +export type ProjectSettingsSchemaDefaultStickiness = + typeof ProjectSettingsSchemaDefaultStickiness[keyof typeof ProjectSettingsSchemaDefaultStickiness]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ProjectSettingsSchemaDefaultStickiness = { + default: 'default', + sessionId: 'sessionId', + userId: 'userId', + random: 'random', + null: null, +} as const; diff --git a/frontend/src/openapi/models/projectSettingsSchemaMode.ts b/frontend/src/openapi/models/projectSettingsSchemaMode.ts new file mode 100644 index 0000000000..a83311d843 --- /dev/null +++ b/frontend/src/openapi/models/projectSettingsSchemaMode.ts @@ -0,0 +1,15 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +export type ProjectSettingsSchemaMode = + typeof ProjectSettingsSchemaMode[keyof typeof ProjectSettingsSchemaMode]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ProjectSettingsSchemaMode = { + open: 'open', + protected: 'protected', + null: null, +} as const; diff --git a/src/lib/db/feature-strategy-store.ts b/src/lib/db/feature-strategy-store.ts index 2f1aa17081..56dc2044df 100644 --- a/src/lib/db/feature-strategy-store.ts +++ b/src/lib/db/feature-strategy-store.ts @@ -466,10 +466,12 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { let selectColumns = [ 'features.name as feature_name', + 'features.description as description', 'features.type as type', 'features.created_at as created_at', 'features.last_seen_at as last_seen_at', 'features.stale as stale', + 'features.impression_data as impression_data', 'feature_environments.enabled as enabled', 'feature_environments.environment as environment', 'feature_environments.variants as variants', @@ -499,28 +501,30 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore { const rows = await query; if (rows.length > 0) { - const overview = rows.reduce((acc, r) => { - if (acc[r.feature_name] !== undefined) { - acc[r.feature_name].environments.push( - FeatureStrategiesStore.getEnvironment(r), + const overview = rows.reduce((acc, row) => { + if (acc[row.feature_name] !== undefined) { + acc[row.feature_name].environments.push( + FeatureStrategiesStore.getEnvironment(row), ); - if (this.isNewTag(acc[r.feature_name], r)) { - this.addTag(acc[r.feature_name], r); + if (this.isNewTag(acc[row.feature_name], row)) { + this.addTag(acc[row.feature_name], row); } } else { - acc[r.feature_name] = { - type: r.type, - favorite: r.favorite, - name: r.feature_name, - createdAt: r.created_at, - lastSeenAt: r.last_seen_at, - stale: r.stale, + acc[row.feature_name] = { + type: row.type, + description: row.description, + favorite: row.favorite, + name: row.feature_name, + createdAt: row.created_at, + lastSeenAt: row.last_seen_at, + stale: row.stale, + impressionData: row.impression_data, environments: [ - FeatureStrategiesStore.getEnvironment(r), + FeatureStrategiesStore.getEnvironment(row), ], }; - if (this.isNewTag(acc[r.feature_name], r)) { - this.addTag(acc[r.feature_name], r); + if (this.isNewTag(acc[row.feature_name], row)) { + this.addTag(acc[row.feature_name], row); } } return acc; diff --git a/src/lib/openapi/spec/feature-schema.ts b/src/lib/openapi/spec/feature-schema.ts index 62a9622f0c..3709825286 100644 --- a/src/lib/openapi/spec/feature-schema.ts +++ b/src/lib/openapi/spec/feature-schema.ts @@ -34,8 +34,7 @@ export const featureSchema = { archived: { type: 'boolean', example: true, - description: - '`true` if the feature is archived, otherwise `false`.', + description: '`true` if the feature is archived', }, project: { type: 'string', @@ -96,6 +95,7 @@ export const featureSchema = { $ref: '#/components/schemas/variantSchema', }, description: 'The list of feature variants', + deprecated: true, }, strategies: { type: 'array', @@ -103,6 +103,7 @@ export const featureSchema = { type: 'object', }, description: 'This is a legacy field that will be deprecated', + deprecated: true, }, tags: { type: 'array', diff --git a/src/lib/routes/admin-api/project/project-features.ts b/src/lib/routes/admin-api/project/project-features.ts index 3b6b47ed03..3326213c7f 100644 --- a/src/lib/routes/admin-api/project/project-features.ts +++ b/src/lib/routes/admin-api/project/project-features.ts @@ -417,7 +417,10 @@ export default class ProjectFeaturesController extends Controller { ): Promise { const { projectId } = req.params; const query = await this.prepQuery(req.query, projectId); - const features = await this.featureService.getFeatureOverview(query); + const features = await this.featureService.getFeatureOverview({ + ...query, + userId: req.user.id, + }); this.openApiService.respondWithValidation( 200, res, diff --git a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap index 9c5357a55f..9472dc3f5d 100644 --- a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap +++ b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap @@ -1459,7 +1459,7 @@ exports[`should serve the OpenAPI spec 1`] = ` "additionalProperties": false, "properties": { "archived": { - "description": "\`true\` if the feature is archived, otherwise \`false\`.", + "description": "\`true\` if the feature is archived", "example": true, "type": "boolean", }, @@ -1524,6 +1524,7 @@ exports[`should serve the OpenAPI spec 1`] = ` "type": "boolean", }, "strategies": { + "deprecated": true, "description": "This is a legacy field that will be deprecated", "items": { "type": "object", @@ -1544,6 +1545,7 @@ exports[`should serve the OpenAPI spec 1`] = ` "type": "string", }, "variants": { + "deprecated": true, "description": "The list of feature variants", "items": { "$ref": "#/components/schemas/variantSchema",