@featurevisor/core 2.26.1 → 3.0.1

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 (390) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/coverage/clover.xml +4991 -3130
  3. package/coverage/coverage-final.json +63 -39
  4. package/coverage/lcov-report/block-navigation.js +1 -1
  5. package/coverage/lcov-report/index.html +248 -98
  6. package/coverage/lcov-report/sorter.js +21 -7
  7. package/coverage/lcov-report/src/assess-distribution/index.html +116 -0
  8. package/coverage/lcov-report/src/assess-distribution/index.ts.html +754 -0
  9. package/coverage/lcov-report/{list → src/benchmark}/index.html +30 -30
  10. package/coverage/lcov-report/src/benchmark/index.ts.html +793 -0
  11. package/coverage/lcov-report/{builder → src/builder}/allocator.ts.html +38 -38
  12. package/coverage/lcov-report/{builder/buildScopedConditions.ts.html → src/builder/applyContextToConditions.ts.html} +80 -65
  13. package/coverage/lcov-report/{builder/buildScopedDatafile.ts.html → src/builder/applyContextToDatafile.ts.html} +92 -92
  14. package/coverage/lcov-report/{builder/buildScopedSegments.ts.html → src/builder/applyContextToSegments.ts.html} +103 -67
  15. package/coverage/lcov-report/{builder → src/builder}/buildDatafile.ts.html +336 -306
  16. package/coverage/lcov-report/src/builder/buildProject.ts.html +1117 -0
  17. package/coverage/lcov-report/src/builder/buildRuntimeDatafiles.ts.html +256 -0
  18. package/coverage/lcov-report/{builder → src/builder}/getFeatureRanges.ts.html +22 -22
  19. package/coverage/lcov-report/{builder → src/builder}/hashes.ts.html +50 -50
  20. package/coverage/lcov-report/{builder → src/builder}/index.html +114 -84
  21. package/coverage/lcov-report/{tester/cliFormat.ts.html → src/builder/index.ts.html} +17 -29
  22. package/coverage/lcov-report/{builder → src/builder}/mutateVariables.ts.html +55 -55
  23. package/coverage/lcov-report/{builder → src/builder}/mutator.ts.html +118 -118
  24. package/coverage/lcov-report/{builder → src/builder}/revision.ts.html +15 -15
  25. package/coverage/lcov-report/{builder → src/builder}/traffic.ts.html +86 -86
  26. package/coverage/lcov-report/src/cli/cli.ts.html +400 -0
  27. package/coverage/lcov-report/{tester → src/cli}/index.html +41 -41
  28. package/coverage/lcov-report/src/cli/plugins.ts.html +214 -0
  29. package/coverage/lcov-report/{config → src/config}/index.html +31 -31
  30. package/coverage/lcov-report/{config → src/config}/index.ts.html +12 -12
  31. package/coverage/lcov-report/{config → src/config}/projectConfig.ts.html +312 -96
  32. package/coverage/lcov-report/{datasource → src/datasource}/adapter.ts.html +28 -73
  33. package/coverage/lcov-report/{datasource → src/datasource}/datasource.ts.html +191 -104
  34. package/coverage/lcov-report/{datasource → src/datasource}/filesystemAdapter.ts.html +233 -635
  35. package/coverage/lcov-report/{datasource → src/datasource}/index.html +48 -48
  36. package/coverage/lcov-report/{datasource → src/datasource}/index.ts.html +14 -14
  37. package/coverage/lcov-report/src/evaluate/index.html +116 -0
  38. package/coverage/lcov-report/src/evaluate/index.ts.html +814 -0
  39. package/coverage/lcov-report/src/find-duplicate-segments/findDuplicateSegments.ts.html +313 -0
  40. package/coverage/lcov-report/src/find-duplicate-segments/index.html +131 -0
  41. package/coverage/lcov-report/src/find-duplicate-segments/index.ts.html +307 -0
  42. package/coverage/lcov-report/src/find-usage/index.html +116 -0
  43. package/coverage/lcov-report/src/find-usage/index.ts.html +1780 -0
  44. package/coverage/lcov-report/src/generate-code/index.html +131 -0
  45. package/coverage/lcov-report/src/generate-code/index.ts.html +403 -0
  46. package/coverage/lcov-report/{generate-code → src/generate-code}/typescript.ts.html +266 -1361
  47. package/coverage/lcov-report/{generate-code → src}/index.html +38 -23
  48. package/coverage/lcov-report/src/info/index.html +116 -0
  49. package/coverage/lcov-report/src/info/index.ts.html +472 -0
  50. package/coverage/lcov-report/src/init/index.html +116 -0
  51. package/coverage/lcov-report/src/init/index.ts.html +280 -0
  52. package/coverage/lcov-report/{linter → src/linter}/attributeSchema.ts.html +160 -157
  53. package/coverage/lcov-report/{linter → src/linter}/checkCircularDependency.ts.html +25 -25
  54. package/coverage/lcov-report/{linter → src/linter}/checkPercentageExceedingSlot.ts.html +42 -42
  55. package/coverage/lcov-report/{linter → src/linter}/conditionSchema.ts.html +207 -207
  56. package/coverage/lcov-report/{linter → src/linter}/featureSchema.ts.html +462 -471
  57. package/coverage/lcov-report/{linter → src/linter}/groupSchema.ts.html +25 -22
  58. package/coverage/lcov-report/{linter → src/linter}/index.html +129 -99
  59. package/coverage/lcov-report/src/linter/index.ts.html +88 -0
  60. package/coverage/lcov-report/{linter → src/linter}/lintProject.ts.html +740 -332
  61. package/coverage/lcov-report/{linter → src/linter}/mutationNotation.ts.html +130 -130
  62. package/coverage/lcov-report/{linter → src/linter}/printError.ts.html +27 -27
  63. package/coverage/lcov-report/{linter → src/linter}/schema.ts.html +153 -150
  64. package/coverage/lcov-report/{linter → src/linter}/segmentSchema.ts.html +18 -15
  65. package/coverage/lcov-report/src/linter/targetSchema.ts.html +223 -0
  66. package/coverage/lcov-report/{linter → src/linter}/testSchema.ts.html +54 -48
  67. package/coverage/lcov-report/{linter → src/linter}/zodHelpers.ts.html +17 -17
  68. package/coverage/lcov-report/src/list/index.html +131 -0
  69. package/coverage/lcov-report/src/list/index.ts.html +2065 -0
  70. package/coverage/lcov-report/{list → src/list}/matrix.ts.html +43 -58
  71. package/coverage/lcov-report/src/promoter/index.html +116 -0
  72. package/coverage/lcov-report/src/promoter/index.ts.html +3883 -0
  73. package/coverage/lcov-report/src/sets.ts.html +313 -0
  74. package/coverage/lcov-report/src/targeting.ts.html +403 -0
  75. package/coverage/lcov-report/src/tester/cliFormat.ts.html +133 -0
  76. package/coverage/lcov-report/{tester → src/tester}/helpers.ts.html +15 -15
  77. package/coverage/lcov-report/src/tester/index.html +206 -0
  78. package/coverage/lcov-report/src/tester/prettyDuration.ts.html +187 -0
  79. package/coverage/lcov-report/src/tester/printTestResult.ts.html +337 -0
  80. package/coverage/lcov-report/src/tester/testFeature.ts.html +1186 -0
  81. package/coverage/lcov-report/src/tester/testProject.ts.html +1018 -0
  82. package/coverage/lcov-report/src/tester/testSegment.ts.html +316 -0
  83. package/coverage/lcov-report/{utils → src/utils}/extractKeys.ts.html +68 -68
  84. package/coverage/lcov-report/{utils → src/utils}/git.ts.html +44 -68
  85. package/coverage/lcov-report/{utils → src/utils}/index.html +44 -44
  86. package/coverage/lcov-report/{utils → src/utils}/index.ts.html +14 -14
  87. package/coverage/lcov-report/{utils → src/utils}/pretty.ts.html +20 -20
  88. package/coverage/lcov.info +10121 -5723
  89. package/jest.config.js +13 -4
  90. package/lib/assess-distribution/index.d.ts +1 -1
  91. package/lib/assess-distribution/index.js +59 -40
  92. package/lib/assess-distribution/index.js.map +1 -1
  93. package/lib/benchmark/index.d.ts +8 -5
  94. package/lib/benchmark/index.js +82 -65
  95. package/lib/benchmark/index.js.map +1 -1
  96. package/lib/builder/applyContextToConditions.d.ts +5 -0
  97. package/lib/builder/{buildScopedConditions.js → applyContextToConditions.js} +19 -14
  98. package/lib/builder/applyContextToConditions.js.map +1 -0
  99. package/lib/builder/applyContextToDatafile.d.ts +2 -0
  100. package/lib/builder/{buildScopedDatafile.js → applyContextToDatafile.js} +26 -26
  101. package/lib/builder/applyContextToDatafile.js.map +1 -0
  102. package/lib/builder/applyContextToSegments.d.ts +5 -0
  103. package/lib/builder/{buildScopedSegments.js → applyContextToSegments.js} +19 -14
  104. package/lib/builder/applyContextToSegments.js.map +1 -0
  105. package/lib/builder/buildDatafile.d.ts +9 -6
  106. package/lib/builder/buildDatafile.js +86 -51
  107. package/lib/builder/buildDatafile.js.map +1 -1
  108. package/lib/builder/buildProject.d.ts +17 -3
  109. package/lib/builder/buildProject.js +151 -59
  110. package/lib/builder/buildProject.js.map +1 -1
  111. package/lib/builder/buildRuntimeDatafiles.d.ts +12 -0
  112. package/lib/builder/buildRuntimeDatafiles.js +35 -0
  113. package/lib/builder/buildRuntimeDatafiles.js.map +1 -0
  114. package/lib/builder/getFeatureRanges.js +34 -1
  115. package/lib/builder/getFeatureRanges.js.map +1 -1
  116. package/lib/builder/hashes.js +34 -1
  117. package/lib/builder/hashes.js.map +1 -1
  118. package/lib/builder/index.d.ts +0 -1
  119. package/lib/builder/index.js +0 -1
  120. package/lib/builder/index.js.map +1 -1
  121. package/lib/cli/cli.js +0 -4
  122. package/lib/cli/cli.js.map +1 -1
  123. package/lib/cli/plugins.js +7 -2
  124. package/lib/cli/plugins.js.map +1 -1
  125. package/lib/config/projectConfig.d.ts +17 -17
  126. package/lib/config/projectConfig.js +101 -15
  127. package/lib/config/projectConfig.js.map +1 -1
  128. package/lib/datasource/adapter.d.ts +7 -9
  129. package/lib/datasource/adapter.js +0 -7
  130. package/lib/datasource/adapter.js.map +1 -1
  131. package/lib/datasource/datasource.d.ts +15 -5
  132. package/lib/datasource/datasource.js +37 -9
  133. package/lib/datasource/datasource.js.map +1 -1
  134. package/lib/datasource/filesystemAdapter.d.ts +4 -10
  135. package/lib/datasource/filesystemAdapter.js +111 -149
  136. package/lib/datasource/filesystemAdapter.js.map +1 -1
  137. package/lib/evaluate/index.d.ts +1 -7
  138. package/lib/evaluate/index.js +81 -67
  139. package/lib/evaluate/index.js.map +1 -1
  140. package/lib/find-duplicate-segments/findDuplicateSegments.js +34 -1
  141. package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
  142. package/lib/find-duplicate-segments/index.js +21 -13
  143. package/lib/find-duplicate-segments/index.js.map +1 -1
  144. package/lib/find-usage/index.js +57 -41
  145. package/lib/find-usage/index.js.map +1 -1
  146. package/lib/generate-code/index.d.ts +1 -1
  147. package/lib/generate-code/index.js +64 -21
  148. package/lib/generate-code/index.js.map +1 -1
  149. package/lib/generate-code/typescript.d.ts +1 -1
  150. package/lib/generate-code/typescript.js +59 -333
  151. package/lib/generate-code/typescript.js.map +1 -1
  152. package/lib/index.d.ts +2 -1
  153. package/lib/index.js +2 -1
  154. package/lib/index.js.map +1 -1
  155. package/lib/info/index.js +57 -16
  156. package/lib/info/index.js.map +1 -1
  157. package/lib/init/index.d.ts +2 -2
  158. package/lib/init/index.js +39 -3
  159. package/lib/init/index.js.map +1 -1
  160. package/lib/linter/attributeSchema.d.ts +1 -0
  161. package/lib/linter/attributeSchema.js +1 -0
  162. package/lib/linter/attributeSchema.js.map +1 -1
  163. package/lib/linter/conditionSchema.js +5 -5
  164. package/lib/linter/conditionSchema.js.map +1 -1
  165. package/lib/linter/featureSchema.d.ts +4 -1
  166. package/lib/linter/featureSchema.js +15 -13
  167. package/lib/linter/featureSchema.js.map +1 -1
  168. package/lib/linter/groupSchema.d.ts +1 -0
  169. package/lib/linter/groupSchema.js +1 -0
  170. package/lib/linter/groupSchema.js.map +1 -1
  171. package/lib/linter/lintProject.d.ts +1 -3
  172. package/lib/linter/lintProject.js +198 -68
  173. package/lib/linter/lintProject.js.map +1 -1
  174. package/lib/linter/schema.js +1 -0
  175. package/lib/linter/schema.js.map +1 -1
  176. package/lib/linter/segmentSchema.d.ts +1 -0
  177. package/lib/linter/segmentSchema.js +1 -0
  178. package/lib/linter/segmentSchema.js.map +1 -1
  179. package/lib/linter/targetSchema.d.ts +16 -0
  180. package/lib/linter/targetSchema.js +40 -0
  181. package/lib/linter/targetSchema.js.map +1 -0
  182. package/lib/linter/testSchema.d.ts +4 -3
  183. package/lib/linter/testSchema.js +9 -4
  184. package/lib/linter/testSchema.js.map +1 -1
  185. package/lib/list/index.d.ts +1 -0
  186. package/lib/list/index.js +131 -12
  187. package/lib/list/index.js.map +1 -1
  188. package/lib/list/matrix.js +3 -7
  189. package/lib/list/matrix.js.map +1 -1
  190. package/lib/promoter/index.d.ts +50 -0
  191. package/lib/promoter/index.js +880 -0
  192. package/lib/promoter/index.js.map +1 -0
  193. package/lib/sets.d.ts +11 -0
  194. package/lib/sets.js +81 -0
  195. package/lib/sets.js.map +1 -0
  196. package/lib/targeting.d.ts +14 -0
  197. package/lib/targeting.js +82 -0
  198. package/lib/targeting.js.map +1 -0
  199. package/lib/tester/cliFormat.d.ts +7 -1
  200. package/lib/tester/cliFormat.js +11 -2
  201. package/lib/tester/cliFormat.js.map +1 -1
  202. package/lib/tester/printTestResult.js +2 -2
  203. package/lib/tester/printTestResult.js.map +1 -1
  204. package/lib/tester/testFeature.d.ts +0 -1
  205. package/lib/tester/testFeature.js +8 -25
  206. package/lib/tester/testFeature.js.map +1 -1
  207. package/lib/tester/testProject.d.ts +2 -3
  208. package/lib/tester/testProject.js +93 -86
  209. package/lib/tester/testProject.js.map +1 -1
  210. package/lib/tester/testSegment.d.ts +1 -1
  211. package/lib/tester/testSegment.js +3 -21
  212. package/lib/tester/testSegment.js.map +1 -1
  213. package/lib/utils/git.js +45 -19
  214. package/lib/utils/git.js.map +1 -1
  215. package/package.json +12 -12
  216. package/src/assess-distribution/index.ts +72 -52
  217. package/src/benchmark/index.ts +124 -91
  218. package/src/builder/{buildScopedConditions.spec.ts → applyContextToConditions.spec.ts} +160 -142
  219. package/src/builder/{buildScopedConditions.ts → applyContextToConditions.ts} +19 -14
  220. package/src/builder/{buildScopedDatafile.spec.ts → applyContextToDatafile.spec.ts} +141 -81
  221. package/src/builder/{buildScopedDatafile.ts → applyContextToDatafile.ts} +33 -33
  222. package/src/builder/{buildScopedSegments.spec.ts → applyContextToSegments.spec.ts} +171 -151
  223. package/src/builder/{buildScopedSegments.ts → applyContextToSegments.ts} +26 -14
  224. package/src/builder/buildDatafile.spec.ts +192 -14
  225. package/src/builder/buildDatafile.ts +74 -64
  226. package/src/builder/buildProject.ts +171 -86
  227. package/src/builder/buildRuntimeDatafiles.ts +57 -0
  228. package/src/builder/index.ts +0 -1
  229. package/src/cli/cli.ts +0 -5
  230. package/src/cli/plugins.ts +7 -2
  231. package/src/config/projectConfig.spec.ts +171 -8
  232. package/src/config/projectConfig.ts +100 -28
  233. package/src/datasource/adapter.ts +8 -23
  234. package/src/datasource/datasource.ts +50 -21
  235. package/src/datasource/filesystemAdapter.spec.ts +133 -74
  236. package/src/datasource/filesystemAdapter.ts +93 -227
  237. package/src/evaluate/index.ts +109 -97
  238. package/src/find-duplicate-segments/index.ts +34 -16
  239. package/src/find-usage/index.ts +89 -44
  240. package/src/generate-code/index.ts +36 -24
  241. package/src/generate-code/typescript.spec.ts +106 -0
  242. package/src/generate-code/typescript.ts +33 -398
  243. package/src/index.ts +2 -1
  244. package/src/info/index.ts +72 -16
  245. package/src/init/index.ts +1 -1
  246. package/src/linter/attributeSchema.ts +1 -0
  247. package/src/linter/conditionSchema.spec.ts +23 -3
  248. package/src/linter/conditionSchema.ts +5 -5
  249. package/src/linter/featureSchema.spec.ts +107 -18
  250. package/src/linter/featureSchema.ts +25 -28
  251. package/src/linter/groupSchema.ts +1 -0
  252. package/src/linter/lintProject.spec.ts +131 -92
  253. package/src/linter/lintProject.ts +233 -97
  254. package/src/linter/schema.ts +1 -0
  255. package/src/linter/segmentSchema.spec.ts +5 -3
  256. package/src/linter/segmentSchema.ts +1 -0
  257. package/src/linter/targetSchema.spec.ts +159 -0
  258. package/src/linter/targetSchema.ts +46 -0
  259. package/src/linter/testSchema.spec.ts +70 -5
  260. package/src/linter/testSchema.ts +12 -10
  261. package/src/list/index.spec.ts +135 -0
  262. package/src/list/index.ts +188 -12
  263. package/src/list/matrix.ts +3 -8
  264. package/src/promoter/index.spec.ts +617 -0
  265. package/src/promoter/index.ts +1266 -0
  266. package/src/sets.ts +76 -0
  267. package/src/targeting.spec.ts +74 -0
  268. package/src/targeting.ts +106 -0
  269. package/src/tester/cliFormat.ts +11 -1
  270. package/src/tester/printTestResult.ts +12 -3
  271. package/src/tester/testFeature.ts +10 -36
  272. package/src/tester/testProject.spec.ts +50 -0
  273. package/src/tester/testProject.ts +89 -140
  274. package/src/tester/testSegment.ts +5 -22
  275. package/src/utils/git.ts +13 -21
  276. package/tsconfig.cjs.json +5 -1
  277. package/tsconfig.typecheck.json +9 -0
  278. package/coverage/lcov-report/builder/convertToV1.ts.html +0 -583
  279. package/lib/builder/allocator.spec.d.ts +0 -1
  280. package/lib/builder/allocator.spec.js +0 -85
  281. package/lib/builder/allocator.spec.js.map +0 -1
  282. package/lib/builder/buildDatafile.spec.d.ts +0 -1
  283. package/lib/builder/buildDatafile.spec.js +0 -233
  284. package/lib/builder/buildDatafile.spec.js.map +0 -1
  285. package/lib/builder/buildScopedConditions.d.ts +0 -5
  286. package/lib/builder/buildScopedConditions.js.map +0 -1
  287. package/lib/builder/buildScopedConditions.spec.d.ts +0 -1
  288. package/lib/builder/buildScopedConditions.spec.js +0 -2167
  289. package/lib/builder/buildScopedConditions.spec.js.map +0 -1
  290. package/lib/builder/buildScopedDatafile.d.ts +0 -2
  291. package/lib/builder/buildScopedDatafile.js.map +0 -1
  292. package/lib/builder/buildScopedDatafile.spec.d.ts +0 -1
  293. package/lib/builder/buildScopedDatafile.spec.js +0 -2277
  294. package/lib/builder/buildScopedDatafile.spec.js.map +0 -1
  295. package/lib/builder/buildScopedSegments.d.ts +0 -5
  296. package/lib/builder/buildScopedSegments.js.map +0 -1
  297. package/lib/builder/buildScopedSegments.spec.d.ts +0 -1
  298. package/lib/builder/buildScopedSegments.spec.js +0 -1062
  299. package/lib/builder/buildScopedSegments.spec.js.map +0 -1
  300. package/lib/builder/convertToV1.d.ts +0 -10
  301. package/lib/builder/convertToV1.js +0 -119
  302. package/lib/builder/convertToV1.js.map +0 -1
  303. package/lib/builder/mutateVariables.spec.d.ts +0 -1
  304. package/lib/builder/mutateVariables.spec.js +0 -1074
  305. package/lib/builder/mutateVariables.spec.js.map +0 -1
  306. package/lib/builder/mutator.spec.d.ts +0 -1
  307. package/lib/builder/mutator.spec.js +0 -368
  308. package/lib/builder/mutator.spec.js.map +0 -1
  309. package/lib/builder/revision.spec.d.ts +0 -1
  310. package/lib/builder/revision.spec.js +0 -21
  311. package/lib/builder/revision.spec.js.map +0 -1
  312. package/lib/builder/traffic.spec.d.ts +0 -1
  313. package/lib/builder/traffic.spec.js +0 -872
  314. package/lib/builder/traffic.spec.js.map +0 -1
  315. package/lib/config/projectConfig.spec.d.ts +0 -1
  316. package/lib/config/projectConfig.spec.js +0 -24
  317. package/lib/config/projectConfig.spec.js.map +0 -1
  318. package/lib/datasource/filesystemAdapter.spec.d.ts +0 -1
  319. package/lib/datasource/filesystemAdapter.spec.js +0 -88
  320. package/lib/datasource/filesystemAdapter.spec.js.map +0 -1
  321. package/lib/generate-code/typescript.spec.d.ts +0 -1
  322. package/lib/generate-code/typescript.spec.js +0 -78
  323. package/lib/generate-code/typescript.spec.js.map +0 -1
  324. package/lib/linter/attributeSchema.spec.d.ts +0 -1
  325. package/lib/linter/attributeSchema.spec.js +0 -266
  326. package/lib/linter/attributeSchema.spec.js.map +0 -1
  327. package/lib/linter/conditionSchema.spec.d.ts +0 -1
  328. package/lib/linter/conditionSchema.spec.js +0 -380
  329. package/lib/linter/conditionSchema.spec.js.map +0 -1
  330. package/lib/linter/featureSchema.spec.d.ts +0 -1
  331. package/lib/linter/featureSchema.spec.js +0 -1552
  332. package/lib/linter/featureSchema.spec.js.map +0 -1
  333. package/lib/linter/lintProject.spec.d.ts +0 -1
  334. package/lib/linter/lintProject.spec.js +0 -211
  335. package/lib/linter/lintProject.spec.js.map +0 -1
  336. package/lib/linter/mutationNotation.spec.d.ts +0 -1
  337. package/lib/linter/mutationNotation.spec.js +0 -598
  338. package/lib/linter/mutationNotation.spec.js.map +0 -1
  339. package/lib/linter/schema.spec.d.ts +0 -1
  340. package/lib/linter/schema.spec.js +0 -535
  341. package/lib/linter/schema.spec.js.map +0 -1
  342. package/lib/linter/segmentSchema.spec.d.ts +0 -1
  343. package/lib/linter/segmentSchema.spec.js +0 -303
  344. package/lib/linter/segmentSchema.spec.js.map +0 -1
  345. package/lib/linter/testSchema.spec.d.ts +0 -1
  346. package/lib/linter/testSchema.spec.js +0 -162
  347. package/lib/linter/testSchema.spec.js.map +0 -1
  348. package/lib/list/matrix.spec.d.ts +0 -1
  349. package/lib/list/matrix.spec.js +0 -42
  350. package/lib/list/matrix.spec.js.map +0 -1
  351. package/lib/site/exportSite.d.ts +0 -2
  352. package/lib/site/exportSite.js +0 -30
  353. package/lib/site/exportSite.js.map +0 -1
  354. package/lib/site/generateHistory.d.ts +0 -3
  355. package/lib/site/generateHistory.js +0 -31
  356. package/lib/site/generateHistory.js.map +0 -1
  357. package/lib/site/generateSiteSearchIndex.d.ts +0 -4
  358. package/lib/site/generateSiteSearchIndex.js +0 -195
  359. package/lib/site/generateSiteSearchIndex.js.map +0 -1
  360. package/lib/site/getLastModifiedFromHistory.d.ts +0 -2
  361. package/lib/site/getLastModifiedFromHistory.js +0 -18
  362. package/lib/site/getLastModifiedFromHistory.js.map +0 -1
  363. package/lib/site/getOwnerAndRepoFromUrl.d.ts +0 -4
  364. package/lib/site/getOwnerAndRepoFromUrl.js +0 -20
  365. package/lib/site/getOwnerAndRepoFromUrl.js.map +0 -1
  366. package/lib/site/getRelativePaths.d.ts +0 -6
  367. package/lib/site/getRelativePaths.js +0 -15
  368. package/lib/site/getRelativePaths.js.map +0 -1
  369. package/lib/site/getRepoDetails.d.ts +0 -8
  370. package/lib/site/getRepoDetails.js +0 -48
  371. package/lib/site/getRepoDetails.js.map +0 -1
  372. package/lib/site/index.d.ts +0 -2
  373. package/lib/site/index.js +0 -43
  374. package/lib/site/index.js.map +0 -1
  375. package/lib/site/serveSite.d.ts +0 -2
  376. package/lib/site/serveSite.js +0 -54
  377. package/lib/site/serveSite.js.map +0 -1
  378. package/lib/tester/helpers.spec.d.ts +0 -1
  379. package/lib/tester/helpers.spec.js +0 -115
  380. package/lib/tester/helpers.spec.js.map +0 -1
  381. package/src/builder/convertToV1.ts +0 -166
  382. package/src/site/exportSite.ts +0 -42
  383. package/src/site/generateHistory.ts +0 -40
  384. package/src/site/generateSiteSearchIndex.ts +0 -258
  385. package/src/site/getLastModifiedFromHistory.ts +0 -21
  386. package/src/site/getOwnerAndRepoFromUrl.ts +0 -17
  387. package/src/site/getRelativePaths.ts +0 -24
  388. package/src/site/getRepoDetails.ts +0 -62
  389. package/src/site/index.ts +0 -46
  390. package/src/site/serveSite.ts +0 -58
