unleash-server 4.14.2 → 4.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/dist/lib/db/event-store.d.ts +2 -3
  2. package/dist/lib/db/event-store.js +26 -36
  3. package/dist/lib/db/event-store.js.map +1 -1
  4. package/dist/lib/db/event-store.test.js +1 -1
  5. package/dist/lib/db/event-store.test.js.map +1 -1
  6. package/dist/lib/db/feature-strategy-store.js +3 -3
  7. package/dist/lib/db/feature-strategy-store.js.map +1 -1
  8. package/dist/lib/db/feature-toggle-client-store.d.ts +1 -1
  9. package/dist/lib/db/feature-toggle-client-store.js +6 -6
  10. package/dist/lib/db/feature-toggle-client-store.js.map +1 -1
  11. package/dist/lib/db/group-store.d.ts +0 -1
  12. package/dist/lib/db/group-store.js +1 -14
  13. package/dist/lib/db/group-store.js.map +1 -1
  14. package/dist/lib/db/user-store.js +8 -1
  15. package/dist/lib/db/user-store.js.map +1 -1
  16. package/dist/lib/openapi/index.d.ts +2388 -952
  17. package/dist/lib/openapi/index.js +8 -4
  18. package/dist/lib/openapi/index.js.map +1 -1
  19. package/dist/lib/openapi/spec/client-feature-schema.d.ts +72 -7
  20. package/dist/lib/openapi/spec/client-feature-schema.js +5 -3
  21. package/dist/lib/openapi/spec/client-feature-schema.js.map +1 -1
  22. package/dist/lib/openapi/spec/client-features-schema.d.ts +138 -16
  23. package/dist/lib/openapi/spec/client-features-schema.js +2 -2
  24. package/dist/lib/openapi/spec/client-features-schema.js.map +1 -1
  25. package/dist/lib/openapi/spec/client-features-schema.test.js +10 -0
  26. package/dist/lib/openapi/spec/client-features-schema.test.js.map +1 -1
  27. package/dist/lib/openapi/spec/constraint-schema.d.ts +51 -2
  28. package/dist/lib/openapi/spec/constraint-schema.js +17 -4
  29. package/dist/lib/openapi/spec/constraint-schema.js.map +1 -1
  30. package/dist/lib/openapi/spec/context-field-schema.test.js +5 -1
  31. package/dist/lib/openapi/spec/context-field-schema.test.js.map +1 -1
  32. package/dist/lib/openapi/spec/create-feature-strategy-schema.d.ts +12 -2
  33. package/dist/lib/openapi/spec/feature-environment-schema.d.ts +12 -2
  34. package/dist/lib/openapi/spec/feature-events-schema.d.ts +1 -1
  35. package/dist/lib/openapi/spec/feature-events-schema.js +1 -1
  36. package/dist/lib/openapi/spec/feature-events-schema.js.map +1 -1
  37. package/dist/lib/openapi/spec/feature-schema.d.ts +25 -5
  38. package/dist/lib/openapi/spec/feature-schema.test.js +13 -1
  39. package/dist/lib/openapi/spec/feature-schema.test.js.map +1 -1
  40. package/dist/lib/openapi/spec/feature-strategy-schema.d.ts +12 -2
  41. package/dist/lib/openapi/spec/feature-variants-schema.d.ts +1 -1
  42. package/dist/lib/openapi/spec/features-schema.d.ts +50 -10
  43. package/dist/lib/openapi/spec/group-schema.d.ts +1 -4
  44. package/dist/lib/openapi/spec/group-user-model-schema.d.ts +1 -4
  45. package/dist/lib/openapi/spec/group-user-model-schema.js +1 -4
  46. package/dist/lib/openapi/spec/group-user-model-schema.js.map +1 -1
  47. package/dist/lib/openapi/spec/groups-schema.d.ts +2 -8
  48. package/dist/lib/openapi/spec/groups-schema.test.js +0 -1
  49. package/dist/lib/openapi/spec/groups-schema.test.js.map +1 -1
  50. package/dist/lib/openapi/spec/health-overview-schema.d.ts +50 -10
  51. package/dist/lib/openapi/spec/health-report-schema.d.ts +50 -10
  52. package/dist/lib/openapi/spec/playground-constraint-schema.d.ts +47 -0
  53. package/dist/lib/openapi/spec/playground-constraint-schema.js +18 -0
  54. package/dist/lib/openapi/spec/playground-constraint-schema.js.map +1 -0
  55. package/dist/lib/openapi/spec/playground-feature-schema.d.ts +388 -2
  56. package/dist/lib/openapi/spec/playground-feature-schema.js +95 -9
  57. package/dist/lib/openapi/spec/playground-feature-schema.js.map +1 -1
  58. package/dist/lib/openapi/spec/playground-feature-schema.test.js +64 -3
  59. package/dist/lib/openapi/spec/playground-feature-schema.test.js.map +1 -1
  60. package/dist/lib/openapi/spec/playground-request-schema.d.ts +2 -0
  61. package/dist/lib/openapi/spec/playground-request-schema.js +6 -1
  62. package/dist/lib/openapi/spec/playground-request-schema.js.map +1 -1
  63. package/dist/lib/openapi/spec/playground-response-schema.d.ts +774 -3
  64. package/dist/lib/openapi/spec/playground-response-schema.js +15 -1
  65. package/dist/lib/openapi/spec/playground-response-schema.js.map +1 -1
  66. package/dist/lib/openapi/spec/playground-segment-schema.d.ts +79 -0
  67. package/dist/lib/openapi/spec/playground-segment-schema.js +36 -0
  68. package/dist/lib/openapi/spec/playground-segment-schema.js.map +1 -0
  69. package/dist/lib/openapi/spec/playground-strategy-schema.d.ts +257 -0
  70. package/dist/lib/openapi/spec/playground-strategy-schema.js +102 -0
  71. package/dist/lib/openapi/spec/playground-strategy-schema.js.map +1 -0
  72. package/dist/lib/openapi/spec/{bootstrap-ui-schema.test.d.ts → project-schema.test.d.ts} +0 -0
  73. package/dist/lib/openapi/spec/project-schema.test.js +17 -0
  74. package/dist/lib/openapi/spec/project-schema.test.js.map +1 -0
  75. package/dist/lib/openapi/spec/search-events-schema.d.ts +37 -0
  76. package/dist/lib/openapi/spec/search-events-schema.js +47 -0
  77. package/dist/lib/openapi/spec/search-events-schema.js.map +1 -0
  78. package/dist/lib/openapi/spec/segment-schema.d.ts +12 -2
  79. package/dist/lib/openapi/spec/state-schema.d.ts +61 -11
  80. package/dist/lib/{routes/admin-api/bootstrap-ui.test.d.ts → openapi/spec/tag-types-schema.test.d.ts} +0 -0
  81. package/dist/lib/openapi/spec/tag-types-schema.test.js +23 -0
  82. package/dist/lib/openapi/spec/tag-types-schema.test.js.map +1 -0
  83. package/dist/lib/openapi/spec/ui-config-schema.d.ts +3 -0
  84. package/dist/lib/openapi/spec/ui-config-schema.js +3 -0
  85. package/dist/lib/openapi/spec/ui-config-schema.js.map +1 -1
  86. package/dist/lib/openapi/spec/update-feature-schema.d.ts +12 -2
  87. package/dist/lib/openapi/spec/update-feature-strategy-schema.d.ts +12 -2
  88. package/dist/{test/e2e/api/admin/bootstrap.test.d.ts → lib/openapi/spec/user-schema.test.d.ts} +0 -0
  89. package/dist/lib/openapi/spec/user-schema.test.js +17 -0
  90. package/dist/lib/openapi/spec/user-schema.test.js.map +1 -0
  91. package/dist/lib/openapi/spec/users-groups-base-schema.d.ts +2 -8
  92. package/dist/lib/openapi/spec/variant-schema.d.ts +1 -1
  93. package/dist/lib/openapi/spec/variant-schema.js +1 -1
  94. package/dist/lib/openapi/spec/variant-schema.js.map +1 -1
  95. package/dist/lib/openapi/spec/variants-schema.d.ts +1 -1
  96. package/dist/lib/openapi/util/standard-responses.d.ts +6 -0
  97. package/dist/lib/openapi/util/standard-responses.js +10 -2
  98. package/dist/lib/openapi/util/standard-responses.js.map +1 -1
  99. package/dist/lib/routes/admin-api/config.d.ts +2 -1
  100. package/dist/lib/routes/admin-api/config.js +3 -1
  101. package/dist/lib/routes/admin-api/config.js.map +1 -1
  102. package/dist/lib/routes/admin-api/event.d.ts +3 -1
  103. package/dist/lib/routes/admin-api/event.js +30 -7
  104. package/dist/lib/routes/admin-api/event.js.map +1 -1
  105. package/dist/lib/routes/admin-api/index.js +0 -2
  106. package/dist/lib/routes/admin-api/index.js.map +1 -1
  107. package/dist/lib/routes/admin-api/playground.js.map +1 -1
  108. package/dist/lib/services/event-service.d.ts +2 -2
  109. package/dist/lib/services/event-service.js +2 -5
  110. package/dist/lib/services/event-service.js.map +1 -1
  111. package/dist/lib/services/feature-toggle-service.d.ts +1 -1
  112. package/dist/lib/services/feature-toggle-service.js +2 -2
  113. package/dist/lib/services/feature-toggle-service.js.map +1 -1
  114. package/dist/lib/services/group-service.d.ts +1 -1
  115. package/dist/lib/services/group-service.js +1 -5
  116. package/dist/lib/services/group-service.js.map +1 -1
  117. package/dist/lib/services/index.js +1 -0
  118. package/dist/lib/services/index.js.map +1 -1
  119. package/dist/lib/services/openapi-service.js +1 -1
  120. package/dist/lib/services/openapi-service.js.map +1 -1
  121. package/dist/lib/services/playground-service.d.ts +2 -1
  122. package/dist/lib/services/playground-service.js +30 -11
  123. package/dist/lib/services/playground-service.js.map +1 -1
  124. package/dist/lib/types/group.d.ts +1 -2
  125. package/dist/lib/types/group.js.map +1 -1
  126. package/dist/lib/types/stores/event-store.d.ts +2 -3
  127. package/dist/lib/types/stores/feature-toggle-client-store.d.ts +1 -1
  128. package/dist/lib/types/stores/group-store.d.ts +0 -1
  129. package/dist/lib/util/feature-evaluator/client.d.ts +25 -0
  130. package/dist/lib/util/feature-evaluator/client.js +135 -0
  131. package/dist/lib/util/feature-evaluator/client.js.map +1 -0
  132. package/dist/lib/util/feature-evaluator/constraint.d.ts +28 -0
  133. package/dist/lib/util/feature-evaluator/constraint.js +129 -0
  134. package/dist/lib/util/feature-evaluator/constraint.js.map +1 -0
  135. package/dist/lib/util/feature-evaluator/context.d.ts +13 -0
  136. package/dist/lib/util/feature-evaluator/context.js +3 -0
  137. package/dist/lib/util/feature-evaluator/context.js.map +1 -0
  138. package/dist/lib/util/feature-evaluator/feature-evaluator.d.ts +36 -0
  139. package/dist/lib/util/feature-evaluator/feature-evaluator.js +55 -0
  140. package/dist/lib/util/feature-evaluator/feature-evaluator.js.map +1 -0
  141. package/dist/lib/util/feature-evaluator/feature.d.ts +19 -0
  142. package/dist/lib/util/feature-evaluator/feature.js +3 -0
  143. package/dist/lib/util/feature-evaluator/feature.js.map +1 -0
  144. package/dist/lib/util/feature-evaluator/helpers.d.ts +6 -0
  145. package/dist/lib/util/feature-evaluator/helpers.js +32 -0
  146. package/dist/lib/util/feature-evaluator/helpers.js.map +1 -0
  147. package/dist/lib/util/feature-evaluator/index.d.ts +8 -0
  148. package/dist/lib/util/feature-evaluator/index.js +14 -0
  149. package/dist/lib/util/feature-evaluator/index.js.map +1 -0
  150. package/dist/lib/util/feature-evaluator/repository/bootstrap-provider.d.ts +16 -0
  151. package/dist/lib/util/feature-evaluator/repository/bootstrap-provider.js +25 -0
  152. package/dist/lib/util/feature-evaluator/repository/bootstrap-provider.js.map +1 -0
  153. package/dist/lib/util/feature-evaluator/repository/index.d.ts +35 -0
  154. package/dist/lib/util/feature-evaluator/repository/index.js +63 -0
  155. package/dist/lib/util/feature-evaluator/repository/index.js.map +1 -0
  156. package/dist/lib/util/feature-evaluator/repository/storage-provider-in-mem.d.ts +6 -0
  157. package/dist/lib/util/feature-evaluator/repository/storage-provider-in-mem.js +16 -0
  158. package/dist/lib/util/feature-evaluator/repository/storage-provider-in-mem.js.map +1 -0
  159. package/dist/lib/util/feature-evaluator/repository/storage-provider.d.ts +14 -0
  160. package/dist/lib/util/feature-evaluator/repository/storage-provider.js +50 -0
  161. package/dist/lib/util/feature-evaluator/repository/storage-provider.js.map +1 -0
  162. package/dist/lib/util/feature-evaluator/strategy/application-hostname-strategy.d.ts +8 -0
  163. package/dist/lib/util/feature-evaluator/strategy/application-hostname-strategy.js +23 -0
  164. package/dist/lib/util/feature-evaluator/strategy/application-hostname-strategy.js.map +1 -0
  165. package/dist/lib/util/feature-evaluator/strategy/default-strategy.d.ts +5 -0
  166. package/dist/lib/util/feature-evaluator/strategy/default-strategy.js +13 -0
  167. package/dist/lib/util/feature-evaluator/strategy/default-strategy.js.map +1 -0
  168. package/dist/lib/util/feature-evaluator/strategy/flexible-rollout-strategy.d.ts +12 -0
  169. package/dist/lib/util/feature-evaluator/strategy/flexible-rollout-strategy.js +49 -0
  170. package/dist/lib/util/feature-evaluator/strategy/flexible-rollout-strategy.js.map +1 -0
  171. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-random.d.ts +9 -0
  172. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-random.js +19 -0
  173. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-random.js.map +1 -0
  174. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-session-id.d.ts +9 -0
  175. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-session-id.js +24 -0
  176. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-session-id.js.map +1 -0
  177. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-user-id.d.ts +9 -0
  178. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-user-id.js +24 -0
  179. package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-user-id.js.map +1 -0
  180. package/dist/lib/util/feature-evaluator/strategy/index.d.ts +4 -0
  181. package/dist/lib/util/feature-evaluator/strategy/index.js +29 -0
  182. package/dist/lib/util/feature-evaluator/strategy/index.js.map +1 -0
  183. package/dist/lib/util/feature-evaluator/strategy/remote-address-strategy.d.ts +8 -0
  184. package/dist/lib/util/feature-evaluator/strategy/remote-address-strategy.js +35 -0
  185. package/dist/lib/util/feature-evaluator/strategy/remote-address-strategy.js.map +1 -0
  186. package/dist/lib/util/feature-evaluator/strategy/strategy.d.ts +41 -0
  187. package/dist/lib/util/feature-evaluator/strategy/strategy.js +75 -0
  188. package/dist/lib/util/feature-evaluator/strategy/strategy.js.map +1 -0
  189. package/dist/lib/util/feature-evaluator/strategy/unknown-strategy.d.ts +9 -0
  190. package/dist/lib/util/feature-evaluator/strategy/unknown-strategy.js +29 -0
  191. package/dist/lib/util/feature-evaluator/strategy/unknown-strategy.js.map +1 -0
  192. package/dist/lib/util/feature-evaluator/strategy/user-with-id-strategy.d.ts +8 -0
  193. package/dist/lib/util/feature-evaluator/strategy/user-with-id-strategy.js +16 -0
  194. package/dist/lib/util/feature-evaluator/strategy/user-with-id-strategy.js.map +1 -0
  195. package/dist/lib/util/feature-evaluator/strategy/util.d.ts +1 -0
  196. package/dist/lib/util/feature-evaluator/strategy/util.js +31 -0
  197. package/dist/lib/util/feature-evaluator/strategy/util.js.map +1 -0
  198. package/dist/lib/util/feature-evaluator/variant.d.ts +28 -0
  199. package/dist/lib/util/feature-evaluator/variant.js +73 -0
  200. package/dist/lib/util/feature-evaluator/variant.js.map +1 -0
  201. package/dist/lib/util/offline-unleash-client.d.ts +13 -2
  202. package/dist/lib/util/offline-unleash-client.js +20 -20
  203. package/dist/lib/util/offline-unleash-client.js.map +1 -1
  204. package/dist/lib/util/offline-unleash-client.test.d.ts +3 -1
  205. package/dist/lib/util/offline-unleash-client.test.js +349 -139
  206. package/dist/lib/util/offline-unleash-client.test.js.map +1 -1
  207. package/dist/migrations/20220808084524-add-group-permissions.d.ts +2 -0
  208. package/dist/migrations/20220808084524-add-group-permissions.js +12 -0
  209. package/dist/migrations/20220808084524-add-group-permissions.js.map +1 -0
  210. package/dist/migrations/20220808110415-add-projects-foreign-key.d.ts +2 -0
  211. package/dist/migrations/20220808110415-add-projects-foreign-key.js +14 -0
  212. package/dist/migrations/20220808110415-add-projects-foreign-key.js.map +1 -0
  213. package/dist/test/arbitraries.test.d.ts +12 -2
  214. package/dist/test/arbitraries.test.js +67 -9
  215. package/dist/test/arbitraries.test.js.map +1 -1
  216. package/dist/test/e2e/api/admin/config.e2e.test.js +2 -1
  217. package/dist/test/e2e/api/admin/config.e2e.test.js.map +1 -1
  218. package/dist/test/e2e/api/admin/event.e2e.test.js +57 -0
  219. package/dist/test/e2e/api/admin/event.e2e.test.js.map +1 -1
  220. package/dist/test/e2e/api/admin/feature.e2e.test.js +8 -7
  221. package/dist/test/e2e/api/admin/feature.e2e.test.js.map +1 -1
  222. package/dist/test/e2e/api/admin/playground.e2e.test.js +22 -0
  223. package/dist/test/e2e/api/admin/playground.e2e.test.js.map +1 -1
  224. package/dist/test/e2e/services/access-service.e2e.test.js +38 -20
  225. package/dist/test/e2e/services/access-service.e2e.test.js.map +1 -1
  226. package/dist/test/e2e/services/playground-service.test.d.ts +5 -1
  227. package/dist/test/e2e/services/playground-service.test.js +725 -37
  228. package/dist/test/e2e/services/playground-service.test.js.map +1 -1
  229. package/dist/test/e2e/services/project-service.e2e.test.js +12 -4
  230. package/dist/test/e2e/services/project-service.e2e.test.js.map +1 -1
  231. package/dist/test/e2e/services/setting-service.test.js +9 -3
  232. package/dist/test/e2e/services/setting-service.test.js.map +1 -1
  233. package/dist/test/e2e/stores/event-store.e2e.test.js +6 -2
  234. package/dist/test/e2e/stores/event-store.e2e.test.js.map +1 -1
  235. package/dist/test/fixtures/fake-event-store.d.ts +1 -3
  236. package/dist/test/fixtures/fake-event-store.js +2 -8
  237. package/dist/test/fixtures/fake-event-store.js.map +1 -1
  238. package/dist/test/fixtures/fake-group-store.d.ts +0 -1
  239. package/dist/test/fixtures/fake-group-store.js +0 -3
  240. package/dist/test/fixtures/fake-group-store.js.map +1 -1
  241. package/package.json +15 -13
  242. package/dist/lib/openapi/spec/bootstrap-ui-schema.d.ts +0 -491
  243. package/dist/lib/openapi/spec/bootstrap-ui-schema.js +0 -94
  244. package/dist/lib/openapi/spec/bootstrap-ui-schema.js.map +0 -1
  245. package/dist/lib/openapi/spec/bootstrap-ui-schema.test.js +0 -145
  246. package/dist/lib/openapi/spec/bootstrap-ui-schema.test.js.map +0 -1
  247. package/dist/lib/openapi/spec/client-variant-schema.d.ts +0 -35
  248. package/dist/lib/openapi/spec/client-variant-schema.js +0 -37
  249. package/dist/lib/openapi/spec/client-variant-schema.js.map +0 -1
  250. package/dist/lib/routes/admin-api/bootstrap-ui.d.ts +0 -25
  251. package/dist/lib/routes/admin-api/bootstrap-ui.js +0 -82
  252. package/dist/lib/routes/admin-api/bootstrap-ui.js.map +0 -1
  253. package/dist/lib/routes/admin-api/bootstrap-ui.test.js +0 -60
  254. package/dist/lib/routes/admin-api/bootstrap-ui.test.js.map +0 -1
  255. package/dist/test/e2e/api/admin/bootstrap.test.js +0 -43
  256. package/dist/test/e2e/api/admin/bootstrap.test.js.map +0 -1
