mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
Feat: start adding detailed event descriptions per event
This commit is contained in:
parent
d38001f719
commit
056b8082b2
@ -82,7 +82,13 @@ import { emailSchema } from './spec/email-schema';
|
||||
import { strategySchema } from './spec/strategy-schema';
|
||||
import { strategiesSchema } from './spec/strategies-schema';
|
||||
import { upsertStrategySchema } from './spec/upsert-strategy-schema';
|
||||
import { eventSchema } from './spec/event-schema';
|
||||
import {
|
||||
eventSchema,
|
||||
eventCollectedSchema,
|
||||
featureCreatedEventSchema,
|
||||
eventBaseSchema,
|
||||
featureUpdatedEventSchema,
|
||||
} from './spec/event-schema';
|
||||
import { eventsSchema } from './spec/events-schema';
|
||||
import { featureEventsSchema } from './spec/feature-events-schema';
|
||||
import { clientApplicationSchema } from './spec/client-application-schema';
|
||||
@ -111,6 +117,10 @@ export const schemas = {
|
||||
environmentSchema,
|
||||
environmentsSchema,
|
||||
eventSchema,
|
||||
eventCollectedSchema,
|
||||
featureCreatedEventSchema,
|
||||
featureUpdatedEventSchema,
|
||||
eventBaseSchema,
|
||||
eventsSchema,
|
||||
exportParametersSchema,
|
||||
featureEnvironmentSchema,
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { FromSchema } from 'json-schema-to-ts';
|
||||
import { FEATURE_CREATED, FEATURE_UPDATED } from '../../../lib/types/events';
|
||||
import { tagSchema } from './tag-schema';
|
||||
|
||||
export const eventSchema = {
|
||||
@ -51,3 +52,109 @@ export const eventSchema = {
|
||||
} as const;
|
||||
|
||||
export type EventSchema = FromSchema<typeof eventSchema>;
|
||||
|
||||
export const eventBaseSchema = {
|
||||
$id: '#/components/schemas/eventBaseSchema',
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['id', 'createdAt', 'type', 'createdBy'],
|
||||
properties: {
|
||||
id: {
|
||||
type: 'integer',
|
||||
minimum: 1,
|
||||
description: 'The ID of the event.',
|
||||
example: 42,
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'When the event ocurred.',
|
||||
example: '2022-06-29T13:29:48Z',
|
||||
},
|
||||
createdBy: {
|
||||
type: 'string',
|
||||
description:
|
||||
'The username or email of the person who triggered the event.',
|
||||
example: 'user@company.com',
|
||||
},
|
||||
},
|
||||
components: {
|
||||
schemas: {
|
||||
tagSchema,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
const getEventTypeProperty = (eventType: string) => ({
|
||||
type: 'string',
|
||||
enum: [eventType],
|
||||
description: 'The type of the event.',
|
||||
});
|
||||
|
||||
// const createEvent = () => ({
|
||||
// $id: '#/components/schemas/featureCreatedEventSchema',
|
||||
// allOf: [
|
||||
// { $ref: eventBaseSchema.$id },
|
||||
// {
|
||||
// type: 'object',
|
||||
// additionalProperties: false,
|
||||
// required: ['type', ...requiredProps],
|
||||
// description:
|
||||
// 'This event fires when you create a feature. The `data` property contains the details for the new feature.',
|
||||
// properties: {
|
||||
// type: getEventTypeProperty(eventType),
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// components: {},
|
||||
// })
|
||||
|
||||
export const featureCreatedEventSchema = {
|
||||
$id: '#/components/schemas/featureCreatedEventSchema',
|
||||
allOf: [
|
||||
{ $ref: eventBaseSchema.$id },
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['type'],
|
||||
description:
|
||||
'This event fires when you create a feature. The `data` property contains the details for the new feature.',
|
||||
properties: {
|
||||
type: getEventTypeProperty(FEATURE_CREATED),
|
||||
},
|
||||
},
|
||||
],
|
||||
components: {},
|
||||
};
|
||||
|
||||
export const featureUpdatedEventSchema = {
|
||||
$id: '#/components/schemas/featureUpdatedEventSchema',
|
||||
allOf: [
|
||||
{ $ref: eventBaseSchema.$id },
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['type'],
|
||||
deprecated: true,
|
||||
description:
|
||||
'This event fires when a feature gets updated in some way. The `data` property contains the new state of the toggle. This is a legacy event, so it does not populate `preData` property.\n\nThis event type was replaced by more granular event types in Unleash 4.3.',
|
||||
properties: {
|
||||
type: getEventTypeProperty(FEATURE_UPDATED),
|
||||
},
|
||||
},
|
||||
],
|
||||
components: {},
|
||||
};
|
||||
|
||||
export const eventCollectedSchema = {
|
||||
$id: '#/components/schemas/eventCollectedSchema',
|
||||
oneOf: [{ $ref: featureCreatedEventSchema.$id }],
|
||||
components: {
|
||||
schemas: {
|
||||
tagSchema,
|
||||
featureCreatedEventSchema,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export type EventCollectedSchema = FromSchema<typeof eventCollectedSchema>;
|
||||
|
Loading…
Reference in New Issue
Block a user