@@ -1,9 +1,9 @@
1
1
  import type { DatafileContent } from "@featurevisor/types";
2
- import { buildScopedDatafile } from "./buildScopedDatafile";
2
+ import { applyContextToDatafile } from "./applyContextToDatafile";
3
3
 
4
- describe("core: buildScopedDatafile", function () {
5
- test("buildScopedDatafile is a function", function () {
6
- expect(buildScopedDatafile).toBeInstanceOf(Function);
4
+ describe("core: applyContextToDatafile", function () {
5
+ test("applyContextToDatafile is a function", function () {
6
+ expect(applyContextToDatafile).toBeInstanceOf(Function);
7
7
  });
8
8
 
9
9
  describe("basic functionality", function () {
@@ -15,7 +15,7 @@ describe("core: buildScopedDatafile", function () {
15
15
  features: {},
16
16
  };
17
17
 
18
- const result = buildScopedDatafile(datafile, {});
18
+ const result = applyContextToDatafile(datafile, {});
19
19
 
20
20
  expect(result).toEqual(datafile);
21
21
  });
@@ -39,7 +39,7 @@ describe("core: buildScopedDatafile", function () {
39
39
  },
40
40
  };
41
41
 
42
- const result = buildScopedDatafile(datafile, {});
42
+ const result = applyContextToDatafile(datafile, {});
43
43
 
44
44
  expect(result.segments).toEqual({});
45
45
  expect(result.features.feature1).toBeDefined();
@@ -57,7 +57,7 @@ describe("core: buildScopedDatafile", function () {
57
57
  features: {},
58
58
  };
59
59
 
60
- const result = buildScopedDatafile(datafile, { platform: "web" });
60
+ const result = applyContextToDatafile(datafile, { platform: "web" });
61
61
 
62
62
  expect(result.segments).toEqual({});
63
63
  expect(result.features).toEqual({});
@@ -77,7 +77,7 @@ describe("core: buildScopedDatafile", function () {
77
77
  features: {},
78
78
  };
79
79
 
80
- const result = buildScopedDatafile(datafile, { platform: "web" });
80
+ const result = applyContextToDatafile(datafile, { platform: "web" });
81
81
 
82
82
  expect(result.segments).toEqual({});
83
83
  });
@@ -94,7 +94,7 @@ describe("core: buildScopedDatafile", function () {
94
94
  features: {},
95
95
  };
96
96
 
97
- const result = buildScopedDatafile(datafile, { platform: "mobile" });
97
+ const result = applyContextToDatafile(datafile, { platform: "mobile" });
98
98
 
99
99
  expect(result.segments.web).toBeDefined();
100
100
  expect(result.segments.web.conditions).toEqual([
@@ -114,7 +114,7 @@ describe("core: buildScopedDatafile", function () {
114
114
  features: {},
115
115
  };
116
116
 
117
- const result = buildScopedDatafile(datafile, {});
117
+ const result = applyContextToDatafile(datafile, {});
118
118
 
119
119
  expect(result.segments).toEqual({});
120
120
  });
@@ -137,7 +137,7 @@ describe("core: buildScopedDatafile", function () {
137
137
  features: {},
138
138
  };
139
139
 
140
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
140
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
141
141
 
142
142
  expect(result.segments.web).toBeUndefined();
143
143
  expect(result.segments.mobile).toBeDefined();
@@ -161,7 +161,7 @@ describe("core: buildScopedDatafile", function () {
161
161
  features: {},
162
162
  };
163
163
 
164
- const result = buildScopedDatafile(datafile, { tier: "premium", status: "active" });
164
+ const result = applyContextToDatafile(datafile, { tier: "premium", status: "active" });
165
165
 
166
166
  expect(result.segments).toEqual({});
167
167
  });
@@ -183,7 +183,7 @@ describe("core: buildScopedDatafile", function () {
183
183
  features: {},
184
184
  };
185
185
 
186
- const result = buildScopedDatafile(datafile, { tier: "premium" });
186
+ const result = applyContextToDatafile(datafile, { tier: "premium" });
187
187
 
188
188
  expect(result.segments.premium).toBeDefined();
189
189
  expect(result.segments.premium.conditions).toEqual({
@@ -208,7 +208,7 @@ describe("core: buildScopedDatafile", function () {
208
208
  features: {},
209
209
  };
210
210
 
211
- const result = buildScopedDatafile(datafile, { browser: "chrome" });
211
+ const result = applyContextToDatafile(datafile, { browser: "chrome" });
212
212
 
213
213
  expect(result.segments).toEqual({
214
214
  browser: {
@@ -241,7 +241,7 @@ describe("core: buildScopedDatafile", function () {
241
241
  features: {},
242
242
  };
243
243
 
244
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
244
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
245
245
 
246
246
  expect(result.segments).toEqual({});
247
247
  });
@@ -261,7 +261,7 @@ describe("core: buildScopedDatafile", function () {
261
261
  features: {},
262
262
  };
263
263
 
264
- const result = buildScopedDatafile(datafile, { platform: "web" });
264
+ const result = applyContextToDatafile(datafile, { platform: "web" });
265
265
 
266
266
  expect(result.segments.combined).toBeDefined();
267
267
  expect(result.segments.combined.conditions).toEqual([
@@ -294,7 +294,7 @@ describe("core: buildScopedDatafile", function () {
294
294
  },
295
295
  };
296
296
 
297
- const result = buildScopedDatafile(datafile, { platform: "web" });
297
+ const result = applyContextToDatafile(datafile, { platform: "web" });
298
298
 
299
299
  expect(result.features.feature1.force?.[0].segments).toEqual("*");
300
300
  });
@@ -322,7 +322,7 @@ describe("core: buildScopedDatafile", function () {
322
322
  },
323
323
  };
324
324
 
325
- const result = buildScopedDatafile(datafile, { platform: "mobile" });
325
+ const result = applyContextToDatafile(datafile, { platform: "mobile" });
326
326
 
327
327
  expect(result.features.feature1.force?.[0].segments).toEqual("web");
328
328
  });
@@ -346,7 +346,7 @@ describe("core: buildScopedDatafile", function () {
346
346
  },
347
347
  };
348
348
 
349
- const result = buildScopedDatafile(datafile, { platform: "web" });
349
+ const result = applyContextToDatafile(datafile, { platform: "web" });
350
350
 
351
351
  expect(result.features.feature1.force?.[0].conditions).toEqual("*");
352
352
  });
@@ -370,7 +370,7 @@ describe("core: buildScopedDatafile", function () {
370
370
  },
371
371
  };
372
372
 
373
- const result = buildScopedDatafile(datafile, { platform: "mobile" });
373
+ const result = applyContextToDatafile(datafile, { platform: "mobile" });
374
374
 
375
375
  expect(result.features.feature1.force?.[0].conditions).toEqual([
376
376
  { attribute: "platform", operator: "equals", value: "web" },
@@ -403,7 +403,7 @@ describe("core: buildScopedDatafile", function () {
403
403
  },
404
404
  };
405
405
 
406
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
406
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
407
407
 
408
408
  expect(result.features.feature1.force?.[0].segments).toEqual("*");
409
409
  });
@@ -434,7 +434,7 @@ describe("core: buildScopedDatafile", function () {
434
434
  },
435
435
  };
436
436
 
437
- const result = buildScopedDatafile(datafile, { platform: "web" });
437
+ const result = applyContextToDatafile(datafile, { platform: "web" });
438
438
 
439
439
  expect(result.features.feature1.force?.[0].segments).toEqual(["chrome"]);
440
440
  });
@@ -465,7 +465,7 @@ describe("core: buildScopedDatafile", function () {
465
465
  },
466
466
  };
467
467
 
468
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
468
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
469
469
 
470
470
  expect(result.features.feature1.force?.[0].segments).toEqual("*");
471
471
  });
@@ -496,7 +496,7 @@ describe("core: buildScopedDatafile", function () {
496
496
  },
497
497
  };
498
498
 
499
- const result = buildScopedDatafile(datafile, { platform: "web" });
499
+ const result = applyContextToDatafile(datafile, { platform: "web" });
500
500
 
501
501
  expect(result.features.feature1.force?.[0].segments).toEqual({ or: ["mobile"] });
502
502
  });
@@ -525,7 +525,7 @@ describe("core: buildScopedDatafile", function () {
525
525
  },
526
526
  };
527
527
 
528
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
528
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
529
529
 
530
530
  expect(result.features.feature1.force?.[0].conditions).toEqual("*");
531
531
  });
@@ -554,7 +554,7 @@ describe("core: buildScopedDatafile", function () {
554
554
  },
555
555
  };
556
556
 
557
- const result = buildScopedDatafile(datafile, { platform: "web" });
557
+ const result = applyContextToDatafile(datafile, { platform: "web" });
558
558
 
559
559
  expect(result.features.feature1.force?.[0].conditions).toEqual({
560
560
  or: [{ attribute: "platform", operator: "equals", value: "mobile" }],
@@ -591,7 +591,7 @@ describe("core: buildScopedDatafile", function () {
591
591
  },
592
592
  };
593
593
 
594
- const result = buildScopedDatafile(datafile, { platform: "web" });
594
+ const result = applyContextToDatafile(datafile, { platform: "web" });
595
595
 
596
596
  expect(result.features.feature1.force?.[0].segments).toEqual("*");
597
597
  expect(result.features.feature1.force?.[1].segments).toEqual("mobile");
@@ -622,7 +622,7 @@ describe("core: buildScopedDatafile", function () {
622
622
  },
623
623
  };
624
624
 
625
- const result = buildScopedDatafile(datafile, { platform: "web" });
625
+ const result = applyContextToDatafile(datafile, { platform: "web" });
626
626
 
627
627
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
628
628
  });
@@ -650,7 +650,7 @@ describe("core: buildScopedDatafile", function () {
650
650
  },
651
651
  };
652
652
 
653
- const result = buildScopedDatafile(datafile, { platform: "mobile" });
653
+ const result = applyContextToDatafile(datafile, { platform: "mobile" });
654
654
 
655
655
  expect(result.features.feature1.traffic[0].segments).toEqual("web");
656
656
  });
@@ -681,7 +681,7 @@ describe("core: buildScopedDatafile", function () {
681
681
  },
682
682
  };
683
683
 
684
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
684
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
685
685
 
686
686
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
687
687
  });
