@@ -249,12 +249,6 @@ export type InitOptions = {
249249 */
250250 offline ?: boolean ;
251251
252- /**
253- * An object containing pre-fetched flags to be used instead of fetching them from the server.
254- * This is intended to be used with the Node-SDK getFlagsForBootstrap method.
255- */
256- bootstrappedFlags ?: FetchedFlags ;
257-
258252 /**
259253 * Flag keys for which `isEnabled` should fallback to true
260254 * if SDK fails to fetch flags from Reflag servers. If a record
@@ -316,6 +310,24 @@ export type InitOptions = {
316310 toolbar ?: ToolbarOptions ;
317311} ;
318312
313+ /**
314+ * Init options for bootstrapped flags.
315+ */
316+ export type InitOptionsBootstrapped = Omit <
317+ InitOptions ,
318+ | "fallbackFlags"
319+ | "timeoutMs"
320+ | "staleWhileRevalidate"
321+ | "staleTimeMs"
322+ | "expireTimeMs"
323+ > & {
324+ bootstrappedFlags : FetchedFlags ;
325+ } ;
326+
327+ function isBootstrapped ( opts : InitOptions ) : opts is InitOptionsBootstrapped {
328+ return "bootstrappedFlags" in opts ;
329+ }
330+
319331const defaultConfig : Config = {
320332 apiBaseUrl : API_BASE_URL ,
321333 appBaseUrl : APP_BASE_URL ,
@@ -427,7 +439,8 @@ export class ReflagClient {
427439 sseBaseUrl : opts ?. sseBaseUrl ?? defaultConfig . sseBaseUrl ,
428440 enableTracking : opts ?. enableTracking ?? defaultConfig . enableTracking ,
429441 offline : opts ?. offline ?? defaultConfig . offline ,
430- bootstrapped : ! ! opts . bootstrappedFlags ,
442+ bootstrapped :
443+ opts && "bootstrappedFlags" in opts && ! ! opts . bootstrappedFlags ,
431444 initialized : false ,
432445 } ;
433446
@@ -451,14 +464,18 @@ export class ReflagClient {
451464 other : this . context . otherContext ,
452465 } ,
453466 this . logger ,
454- {
455- bootstrappedFlags : opts . bootstrappedFlags ,
456- expireTimeMs : opts . expireTimeMs ,
457- staleTimeMs : opts . staleTimeMs ,
458- fallbackFlags : opts . fallbackFlags ,
459- timeoutMs : opts . timeoutMs ,
460- offline : this . config . offline ,
461- } ,
467+ isBootstrapped ( opts )
468+ ? {
469+ bootstrappedFlags : opts . bootstrappedFlags ,
470+ offline : this . config . offline ,
471+ }
472+ : {
473+ expireTimeMs : opts . expireTimeMs ,
474+ staleTimeMs : opts . staleTimeMs ,
475+ timeoutMs : opts . timeoutMs ,
476+ fallbackFlags : opts . fallbackFlags ,
477+ offline : this . config . offline ,
478+ } ,
462479 ) ;
463480
464481 if (
0 commit comments