New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@featurevisor/core

Package Overview
Dependencies
Maintainers
0
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@featurevisor/core - npm Package Compare versions

Comparing version 1.27.6 to 1.28.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.28.0](https://github.com/featurevisor/featurevisor/compare/v1.27.6...v1.28.0) (2025-01-21)
### Features
* datafile schema v2 ([#334](https://github.com/featurevisor/featurevisor/issues/334)) ([ee91c78](https://github.com/featurevisor/featurevisor/commit/ee91c781ad8e3347c828cea63279f5b9931a24e7))
## [1.27.6](https://github.com/featurevisor/featurevisor/compare/v1.27.5...v1.27.6) (2025-01-20)

@@ -8,0 +19,0 @@

2

lib/assess-distribution/index.d.ts

@@ -9,2 +9,4 @@ import { FeatureKey, AttributeKey, Context } from "@featurevisor/types";

n: number;
schemaVersion?: string;
inflate?: number;
populateUuid?: AttributeKey[];

@@ -11,0 +13,0 @@ verbose?: boolean;

3

lib/assess-distribution/index.js

@@ -107,5 +107,6 @@ "use strict";

return [4 /*yield*/, (0, builder_1.buildDatafile)(projectConfig, datasource, {
schemaVersion: config_1.SCHEMA_VERSION,
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
revision: "include-all-features",
environment: options.environment,
inflate: options.inflate,
}, existingState)];

@@ -112,0 +113,0 @@ case 2:

@@ -18,4 +18,6 @@ import { FeaturevisorInstance } from "@featurevisor/sdk";

variable?: string;
schemaVersion?: string;
inflate?: number;
}
export declare function benchmarkFeature(deps: Dependencies, options: BenchmarkOptions): Promise<void>;
export declare const benchmarkPlugin: Plugin;

@@ -100,5 +100,6 @@ "use strict";

return [4 /*yield*/, (0, builder_1.buildDatafile)(projectConfig, datasource, {
schemaVersion: config_1.SCHEMA_VERSION,
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
revision: "include-all-features",
environment: options.environment,
inflate: options.inflate,
}, existingState)];

@@ -109,2 +110,9 @@ case 2:

console.log("Datafile build duration: ".concat(datafileBuildDuration, "ms"));
console.log("Datafile size: ".concat((JSON.stringify(datafileContent).length / 1024).toFixed(2), " kB"));
if (options.inflate) {
console.log("");
console.log("Features count:", Object.keys(datafileContent.features).length);
console.log("Segments count:", Object.keys(datafileContent.segments).length);
console.log("Attributes count:", Object.keys(datafileContent.attributes).length);
}
console.log("");

@@ -159,2 +167,4 @@ f = (0, sdk_1.createInstance)({

variable: parsed.variable || undefined,
schemaVersion: parsed.schemaVersion || undefined,
inflate: parseInt(parsed.inflate, 10) || undefined,
})];

@@ -161,0 +171,0 @@ case 1:

@@ -10,2 +10,4 @@ import { DatafileContent, ExistingState, FeatureKey } from "@featurevisor/types";

revision?: string;
schemaVersion?: string;
inflate?: number;
}

@@ -19,3 +21,4 @@ export declare function getCustomDatafile(options: CustomDatafileOptions): Promise<DatafileContent>;

features?: FeatureKey[];
inflate?: number;
}
export declare function buildDatafile(projectConfig: ProjectConfig, datasource: Datasource, options: BuildOptions, existingState: ExistingState): Promise<DatafileContent>;

@@ -73,6 +73,7 @@ "use strict";

return [4 /*yield*/, buildDatafile(options.projectConfig, options.datasource, {
schemaVersion: config_1.SCHEMA_VERSION,
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
revision: options.revision || "tester",
environment: options.environment,
features: featuresToInclude,
inflate: options.inflate,
}, existingState)];

@@ -88,6 +89,6 @@ case 4:

return __awaiter(this, void 0, void 0, function () {
var datafileContent, segmentKeysUsedByTag, attributeKeysUsedByTag, _a, featureRanges, featureIsInGroup, features, featuresDirectory, featureFiles, _i, featureFiles_1, featureKey, parsedFeature, exposeTags, _b, _c, parsedRule, extractedSegmentKeys, feature, segments, segmentsDirectory, segmentFiles, _d, segmentFiles_1, segmentKey, parsedSegment, extractedAttributeKeys, segment, attributes, attributesDirectory, attributeFiles, _e, attributeFiles_1, attributeKey, parsedAttribute, attribute;
var _f;
return __generator(this, function (_g) {
switch (_g.label) {
var datafileContent, segmentKeysUsedByTag, attributeKeysUsedByTag, _a, featureRanges, featureIsInGroup, features, featuresDirectory, featureFiles, _i, featureFiles_1, featureKey, parsedFeature, exposeTags, _b, _c, parsedRule, extractedSegmentKeys, feature, segments, segmentsDirectory, segmentFiles, _d, segmentFiles_1, segmentKey, parsedSegment, extractedAttributeKeys, segment, attributes, attributesDirectory, attributeFiles, _e, attributeFiles_1, attributeKey, parsedAttribute, attribute, allFeatureKeys, allSegmentKeys, allAttributeKeys, i, _loop_1, _f, allFeatureKeys_1, featureKey, _loop_2, _g, allSegmentKeys_1, segmentKey, _loop_3, _h, allAttributeKeys_1, attributeKey, datafileContentV2;
var _j;
return __generator(this, function (_k) {
switch (_k.label) {
case 0:

@@ -105,3 +106,3 @@ datafileContent = {

case 1:
_a = _g.sent(), featureRanges = _a.featureRanges, featureIsInGroup = _a.featureIsInGroup;
_a = _k.sent(), featureRanges = _a.featureRanges, featureIsInGroup = _a.featureIsInGroup;
features = [];

@@ -112,5 +113,5 @@ featuresDirectory = projectConfig.featuresDirectoryPath;

case 2:
featureFiles = _g.sent();
featureFiles = _k.sent();
_i = 0, featureFiles_1 = featureFiles;
_g.label = 3;
_k.label = 3;
case 3:

@@ -121,3 +122,3 @@ if (!(_i < featureFiles_1.length)) return [3 /*break*/, 6];

case 4:
parsedFeature = _g.sent();
parsedFeature = _k.sent();
if (parsedFeature.archived === true) {

@@ -244,3 +245,3 @@ return [3 /*break*/, 5];

feature.force = parsedFeature.environments[options.environment].force;
(_f = feature.force) === null || _f === void 0 ? void 0 : _f.forEach(function (f) {
(_j = feature.force) === null || _j === void 0 ? void 0 : _j.forEach(function (f) {
if (f.segments) {

@@ -253,3 +254,3 @@ var extractedSegmentKeys = (0, utils_1.extractSegmentKeysFromGroupSegments)(f.segments);

features.push(feature);
_g.label = 5;
_k.label = 5;
case 5:

@@ -264,5 +265,5 @@ _i++;

case 7:
segmentFiles = _g.sent();
segmentFiles = _k.sent();
_d = 0, segmentFiles_1 = segmentFiles;
_g.label = 8;
_k.label = 8;
case 8:

@@ -273,3 +274,3 @@ if (!(_d < segmentFiles_1.length)) return [3 /*break*/, 11];

case 9:
parsedSegment = _g.sent();
parsedSegment = _k.sent();
if (parsedSegment.archived === true) {

@@ -290,3 +291,3 @@ return [3 /*break*/, 10];

segments.push(segment);
_g.label = 10;
_k.label = 10;
case 10:

@@ -301,5 +302,5 @@ _d++;

case 12:
attributeFiles = _g.sent();
attributeFiles = _k.sent();
_e = 0, attributeFiles_1 = attributeFiles;
_g.label = 13;
_k.label = 13;
case 13:

@@ -310,3 +311,3 @@ if (!(_e < attributeFiles_1.length)) return [3 /*break*/, 16];

case 14:
parsedAttribute = _g.sent();
parsedAttribute = _k.sent();
if (parsedAttribute.archived === true) {

@@ -326,3 +327,3 @@ return [3 /*break*/, 15];

attributes.push(attribute);
_g.label = 15;
_k.label = 15;
case 15:

@@ -332,2 +333,61 @@ _e++;

case 16:
// inflate
if (options.inflate) {
allFeatureKeys = features.map(function (f) { return f.key; });
allSegmentKeys = segments.map(function (s) { return s.key; });
allAttributeKeys = attributes.map(function (a) { return a.key; });
for (i = 0; i < options.inflate; i++) {
_loop_1 = function (featureKey) {
var originalFeature = features.find(function (f) { return f.key === featureKey; });
features.unshift(__assign(__assign({}, originalFeature), { key: "".concat(originalFeature.key, "-").concat(i) }));
};
// feature
for (_f = 0, allFeatureKeys_1 = allFeatureKeys; _f < allFeatureKeys_1.length; _f++) {
featureKey = allFeatureKeys_1[_f];
_loop_1(featureKey);
}
_loop_2 = function (segmentKey) {
var originalSegment = segments.find(function (s) { return s.key === segmentKey; });
segments.unshift(__assign(__assign({}, originalSegment), { key: "".concat(originalSegment.key, "-").concat(i) }));
};
// segment
for (_g = 0, allSegmentKeys_1 = allSegmentKeys; _g < allSegmentKeys_1.length; _g++) {
segmentKey = allSegmentKeys_1[_g];
_loop_2(segmentKey);
}
_loop_3 = function (attributeKey) {
var originalAttribute = attributes.find(function (a) { return a.key === attributeKey; });
attributes.unshift(__assign(__assign({}, originalAttribute), { key: "".concat(originalAttribute.key, "-").concat(i) }));
};
// attribute
for (_h = 0, allAttributeKeys_1 = allAttributeKeys; _h < allAttributeKeys_1.length; _h++) {
attributeKey = allAttributeKeys_1[_h];
_loop_3(attributeKey);
}
}
}
// schema v2
if (options.schemaVersion === "2") {
datafileContentV2 = {
schemaVersion: "2",
revision: options.revision,
attributes: {},
segments: {},
features: {},
};
datafileContentV2.attributes = attributes.reduce(function (acc, attribute) {
acc[attribute.key] = attribute;
return acc;
}, {});
datafileContentV2.segments = segments.reduce(function (acc, segment) {
acc[segment.key] = segment;
return acc;
}, {});
datafileContentV2.features = features.reduce(function (acc, feature) {
acc[feature.key] = feature;
return acc;
}, {});
return [2 /*return*/, datafileContentV2];
}
// default behaviour
datafileContent.attributes = attributes;

@@ -334,0 +394,0 @@ datafileContent.segments = segments;

@@ -5,2 +5,3 @@ import { Dependencies } from "../dependencies";

revision?: string;
schemaVersion?: string;
environment?: string;

@@ -11,4 +12,5 @@ feature?: string;

stateFiles?: boolean;
inflate?: number;
}
export declare function buildProject(deps: Dependencies, cliOptions?: BuildCLIOptions): Promise<void>;
export declare const buildPlugin: Plugin;

@@ -59,2 +59,3 @@ "use strict";

revision: cliOptions.revision,
schemaVersion: cliOptions.schemaVersion,
})];

@@ -94,6 +95,7 @@ case 1:

return [4 /*yield*/, (0, buildDatafile_1.buildDatafile)(projectConfig, datasource, {
schemaVersion: config_1.SCHEMA_VERSION,
schemaVersion: cliOptions.schemaVersion || config_1.SCHEMA_VERSION,
revision: nextRevision,
environment: environment,
tag: tag,
inflate: cliOptions.inflate,
}, existingState)];

@@ -100,0 +102,0 @@ case 7:

@@ -66,3 +66,9 @@ "use strict";

case 0:
_a.trys.push([0, 2, , 3]);
// @TODO: in future, allow yargs options to be defined via plugins
if (parsed.schemaVersion && typeof parsed.schemaVersion !== "string") {
parsed.schemaVersion = parsed.schemaVersion.toString();
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, plugin.handler({

@@ -74,3 +80,3 @@ rootDirectoryPath: rootDirectoryPath,

})];
case 1:
case 2:
result = _a.sent();

@@ -80,9 +86,9 @@ if (result === false) {

}
return [3 /*break*/, 3];
case 2:
return [3 /*break*/, 4];
case 3:
error_1 = _a.sent();
console.error(error_1);
process.exit(1);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}

@@ -89,0 +95,0 @@ });

@@ -61,3 +61,3 @@ "use strict";

exports.DEFAULT_PARSER = "yml";
exports.SCHEMA_VERSION = "1";
exports.SCHEMA_VERSION = "1"; // default schema version
// rootDirectoryPath: path to the root directory of the project (without ending with a slash)

@@ -64,0 +64,0 @@ function getProjectConfig(rootDirectoryPath) {

@@ -11,2 +11,4 @@ import { LogLevel, LogMessage, LogDetails } from "@featurevisor/sdk";

verbose?: boolean;
schemaVersion?: string;
inflate?: number;
}

@@ -13,0 +15,0 @@ export interface Log {

@@ -95,5 +95,6 @@ "use strict";

return [4 /*yield*/, (0, builder_1.buildDatafile)(projectConfig, datasource, {
schemaVersion: config_1.SCHEMA_VERSION,
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
revision: "include-all-features",
environment: options.environment,
inflate: options.inflate,
}, existingState)];

@@ -100,0 +101,0 @@ case 2:

@@ -10,2 +10,4 @@ import { DatafileContent } from "@featurevisor/types";

onlyFailures?: boolean;
schemaVersion?: string;
inflate?: number;
}

@@ -12,0 +14,0 @@ export interface TestPatterns {

@@ -155,5 +155,6 @@ "use strict";

return [4 /*yield*/, (0, builder_1.buildDatafile)(projectConfig, datasource, {
schemaVersion: config_1.SCHEMA_VERSION,
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
revision: "include-all-features",
environment: environment,
inflate: options.inflate,
}, existingState)];

@@ -160,0 +161,0 @@ case 4:

{
"name": "@featurevisor/core",
"version": "1.27.6",
"version": "1.28.0",
"description": "Core package of Featurevisor for Node.js usage",

@@ -43,5 +43,5 @@ "main": "lib/index.js",

"dependencies": {
"@featurevisor/sdk": "^1.27.6",
"@featurevisor/site": "^1.27.5",
"@featurevisor/types": "^1.27.5",
"@featurevisor/sdk": "^1.28.0",
"@featurevisor/site": "^1.28.0",
"@featurevisor/types": "^1.28.0",
"axios": "^1.3.4",

@@ -58,3 +58,3 @@ "js-yaml": "^4.1.0",

},
"gitHead": "f9df0bbdef77915f6718647ff26e0ee1255978f5"
"gitHead": "2ae2980762184d9c47b878edffd0ec36d267df3b"
}

@@ -74,2 +74,4 @@ import { randomBytes } from "crypto";

n: number;
schemaVersion?: string;
inflate?: number;

@@ -95,5 +97,6 @@ populateUuid?: AttributeKey[];

{
schemaVersion: SCHEMA_VERSION,
schemaVersion: options.schemaVersion || SCHEMA_VERSION,
revision: "include-all-features",
environment: options.environment,
inflate: options.inflate,
},

@@ -100,0 +103,0 @@ existingState,

@@ -86,2 +86,4 @@ import { Context } from "@featurevisor/types";

variable?: string;
schemaVersion?: string;
inflate?: number;
}

@@ -107,5 +109,6 @@

{
schemaVersion: SCHEMA_VERSION,
schemaVersion: options.schemaVersion || SCHEMA_VERSION,
revision: "include-all-features",
environment: options.environment,
inflate: options.inflate,
},

@@ -116,3 +119,11 @@ existingState,

console.log(`Datafile build duration: ${datafileBuildDuration}ms`);
console.log(`Datafile size: ${(JSON.stringify(datafileContent).length / 1024).toFixed(2)} kB`);
if (options.inflate) {
console.log("");
console.log("Features count:", Object.keys(datafileContent.features).length);
console.log("Segments count:", Object.keys(datafileContent.segments).length);
console.log("Attributes count:", Object.keys(datafileContent.attributes).length);
}
console.log("");

@@ -173,2 +184,4 @@

variable: parsed.variable || undefined,
schemaVersion: parsed.schemaVersion || undefined,
inflate: parseInt(parsed.inflate, 10) || undefined,
},

@@ -175,0 +188,0 @@ );

@@ -7,2 +7,4 @@ import * as fs from "fs";

DatafileContent,
DatafileContentV1,
DatafileContentV2,
Variation,

@@ -36,2 +38,4 @@ Variable,

revision?: string;
schemaVersion?: string;
inflate?: number;
}

@@ -52,6 +56,7 @@

{
schemaVersion: SCHEMA_VERSION,
schemaVersion: options.schemaVersion || SCHEMA_VERSION,
revision: options.revision || "tester",
environment: options.environment,
features: featuresToInclude,
inflate: options.inflate,
},

@@ -70,2 +75,3 @@ existingState,

features?: FeatureKey[];
inflate?: number;
}

@@ -79,3 +85,3 @@

): Promise<DatafileContent> {
const datafileContent: DatafileContent = {
const datafileContent: DatafileContentV1 = {
schemaVersion: options.schemaVersion,

@@ -336,2 +342,71 @@ revision: options.revision,

// inflate
if (options.inflate) {
const allFeatureKeys = features.map((f) => f.key);
const allSegmentKeys = segments.map((s) => s.key);
const allAttributeKeys = attributes.map((a) => a.key);
for (let i = 0; i < options.inflate; i++) {
// feature
for (const featureKey of allFeatureKeys) {
const originalFeature = features.find((f) => f.key === featureKey) as Feature;
features.unshift({
...originalFeature,
key: `${originalFeature.key}-${i}`,
});
}
// segment
for (const segmentKey of allSegmentKeys) {
const originalSegment = segments.find((s) => s.key === segmentKey) as Segment;
segments.unshift({
...originalSegment,
key: `${originalSegment.key}-${i}`,
});
}
// attribute
for (const attributeKey of allAttributeKeys) {
const originalAttribute = attributes.find((a) => a.key === attributeKey) as Attribute;
attributes.unshift({
...originalAttribute,
key: `${originalAttribute.key}-${i}`,
});
}
}
}
// schema v2
if (options.schemaVersion === "2") {
// v2
const datafileContentV2: DatafileContentV2 = {
schemaVersion: "2",
revision: options.revision,
attributes: {},
segments: {},
features: {},
};
datafileContentV2.attributes = attributes.reduce((acc, attribute) => {
acc[attribute.key] = attribute;
return acc;
}, {});
datafileContentV2.segments = segments.reduce((acc, segment) => {
acc[segment.key] = segment;
return acc;
}, {});
datafileContentV2.features = features.reduce((acc, feature) => {
acc[feature.key] = feature;
return acc;
}, {});
return datafileContentV2;
}
// default behaviour
datafileContent.attributes = attributes;

@@ -338,0 +413,0 @@ datafileContent.segments = segments;

@@ -10,2 +10,3 @@ import { SCHEMA_VERSION } from "../config";

revision?: string;
schemaVersion?: string;

@@ -18,2 +19,3 @@ // all three together

stateFiles?: boolean; // --no-state-files in CLI
inflate?: number;
}

@@ -41,2 +43,3 @@

revision: cliOptions.revision,
schemaVersion: cliOptions.schemaVersion,
});

@@ -77,6 +80,7 @@

{
schemaVersion: SCHEMA_VERSION,
schemaVersion: cliOptions.schemaVersion || SCHEMA_VERSION,
revision: nextRevision,
environment: environment,
tag: tag,
inflate: cliOptions.inflate,
},

@@ -83,0 +87,0 @@ existingState,

@@ -54,2 +54,7 @@ import { ProjectConfig } from "../config";

handler: async function (parsed: ParsedOptions) {
// @TODO: in future, allow yargs options to be defined via plugins
if (parsed.schemaVersion && typeof parsed.schemaVersion !== "string") {
parsed.schemaVersion = parsed.schemaVersion.toString();
}
try {

@@ -56,0 +61,0 @@ const result = await plugin.handler({

@@ -30,3 +30,3 @@ import * as path from "path";

export const SCHEMA_VERSION = "1";
export const SCHEMA_VERSION = "1"; // default schema version

@@ -33,0 +33,0 @@ export interface ProjectConfig {

@@ -59,2 +59,4 @@ import { Context } from "@featurevisor/types";

verbose?: boolean;
schemaVersion?: string;
inflate?: number;
}

@@ -76,5 +78,6 @@

{
schemaVersion: SCHEMA_VERSION,
schemaVersion: options.schemaVersion || SCHEMA_VERSION,
revision: "include-all-features",
environment: options.environment,
inflate: options.inflate,
},

@@ -81,0 +84,0 @@ existingState,

@@ -22,2 +22,4 @@ import * as fs from "fs";

onlyFailures?: boolean;
schemaVersion?: string;
inflate?: number;
}

@@ -161,5 +163,6 @@

{
schemaVersion: SCHEMA_VERSION,
schemaVersion: options.schemaVersion || SCHEMA_VERSION,
revision: "include-all-features",
environment: environment,
inflate: options.inflate,
},

@@ -166,0 +169,0 @@ existingState,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc