@flagix/js-sdk 1.1.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.
@@ -0,0 +1,19 @@
1
+
2
+ > @flagix/js-sdk@1.1.0 build /home/runner/work/flagixx/flagixx/sdk/javascript
3
+ > tsup src/index.ts --format cjs,esm --dts --clean
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.1
8
+ CLI Target: es2020
9
+ CLI Cleaning output folder
10
+ CJS Build start
11
+ ESM Build start
12
+ CJS dist/index.js 17.16 KB
13
+ CJS ⚡️ Build success in 49ms
14
+ ESM dist/index.mjs 15.47 KB
15
+ ESM ⚡️ Build success in 49ms
16
+ DTS Build start
17
+ DTS ⚡️ Build success in 1843ms
18
+ DTS dist/index.d.ts 2.30 KB
19
+ DTS dist/index.d.mts 2.30 KB
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # @flagix/js-sdk
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ab7f12d: initial release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ab7f12d]
12
+ - @flagix/evaluation-core@1.1.0
@@ -0,0 +1,68 @@
1
+ import { EvaluationContext, VariationValue } from '@flagix/evaluation-core';
2
+ export { EvaluationContext, FlagConfig, FlagVariation, VariationValue } from '@flagix/evaluation-core';
3
+
4
+ /**
5
+ * 'info' is for detailed debugging information
6
+ * 'warn' is for non-critical issues
7
+ * 'error' is for critical failures
8
+ * 'none' suppresses all output.
9
+ */
10
+ type LogLevel = "none" | "error" | "warn" | "info";
11
+
12
+ type FlagixClientOptions = {
13
+ /** The API Key for the environment */
14
+ apiKey: string;
15
+ /** The base URL for the flag evaluation API */
16
+ apiBaseUrl: string;
17
+ /** Optional context attributes */
18
+ initialContext?: EvaluationContext;
19
+ /** Enable SDK logging */
20
+ logs?: {
21
+ level?: LogLevel;
22
+ };
23
+ };
24
+
25
+ declare const Flagix: {
26
+ /**
27
+ * Initializes the Flagix SDK, fetches all flags, and sets up an SSE connection.
28
+ */
29
+ initialize(options: FlagixClientOptions): Promise<void>;
30
+ /**
31
+ * Evaluates a flag based on the local cache and current context.
32
+ * @param flagKey The key of the flag to evaluate.
33
+ * @param contextOverrides Optional, temporary context overrides.
34
+ */
35
+ evaluate<T extends VariationValue>(flagKey: string, contextOverrides?: EvaluationContext): T | null;
36
+ /**
37
+ * Records a custom event for analytics.
38
+ * @param eventName The name of the event.
39
+ * @param properties Optional custom metadata.
40
+ * @param contextOverrides Optional context.
41
+ */
42
+ track(eventName: string, properties?: Record<string, unknown>, contextOverrides?: EvaluationContext): void;
43
+ /**
44
+ * Sets or updates the global evaluation context.
45
+ * @param newContext New context attributes to merge or replace.
46
+ */
47
+ setContext(newContext: EvaluationContext): void;
48
+ /**
49
+ * Closes the SSE connection and cleans up resources.
50
+ */
51
+ close(): void;
52
+ /**
53
+ * checks initialization status
54
+ */
55
+ isInitialized(): boolean;
56
+ /**
57
+ * Subscribes a listener to updates for any flag.
58
+ * @param listener The callback function (receives the updated flagKey).
59
+ */
60
+ onFlagUpdate(listener: (flagKey: string) => void): void;
61
+ /**
62
+ * Unsubscribes a listener from flag updates.
63
+ * @param listener The callback function to remove.
64
+ */
65
+ offFlagUpdate(listener: (flagKey: string) => void): void;
66
+ };
67
+
68
+ export { Flagix, type FlagixClientOptions };
@@ -0,0 +1,68 @@
1
+ import { EvaluationContext, VariationValue } from '@flagix/evaluation-core';
2
+ export { EvaluationContext, FlagConfig, FlagVariation, VariationValue } from '@flagix/evaluation-core';
3
+
4
+ /**
5
+ * 'info' is for detailed debugging information
6
+ * 'warn' is for non-critical issues
7
+ * 'error' is for critical failures
8
+ * 'none' suppresses all output.
9
+ */
10
+ type LogLevel = "none" | "error" | "warn" | "info";
11
+
12
+ type FlagixClientOptions = {
13
+ /** The API Key for the environment */
14
+ apiKey: string;
15
+ /** The base URL for the flag evaluation API */
16
+ apiBaseUrl: string;
17
+ /** Optional context attributes */
18
+ initialContext?: EvaluationContext;
19
+ /** Enable SDK logging */
20
+ logs?: {
21
+ level?: LogLevel;
22
+ };
23
+ };
24
+
25
+ declare const Flagix: {
26
+ /**
27
+ * Initializes the Flagix SDK, fetches all flags, and sets up an SSE connection.
28
+ */
29
+ initialize(options: FlagixClientOptions): Promise<void>;
30
+ /**
31
+ * Evaluates a flag based on the local cache and current context.
32
+ * @param flagKey The key of the flag to evaluate.
33
+ * @param contextOverrides Optional, temporary context overrides.
34
+ */
35
+ evaluate<T extends VariationValue>(flagKey: string, contextOverrides?: EvaluationContext): T | null;
36
+ /**
37
+ * Records a custom event for analytics.
38
+ * @param eventName The name of the event.
39
+ * @param properties Optional custom metadata.
40
+ * @param contextOverrides Optional context.
41
+ */
42
+ track(eventName: string, properties?: Record<string, unknown>, contextOverrides?: EvaluationContext): void;
43
+ /**
44
+ * Sets or updates the global evaluation context.
45
+ * @param newContext New context attributes to merge or replace.
46
+ */
47
+ setContext(newContext: EvaluationContext): void;
48
+ /**
49
+ * Closes the SSE connection and cleans up resources.
50
+ */
51
+ close(): void;
52
+ /**
53
+ * checks initialization status
54
+ */
55
+ isInitialized(): boolean;
56
+ /**
57
+ * Subscribes a listener to updates for any flag.
58
+ * @param listener The callback function (receives the updated flagKey).
59
+ */
60
+ onFlagUpdate(listener: (flagKey: string) => void): void;
61
+ /**
62
+ * Unsubscribes a listener from flag updates.
63
+ * @param listener The callback function to remove.
64
+ */
65
+ offFlagUpdate(listener: (flagKey: string) => void): void;
66
+ };
67
+
68
+ export { Flagix, type FlagixClientOptions };