flagmint-js-sdk 1.2.24 → 1.2.25
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.
- package/LICENSE +25 -17
- package/README.md +70 -13
- package/dist/flagmint.cjs.js +8 -8
- package/dist/flagmint.es.js +1454 -1442
- package/dist/flagmint.umd.js +8 -8
- package/dist/sdk/core/client.d.ts +18 -2
- package/dist/sdk/core/helpers/logger.d.ts +4 -0
- package/dist/sdk/core/transports/WebsocketTransport.d.ts +1 -0
- package/package.json +2 -2
|
@@ -2,7 +2,6 @@ import { CacheAdapter, FeatureFlags } from '../core/helpers/types';
|
|
|
2
2
|
import type { Transport } from '../core/transports/Transport';
|
|
3
3
|
import { FlagValue } from '../core/evaluation/types';
|
|
4
4
|
type TransportMode = 'auto' | 'websocket' | 'long-polling';
|
|
5
|
-
type Environment = 'production' | 'staging' | 'development';
|
|
6
5
|
export interface FlagClientOptions<C extends Record<string, any> = Record<string, any>> {
|
|
7
6
|
apiKey: string;
|
|
8
7
|
context?: C;
|
|
@@ -10,6 +9,19 @@ export interface FlagClientOptions<C extends Record<string, any> = Record<string
|
|
|
10
9
|
persistContext?: boolean;
|
|
11
10
|
transport?: Transport<C, any>;
|
|
12
11
|
transportMode?: TransportMode;
|
|
12
|
+
/**
|
|
13
|
+
* Called when a non-fatal but noteworthy error occurs during or after initialization.
|
|
14
|
+
* The client always resolves ready() regardless — use this to show a degraded/fallback UI.
|
|
15
|
+
*
|
|
16
|
+
* Common cases:
|
|
17
|
+
* - Auth failure (err.code === 'ERR_AUTH'): API key invalid; flags will be empty; getFlag() returns fallback values.
|
|
18
|
+
* - Rate limited (err.code === 'ERR_RATE_LIMITED'): free-tier call limit exceeded; cached flags are served if available.
|
|
19
|
+
* Check (err as any).resetTime for the reset timestamp string supplied by the server, if present.
|
|
20
|
+
* - Degraded mode: transport failed but cached flags are available and being served.
|
|
21
|
+
* - Context update error: re-evaluation after updateContext() failed; previous flags retained.
|
|
22
|
+
*
|
|
23
|
+
* Note: ready() will never throw. All errors are surfaced exclusively through this callback.
|
|
24
|
+
*/
|
|
13
25
|
onError?: (error: Error) => void;
|
|
14
26
|
previewMode?: boolean;
|
|
15
27
|
rawFlags?: Record<string, FlagValue>;
|
|
@@ -17,7 +29,9 @@ export interface FlagClientOptions<C extends Record<string, any> = Record<string
|
|
|
17
29
|
cacheAdapter?: CacheAdapter<C>;
|
|
18
30
|
restEndpoint?: string;
|
|
19
31
|
wsEndpoint?: string;
|
|
20
|
-
|
|
32
|
+
debugLog?: boolean;
|
|
33
|
+
env?: string;
|
|
34
|
+
enableFlagmint: boolean;
|
|
21
35
|
}
|
|
22
36
|
type FlagUpdateCallback<T> = (flags: FeatureFlags<T>) => void;
|
|
23
37
|
export declare class FlagClient<T = unknown, C extends Record<string, any> = Record<string, any>> {
|
|
@@ -38,6 +52,8 @@ export declare class FlagClient<T = unknown, C extends Record<string, any> = Rec
|
|
|
38
52
|
private previewMode;
|
|
39
53
|
private rawFlags;
|
|
40
54
|
private cacheAdapter;
|
|
55
|
+
private env?;
|
|
56
|
+
private enableFlagmint?;
|
|
41
57
|
private deferInitialization;
|
|
42
58
|
private initializationOptions?;
|
|
43
59
|
private isInitialized;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Environment-aware logger that respects production restrictions
|
|
3
3
|
*/
|
|
4
4
|
export declare const logger: {
|
|
5
|
+
canDebugLog: boolean;
|
|
6
|
+
setup: (options: {
|
|
7
|
+
debugLog?: boolean;
|
|
8
|
+
}) => void;
|
|
5
9
|
log: (message: string, ...args: any[]) => void;
|
|
6
10
|
error: (message: string, ...args: any[]) => void;
|
|
7
11
|
warn: (message: string, ...args: any[]) => void;
|
|
@@ -12,6 +12,7 @@ export declare class WebSocketTransport<C, T> implements Transport<C, T> {
|
|
|
12
12
|
private initialFlagsReceived;
|
|
13
13
|
private initialFlagsPromise;
|
|
14
14
|
private initialFlagsResolve;
|
|
15
|
+
private initialFlagsReject;
|
|
15
16
|
private onFlagsUpdatedCallback?;
|
|
16
17
|
private onConnectionStateCallback?;
|
|
17
18
|
private retries;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagmint-js-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.25",
|
|
4
4
|
"description": "Framework-agnostic JavaScript SDK for managing feature flags in Flagmint applications.",
|
|
5
5
|
"author": "Flagmint Team",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "BSD 3-Clause",
|
|
7
7
|
"main": "dist/flagmint.cjs.js",
|
|
8
8
|
"module": "dist/flagmint.es.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|