1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

In-flight: attempt to simplify event generation

This commit is contained in:
Thomas Heartman 2022-06-29 14:09:15 +02:00
parent 056b8082b2
commit fc73abdc94

View File

@ -89,43 +89,59 @@ const getEventTypeProperty = (eventType: string) => ({
type: 'string', type: 'string',
enum: [eventType], enum: [eventType],
description: 'The type of the event.', description: 'The type of the event.',
example: eventType,
}); });
// const createEvent = () => ({ type EventData = {
type: string;
required: string[];
properties: {};
description: string;
};
const createEvent = (e: EventData) => ({
$id: `#/components/schemas/${e.type}EventSchema`,
allOf: [
{ $ref: eventBaseSchema.$id },
{
type: 'object',
additionalProperties: false,
required: ['type', ...e.required],
description:
'This event fires when you create a feature. The `data` property contains the details for the new feature.',
properties: {
type: getEventTypeProperty(e.type),
},
},
],
components: {},
});
export const featureCreatedEventSchema = createEvent({
type: FEATURE_CREATED,
description: 'blu',
required: ['other prop'],
properties: {
'other prop': { type: 'string' },
},
});
// export const featureCreatedEventSchema = {
// $id: '#/components/schemas/featureCreatedEventSchema', // $id: '#/components/schemas/featureCreatedEventSchema',
// allOf: [ // allOf: [
// { $ref: eventBaseSchema.$id }, // { $ref: eventBaseSchema.$id },
// { // {
// type: 'object', // type: 'object',
// additionalProperties: false, // additionalProperties: false,
// required: ['type', ...requiredProps], // required: ['type'],
// description: // description:
// 'This event fires when you create a feature. The `data` property contains the details for the new feature.', // 'This event fires when you create a feature. The `data` property contains the details for the new feature.',
// properties: { // properties: {
// type: getEventTypeProperty(eventType), // type: getEventTypeProperty(FEATURE_CREATED),
// }, // },
// }, // },
// ], // ],
// components: {}, // 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 = { export const featureUpdatedEventSchema = {
$id: '#/components/schemas/featureUpdatedEventSchema', $id: '#/components/schemas/featureUpdatedEventSchema',