@plyaz/core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +439 -0
  2. package/dist/backend/featureFlags/feature-flag.controller.d.ts +135 -0
  3. package/dist/backend/featureFlags/feature-flag.controller.d.ts.map +1 -0
  4. package/dist/backend/featureFlags/feature-flag.module.d.ts +114 -0
  5. package/dist/backend/featureFlags/feature-flag.module.d.ts.map +1 -0
  6. package/dist/backend/featureFlags/feature-flag.repository.d.ts +85 -0
  7. package/dist/backend/featureFlags/feature-flag.repository.d.ts.map +1 -0
  8. package/dist/backend/featureFlags/feature-flag.service.d.ts +123 -0
  9. package/dist/backend/featureFlags/feature-flag.service.d.ts.map +1 -0
  10. package/dist/backend/featureFlags/index.d.ts +49 -0
  11. package/dist/backend/featureFlags/index.d.ts.map +1 -0
  12. package/dist/backend/index.d.ts +5 -0
  13. package/dist/backend/index.d.ts.map +1 -0
  14. package/dist/cache/index.d.ts +98 -0
  15. package/dist/cache/index.d.ts.map +1 -0
  16. package/dist/cache/strategies/memory.d.ts +103 -0
  17. package/dist/cache/strategies/memory.d.ts.map +1 -0
  18. package/dist/cache/strategies/redis.d.ts +105 -0
  19. package/dist/cache/strategies/redis.d.ts.map +1 -0
  20. package/dist/domain/featureFlags/index.d.ts +49 -0
  21. package/dist/domain/featureFlags/index.d.ts.map +1 -0
  22. package/dist/domain/featureFlags/provider.d.ts +166 -0
  23. package/dist/domain/featureFlags/provider.d.ts.map +1 -0
  24. package/dist/domain/featureFlags/providers/api.d.ts +78 -0
  25. package/dist/domain/featureFlags/providers/api.d.ts.map +1 -0
  26. package/dist/domain/featureFlags/providers/database.d.ts +102 -0
  27. package/dist/domain/featureFlags/providers/database.d.ts.map +1 -0
  28. package/dist/domain/featureFlags/providers/factory.d.ts +116 -0
  29. package/dist/domain/featureFlags/providers/factory.d.ts.map +1 -0
  30. package/dist/domain/featureFlags/providers/file.d.ts +84 -0
  31. package/dist/domain/featureFlags/providers/file.d.ts.map +1 -0
  32. package/dist/domain/featureFlags/providers/memory.d.ts +179 -0
  33. package/dist/domain/featureFlags/providers/memory.d.ts.map +1 -0
  34. package/dist/domain/featureFlags/providers/redis.d.ts +80 -0
  35. package/dist/domain/featureFlags/providers/redis.d.ts.map +1 -0
  36. package/dist/domain/index.d.ts +6 -0
  37. package/dist/domain/index.d.ts.map +1 -0
  38. package/dist/domain/types.d.ts +18 -0
  39. package/dist/domain/types.d.ts.map +1 -0
  40. package/dist/engine/featureFlags/engine.d.ts +193 -0
  41. package/dist/engine/featureFlags/engine.d.ts.map +1 -0
  42. package/dist/engine/featureFlags/index.d.ts +10 -0
  43. package/dist/engine/featureFlags/index.d.ts.map +1 -0
  44. package/dist/engine/index.d.ts +5 -0
  45. package/dist/engine/index.d.ts.map +1 -0
  46. package/dist/frontend/featureFlags/hooks/useFeatureFlag.d.ts +103 -0
  47. package/dist/frontend/featureFlags/hooks/useFeatureFlag.d.ts.map +1 -0
  48. package/dist/frontend/featureFlags/hooks/useFeatureFlagActions.d.ts +35 -0
  49. package/dist/frontend/featureFlags/hooks/useFeatureFlagActions.d.ts.map +1 -0
  50. package/dist/frontend/featureFlags/hooks/useFeatureFlagHelpers.d.ts +55 -0
  51. package/dist/frontend/featureFlags/hooks/useFeatureFlagHelpers.d.ts.map +1 -0
  52. package/dist/frontend/featureFlags/hooks/useFeatureFlagProvider.d.ts +57 -0
  53. package/dist/frontend/featureFlags/hooks/useFeatureFlagProvider.d.ts.map +1 -0
  54. package/dist/frontend/featureFlags/index.d.ts +14 -0
  55. package/dist/frontend/featureFlags/index.d.ts.map +1 -0
  56. package/dist/frontend/featureFlags/providers/FeatureFlagProvider.d.ts +99 -0
  57. package/dist/frontend/featureFlags/providers/FeatureFlagProvider.d.ts.map +1 -0
  58. package/dist/frontend/featureFlags/providers/FeatureFlagProviderHelpers.d.ts +45 -0
  59. package/dist/frontend/featureFlags/providers/FeatureFlagProviderHelpers.d.ts.map +1 -0
  60. package/dist/frontend/index.d.ts +2 -0
  61. package/dist/frontend/index.d.ts.map +1 -0
  62. package/dist/index.cjs +3951 -0
  63. package/dist/index.cjs.map +1 -0
  64. package/dist/index.d.ts +7 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.mjs +3902 -0
  67. package/dist/index.mjs.map +1 -0
  68. package/dist/utils/common/hash.d.ts +81 -0
  69. package/dist/utils/common/hash.d.ts.map +1 -0
  70. package/dist/utils/common/index.d.ts +11 -0
  71. package/dist/utils/common/index.d.ts.map +1 -0
  72. package/dist/utils/common/values.d.ts +48 -0
  73. package/dist/utils/common/values.d.ts.map +1 -0
  74. package/dist/utils/featureFlags/conditions.d.ts +114 -0
  75. package/dist/utils/featureFlags/conditions.d.ts.map +1 -0
  76. package/dist/utils/featureFlags/context.d.ts +241 -0
  77. package/dist/utils/featureFlags/context.d.ts.map +1 -0
  78. package/dist/utils/featureFlags/index.d.ts +11 -0
  79. package/dist/utils/featureFlags/index.d.ts.map +1 -0
  80. package/dist/utils/index.d.ts +6 -0
  81. package/dist/utils/index.d.ts.map +1 -0
  82. package/package.json +144 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Hash Utilities
