2023-01-11 16:00:20 +01:00
import { FromSchema } from 'json-schema-to-ts' ;
import { featureSchema } from './feature-schema' ;
import { featureStrategySchema } from './feature-strategy-schema' ;
2023-01-17 12:10:20 +01:00
import { featureEnvironmentSchema } from './feature-environment-schema' ;
import { contextFieldSchema } from './context-field-schema' ;
import { featureTagSchema } from './feature-tag-schema' ;
2023-01-19 14:17:36 +01:00
import { parametersSchema } from './parameters-schema' ;
import { legalValueSchema } from './legal-value-schema' ;
import { variantSchema } from './variant-schema' ;
import { overrideSchema } from './override-schema' ;
import { variantsSchema } from './variants-schema' ;
import { constraintSchema } from './constraint-schema' ;
2023-02-01 12:14:49 +01:00
import { tagTypeSchema } from './tag-type-schema' ;
2023-07-13 13:50:03 +02:00
import { strategyVariantSchema } from './strategy-variant-schema' ;
2023-01-11 16:00:20 +01:00
export const exportResultSchema = {
$id : '#/components/schemas/exportResultSchema' ,
type : 'object' ,
additionalProperties : false ,
2023-07-04 16:41:16 +02:00
description :
'The result of the export operation, providing you with the feature toggle definitions, strategy definitions and the rest of the elements relevant to the features (tags, environments etc.)' ,
2023-02-01 12:14:49 +01:00
required : [ 'features' , 'featureStrategies' , 'tagTypes' ] ,
2023-01-11 16:00:20 +01:00
properties : {
features : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description : 'All the exported features.' ,
example : [
{
name : 'my-feature' ,
description : 'best feature ever' ,
type : 'release' ,
project : 'default' ,
stale : false ,
impressionData : false ,
archived : false ,
} ,
] ,
2023-01-11 16:00:20 +01:00
items : {
$ref : '#/components/schemas/featureSchema' ,
} ,
} ,
featureStrategies : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description :
'All strategy instances that are used by the exported features in the `features` list.' ,
example : [
{
name : 'flexibleRollout' ,
id : '924974d7-8003-43ee-87eb-c5f887c06fd1' ,
featureName : 'my-feature' ,
title : 'Rollout 50%' ,
parameters : {
groupId : 'default' ,
rollout : '50' ,
stickiness : 'random' ,
} ,
constraints : [ ] ,
disabled : false ,
segments : [ 1 ] ,
} ,
] ,
2023-01-11 16:00:20 +01:00
items : {
$ref : '#/components/schemas/featureStrategySchema' ,
} ,
} ,
2023-01-17 12:10:20 +01:00
featureEnvironments : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description :
'Environment-specific configuration for all the features in the `features` list. Includes data such as whether the feature is enabled in the selected export environment, whether there are any variants assigned, etc.' ,
example : [
{
enabled : true ,
featureName : 'my-feature' ,
environment : 'development' ,
variants : [
{
name : 'a' ,
weight : 500 ,
overrides : [ ] ,
stickiness : 'random' ,
weightType : 'variable' ,
} ,
{
name : 'b' ,
weight : 500 ,
overrides : [ ] ,
stickiness : 'random' ,
weightType : 'variable' ,
} ,
] ,
name : 'variant-testing' ,
} ,
] ,
2023-01-17 12:10:20 +01:00
items : {
$ref : '#/components/schemas/featureEnvironmentSchema' ,
} ,
} ,
contextFields : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description :
'A list of all the context fields that are in use by any of the strategies in the `featureStrategies` list.' ,
example : [
{
name : 'appName' ,
description : 'Allows you to constrain on application name' ,
stickiness : false ,
sortOrder : 2 ,
legalValues : [ ] ,
} ,
] ,
2023-01-17 12:10:20 +01:00
items : {
$ref : '#/components/schemas/contextFieldSchema' ,
} ,
} ,
featureTags : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description :
'A list of all the tags that have been applied to any of the features in the `features` list.' ,
example : [
{
featureName : 'my-feature' ,
tagType : 'simple' ,
tagValue : 'user-facing' ,
} ,
] ,
2023-01-17 12:10:20 +01:00
items : {
$ref : '#/components/schemas/featureTagSchema' ,
} ,
} ,
2023-01-18 09:41:22 +01:00
segments : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description :
'A list of all the segments that are used by the strategies in the `featureStrategies` list.' ,
example : [
{
id : 1 ,
name : 'new-segment-name' ,
} ,
] ,
2023-01-18 09:41:22 +01:00
items : {
2023-02-14 15:35:10 +01:00
type : 'object' ,
additionalProperties : false ,
required : [ 'id' ] ,
properties : {
id : {
type : 'number' ,
} ,
name : {
type : 'string' ,
} ,
} ,
2023-01-18 09:41:22 +01:00
} ,
} ,
2023-02-01 12:14:49 +01:00
tagTypes : {
type : 'array' ,
2023-07-04 16:41:16 +02:00
description :
'A list of all of the tag types that are used in the `featureTags` list.' ,
example : [
{
name : 'simple' ,
description : 'Used to simplify filtering of features' ,
icon : '#' ,
} ,
] ,
2023-02-01 12:14:49 +01:00
items : {
$ref : '#/components/schemas/tagTypeSchema' ,
} ,
} ,
2023-01-11 16:00:20 +01:00
} ,
components : {
schemas : {
featureSchema ,
featureStrategySchema ,
2023-07-13 13:50:03 +02:00
strategyVariantSchema ,
2023-01-17 12:10:20 +01:00
featureEnvironmentSchema ,
contextFieldSchema ,
featureTagSchema ,
2023-01-19 14:17:36 +01:00
variantsSchema ,
variantSchema ,
overrideSchema ,
constraintSchema ,
parametersSchema ,
legalValueSchema ,
2023-02-01 12:14:49 +01:00
tagTypeSchema ,
2023-01-11 16:00:20 +01:00
} ,
} ,
} as const ;
export type ExportResultSchema = FromSchema < typeof exportResultSchema > ;