mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: add missing client variant schema fields (#1880)
* refactor: format file * fix: use correct variants schema reference * fix: add missing client variant schema fields
This commit is contained in:
		
							parent
							
								
									2d22a4d471
								
							
						
					
					
						commit
						9c491c0abc
					
				@ -16,6 +16,14 @@ test('clientFeaturesSchema required fields', () => {
 | 
				
			|||||||
                name: 'some-name',
 | 
					                name: 'some-name',
 | 
				
			||||||
                enabled: false,
 | 
					                enabled: false,
 | 
				
			||||||
                impressionData: false,
 | 
					                impressionData: false,
 | 
				
			||||||
 | 
					                variants: [
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        name: 'a',
 | 
				
			||||||
 | 
					                        weight: 1,
 | 
				
			||||||
 | 
					                        weightType: 'b',
 | 
				
			||||||
 | 
					                        stickiness: 'c',
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@ -27,102 +35,101 @@ test('clientFeaturesSchema required fields', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
test('clientFeaturesSchema java-sdk expected response', () => {
 | 
					test('clientFeaturesSchema java-sdk expected response', () => {
 | 
				
			||||||
    const json = `{
 | 
					    const json = `{
 | 
				
			||||||
    "version": 2,
 | 
					      "version": 2,
 | 
				
			||||||
    "segments": [
 | 
					      "segments": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "id": 1,
 | 
					          "id": 1,
 | 
				
			||||||
            "name": "some-name",
 | 
					          "name": "some-name",
 | 
				
			||||||
            "description": null,
 | 
					          "description": null,
 | 
				
			||||||
            "constraints": [
 | 
					          "constraints": [
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    "contextName": "some-name",
 | 
					 | 
				
			||||||
                    "operator": "IN",
 | 
					 | 
				
			||||||
                    "value": "name",
 | 
					 | 
				
			||||||
                    "inverted": false,
 | 
					 | 
				
			||||||
                    "caseInsensitive": true
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    "features": [
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                "name": "Test.old",
 | 
					              "contextName": "some-name",
 | 
				
			||||||
                "description": "No variants here!",
 | 
					              "operator": "IN",
 | 
				
			||||||
                "enabled": true,
 | 
					              "value": "name",
 | 
				
			||||||
                "strategies": [
 | 
					              "inverted": false,
 | 
				
			||||||
                    {
 | 
					              "caseInsensitive": true
 | 
				
			||||||
                        "name": "default"
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                "variants": null,
 | 
					 | 
				
			||||||
                "createdAt": "2019-01-24T10:38:10.370Z"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "Test.variants",
 | 
					 | 
				
			||||||
                "description": null,
 | 
					 | 
				
			||||||
                "enabled": true,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "default",
 | 
					 | 
				
			||||||
                        "segments": [
 | 
					 | 
				
			||||||
                            1
 | 
					 | 
				
			||||||
                        ]
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                "variants": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "variant1",
 | 
					 | 
				
			||||||
                        "weight": 50
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "variant2",
 | 
					 | 
				
			||||||
                        "weight": 50
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                "createdAt": "2019-01-24T10:41:45.236Z"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "featureX",
 | 
					 | 
				
			||||||
                "enabled": true,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "default"
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "featureY",
 | 
					 | 
				
			||||||
                "enabled": false,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "baz",
 | 
					 | 
				
			||||||
                        "parameters": {
 | 
					 | 
				
			||||||
                            "foo": "bar"
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "featureZ",
 | 
					 | 
				
			||||||
                "enabled": true,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "default"
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "hola",
 | 
					 | 
				
			||||||
                        "parameters": {
 | 
					 | 
				
			||||||
                            "name": "val"
 | 
					 | 
				
			||||||
                        },
 | 
					 | 
				
			||||||
                        "segments": [1]
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        ]
 | 
					          ]
 | 
				
			||||||
}
 | 
					        }
 | 
				
			||||||
`;
 | 
					      ],
 | 
				
			||||||
 | 
					      "features": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "Test.old",
 | 
				
			||||||
 | 
					          "description": "No variants here!",
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "variants": null,
 | 
				
			||||||
 | 
					          "createdAt": "2019-01-24T10:38:10.370Z"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "Test.variants",
 | 
				
			||||||
 | 
					          "description": null,
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default",
 | 
				
			||||||
 | 
					              "segments": [
 | 
				
			||||||
 | 
					                1
 | 
				
			||||||
 | 
					              ]
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "variants": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "variant1",
 | 
				
			||||||
 | 
					              "weight": 50
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "variant2",
 | 
				
			||||||
 | 
					              "weight": 50
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "createdAt": "2019-01-24T10:41:45.236Z"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "featureX",
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "featureY",
 | 
				
			||||||
 | 
					          "enabled": false,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "baz",
 | 
				
			||||||
 | 
					              "parameters": {
 | 
				
			||||||
 | 
					                "foo": "bar"
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "featureZ",
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "hola",
 | 
				
			||||||
 | 
					              "parameters": {
 | 
				
			||||||
 | 
					                "name": "val"
 | 
				
			||||||
 | 
					              },
 | 
				
			||||||
 | 
					              "segments": [
 | 
				
			||||||
 | 
					                1
 | 
				
			||||||
 | 
					              ]
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    }`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(
 | 
					    expect(
 | 
				
			||||||
        validateSchema(
 | 
					        validateSchema(
 | 
				
			||||||
@ -134,102 +141,101 @@ test('clientFeaturesSchema java-sdk expected response', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
test('clientFeaturesSchema unleash-proxy expected response', () => {
 | 
					test('clientFeaturesSchema unleash-proxy expected response', () => {
 | 
				
			||||||
    const json = `{
 | 
					    const json = `{
 | 
				
			||||||
    "version": 2,
 | 
					      "version": 2,
 | 
				
			||||||
    "segments": [
 | 
					      "segments": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "id": 1,
 | 
					          "id": 1,
 | 
				
			||||||
            "name": "some-name",
 | 
					          "name": "some-name",
 | 
				
			||||||
            "description": null,
 | 
					          "description": null,
 | 
				
			||||||
            "constraints": [
 | 
					          "constraints": [
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    "contextName": "some-name",
 | 
					 | 
				
			||||||
                    "operator": "IN",
 | 
					 | 
				
			||||||
                    "value": "name",
 | 
					 | 
				
			||||||
                    "inverted": false,
 | 
					 | 
				
			||||||
                    "caseInsensitive": true
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    "features": [
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                "name": "Test.old",
 | 
					              "contextName": "some-name",
 | 
				
			||||||
                "description": "No variants here!",
 | 
					              "operator": "IN",
 | 
				
			||||||
                "enabled": true,
 | 
					              "value": "name",
 | 
				
			||||||
                "strategies": [
 | 
					              "inverted": false,
 | 
				
			||||||
                    {
 | 
					              "caseInsensitive": true
 | 
				
			||||||
                        "name": "default"
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                "variants": null,
 | 
					 | 
				
			||||||
                "createdAt": "2019-01-24T10:38:10.370Z"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "Test.variants",
 | 
					 | 
				
			||||||
                "description": null,
 | 
					 | 
				
			||||||
                "enabled": true,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "default",
 | 
					 | 
				
			||||||
                        "segments": [
 | 
					 | 
				
			||||||
                            1
 | 
					 | 
				
			||||||
                        ]
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                "variants": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "variant1",
 | 
					 | 
				
			||||||
                        "weight": 50
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "variant2",
 | 
					 | 
				
			||||||
                        "weight": 50
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ],
 | 
					 | 
				
			||||||
                "createdAt": "2019-01-24T10:41:45.236Z"
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "featureX",
 | 
					 | 
				
			||||||
                "enabled": true,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "default"
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "featureY",
 | 
					 | 
				
			||||||
                "enabled": false,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "baz",
 | 
					 | 
				
			||||||
                        "parameters": {
 | 
					 | 
				
			||||||
                            "foo": "bar"
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                "name": "featureZ",
 | 
					 | 
				
			||||||
                "enabled": true,
 | 
					 | 
				
			||||||
                "strategies": [
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "default"
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        "name": "hola",
 | 
					 | 
				
			||||||
                        "parameters": {
 | 
					 | 
				
			||||||
                            "name": "val"
 | 
					 | 
				
			||||||
                        },
 | 
					 | 
				
			||||||
                        "segments": [1]
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        ]
 | 
					          ]
 | 
				
			||||||
}
 | 
					        }
 | 
				
			||||||
`;
 | 
					      ],
 | 
				
			||||||
 | 
					      "features": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "Test.old",
 | 
				
			||||||
 | 
					          "description": "No variants here!",
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "variants": null,
 | 
				
			||||||
 | 
					          "createdAt": "2019-01-24T10:38:10.370Z"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "Test.variants",
 | 
				
			||||||
 | 
					          "description": null,
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default",
 | 
				
			||||||
 | 
					              "segments": [
 | 
				
			||||||
 | 
					                1
 | 
				
			||||||
 | 
					              ]
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "variants": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "variant1",
 | 
				
			||||||
 | 
					              "weight": 50
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "variant2",
 | 
				
			||||||
 | 
					              "weight": 50
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ],
 | 
				
			||||||
 | 
					          "createdAt": "2019-01-24T10:41:45.236Z"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "featureX",
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "featureY",
 | 
				
			||||||
 | 
					          "enabled": false,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "baz",
 | 
				
			||||||
 | 
					              "parameters": {
 | 
				
			||||||
 | 
					                "foo": "bar"
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "name": "featureZ",
 | 
				
			||||||
 | 
					          "enabled": true,
 | 
				
			||||||
 | 
					          "strategies": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "default"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "name": "hola",
 | 
				
			||||||
 | 
					              "parameters": {
 | 
				
			||||||
 | 
					                "name": "val"
 | 
				
			||||||
 | 
					              },
 | 
				
			||||||
 | 
					              "segments": [
 | 
				
			||||||
 | 
					                1
 | 
				
			||||||
 | 
					              ]
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    }`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(
 | 
					    expect(
 | 
				
			||||||
        validateSchema(
 | 
					        validateSchema(
 | 
				
			||||||
@ -241,150 +247,163 @@ test('clientFeaturesSchema unleash-proxy expected response', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
test('clientFeaturesSchema client specification test 15', () => {
 | 
					test('clientFeaturesSchema client specification test 15', () => {
 | 
				
			||||||
    const json = `{
 | 
					    const json = `{
 | 
				
			||||||
       "version": 2,
 | 
					      "version": 2,
 | 
				
			||||||
        "features": [
 | 
					      "features": [
 | 
				
			||||||
          {
 | 
					        {
 | 
				
			||||||
            "name": "F9.globalSegmentOn",
 | 
					          "name": "F9.globalSegmentOn",
 | 
				
			||||||
            "description": "With global segment referencing constraint in on state",
 | 
					          "description": "With global segment referencing constraint in on state",
 | 
				
			||||||
            "enabled": true,
 | 
					          "enabled": true,
 | 
				
			||||||
            "strategies": [
 | 
					          "strategies": [
 | 
				
			||||||
              {
 | 
					            {
 | 
				
			||||||
                "name": "default",
 | 
					              "name": "default",
 | 
				
			||||||
                "parameters": {},
 | 
					              "parameters": {},
 | 
				
			||||||
                "segments": [1]
 | 
					              "segments": [
 | 
				
			||||||
              }
 | 
					                1
 | 
				
			||||||
            ]
 | 
					              ]
 | 
				
			||||||
          },
 | 
					            }
 | 
				
			||||||
          {
 | 
					          ]
 | 
				
			||||||
            "name": "F9.globalSegmentOff",
 | 
					        },
 | 
				
			||||||
            "description": "With global segment referencing constraint in off state",
 | 
					        {
 | 
				
			||||||
            "enabled": true,
 | 
					          "name": "F9.globalSegmentOff",
 | 
				
			||||||
            "strategies": [
 | 
					          "description": "With global segment referencing constraint in off state",
 | 
				
			||||||
              {
 | 
					          "enabled": true,
 | 
				
			||||||
                "name": "default",
 | 
					          "strategies": [
 | 
				
			||||||
                "parameters": {},
 | 
					            {
 | 
				
			||||||
                "segments": [2]
 | 
					              "name": "default",
 | 
				
			||||||
              }
 | 
					              "parameters": {},
 | 
				
			||||||
            ]
 | 
					              "segments": [
 | 
				
			||||||
          },
 | 
					                2
 | 
				
			||||||
          {
 | 
					              ]
 | 
				
			||||||
            "name": "F9.globalSegmentAndConstraint",
 | 
					            }
 | 
				
			||||||
            "description": "With global segment and constraint both on",
 | 
					          ]
 | 
				
			||||||
            "enabled": true,
 | 
					        },
 | 
				
			||||||
            "strategies": [
 | 
					        {
 | 
				
			||||||
              {
 | 
					          "name": "F9.globalSegmentAndConstraint",
 | 
				
			||||||
                "name": "default",
 | 
					          "description": "With global segment and constraint both on",
 | 
				
			||||||
                "parameters": {},
 | 
					          "enabled": true,
 | 
				
			||||||
                "constraints": [
 | 
					          "strategies": [
 | 
				
			||||||
                  {
 | 
					            {
 | 
				
			||||||
                    "contextName": "version",
 | 
					              "name": "default",
 | 
				
			||||||
                    "operator": "SEMVER_EQ",
 | 
					              "parameters": {},
 | 
				
			||||||
                    "value": "1.2.2"
 | 
					              "constraints": [
 | 
				
			||||||
                  }
 | 
					                {
 | 
				
			||||||
                ],
 | 
					                  "contextName": "version",
 | 
				
			||||||
                "segments": [1]
 | 
					                  "operator": "SEMVER_EQ",
 | 
				
			||||||
              }
 | 
					                  "value": "1.2.2"
 | 
				
			||||||
            ]
 | 
					                }
 | 
				
			||||||
          },
 | 
					              ],
 | 
				
			||||||
          {
 | 
					              "segments": [
 | 
				
			||||||
            "name": "F9.withExtraParams",
 | 
					                1
 | 
				
			||||||
            "description": "With global segment that doesn't exist",
 | 
					              ]
 | 
				
			||||||
            "enabled": true,
 | 
					            }
 | 
				
			||||||
            "project": "some-project",
 | 
					          ]
 | 
				
			||||||
            "strategies": [
 | 
					        },
 | 
				
			||||||
              {
 | 
					        {
 | 
				
			||||||
                "name": "default",
 | 
					          "name": "F9.withExtraParams",
 | 
				
			||||||
                "parameters": {},
 | 
					          "description": "With global segment that doesn't exist",
 | 
				
			||||||
                "constraints": [
 | 
					          "enabled": true,
 | 
				
			||||||
                  {
 | 
					          "project": "some-project",
 | 
				
			||||||
                    "contextName": "version",
 | 
					          "strategies": [
 | 
				
			||||||
                    "operator": "SEMVER_EQ",
 | 
					            {
 | 
				
			||||||
                    "value": "1.2.2"
 | 
					              "name": "default",
 | 
				
			||||||
                  }
 | 
					              "parameters": {},
 | 
				
			||||||
                ],
 | 
					              "constraints": [
 | 
				
			||||||
                "segments": [3]
 | 
					                {
 | 
				
			||||||
              }
 | 
					                  "contextName": "version",
 | 
				
			||||||
            ]
 | 
					                  "operator": "SEMVER_EQ",
 | 
				
			||||||
          },
 | 
					                  "value": "1.2.2"
 | 
				
			||||||
          {
 | 
					                }
 | 
				
			||||||
            "name": "F9.withSeveralConstraintsAndSegments",
 | 
					              ],
 | 
				
			||||||
            "description": "With several segments and constraints",
 | 
					              "segments": [
 | 
				
			||||||
            "enabled": true,
 | 
					                3
 | 
				
			||||||
            "strategies": [
 | 
					              ]
 | 
				
			||||||
              {
 | 
					            }
 | 
				
			||||||
                "name": "default",
 | 
					          ]
 | 
				
			||||||
                "parameters": {},
 | 
					        },
 | 
				
			||||||
                "constraints": [
 | 
					        {
 | 
				
			||||||
                  {
 | 
					          "name": "F9.withSeveralConstraintsAndSegments",
 | 
				
			||||||
                    "contextName": "customNumber",
 | 
					          "description": "With several segments and constraints",
 | 
				
			||||||
                    "operator": "NUM_LT",
 | 
					          "enabled": true,
 | 
				
			||||||
                    "value": "10"
 | 
					          "strategies": [
 | 
				
			||||||
                  },
 | 
					            {
 | 
				
			||||||
                  {
 | 
					              "name": "default",
 | 
				
			||||||
                    "contextName": "version",
 | 
					              "parameters": {},
 | 
				
			||||||
                    "operator": "SEMVER_LT",
 | 
					              "constraints": [
 | 
				
			||||||
                    "value": "3.2.2"
 | 
					                {
 | 
				
			||||||
                  }
 | 
					                  "contextName": "customNumber",
 | 
				
			||||||
                ],
 | 
					                  "operator": "NUM_LT",
 | 
				
			||||||
                "segments": [1, 4, 5]
 | 
					                  "value": "10"
 | 
				
			||||||
              }
 | 
					                },
 | 
				
			||||||
            ]
 | 
					                {
 | 
				
			||||||
          }
 | 
					                  "contextName": "version",
 | 
				
			||||||
        ],
 | 
					                  "operator": "SEMVER_LT",
 | 
				
			||||||
        "segments": [
 | 
					                  "value": "3.2.2"
 | 
				
			||||||
          {
 | 
					                }
 | 
				
			||||||
            "id": 1,
 | 
					              ],
 | 
				
			||||||
            "constraints": [
 | 
					              "segments": [
 | 
				
			||||||
              {
 | 
					                1,
 | 
				
			||||||
                "contextName": "version",
 | 
					                4,
 | 
				
			||||||
                "operator": "SEMVER_EQ",
 | 
					                5
 | 
				
			||||||
                "value": "1.2.2"
 | 
					              ]
 | 
				
			||||||
              }
 | 
					            }
 | 
				
			||||||
            ]
 | 
					          ]
 | 
				
			||||||
          },
 | 
					        }
 | 
				
			||||||
          {
 | 
					      ],
 | 
				
			||||||
            "id": 2,
 | 
					      "segments": [
 | 
				
			||||||
            "constraints": [
 | 
					        {
 | 
				
			||||||
              {
 | 
					          "id": 1,
 | 
				
			||||||
                "contextName": "version",
 | 
					          "constraints": [
 | 
				
			||||||
                "operator": "SEMVER_EQ",
 | 
					            {
 | 
				
			||||||
                "value": "3.1.4"
 | 
					              "contextName": "version",
 | 
				
			||||||
              }
 | 
					              "operator": "SEMVER_EQ",
 | 
				
			||||||
            ]
 | 
					              "value": "1.2.2"
 | 
				
			||||||
          },
 | 
					            }
 | 
				
			||||||
          {
 | 
					          ]
 | 
				
			||||||
            "id": 3,
 | 
					        },
 | 
				
			||||||
            "constraints": [
 | 
					        {
 | 
				
			||||||
              {
 | 
					          "id": 2,
 | 
				
			||||||
                "contextName": "version",
 | 
					          "constraints": [
 | 
				
			||||||
                "operator": "SEMVER_EQ",
 | 
					            {
 | 
				
			||||||
                "value": "3.1.4"
 | 
					              "contextName": "version",
 | 
				
			||||||
              }
 | 
					              "operator": "SEMVER_EQ",
 | 
				
			||||||
            ]
 | 
					              "value": "3.1.4"
 | 
				
			||||||
          },
 | 
					            }
 | 
				
			||||||
          {
 | 
					          ]
 | 
				
			||||||
            "id": 4,
 | 
					        },
 | 
				
			||||||
            "constraints": [
 | 
					        {
 | 
				
			||||||
              {
 | 
					          "id": 3,
 | 
				
			||||||
                "contextName": "customName",
 | 
					          "constraints": [
 | 
				
			||||||
                "operator": "STR_CONTAINS",
 | 
					            {
 | 
				
			||||||
                "values": ["Pi"]
 | 
					              "contextName": "version",
 | 
				
			||||||
              }
 | 
					              "operator": "SEMVER_EQ",
 | 
				
			||||||
            ]
 | 
					              "value": "3.1.4"
 | 
				
			||||||
          },
 | 
					            }
 | 
				
			||||||
          {
 | 
					          ]
 | 
				
			||||||
            "id": 5,
 | 
					        },
 | 
				
			||||||
            "constraints": [
 | 
					        {
 | 
				
			||||||
              {
 | 
					          "id": 4,
 | 
				
			||||||
                "contextName": "slicesLeft",
 | 
					          "constraints": [
 | 
				
			||||||
                "operator": "NUM_LTE",
 | 
					            {
 | 
				
			||||||
                "value": "4"
 | 
					              "contextName": "customName",
 | 
				
			||||||
              }
 | 
					              "operator": "STR_CONTAINS",
 | 
				
			||||||
            ]
 | 
					              "values": [
 | 
				
			||||||
          }
 | 
					                "Pi"
 | 
				
			||||||
        ]
 | 
					              ]
 | 
				
			||||||
      }
 | 
					            }
 | 
				
			||||||
`;
 | 
					          ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "id": 5,
 | 
				
			||||||
 | 
					          "constraints": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "contextName": "slicesLeft",
 | 
				
			||||||
 | 
					              "operator": "NUM_LTE",
 | 
				
			||||||
 | 
					              "value": "4"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    }`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(
 | 
					    expect(
 | 
				
			||||||
        validateSchema(
 | 
					        validateSchema(
 | 
				
			||||||
 | 
				
			|||||||
@ -6,8 +6,8 @@ import { environmentSchema } from './environment-schema';
 | 
				
			|||||||
import { overrideSchema } from './override-schema';
 | 
					import { overrideSchema } from './override-schema';
 | 
				
			||||||
import { parametersSchema } from './parameters-schema';
 | 
					import { parametersSchema } from './parameters-schema';
 | 
				
			||||||
import { featureStrategySchema } from './feature-strategy-schema';
 | 
					import { featureStrategySchema } from './feature-strategy-schema';
 | 
				
			||||||
import { variantSchema } from './variant-schema';
 | 
					 | 
				
			||||||
import { clientFeatureSchema } from './client-feature-schema';
 | 
					import { clientFeatureSchema } from './client-feature-schema';
 | 
				
			||||||
 | 
					import { clientVariantSchema } from './client-variant-schema';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const clientFeaturesSchema = {
 | 
					export const clientFeaturesSchema = {
 | 
				
			||||||
    $id: '#/components/schemas/clientFeaturesSchema',
 | 
					    $id: '#/components/schemas/clientFeaturesSchema',
 | 
				
			||||||
@ -43,7 +43,7 @@ export const clientFeaturesSchema = {
 | 
				
			|||||||
            overrideSchema,
 | 
					            overrideSchema,
 | 
				
			||||||
            parametersSchema,
 | 
					            parametersSchema,
 | 
				
			||||||
            featureStrategySchema,
 | 
					            featureStrategySchema,
 | 
				
			||||||
            variantSchema,
 | 
					            clientVariantSchema,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
} as const;
 | 
					} as const;
 | 
				
			||||||
 | 
				
			|||||||
@ -12,6 +12,12 @@ export const clientVariantSchema = {
 | 
				
			|||||||
        weight: {
 | 
					        weight: {
 | 
				
			||||||
            type: 'number',
 | 
					            type: 'number',
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        weightType: {
 | 
				
			||||||
 | 
					            type: 'string',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        stickiness: {
 | 
				
			||||||
 | 
					            type: 'string',
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        payload: {
 | 
					        payload: {
 | 
				
			||||||
            type: 'object',
 | 
					            type: 'object',
 | 
				
			||||||
            required: ['type', 'value'],
 | 
					            required: ['type', 'value'],
 | 
				
			||||||
 | 
				
			|||||||
@ -660,9 +660,15 @@ Object {
 | 
				
			|||||||
            ],
 | 
					            ],
 | 
				
			||||||
            "type": "object",
 | 
					            "type": "object",
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
 | 
					          "stickiness": Object {
 | 
				
			||||||
 | 
					            "type": "string",
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
          "weight": Object {
 | 
					          "weight": Object {
 | 
				
			||||||
            "type": "number",
 | 
					            "type": "number",
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
 | 
					          "weightType": Object {
 | 
				
			||||||
 | 
					            "type": "string",
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "required": Array [
 | 
					        "required": Array [
 | 
				
			||||||
          "name",
 | 
					          "name",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user