@@ -712,7 +712,7 @@ describe("core: buildScopedDatafile", function () {
712
712
  },
713
713
  };
714
714
 
715
- const result = buildScopedDatafile(datafile, { platform: "web" });
715
+ const result = applyContextToDatafile(datafile, { platform: "web" });
716
716
 
717
717
  expect(result.features.feature1.traffic[0].segments).toEqual(["chrome"]);
718
718
  });
@@ -743,7 +743,7 @@ describe("core: buildScopedDatafile", function () {
743
743
  },
744
744
  };
745
745
 
746
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
746
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
747
747
 
748
748
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
749
749
  });
@@ -774,7 +774,7 @@ describe("core: buildScopedDatafile", function () {
774
774
  },
775
775
  };
776
776
 
777
- const result = buildScopedDatafile(datafile, { platform: "web" });
777
+ const result = applyContextToDatafile(datafile, { platform: "web" });
778
778
 
779
779
  expect(result.features.feature1.traffic[0].segments).toEqual({ or: ["mobile"] });
780
780
  });
@@ -810,7 +810,7 @@ describe("core: buildScopedDatafile", function () {
810
810
  },
811
811
  };
812
812
 
813
- const result = buildScopedDatafile(datafile, { platform: "web" });
813
+ const result = applyContextToDatafile(datafile, { platform: "web" });
814
814
 
