@featurevisor/core 0.53.2 → 0.53.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +8 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/lib/builder/allocator.js.html +1 -1
- package/coverage/lcov-report/lib/builder/index.html +1 -1
- package/coverage/lcov-report/lib/builder/traffic.js.html +1 -1
- package/coverage/lcov-report/src/builder/allocator.ts.html +1 -1
- package/coverage/lcov-report/src/builder/index.html +1 -1
- package/coverage/lcov-report/src/builder/traffic.ts.html +1 -1
- package/lib/builder/buildDatafile.d.ts +1 -1
- package/lib/builder/buildDatafile.js +241 -168
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +1 -1
- package/lib/builder/buildProject.js +99 -40
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/getFeatureRanges.d.ts +1 -1
- package/lib/builder/getFeatureRanges.js +92 -31
- package/lib/builder/getFeatureRanges.js.map +1 -1
- package/lib/datasource/datasource.d.ts +16 -16
- package/lib/datasource/datasource.js +123 -67
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.d.ts +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +75 -18
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-duplicate-segments/index.d.ts +1 -1
- package/lib/find-duplicate-segments/index.js +56 -9
- package/lib/find-duplicate-segments/index.js.map +1 -1
- package/lib/generate-code/index.d.ts +1 -1
- package/lib/generate-code/index.js +67 -23
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.d.ts +1 -1
- package/lib/generate-code/typescript.js +139 -72
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/linter/checkCircularDependency.d.ts +1 -1
- package/lib/linter/checkCircularDependency.js +78 -22
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/linter/groupSchema.js +79 -28
- package/lib/linter/groupSchema.js.map +1 -1
- package/lib/linter/lintProject.js +122 -101
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/restore.d.ts +1 -1
- package/lib/restore.js +53 -11
- package/lib/restore.js.map +1 -1
- package/lib/site/exportSite.d.ts +1 -1
- package/lib/site/exportSite.js +64 -21
- package/lib/site/exportSite.js.map +1 -1
- package/lib/site/generateSiteSearchIndex.d.ts +1 -1
- package/lib/site/generateSiteSearchIndex.js +203 -111
- package/lib/site/generateSiteSearchIndex.js.map +1 -1
- package/lib/tester/testFeature.d.ts +1 -1
- package/lib/tester/testFeature.js +127 -59
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +1 -1
- package/lib/tester/testProject.js +105 -48
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +1 -1
- package/lib/tester/testSegment.js +69 -21
- package/lib/tester/testSegment.js.map +1 -1
- package/package.json +2 -2
- package/src/builder/buildDatafile.ts +9 -9
- package/src/builder/buildProject.ts +2 -2
- package/src/builder/getFeatureRanges.ts +4 -4
- package/src/datasource/datasource.ts +22 -69
- package/src/find-duplicate-segments/findDuplicateSegments.ts +9 -6
- package/src/find-duplicate-segments/index.ts +5 -2
- package/src/generate-code/index.ts +2 -2
- package/src/generate-code/typescript.ts +42 -25
- package/src/linter/checkCircularDependency.ts +4 -4
- package/src/linter/groupSchema.ts +3 -3
- package/src/linter/lintProject.ts +39 -39
- package/src/restore.ts +1 -1
- package/src/site/exportSite.ts +2 -2
- package/src/site/generateSiteSearchIndex.ts +14 -14
- package/src/tester/testFeature.ts +8 -6
- package/src/tester/testProject.ts +8 -5
- package/src/tester/testSegment.ts +3 -3
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.buildProject = exports.getExistingStateFilePath = exports.getDatafilePath = void 0;
|
|
4
40
|
var fs = require("fs");
|
|
@@ -18,46 +54,69 @@ function getExistingStateFilePath(projectConfig, environment) {
|
|
|
18
54
|
exports.getExistingStateFilePath = getExistingStateFilePath;
|
|
19
55
|
function buildProject(rootDirectoryPath, projectConfig, cliOptions) {
|
|
20
56
|
if (cliOptions === void 0) { cliOptions = {}; }
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var tags, environments, pkg, datasource, _i, environments_1, environment, existingStateFilePath, existingState, _a, tags_1, tag, datafileContent, outputEnvironmentDirPath, outputFilePath, shortPath;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
switch (_b.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
tags = projectConfig.tags;
|
|
63
|
+
environments = projectConfig.environments;
|
|
64
|
+
pkg = require(path.join(rootDirectoryPath, "package.json"));
|
|
65
|
+
datasource = new datasource_1.Datasource(projectConfig);
|
|
66
|
+
_i = 0, environments_1 = environments;
|
|
67
|
+
_b.label = 1;
|
|
68
|
+
case 1:
|
|
69
|
+
if (!(_i < environments_1.length)) return [3 /*break*/, 7];
|
|
70
|
+
environment = environments_1[_i];
|
|
71
|
+
console.log("\nBuilding datafiles for environment: ".concat(environment));
|
|
72
|
+
existingStateFilePath = getExistingStateFilePath(projectConfig, environment);
|
|
73
|
+
existingState = fs.existsSync(existingStateFilePath)
|
|
74
|
+
? require(existingStateFilePath)
|
|
75
|
+
: {
|
|
76
|
+
features: {},
|
|
77
|
+
};
|
|
78
|
+
_a = 0, tags_1 = tags;
|
|
79
|
+
_b.label = 2;
|
|
80
|
+
case 2:
|
|
81
|
+
if (!(_a < tags_1.length)) return [3 /*break*/, 5];
|
|
82
|
+
tag = tags_1[_a];
|
|
83
|
+
console.log("\n => Tag: ".concat(tag));
|
|
84
|
+
return [4 /*yield*/, (0, buildDatafile_1.buildDatafile)(projectConfig, datasource, {
|
|
85
|
+
schemaVersion: config_1.SCHEMA_VERSION,
|
|
86
|
+
revision: cliOptions.revision || pkg.version,
|
|
87
|
+
environment: environment,
|
|
88
|
+
tag: tag,
|
|
89
|
+
}, existingState)];
|
|
90
|
+
case 3:
|
|
91
|
+
datafileContent = _b.sent();
|
|
92
|
+
outputEnvironmentDirPath = path.join(projectConfig.outputDirectoryPath, environment);
|
|
93
|
+
mkdirp.sync(outputEnvironmentDirPath);
|
|
94
|
+
outputFilePath = getDatafilePath(projectConfig, environment, tag);
|
|
95
|
+
fs.writeFileSync(outputFilePath, projectConfig.prettyDatafile
|
|
96
|
+
? JSON.stringify(datafileContent, null, 2)
|
|
97
|
+
: JSON.stringify(datafileContent));
|
|
98
|
+
shortPath = outputFilePath.replace(rootDirectoryPath + path.sep, "");
|
|
99
|
+
console.log(" Datafile generated: ".concat(shortPath));
|
|
100
|
+
_b.label = 4;
|
|
101
|
+
case 4:
|
|
102
|
+
_a++;
|
|
103
|
+
return [3 /*break*/, 2];
|
|
104
|
+
case 5:
|
|
105
|
+
// write state for environment
|
|
106
|
+
if (!fs.existsSync(projectConfig.stateDirectoryPath)) {
|
|
107
|
+
mkdirp.sync(projectConfig.stateDirectoryPath);
|
|
108
|
+
}
|
|
109
|
+
fs.writeFileSync(existingStateFilePath, projectConfig.prettyState
|
|
110
|
+
? JSON.stringify(existingState, null, 2)
|
|
111
|
+
: JSON.stringify(existingState));
|
|
112
|
+
_b.label = 6;
|
|
113
|
+
case 6:
|
|
114
|
+
_i++;
|
|
115
|
+
return [3 /*break*/, 1];
|
|
116
|
+
case 7: return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
61
120
|
}
|
|
62
121
|
exports.buildProject = buildProject;
|
|
63
122
|
//# sourceMappingURL=buildProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProject.js","sourceRoot":"","sources":["../../src/builder/buildProject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildProject.js","sourceRoot":"","sources":["../../src/builder/buildProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAyB;AACzB,2BAA6B;AAE7B,+BAAiC;AAIjC,oCAA0D;AAC1D,4CAA2C;AAE3C,iDAAgD;AAEhD,SAAgB,eAAe,CAC7B,aAA4B,EAC5B,WAA2B,EAC3B,GAAW;IAEX,IAAM,QAAQ,GAAG,uBAAgB,GAAG,UAAO,CAAC;IAE5C,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mBAAmB,EAAE,WAAW,EAAE,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ectConfig: ProjectConfig, datasource: Datasource): FeatureRangesResult
|
|
11
|
+
export declare function getFeatureRanges(projectConfig: ProjectConfig, datasource: Datasource): Promise<FeatureRangesResult>;
|
|
@@ -10,41 +10,102 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
50
|
exports.getFeatureRanges = void 0;
|
|
15
51
|
var fs = require("fs");
|
|
16
52
|
function getFeatureRanges(projectConfig, datasource) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var featureRanges, featureIsInGroup, groups, groupFiles, _loop_1, _i, groupFiles_1, groupKey;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
featureRanges = new Map();
|
|
59
|
+
featureIsInGroup = {};
|
|
60
|
+
groups = [];
|
|
61
|
+
if (!fs.existsSync(projectConfig.groupsDirectoryPath)) return [3 /*break*/, 5];
|
|
62
|
+
return [4 /*yield*/, datasource.listGroups()];
|
|
63
|
+
case 1:
|
|
64
|
+
groupFiles = _a.sent();
|
|
65
|
+
_loop_1 = function (groupKey) {
|
|
66
|
+
var parsedGroup, accumulatedPercentage;
|
|
67
|
+
return __generator(this, function (_b) {
|
|
68
|
+
switch (_b.label) {
|
|
69
|
+
case 0: return [4 /*yield*/, datasource.readGroup(groupKey)];
|
|
70
|
+
case 1:
|
|
71
|
+
parsedGroup = _b.sent();
|
|
72
|
+
groups.push(__assign(__assign({}, parsedGroup), { key: groupKey }));
|
|
73
|
+
accumulatedPercentage = 0;
|
|
74
|
+
parsedGroup.slots.forEach(function (slot, slotIndex) {
|
|
75
|
+
var isFirstSlot = slotIndex === 0;
|
|
76
|
+
if (slot.feature) {
|
|
77
|
+
var featureKey = slot.feature;
|
|
78
|
+
if (typeof featureKey === "string") {
|
|
79
|
+
featureIsInGroup[featureKey] = true;
|
|
80
|
+
}
|
|
81
|
+
var featureRangesForFeature = featureRanges.get(featureKey) || [];
|
|
82
|
+
var start = isFirstSlot ? accumulatedPercentage : accumulatedPercentage + 1;
|
|
83
|
+
var end = accumulatedPercentage + slot.percentage * 1000;
|
|
84
|
+
featureRangesForFeature.push([start, end]);
|
|
85
|
+
featureRanges.set(slot.feature, featureRangesForFeature);
|
|
86
|
+
}
|
|
87
|
+
accumulatedPercentage += slot.percentage * 1000;
|
|
88
|
+
});
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
_i = 0, groupFiles_1 = groupFiles;
|
|
94
|
+
_a.label = 2;
|
|
95
|
+
case 2:
|
|
96
|
+
if (!(_i < groupFiles_1.length)) return [3 /*break*/, 5];
|
|
97
|
+
groupKey = groupFiles_1[_i];
|
|
98
|
+
return [5 /*yield**/, _loop_1(groupKey)];
|
|
99
|
+
case 3:
|
|
100
|
+
_a.sent();
|
|
101
|
+
_a.label = 4;
|
|
102
|
+
case 4:
|
|
103
|
+
_i++;
|
|
104
|
+
return [3 /*break*/, 2];
|
|
105
|
+
case 5: return [2 /*return*/, { featureRanges: featureRanges, featureIsInGroup: featureIsInGroup }];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
48
109
|
}
|
|
49
110
|
exports.getFeatureRanges = getFeatureRanges;
|
|
50
111
|
//# sourceMappingURL=getFeatureRanges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeatureRanges.js","sourceRoot":"","sources":["../../src/builder/getFeatureRanges.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFeatureRanges.js","sourceRoot":"","sources":["../../src/builder/getFeatureRanges.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAyB;AAczB,SAAsB,gBAAgB,CACpC,aAA4B,EAC5B,UAAsB;;;;;;oBAEhB,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;oBAC/C,gBAAgB,GAAG,EAAE,CAAC;oBAEtB,MAAM,GAAY,EAAE,CAAC;yBACvB,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,mBAAmB,CAAC,EAAhD,wBAAgD;oBAC/B,qBAAM,UAAU,CAAC,UAAU,EAAE,EAAA;;oBAA1C,UAAU,GAAG,SAA6B;wCAErC,QAAQ;;;;wCACG,qBAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAA;;oCAAlD,WAAW,GAAG,SAAoC;oCAExD,MAAM,CAAC,IAAI,uBACN,WAAW,KACd,GAAG,EAAE,QAAQ,IACb,CAAC;oCAEC,qBAAqB,GAAG,CAAC,CAAC;oCAC9B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,SAAS;wCACjD,IAAM,WAAW,GAAG,SAAS,KAAK,CAAC,CAAC;wCAEpC,IAAI,IAAI,CAAC,OAAO,EAAE;4CAChB,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;4CAEhC,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;gDAClC,gBAAgB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;6CACrC;4CAED,IAAM,uBAAuB,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;4CAEpE,IAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAC;4CAC9E,IAAM,GAAG,GAAG,qBAAqB,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;4CAE3D,uBAAuB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;4CAE3C,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;yCAC1D;wCAED,qBAAqB,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;oCAClD,CAAC,CAAC,CAAC;;;;;0BA9B4B,EAAV,yBAAU;;;yBAAV,CAAA,wBAAU,CAAA;oBAAtB,QAAQ;kDAAR,QAAQ;;;;;oBAAI,IAAU,CAAA;;wBAkCnC,sBAAO,EAAE,aAAa,eAAA,EAAE,gBAAgB,kBAAA,EAAE,EAAC;;;;CAC5C;AA9CD,4CA8CC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParsedFeature, Segment, Attribute, Group, FeatureKey, Test } from "@featurevisor/types";
|
|
2
2
|
import { ProjectConfig } from "../config";
|
|
3
3
|
export type EntityType = "feature" | "group" | "segment" | "attribute" | "test";
|
|
4
4
|
export declare class Datasource {
|
|
@@ -10,24 +10,24 @@ export declare class Datasource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Common methods
|
|
12
12
|
*/
|
|
13
|
-
listEntities(entityType: EntityType): string[]
|
|
13
|
+
listEntities(entityType: EntityType): Promise<string[]>;
|
|
14
14
|
getEntityDirectoryPath(entityType: EntityType): string;
|
|
15
15
|
getEntityPath(entityType: EntityType, entityKey: string): string;
|
|
16
|
-
entityExists(entityType: EntityType, entityKey: string): boolean
|
|
17
|
-
readEntity(entityType: EntityType, entityKey: string): string
|
|
18
|
-
parseEntity<T>(entityType: EntityType, entityKey: string): T
|
|
16
|
+
entityExists(entityType: EntityType, entityKey: string): Promise<boolean>;
|
|
17
|
+
readEntity(entityType: EntityType, entityKey: string): Promise<string>;
|
|
18
|
+
parseEntity<T>(entityType: EntityType, entityKey: string): Promise<T>;
|
|
19
19
|
/**
|
|
20
20
|
* Entity specific methods
|
|
21
21
|
*/
|
|
22
|
-
listFeatures(
|
|
23
|
-
readFeature(featureKey: string): ParsedFeature
|
|
24
|
-
getRequiredFeaturesChain(featureKey: FeatureKey, chain?: Set<string>): Set<FeatureKey
|
|
25
|
-
listSegments(
|
|
26
|
-
readSegment(segmentKey: string): Segment
|
|
27
|
-
listAttributes(
|
|
28
|
-
readAttribute(attributeKey: string): Attribute
|
|
29
|
-
listGroups(
|
|
30
|
-
readGroup(groupKey: string): Group
|
|
31
|
-
listTests(): string[]
|
|
32
|
-
readTest(testKey: string): Test
|
|
22
|
+
listFeatures(): Promise<string[]>;
|
|
23
|
+
readFeature(featureKey: string): Promise<ParsedFeature>;
|
|
24
|
+
getRequiredFeaturesChain(featureKey: FeatureKey, chain?: Set<string>): Promise<Set<FeatureKey>>;
|
|
25
|
+
listSegments(): Promise<string[]>;
|
|
26
|
+
readSegment(segmentKey: string): Promise<Segment>;
|
|
27
|
+
listAttributes(): Promise<string[]>;
|
|
28
|
+
readAttribute(attributeKey: string): Promise<Attribute>;
|
|
29
|
+
listGroups(): Promise<string[]>;
|
|
30
|
+
readGroup(groupKey: string): Promise<Group>;
|
|
31
|
+
listTests(): Promise<string[]>;
|
|
32
|
+
readTest(testKey: string): Promise<Test>;
|
|
33
33
|
}
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.Datasource = void 0;
|
|
4
40
|
var path = require("path");
|
|
@@ -37,12 +73,17 @@ var Datasource = /** @class */ (function () {
|
|
|
37
73
|
* Common methods
|
|
38
74
|
*/
|
|
39
75
|
Datasource.prototype.listEntities = function (entityType) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var directoryPath;
|
|
78
|
+
var _this = this;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
directoryPath = this.getEntityDirectoryPath(entityType);
|
|
81
|
+
return [2 /*return*/, fs
|
|
82
|
+
.readdirSync(directoryPath)
|
|
83
|
+
.filter(function (fileName) { return fileName.endsWith(".".concat(_this.extension)); })
|
|
84
|
+
.map(function (fileName) { return fileName.replace(".".concat(_this.extension), ""); })];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
46
87
|
};
|
|
47
88
|
Datasource.prototype.getEntityDirectoryPath = function (entityType) {
|
|
48
89
|
if (entityType === "feature") {
|
|
@@ -64,97 +105,112 @@ var Datasource = /** @class */ (function () {
|
|
|
64
105
|
return path.join(basePath, "".concat(entityKey, ".").concat(this.extension));
|
|
65
106
|
};
|
|
66
107
|
Datasource.prototype.entityExists = function (entityType, entityKey) {
|
|
67
|
-
|
|
68
|
-
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var entityPath;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
entityPath = this.getEntityPath(entityType, entityKey);
|
|
112
|
+
return [2 /*return*/, fs.existsSync(entityPath)];
|
|
113
|
+
});
|
|
114
|
+
});
|
|
69
115
|
};
|
|
70
116
|
Datasource.prototype.readEntity = function (entityType, entityKey) {
|
|
71
|
-
|
|
72
|
-
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var filePath;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
filePath = this.getEntityPath(entityType, entityKey);
|
|
121
|
+
return [2 /*return*/, fs.readFileSync(filePath, "utf8")];
|
|
122
|
+
});
|
|
123
|
+
});
|
|
73
124
|
};
|
|
74
125
|
Datasource.prototype.parseEntity = function (entityType, entityKey) {
|
|
75
|
-
|
|
76
|
-
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var entityContent;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0: return [4 /*yield*/, this.readEntity(entityType, entityKey)];
|
|
131
|
+
case 1:
|
|
132
|
+
entityContent = _a.sent();
|
|
133
|
+
return [2 /*return*/, this.parse(entityContent)];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
77
137
|
};
|
|
78
138
|
/**
|
|
79
139
|
* Entity specific methods
|
|
80
140
|
*/
|
|
81
141
|
// features
|
|
82
|
-
Datasource.prototype.listFeatures = function (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
142
|
+
Datasource.prototype.listFeatures = function () {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0: return [4 /*yield*/, this.listEntities("feature")];
|
|
147
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
148
|
+
}
|
|
89
149
|
});
|
|
90
|
-
}
|
|
91
|
-
return features;
|
|
150
|
+
});
|
|
92
151
|
};
|
|
93
152
|
Datasource.prototype.readFeature = function (featureKey) {
|
|
94
153
|
return this.parseEntity("feature", featureKey);
|
|
95
154
|
};
|
|
96
155
|
Datasource.prototype.getRequiredFeaturesChain = function (featureKey, chain) {
|
|
97
|
-
var _this = this;
|
|
98
156
|
if (chain === void 0) { chain = new Set(); }
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var feature, _i, _a, r, requiredKey;
|
|
159
|
+
return __generator(this, function (_b) {
|
|
160
|
+
switch (_b.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
chain.add(featureKey);
|
|
163
|
+
if (!this.entityExists("feature", featureKey)) {
|
|
164
|
+
throw new Error("Feature not found: ".concat(featureKey));
|
|
165
|
+
}
|
|
166
|
+
return [4 /*yield*/, this.readFeature(featureKey)];
|
|
167
|
+
case 1:
|
|
168
|
+
feature = _b.sent();
|
|
169
|
+
if (!feature.required) {
|
|
170
|
+
return [2 /*return*/, chain];
|
|
171
|
+
}
|
|
172
|
+
_i = 0, _a = feature.required;
|
|
173
|
+
_b.label = 2;
|
|
174
|
+
case 2:
|
|
175
|
+
if (!(_i < _a.length)) return [3 /*break*/, 5];
|
|
176
|
+
r = _a[_i];
|
|
177
|
+
requiredKey = typeof r === "string" ? r : r.key;
|
|
178
|
+
if (chain.has(requiredKey)) {
|
|
179
|
+
throw new Error("Circular dependency detected: ".concat(chain.toString()));
|
|
180
|
+
}
|
|
181
|
+
return [4 /*yield*/, this.getRequiredFeaturesChain(requiredKey, chain)];
|
|
182
|
+
case 3:
|
|
183
|
+
_b.sent();
|
|
184
|
+
_b.label = 4;
|
|
185
|
+
case 4:
|
|
186
|
+
_i++;
|
|
187
|
+
return [3 /*break*/, 2];
|
|
188
|
+
case 5: return [2 /*return*/, chain];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
113
191
|
});
|
|
114
|
-
return chain;
|
|
115
192
|
};
|
|
116
193
|
// segments
|
|
117
|
-
Datasource.prototype.listSegments = function (
|
|
118
|
-
|
|
119
|
-
if (segmentsList) {
|
|
120
|
-
return segments.filter(function (segment) {
|
|
121
|
-
return segmentsList.indexOf(segment) !== -1;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return segments;
|
|
194
|
+
Datasource.prototype.listSegments = function () {
|
|
195
|
+
return this.listEntities("segment");
|
|
125
196
|
};
|
|
126
197
|
Datasource.prototype.readSegment = function (segmentKey) {
|
|
127
198
|
return this.parseEntity("segment", segmentKey);
|
|
128
199
|
};
|
|
129
200
|
// attributes
|
|
130
|
-
Datasource.prototype.listAttributes = function (
|
|
131
|
-
|
|
132
|
-
if (attributesList) {
|
|
133
|
-
return attributes.filter(function (segment) {
|
|
134
|
-
return attributesList.indexOf(segment) !== -1;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return attributes;
|
|
201
|
+
Datasource.prototype.listAttributes = function () {
|
|
202
|
+
return this.listEntities("attribute");
|
|
138
203
|
};
|
|
139
204
|
Datasource.prototype.readAttribute = function (attributeKey) {
|
|
140
205
|
return this.parseEntity("attribute", attributeKey);
|
|
141
206
|
};
|
|
142
207
|
// groups
|
|
143
|
-
Datasource.prototype.listGroups = function (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return groups.filter(function (group) {
|
|
148
|
-
var groupContent = _this.parseEntity("group", group);
|
|
149
|
-
return groupContent.slots.some(function (slot) {
|
|
150
|
-
if (!slot.feature) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
return featuresList.indexOf(slot.feature) !== -1;
|
|
154
|
-
});
|
|
208
|
+
Datasource.prototype.listGroups = function () {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
210
|
+
return __generator(this, function (_a) {
|
|
211
|
+
return [2 /*return*/, this.listEntities("group")];
|
|
155
212
|
});
|
|
156
|
-
}
|
|
157
|
-
return groups;
|
|
213
|
+
});
|
|
158
214
|
};
|
|
159
215
|
Datasource.prototype.readGroup = function (groupKey) {
|
|
160
216
|
return this.parseEntity("group", groupKey);
|