From 63ff2f16de8505ef3986f1780e3fa7ca103da2f5 Mon Sep 17 00:00:00 2001 From: kwasniew Date: Wed, 20 Mar 2024 07:16:44 +0100 Subject: [PATCH 1/3] chore: orval with project insights --- .../models/actionDefinitionParameterSchema.ts | 23 +++++++++++++++ .../actionDefinitionParameterSchemaName.ts | 19 ++++++++++++ .../actionDefinitionParameterSchemaType.ts | 17 +++++++++++ .../openapi/models/actionDefinitionSchema.ts | 22 ++++++++++++++ .../models/actionDefinitionsConfigSchema.ts | 16 ++++++++++ .../addonCreateUpdateSchemaParameters.ts | 2 +- .../openapi/models/addonSchemaParameters.ts | 2 +- .../openapi/models/getProjectInsights401.ts | 14 +++++++++ .../openapi/models/getProjectInsights403.ts | 14 +++++++++ .../openapi/models/getProjectInsights404.ts | 14 +++++++++ frontend/src/openapi/models/index.ts | 14 +++++++++ frontend/src/openapi/models/patchSchema.ts | 3 +- .../src/openapi/models/patchSchemaValue.ts | 10 +++++++ .../openapi/models/projectInsightsSchema.ts | 29 +++++++++++++++++++ .../projectInsightsSchemaChangeRequests.ts | 23 +++++++++++++++ .../models/projectInsightsSchemaHealth.ts | 19 ++++++++++++ .../models/projectInsightsSchemaMembers.ts | 17 +++++++++++ .../openapi/models/resourceLimitsSchema.ts | 16 +++++----- .../models/toggleFeaturesByTagActionSchema.ts | 17 +++++++++++ 19 files changed, 280 insertions(+), 11 deletions(-) create mode 100644 frontend/src/openapi/models/actionDefinitionParameterSchema.ts create mode 100644 frontend/src/openapi/models/actionDefinitionParameterSchemaName.ts create mode 100644 frontend/src/openapi/models/actionDefinitionParameterSchemaType.ts create mode 100644 frontend/src/openapi/models/actionDefinitionSchema.ts create mode 100644 frontend/src/openapi/models/actionDefinitionsConfigSchema.ts create mode 100644 frontend/src/openapi/models/getProjectInsights401.ts create mode 100644 frontend/src/openapi/models/getProjectInsights403.ts create mode 100644 frontend/src/openapi/models/getProjectInsights404.ts create mode 100644 frontend/src/openapi/models/patchSchemaValue.ts create mode 100644 frontend/src/openapi/models/projectInsightsSchema.ts create mode 100644 frontend/src/openapi/models/projectInsightsSchemaChangeRequests.ts create mode 100644 frontend/src/openapi/models/projectInsightsSchemaHealth.ts create mode 100644 frontend/src/openapi/models/projectInsightsSchemaMembers.ts create mode 100644 frontend/src/openapi/models/toggleFeaturesByTagActionSchema.ts diff --git a/frontend/src/openapi/models/actionDefinitionParameterSchema.ts b/frontend/src/openapi/models/actionDefinitionParameterSchema.ts new file mode 100644 index 00000000000..52a893fa065 --- /dev/null +++ b/frontend/src/openapi/models/actionDefinitionParameterSchema.ts @@ -0,0 +1,23 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ +import type { ActionDefinitionParameterSchemaName } from './actionDefinitionParameterSchemaName'; +import type { ActionDefinitionParameterSchemaType } from './actionDefinitionParameterSchemaType'; + +/** + * Defines a parameter for an action. + */ +export interface ActionDefinitionParameterSchema { + /** The label of the parameter. */ + label: string; + /** The name of the parameter. */ + name: ActionDefinitionParameterSchemaName; + /** Whether the parameter is optional. */ + optional?: boolean; + /** Lists of options to be used for the parameter. */ + options?: string[]; + /** The parameter type. */ + type: ActionDefinitionParameterSchemaType; +} diff --git a/frontend/src/openapi/models/actionDefinitionParameterSchemaName.ts b/frontend/src/openapi/models/actionDefinitionParameterSchemaName.ts new file mode 100644 index 00000000000..f2cb9d550c9 --- /dev/null +++ b/frontend/src/openapi/models/actionDefinitionParameterSchemaName.ts @@ -0,0 +1,19 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * The name of the parameter. + */ +export type ActionDefinitionParameterSchemaName = + (typeof ActionDefinitionParameterSchemaName)[keyof typeof ActionDefinitionParameterSchemaName]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ActionDefinitionParameterSchemaName = { + project: 'project', + environment: 'environment', + featureName: 'featureName', + tag: 'tag', +} as const; diff --git a/frontend/src/openapi/models/actionDefinitionParameterSchemaType.ts b/frontend/src/openapi/models/actionDefinitionParameterSchemaType.ts new file mode 100644 index 00000000000..df2d00473a5 --- /dev/null +++ b/frontend/src/openapi/models/actionDefinitionParameterSchemaType.ts @@ -0,0 +1,17 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * The parameter type. + */ +export type ActionDefinitionParameterSchemaType = + (typeof ActionDefinitionParameterSchemaType)[keyof typeof ActionDefinitionParameterSchemaType]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ActionDefinitionParameterSchemaType = { + select: 'select', + hidden: 'hidden', +} as const; diff --git a/frontend/src/openapi/models/actionDefinitionSchema.ts b/frontend/src/openapi/models/actionDefinitionSchema.ts new file mode 100644 index 00000000000..720186cebe9 --- /dev/null +++ b/frontend/src/openapi/models/actionDefinitionSchema.ts @@ -0,0 +1,22 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ +import type { ActionDefinitionParameterSchema } from './actionDefinitionParameterSchema'; + +/** + * Configuration of a single action and its parameters. + */ +export interface ActionDefinitionSchema { + /** The category of the action. */ + category: string; + /** A description for the action. */ + description: string; + /** The label of the action. */ + label: string; + /** The parameters required to perform the action. */ + parameters: ActionDefinitionParameterSchema[]; + /** The permissions required to perform the action. */ + permissions: string[]; +} diff --git a/frontend/src/openapi/models/actionDefinitionsConfigSchema.ts b/frontend/src/openapi/models/actionDefinitionsConfigSchema.ts new file mode 100644 index 00000000000..afbe9d51bc6 --- /dev/null +++ b/frontend/src/openapi/models/actionDefinitionsConfigSchema.ts @@ -0,0 +1,16 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ +import type { ActionDefinitionSchema } from './actionDefinitionSchema'; + +/** + * Configuration of different actions and their parameters. + */ +export interface ActionDefinitionsConfigSchema { + TOGGLE_FEATURE_OFF?: ActionDefinitionSchema; + TOGGLE_FEATURE_ON?: ActionDefinitionSchema; + TOGGLE_FEATURES_OFF_BY_TAG?: ActionDefinitionSchema; + TOGGLE_FEATURES_ON_BY_TAG?: ActionDefinitionSchema; +} diff --git a/frontend/src/openapi/models/addonCreateUpdateSchemaParameters.ts b/frontend/src/openapi/models/addonCreateUpdateSchemaParameters.ts index 0eb5da8946c..ade258cb77c 100644 --- a/frontend/src/openapi/models/addonCreateUpdateSchemaParameters.ts +++ b/frontend/src/openapi/models/addonCreateUpdateSchemaParameters.ts @@ -7,4 +7,4 @@ /** * Parameters for the addon provider. This object has different required and optional properties depending on the provider you choose. Consult the documentation for details. */ -export type AddonCreateUpdateSchemaParameters = { [key: string]: unknown }; +export type AddonCreateUpdateSchemaParameters = { [key: string]: {} }; diff --git a/frontend/src/openapi/models/addonSchemaParameters.ts b/frontend/src/openapi/models/addonSchemaParameters.ts index 64c2523892a..96a85560482 100644 --- a/frontend/src/openapi/models/addonSchemaParameters.ts +++ b/frontend/src/openapi/models/addonSchemaParameters.ts @@ -7,4 +7,4 @@ /** * Parameters for the addon provider. This object has different required and optional properties depending on the provider you choose. */ -export type AddonSchemaParameters = { [key: string]: unknown }; +export type AddonSchemaParameters = { [key: string]: {} }; diff --git a/frontend/src/openapi/models/getProjectInsights401.ts b/frontend/src/openapi/models/getProjectInsights401.ts new file mode 100644 index 00000000000..63ffb1eb516 --- /dev/null +++ b/frontend/src/openapi/models/getProjectInsights401.ts @@ -0,0 +1,14 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +export type GetProjectInsights401 = { + /** The ID of the error instance */ + id?: string; + /** A description of what went wrong. */ + message?: string; + /** The name of the error kind */ + name?: string; +}; diff --git a/frontend/src/openapi/models/getProjectInsights403.ts b/frontend/src/openapi/models/getProjectInsights403.ts new file mode 100644 index 00000000000..f2de9a94515 --- /dev/null +++ b/frontend/src/openapi/models/getProjectInsights403.ts @@ -0,0 +1,14 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +export type GetProjectInsights403 = { + /** The ID of the error instance */ + id?: string; + /** A description of what went wrong. */ + message?: string; + /** The name of the error kind */ + name?: string; +}; diff --git a/frontend/src/openapi/models/getProjectInsights404.ts b/frontend/src/openapi/models/getProjectInsights404.ts new file mode 100644 index 00000000000..1582ffc7736 --- /dev/null +++ b/frontend/src/openapi/models/getProjectInsights404.ts @@ -0,0 +1,14 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +export type GetProjectInsights404 = { + /** The ID of the error instance */ + id?: string; + /** A description of what went wrong. */ + message?: string; + /** The name of the error kind */ + name?: string; +}; diff --git a/frontend/src/openapi/models/index.ts b/frontend/src/openapi/models/index.ts index 7cce221cf7a..a5d2b8422f3 100644 --- a/frontend/src/openapi/models/index.ts +++ b/frontend/src/openapi/models/index.ts @@ -7,6 +7,11 @@ export * from './_exportFormat'; export * from './_exportParams'; export * from './accessOverviewSchema'; +export * from './actionDefinitionParameterSchema'; +export * from './actionDefinitionParameterSchemaName'; +export * from './actionDefinitionParameterSchemaType'; +export * from './actionDefinitionSchema'; +export * from './actionDefinitionsConfigSchema'; export * from './actionEventSchema'; export * from './actionEventSchemaExecutionParams'; export * from './actionEventSchemaState'; @@ -673,6 +678,9 @@ export * from './getProjectEnvironments404'; export * from './getProjectHealthReport401'; export * from './getProjectHealthReport403'; export * from './getProjectHealthReport404'; +export * from './getProjectInsights401'; +export * from './getProjectInsights403'; +export * from './getProjectInsights404'; export * from './getProjectOverview401'; export * from './getProjectOverview403'; export * from './getProjectOverview404'; @@ -827,6 +835,7 @@ export * from './patchFeatureVariants403'; export * from './patchFeatureVariants404'; export * from './patchSchema'; export * from './patchSchemaOp'; +export * from './patchSchemaValue'; export * from './patchesSchema'; export * from './patsSchema'; export * from './permissionSchema'; @@ -867,6 +876,10 @@ export * from './projectCreatedSchema'; export * from './projectCreatedSchemaMode'; export * from './projectDoraMetricsSchema'; export * from './projectEnvironmentSchema'; +export * from './projectInsightsSchema'; +export * from './projectInsightsSchemaChangeRequests'; +export * from './projectInsightsSchemaHealth'; +export * from './projectInsightsSchemaMembers'; export * from './projectOverviewSchema'; export * from './projectOverviewSchemaMode'; export * from './projectRoleSchema'; @@ -1056,6 +1069,7 @@ export * from './toggleFeatureEnvironmentOn400'; export * from './toggleFeatureEnvironmentOn401'; export * from './toggleFeatureEnvironmentOn403'; export * from './toggleFeatureEnvironmentOn404'; +export * from './toggleFeaturesByTagActionSchema'; export * from './toggleMaintenance400'; export * from './toggleMaintenance401'; export * from './toggleMaintenance403'; diff --git a/frontend/src/openapi/models/patchSchema.ts b/frontend/src/openapi/models/patchSchema.ts index 94c0d06918d..7daa7240a9f 100644 --- a/frontend/src/openapi/models/patchSchema.ts +++ b/frontend/src/openapi/models/patchSchema.ts @@ -4,6 +4,7 @@ * See `gen:api` script in package.json */ import type { PatchSchemaOp } from './patchSchemaOp'; +import type { PatchSchemaValue } from './patchSchemaValue'; /** * A [JSON patch](https://www.rfc-editor.org/rfc/rfc6902) operation description @@ -16,5 +17,5 @@ export interface PatchSchema { /** The path to the property to operate on */ path: string; /** The value to add or replace, if performing one of those operations */ - value?: unknown; + value?: PatchSchemaValue; } diff --git a/frontend/src/openapi/models/patchSchemaValue.ts b/frontend/src/openapi/models/patchSchemaValue.ts new file mode 100644 index 00000000000..db10f819283 --- /dev/null +++ b/frontend/src/openapi/models/patchSchemaValue.ts @@ -0,0 +1,10 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * The value to add or replace, if performing one of those operations + */ +export type PatchSchemaValue = {}; diff --git a/frontend/src/openapi/models/projectInsightsSchema.ts b/frontend/src/openapi/models/projectInsightsSchema.ts new file mode 100644 index 00000000000..d85187bff6c --- /dev/null +++ b/frontend/src/openapi/models/projectInsightsSchema.ts @@ -0,0 +1,29 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ +import type { ProjectInsightsSchemaChangeRequests } from './projectInsightsSchemaChangeRequests'; +import type { FeatureTypeCountSchema } from './featureTypeCountSchema'; +import type { ProjectInsightsSchemaHealth } from './projectInsightsSchemaHealth'; +import type { ProjectDoraMetricsSchema } from './projectDoraMetricsSchema'; +import type { ProjectInsightsSchemaMembers } from './projectInsightsSchemaMembers'; +import type { ProjectStatsSchema } from './projectStatsSchema'; + +/** + * A high-level overview of a project insights. It contains information such as project statistics, overall health, types of flags, members overview, change requests overview. + */ +export interface ProjectInsightsSchema { + /** Count of change requests in different stages of the [process](https://docs.getunleash.io/reference/change-requests#change-request-flow). Only for enterprise users. */ + changeRequests?: ProjectInsightsSchemaChangeRequests; + /** The number of features of each type */ + featureTypeCounts: FeatureTypeCountSchema[]; + /** Health summary of the project */ + health: ProjectInsightsSchemaHealth; + /** Lead time (DORA) metrics */ + leadTime: ProjectDoraMetricsSchema; + /** Active/inactive users summary */ + members: ProjectInsightsSchemaMembers; + /** Project statistics */ + stats: ProjectStatsSchema; +} diff --git a/frontend/src/openapi/models/projectInsightsSchemaChangeRequests.ts b/frontend/src/openapi/models/projectInsightsSchemaChangeRequests.ts new file mode 100644 index 00000000000..5ce8e17e6b2 --- /dev/null +++ b/frontend/src/openapi/models/projectInsightsSchemaChangeRequests.ts @@ -0,0 +1,23 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * Count of change requests in different stages of the [process](https://docs.getunleash.io/reference/change-requests#change-request-flow). Only for enterprise users. + */ +export type ProjectInsightsSchemaChangeRequests = { + /** The number of applied change requests */ + applied: number; + /** The number of approved change requests */ + approved: number; + /** The number of rejected change requests */ + rejected: number; + /** The number of change requests awaiting the review */ + reviewRequired: number; + /** The number of scheduled change requests */ + scheduled: number; + /** The number of total change requests in this project */ + total: number; +}; diff --git a/frontend/src/openapi/models/projectInsightsSchemaHealth.ts b/frontend/src/openapi/models/projectInsightsSchemaHealth.ts new file mode 100644 index 00000000000..678cfd1326b --- /dev/null +++ b/frontend/src/openapi/models/projectInsightsSchemaHealth.ts @@ -0,0 +1,19 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * Health summary of the project + */ +export type ProjectInsightsSchemaHealth = { + /** The number of active feature toggles. */ + activeCount: number; + /** The number of potentially stale feature toggles. */ + potentiallyStaleCount: number; + /** An indicator of the [project's health](https://docs.getunleash.io/reference/technical-debt#health-rating) on a scale from 0 to 100 */ + rating: number; + /** The number of stale feature toggles. */ + staleCount: number; +}; diff --git a/frontend/src/openapi/models/projectInsightsSchemaMembers.ts b/frontend/src/openapi/models/projectInsightsSchemaMembers.ts new file mode 100644 index 00000000000..736662cea6b --- /dev/null +++ b/frontend/src/openapi/models/projectInsightsSchemaMembers.ts @@ -0,0 +1,17 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * Active/inactive users summary + */ +export type ProjectInsightsSchemaMembers = { + /** The number of active project members who have used Unleash in the past 60 days */ + active: number; + /** The number of inactive project members who have not used Unleash in the past 60 days */ + inactive: number; + /** The number of total project members in the previous month */ + totalPreviousMonth?: number; +}; diff --git a/frontend/src/openapi/models/resourceLimitsSchema.ts b/frontend/src/openapi/models/resourceLimitsSchema.ts index 1e01897aac0..38ea977a128 100644 --- a/frontend/src/openapi/models/resourceLimitsSchema.ts +++ b/frontend/src/openapi/models/resourceLimitsSchema.ts @@ -9,19 +9,19 @@ */ export interface ResourceLimitsSchema { /** The maximum number of actions per action set allowed. */ - actionSetActions?: number; + actionSetActions: number; /** The maximum number of filters per action set allowed. */ - actionSetFilters?: number; + actionSetFilters: number; /** The maximum number of filter values inside an action set allowed. */ - actionSetFilterValues?: number; + actionSetFilterValues: number; /** The maximum number of action set definitions per project allowed. */ - actionSetsPerProject?: number; + actionSetsPerProject: number; /** The maximum number of values per segment allowed. */ - segmentValues?: number; + segmentValues: number; /** The maximum number of signal endpoints allowed. */ - signalEndpoints?: number; + signalEndpoints: number; /** The maximum number of signal tokens per endpoint allowed. */ - signalTokensPerEndpoint?: number; + signalTokensPerEndpoint: number; /** The maximum number of strategy segments allowed. */ - strategySegments?: number; + strategySegments: number; } diff --git a/frontend/src/openapi/models/toggleFeaturesByTagActionSchema.ts b/frontend/src/openapi/models/toggleFeaturesByTagActionSchema.ts new file mode 100644 index 00000000000..5b3c9d919f6 --- /dev/null +++ b/frontend/src/openapi/models/toggleFeaturesByTagActionSchema.ts @@ -0,0 +1,17 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * Input data required for the action + */ +export interface ToggleFeaturesByTagActionSchema { + /** The environment we want to target */ + environment: string; + /** The project where the feature is located */ + project: string; + /** The tag we want to target, in the following format: `[TAG_TYPE]:[TAG_VALUE]` */ + tag: string; +} From 35531f1b45ebf309cf3ff462cde0d7d673293efd Mon Sep 17 00:00:00 2001 From: kwasniew Date: Wed, 20 Mar 2024 08:06:23 +0100 Subject: [PATCH 2/3] chore: orval with project insights --- .../integrations/IntegrationForm/IntegrationForm.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx b/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx index b9d93acffec..4f5cf7ddf79 100644 --- a/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx +++ b/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx @@ -142,7 +142,11 @@ export const IntegrationForm: VFC = ({ : event.target.value; setFormValues( produce((draft) => { - draft.parameters[param] = value; + if (value === undefined) { + delete draft.parameters[param]; // or set to a default value if required + } else { + draft.parameters[param] = value; + } }), ); }; From 814a480f0acbc09bff7af9e0fe7d8c0bcd006f43 Mon Sep 17 00:00:00 2001 From: kwasniew Date: Wed, 20 Mar 2024 09:08:52 +0100 Subject: [PATCH 3/3] chore: orval with project insights --- .../component/integrations/IntegrationForm/IntegrationForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx b/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx index 4f5cf7ddf79..ea6cdfde804 100644 --- a/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx +++ b/frontend/src/component/integrations/IntegrationForm/IntegrationForm.tsx @@ -143,7 +143,7 @@ export const IntegrationForm: VFC = ({ setFormValues( produce((draft) => { if (value === undefined) { - delete draft.parameters[param]; // or set to a default value if required + delete draft.parameters[param]; } else { draft.parameters[param] = value; }