mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-27 11:02:16 +01:00
<!-- 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! ❤️ --> When reordering strategies for a feature environment: - Adds stop when CR are enabled - Emits an event ## 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>
162 lines
5.1 KiB
TypeScript
162 lines
5.1 KiB
TypeScript
import { FromSchema } from 'json-schema-to-ts';
|
|
import { tagSchema } from './tag-schema';
|
|
import { IEventTypes } from '../../types';
|
|
import { variantSchema } from './variant-schema';
|
|
|
|
const eventDataSchema = {
|
|
type: 'object',
|
|
additionalProperties: true,
|
|
properties: {
|
|
name: {
|
|
type: 'string',
|
|
description:
|
|
'Name of the feature toggle/strategy/environment that this event relates to',
|
|
example: 'my.first.toggle',
|
|
nullable: true,
|
|
},
|
|
description: {
|
|
type: 'string',
|
|
description: 'The description of the object this event relates to',
|
|
example: 'Toggle description',
|
|
nullable: true,
|
|
},
|
|
type: {
|
|
type: 'string',
|
|
description:
|
|
'If this event relates to a feature toggle, the type of feature toggle.',
|
|
example: 'release',
|
|
nullable: true,
|
|
},
|
|
project: {
|
|
type: 'string',
|
|
description: 'The project this event relates to',
|
|
example: 'default',
|
|
nullable: true,
|
|
},
|
|
stale: {
|
|
description: 'Is the feature toggle this event relates to stale',
|
|
type: 'boolean',
|
|
example: true,
|
|
nullable: true,
|
|
},
|
|
variants: {
|
|
description: 'Variants configured for this toggle',
|
|
type: 'array',
|
|
items: {
|
|
$ref: '#/components/schemas/variantSchema',
|
|
},
|
|
nullable: true,
|
|
},
|
|
createdAt: {
|
|
type: 'string',
|
|
format: 'date-time',
|
|
description:
|
|
'The time the event happened as a RFC 3339-conformant timestamp.',
|
|
example: '2023-07-05T12:56:00.000Z',
|
|
nullable: true,
|
|
},
|
|
lastSeenAt: {
|
|
type: 'string',
|
|
format: 'date-time',
|
|
description: 'The time the feature was last seen',
|
|
example: '2023-07-05T12:56:00.000Z',
|
|
nullable: true,
|
|
},
|
|
impressionData: {
|
|
description:
|
|
'Should [impression events](https://docs.getunleash.io/reference/impression-data) activate for this feature toggle',
|
|
type: 'boolean',
|
|
example: false,
|
|
},
|
|
},
|
|
description:
|
|
'Extra associated data related to the event, such as feature toggle state, segment configuration, etc., if applicable.',
|
|
example: {
|
|
name: 'new-feature',
|
|
description: 'Toggle description',
|
|
type: 'release',
|
|
project: 'my-project',
|
|
stale: false,
|
|
variants: [],
|
|
createdAt: '2022-05-31T13:32:20.547Z',
|
|
lastSeenAt: null,
|
|
impressionData: true,
|
|
},
|
|
} as const;
|
|
export const eventSchema = {
|
|
$id: '#/components/schemas/eventSchema',
|
|
type: 'object',
|
|
additionalProperties: false,
|
|
required: ['id', 'createdAt', 'type', 'createdBy'],
|
|
description: 'An event describing something happening in the system',
|
|
properties: {
|
|
id: {
|
|
type: 'integer',
|
|
minimum: 1,
|
|
description: 'The ID of the event. An increasing natural number.',
|
|
},
|
|
createdAt: {
|
|
type: 'string',
|
|
format: 'date-time',
|
|
description:
|
|
'The time the event happened as a RFC 3339-conformant timestamp.',
|
|
example: '2023-07-05T12:56:00.000Z',
|
|
},
|
|
type: {
|
|
type: 'string',
|
|
description:
|
|
'What [type](https://docs.getunleash.io/reference/api/legacy/unleash/admin/events#event-type-description) of event this is',
|
|
enum: IEventTypes,
|
|
example: 'feature-created',
|
|
},
|
|
createdBy: {
|
|
type: 'string',
|
|
description: 'Which user created this event',
|
|
example: 'johndoe',
|
|
},
|
|
environment: {
|
|
type: 'string',
|
|
description:
|
|
'The feature toggle environment the event relates to, if applicable.',
|
|
nullable: true,
|
|
example: 'development',
|
|
},
|
|
project: {
|
|
type: 'string',
|
|
nullable: true,
|
|
description: 'The project the event relates to, if applicable.',
|
|
example: 'default',
|
|
},
|
|
featureName: {
|
|
type: 'string',
|
|
nullable: true,
|
|
description:
|
|
'The name of the feature toggle the event relates to, if applicable.',
|
|
example: 'my.first.feature',
|
|
},
|
|
data: eventDataSchema,
|
|
preData: {
|
|
...eventDataSchema,
|
|
description:
|
|
"Data relating to the previous state of the event's subject.",
|
|
nullable: true,
|
|
},
|
|
tags: {
|
|
type: 'array',
|
|
items: {
|
|
$ref: tagSchema.$id,
|
|
},
|
|
nullable: true,
|
|
description: 'Any tags related to the event, if applicable.',
|
|
},
|
|
},
|
|
components: {
|
|
schemas: {
|
|
tagSchema,
|
|
variantSchema,
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export type EventSchema = FromSchema<typeof eventSchema>;
|