@featurevisor/core 1.11.0 → 1.12.0

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.
Files changed (35) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +22 -0
  3. package/LICENSE +1 -1
  4. package/coverage/clover.xml +69 -69
  5. package/coverage/coverage-final.json +2 -2
  6. package/coverage/lcov-report/index.html +7 -7
  7. package/coverage/lcov-report/lib/builder/allocator.js.html +1 -1
  8. package/coverage/lcov-report/lib/builder/index.html +5 -5
  9. package/coverage/lcov-report/lib/builder/revision.js.html +1 -1
  10. package/coverage/lcov-report/lib/builder/traffic.js.html +5 -11
  11. package/coverage/lcov-report/lib/tester/checkIfObjectsAreEqual.js.html +1 -1
  12. package/coverage/lcov-report/lib/tester/index.html +1 -1
  13. package/coverage/lcov-report/lib/tester/matrix.js.html +1 -1
  14. package/coverage/lcov-report/src/builder/allocator.ts.html +1 -1
  15. package/coverage/lcov-report/src/builder/index.html +5 -5
  16. package/coverage/lcov-report/src/builder/revision.ts.html +1 -1
  17. package/coverage/lcov-report/src/builder/traffic.ts.html +6 -15
  18. package/coverage/lcov-report/src/tester/checkIfObjectsAreEqual.ts.html +1 -1
  19. package/coverage/lcov-report/src/tester/index.html +1 -1
  20. package/coverage/lcov-report/src/tester/matrix.ts.html +1 -1
  21. package/coverage/lcov.info +113 -117
  22. package/lib/builder/buildDatafile.js +23 -6
  23. package/lib/builder/buildDatafile.js.map +1 -1
  24. package/lib/builder/traffic.js +1 -3
  25. package/lib/builder/traffic.js.map +1 -1
  26. package/lib/config/projectConfig.d.ts +1 -0
  27. package/lib/config/projectConfig.js +3 -1
  28. package/lib/config/projectConfig.js.map +1 -1
  29. package/lib/tester/testSegment.js +3 -2
  30. package/lib/tester/testSegment.js.map +1 -1
  31. package/package.json +3 -3
  32. package/src/builder/buildDatafile.ts +16 -6
  33. package/src/builder/traffic.ts +2 -5
  34. package/src/config/projectConfig.ts +4 -1
  35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AAC,WAAW,CAAC,EAAE;gCACvF,OAAO;6BACR;4BAED,IAAM,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;4BAC3C,IAAM,MAAM,GAAG,IAAA,6BAAuB,EAAC,UAAU,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;4BAC9E,IAAM,MAAM,GAAG,MAAM,KAAK,QAAQ,CAAC;4BAEnC,IAAI,CAAC,MAAM,EAAE;gCACX,IAAM,wBAAwB,GAA6B;oCACzD,IAAI,EAAE,SAAS;oCACf,QAAQ,UAAA;oCACR,MAAM,QAAA;iCACP,CAAC;gCAED,mBAAmB,CAAC,MAAqC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;gCAC1F,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;gCAC1B,mBAAmB,CAAC,MAAM,GAAG,MAAM,CAAC;6BACrC;4BAED,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;4BAChD,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC;wBACjE,CAAC,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;oBAEH,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC;oBAEjD,sBAAO,UAAU,EAAC;;;;CACnB;AAxED,kCAwEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featurevisor/core",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Core package of Featurevisor for Node.js usage",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
- "@featurevisor/sdk": "^1.3.0",
47
+ "@featurevisor/sdk": "^1.11.1",
48
48
  "@featurevisor/site": "^1.7.1",
49
49
  "@featurevisor/types": "^1.3.0",
50
50
  "axios": "^1.3.4",
@@ -57,5 +57,5 @@
57
57
  "@types/js-yaml": "^4.0.5",
58
58
  "@types/tar": "^6.1.4"
59
59
  },
60
- "gitHead": "92ff9153a53a9a2182c3dc3994dbdca9f76e3dc5"
60
+ "gitHead": "399f2ddc2575ce783f175dab4bd5c761666bd7b4"
61
61
  }
@@ -159,7 +159,9 @@ export async function buildDatafile(
159
159
  );
160
160
 
161
161
  return {
162
- conditions: JSON.stringify(override.conditions),
162
+ conditions: projectConfig.stringify
163
+ ? JSON.stringify(override.conditions)
164
+ : override.conditions,
163
165
  value: override.value,
164
166
  };
165
167
  }
@@ -174,9 +176,9 @@ export async function buildDatafile(
174
176
 
175
177
  return {
176
178
  segments:
177
- typeof override.segments === "string"
178
- ? override.segments
179
- : JSON.stringify(override.segments),
179
+ typeof override.segments !== "string" && projectConfig.stringify
180
+ ? JSON.stringify(override.segments)
181
+ : override.segments,
180
182
  value: override.value,
181
183
  };
182
184
  }