815
815
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
816
816
  expect(result.features.feature1.traffic[1].segments).toEqual("mobile");
@@ -844,7 +844,7 @@ describe("core: buildScopedDatafile", function () {
844
844
  },
845
845
  };
846
846
 
847
- const result = buildScopedDatafile(datafile, {});
847
+ const result = applyContextToDatafile(datafile, {});
848
848
 
849
849
  expect(result.features.feature1.traffic).toHaveLength(1);
850
850
  expect(result.features.feature1.traffic[0].key).toEqual("rule1");
@@ -873,7 +873,7 @@ describe("core: buildScopedDatafile", function () {
873
873
  },
874
874
  };
875
875
 
876
- const result = buildScopedDatafile(datafile, { platform: "web" });
876
+ const result = applyContextToDatafile(datafile, { platform: "web" });
877
877
 
878
878
  expect(result.features.feature1.traffic).toHaveLength(1);
879
879
  expect(result.features.feature1.traffic[0].key).toEqual("rule1");
@@ -916,7 +916,7 @@ describe("core: buildScopedDatafile", function () {
916
916
  },
917
917
  };
918
918
 
919
- const result = buildScopedDatafile(datafile, {});
919
+ const result = applyContextToDatafile(datafile, {});
920
920
 
921
921
  expect(result.features.feature1.traffic).toHaveLength(3);