3
+ *
4
+ * Common hashing functions for consistent data distribution and rollouts.
5
+ *
6
+ * @fileoverview Hash utility functions
7
+ * @version 1.0.0
8
+ */
9
+ /**
10
+ * Simple string hashing function for consistent distribution.
11
+ * Uses a basic polynomial rolling hash for good distribution.
12
+ *
13
+ * @param str - String to hash
14
+ * @returns Positive hash value
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const hash = hashString('user123:AUTH_GOOGLE');
19
+ * const bucket = hash % 100; // 0-99
20
+ * ```
21
+ */
22
+ export declare function hashString(str: string): number;
23
+ /**
24
+ * Determines if a user should be included in a rollout based on percentage.
25
+ * Uses consistent hashing to ensure the same user always gets the same result.
26
+ *
27
+ * @param identifier - Unique identifier for consistency (e.g., userId, flagKey)
28
+ * @param percentage - Rollout percentage (0-100)
29
+ * @returns true if identifier should be included in rollout
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const shouldInclude = isInRollout('user123:AUTH_GOOGLE', 25); // 25% rollout
34
+ * ```
35
+ */
36
+ export declare function isInRollout(identifier: string, percentage: number): boolean;
37
+ /**
38
+ * Creates a consistent rollout identifier for a user and feature.
39
+ *
40
+ * @param featureKey - Feature or flag key
41
+ * @param userId - User identifier (defaults to 'anonymous')
42
+ * @returns Consistent identifier for rollout calculations
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const identifier = createRolloutIdentifier('AUTH_GOOGLE', 'user123');
47
+ * const inRollout = isInRollout(identifier, 50);
48
+ * ```
49
+ */
50
+ export declare function createRolloutIdentifier(featureKey: string, userId?: string): string;
51
+ /**
52
+ * Hash-based utilities for consistent data operations.
53
+ */
54
+ export declare const HashUtils: {
55
+ /**
56
+ * Generates a hash-based bucket for load balancing or distribution.
57
+ *
58
+ * @param identifier - Unique identifier
59
+ * @param bucketCount - Number of buckets (default: 10)
60
+ * @returns Bucket number (0 to bucketCount-1)
61
+ */
62
+ readonly getBucket: (identifier: string, bucketCount?: number) => number;
63
+ /**
64
+ * Checks if an identifier falls within a specific bucket range.
65
+ *
66
+ * @param identifier - Unique identifier
67
+ * @param startBucket - Starting bucket (inclusive)
68
+ * @param endBucket - Ending bucket (inclusive)
69
+ * @param totalBuckets - Total number of buckets (default: 100)
70
+ * @returns true if identifier is in the bucket range
71
+ */
72
+ readonly isInBucketRange: (identifier: string, startBucket: number, endBucket: number, totalBuckets?: number) => boolean;
73
+ /**
74
+ * Creates a deterministic random seed from a string.
75
+ *
76
+ * @param str - String to convert to seed
77
+ * @returns Deterministic seed value
78
+ */
79
+ readonly createSeed: (str: string) => number;
80
+ };
81
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/utils/common/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAM3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAInF;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;;;;;OAMG;qCACqB,MAAM,gBAAe,MAAM,KAAQ,MAAM;IAIjE;;;;;;;;OAQG;2CAEW,MAAM,eACL,MAAM,aACR,MAAM,iBACH,MAAM,KACnB,OAAO;IAKV;;;;;OAKG;+BACe,MAAM,KAAG,MAAM;CAIzB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Common Utilities - Main Export
3
+ *
4
+ * Exports all common utility functions that can be reused across the application.
5
+ *
6
+ * @fileoverview Common utilities export
7
+ * @version 1.0.0
8
+ */
9
+ export { hashString, isInRollout, createRolloutIdentifier, HashUtils } from './hash';
10
+ export { isTruthy, toBoolean, ValueUtils } from './values';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGrF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Value Utilities
3
+ *
4
+ * Common utility functions for working with different value types.
5
+ *
6
+ * @fileoverview Value manipulation utilities
7
+ * @version 1.0.0
8
+ */
9
+ export declare function isTruthy(value: unknown): boolean;
10
+ export declare function toBoolean(value: unknown, defaultValue?: boolean): boolean;
11
+ /**
12
+ * Value validation and conversion utilities.
13
+ */
14
+ export declare const ValueUtils: {
15
+ /**
16
+ * Checks if a value is a valid percentage (0-100).
17
+ *
18
+ * @param value - Value to check
19
+ * @returns true if valid percentage
20
+ */
21
+ readonly isValidPercentage: (value: unknown) => boolean;
22
+ /**
23
+ * Clamps a number to a specific range.
24
+ *
25
+ * @param value - Value to clamp
26
+ * @param min - Minimum value
27
+ * @param max - Maximum value
28
+ * @returns Clamped value
29
+ */
30
+ readonly clamp: (value: number, min: number, max: number) => number;
31
+ /**
32
+ * Checks if a value is empty (null, undefined, empty string, empty array).
33
+ *
34
+ * @param value - Value to check
35
+ * @returns true if empty
36
+ */
37
+ readonly isEmpty: (value: unknown) => boolean;
38
+ /**
39
+ * Safely gets a nested property from an object.
40
+ *
41
+ * @param obj - Object to query
42
+ * @param path - Dot-separated path (e.g., 'user.profile.name')
43
+ * @param defaultValue - Default if path doesn't exist
44
+ * @returns Property value or default
45
+ */
46
+ readonly getNestedProperty: (obj: unknown, path: string, defaultValue?: unknown) => unknown;
47
+ };
48
+ //# sourceMappingURL=values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../../src/utils/common/values.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAmCH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkBhD;AA2BD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO,CAgBhF;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB;;;;;OAKG;wCACwB,OAAO,KAAG,OAAO;IAK5C;;;;;;;OAOG;4BACY,MAAM,OAAO,MAAM,OAAO,MAAM,KAAG,MAAM;IAIxD;;;;;OAKG;8BACc,OAAO,KAAG,OAAO;IAQlC;;;;;;;OAOG;sCACsB,OAAO,QAAQ,MAAM,iBAAiB,OAAO,KAAG,OAAO;CAcxE,CAAC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Feature Flag Condition Utilities
3
+ *
4
+ * Utilities for evaluating feature flag conditions and rules.
5
+ *
6
+ * @fileoverview Condition evaluation utilities
7
+ * @version 1.0.0
8
+ */
9
+ import type { FeatureFlagCondition } from '@plyaz/types';
10
+ /**
11
+ * Evaluates condition operator against context value.
12
+ *
13
+ * @param condition - The condition to evaluate
14
+ * @param contextValue - The context value to check against
15
+ * @returns true if the condition matches
16
+ */
17
+ export declare function evaluateConditionOperator(condition: FeatureFlagCondition, contextValue: unknown): boolean;
18
+ /**
19
+ * Checks if operator is equality-based.
20
+ *
21
+ * @param operator - The operator to check
22
+ * @returns true if equality operator
23
+ */
24
+ export declare function isEqualityOperator(operator: string): boolean;
25
+ /**
26
+ * Checks if operator is string-based.
27
+ *
28
+ * @param operator - The operator to check
29
+ * @returns true if string operator
30
+ */
31
+ export declare function isStringOperator(operator: string): boolean;
32
+ /**
33
+ * Checks if operator is array-based.
34
+ *
35
+ * @param operator - The operator to check
36
+ * @returns true if array operator
37
+ */
38
+ export declare function isArrayOperator(operator: string): boolean;
39
+ /**
40
+ * Checks if operator is numeric-based.
41
+ *
42
+ * @param operator - The operator to check
43
+ * @returns true if numeric operator
44
+ */
45
+ export declare function isNumericOperator(operator: string): boolean;
46
+ /**
47
+ * Evaluates equality operators.
48
+ *
49
+ * @param operator - equals or not_equals
50
+ * @param contextValue - Value from context
51
+ * @param conditionValue - Value from condition
52
+ * @returns Evaluation result
53
+ */
54
+ export declare function evaluateEqualityOperator(operator: string, contextValue: unknown, conditionValue: unknown): boolean;
55
+ /**
56
+ * Evaluates string operators.
57
+ *
58
+ * @param operator - contains or not_contains
59
+ * @param contextValue - Value from context
60
+ * @param conditionValue - Value from condition
61
+ * @returns Evaluation result
62
+ */
63
+ export declare function evaluateStringOperator(operator: string, contextValue: unknown, conditionValue: unknown): boolean;
64
+ /**
65
+ * Evaluates array operators.
66
+ *
67
+ * @param operator - in or not_in
68
+ * @param conditionValue - Array value from condition
69
+ * @param contextValue - Value from context
70
+ * @returns Evaluation result
71
+ */
72
+ export declare function evaluateArrayOperator(operator: string, conditionValue: unknown, contextValue: unknown): boolean;
73
+ export declare function evaluateNumericOperator(operator: string, contextValue: unknown, conditionValue: unknown): boolean;
74
+ /**
75
+ * Condition evaluation utilities.
76
+ */
77
+ export declare const ConditionUtils: {
78
+ /**
79
+ * Evaluates multiple conditions with AND logic.
80
+ *
81
+ * @param conditions - Array of conditions
82
+ * @param contextValue - Context value getter function
83
+ * @returns true if all conditions match
84
+ */
85
+ readonly evaluateConditionsAnd: (conditions: FeatureFlagCondition[], contextValue: (field: string) => unknown) => boolean;
86
+ /**
87
+ * Evaluates multiple conditions with OR logic.
88
+ *
89
+ * @param conditions - Array of conditions
90
+ * @param contextValue - Context value getter function
91
+ * @returns true if any condition matches
92
+ */
93
+ readonly evaluateConditionsOr: (conditions: FeatureFlagCondition[], contextValue: (field: string) => unknown) => boolean;
94
+ /**
95
+ * Validates a condition structure.
96
+ *
97
+ * @param condition - Condition to validate
98
+ * @returns Validation result
99
+ */
100
+ readonly validateCondition: (condition: Partial<FeatureFlagCondition>) => {
101
+ isValid: boolean;
102
+ errors: string[];
103
+ };
104
+ /**
105
+ * Creates a condition object with validation.
106
+ *
107
+ * @param field - Context field to evaluate
108
+ * @param operator - Comparison operator
109
+ * @param value - Value to compare against
110
+ * @returns Valid condition object
111
+ */
112
+ readonly createCondition: (field: string, operator: FeatureFlagCondition["operator"], value: FeatureFlagCondition["value"]) => FeatureFlagCondition;
113
+ };
114
+ //# sourceMappingURL=conditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,yBA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EAAE,MAAM,EAAE,CAAC;KAClB;IAmCD;;;;;;;OAOG;sCAEM,MAAM,YACH,oBAAoB,CAAC,UAAU,CAAC,SACnC,oBAAoB,CAAC,OAAO,CAAC,KACnC,oBAAoB;CAUf,CAAC"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Feature Flag Context Utilities
3
+ *
4
+ * Utilities for building, validating, and manipulating feature flag contexts.
5
+ * Re-exports the context builder and utilities from domain layer for convenience.
6
+ *
7
+ * @fileoverview Feature flag context utilities
8
+ * @version 1.0.0
9
+ */
10
+ import type { FeatureFlagContext } from '@plyaz/types';
11
+ /**
12
+ * Builder class for creating feature flag evaluation contexts.
13
+ * Provides a fluent interface for setting context properties.
14
+ *
15
+ * @class FeatureFlagContextBuilder
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const context = new FeatureFlagContextBuilder()
20
+ * .setUserId('user123')
21
+ * .setUserRole('premium')
22
+ * .setEnvironment('production')
23
+ * .setPlatform('web')
24
+ * .setCustom({ subscription: 'premium', betaTester: true })
25
+ * .build();
26
+ * ```
27
+ */
28
+ export declare class FeatureFlagContextBuilder {
29
+ private context;
30
+ /**
31
+ * Sets the user ID in the context.
32
+ *
33
+ * @param userId - User identifier
34
+ * @returns Builder instance for chaining
35
+ */
36
+ setUserId(userId: string): this;
37
+ /**
38
+ * Sets the user email in the context.
39
+ *
40
+ * @param userEmail - User email address
41
+ * @returns Builder instance for chaining
42
+ */
43
+ setUserEmail(userEmail: string): this;
44
+ /**
45
+ * Sets the user role in the context.
46
+ *
47
+ * @param userRole - User role or permission level
48
+ * @returns Builder instance for chaining
49
+ */
50
+ setUserRole(userRole: string): this;
51
+ /**
52
+ * Sets the country in the context.
53
+ *
54
+ * @param country - Country code (ISO 3166-1 alpha-2)
55
+ * @returns Builder instance for chaining
56
+ */
57
+ setCountry(country: string): this;
58
+ /**
59
+ * Sets the platform in the context.
60
+ *
61
+ * @param platform - Platform type
62
+ * @returns Builder instance for chaining
63
+ */
64
+ setPlatform(platform: 'web' | 'mobile' | 'desktop'): this;
65
+ /**
66
+ * Sets the version in the context.
67
+ *
68
+ * @param version - Application version
69
+ * @returns Builder instance for chaining
70
+ */
71
+ setVersion(version: string): this;
72
+ /**
73
+ * Sets the environment in the context.
74
+ *
75
+ * @param environment - Current environment
76
+ * @returns Builder instance for chaining
77
+ */
78
+ setEnvironment(environment: 'development' | 'staging' | 'production'): this;
79
+ /**
80
+ * Sets custom context data.
81
+ *
82
+ * @param custom - Custom context properties
83
+ * @returns Builder instance for chaining
84
+ */
85
+ setCustom(custom: Record<string, unknown>): this;
86
+ /**
87
+ * Adds a single custom property to the context.
88
+ *
89
+ * @param key - Custom property key
90
+ * @param value - Custom property value
91
+ * @returns Builder instance for chaining
92
+ */
93
+ addCustomProperty(key: string, value: unknown): this;
94
+ /**
95
+ * Builds the final context object.
96
+ * Validates required fields and returns the context.
97
+ *
98
+ * @returns Complete feature flag context
99
+ * @throws Error if required environment is not set
100
+ */
101
+ build(): FeatureFlagContext;
102
+ /**
103
+ * Clears all context data and resets the builder.
104
+ *
105
+ * @returns Builder instance for chaining
106
+ */
107
+ clear(): this;
108
+ /**
109
+ * Creates a copy of the current builder state.
110
+ *
111
+ * @returns New builder instance with copied context
112
+ */
113
+ clone(): FeatureFlagContextBuilder;
114
+ }
115
+ /**
116
+ * Context utilities for common scenarios.
117
+ */
118
+ export declare const ContextUtils: {
119
+ /**
120
+ * Creates a basic context for anonymous users using the builder.
121
+ *
122
+ * @param environment - Target environment
123
+ * @param platform - User platform
124
+ * @returns Basic anonymous context
125
+ */
126
+ readonly createAnonymousContext: (environment: "development" | "staging" | "production", platform?: "web" | "mobile" | "desktop") => FeatureFlagContext;
127
+ /**
128
+ * Creates a context for authenticated users using the builder.
129
+ *
130
+ * @param params - User context parameters
131
+ * @returns User context
132
+ */
133
+ readonly createUserContext: (params: {
134
+ userId: string;
135
+ environment: "development" | "staging" | "production";
136
+ userEmail?: string;
137
+ userRole?: string;
138
+ platform?: "web" | "mobile" | "desktop";
139
+ country?: string;
140
+ version?: string;
141
+ custom?: Record<string, unknown>;
142
+ }) => FeatureFlagContext;
143
+ /**
144
+ * Creates a testing context with minimal required fields.
145
+ *
146
+ * @param overrides - Optional context overrides
147
+ * @returns Testing context
148
+ */
149
+ readonly createTestingContext: (overrides?: Partial<FeatureFlagContext>) => FeatureFlagContext;
150
+ /**
151
+ * Validates if a context object is complete and valid.
152
+ *
153
+ * @param context - Context to validate
154
+ * @returns Validation result
155
+ */
156
+ readonly validateContext: (context: Partial<FeatureFlagContext>) => {
157
+ isValid: boolean;
158
+ errors: string[];
159
+ };
160
+ /**
161
+ * Merges multiple context objects, with later contexts taking precedence.
162
+ *
163
+ * @param contexts - Array of contexts to merge
164
+ * @returns Merged context
165
+ */
166
+ readonly mergeContexts: (...contexts: Partial<FeatureFlagContext>[]) => FeatureFlagContext;
167
+ /**
168
+ * Extracts a specific field value from a context.
169
+ *
170
+ * @param field - Field name to extract
171
+ * @param context - Context object
172
+ * @returns Field value or undefined
173
+ */
174
+ readonly getContextValue: (field: string, context: FeatureFlagContext) => unknown;
175
+ /**
176
+ * Creates a context fingerprint for caching and consistency.
177
+ *
178
+ * @param context - Context to fingerprint
179
+ * @returns String fingerprint
180
+ */
181
+ readonly createFingerprint: (context: FeatureFlagContext) => string;
182
+ /**
183
+ * Sanitizes a context by removing sensitive information.
184
+ *
185
+ * @param context - Context to sanitize
186
+ * @param sensitiveFields - Fields to remove (default: ['userEmail'])
187
+ * @returns Sanitized context
188
+ */
189
+ readonly sanitizeContext: (context: FeatureFlagContext, sensitiveFields?: string[]) => FeatureFlagContext;
190
+ };
191
+ /**
192
+ * Utility for creating feature flag context for backend applications.
193
+ *
194
+ * @param params - Context parameters
195
+ * @returns Backend-optimized feature flag context
196
+ */
197
+ export declare function createBackendContext(params: {
198
+ userId?: string;
199
+ userEmail?: string;
200
+ environment: 'development' | 'staging' | 'production';
201
+ userRole?: string;
202
+ platform?: 'api' | 'worker' | 'cron';
203
+ country?: string;
204
+ version?: string;
205
+ custom?: Record<string, unknown>;
206
+ }): {
207
+ environment: 'development' | 'staging' | 'production';
208
+ userId?: string;
209
+ userEmail?: string;
210
+ userRole?: string;
211
+ platform: 'api' | 'worker' | 'cron';
212
+ country?: string;
213
+ version?: string;
214
+ custom?: Record<string, unknown>;
215
+ };
216
+ /**
217
+ * Utility for creating feature flag context for frontend applications.
218
+ *
219
+ * @param params - Context parameters
220
+ * @returns Frontend-optimized feature flag context
221
+ */
222
+ export declare function createFrontendContext(params: {
223
+ userId?: string;
224
+ userEmail?: string;
225
+ environment: 'development' | 'staging' | 'production';
226
+ userRole?: string;
227
+ platform?: 'web' | 'mobile' | 'desktop';
228
+ country?: string;
229
+ version?: string;
230
+ custom?: Record<string, unknown>;
231
+ }): {
232
+ environment: 'development' | 'staging' | 'production';
233
+ userId?: string;
234
+ userEmail?: string;
235
+ userRole?: string;
236
+ platform: 'web' | 'mobile' | 'desktop';
237
+ country?: string;
238
+ version?: string;
239
+ custom?: Record<string, unknown>;
240
+ };
241
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B;;;;;OAKG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKrC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnC;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,K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W,EAAE,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GAAG;IACF,WAAW,EAAE,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAWA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Feature Flag Utilities - Main Export
3
+ *
4
+ * Exports all feature flag specific utility functions.
5
+ *
6
+ * @fileoverview Feature flag utilities export
7
+ * @version 1.0.0
8
+ */
9
+ export { ContextUtils, FeatureFlagContextBuilder, createBackendContext, createFrontendContext, } from './context';
10
+ export { evaluateConditionOperator, isEqualityOperator, isStringOperator, isArrayOperator, isNumericOperator, evaluateEqualityOperator, evaluateStringOperator, evaluateArrayOperator, evaluateNumericOperator, ConditionUtils, } from './conditions';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/featureFlags/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,GACf,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utilities Exports
3
+ */
4
+ export * from './common';
5
+ export * from './featureFlags';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC"}