2023-03-15 14:58:19 +01:00
|
|
|
import { FromSchema } from 'json-schema-to-ts';
|
|
|
|
import { constraintSchema } from './constraint-schema';
|
|
|
|
|
|
|
|
export const upsertSegmentSchema = {
|
|
|
|
$id: '#/components/schemas/upsertSegmentSchema',
|
|
|
|
type: 'object',
|
2023-04-17 10:51:48 +02:00
|
|
|
description:
|
|
|
|
'Represents a segment of users defined by a set of constraints.',
|
2023-03-15 14:58:19 +01:00
|
|
|
required: ['name', 'constraints'],
|
|
|
|
properties: {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
2023-04-17 10:51:48 +02:00
|
|
|
description: 'The name of the segment.',
|
2023-03-15 14:58:19 +01:00
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: 'string',
|
|
|
|
nullable: true,
|
2023-04-17 10:51:48 +02:00
|
|
|
description: 'The description of the segment.',
|
2023-03-15 14:58:19 +01:00
|
|
|
},
|
|
|
|
project: {
|
|
|
|
type: 'string',
|
|
|
|
nullable: true,
|
2023-04-12 11:29:51 +02:00
|
|
|
description:
|
|
|
|
'Project from where this segment will be accessible. If none is defined the segment will be global (i.e. accessible from any project).',
|
2023-03-15 14:58:19 +01:00
|
|
|
},
|
|
|
|
constraints: {
|
|
|
|
type: 'array',
|
2023-04-12 11:29:51 +02:00
|
|
|
description:
|
|
|
|
'List of constraints that determine which users will be part of the segment',
|
2023-03-15 14:58:19 +01:00
|
|
|
items: {
|
|
|
|
$ref: '#/components/schemas/constraintSchema',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-04-12 11:29:51 +02:00
|
|
|
example: {
|
|
|
|
name: 'segment name',
|
|
|
|
description: 'segment description',
|
|
|
|
project: 'optional project id',
|
|
|
|
constraints: [
|
|
|
|
{
|
|
|
|
contextName: 'environment',
|
|
|
|
operator: 'IN',
|
|
|
|
values: ['production', 'staging'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-03-15 14:58:19 +01:00
|
|
|
components: {
|
|
|
|
schemas: {
|
|
|
|
constraintSchema,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
export type UpsertSegmentSchema = FromSchema<typeof upsertSegmentSchema>;
|