mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
chore: update Frontend schema (#8037)
update types, fix frontend types issues in insights and archive
This commit is contained in:
parent
e4fcb252d1
commit
76ffdb2cd3
@ -21,7 +21,7 @@ import { LinkCell } from 'component/common/Table/cells/LinkCell/LinkCell';
|
||||
import { ArchivedFeatureActionCell } from 'component/archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureActionCell';
|
||||
import { featuresPlaceholder } from 'component/feature/FeatureToggleList/FeatureToggleListTable';
|
||||
import theme from 'themes/theme';
|
||||
import type { FeatureSchema } from 'openapi';
|
||||
import type { ArchivedFeatureSchema } from 'openapi';
|
||||
import { useSearch } from 'hooks/useSearch';
|
||||
import { FeatureArchivedCell } from './FeatureArchivedCell/FeatureArchivedCell';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
@ -36,7 +36,7 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||
import { ArchivedFeatureReviveConfirm } from './ArchivedFeatureActionCell/ArchivedFeatureReviveConfirm/ArchivedFeatureReviveConfirm';
|
||||
|
||||
export interface IFeaturesArchiveTableProps {
|
||||
archivedFeatures: FeatureSchema[];
|
||||
archivedFeatures: ArchivedFeatureSchema[];
|
||||
title: string;
|
||||
refetch: () => void;
|
||||
loading: boolean;
|
||||
|
@ -1,25 +1,16 @@
|
||||
import useSWR from 'swr';
|
||||
import type { FeatureSchema, FeaturesSchema } from 'openapi';
|
||||
import type { ArchivedFeaturesSchema } from 'openapi';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
import { formatApiPath } from 'utils/formatPath';
|
||||
|
||||
export interface IUseFeaturesArchiveOutput {
|
||||
archivedFeatures?: FeatureSchema[];
|
||||
refetchArchived: () => void;
|
||||
loading: boolean;
|
||||
error?: Error;
|
||||
}
|
||||
|
||||
const fetcher = (path: string) => {
|
||||
return fetch(path)
|
||||
.then(handleErrorResponses('Feature flag archive'))
|
||||
.then((res) => res.json());
|
||||
};
|
||||
|
||||
export const useFeaturesArchive = (
|
||||
projectId?: string,
|
||||
): IUseFeaturesArchiveOutput => {
|
||||
const { data, error, mutate, isLoading } = useSWR<FeaturesSchema>(
|
||||
export const useFeaturesArchive = (projectId?: string) => {
|
||||
const { data, error, mutate, isLoading } = useSWR<ArchivedFeaturesSchema>(
|
||||
formatApiPath(
|
||||
projectId
|
||||
? `/api/admin/archive/features/${projectId}`
|
||||
|
@ -2,20 +2,16 @@ import useSWR, { mutate, type SWRConfiguration } from 'swr';
|
||||
import { useCallback } from 'react';
|
||||
import { formatApiPath } from 'utils/formatPath';
|
||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||
import type { InstanceInsightsSchema } from 'openapi';
|
||||
|
||||
interface IUseInsightsDataOutput {
|
||||
insights: InstanceInsightsSchema;
|
||||
refetchInsights: () => void;
|
||||
loading: boolean;
|
||||
error?: Error;
|
||||
}
|
||||
import type {
|
||||
InstanceInsightsSchema,
|
||||
GetInstanceInsightsParams,
|
||||
} from 'openapi';
|
||||
|
||||
export const useInsights = (
|
||||
from = '',
|
||||
to = '',
|
||||
from: GetInstanceInsightsParams['from'] = '',
|
||||
to: GetInstanceInsightsParams['to'] = '',
|
||||
options?: SWRConfiguration,
|
||||
): IUseInsightsDataOutput => {
|
||||
) => {
|
||||
const path = formatApiPath(`api/admin/insights?from=${from}&to=${to}`);
|
||||
|
||||
const { data, error } = useSWR<InstanceInsightsSchema>(
|
||||
@ -29,13 +25,15 @@ export const useInsights = (
|
||||
}, [path]);
|
||||
|
||||
return {
|
||||
insights: data || {
|
||||
userTrends: [],
|
||||
flagTrends: [],
|
||||
projectFlagTrends: [],
|
||||
metricsSummaryTrends: [],
|
||||
environmentTypeTrends: [],
|
||||
},
|
||||
insights:
|
||||
data ||
|
||||
({
|
||||
userTrends: [],
|
||||
flagTrends: [],
|
||||
projectFlagTrends: [],
|
||||
metricsSummaryTrends: [],
|
||||
environmentTypeTrends: [],
|
||||
} as InstanceInsightsSchema),
|
||||
refetchInsights,
|
||||
loading: !error && !data,
|
||||
error,
|
||||
|
42
frontend/src/openapi/models/archivedFeatureSchema.ts
Normal file
42
frontend/src/openapi/models/archivedFeatureSchema.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
import type { ArchivedFeatureSchemaEnvironmentsItem } from './archivedFeatureSchemaEnvironmentsItem';
|
||||
|
||||
/**
|
||||
* An archived project feature flag definition
|
||||
*/
|
||||
export interface ArchivedFeatureSchema {
|
||||
/** The date the feature was archived */
|
||||
archivedAt?: string;
|
||||
/** The date the feature was created */
|
||||
createdAt?: string;
|
||||
/**
|
||||
* Detailed description of the feature
|
||||
* @nullable
|
||||
*/
|
||||
description?: string | null;
|
||||
/**
|
||||
* The list of environments where the feature can be used
|
||||
* @deprecated
|
||||
*/
|
||||
environments?: ArchivedFeatureSchemaEnvironmentsItem[];
|
||||
/** `true` if the impression data collection is enabled for the feature, otherwise `false`. */
|
||||
impressionData?: boolean;
|
||||
/**
|
||||
* The date when metrics where last collected for the feature. This field was deprecated in v5, use the one in featureEnvironmentSchema
|
||||
* @deprecated
|
||||
* @nullable
|
||||
*/
|
||||
lastSeenAt?: string | null;
|
||||
/** Unique feature name */
|
||||
name: string;
|
||||
/** Name of the project the feature belongs to */
|
||||
project: string;
|
||||
/** `true` if the feature is stale based on the age and feature type, otherwise `false`. */
|
||||
stale?: boolean;
|
||||
/** Type of the flag e.g. experiment, kill-switch, release, operational, permission */
|
||||
type?: string;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
export type ArchivedFeatureSchemaEnvironmentsItem = {
|
||||
/** `true` if the feature is enabled for the environment, otherwise `false`. */
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* The date when metrics where last collected for the feature environment
|
||||
* @nullable
|
||||
*/
|
||||
lastSeenAt?: string | null;
|
||||
/** The name of the environment */
|
||||
name?: string;
|
||||
};
|
16
frontend/src/openapi/models/archivedFeaturesSchema.ts
Normal file
16
frontend/src/openapi/models/archivedFeaturesSchema.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
import type { ArchivedFeatureSchema } from './archivedFeatureSchema';
|
||||
|
||||
/**
|
||||
* A list of archived features
|
||||
*/
|
||||
export interface ArchivedFeaturesSchema {
|
||||
/** A list of features */
|
||||
features: ArchivedFeatureSchema[];
|
||||
/** The version of the feature's schema */
|
||||
version: number;
|
||||
}
|
@ -115,6 +115,9 @@ export * from './archiveFeatures415';
|
||||
export * from './archiveProject400';
|
||||
export * from './archiveProject401';
|
||||
export * from './archiveProject403';
|
||||
export * from './archivedFeatureSchema';
|
||||
export * from './archivedFeatureSchemaEnvironmentsItem';
|
||||
export * from './archivedFeaturesSchema';
|
||||
export * from './bannerSchema';
|
||||
export * from './bannersSchema';
|
||||
export * from './batchFeaturesSchema';
|
||||
@ -576,7 +579,6 @@ export * from './featureTypesSchema';
|
||||
export * from './featureTypesSchemaVersion';
|
||||
export * from './featureUsageSchema';
|
||||
export * from './featureVariantsSchema';
|
||||
export * from './featuresSchema';
|
||||
export * from './feedbackCreateSchema';
|
||||
export * from './feedbackListSchema';
|
||||
export * from './feedbackResponseSchema';
|
||||
@ -801,6 +803,7 @@ export * from './inactiveUserSchema';
|
||||
export * from './inactiveUsersSchema';
|
||||
export * from './instanceAdminStatsSchema';
|
||||
export * from './instanceAdminStatsSchemaActiveUsers';
|
||||
export * from './instanceAdminStatsSchemaApiTokens';
|
||||
export * from './instanceAdminStatsSchemaClientAppsItem';
|
||||
export * from './instanceAdminStatsSchemaClientAppsItemRange';
|
||||
export * from './instanceAdminStatsSchemaPreviousDayMetricsBucketsCount';
|
||||
@ -808,11 +811,9 @@ export * from './instanceAdminStatsSchemaProductionChanges';
|
||||
export * from './instanceInsightsSchema';
|
||||
export * from './instanceInsightsSchemaEnvironmentTypeTrendsItem';
|
||||
export * from './instanceInsightsSchemaFlagTrendsItem';
|
||||
export * from './instanceInsightsSchemaFlags';
|
||||
export * from './instanceInsightsSchemaMetricsSummaryTrendsItem';
|
||||
export * from './instanceInsightsSchemaProjectFlagTrendsItem';
|
||||
export * from './instanceInsightsSchemaUserTrendsItem';
|
||||
export * from './instanceInsightsSchemaUsers';
|
||||
export * from './integrationEventSchema';
|
||||
export * from './integrationEventSchemaDetails';
|
||||
export * from './integrationEventSchemaState';
|
||||
@ -931,6 +932,9 @@ export * from './projectCreatedSchemaChangeRequestEnvironmentsItem';
|
||||
export * from './projectCreatedSchemaMode';
|
||||
export * from './projectDoraMetricsSchema';
|
||||
export * from './projectEnvironmentSchema';
|
||||
export * from './projectFeatureEnvironmentSchema';
|
||||
export * from './projectFeatureSchema';
|
||||
export * from './projectFeaturesSchema';
|
||||
export * from './projectFlagCreatorsSchema';
|
||||
export * from './projectFlagCreatorsSchemaItem';
|
||||
export * from './projectInsightsSchema';
|
||||
|
@ -4,6 +4,7 @@
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
import type { InstanceAdminStatsSchemaActiveUsers } from './instanceAdminStatsSchemaActiveUsers';
|
||||
import type { InstanceAdminStatsSchemaApiTokens } from './instanceAdminStatsSchemaApiTokens';
|
||||
import type { InstanceAdminStatsSchemaClientAppsItem } from './instanceAdminStatsSchemaClientAppsItem';
|
||||
import type { InstanceAdminStatsSchemaPreviousDayMetricsBucketsCount } from './instanceAdminStatsSchemaPreviousDayMetricsBucketsCount';
|
||||
import type { InstanceAdminStatsSchemaProductionChanges } from './instanceAdminStatsSchemaProductionChanges';
|
||||
@ -14,6 +15,8 @@ import type { InstanceAdminStatsSchemaProductionChanges } from './instanceAdminS
|
||||
export interface InstanceAdminStatsSchema {
|
||||
/** The number of active users in the last 7, 30 and 90 days */
|
||||
activeUsers?: InstanceAdminStatsSchemaActiveUsers;
|
||||
/** The number of API tokens in Unleash, split by type */
|
||||
apiTokens?: InstanceAdminStatsSchemaApiTokens;
|
||||
/** A count of connected applications in the last week, last month and all time since last restart */
|
||||
clientApps?: InstanceAdminStatsSchemaClientAppsItem[];
|
||||
/**
|
||||
@ -48,6 +51,21 @@ export interface InstanceAdminStatsSchema {
|
||||
groups?: number;
|
||||
/** A unique identifier for this instance. Generated by the database migration scripts at first run. Typically a UUID. */
|
||||
instanceId: string;
|
||||
/**
|
||||
* The highest number of constraints used on a single strategy.
|
||||
* @minimum 0
|
||||
*/
|
||||
maxConstraints?: number;
|
||||
/**
|
||||
* The highest number of constraint values used on a single constraint.
|
||||
* @minimum 0
|
||||
*/
|
||||
maxConstraintValues?: number;
|
||||
/**
|
||||
* The highest number of strategies used on a single feature flag in a single environment.
|
||||
* @minimum 0
|
||||
*/
|
||||
maxEnvironmentStrategies?: number;
|
||||
/** Whether or not OIDC authentication is enabled for this instance */
|
||||
OIDCenabled?: boolean;
|
||||
/** The number client metrics buckets records recorded in the previous day. # features * # apps * # envs * # hours with metrics */
|
||||
@ -92,20 +110,4 @@ export interface InstanceAdminStatsSchema {
|
||||
versionEnterprise?: string;
|
||||
/** The version of Unleash OSS that is bundled in this instance */
|
||||
versionOSS?: string;
|
||||
|
||||
/** A breakdown of API tokens that exist in this instance */
|
||||
apiTokens: {
|
||||
client: number;
|
||||
admin: number;
|
||||
frontend: number;
|
||||
};
|
||||
|
||||
// The highest number of strategies used on a single feature flag in a single environment.
|
||||
maxEnvironmentStrategies: number;
|
||||
|
||||
// The highest number of constraints used on a single strategy.
|
||||
maxConstraints: number;
|
||||
|
||||
// The highest number of constraint values used on a single constraint.
|
||||
maxConstraintValues: number;
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
/**
|
||||
* The number of API tokens in Unleash, split by type
|
||||
*/
|
||||
export type InstanceAdminStatsSchemaApiTokens = {
|
||||
/**
|
||||
* The number of admin tokens.
|
||||
* @minimum 0
|
||||
*/
|
||||
admin?: number;
|
||||
/**
|
||||
* The number of client tokens.
|
||||
* @minimum 0
|
||||
*/
|
||||
client?: number;
|
||||
/**
|
||||
* The number of frontend tokens.
|
||||
* @minimum 0
|
||||
*/
|
||||
frontend?: number;
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
/**
|
||||
* High level flag count statistics
|
||||
*/
|
||||
export type InstanceInsightsSchemaFlags = {
|
||||
/** The number of non-archived flags */
|
||||
total: number;
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
/**
|
||||
* High level user count statistics
|
||||
*/
|
||||
export type InstanceInsightsSchemaUsers = {
|
||||
/** The number of active Unleash users who have user Unleash in the past 60 days */
|
||||
active: number;
|
||||
/** The number of inactive Unleash users who have not used Unleash in the past 60 days. */
|
||||
inactive: number;
|
||||
/** The number of actual Unleash users */
|
||||
total: number;
|
||||
};
|
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
|
||||
/**
|
||||
* A detailed description of the feature environment
|
||||
*/
|
||||
export interface ProjectFeatureEnvironmentSchema {
|
||||
/** `true` if the feature is enabled for the environment, otherwise `false`. */
|
||||
enabled: boolean;
|
||||
/** Whether the feature has any enabled strategies defined. */
|
||||
hasEnabledStrategies?: boolean;
|
||||
/** Whether the feature has any strategies defined. */
|
||||
hasStrategies?: boolean;
|
||||
/**
|
||||
* The date when metrics where last collected for the feature environment
|
||||
* @nullable
|
||||
*/
|
||||
lastSeenAt: string | null;
|
||||
/** The name of the environment */
|
||||
name: string;
|
||||
/** The sort order of the feature environment in the feature environments list */
|
||||
sortOrder: number;
|
||||
/** The type of the environment */
|
||||
type: string;
|
||||
/** The number of defined variants */
|
||||
variantCount: number;
|
||||
}
|
43
frontend/src/openapi/models/projectFeatureSchema.ts
Normal file
43
frontend/src/openapi/models/projectFeatureSchema.ts
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Generated by Orval
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
import type { ProjectFeatureEnvironmentSchema } from './projectFeatureEnvironmentSchema';
|
||||
import type { TagSchema } from './tagSchema';
|
||||
|
||||
/**
|
||||
* A project feature flag definition
|
||||
*/
|
||||
export interface ProjectFeatureSchema {
|
||||
/** The date the feature was created */
|
||||
createdAt: string;
|
||||
/**
|
||||
* Detailed description of the feature
|
||||
* @nullable
|
||||
*/
|
||||
description: string | null;
|
||||
/** The list of environments where the feature can be used */
|
||||
environments: ProjectFeatureEnvironmentSchema[];
|
||||
/** `true` if the feature was favorited, otherwise `false`. */
|
||||
favorite: boolean;
|
||||
/** `true` if the impression data collection is enabled for the feature, otherwise `false`. */
|
||||
impressionData: boolean;
|
||||
/**
|
||||
* The date and time when metrics where last collected for this flag in any environment. This field was deprecated in v5. You should instead use the `lastSeenAt` property on the individual environments listed under the `environments` property.
|
||||
* @deprecated
|
||||
* @nullable
|
||||
*/
|
||||
lastSeenAt: string | null;
|
||||
/** Unique feature name */
|
||||
name: string;
|
||||
/** `true` if the feature is stale based on the age and feature type, otherwise `false`. */
|
||||
stale: boolean;
|
||||
/**
|
||||
* The list of feature tags
|
||||
* @nullable
|
||||
*/
|
||||
tags?: TagSchema[] | null;
|
||||
/** Type of the flag e.g. experiment, kill-switch, release, operational, permission */
|
||||
type: string;
|
||||
}
|
@ -3,15 +3,15 @@
|
||||
* Do not edit manually.
|
||||
* See `gen:api` script in package.json
|
||||
*/
|
||||
import type { FeatureSchema } from './featureSchema';
|
||||
import type { ProjectFeatureSchema } from './projectFeatureSchema';
|
||||
|
||||
/**
|
||||
* A list of features
|
||||
* A list of features in a project
|
||||
* @deprecated
|
||||
*/
|
||||
export interface FeaturesSchema {
|
||||
export interface ProjectFeaturesSchema {
|
||||
/** A list of features */
|
||||
features: FeatureSchema[];
|
||||
features: ProjectFeatureSchema[];
|
||||
/** The version of the feature's schema */
|
||||
version: number;
|
||||
}
|
@ -13,6 +13,11 @@ import type { ProjectStatsSchema } from './projectStatsSchema';
|
||||
* A high-level overview of a project. It contains information such as project statistics, the name of the project, what members and what features it contains, etc.
|
||||
*/
|
||||
export interface ProjectOverviewSchema {
|
||||
/**
|
||||
* When the project was archived.
|
||||
* @nullable
|
||||
*/
|
||||
archivedAt?: string | null;
|
||||
/**
|
||||
* When the project was created.
|
||||
* @nullable
|
||||
|
@ -15,14 +15,21 @@ export interface ProjectSchema {
|
||||
* @nullable
|
||||
*/
|
||||
archivedAt?: string | null;
|
||||
/** The average time from when a feature was created to when it was enabled in the "production" environment during the current window */
|
||||
/**
|
||||
* The average time from when a feature was created to when it was enabled in the "production" environment during the current window
|
||||
* @deprecated
|
||||
*/
|
||||
avgTimeToProduction?: number;
|
||||
/** When this project was created. */
|
||||
createdAt?: string;
|
||||
/** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */
|
||||
/**
|
||||
* A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy
|
||||
* @deprecated
|
||||
*/
|
||||
defaultStickiness?: string;
|
||||
/**
|
||||
* Additional information about the project
|
||||
* @deprecated
|
||||
* @nullable
|
||||
*/
|
||||
description?: string | null;
|
||||
@ -42,12 +49,19 @@ export interface ProjectSchema {
|
||||
name: string;
|
||||
/** The users and/or groups that have the "owner" role in this project. If no such users or groups exist, the list will contain the "system" owner instead. */
|
||||
owners?: ProjectSchemaOwners;
|
||||
/** The number of potentially stale features this project has */
|
||||
/**
|
||||
* The number of potentially stale features this project has
|
||||
* @deprecated
|
||||
*/
|
||||
potentiallyStaleFeatureCount?: number;
|
||||
/** The number of stale features this project has */
|
||||
/**
|
||||
* The number of stale features this project has
|
||||
* @deprecated
|
||||
*/
|
||||
staleFeatureCount?: number;
|
||||
/**
|
||||
* When this project was last updated.
|
||||
* @deprecated
|
||||
* @nullable
|
||||
*/
|
||||
updatedAt?: string | null;
|
||||
|
@ -7,7 +7,6 @@ export const archivedFeaturesSchema = {
|
||||
additionalProperties: false,
|
||||
required: ['version', 'features'],
|
||||
description: 'A list of archived features',
|
||||
deprecated: true,
|
||||
properties: {
|
||||
version: {
|
||||
type: 'integer',
|
||||
|
Loading…
Reference in New Issue
Block a user