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

chore: generate orval for event creators (#7823)

Updates our orval config to include event creator data
This commit is contained in:
Thomas Heartman 2024-08-12 15:07:26 +02:00 committed by GitHub
parent b194393dae
commit 245bdeae1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 279 additions and 26 deletions

View File

@ -1,4 +1,3 @@
import type React from 'react';
import {
FormControl,
InputLabel,
@ -22,12 +21,13 @@ export interface ISelectOption {
sx?: SxProps<Theme>;
}
export interface IGeneralSelectProps extends Omit<SelectProps, 'onChange'> {
export interface IGeneralSelectProps<T extends string = string>
extends Omit<SelectProps, 'onChange'> {
name?: string;
value?: string;
value?: T;
label?: string;
options: ISelectOption[];
onChange: (key: string) => void;
onChange: (key: T) => void;
disabled?: boolean;
fullWidth?: boolean;
classes?: any;
@ -39,9 +39,9 @@ const StyledFormControl = styled(FormControl)({
maxWidth: '100%',
});
const GeneralSelect: React.FC<IGeneralSelectProps> = ({
function GeneralSelect<T extends string = string>({
name,
value = '',
value,
label = '',
options,
onChange,
@ -52,10 +52,10 @@ const GeneralSelect: React.FC<IGeneralSelectProps> = ({
fullWidth,
visuallyHideLabel,
...rest
}) => {
}: IGeneralSelectProps<T>) {
const onSelectChange = (event: SelectChangeEvent) => {
event.preventDefault();
onChange(String(event.target.value));
onChange(String(event.target.value) as T);
};
return (
@ -78,7 +78,7 @@ const GeneralSelect: React.FC<IGeneralSelectProps> = ({
className={className}
label={visuallyHideLabel ? '' : label}
id={id}
value={value}
value={value ?? ''}
MenuProps={{
sx: {
'.MuiPopover-paper.MuiMenu-paper': {
@ -104,6 +104,6 @@ const GeneralSelect: React.FC<IGeneralSelectProps> = ({
</Select>
</StyledFormControl>
);
};
}
export default GeneralSelect;

View File

@ -24,14 +24,15 @@ import React from 'react';
import { useAuthPermissions } from 'hooks/api/getters/useAuth/useAuthPermissions';
import type { FeatureNamingType } from 'interfaces/project';
import { FeatureNamingPatternInfo } from '../FeatureNamingPatternInfo/FeatureNamingPatternInfo';
import type { CreateFeatureSchemaType } from 'openapi';
interface IFeatureToggleForm {
type: string;
type: CreateFeatureSchemaType;
name: string;
description: string;
project: string;
impressionData: boolean;
setType: React.Dispatch<React.SetStateAction<string>>;
setType: React.Dispatch<React.SetStateAction<CreateFeatureSchemaType>>;
setName: React.Dispatch<React.SetStateAction<string>>;
setDescription: React.Dispatch<React.SetStateAction<string>>;
setProject: React.Dispatch<React.SetStateAction<string>>;

View File

@ -3,10 +3,14 @@ import GeneralSelect, {
type ISelectOption,
type IGeneralSelectProps,
} from 'component/common/GeneralSelect/GeneralSelect';
import type { CreateFeatureSchemaType } from 'openapi';
interface IFeatureTypeSelectProps
extends Omit<IGeneralSelectProps, 'options' | 'value'> {
value: string;
extends Omit<
IGeneralSelectProps<CreateFeatureSchemaType>,
'options' | 'value'
> {
value: CreateFeatureSchemaType;
editable: boolean;
}

View File

@ -4,13 +4,14 @@ import useQueryParams from 'hooks/useQueryParams';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { formatUnknownError } from 'utils/formatUnknownError';
import type { ITag } from 'interfaces/tags';
import type { CreateFeatureSchema, CreateFeatureSchemaType } from 'openapi';
const useFeatureForm = (
initialName = '',
initialType = 'release',
initialProject = 'default',
initialDescription = '',
initialImpressionData = false,
initialName: string = '',
initialType: CreateFeatureSchemaType = 'release',
initialProject: string = 'default',
initialDescription: string = '',
initialImpressionData: boolean = false,
) => {
const projectId = useRequiredPathParam('projectId');
const params = useQueryParams();
@ -49,7 +50,7 @@ const useFeatureForm = (
setImpressionData(initialImpressionData);
}, [initialImpressionData]);
const getTogglePayload = () => {
const getTogglePayload = (): CreateFeatureSchema => {
const tagsPayload = tags.size > 0 ? { tags: Array.from(tags) } : {};
return {
type,

View File

@ -17,6 +17,7 @@ describe('useFilteredFlagTrends', () => {
users: 1,
date: '',
timeToProduction: 4,
health: 100,
},
{
week: '2024-01',
@ -28,6 +29,7 @@ describe('useFilteredFlagTrends', () => {
users: 2,
date: '',
timeToProduction: 5,
health: 100,
},
{
week: '2024-02',
@ -39,6 +41,7 @@ describe('useFilteredFlagTrends', () => {
users: 1,
date: '',
timeToProduction: 4,
health: 75,
},
{
week: '2024-02',
@ -50,6 +53,7 @@ describe('useFilteredFlagTrends', () => {
users: 3,
date: '',
timeToProduction: 2,
health: 80,
},
],
{ total: 1 } as unknown as InstanceInsightsSchemaUsers,
@ -82,6 +86,7 @@ describe('useFilteredFlagTrends', () => {
users: 0,
date: '',
timeToProduction: 4,
health: 100,
},
],
{ total: 1 } as unknown as InstanceInsightsSchemaUsers,
@ -114,6 +119,7 @@ describe('useFilteredFlagTrends', () => {
users: 0,
date: '',
timeToProduction: 2,
health: 100,
},
{
week: '2024-01',
@ -125,6 +131,7 @@ describe('useFilteredFlagTrends', () => {
users: 3,
date: '',
timeToProduction: 5,
health: 100,
},
],
{ total: 1 } as unknown as InstanceInsightsSchemaUsers,
@ -157,6 +164,7 @@ describe('useFilteredFlagTrends', () => {
users: 0,
date: '',
timeToProduction: 0,
health: 100,
},
],
{ total: 1 } as unknown as InstanceInsightsSchemaUsers,
@ -189,6 +197,7 @@ describe('useFilteredFlagTrends', () => {
users: 0,
date: '',
timeToProduction: 0,
health: 100,
},
{
week: '2024-01',
@ -200,6 +209,7 @@ describe('useFilteredFlagTrends', () => {
users: 0,
date: '',
timeToProduction: 0,
health: 100,
},
{
week: '2024-01',
@ -211,6 +221,7 @@ describe('useFilteredFlagTrends', () => {
users: 0,
date: '',
timeToProduction: 5,
health: 100,
},
],
{ total: 1 } as unknown as InstanceInsightsSchemaUsers,

View File

@ -3,7 +3,7 @@ import type { IFeatureToggle } from 'interfaces/featureToggle';
export const emptyFeature: IFeatureToggle = {
environments: [],
name: '',
type: '',
type: 'release',
stale: false,
archived: false,
createdAt: '',

View File

@ -1,3 +1,4 @@
import type { CreateFeatureSchemaType } from 'openapi';
import type { IFeatureStrategy } from './strategy';
import type { ITag } from './tags';
@ -60,10 +61,9 @@ export interface IFeatureToggle {
description?: string;
environments: IFeatureEnvironment[];
name: string;
favorite: boolean;
project: string;
type: string;
type: CreateFeatureSchemaType;
variants: IFeatureVariant[];
impressionData: boolean;
strategies?: IFeatureStrategy[];

View File

@ -4,6 +4,7 @@
* See `gen:api` script in package.json
*/
import type { TagSchema } from './tagSchema';
import type { CreateFeatureSchemaType } from './createFeatureSchemaType';
/**
* Data used to create a new feature flag.
@ -21,5 +22,5 @@ export interface CreateFeatureSchema {
/** Tags to add to the feature. */
tags?: TagSchema[];
/** The feature flag's [type](https://docs.getunleash.io/reference/feature-toggle-types). One of experiment, kill-switch, release, operational, or permission */
type?: string;
type?: CreateFeatureSchemaType;
}

View File

@ -0,0 +1,20 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
/**
* The feature flag's [type](https://docs.getunleash.io/reference/feature-toggle-types). One of experiment, kill-switch, release, operational, or permission
*/
export type CreateFeatureSchemaType =
(typeof CreateFeatureSchemaType)[keyof typeof CreateFeatureSchemaType];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CreateFeatureSchemaType = {
experiment: 'experiment',
'kill-switch': 'kill-switch',
release: 'release',
operational: 'operational',
permission: 'permission',
} as const;

View File

@ -59,6 +59,7 @@ export const DeprecatedSearchEventsSchemaType = {
'project-created': 'project-created',
'project-updated': 'project-updated',
'project-deleted': 'project-deleted',
'project-archived': 'project-archived',
'project-import': 'project-import',
'project-user-added': 'project-user-added',
'project-user-removed': 'project-user-removed',

View File

@ -0,0 +1,11 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { EventCreatorsSchemaItem } from './eventCreatorsSchemaItem';
/**
* A list of event creators
*/
export type EventCreatorsSchema = EventCreatorsSchemaItem[];

View File

@ -0,0 +1,12 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type EventCreatorsSchemaItem = {
/** The user id. */
id: number;
/** Name of the user. If the user has no set name, the API falls back to using the user's username (if they have one) or email (if neither name or username is set). */
name: string;
};

View File

@ -59,6 +59,7 @@ export const EventSchemaType = {
'project-created': 'project-created',
'project-updated': 'project-updated',
'project-deleted': 'project-deleted',
'project-archived': 'project-archived',
'project-import': 'project-import',
'project-user-added': 'project-user-added',
'project-user-removed': 'project-user-removed',

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GenerateNewToken401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GenerateNewToken403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GenerateNewToken404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GetEventCreators401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GetEventCreators403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GetEventCreators404 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type GetScimSettings401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -352,6 +352,7 @@ export * from './createFeature404';
export * from './createFeature415';
export * from './createFeatureNamingPatternSchema';
export * from './createFeatureSchema';
export * from './createFeatureSchemaType';
export * from './createFeatureStrategySchema';
export * from './createFeedback400';
export * from './createFeedback401';
@ -520,6 +521,8 @@ export * from './environmentProjectSchema';
export * from './environmentSchema';
export * from './environmentsProjectSchema';
export * from './environmentsSchema';
export * from './eventCreatorsSchema';
export * from './eventCreatorsSchemaItem';
export * from './eventSchema';
export * from './eventSchemaData';
export * from './eventSchemaPreData';
@ -581,6 +584,9 @@ export * from './frontendApiFeatureSchemaVariant';
export * from './frontendApiFeatureSchemaVariantPayload';
export * from './frontendApiFeatureSchemaVariantPayloadType';
export * from './frontendApiFeaturesSchema';
export * from './generateNewToken401';
export * from './generateNewToken403';
export * from './generateNewToken404';
export * from './getAccessOverview401';
export * from './getAccessOverview403';
export * from './getAccessOverview415';
@ -621,6 +627,9 @@ export * from './getEnvironment404';
export * from './getEnvironmentFeatureVariants401';
export * from './getEnvironmentFeatureVariants403';
export * from './getEnvironmentFeatureVariants404';
export * from './getEventCreators401';
export * from './getEventCreators403';
export * from './getEventCreators404';
export * from './getEvents401';
export * from './getEventsForToggle401';
export * from './getEventsParams';
@ -724,6 +733,7 @@ export * from './getSamlSettings400';
export * from './getSamlSettings401';
export * from './getSamlSettings403';
export * from './getScheduledChangeRequests404';
export * from './getScimSettings401';
export * from './getSegment404';
export * from './getServiceAccountPermissions401';
export * from './getServiceAccountPermissions403';
@ -1058,6 +1068,10 @@ export * from './setSamlSettings400';
export * from './setSamlSettings401';
export * from './setSamlSettings403';
export * from './setSamlSettings415';
export * from './setScimSettings400';
export * from './setScimSettings401';
export * from './setScimSettings403';
export * from './setScimSettings415';
export * from './setScimSettingsSchema';
export * from './setSimpleSettings400';
export * from './setSimpleSettings401';
@ -1163,6 +1177,7 @@ export * from './updateFeature403';
export * from './updateFeature404';
export * from './updateFeature415';
export * from './updateFeatureSchema';
export * from './updateFeatureSchemaType';
export * from './updateFeatureStrategy400';
export * from './updateFeatureStrategy401';
export * from './updateFeatureStrategy403';

View File

@ -10,7 +10,7 @@ export type InstanceInsightsSchemaProjectFlagTrendsItem = {
/** A UTC date when the stats were captured. Time is the very end of a given day. */
date: string;
/** An indicator of the [project's health](https://docs.getunleash.io/reference/technical-debt#health-rating) on a scale from 0 to 100 */
health?: number;
health: number;
/** The number of time calculated potentially stale flags on a particular day */
potentiallyStale: number;
/** Project id of the project the flag trends belong to */

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type SetScimSettings400 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type SetScimSettings401 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type SetScimSettings403 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
export type SetScimSettings415 = {
/** The ID of the error instance */
id?: string;
/** A description of what went wrong. */
message?: string;
/** The name of the error kind */
name?: string;
};

View File

@ -3,6 +3,7 @@
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { UpdateFeatureSchemaType } from './updateFeatureSchemaType';
/**
* Data used for updating a feature flag
@ -17,5 +18,5 @@ export interface UpdateFeatureSchema {
/** `true` if the feature is archived */
stale?: boolean;
/** Type of the flag e.g. experiment, kill-switch, release, operational, permission */
type?: string;
type?: UpdateFeatureSchemaType;
}

View File

@ -0,0 +1,20 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
/**
* Type of the flag e.g. experiment, kill-switch, release, operational, permission
*/
export type UpdateFeatureSchemaType =
(typeof UpdateFeatureSchemaType)[keyof typeof UpdateFeatureSchemaType];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const UpdateFeatureSchemaType = {
experiment: 'experiment',
'kill-switch': 'kill-switch',
release: 'release',
operational: 'operational',
permission: 'permission',
} as const;