@@ -13,7 +13,6 @@ export interface IGroupStore extends Store<IGroup, number> {
13
13
  update(group: IGroupModel): Promise<IGroup>;
14
14
  getAllUsersByGroups(groupIds: number[]): Promise<IGroupUser[]>;
15
15
  addNewUsersToGroup(groupId: number, users: IGroupUserModel[], userName: string): Promise<void>;
16
- updateExistingUsersInGroup(groupId: number, users: IGroupUserModel[]): Promise<void>;
17
16
  existsWithName(name: string): Promise<boolean>;
18
17
  create(group: IStoreGroup): Promise<IGroup>;
19
18
  }
@@ -0,0 +1,25 @@
1
+ import { Strategy } from './strategy';
2
+ import { FeatureInterface } from './feature';
3
+ import { RepositoryInterface } from './repository';
4
+ import { Variant } from './variant';
5
+ import { Context } from './context';
6
+ import { SegmentForEvaluation } from './strategy/strategy';
7
+ import { PlaygroundStrategySchema } from 'lib/openapi/spec/playground-strategy-schema';
8
+ import { playgroundStrategyEvaluation } from '../../openapi/spec/playground-strategy-schema';
9
+ export declare type StrategyEvaluationResult = Pick<PlaygroundStrategySchema, 'result' | 'segments' | 'constraints'>;
10
+ export declare type FeatureStrategiesEvaluationResult = {
11
+ result: boolean | typeof playgroundStrategyEvaluation.unknownResult;
12
+ strategies: PlaygroundStrategySchema[];
13
+ };
14
+ export default class UnleashClient {
15
+ private repository;
16
+ private strategies;
17
+ constructor(repository: RepositoryInterface, strategies: Strategy[]);
18
+ private getStrategy;
19
+ isEnabled(name: string, context: Context, fallback: Function): FeatureStrategiesEvaluationResult;
20
+ isFeatureEnabled(feature: FeatureInterface, context: Context, fallback: Function): FeatureStrategiesEvaluationResult;
21
+ getSegment(repo: RepositoryInterface): (segmentId: number) => SegmentForEvaluation | undefined;
22
+ getVariant(name: string, context: Context, fallbackVariant?: Variant): Variant;
23
+ forceGetVariant(name: string, context: Context, fallbackVariant?: Variant): Variant;
24
+ private resolveVariant;
25
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const variant_1 = require("./variant");
4
+ const playground_strategy_schema_1 = require("../../openapi/spec/playground-strategy-schema");
5
+ class UnleashClient {
6
+ constructor(repository, strategies) {
7
+ this.repository = repository;
8
+ this.strategies = strategies || [];
9
+ this.strategies.forEach((strategy) => {
10
+ if (!strategy ||
11
+ !strategy.name ||
12
+ typeof strategy.name !== 'string' ||
13
+ !strategy.isEnabled ||
14
+ typeof strategy.isEnabled !== 'function') {
15
+ throw new Error('Invalid strategy data / interface');
16
+ }
17
+ });
18
+ }
19
+ getStrategy(name) {
20
+ return this.strategies.find((strategy) => strategy.name === name);
21
+ }
22
+ isEnabled(name, context, fallback) {
23
+ const feature = this.repository.getToggle(name);
24
+ return this.isFeatureEnabled(feature, context, fallback);
25
+ }
26
+ isFeatureEnabled(feature, context, fallback) {
27
+ if (!feature) {
28
+ return fallback();
29
+ }
30
+ if (!Array.isArray(feature.strategies)) {
31
+ return {
32
+ result: false,
33
+ strategies: [],
34
+ };
35
+ }
36
+ if (feature.strategies.length === 0) {
37
+ return {
38
+ result: feature.enabled,
39
+ strategies: [],
40
+ };
41
+ }
42
+ const strategies = feature.strategies.map((strategySelector) => {
43
+ const getStrategy = () => {
44
+ // the application hostname strategy relies on external
45
+ // variables to calculate its result. As such, we can't
46
+ // evaluate it in a way that makes sense. So we'll
47
+ // use the 'unknown' strategy instead.
48
+ if (strategySelector.name === 'applicationHostname') {
49
+ return this.getStrategy('unknown');
50
+ }
51
+ return (this.getStrategy(strategySelector.name) ??
52
+ this.getStrategy('unknown'));
53
+ };
54
+ const strategy = getStrategy();
55
+ const segments = strategySelector.segments
56
+ ?.map(this.getSegment(this.repository))
57
+ .filter(Boolean) ?? [];
58
+ return {
59
+ name: strategySelector.name,
60
+ id: strategySelector.id,
61
+ parameters: strategySelector.parameters,
62
+ ...strategy.isEnabledWithConstraints(strategySelector.parameters, context, strategySelector.constraints, segments),
63
+ };
64
+ });
65
+ // Feature evaluation
66
+ const overallStrategyResult = () => {
67
+ // if at least one strategy is enabled, then the feature is enabled
68
+ if (strategies.some((strategy) => strategy.result.enabled === true)) {
69
+ return true;
70
+ }
71
+ // if at least one strategy is unknown, then the feature _may_ be enabled
72
+ if (strategies.some((strategy) => strategy.result.enabled === 'unknown')) {
73
+ return playground_strategy_schema_1.playgroundStrategyEvaluation.unknownResult;
74
+ }
75
+ return false;
76
+ };
77
+ const evalResults = {
78
+ result: overallStrategyResult(),
79
+ strategies,
80
+ };
81
+ return evalResults;
82
+ }
83
+ getSegment(repo) {
84
+ return (segmentId) => {
85
+ const segment = repo.getSegment(segmentId);
86
+ if (!segment) {
87
+ return undefined;
88
+ }
89
+ return {
90
+ name: segment.name,
91
+ id: segmentId,
92
+ constraints: segment.constraints,
93
+ };
94
+ };
95
+ }
96
+ getVariant(name, context, fallbackVariant) {
97
+ return this.resolveVariant(name, context, true, fallbackVariant);
98
+ }
99
+ // This function is intended to close an issue in the proxy where feature enabled
100
+ // state gets checked twice when resolving a variant with random stickiness and
101
+ // gradual rollout. This is not intended for general use, prefer getVariant instead
102
+ forceGetVariant(name, context, fallbackVariant) {
103
+ return this.resolveVariant(name, context, false, fallbackVariant);
104
+ }
105
+ resolveVariant(name, context, checkToggle, fallbackVariant) {
106
+ const fallback = fallbackVariant || (0, variant_1.getDefaultVariant)();
107
+ const feature = this.repository.getToggle(name);
108
+ if (typeof feature === 'undefined' ||
109
+ !feature.variants ||
110
+ !Array.isArray(feature.variants) ||
111
+ feature.variants.length === 0 ||
112
+ !feature.enabled) {
113
+ return fallback;
114
+ }
115
+ let enabled = true;
116
+ if (checkToggle) {
117
+ enabled =
118
+ this.isFeatureEnabled(feature, context, () => fallbackVariant ? fallbackVariant.enabled : false).result === true;
119
+ if (!enabled) {
120
+ return fallback;
121
+ }
122
+ }
123
+ const variant = (0, variant_1.selectVariant)(feature, context);
124
+ if (variant === null) {
125
+ return fallback;
126
+ }
127
+ return {
128
+ name: variant.name,
129
+ payload: variant.payload,
130
+ enabled: !checkToggle || enabled,
131
+ };
132
+ }
133
+ }
134
+ exports.default = UnleashClient;
135
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/client.ts"],"names":[],"mappings":";;AAGA,uCAKmB;AAInB,8FAA6F;AAY7F,MAAqB,aAAa;IAK9B,YAAY,UAA+B,EAAE,UAAsB;QAC/D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;QAEnC,I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,KAAK,CAAC;YAC7B,CAAC,OAAO,CAAC,OAAO,EAClB;YACE,OAAO,QAAQ,CAAC;SACnB;QAED,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,WAAW,EAAE;YACb,OAAO;gBACH,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CACzC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CACpD,CAAC,MAAM,KAAK,IAAI,CAAC;YACtB,IAAI,CAAC,OAAO,EAAE;gBACV,OAAO,QAAQ,CAAC;aACnB;SACJ;QAED,MAAM,OAAO,GAA6B,IAAA,uBAAa,EACnD,OAAO,EACP,OAAO,CACV,CAAC;QACF,IAAI,OAAO,KAAK,IAAI,EAAE;YAClB,OAAO,QAAQ,CAAC;SACnB;QAED,OAAO;YACH,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,CAAC,WAAW,IAAI,OAAO;SACnC,CAAC;IACN,CAAC;CACJ;AA1MD,gCA0MC"}
@@ -0,0 +1,28 @@
1
+ import { Context } from './context';
2
+ export interface Constraint {
3
+ contextName: string;
4
+ operator: Operator;
5
+ inverted: boolean;
6
+ values: string[];
7
+ value?: string | number | Date;
8
+ caseInsensitive?: boolean;
9
+ }
10
+ export declare enum Operator {
11
+ IN = "IN",
12
+ NOT_IN = "NOT_IN",
13
+ STR_ENDS_WITH = "STR_ENDS_WITH",
14
+ STR_STARTS_WITH = "STR_STARTS_WITH",
15
+ STR_CONTAINS = "STR_CONTAINS",
16
+ NUM_EQ = "NUM_EQ",
17
+ NUM_GT = "NUM_GT",
18
+ NUM_GTE = "NUM_GTE",
19
+ NUM_LT = "NUM_LT",
20
+ NUM_LTE = "NUM_LTE",
21
+ DATE_AFTER = "DATE_AFTER",
22
+ DATE_BEFORE = "DATE_BEFORE",
23
+ SEMVER_EQ = "SEMVER_EQ",
24
+ SEMVER_GT = "SEMVER_GT",
25
+ SEMVER_LT = "SEMVER_LT"
26
+ }
27
+ export declare type OperatorImpl = (constraint: Constraint, context: Context) => boolean;
28
+ export declare const operators: Map<Operator, OperatorImpl>;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.operators = exports.Operator = void 0;
4
+ const semver_1 = require("semver");
5
+ const helpers_1 = require("./helpers");
6
+ var Operator;
7
+ (function (Operator) {
8
+ Operator["IN"] = "IN";
9
+ Operator["NOT_IN"] = "NOT_IN";
10
+ Operator["STR_ENDS_WITH"] = "STR_ENDS_WITH";
11
+ Operator["STR_STARTS_WITH"] = "STR_STARTS_WITH";
12
+ Operator["STR_CONTAINS"] = "STR_CONTAINS";
13
+ Operator["NUM_EQ"] = "NUM_EQ";
14
+ Operator["NUM_GT"] = "NUM_GT";
15
+ Operator["NUM_GTE"] = "NUM_GTE";
16
+ Operator["NUM_LT"] = "NUM_LT";
17
+ Operator["NUM_LTE"] = "NUM_LTE";
18
+ Operator["DATE_AFTER"] = "DATE_AFTER";
19
+ Operator["DATE_BEFORE"] = "DATE_BEFORE";
20
+ Operator["SEMVER_EQ"] = "SEMVER_EQ";
21
+ Operator["SEMVER_GT"] = "SEMVER_GT";
22
+ Operator["SEMVER_LT"] = "SEMVER_LT";
23
+ })(Operator = exports.Operator || (exports.Operator = {}));
24
+ const cleanValues = (values) => values.filter((v) => !!v).map((v) => v.trim());
25
+ const InOperator = (constraint, context) => {
26
+ const field = constraint.contextName;
27
+ const values = cleanValues(constraint.values);
28
+ const contextValue = (0, helpers_1.resolveContextValue)(context, field);
29
+ const isIn = values.some((val) => val === contextValue);
30
+ return constraint.operator === Operator.IN ? isIn : !isIn;
31
+ };
32
+ const StringOperator = (constraint, context) => {
33
+ const { contextName, operator, caseInsensitive } = constraint;
34
+ let values = cleanValues(constraint.values);
35
+ let contextValue = (0, helpers_1.resolveContextValue)(context, contextName);
36
+ if (caseInsensitive) {
37
+ values = values.map((v) => v.toLocaleLowerCase());
38
+ contextValue = contextValue?.toLocaleLowerCase();
39
+ }
40
+ if (operator === Operator.STR_STARTS_WITH) {
41
+ return values.some((val) => contextValue?.startsWith(val));
42
+ }
43
+ if (operator === Operator.STR_ENDS_WITH) {
44
+ return values.some((val) => contextValue?.endsWith(val));
45
+ }
46
+ if (operator === Operator.STR_CONTAINS) {
47
+ return values.some((val) => contextValue?.includes(val));
48
+ }
49
+ return false;
50
+ };
51
+ const SemverOperator = (constraint, context) => {
52
+ const { contextName, operator } = constraint;
53
+ const value = constraint.value;
54
+ const contextValue = (0, helpers_1.resolveContextValue)(context, contextName);
55
+ if (!contextValue) {
56
+ return false;
57
+ }
58
+ try {
59
+ if (operator === Operator.SEMVER_EQ) {
60
+ return (0, semver_1.eq)(contextValue, value);
61
+ }
62
+ if (operator === Operator.SEMVER_LT) {
63
+ return (0, semver_1.lt)(contextValue, value);
64
+ }
65
+ if (operator === Operator.SEMVER_GT) {
66
+ return (0, semver_1.gt)(contextValue, value);
67
+ }
68
+ }
69
+ catch (e) {
70
+ return false;
71
+ }
72
+ return false;
73
+ };
74
+ const DateOperator = (constraint, context) => {
75
+ const { operator } = constraint;
76
+ const value = new Date(constraint.value);
77
+ const currentTime = context.currentTime
78
+ ? new Date(context.currentTime)
79
+ : new Date();
80
+ if (operator === Operator.DATE_AFTER) {
81
+ return currentTime > value;
82
+ }
83
+ if (operator === Operator.DATE_BEFORE) {
84
+ return currentTime < value;
85
+ }
86
+ return false;
87
+ };
88
+ const NumberOperator = (constraint, context) => {
89
+ const field = constraint.contextName;
90
+ const { operator } = constraint;
91
+ const value = Number(constraint.value);
92
+ const contextValue = Number((0, helpers_1.resolveContextValue)(context, field));
93
+ if (Number.isNaN(value) || Number.isNaN(contextValue)) {
94
+ return false;
95
+ }
96
+ if (operator === Operator.NUM_EQ) {
97
+ return contextValue === value;
98
+ }
99
+ if (operator === Operator.NUM_GT) {
100
+ return contextValue > value;
101
+ }
102
+ if (operator === Operator.NUM_GTE) {
103
+ return contextValue >= value;
104
+ }
105
+ if (operator === Operator.NUM_LT) {
106
+ return contextValue < value;
107
+ }
108
+ if (operator === Operator.NUM_LTE) {
109
+ return contextValue <= value;
110
+ }
111
+ return false;
112
+ };
113
+ exports.operators = new Map();
114
+ exports.operators.set(Operator.IN, InOperator);
115
+ exports.operators.set(Operator.NOT_IN, InOperator);
116
+ exports.operators.set(Operator.STR_STARTS_WITH, StringOperator);
117
+ exports.operators.set(Operator.STR_ENDS_WITH, StringOperator);
118
+ exports.operators.set(Operator.STR_CONTAINS, StringOperator);
119
+ exports.operators.set(Operator.NUM_EQ, NumberOperator);
120
+ exports.operators.set(Operator.NUM_LT, NumberOperator);
121
+ exports.operators.set(Operator.NUM_LTE, NumberOperator);
122
+ exports.operators.set(Operator.NUM_GT, NumberOperator);
123
+ exports.operators.set(Operator.NUM_GTE, NumberOperator);
124
+ exports.operators.set(Operator.DATE_AFTER, DateOperator);
125
+ exports.operators.set(Operator.DATE_BEFORE, DateOperator);
126
+ exports.operators.set(Operator.SEMVER_EQ, SemverOperator);
127
+ exports.operators.set(Operator.SEMVER_GT, SemverOperator);
128
+ exports.operators.set(Operator.SEMVER_LT, SemverOperator);
129
+ //# sourceMappingURL=constraint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraint.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/constraint.ts"],"names":[],"mappings":";;;AAAA,mCAAwE;AAExE,uCAAgD;AAWhD,IAAY,QAgBX;AAhBD,WAAY,QAAQ;IAChB,qBAAS,CAAA;IACT,6BAAiB,CAAA;IACjB,2CAA+B,CAAA;IAC/B,+CAAmC,CAAA;IACnC,yCAA6B,CAAA;IAC7B,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,mCAAuB,CAA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C,CAAC;AAChD,iBAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AACjD,iBAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAClD,iBAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAClD,iBAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAClD,iBAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface Properties {
2
+ [key: string]: string | undefined | number;
3
+ }
4
+ export interface Context {
5
+ [key: string]: string | Date | undefined | number | Properties;
6
+ currentTime?: Date;
7
+ userId?: string;
8
+ sessionId?: string;
9
+ remoteAddress?: string;
10
+ environment?: string;
11
+ appName?: string;
12
+ properties?: Properties;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { FeatureStrategiesEvaluationResult } from './client';
2
+ import { RepositoryInterface } from './repository';
3
+ import { Context } from './context';
4
+ import { Strategy } from './strategy';
5
+ import { ClientFeaturesResponse, FeatureInterface } from './feature';
6
+ import { Variant } from './variant';
7
+ import { FallbackFunction } from './helpers';
8
+ import { BootstrapOptions } from './repository/bootstrap-provider';
9
+ import { StorageProvider } from './repository/storage-provider';
10
+ export { Strategy };
11
+ export interface FeatureEvaluatorConfig {
12
+ appName: string;
13
+ environment?: string;
14
+ strategies?: Strategy[];
15
+ repository?: RepositoryInterface;
16
+ bootstrap?: BootstrapOptions;
17
+ storageProvider?: StorageProvider<ClientFeaturesResponse>;
18
+ }
19
+ export interface StaticContext {
20
+ appName: string;
21
+ environment: string;
22
+ }
23
+ export declare class FeatureEvaluator {
24
+ private repository;
25
+ private client;
26
+ private staticContext;
27
+ constructor({ appName, environment, strategies, repository, bootstrap, storageProvider, }: FeatureEvaluatorConfig);
28
+ start(): Promise<void>;
29
+ destroy(): void;
30
+ isEnabled(name: string, context?: Context, fallbackFunction?: FallbackFunction): FeatureStrategiesEvaluationResult;
31
+ isEnabled(name: string, context?: Context, fallbackValue?: boolean): FeatureStrategiesEvaluationResult;
32
+ getVariant(name: string, context?: Context, fallbackVariant?: Variant): Variant;
33
+ forceGetVariant(name: string, context?: Context, fallbackVariant?: Variant): Variant;
34
+ getFeatureToggleDefinition(toggleName: string): FeatureInterface;
35
+ getFeatureToggleDefinitions(): FeatureInterface[];
36
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FeatureEvaluator = exports.Strategy = void 0;
7
+ const client_1 = __importDefault(require("./client"));
8
+ const repository_1 = __importDefault(require("./repository"));
9
+ const strategy_1 = require("./strategy");
10
+ Object.defineProperty(exports, "Strategy", { enumerable: true, get: function () { return strategy_1.Strategy; } });
11
+ const helpers_1 = require("./helpers");
12
+ const bootstrap_provider_1 = require("./repository/bootstrap-provider");
13
+ class FeatureEvaluator {
14
+ constructor({ appName, environment = 'default', strategies = [], repository, bootstrap = { data: [] }, storageProvider, }) {
15
+ this.staticContext = { appName, environment };
16
+ const bootstrapProvider = (0, bootstrap_provider_1.resolveBootstrapProvider)(bootstrap);
17
+ this.repository =
18
+ repository ||
19
+ new repository_1.default({
20
+ appName,
21
+ bootstrapProvider,
22
+ storageProvider: storageProvider,
23
+ });
24
+ // setup client
25
+ const supportedStrategies = strategies.concat(strategy_1.defaultStrategies);
26
+ this.client = new client_1.default(this.repository, supportedStrategies);
27
+ }
28
+ async start() {
29
+ return this.repository.start();
30
+ }
31
+ destroy() {
32
+ this.repository.stop();
33
+ }
34
+ isEnabled(name, context = {}, fallback) {
35
+ const enhancedContext = { ...this.staticContext, ...context };
36
+ const fallbackFunc = (0, helpers_1.createFallbackFunction)(name, enhancedContext, fallback);
37
+ return this.client.isEnabled(name, enhancedContext, fallbackFunc);
38
+ }
39
+ getVariant(name, context = {}, fallbackVariant) {
40
+ const enhancedContext = { ...this.staticContext, ...context };
41
+ return this.client.getVariant(name, enhancedContext, fallbackVariant);
42
+ }
43
+ forceGetVariant(name, context = {}, fallbackVariant) {
44
+ const enhancedContext = { ...this.staticContext, ...context };
45
+ return this.client.forceGetVariant(name, enhancedContext, fallbackVariant);
46
+ }
47
+ getFeatureToggleDefinition(toggleName) {
48
+ return this.repository.getToggle(toggleName);
49
+ }
50
+ getFeatureToggleDefinitions() {
51
+ return this.repository.getToggles();
52
+ }
53
+ }
54
+ exports.FeatureEvaluator = FeatureEvaluator;
55
+ //# sourceMappingURL=feature-evaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-evaluator.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/feature-evaluator.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAqE;AACrE,8DAA+D;AAE/D,yCAAyD;AAWhD,yFAXA,mBAAQ,OAWA;AAPjB,uCAAqE;AACrE,wEAGyC;AAmBzC,MAAa,gBAAgB;IAOzB,YAAY,EACR,OAAO,EACP,WAAW,GAAG,SAAS,EACvB,UAAU,GAAG,EAAE,EACf,UAAU,EACV,SAAS,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EACxB,eAAe,GACM;QACrB,IAAI,CAAC,aAAa,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QAE9C,MAAM,iBAAiB,GAAG,IAAA,6CAAwB,EAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,CAAC,UAAU;YACX,UAAU;gBACV,IAAI,oBAAU,CA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AC;IAED,0BAA0B,CAAC,UAAkB;QACzC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,2BAA2B;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;CACJ;AA9FD,4CA8FC"}
@@ -0,0 +1,19 @@
1
+ import { StrategyTransportInterface } from './strategy';
2
+ import { Segment } from './strategy/strategy';
3
+ import { VariantDefinition } from './variant';
4
+ export interface FeatureInterface {
5
+ name: string;
6
+ type: string;
7
+ description?: string;
8
+ enabled: boolean;
9
+ stale: boolean;
10
+ impressionData: boolean;
11
+ strategies: StrategyTransportInterface[];
12
+ variants: VariantDefinition[];
13
+ }
14
+ export interface ClientFeaturesResponse {
15
+ version: number;
16
+ features: FeatureInterface[];
17
+ query?: any;
18
+ segments?: Segment[];
19
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/feature.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { FeatureStrategiesEvaluationResult } from './client';
2
+ import { Context } from './context';
3
+ export declare type FallbackFunction = (name: string, context: Context) => boolean;
4
+ export declare function createFallbackFunction(name: string, context: Context, fallback?: FallbackFunction | boolean): () => FeatureStrategiesEvaluationResult;
5
+ export declare function resolveContextValue(context: Context, field: string): string | undefined;
6
+ export declare function safeName(str?: string): string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safeName = exports.resolveContextValue = exports.createFallbackFunction = void 0;
4
+ function createFallbackFunction(name, context, fallback) {
5
+ const createEvalResult = (enabled) => ({
6
+ result: enabled,
7
+ strategies: [],
8
+ });
9
+ if (typeof fallback === 'function') {
10
+ return () => createEvalResult(fallback(name, context));
11
+ }
12
+ if (typeof fallback === 'boolean') {
13
+ return () => createEvalResult(fallback);
14
+ }
15
+ return () => createEvalResult(false);
16
+ }
17
+ exports.createFallbackFunction = createFallbackFunction;
18
+ function resolveContextValue(context, field) {
19
+ if (context[field]) {
20
+ return context[field];
21
+ }
22
+ if (context.properties && context.properties[field]) {
23
+ return context.properties[field];
24
+ }
25
+ return undefined;
26
+ }
27
+ exports.resolveContextValue = resolveContextValue;
28
+ function safeName(str = '') {
29
+ return str.replace(/\//g, '_');
30
+ }
31
+ exports.safeName = safeName;
32
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/helpers.ts"],"names":[],"mappings":";;;AAKA,SAAgB,sBAAsB,CAClC,IAAY,EACZ,OAAgB,EAChB,QAAqC;IAErC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC;QAC5C,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,EAAE;KACjB,CAAC,CAAC;IAEH,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;QAChC,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;KAC1D;IACD,IAAI,OAAO,QAAQ,KAAK,SAAS,EAAE;QAC/B,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KAC3C;IACD,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAjBD,wDAiBC;AAED,SAAgB,mBAAmB,CAC/B,OAAgB,EAChB,KAAa;IAEb,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,OAAO,CAAC,KAAK,CAAW,CAAC;KACnC;IACD,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QACjD,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK,CAAW,CAAC;KAC9C;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAXD,kDAWC;AAED,SAAgB,QAAQ,CAAC,MAAc,EAAE;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,4BAEC"}
@@ -0,0 +1,8 @@
1
+ import { FeatureEvaluator, FeatureEvaluatorConfig } from './feature-evaluator';
2
+ import { Variant } from './variant';
3
+ import { Context } from './context';
4
+ import { ClientFeaturesResponse } from './feature';
5
+ import InMemStorageProvider from './repository/storage-provider-in-mem';
6
+ export { Strategy } from './strategy/index';
7
+ export { Context, Variant, FeatureEvaluator, InMemStorageProvider };
8
+ export type { ClientFeaturesResponse, FeatureEvaluatorConfig };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InMemStorageProvider = exports.FeatureEvaluator = exports.Strategy = void 0;
7
+ const feature_evaluator_1 = require("./feature-evaluator");
8
+ Object.defineProperty(exports, "FeatureEvaluator", { enumerable: true, get: function () { return feature_evaluator_1.FeatureEvaluator; } });
9
+ const storage_provider_in_mem_1 = __importDefault(require("./repository/storage-provider-in-mem"));
10
+ exports.InMemStorageProvider = storage_provider_in_mem_1.default;
11
+ // exports
12
+ var index_1 = require("./strategy/index");
13
+ Object.defineProperty(exports, "Strategy", { enumerable: true, get: function () { return index_1.Strategy; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/util/feature-evaluator/index.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA+E;AAQpD,iGARlB,oCAAgB,OAQkB;AAJ3C,mGAAwE;AAI3B,+BAJtC,iCAAoB,CAIsC;AAFjE,UAAU;AACV,0CAA4C;AAAnC,iGAAA,QAAQ,OAAA"}
@@ -0,0 +1,16 @@
1
+ import { ClientFeaturesResponse, FeatureInterface } from '../feature';
2
+ import { Segment } from '../strategy/strategy';
3
+ export interface BootstrapProvider {
4
+ readBootstrap(): Promise<ClientFeaturesResponse | undefined>;
5
+ }
6
+ export interface BootstrapOptions {
7
+ data: FeatureInterface[];
8
+ segments?: Segment[];
9
+ }
10
+ export declare class DefaultBootstrapProvider implements BootstrapProvider {
11
+ private data?;
12
+ private segments?;
13
+ constructor(options: BootstrapOptions);
14
+ readBootstrap(): Promise<ClientFeaturesResponse | undefined>;
15
+ }
16
+ export declare function resolveBootstrapProvider(options: BootstrapOptions): BootstrapProvider;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveBootstrapProvider = exports.DefaultBootstrapProvider = void 0;
4
+ class DefaultBootstrapProvider {
5
+ constructor(options) {
6
+ this.data = options.data;
7
+ this.segments = options.segments;
8
+ }
9
+ async readBootstrap() {
10
+ if (this.data) {
11
+ return {
12
+ version: 2,
13
+ segments: this.segments,
14
+ features: [...this.data],
15
+ };
16
+ }
17
+ return undefined;
18
+ }
19
+ }
20
+ exports.DefaultBootstrapProvider = DefaultBootstrapProvider;
21
+ function resolveBootstrapProvider(options) {
22
+ return new DefaultBootstrapProvider(options);
23
+ }
24
+ exports.resolveBootstrapProvider = resolveBootstrapProvider;
25
+ //# sourceMappingURL=bootstrap-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-provider.js","sourceRoot":"","sources":["../../../../../src/lib/util/feature-evaluator/repository/bootstrap-provider.ts"],"names":[],"mappings":";;;AAYA,MAAa,wBAAwB;IAKjC,YAAY,OAAyB;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,aAAa;QACf,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,OAAO;gBACH,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;aAC3B,CAAC;SACL;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AApBD,4DAoBC;AAED,SAAgB,wBAAwB,CACpC,OAAyB;IAEzB,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC;AAJD,4DAIC"}