@@ -195,7 +197,15 @@ export async function buildDatafile(
195
197
  parsedFeature.environments[options.environment].rules,
196
198
  existingState.features[featureKey],
197
199
  featureRanges.get(featureKey) || [],
198
- ),
200
+ ).map((t: Traffic) => {
201
+ return {
202
+ ...t,
203
+ segments:
204
+ typeof t.segments !== "string" && projectConfig.stringify
205
+ ? JSON.stringify(t.segments)
206
+ : t.segments,
207
+ };
208
+ }),
199
209
  ranges: featureRanges.get(featureKey) || undefined,
200
210
  };
201
211
 
@@ -278,7 +288,7 @@ export async function buildDatafile(
278
288
  const segment: Segment = {
279
289
  key: segmentKey,
280
290
  conditions:
281
- typeof parsedSegment.conditions !== "string"
291
+ typeof parsedSegment.conditions !== "string" && projectConfig.stringify === true
282
292
  ? JSON.stringify(parsedSegment.conditions)
283
293
  : parsedSegment.conditions,
284
294
  };
@@ -79,11 +79,8 @@ export function getTraffic(
79
79
  const rulePercentage = parsedRule.percentage; // 0 - 100
80
80
 
81
81
  const traffic: Traffic = {
82
- key: parsedRule.key, // @TODO: not needed in datafile. keep it for now
83
- segments:
84
- typeof parsedRule.segments !== "string"
85
- ? JSON.stringify(parsedRule.segments)
86
- : parsedRule.segments,
82
+ key: parsedRule.key,
83
+ segments: parsedRule.segments,
87
84
  percentage: rulePercentage * (MAX_BUCKETED_NUMBER / 100),
88
85
  allocation: [],
89
86
  };
@@ -42,6 +42,7 @@ export interface ProjectConfig {
42
42
  parser: Parser;
43
43
  prettyState: boolean;
44
44
  prettyDatafile: boolean;
45
+ stringify: boolean;
45
46
  siteExportDirectoryPath: string;
46
47
  adapter: any; // @TODO: type this properly later
47
48
  }
@@ -66,6 +67,7 @@ export function getProjectConfig(rootDirectoryPath: string): ProjectConfig {
66
67
 
67
68
  prettyState: DEFAULT_PRETTY_STATE,
68
69
  prettyDatafile: DEFAULT_PRETTY_DATAFILE,
70
+ stringify: true,
69
71
 
70
72
  siteExportDirectoryPath: path.join(rootDirectoryPath, SITE_EXPORT_DIRECTORY_NAME),
71
73
 
@@ -78,7 +80,8 @@ export function getProjectConfig(rootDirectoryPath: string): ProjectConfig {
78
80
  const mergedConfig = {};
79
81
 
80
82
  Object.keys(baseConfig).forEach((key) => {
81
- mergedConfig[key] = customConfig[key] || baseConfig[key];
83
+ mergedConfig[key] =
84
+ typeof customConfig[key] !== "undefined" ? customConfig[key] : baseConfig[key];
82
85
 
83
86
  if (key.endsWith("Path") && mergedConfig[key].indexOf(ROOT_DIR_PLACEHOLDER) !== -1) {
84
87
  mergedConfig[key] = mergedConfig[key].replace(ROOT_DIR_PLACEHOLDER, rootDirectoryPath);
@@ -5,7 +5,7 @@ import {
5
5
  TestResultAssertion,
6
6
  TestResultAssertionError,
7
7
  } from "@featurevisor/types";
8
- import { allConditionsAreMatched } from "@featurevisor/sdk";
8
+ import { allConditionsAreMatched, createLogger } from "@featurevisor/sdk";
9
9
 
10
10
  import { Datasource } from "../datasource";
11
11
 
@@ -41,6 +41,7 @@ export async function testSegment(
41
41
 
42
42
  const parsedSegment = await datasource.readSegment(segmentKey);
43
43
  const conditions = parsedSegment.conditions as Condition | Condition[];
44
+ const logger = createLogger();
44
45
 
45
46
  test.assertions.forEach(function (assertion, aIndex) {
46
47
  const assertions = getSegmentAssertionsFromMatrix(aIndex, assertion);
@@ -59,7 +60,7 @@ export async function testSegment(
59
60
  }
60
61
 
61
62
  const expected = assertion.expectedToMatch;
62
- const actual = allConditionsAreMatched(conditions, assertion.context);
63
+ const actual = allConditionsAreMatched(conditions, assertion.context, logger);
63
64
  const passed = actual === expected;
64
65
 
65
66
  if (!passed) {