@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,2167 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const buildScopedConditions_1 = require("./buildScopedConditions");
4
- const sdk_1 = require("@featurevisor/sdk");
5
- describe("core: buildScopedConditions", function () {
6
- const emptyDatafile = {
7
- schemaVersion: "2",
8
- revision: "unknown",
9
- segments: {},
10
- features: {},
11
- };
12
- const datafileReader = new sdk_1.DatafileReader({
13
- datafile: emptyDatafile,
14
- logger: (0, sdk_1.createLogger)({ level: "fatal" }),
15
- });
16
- describe("buildScopedConditions (plural)", function () {
17
- test("buildScopedConditions is a function", function () {
18
- expect(buildScopedConditions_1.buildScopedConditions).toBeInstanceOf(Function);
19
- });
20
- test("simple cases", function () {
21
- // "*" remains "*"
22
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, "*", {})).toEqual("*");
23
- // Plain condition that matches
24
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
25
- attribute: "platform",
26
- operator: "equals",
27
- value: "web",
28
- }, {
29
- platform: "web",
30
- })).toEqual("*");
31
- // Plain condition that doesn't match
32
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
33
- attribute: "platform",
34
- operator: "equals",
35
- value: "web",
36
- }, {
37
- platform: "mobile",
38
- })).toEqual({
39
- attribute: "platform",
40
- operator: "equals",
41
- value: "web",
42
- });
43
- // Array of conditions - partial match (redundant "*" removed)
44
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [
45
- {
46
- attribute: "platform",
47
- operator: "equals",
48
- value: "web",
49
- },
50
- {
51
- attribute: "browser",
52
- operator: "equals",
53
- value: "chrome",
54
- },
55
- ], {
56
- platform: "web",
57
- })).toEqual([
58
- {
59
- attribute: "browser",
60
- operator: "equals",
61
- value: "chrome",
62
- },
63
- ]);
64
- // Array of conditions - full match (all "*" becomes "*")
65
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [
66
- {
67
- attribute: "platform",
68
- operator: "equals",
69
- value: "web",
70
- },
71
- {
72
- attribute: "browser",
73
- operator: "equals",
74
- value: "chrome",
75
- },
76
- ], {
77
- platform: "web",
78
- browser: "chrome",
79
- })).toEqual("*");
80
- // Array of conditions - no match
81
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [
82
- {
83
- attribute: "platform",
84
- operator: "equals",
85
- value: "web",
86
- },
87
- {
88
- attribute: "browser",
89
- operator: "equals",
90
- value: "chrome",
91
- },
92
- ], {
93
- platform: "mobile",
94
- browser: "safari",
95
- })).toEqual([
96
- {
97
- attribute: "platform",
98
- operator: "equals",
99
- value: "web",
100
- },
101
- {
102
- attribute: "browser",
103
- operator: "equals",
104
- value: "chrome",
105
- },
106
- ]);
107
- });
108
- test("AND conditions", function () {
109
- // AND with all matching conditions (all "*" becomes "*")
110
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
111
- and: [
112
- {
113
- attribute: "platform",
114
- operator: "equals",
115
- value: "web",
116
- },
117
- {
118
- attribute: "browser",
119
- operator: "equals",
120
- value: "chrome",
121
- },
122
- ],
123
- }, {
124
- platform: "web",
125
- browser: "chrome",
126
- })).toEqual("*");
127
- // AND with partial match (redundant "*" removed)
128
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
129
- and: [
130
- {
131
- attribute: "platform",
132
- operator: "equals",
133
- value: "web",
134
- },
135
- {
136
- attribute: "browser",
137
- operator: "equals",
138
- value: "chrome",
139
- },
140
- ],
141
- }, {
142
- platform: "web",
143
- })).toEqual({
144
- and: [
145
- {
146
- attribute: "browser",
147
- operator: "equals",
148
- value: "chrome",
149
- },
150
- ],
151
- });
152
- // AND with no matches
153
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
154
- and: [
155
- {
156
- attribute: "platform",
157
- operator: "equals",
158
- value: "web",
159
- },
160
- {
161
- attribute: "browser",
162
- operator: "equals",
163
- value: "chrome",
164
- },
165
- ],
166
- }, {
167
- platform: "mobile",
168
- browser: "safari",
169
- })).toEqual({
170
- and: [
171
- {
172
- attribute: "platform",
173
- operator: "equals",
174
- value: "web",
175
- },
176
- {
177
- attribute: "browser",
178
- operator: "equals",
179
- value: "chrome",
180
- },
181
- ],
182
- });
183
- // AND with "*" in it (all "*" becomes "*")
184
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
185
- and: [
186
- "*",
187
- {
188
- attribute: "platform",
189
- operator: "equals",
190
- value: "web",
191
- },
192
- ],
193
- }, {
194
- platform: "web",
195
- })).toEqual("*");
196
- });
197
- test("OR conditions", function () {
198
- // OR with all matching conditions (all "*" becomes "*")
199
- // Note: This would require both conditions to match, which isn't possible with same attribute
200
- // So testing with different attributes that both match
201
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
202
- or: [
203
- {
204
- attribute: "platform",
205
- operator: "equals",
206
- value: "web",
207
- },
208
- {
209
- attribute: "browser",
210
- operator: "equals",
211
- value: "chrome",
212
- },
213
- ],
214
- }, {
215
- platform: "web",
216
- browser: "chrome",
217
- })).toEqual("*");
218
- // OR with partial match (redundant "*" removed, but OR structure remains)
219
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
220
- or: [
221
- {
222
- attribute: "platform",
223
- operator: "equals",
224
- value: "web",
225
- },
226
- {
227
- attribute: "browser",
228
- operator: "equals",
229
- value: "chrome",
230
- },
231
- ],
232
- }, {
233
- platform: "web",
234
- })).toEqual({
235
- or: [
236
- {
237
- attribute: "browser",
238
- operator: "equals",
239
- value: "chrome",
240
- },
241
- ],
242
- });
243
- // OR with no matches
244
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
245
- or: [
246
- {
247
- attribute: "platform",
248
- operator: "equals",
249
- value: "web",
250
- },
251
- {
252
- attribute: "platform",
253
- operator: "equals",
254
- value: "mobile",
255
- },
256
- ],
257
- }, {
258
- platform: "desktop",
259
- })).toEqual({
260
- or: [
261
- {
262
- attribute: "platform",
263
- operator: "equals",
264
- value: "web",
265
- },
266
- {
267
- attribute: "platform",
268
- operator: "equals",
269
- value: "mobile",
270
- },
271
- ],
272
- });
273
- });
274
- test("NOT conditions", function () {
275
- // NOT with matching condition (all "*" becomes "*")
276
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
277
- not: [
278
- {
279
- attribute: "platform",
280
- operator: "equals",
281
- value: "web",
282
- },
283
- ],
284
- }, {
285
- platform: "web",
286
- })).toEqual("*");
287
- // NOT with non-matching condition
288
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
289
- not: [
290
- {
291
- attribute: "platform",
292
- operator: "equals",
293
- value: "web",
294
- },
295
- ],
296
- }, {
297
- platform: "mobile",
298
- })).toEqual({
299
- not: [
300
- {
301
- attribute: "platform",
302
- operator: "equals",
303
- value: "web",
304
- },
305
- ],
306
- });
307
- // NOT with multiple conditions (all "*" becomes "*")
308
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
309
- not: [
310
- {
311
- attribute: "platform",
312
- operator: "equals",
313
- value: "web",
314
- },
315
- {
316
- attribute: "browser",
317
- operator: "equals",
318
- value: "chrome",
319
- },
320
- ],
321
- }, {
322
- platform: "web",
323
- browser: "chrome",
324
- })).toEqual("*");
325
- });
326
- test("nested AND conditions", function () {
327
- // Nested AND with all matching (all "*" becomes "*")
328
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
329
- and: [
330
- {
331
- attribute: "platform",
332
- operator: "equals",
333
- value: "web",
334
- },
335
- {
336
- and: [
337
- {
338
- attribute: "browser",
339
- operator: "equals",
340
- value: "chrome",
341
- },
342
- {
343
- attribute: "version",
344
- operator: "equals",
345
- value: "1.0",
346
- },
347
- ],
348
- },
349
- ],
350
- }, {
351
- platform: "web",
352
- browser: "chrome",
353
- version: "1.0",
354
- })).toEqual("*");
355
- // Nested AND with partial match (redundant "*" removed)
356
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
357
- and: [
358
- {
359
- attribute: "platform",
360
- operator: "equals",
361
- value: "web",
362
- },
363
- {
364
- and: [
365
- {
366
- attribute: "browser",
367
- operator: "equals",
368
- value: "chrome",
369
- },
370
- {
371
- attribute: "version",
372
- operator: "equals",
373
- value: "1.0",
374
- },
375
- ],
376
- },
377
- ],
378
- }, {
379
- platform: "web",
380
- browser: "chrome",
381
- })).toEqual({
382
- and: [
383
- {
384
- and: [
385
- {
386
- attribute: "version",
387
- operator: "equals",
388
- value: "1.0",
389
- },
390
- ],
391
- },
392
- ],
393
- });
394
- });
395
- test("nested OR conditions", function () {
396
- // Nested OR with outer match (redundant "*" removed, but inner OR remains)
397
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
398
- or: [
399
- {
400
- attribute: "platform",
401
- operator: "equals",
402
- value: "web",
403
- },
404
- {
405
- or: [
406
- {
407
- attribute: "platform",
408
- operator: "equals",
409
- value: "mobile",
410
- },
411
- {
412
- attribute: "platform",
413
- operator: "equals",
414
- value: "desktop",
415
- },
416
- ],
417
- },
418
- ],
419
- }, {
420
- platform: "web",
421
- })).toEqual({
422
- or: [
423
- {
424
- or: [
425
- {
426
- attribute: "platform",
427
- operator: "equals",
428
- value: "mobile",
429
- },
430
- {
431
- attribute: "platform",
432
- operator: "equals",
433
- value: "desktop",
434
- },
435
- ],
436
- },
437
- ],
438
- });
439
- // Nested OR with inner match (redundant "*" removed, but outer OR remains)
440
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
441
- or: [
442
- {
443
- attribute: "platform",
444
- operator: "equals",
445
- value: "web",
446
- },
447
- {
448
- or: [
449
- {
450
- attribute: "platform",
451
- operator: "equals",
452
- value: "mobile",
453
- },
454
- {
455
- attribute: "platform",
456
- operator: "equals",
457
- value: "desktop",
458
- },
459
- ],
460
- },
461
- ],
462
- }, {
463
- platform: "mobile",
464
- })).toEqual({
465
- or: [
466
- {
467
- attribute: "platform",
468
- operator: "equals",
469
- value: "web",
470
- },
471
- {
472
- or: [
473
- {
474
- attribute: "platform",
475
- operator: "equals",
476
- value: "desktop",
477
- },
478
- ],
479
- },
480
- ],
481
- });
482
- });
483
- test("nested NOT conditions", function () {
484
- // Nested NOT (all "*" becomes "*")
485
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
486
- not: [
487
- {
488
- attribute: "platform",
489
- operator: "equals",
490
- value: "web",
491
- },
492
- {
493
- not: [
494
- {
495
- attribute: "browser",
496
- operator: "equals",
497
- value: "chrome",
498
- },
499
- ],
500
- },
501
- ],
502
- }, {
503
- platform: "web",
504
- browser: "chrome",
505
- })).toEqual("*");
506
- });
507
- test("mixed nested conditions", function () {
508
- // AND with nested OR (redundant "*" removed, but OR structure remains if not all match)
509
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
510
- and: [
511
- {
512
- attribute: "platform",
513
- operator: "equals",
514
- value: "web",
515
- },
516
- {
517
- or: [
518
- {
519
- attribute: "browser",
520
- operator: "equals",
521
- value: "chrome",
522
- },
523
- {
524
- attribute: "browser",
525
- operator: "equals",
526
- value: "firefox",
527
- },
528
- ],
529
- },
530
- ],
531
- }, {
532
- platform: "web",
533
- browser: "chrome",
534
- })).toEqual({
535
- and: [
536
- {
537
- or: [
538
- {
539
- attribute: "browser",
540
- operator: "equals",
541
- value: "firefox",
542
- },
543
- ],
544
- },
545
- ],
546
- });
547
- // OR with nested AND (redundant "*" removed, but OR structure remains if not all match)
548
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
549
- or: [
550
- {
551
- attribute: "platform",
552
- operator: "equals",
553
- value: "web",
554
- },
555
- {
556
- and: [
557
- {
558
- attribute: "platform",
559
- operator: "equals",
560
- value: "mobile",
561
- },
562
- {
563
- attribute: "browser",
564
- operator: "equals",
565
- value: "chrome",
566
- },
567
- ],
568
- },
569
- ],
570
- }, {
571
- platform: "mobile",
572
- browser: "chrome",
573
- })).toEqual({
574
- or: [
575
- {
576
- attribute: "platform",
577
- operator: "equals",
578
- value: "web",
579
- },
580
- ],
581
- });
582
- // AND with nested NOT (redundant "*" removed)
583
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
584
- and: [
585
- {
586
- attribute: "platform",
587
- operator: "equals",
588
- value: "web",
589
- },
590
- {
591
- not: [
592
- {
593
- attribute: "browser",
594
- operator: "equals",
595
- value: "safari",
596
- },
597
- ],
598
- },
599
- ],
600
- }, {
601
- platform: "web",
602
- browser: "chrome",
603
- })).toEqual({
604
- and: [
605
- {
606
- not: [
607
- {
608
- attribute: "browser",
609
- operator: "equals",
610
- value: "safari",
611
- },
612
- ],
613
- },
614
- ],
615
- });
616
- // Complex nested structure (redundant "*" removed)
617
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
618
- and: [
619
- {
620
- attribute: "platform",
621
- operator: "equals",
622
- value: "web",
623
- },
624
- {
625
- or: [
626
- {
627
- and: [
628
- {
629
- attribute: "browser",
630
- operator: "equals",
631
- value: "chrome",
632
- },
633
- {
634
- attribute: "version",
635
- operator: "equals",
636
- value: "1.0",
637
- },
638
- ],
639
- },
640
- {
641
- attribute: "browser",
642
- operator: "equals",
643
- value: "firefox",
644
- },
645
- ],
646
- },
647
- ],
648
- }, {
649
- platform: "web",
650
- browser: "chrome",
651
- version: "1.0",
652
- })).toEqual({
653
- and: [
654
- {
655
- or: [
656
- {
657
- attribute: "browser",
658
- operator: "equals",
659
- value: "firefox",
660
- },
661
- ],
662
- },
663
- ],
664
- });
665
- });
666
- test("arrays with nested conditions", function () {
667
- // Array with AND condition (redundant "*" removed)
668
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [
669
- {
670
- attribute: "platform",
671
- operator: "equals",
672
- value: "web",
673
- },
674
- {
675
- and: [
676
- {
677
- attribute: "browser",
678
- operator: "equals",
679
- value: "chrome",
680
- },
681
- {
682
- attribute: "version",
683
- operator: "equals",
684
- value: "1.0",
685
- },
686
- ],
687
- },
688
- ], {
689
- platform: "web",
690
- browser: "chrome",
691
- version: "1.0",
692
- })).toEqual("*");
693
- // Array with OR condition (redundant "*" removed, but OR structure remains if not all match)
694
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [
695
- {
696
- attribute: "platform",
697
- operator: "equals",
698
- value: "web",
699
- },
700
- {
701
- or: [
702
- {
703
- attribute: "browser",
704
- operator: "equals",
705
- value: "chrome",
706
- },
707
- {
708
- attribute: "browser",
709
- operator: "equals",
710
- value: "firefox",
711
- },
712
- ],
713
- },
714
- ], {
715
- platform: "web",
716
- browser: "chrome",
717
- })).toEqual([
718
- {
719
- or: [
720
- {
721
- attribute: "browser",
722
- operator: "equals",
723
- value: "firefox",
724
- },
725
- ],
726
- },
727
- ]);
728
- });
729
- test("edge cases", function () {
730
- // Empty context
731
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
732
- attribute: "platform",
733
- operator: "equals",
734
- value: "web",
735
- }, {})).toEqual({
736
- attribute: "platform",
737
- operator: "equals",
738
- value: "web",
739
- });
740
- // Empty array (all "*" becomes "*")
741
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [], {})).toEqual("*");
742
- // "*" in array with matching condition (all "*" becomes "*")
743
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, [
744
- "*",
745
- {
746
- attribute: "platform",
747
- operator: "equals",
748
- value: "web",
749
- },
750
- ], {
751
- platform: "web",
752
- })).toEqual("*");
753
- // AND with empty array (all "*" becomes "*")
754
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
755
- and: [],
756
- }, {})).toEqual("*");
757
- // OR with empty array (all "*" becomes "*")
758
- expect((0, buildScopedConditions_1.buildScopedConditions)(datafileReader, {
759
- or: [],
760
- }, {})).toEqual("*");
761
- });
762
- });
763
- describe("buildScopedCondition (singular)", function () {
764
- test("buildScopedCondition is a function", function () {
765
- expect(buildScopedConditions_1.buildScopedCondition).toBeInstanceOf(Function);
766
- });
767
- test("simple cases", function () {
768
- // "*" remains "*"
769
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, "*", {})).toEqual("*");
770
- // Plain condition that matches
771
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
772
- attribute: "platform",
773
- operator: "equals",
774
- value: "web",
775
- }, {
776
- platform: "web",
777
- })).toEqual("*");
778
- // Plain condition that doesn't match
779
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
780
- attribute: "platform",
781
- operator: "equals",
782
- value: "web",
783
- }, {
784
- platform: "mobile",
785
- })).toEqual({
786
- attribute: "platform",
787
- operator: "equals",
788
- value: "web",
789
- });
790
- // Array of conditions
791
- const originalConditions = [
792
- {
793
- attribute: "platform",
794
- operator: "equals",
795
- value: "web",
796
- },
797
- {
798
- attribute: "browser",
799
- operator: "equals",
800
- value: "chrome",
801
- },
802
- ];
803
- // Partial match
804
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, originalConditions, {
805
- platform: "web",
806
- })).toEqual([
807
- "*",
808
- {
809
- attribute: "browser",
810
- operator: "equals",
811
- value: "chrome",
812
- },
813
- ]);
814
- // Full match
815
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, originalConditions, {
816
- platform: "web",
817
- browser: "chrome",
818
- })).toEqual(["*", "*"]);
819
- // No match
820
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, originalConditions, {
821
- platform: "mobile",
822
- browser: "safari",
823
- })).toEqual([
824
- {
825
- attribute: "platform",
826
- operator: "equals",
827
- value: "web",
828
- },
829
- {
830
- attribute: "browser",
831
- operator: "equals",
832
- value: "chrome",
833
- },
834
- ]);
835
- });
836
- test("AND conditions", function () {
837
- // AND with all matching conditions
838
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
839
- and: [
840
- {
841
- attribute: "platform",
842
- operator: "equals",
843
- value: "web",
844
- },
845
- {
846
- attribute: "browser",
847
- operator: "equals",
848
- value: "chrome",
849
- },
850
- ],
851
- }, {
852
- platform: "web",
853
- browser: "chrome",
854
- })).toEqual({
855
- and: ["*", "*"],
856
- });
857
- // AND with partial match
858
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
859
- and: [
860
- {
861
- attribute: "platform",
862
- operator: "equals",
863
- value: "web",
864
- },
865
- {
866
- attribute: "browser",
867
- operator: "equals",
868
- value: "chrome",
869
- },
870
- ],
871
- }, {
872
- platform: "web",
873
- })).toEqual({
874
- and: [
875
- "*",
876
- {
877
- attribute: "browser",
878
- operator: "equals",
879
- value: "chrome",
880
- },
881
- ],
882
- });
883
- // AND with no matches
884
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
885
- and: [
886
- {
887
- attribute: "platform",
888
- operator: "equals",
889
- value: "web",
890
- },
891
- {
892
- attribute: "browser",
893
- operator: "equals",
894
- value: "chrome",
895
- },
896
- ],
897
- }, {
898
- platform: "mobile",
899
- browser: "safari",
900
- })).toEqual({
901
- and: [
902
- {
903
- attribute: "platform",
904
- operator: "equals",
905
- value: "web",
906
- },
907
- {
908
- attribute: "browser",
909
- operator: "equals",
910
- value: "chrome",
911
- },
912
- ],
913
- });
914
- // AND with "*" in it
915
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
916
- and: [
917
- "*",
918
- {
919
- attribute: "platform",
920
- operator: "equals",
921
- value: "web",
922
- },
923
- ],
924
- }, {
925
- platform: "web",
926
- })).toEqual({
927
- and: ["*", "*"],
928
- });
929
- });
930
- test("OR conditions", function () {
931
- // OR with all matching conditions
932
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
933
- or: [
934
- {
935
- attribute: "platform",
936
- operator: "equals",
937
- value: "web",
938
- },
939
- {
940
- attribute: "platform",
941
- operator: "equals",
942
- value: "mobile",
943
- },
944
- ],
945
- }, {
946
- platform: "web",
947
- })).toEqual({
948
- or: ["*", { attribute: "platform", operator: "equals", value: "mobile" }],
949
- });
950
- // OR with partial match (first matches)
951
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
952
- or: [
953
- {
954
- attribute: "platform",
955
- operator: "equals",
956
- value: "web",
957
- },
958
- {
959
- attribute: "browser",
960
- operator: "equals",
961
- value: "chrome",
962
- },
963
- ],
964
- }, {
965
- platform: "web",
966
- })).toEqual({
967
- or: [
968
- "*",
969
- {
970
- attribute: "browser",
971
- operator: "equals",
972
- value: "chrome",
973
- },
974
- ],
975
- });
976
- // OR with no matches
977
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
978
- or: [
979
- {
980
- attribute: "platform",
981
- operator: "equals",
982
- value: "web",
983
- },
984
- {
985
- attribute: "platform",
986
- operator: "equals",
987
- value: "mobile",
988
- },
989
- ],
990
- }, {
991
- platform: "desktop",
992
- })).toEqual({
993
- or: [
994
- {
995
- attribute: "platform",
996
- operator: "equals",
997
- value: "web",
998
- },
999
- {
1000
- attribute: "platform",
1001
- operator: "equals",
1002
- value: "mobile",
1003
- },
1004
- ],
1005
- });
1006
- });
1007
- test("NOT conditions", function () {
1008
- // NOT with matching condition (should not match)
1009
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1010
- not: [
1011
- {
1012
- attribute: "platform",
1013
- operator: "equals",
1014
- value: "web",
1015
- },
1016
- ],
1017
- }, {
1018
- platform: "web",
1019
- })).toEqual({
1020
- not: ["*"],
1021
- });
1022
- // NOT with non-matching condition
1023
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1024
- not: [
1025
- {
1026
- attribute: "platform",
1027
- operator: "equals",
1028
- value: "web",
1029
- },
1030
- ],
1031
- }, {
1032
- platform: "mobile",
1033
- })).toEqual({
1034
- not: [
1035
- {
1036
- attribute: "platform",
1037
- operator: "equals",
1038
- value: "web",
1039
- },
1040
- ],
1041
- });
1042
- // NOT with multiple conditions
1043
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1044
- not: [
1045
- {
1046
- attribute: "platform",
1047
- operator: "equals",
1048
- value: "web",
1049
- },
1050
- {
1051
- attribute: "browser",
1052
- operator: "equals",
1053
- value: "chrome",
1054
- },
1055
- ],
1056
- }, {
1057
- platform: "web",
1058
- browser: "chrome",
1059
- })).toEqual({
1060
- not: ["*", "*"],
1061
- });
1062
- });
1063
- test("nested AND conditions", function () {
1064
- // Nested AND with all matching
1065
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1066
- and: [
1067
- {
1068
- attribute: "platform",
1069
- operator: "equals",
1070
- value: "web",
1071
- },
1072
- {
1073
- and: [
1074
- {
1075
- attribute: "browser",
1076
- operator: "equals",
1077
- value: "chrome",
1078
- },
1079
- {
1080
- attribute: "version",
1081
- operator: "equals",
1082
- value: "1.0",
1083
- },
1084
- ],
1085
- },
1086
- ],
1087
- }, {
1088
- platform: "web",
1089
- browser: "chrome",
1090
- version: "1.0",
1091
- })).toEqual({
1092
- and: [
1093
- "*",
1094
- {
1095
- and: ["*", "*"],
1096
- },
1097
- ],
1098
- });
1099
- // Nested AND with partial match
1100
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1101
- and: [
1102
- {
1103
- attribute: "platform",
1104
- operator: "equals",
1105
- value: "web",
1106
- },
1107
- {
1108
- and: [
1109
- {
1110
- attribute: "browser",
1111
- operator: "equals",
1112
- value: "chrome",
1113
- },
1114
- {
1115
- attribute: "version",
1116
- operator: "equals",
1117
- value: "1.0",
1118
- },
1119
- ],
1120
- },
1121
- ],
1122
- }, {
1123
- platform: "web",
1124
- browser: "chrome",
1125
- })).toEqual({
1126
- and: [
1127
- "*",
1128
- {
1129
- and: [
1130
- "*",
1131
- {
1132
- attribute: "version",
1133
- operator: "equals",
1134
- value: "1.0",
1135
- },
1136
- ],
1137
- },
1138
- ],
1139
- });
1140
- });
1141
- test("nested OR conditions", function () {
1142
- // Nested OR with matching
1143
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1144
- or: [
1145
- {
1146
- attribute: "platform",
1147
- operator: "equals",
1148
- value: "web",
1149
- },
1150
- {
1151
- or: [
1152
- {
1153
- attribute: "platform",
1154
- operator: "equals",
1155
- value: "mobile",
1156
- },
1157
- {
1158
- attribute: "platform",
1159
- operator: "equals",
1160
- value: "desktop",
1161
- },
1162
- ],
1163
- },
1164
- ],
1165
- }, {
1166
- platform: "web",
1167
- })).toEqual({
1168
- or: [
1169
- "*",
1170
- {
1171
- or: [
1172
- {
1173
- attribute: "platform",
1174
- operator: "equals",
1175
- value: "mobile",
1176
- },
1177
- {
1178
- attribute: "platform",
1179
- operator: "equals",
1180
- value: "desktop",
1181
- },
1182
- ],
1183
- },
1184
- ],
1185
- });
1186
- // Nested OR with inner match
1187
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1188
- or: [
1189
- {
1190
- attribute: "platform",
1191
- operator: "equals",
1192
- value: "web",
1193
- },
1194
- {
1195
- or: [
1196
- {
1197
- attribute: "platform",
1198
- operator: "equals",
1199
- value: "mobile",
1200
- },
1201
- {
1202
- attribute: "platform",
1203
- operator: "equals",
1204
- value: "desktop",
1205
- },
1206
- ],
1207
- },
1208
- ],
1209
- }, {
1210
- platform: "mobile",
1211
- })).toEqual({
1212
- or: [
1213
- {
1214
- attribute: "platform",
1215
- operator: "equals",
1216
- value: "web",
1217
- },
1218
- {
1219
- or: [
1220
- "*",
1221
- {
1222
- attribute: "platform",
1223
- operator: "equals",
1224
- value: "desktop",
1225
- },
1226
- ],
1227
- },
1228
- ],
1229
- });
1230
- });
1231
- test("nested NOT conditions", function () {
1232
- // Nested NOT
1233
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1234
- not: [
1235
- {
1236
- attribute: "platform",
1237
- operator: "equals",
1238
- value: "web",
1239
- },
1240
- {
1241
- not: [
1242
- {
1243
- attribute: "browser",
1244
- operator: "equals",
1245
- value: "chrome",
1246
- },
1247
- ],
1248
- },
1249
- ],
1250
- }, {
1251
- platform: "web",
1252
- browser: "chrome",
1253
- })).toEqual({
1254
- not: [
1255
- "*",
1256
- {
1257
- not: ["*"],
1258
- },
1259
- ],
1260
- });
1261
- });
1262
- test("mixed nested conditions", function () {
1263
- // AND with nested OR
1264
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1265
- and: [
1266
- {
1267
- attribute: "platform",
1268
- operator: "equals",
1269
- value: "web",
1270
- },
1271
- {
1272
- or: [
1273
- {
1274
- attribute: "browser",
1275
- operator: "equals",
1276
- value: "chrome",
1277
- },
1278
- {
1279
- attribute: "browser",
1280
- operator: "equals",
1281
- value: "firefox",
1282
- },
1283
- ],
1284
- },
1285
- ],
1286
- }, {
1287
- platform: "web",
1288
- browser: "chrome",
1289
- })).toEqual({
1290
- and: [
1291
- "*",
1292
- {
1293
- or: [
1294
- "*",
1295
- {
1296
- attribute: "browser",
1297
- operator: "equals",
1298
- value: "firefox",
1299
- },
1300
- ],
1301
- },
1302
- ],
1303
- });
1304
- // OR with nested AND
1305
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1306
- or: [
1307
- {
1308
- attribute: "platform",
1309
- operator: "equals",
1310
- value: "web",
1311
- },
1312
- {
1313
- and: [
1314
- {
1315
- attribute: "platform",
1316
- operator: "equals",
1317
- value: "mobile",
1318
- },
1319
- {
1320
- attribute: "browser",
1321
- operator: "equals",
1322
- value: "chrome",
1323
- },
1324
- ],
1325
- },
1326
- ],
1327
- }, {
1328
- platform: "mobile",
1329
- browser: "chrome",
1330
- })).toEqual({
1331
- or: [
1332
- {
1333
- attribute: "platform",
1334
- operator: "equals",
1335
- value: "web",
1336
- },
1337
- {
1338
- and: ["*", "*"],
1339
- },
1340
- ],
1341
- });
1342
- // AND with nested NOT
1343
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1344
- and: [
1345
- {
1346
- attribute: "platform",
1347
- operator: "equals",
1348
- value: "web",
1349
- },
1350
- {
1351
- not: [
1352
- {
1353
- attribute: "browser",
1354
- operator: "equals",
1355
- value: "safari",
1356
- },
1357
- ],
1358
- },
1359
- ],
1360
- }, {
1361
- platform: "web",
1362
- browser: "chrome",
1363
- })).toEqual({
1364
- and: [
1365
- "*",
1366
- {
1367
- not: [
1368
- {
1369
- attribute: "browser",
1370
- operator: "equals",
1371
- value: "safari",
1372
- },
1373
- ],
1374
- },
1375
- ],
1376
- });
1377
- // Complex nested structure
1378
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1379
- and: [
1380
- {
1381
- attribute: "platform",
1382
- operator: "equals",
1383
- value: "web",
1384
- },
1385
- {
1386
- or: [
1387
- {
1388
- and: [
1389
- {
1390
- attribute: "browser",
1391
- operator: "equals",
1392
- value: "chrome",
1393
- },
1394
- {
1395
- attribute: "version",
1396
- operator: "equals",
1397
- value: "1.0",
1398
- },
1399
- ],
1400
- },
1401
- {
1402
- attribute: "browser",
1403
- operator: "equals",
1404
- value: "firefox",
1405
- },
1406
- ],
1407
- },
1408
- ],
1409
- }, {
1410
- platform: "web",
1411
- browser: "chrome",
1412
- version: "1.0",
1413
- })).toEqual({
1414
- and: [
1415
- "*",
1416
- {
1417
- or: [
1418
- {
1419
- and: ["*", "*"],
1420
- },
1421
- {
1422
- attribute: "browser",
1423
- operator: "equals",
1424
- value: "firefox",
1425
- },
1426
- ],
1427
- },
1428
- ],
1429
- });
1430
- });
1431
- test("arrays with nested conditions", function () {
1432
- // Array with AND condition
1433
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, [
1434
- {
1435
- attribute: "platform",
1436
- operator: "equals",
1437
- value: "web",
1438
- },
1439
- {
1440
- and: [
1441
- {
1442
- attribute: "browser",
1443
- operator: "equals",
1444
- value: "chrome",
1445
- },
1446
- {
1447
- attribute: "version",
1448
- operator: "equals",
1449
- value: "1.0",
1450
- },
1451
- ],
1452
- },
1453
- ], {
1454
- platform: "web",
1455
- browser: "chrome",
1456
- version: "1.0",
1457
- })).toEqual([
1458
- "*",
1459
- {
1460
- and: ["*", "*"],
1461
- },
1462
- ]);
1463
- // Array with OR condition
1464
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, [
1465
- {
1466
- attribute: "platform",
1467
- operator: "equals",
1468
- value: "web",
1469
- },
1470
- {
1471
- or: [
1472
- {
1473
- attribute: "browser",
1474
- operator: "equals",
1475
- value: "chrome",
1476
- },
1477
- {
1478
- attribute: "browser",
1479
- operator: "equals",
1480
- value: "firefox",
1481
- },
1482
- ],
1483
- },
1484
- ], {
1485
- platform: "web",
1486
- browser: "chrome",
1487
- })).toEqual([
1488
- "*",
1489
- {
1490
- or: [
1491
- "*",
1492
- {
1493
- attribute: "browser",
1494
- operator: "equals",
1495
- value: "firefox",
1496
- },
1497
- ],
1498
- },
1499
- ]);
1500
- });
1501
- test("edge cases", function () {
1502
- // Empty context
1503
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1504
- attribute: "platform",
1505
- operator: "equals",
1506
- value: "web",
1507
- }, {})).toEqual({
1508
- attribute: "platform",
1509
- operator: "equals",
1510
- value: "web",
1511
- });
1512
- // Empty array
1513
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, [], {})).toEqual([]);
1514
- // "*" in array
1515
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, [
1516
- "*",
1517
- {
1518
- attribute: "platform",
1519
- operator: "equals",
1520
- value: "web",
1521
- },
1522
- ], {
1523
- platform: "web",
1524
- })).toEqual(["*", "*"]);
1525
- // AND with empty array
1526
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1527
- and: [],
1528
- }, {})).toEqual({
1529
- and: [],
1530
- });
1531
- // OR with empty array
1532
- expect((0, buildScopedConditions_1.buildScopedCondition)(datafileReader, {
1533
- or: [],
1534
- }, {})).toEqual({
1535
- or: [],
1536
- });
1537
- });
1538
- });
1539
- describe("removeRedundantConditions", function () {
1540
- test("removeRedundantConditions is a function", function () {
1541
- expect(buildScopedConditions_1.removeRedundantConditions).toBeInstanceOf(Function);
1542
- });
1543
- test("simple cases", function () {
1544
- // * is *
1545
- expect((0, buildScopedConditions_1.removeRedundantConditions)("*")).toEqual("*");
1546
- // [*, *, *] is "*"
1547
- expect((0, buildScopedConditions_1.removeRedundantConditions)(["*", "*", "*"])).toEqual("*");
1548
- // Array with mixed conditions
1549
- expect((0, buildScopedConditions_1.removeRedundantConditions)([
1550
- "*",
1551
- {
1552
- attribute: "platform",
1553
- operator: "equals",
1554
- value: "web",
1555
- },
1556
- "*",
1557
- {
1558
- attribute: "browser",
1559
- operator: "equals",
1560
- value: "chrome",
1561
- },
1562
- ])).toEqual([
1563
- {
1564
- attribute: "platform",
1565
- operator: "equals",
1566
- value: "web",
1567
- },
1568
- {
1569
- attribute: "browser",
1570
- operator: "equals",
1571
- value: "chrome",
1572
- },
1573
- ]);
1574
- });
1575
- test("AND conditions", function () {
1576
- // All "*" in AND
1577
- expect((0, buildScopedConditions_1.removeRedundantConditions)({ and: ["*", "*", "*"] })).toEqual("*");
1578
- // Mixed with "*" in AND
1579
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1580
- and: [
1581
- "*",
1582
- {
1583
- attribute: "platform",
1584
- operator: "equals",
1585
- value: "web",
1586
- },
1587
- "*",
1588
- ],
1589
- })).toEqual({
1590
- and: [
1591
- {
1592
- attribute: "platform",
1593
- operator: "equals",
1594
- value: "web",
1595
- },
1596
- ],
1597
- });
1598
- // Multiple non-* conditions in AND
1599
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1600
- and: [
1601
- "*",
1602
- {
1603
- attribute: "platform",
1604
- operator: "equals",
1605
- value: "web",
1606
- },
1607
- "*",
1608
- {
1609
- attribute: "browser",
1610
- operator: "equals",
1611
- value: "chrome",
1612
- },
1613
- "*",
1614
- ],
1615
- })).toEqual({
1616
- and: [
1617
- {
1618
- attribute: "platform",
1619
- operator: "equals",
1620
- value: "web",
1621
- },
1622
- {
1623
- attribute: "browser",
1624
- operator: "equals",
1625
- value: "chrome",
1626
- },
1627
- ],
1628
- });
1629
- });
1630
- test("OR conditions", function () {
1631
- // All "*" in OR
1632
- expect((0, buildScopedConditions_1.removeRedundantConditions)({ or: ["*", "*", "*"] })).toEqual("*");
1633
- // Mixed with "*" in OR
1634
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1635
- or: [
1636
- "*",
1637
- {
1638
- attribute: "platform",
1639
- operator: "equals",
1640
- value: "web",
1641
- },
1642
- "*",
1643
- ],
1644
- })).toEqual({
1645
- or: [
1646
- {
1647
- attribute: "platform",
1648
- operator: "equals",
1649
- value: "web",
1650
- },
1651
- ],
1652
- });
1653
- // Multiple non-* conditions in OR
1654
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1655
- or: [
1656
- "*",
1657
- {
1658
- attribute: "platform",
1659
- operator: "equals",
1660
- value: "web",
1661
- },
1662
- "*",
1663
- {
1664
- attribute: "platform",
1665
- operator: "equals",
1666
- value: "mobile",
1667
- },
1668
- "*",
1669
- ],
1670
- })).toEqual({
1671
- or: [
1672
- {
1673
- attribute: "platform",
1674
- operator: "equals",
1675
- value: "web",
1676
- },
1677
- {
1678
- attribute: "platform",
1679
- operator: "equals",
1680
- value: "mobile",
1681
- },
1682
- ],
1683
- });
1684
- });
1685
- test("NOT conditions", function () {
1686
- // All "*" in NOT
1687
- expect((0, buildScopedConditions_1.removeRedundantConditions)({ not: ["*", "*", "*"] })).toEqual("*");
1688
- // Mixed with "*" in NOT
1689
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1690
- not: [
1691
- "*",
1692
- {
1693
- attribute: "platform",
1694
- operator: "equals",
1695
- value: "web",
1696
- },
1697
- "*",
1698
- ],
1699
- })).toEqual({
1700
- not: [
1701
- {
1702
- attribute: "platform",
1703
- operator: "equals",
1704
- value: "web",
1705
- },
1706
- ],
1707
- });
1708
- });
1709
- test("nested AND conditions", function () {
1710
- // Nested AND with all "*"
1711
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1712
- and: [
1713
- "*",
1714
- {
1715
- and: ["*", "*", "*"],
1716
- },
1717
- "*",
1718
- ],
1719
- })).toEqual("*");
1720
- // Nested AND with mixed conditions
1721
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1722
- and: [
1723
- "*",
1724
- {
1725
- attribute: "platform",
1726
- operator: "equals",
1727
- value: "web",
1728
- },
1729
- {
1730
- and: [
1731
- "*",
1732
- {
1733
- attribute: "browser",
1734
- operator: "equals",
1735
- value: "chrome",
1736
- },
1737
- "*",
1738
- ],
1739
- },
1740
- "*",
1741
- ],
1742
- })).toEqual({
1743
- and: [
1744
- {
1745
- attribute: "platform",
1746
- operator: "equals",
1747
- value: "web",
1748
- },
1749
- {
1750
- and: [
1751
- {
1752
- attribute: "browser",
1753
- operator: "equals",
1754
- value: "chrome",
1755
- },
1756
- ],
1757
- },
1758
- ],
1759
- });
1760
- // Deeply nested AND
1761
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1762
- and: [
1763
- "*",
1764
- {
1765
- and: [
1766
- "*",
1767
- {
1768
- and: ["*", "*", "*"],
1769
- },
1770
- "*",
1771
- ],
1772
- },
1773
- "*",
1774
- ],
1775
- })).toEqual("*");
1776
- });
1777
- test("nested OR conditions", function () {
1778
- // Nested OR with all "*"
1779
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1780
- or: [
1781
- "*",
1782
- {
1783
- or: ["*", "*", "*"],
1784
- },
1785
- "*",
1786
- ],
1787
- })).toEqual("*");
1788
- // Nested OR with mixed conditions
1789
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1790
- or: [
1791
- "*",
1792
- {
1793
- attribute: "platform",
1794
- operator: "equals",
1795
- value: "web",
1796
- },
1797
- {
1798
- or: [
1799
- "*",
1800
- {
1801
- attribute: "platform",
1802
- operator: "equals",
1803
- value: "mobile",
1804
- },
1805
- "*",
1806
- ],
1807
- },
1808
- "*",
1809
- ],
1810
- })).toEqual({
1811
- or: [
1812
- {
1813
- attribute: "platform",
1814
- operator: "equals",
1815
- value: "web",
1816
- },
1817
- {
1818
- or: [
1819
- {
1820
- attribute: "platform",
1821
- operator: "equals",
1822
- value: "mobile",
1823
- },
1824
- ],
1825
- },
1826
- ],
1827
- });
1828
- });
1829
- test("nested NOT conditions", function () {
1830
- // Nested NOT with all "*"
1831
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1832
- not: [
1833
- "*",
1834
- {
1835
- not: ["*", "*", "*"],
1836
- },
1837
- "*",
1838
- ],
1839
- })).toEqual("*");
1840
- // Nested NOT with mixed conditions
1841
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1842
- not: [
1843
- "*",
1844
- {
1845
- attribute: "platform",
1846
- operator: "equals",
1847
- value: "web",
1848
- },
1849
- {
1850
- not: [
1851
- "*",
1852
- {
1853
- attribute: "browser",
1854
- operator: "equals",
1855
- value: "chrome",
1856
- },
1857
- "*",
1858
- ],
1859
- },
1860
- "*",
1861
- ],
1862
- })).toEqual({
1863
- not: [
1864
- {
1865
- attribute: "platform",
1866
- operator: "equals",
1867
- value: "web",
1868
- },
1869
- {
1870
- not: [
1871
- {
1872
- attribute: "browser",
1873
- operator: "equals",
1874
- value: "chrome",
1875
- },
1876
- ],
1877
- },
1878
- ],
1879
- });
1880
- });
1881
- test("mixed nested conditions", function () {
1882
- // AND with nested OR
1883
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1884
- and: [
1885
- "*",
1886
- {
1887
- attribute: "platform",
1888
- operator: "equals",
1889
- value: "web",
1890
- },
1891
- {
1892
- or: [
1893
- "*",
1894
- {
1895
- attribute: "browser",
1896
- operator: "equals",
1897
- value: "chrome",
1898
- },
1899
- "*",
1900
- ],
1901
- },
1902
- "*",
1903
- ],
1904
- })).toEqual({
1905
- and: [
1906
- {
1907
- attribute: "platform",
1908
- operator: "equals",
1909
- value: "web",
1910
- },
1911
- {
1912
- or: [
1913
- {
1914
- attribute: "browser",
1915
- operator: "equals",
1916
- value: "chrome",
1917
- },
1918
- ],
1919
- },
1920
- ],
1921
- });
1922
- // OR with nested AND
1923
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1924
- or: [
1925
- "*",
1926
- {
1927
- attribute: "platform",
1928
- operator: "equals",
1929
- value: "web",
1930
- },
1931
- {
1932
- and: [
1933
- "*",
1934
- {
1935
- attribute: "browser",
1936
- operator: "equals",
1937
- value: "chrome",
1938
- },
1939
- "*",
1940
- ],
1941
- },
1942
- "*",
1943
- ],
1944
- })).toEqual({
1945
- or: [
1946
- {
1947
- attribute: "platform",
1948
- operator: "equals",
1949
- value: "web",
1950
- },
1951
- {
1952
- and: [
1953
- {
1954
- attribute: "browser",
1955
- operator: "equals",
1956
- value: "chrome",
1957
- },
1958
- ],
1959
- },
1960
- ],
1961
- });
1962
- // AND with nested NOT
1963
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
1964
- and: [
1965
- "*",
1966
- {
1967
- attribute: "platform",
1968
- operator: "equals",
1969
- value: "web",
1970
- },
1971
- {
1972
- not: [
1973
- "*",
1974
- {
1975
- attribute: "browser",
1976
- operator: "equals",
1977
- value: "safari",
1978
- },
1979
- "*",
1980
- ],
1981
- },
1982
- "*",
1983
- ],
1984
- })).toEqual({
1985
- and: [
1986
- {
1987
- attribute: "platform",
1988
- operator: "equals",
1989
- value: "web",
1990
- },
1991
- {
1992
- not: [
1993
- {
1994
- attribute: "browser",
1995
- operator: "equals",
1996
- value: "safari",
1997
- },
1998
- ],
1999
- },
2000
- ],
2001
- });
2002
- // Complex nested structure
2003
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
2004
- and: [
2005
- "*",
2006
- {
2007
- attribute: "platform",
2008
- operator: "equals",
2009
- value: "web",
2010
- },
2011
- {
2012
- or: [
2013
- "*",
2014
- {
2015
- and: [
2016
- "*",
2017
- {
2018
- attribute: "browser",
2019
- operator: "equals",
2020
- value: "chrome",
2021
- },
2022
- "*",
2023
- ],
2024
- },
2025
- "*",
2026
- ],
2027
- },
2028
- "*",
2029
- ],
2030
- })).toEqual({
2031
- and: [
2032
- {
2033
- attribute: "platform",
2034
- operator: "equals",
2035
- value: "web",
2036
- },
2037
- {
2038
- or: [
2039
- {
2040
- and: [
2041
- {
2042
- attribute: "browser",
2043
- operator: "equals",
2044
- value: "chrome",
2045
- },
2046
- ],
2047
- },
2048
- ],
2049
- },
2050
- ],
2051
- });
2052
- });
2053
- test("arrays with nested conditions", function () {
2054
- // Array with nested AND
2055
- expect((0, buildScopedConditions_1.removeRedundantConditions)([
2056
- "*",
2057
- {
2058
- and: [
2059
- "*",
2060
- {
2061
- attribute: "platform",
2062
- operator: "equals",
2063
- value: "web",
2064
- },
2065
- "*",
2066
- ],
2067
- },
2068
- "*",
2069
- ])).toEqual([
2070
- {
2071
- and: [
2072
- {
2073
- attribute: "platform",
2074
- operator: "equals",
2075
- value: "web",
2076
- },
2077
- ],
2078
- },
2079
- ]);
2080
- // Array with multiple nested conditions
2081
- expect((0, buildScopedConditions_1.removeRedundantConditions)([
2082
- "*",
2083
- {
2084
- attribute: "platform",
2085
- operator: "equals",
2086
- value: "web",
2087
- },
2088
- {
2089
- or: [
2090
- "*",
2091
- {
2092
- attribute: "browser",
2093
- operator: "equals",
2094
- value: "chrome",
2095
- },
2096
- "*",
2097
- ],
2098
- },
2099
- "*",
2100
- ])).toEqual([
2101
- {
2102
- attribute: "platform",
2103
- operator: "equals",
2104
- value: "web",
2105
- },
2106
- {
2107
- or: [
2108
- {
2109
- attribute: "browser",
2110
- operator: "equals",
2111
- value: "chrome",
2112
- },
2113
- ],
2114
- },
2115
- ]);
2116
- });
2117
- test("edge cases", function () {
2118
- // Single condition after filtering
2119
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
2120
- and: [
2121
- "*",
2122
- {
2123
- attribute: "platform",
2124
- operator: "equals",
2125
- value: "web",
2126
- },
2127
- "*",
2128
- ],
2129
- })).toEqual({
2130
- and: [
2131
- {
2132
- attribute: "platform",
2133
- operator: "equals",
2134
- value: "web",
2135
- },
2136
- ],
2137
- });
2138
- // Plain condition object (no change)
2139
- expect((0, buildScopedConditions_1.removeRedundantConditions)({
2140
- attribute: "platform",
2141
- operator: "equals",
2142
- value: "web",
2143
- })).toEqual({
2144
- attribute: "platform",
2145
- operator: "equals",
2146
- value: "web",
2147
- });
2148
- // Array with single non-* condition
2149
- expect((0, buildScopedConditions_1.removeRedundantConditions)([
2150
- "*",
2151
- {
2152
- attribute: "platform",
2153
- operator: "equals",
2154
- value: "web",
2155
- },
2156
- "*",
2157
- ])).toEqual([
2158
- {
2159
- attribute: "platform",
2160
- operator: "equals",
2161
- value: "web",
2162
- },
2163
- ]);
2164
- });
2165
- });
2166
- });
2167
- //# sourceMappingURL=buildScopedConditions.spec.js.map