@featurevisor/core
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.5.3](https://github.com/fahad19/featurevisor/compare/v0.5.2...v0.5.3) (2023-03-25) | ||
### Bug Fixes | ||
* linting fixes ([#27](https://github.com/fahad19/featurevisor/issues/27)) ([8f16194](https://github.com/fahad19/featurevisor/commit/8f161943332a617a5e25f811c985e1a33a9559fa)) | ||
## [0.5.2](https://github.com/fahad19/featurevisor/compare/v0.5.1...v0.5.2) (2023-03-25) | ||
@@ -8,0 +19,0 @@ |
@@ -127,3 +127,3 @@ "use strict"; | ||
segments: groupSegmentsJoiSchema, | ||
percentage: Joi.number().min(0).max(100), | ||
percentage: Joi.number().precision(3).min(0).max(100), | ||
variables: Joi.object().optional(), // @TODO: make it stricter | ||
@@ -155,6 +155,8 @@ })), | ||
})), | ||
variations: Joi.array().items(Joi.object({ | ||
variations: Joi.array() | ||
.items(Joi.object({ | ||
description: Joi.string().optional(), | ||
type: Joi.string().valid("string", "integer", "boolean", "double"), | ||
value: variationValueJoiSchema, | ||
weight: Joi.number().integer().min(0).max(100), | ||
weight: Joi.number().precision(3).min(0).max(100), | ||
variables: Joi.array().items(Joi.object({ | ||
@@ -171,3 +173,10 @@ key: Joi.string(), | ||
})), | ||
})), | ||
})) | ||
.custom(function (value, helpers) { | ||
var total = value.reduce(function (a, b) { return a + b.weight; }, 0); | ||
if (total !== 100) { | ||
throw new Error("Sum of all variation weights must be 100, got ".concat(total)); | ||
} | ||
return value; | ||
}), | ||
environments: allEnvironomentsJoiSchema, | ||
@@ -189,3 +198,3 @@ }); | ||
description: Joi.string().optional(), | ||
at: Joi.number().integer().min(0).max(100), | ||
at: Joi.number().precision(3).min(0).max(100), | ||
attributes: Joi.object(), | ||
@@ -192,0 +201,0 @@ // @TODO: one or both below |
@@ -82,3 +82,4 @@ "use strict"; | ||
feature.assertions.forEach(function (assertion, aIndex) { | ||
console.log(" => Assertion #".concat(aIndex + 1, ": ").concat(assertion.description || "")); | ||
var description = assertion.description || "at ".concat(assertion.at, "%"); | ||
console.log(" => Assertion #".concat(aIndex + 1, ": ").concat(description)); | ||
var assertionHasError = false; | ||
@@ -85,0 +86,0 @@ currentAt = assertion.at * (sdk_1.MAX_BUCKETED_NUMBER / 100); |
{ | ||
"name": "@featurevisor/core", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Core package of Featurevisor for Node.js usage", | ||
@@ -44,4 +44,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@featurevisor/sdk": "^0.5.2", | ||
"@featurevisor/types": "^0.5.0", | ||
"@featurevisor/sdk": "^0.5.3", | ||
"@featurevisor/types": "^0.5.3", | ||
"axios": "^1.3.4", | ||
@@ -57,3 +57,3 @@ "joi": "^17.8.3", | ||
}, | ||
"gitHead": "088009c0e8fe6eb8d345c4e6e89efb525f259d91" | ||
"gitHead": "66ed55a4be820cb16ecb5bfee7c4df1e06be912f" | ||
} |
@@ -147,3 +147,3 @@ // for use in node only | ||
segments: groupSegmentsJoiSchema, | ||
percentage: Joi.number().min(0).max(100), // @TODO: allow maximum 3 decimal places | ||
percentage: Joi.number().precision(3).min(0).max(100), | ||
variables: Joi.object().optional(), // @TODO: make it stricter | ||
@@ -187,25 +187,36 @@ }), | ||
variations: Joi.array().items( | ||
Joi.object({ | ||
type: Joi.string().valid("string", "integer", "boolean", "double"), | ||
value: variationValueJoiSchema, // @TODO: make it unique among siblings | ||
weight: Joi.number().integer().min(0).max(100), // @TODO: total sum among siblings should be exactly 100, allow maximum 3 decimal places | ||
variables: Joi.array().items( | ||
Joi.object({ | ||
key: Joi.string(), // @TODO: make it unique among siblings | ||
value: variableValueJoiSchema, | ||
overrides: Joi.array().items( | ||
Joi.object({ | ||
// @TODO: either segments or conditions prsent at a time | ||
segments: groupSegmentsJoiSchema, | ||
conditions: conditionsJoiSchema, | ||
variations: Joi.array() | ||
.items( | ||
Joi.object({ | ||
description: Joi.string().optional(), | ||
type: Joi.string().valid("string", "integer", "boolean", "double"), | ||
value: variationValueJoiSchema, // @TODO: make it unique among siblings | ||
weight: Joi.number().precision(3).min(0).max(100), | ||
variables: Joi.array().items( | ||
Joi.object({ | ||
key: Joi.string(), // @TODO: make it unique among siblings | ||
value: variableValueJoiSchema, | ||
overrides: Joi.array().items( | ||
Joi.object({ | ||
// @TODO: either segments or conditions prsent at a time | ||
segments: groupSegmentsJoiSchema, | ||
conditions: conditionsJoiSchema, | ||
// @TODO: make it stricter based on `type` | ||
value: variableValueJoiSchema, | ||
}), | ||
), | ||
}), | ||
), | ||
// @TODO: make it stricter based on `type` | ||
value: variableValueJoiSchema, | ||
}), | ||
), | ||
}), | ||
), | ||
}), | ||
) | ||
.custom((value, helpers) => { | ||
var total = value.reduce((a, b) => a + b.weight, 0); | ||
if (total !== 100) { | ||
throw new Error(`Sum of all variation weights must be 100, got ${total}`); | ||
} | ||
return value; | ||
}), | ||
), | ||
@@ -231,3 +242,3 @@ environments: allEnvironomentsJoiSchema, | ||
description: Joi.string().optional(), | ||
at: Joi.number().integer().min(0).max(100), | ||
at: Joi.number().precision(3).min(0).max(100), | ||
attributes: Joi.object(), // @TODO: make it specific | ||
@@ -234,0 +245,0 @@ |
@@ -139,4 +139,6 @@ import * as fs from "fs"; | ||
feature.assertions.forEach(function (assertion, aIndex) { | ||
console.log(` => Assertion #${aIndex + 1}: ${assertion.description || ""}`); | ||
const description = assertion.description || `at ${assertion.at}%`; | ||
console.log(` => Assertion #${aIndex + 1}: ${description}`); | ||
let assertionHasError = false; | ||
@@ -143,0 +145,0 @@ currentAt = assertion.at * (MAX_BUCKETED_NUMBER / 100); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
166925
3409
Updated@featurevisor/sdk@^0.5.3
Updated@featurevisor/types@^0.5.3