922
922
  });
@@ -949,7 +949,7 @@ describe("core: buildScopedDatafile", function () {
949
949
  },
950
950
  };
951
951
 
952
- const result = buildScopedDatafile(datafile, { platform: "web" });
952
+ const result = applyContextToDatafile(datafile, { platform: "web" });
953
953
 
954
954
  expect(result.features.feature1.traffic).toHaveLength(1);
955
955
  expect(result.features.feature1.traffic[0].key).toEqual("rule1");
@@ -983,7 +983,7 @@ describe("core: buildScopedDatafile", function () {
983
983
  },
984
984
  };
985
985
 
986
- const result = buildScopedDatafile(datafile, { device: "mobile" });
986
+ const result = applyContextToDatafile(datafile, { device: "mobile" });
987
987
 
988
988
  expect(result.features.feature1.traffic[0].variableOverrides?.config[0].segments).toEqual(
989
989
  "*",
@@ -1016,7 +1016,7 @@ describe("core: buildScopedDatafile", function () {
1016
1016
  },
1017
1017
  };
1018
1018
 
1019
- const result = buildScopedDatafile(datafile, { device: "desktop" });
1019
+ const result = applyContextToDatafile(datafile, { device: "desktop" });
1020
1020
 
1021
1021
  expect(result.features.feature1.traffic[0].variableOverrides?.config[0].segments).toEqual(
1022
1022
  "mobile",
@@ -1050,7 +1050,7 @@ describe("core: buildScopedDatafile", function () {
1050
1050
  },
1051
1051
  };
1052
1052
 
1053
- const result = buildScopedDatafile(datafile, { country: "nl" });
1053
+ const result = applyContextToDatafile(datafile, { country: "nl" });
1054
1054
 
1055
1055
  expect(result.features.feature1.traffic[0].variableOverrides?.config[0].conditions).toEqual(
1056
1056
  "*",
@@ -1084,7 +1084,7 @@ describe("core: buildScopedDatafile", function () {
1084
1084
  },
1085
1085
  };
1086
1086
 
1087
- const result = buildScopedDatafile(datafile, { country: "de" });
1087
+ const result = applyContextToDatafile(datafile, { country: "de" });
1088
1088
 
1089
1089
  expect(result.features.feature1.traffic[0].variableOverrides?.config[0].conditions).toEqual([
1090
1090
  { attribute: "country", operator: "equals", value: "nl" },
@@ -1134,7 +1134,7 @@ describe("core: buildScopedDatafile", function () {
1134
1134
  },
1135
1135
  };
1136
1136
 
1137
- const result = buildScopedDatafile(datafile, {
1137
+ const result = applyContextToDatafile(datafile, {
1138
1138
  device: "mobile",
1139
1139
  touch: true,
1140
1140
  country: "nl",
@@ -1189,7 +1189,7 @@ describe("core: buildScopedDatafile", function () {
1189
1189
  },
1190
1190
  };
1191
1191
 
1192
- const result = buildScopedDatafile(datafile, {
1192
+ const result = applyContextToDatafile(datafile, {
1193
1193
  device: "mobile",
1194
1194
  touch: true,
1195
1195
  country: "nl",
@@ -1240,7 +1240,7 @@ describe("core: buildScopedDatafile", function () {
1240
1240
  },
1241
1241
  };
1242
1242
 
1243
- const result = buildScopedDatafile(datafile, {
1243
+ const result = applyContextToDatafile(datafile, {
1244
1244
  platform: "web",
1245
1245
  device: "mobile",
1246
1246
  });
@@ -1280,7 +1280,7 @@ describe("core: buildScopedDatafile", function () {
1280
1280
 
1281
1281
  const original = JSON.stringify(datafile);
1282
1282
 
1283
- buildScopedDatafile(datafile, { device: "mobile" });
1283
+ applyContextToDatafile(datafile, { device: "mobile" });
1284
1284
 
1285
1285
  expect(JSON.stringify(datafile)).toEqual(original);
1286
1286
  });
@@ -1317,7 +1317,7 @@ describe("core: buildScopedDatafile", function () {
1317
1317
  },
1318
1318
  };
1319
1319
 
1320
- const result = buildScopedDatafile(datafile, { platform: "web" });
1320
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1321
1321
 
1322
1322
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1323
1323
  "*",
@@ -1354,7 +1354,7 @@ describe("core: buildScopedDatafile", function () {
1354
1354
  },
1355
1355
  };
1356
1356
 
1357
- const result = buildScopedDatafile(datafile, { platform: "mobile" });
1357
+ const result = applyContextToDatafile(datafile, { platform: "mobile" });
1358
1358
 
1359
1359
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1360
1360
  "web",
@@ -1387,7 +1387,7 @@ describe("core: buildScopedDatafile", function () {
1387
1387
  },
1388
1388
  };
1389
1389
 
1390
- const result = buildScopedDatafile(datafile, { platform: "web" });
1390
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1391
1391
 
1392
1392
  expect(
1393
1393
  result.features.feature1.variations?.[0].variableOverrides?.color[0].conditions,
@@ -1420,7 +1420,7 @@ describe("core: buildScopedDatafile", function () {
1420
1420
  },
1421
1421
  };
1422
1422
 
1423
- const result = buildScopedDatafile(datafile, { platform: "mobile" });
1423
+ const result = applyContextToDatafile(datafile, { platform: "mobile" });
1424
1424
 
1425
1425
  expect(
1426
1426
  result.features.feature1.variations?.[0].variableOverrides?.color[0].conditions,
@@ -1460,7 +1460,7 @@ describe("core: buildScopedDatafile", function () {
1460
1460
  },
1461
1461
  };
1462
1462
 
1463
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
1463
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
1464
1464
 
1465
1465
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1466
1466
  "*",
@@ -1500,7 +1500,7 @@ describe("core: buildScopedDatafile", function () {
1500
1500
  },
1501
1501
  };
1502
1502
 
1503
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
1503
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
1504
1504
 
1505
1505
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1506
1506
  "*",
@@ -1540,7 +1540,7 @@ describe("core: buildScopedDatafile", function () {
1540
1540
  },
1541
1541
  };
1542
1542
 
1543
- const result = buildScopedDatafile(datafile, { platform: "web" });
1543
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1544
1544
 
1545
1545
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1546
1546
  { or: ["mobile"] },
@@ -1578,7 +1578,7 @@ describe("core: buildScopedDatafile", function () {
1578
1578
  },
1579
1579
  };
1580
1580
 
1581
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
1581
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
1582
1582
 
1583
1583
  expect(
1584
1584
  result.features.feature1.variations?.[0].variableOverrides?.color[0].conditions,
@@ -1616,7 +1616,7 @@ describe("core: buildScopedDatafile", function () {
1616
1616
  },
1617
1617
  };
1618
1618
 
1619
- const result = buildScopedDatafile(datafile, { platform: "web" });
1619
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1620
1620
 
1621
1621
  expect(
1622
1622
  result.features.feature1.variations?.[0].variableOverrides?.color[0].conditions,
@@ -1662,7 +1662,7 @@ describe("core: buildScopedDatafile", function () {
1662
1662
  },
1663
1663
  };
1664
1664
 
1665
- const result = buildScopedDatafile(datafile, { platform: "web" });
1665
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1666
1666
 
1667
1667
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1668
1668
  "*",
@@ -1708,7 +1708,7 @@ describe("core: buildScopedDatafile", function () {
1708
1708
  },
1709
1709
  };
1710
1710
 
1711
- const result = buildScopedDatafile(datafile, { platform: "web" });
1711
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1712
1712
 
1713
1713
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1714
1714
  "*",
@@ -1762,7 +1762,7 @@ describe("core: buildScopedDatafile", function () {
1762
1762
  },
1763
1763
  };
1764
1764
 
1765
- const result = buildScopedDatafile(datafile, { platform: "web" });
1765
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1766
1766
 
1767
1767
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
1768
1768
  "*",
@@ -1819,7 +1819,7 @@ describe("core: buildScopedDatafile", function () {
1819
1819
  },
1820
1820
  };
1821
1821
 
1822
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
1822
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
1823
1823
 
1824
1824
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
1825
1825
  expect(result.features.feature1.force?.[0].segments).toEqual("*");
@@ -1864,13 +1864,13 @@ describe("core: buildScopedDatafile", function () {
1864
1864
  },
1865
1865
  };
1866
1866
 
1867
- const result = buildScopedDatafile(datafile, { platform: "web" });
1867
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1868
1868
 
1869
1869
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
1870
1870
  expect(result.features.feature2.traffic[0].segments).toEqual("mobile");
1871
1871
  });
1872
1872
 
1873
- test("segment used in multiple places - all scoped correctly", function () {
1873
+ test("segment used in multiple places - context applied everywhere", function () {
1874
1874
  const datafile: DatafileContent = {
1875
1875
  schemaVersion: "2",
1876
1876
  revision: "unknown",
@@ -1912,7 +1912,7 @@ describe("core: buildScopedDatafile", function () {
1912
1912
  },
1913
1913
  };
1914
1914
 
1915
- const result = buildScopedDatafile(datafile, { platform: "web" });
1915
+ const result = applyContextToDatafile(datafile, { platform: "web" });
1916
1916
 
1917
1917
  expect(result.segments).toEqual({});
1918
1918
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
@@ -1961,7 +1961,7 @@ describe("core: buildScopedDatafile", function () {
1961
1961
  },
1962
1962
  };
1963
1963
 
1964
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
1964
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
1965
1965
 
1966
1966
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
1967
1967
  expect(result.features.feature1.force?.[0].segments).toEqual({ or: ["mobile"] });
@@ -2009,7 +2009,7 @@ describe("core: buildScopedDatafile", function () {
2009
2009
  },
2010
2010
  };
2011
2011
 
2012
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
2012
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
2013
2013
 
2014
2014
  expect(result.features.feature1.force?.[0].conditions).toEqual("*");
2015
2015
  expect(
@@ -2034,7 +2034,7 @@ describe("core: buildScopedDatafile", function () {
2034
2034
  },
2035
2035
  };
2036
2036
 
2037
- const result = buildScopedDatafile(datafile, {});
2037
+ const result = applyContextToDatafile(datafile, {});
2038
2038
 
2039
2039
  expect(result.features.feature1).toBeDefined();
2040
2040
  expect(result.features.feature1.traffic).toEqual([]);
@@ -2054,7 +2054,7 @@ describe("core: buildScopedDatafile", function () {
2054
2054
  },
2055
2055
  };
2056
2056
 
2057
- const result = buildScopedDatafile(datafile, {});
2057
+ const result = applyContextToDatafile(datafile, {});
2058
2058
 
2059
2059
  expect(result.features.feature1.force).toEqual([]);
2060
2060
  });
@@ -2073,7 +2073,7 @@ describe("core: buildScopedDatafile", function () {
2073
2073
  },
2074
2074
  };
2075
2075
 
2076
- const result = buildScopedDatafile(datafile, {});
2076
+ const result = applyContextToDatafile(datafile, {});
2077
2077
 
2078
2078
  expect(result.features.feature1.variations).toEqual([]);
2079
2079
  });
@@ -2096,7 +2096,7 @@ describe("core: buildScopedDatafile", function () {
2096
2096
  },
2097
2097
  };
2098
2098
 
2099
- const result = buildScopedDatafile(datafile, {});
2099
+ const result = applyContextToDatafile(datafile, {});
2100
2100
 
2101
2101
  expect(result.features.feature1.variations?.[0].variableOverrides).toBeUndefined();
2102
2102
  });
@@ -2120,7 +2120,7 @@ describe("core: buildScopedDatafile", function () {
2120
2120
  },
2121
2121
  };
2122
2122
 
2123
- const result = buildScopedDatafile(datafile, {});
2123
+ const result = applyContextToDatafile(datafile, {});
2124
2124
 
2125
2125
  expect(result.features.feature1.variations?.[0].variableOverrides).toEqual({});
2126
2126
  });
@@ -2151,7 +2151,7 @@ describe("core: buildScopedDatafile", function () {
2151
2151
  },
2152
2152
  };
2153
2153
 
2154
- const result = buildScopedDatafile(datafile, {});
2154
+ const result = applyContextToDatafile(datafile, {});
2155
2155
 
2156
2156
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
2157
2157
  "*",
@@ -2182,7 +2182,7 @@ describe("core: buildScopedDatafile", function () {
2182
2182
  },
2183
2183
  };
2184
2184
 
2185
- const result = buildScopedDatafile(datafile, { platform: "web" });
2185
+ const result = applyContextToDatafile(datafile, { platform: "web" });
2186
2186
 
2187
2187
  expect(result.features.feature1.force?.[0].segments).toEqual("*");
2188
2188
  expect(result.features.feature1.force?.[0].conditions).toBeDefined();
@@ -2212,7 +2212,7 @@ describe("core: buildScopedDatafile", function () {
2212
2212
  },
2213
2213
  };
2214
2214
 
2215
- const result = buildScopedDatafile(datafile, {});
2215
+ const result = applyContextToDatafile(datafile, {});
2216
2216
 
2217
2217
  expect(result.features.feature1.traffic).toHaveLength(1);
2218
2218
  });
@@ -2240,7 +2240,7 @@ describe("core: buildScopedDatafile", function () {
2240
2240
  },
2241
2241
  };
2242
2242
 
2243
- const result = buildScopedDatafile(datafile, { platform: "web" });
2243
+ const result = applyContextToDatafile(datafile, { platform: "web" });
2244
2244
 
2245
2245
  expect(result.segments).toEqual({});
2246
2246
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
@@ -2258,7 +2258,7 @@ describe("core: buildScopedDatafile", function () {
2258
2258
  features: {},
2259
2259
  };
2260
2260
 
2261
- const result = buildScopedDatafile(datafile, {
2261
+ const result = applyContextToDatafile(datafile, {
2262
2262
  platform: "web",
2263
2263
  extraAttribute: "extraValue",
2264
2264
  });
@@ -2281,7 +2281,7 @@ describe("core: buildScopedDatafile", function () {
2281
2281
  features: {},
2282
2282
  };
2283
2283
 
2284
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
2284
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
2285
2285
 
2286
2286
  expect(result.segments).toEqual({});
2287
2287
  });
@@ -2301,7 +2301,10 @@ describe("core: buildScopedDatafile", function () {
2301
2301
  features: {},
2302
2302
  };
2303
2303
 
2304
- const result = buildScopedDatafile(datafile, { platform: "mobile", browser: "safari" });
2304
+ const result = applyContextToDatafile(datafile, {
2305
+ platform: "mobile",
2306
+ browser: "safari",
2307
+ });
2305
2308
 
2306
2309
  expect(result.segments.web).toBeDefined();
2307
2310
  expect(result.segments.chrome).toBeDefined();
@@ -2345,7 +2348,7 @@ describe("core: buildScopedDatafile", function () {
2345
2348
  },
2346
2349
  };
2347
2350
 
2348
- const result = buildScopedDatafile(datafile, { platform: "web" });
2351
+ const result = applyContextToDatafile(datafile, { platform: "web" });
2349
2352
 
2350
2353
  expect(result.features.feature1.traffic).toHaveLength(1);
2351
2354
  expect(result.features.feature1.traffic[0].key).toEqual("rule1");
@@ -2381,7 +2384,7 @@ describe("core: buildScopedDatafile", function () {
2381
2384
  },
2382
2385
  };
2383
2386
 
2384
- const result = buildScopedDatafile(datafile, { platform: "web" });
2387
+ const result = applyContextToDatafile(datafile, { platform: "web" });
2385
2388
 
2386
2389
  expect(result.segments).toEqual({});
2387
2390
  expect(result.features.feature1.variations?.[0].variableOverrides?.color[0].segments).toEqual(
@@ -2449,7 +2452,7 @@ describe("core: buildScopedDatafile", function () {
2449
2452
  },
2450
2453
  };
2451
2454
 
2452
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
2455
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
2453
2456
 
2454
2457
  expect(result.segments.web).toBeUndefined();
2455
2458
  expect(result.segments.chrome).toBeUndefined();
@@ -2513,7 +2516,7 @@ describe("core: buildScopedDatafile", function () {
2513
2516
  },
2514
2517
  };
2515
2518
 
2516
- const result = buildScopedDatafile(datafile, { platform: "web", browser: "chrome" });
2519
+ const result = applyContextToDatafile(datafile, { platform: "web", browser: "chrome" });
2517
2520
 
2518
2521
  expect(result.features.feature1.traffic[0].segments).toEqual("*");
2519
2522
  expect(result.features.feature1.force?.[0].conditions).toEqual({
@@ -2531,6 +2534,63 @@ describe("core: buildScopedDatafile", function () {
2531
2534
  });
2532
2535
  });
2533
2536
 
2537
+ test("datafile specialization preserves NOT rules as non-broadening expressions", function () {
2538
+ const datafile: DatafileContent = {
2539
+ schemaVersion: "2",
2540
+ revision: "unknown",
2541
+ segments: {
2542
+ web: {
2543
+ conditions: [{ attribute: "platform", operator: "equals", value: "web" }],
2544
+ },
2545
+ chrome: {
2546
+ conditions: [{ attribute: "browser", operator: "equals", value: "chrome" }],
2547
+ },
2548
+ },
2549
+ features: {
2550
+ feature1: {
2551
+ bucketBy: ["userId"],
2552
+ traffic: [
2553
+ {
2554
+ key: "not-web",
2555
+ segments: {
2556
+ not: ["web"],
2557
+ },
2558
+ percentage: 100000,
2559
+ },
2560
+ {
2561
+ key: "not-web-and-chrome",
2562
+ segments: {
2563
+ not: ["web", "chrome"],
2564
+ },
2565
+ percentage: 100000,
2566
+ },
2567
+ ],
2568
+ },
2569
+ },
2570
+ };
2571
+
2572
+ const webResult = applyContextToDatafile(datafile, { platform: "web" });
2573
+
2574
+ expect(webResult.features.feature1.traffic[0].segments).toEqual({
2575
+ not: ["*"],
2576
+ });
2577
+ expect(webResult.features.feature1.traffic[1].segments).toEqual({
2578
+ not: ["chrome"],
2579
+ });
2580
+
2581
+ const webChromeResult = applyContextToDatafile(datafile, {
2582
+ platform: "web",
2583
+ browser: "chrome",
2584
+ });
2585
+
2586
+ expect(webChromeResult.features.feature1.traffic[0].segments).toEqual({
2587
+ not: ["*"],
2588
+ });
2589
+ expect(webChromeResult.features.feature1.traffic[1].segments).toEqual({
2590
+ not: ["*"],
2591
+ });
2592
+ });
2593
+
2534
2594
  test("datafile immutability - original not modified", function () {
2535
2595
  const datafile: DatafileContent = {
2536
2596
  schemaVersion: "2",
@@ -2557,7 +2617,7 @@ describe("core: buildScopedDatafile", function () {
2557
2617
  const originalSegments = JSON.stringify(datafile.segments);
2558
2618
  const originalTraffic = JSON.stringify(datafile.features.feature1.traffic);
2559
2619
 
2560
- buildScopedDatafile(datafile, { platform: "web" });
2620
+ applyContextToDatafile(datafile, { platform: "web" });
2561
2621
 
2562
2622
  expect(JSON.stringify(datafile.segments)).toEqual(originalSegments);
2563
2623
  expect(JSON.stringify(datafile.features.feature1.traffic)).toEqual(originalTraffic);