@launchdarkly/js-client-sdk-common 1.20.0 → 1.21.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 (114) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/api/datasource/DataSourceEntry.d.ts +45 -0
  3. package/dist/cjs/api/datasource/DataSourceEntry.d.ts.map +1 -0
  4. package/dist/cjs/api/datasource/FDv2ConnectionMode.d.ts +30 -0
  5. package/dist/cjs/api/datasource/FDv2ConnectionMode.d.ts.map +1 -0
  6. package/dist/cjs/api/datasource/LDClientDataSystemOptions.d.ts +75 -0
  7. package/dist/cjs/api/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
  8. package/dist/cjs/api/datasource/ModeDefinition.d.ts +21 -0
  9. package/dist/cjs/api/datasource/ModeDefinition.d.ts.map +1 -0
  10. package/dist/cjs/api/datasource/index.d.ts +5 -0
  11. package/dist/cjs/api/datasource/index.d.ts.map +1 -0
  12. package/dist/cjs/api/index.d.ts +1 -0
  13. package/dist/cjs/api/index.d.ts.map +1 -1
  14. package/dist/cjs/configuration/Configuration.d.ts +0 -1
  15. package/dist/cjs/configuration/Configuration.d.ts.map +1 -1
  16. package/dist/cjs/configuration/validateOptions.d.ts +95 -0
  17. package/dist/cjs/configuration/validateOptions.d.ts.map +1 -0
  18. package/dist/cjs/datasource/ConnectionModeConfig.d.ts +19 -0
  19. package/dist/cjs/datasource/ConnectionModeConfig.d.ts.map +1 -0
  20. package/dist/cjs/datasource/LDClientDataSystemOptions.d.ts +20 -0
  21. package/dist/cjs/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
  22. package/dist/cjs/datasource/StateDebounceManager.d.ts +92 -0
  23. package/dist/cjs/datasource/StateDebounceManager.d.ts.map +1 -0
  24. package/dist/cjs/datasource/fdv2/AsyncQueue.d.ts +2 -0
  25. package/dist/cjs/datasource/fdv2/AsyncQueue.d.ts.map +1 -0
  26. package/dist/cjs/datasource/fdv2/Conditions.d.ts +73 -0
  27. package/dist/cjs/datasource/fdv2/Conditions.d.ts.map +1 -0
  28. package/dist/cjs/datasource/fdv2/FDv2DataSource.d.ts +52 -0
  29. package/dist/cjs/datasource/fdv2/FDv2DataSource.d.ts.map +1 -0
  30. package/dist/cjs/datasource/fdv2/FDv2Requestor.d.ts +45 -0
  31. package/dist/cjs/datasource/fdv2/FDv2Requestor.d.ts.map +1 -0
  32. package/dist/cjs/datasource/fdv2/FDv2SourceResult.d.ts +82 -0
  33. package/dist/cjs/datasource/fdv2/FDv2SourceResult.d.ts.map +1 -0
  34. package/dist/cjs/datasource/fdv2/Initializer.d.ts +40 -0
  35. package/dist/cjs/datasource/fdv2/Initializer.d.ts.map +1 -0
  36. package/dist/cjs/datasource/fdv2/PollingBase.d.ts +2 -0
  37. package/dist/cjs/datasource/fdv2/PollingBase.d.ts.map +1 -0
  38. package/dist/cjs/datasource/fdv2/PollingInitializer.d.ts +2 -0
  39. package/dist/cjs/datasource/fdv2/PollingInitializer.d.ts.map +1 -0
  40. package/dist/cjs/datasource/fdv2/PollingSynchronizer.d.ts +2 -0
  41. package/dist/cjs/datasource/fdv2/PollingSynchronizer.d.ts.map +1 -0
  42. package/dist/cjs/datasource/fdv2/SourceManager.d.ts +88 -0
  43. package/dist/cjs/datasource/fdv2/SourceManager.d.ts.map +1 -0
  44. package/dist/cjs/datasource/fdv2/StreamingFDv2Base.d.ts +11 -0
  45. package/dist/cjs/datasource/fdv2/StreamingFDv2Base.d.ts.map +1 -0
  46. package/dist/cjs/datasource/fdv2/StreamingInitializerFDv2.d.ts +2 -0
  47. package/dist/cjs/datasource/fdv2/StreamingInitializerFDv2.d.ts.map +1 -0
  48. package/dist/cjs/datasource/fdv2/StreamingSynchronizerFDv2.d.ts +2 -0
  49. package/dist/cjs/datasource/fdv2/StreamingSynchronizerFDv2.d.ts.map +1 -0
  50. package/dist/cjs/datasource/fdv2/Synchronizer.d.ts +49 -0
  51. package/dist/cjs/datasource/fdv2/Synchronizer.d.ts.map +1 -0
  52. package/dist/cjs/datasource/fdv2/index.d.ts +16 -0
  53. package/dist/cjs/datasource/fdv2/index.d.ts.map +1 -0
  54. package/dist/cjs/index.cjs +75 -40
  55. package/dist/cjs/index.cjs.map +1 -1
  56. package/dist/cjs/index.d.ts +3 -0
  57. package/dist/cjs/index.d.ts.map +1 -1
  58. package/dist/esm/api/datasource/DataSourceEntry.d.ts +45 -0
  59. package/dist/esm/api/datasource/DataSourceEntry.d.ts.map +1 -0
  60. package/dist/esm/api/datasource/FDv2ConnectionMode.d.ts +30 -0
  61. package/dist/esm/api/datasource/FDv2ConnectionMode.d.ts.map +1 -0
  62. package/dist/esm/api/datasource/LDClientDataSystemOptions.d.ts +75 -0
  63. package/dist/esm/api/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
  64. package/dist/esm/api/datasource/ModeDefinition.d.ts +21 -0
  65. package/dist/esm/api/datasource/ModeDefinition.d.ts.map +1 -0
  66. package/dist/esm/api/datasource/index.d.ts +5 -0
  67. package/dist/esm/api/datasource/index.d.ts.map +1 -0
  68. package/dist/esm/api/index.d.ts +1 -0
  69. package/dist/esm/api/index.d.ts.map +1 -1
  70. package/dist/esm/configuration/Configuration.d.ts +0 -1
  71. package/dist/esm/configuration/Configuration.d.ts.map +1 -1
  72. package/dist/esm/configuration/validateOptions.d.ts +95 -0
  73. package/dist/esm/configuration/validateOptions.d.ts.map +1 -0
  74. package/dist/esm/datasource/ConnectionModeConfig.d.ts +19 -0
  75. package/dist/esm/datasource/ConnectionModeConfig.d.ts.map +1 -0
  76. package/dist/esm/datasource/LDClientDataSystemOptions.d.ts +20 -0
  77. package/dist/esm/datasource/LDClientDataSystemOptions.d.ts.map +1 -0
  78. package/dist/esm/datasource/StateDebounceManager.d.ts +92 -0
  79. package/dist/esm/datasource/StateDebounceManager.d.ts.map +1 -0
  80. package/dist/esm/datasource/fdv2/AsyncQueue.d.ts +2 -0
  81. package/dist/esm/datasource/fdv2/AsyncQueue.d.ts.map +1 -0
  82. package/dist/esm/datasource/fdv2/Conditions.d.ts +73 -0
  83. package/dist/esm/datasource/fdv2/Conditions.d.ts.map +1 -0
  84. package/dist/esm/datasource/fdv2/FDv2DataSource.d.ts +52 -0
  85. package/dist/esm/datasource/fdv2/FDv2DataSource.d.ts.map +1 -0
  86. package/dist/esm/datasource/fdv2/FDv2Requestor.d.ts +45 -0
  87. package/dist/esm/datasource/fdv2/FDv2Requestor.d.ts.map +1 -0
  88. package/dist/esm/datasource/fdv2/FDv2SourceResult.d.ts +82 -0
  89. package/dist/esm/datasource/fdv2/FDv2SourceResult.d.ts.map +1 -0
  90. package/dist/esm/datasource/fdv2/Initializer.d.ts +40 -0
  91. package/dist/esm/datasource/fdv2/Initializer.d.ts.map +1 -0
  92. package/dist/esm/datasource/fdv2/PollingBase.d.ts +2 -0
  93. package/dist/esm/datasource/fdv2/PollingBase.d.ts.map +1 -0
  94. package/dist/esm/datasource/fdv2/PollingInitializer.d.ts +2 -0
  95. package/dist/esm/datasource/fdv2/PollingInitializer.d.ts.map +1 -0
  96. package/dist/esm/datasource/fdv2/PollingSynchronizer.d.ts +2 -0
  97. package/dist/esm/datasource/fdv2/PollingSynchronizer.d.ts.map +1 -0
  98. package/dist/esm/datasource/fdv2/SourceManager.d.ts +88 -0
  99. package/dist/esm/datasource/fdv2/SourceManager.d.ts.map +1 -0
  100. package/dist/esm/datasource/fdv2/StreamingFDv2Base.d.ts +11 -0
  101. package/dist/esm/datasource/fdv2/StreamingFDv2Base.d.ts.map +1 -0
  102. package/dist/esm/datasource/fdv2/StreamingInitializerFDv2.d.ts +2 -0
  103. package/dist/esm/datasource/fdv2/StreamingInitializerFDv2.d.ts.map +1 -0
  104. package/dist/esm/datasource/fdv2/StreamingSynchronizerFDv2.d.ts +2 -0
  105. package/dist/esm/datasource/fdv2/StreamingSynchronizerFDv2.d.ts.map +1 -0
  106. package/dist/esm/datasource/fdv2/Synchronizer.d.ts +49 -0
  107. package/dist/esm/datasource/fdv2/Synchronizer.d.ts.map +1 -0
  108. package/dist/esm/datasource/fdv2/index.d.ts +16 -0
  109. package/dist/esm/datasource/fdv2/index.d.ts.map +1 -0
  110. package/dist/esm/index.d.ts +3 -0
  111. package/dist/esm/index.d.ts.map +1 -1
  112. package/dist/esm/index.mjs +76 -42
  113. package/dist/esm/index.mjs.map +1 -1
  114. package/package.json +2 -2
@@ -0,0 +1,88 @@
1
+ import { Initializer } from './Initializer';
2
+ import { Synchronizer } from './Synchronizer';
3
+ /**
4
+ * Factory function that creates an {@link Initializer} instance.
5
+ *
6
+ * @param selectorGetter Returns the current selector (basis) string, or
7
+ * `undefined` if no selector is available.
8
+ */
9
+ export type InitializerFactory = (selectorGetter: () => string | undefined) => Initializer;
10
+ /**
11
+ * Factory function that creates a {@link Synchronizer} instance.
12
+ *
13
+ * @param selectorGetter Returns the current selector (basis) string, or
14
+ * `undefined` if no selector is available.
15
+ */
16
+ export type SynchronizerFactory = (selectorGetter: () => string | undefined) => Synchronizer;
17
+ /**
18
+ * State of a synchronizer slot.
19
+ * - `'available'`: can be selected for use.
20
+ * - `'blocked'`: has been blocked (e.g., terminal error or not yet activated).
21
+ */
22
+ export type SynchronizerSlotState = 'available' | 'blocked';
23
+ /**
24
+ * A slot in the synchronizer list, wrapping a factory with state metadata.
25
+ */
26
+ export interface SynchronizerSlot {
27
+ readonly factory: SynchronizerFactory;
28
+ readonly isFDv1Fallback: boolean;
29
+ state: SynchronizerSlotState;
30
+ }
31
+ /**
32
+ * Creates a {@link SynchronizerSlot}.
33
+ *
34
+ * @param factory The synchronizer factory function.
35
+ * @param options Optional configuration.
36
+ * @param options.isFDv1Fallback Whether this slot is the FDv1 fallback adapter.
37
+ * FDv1 slots start `'blocked'` by default.
38
+ * @param options.initialState Override the initial state (defaults to
39
+ * `'blocked'` for FDv1 slots, `'available'` otherwise).
40
+ */
41
+ export declare function createSynchronizerSlot(factory: SynchronizerFactory, options?: {
42
+ isFDv1Fallback?: boolean;
43
+ initialState?: SynchronizerSlotState;
44
+ }): SynchronizerSlot;
45
+ /**
46
+ * Manages the state of initializers and synchronizers, tracks which source
47
+ * is active, and handles source transitions.
48
+ */
49
+ export interface SourceManager {
50
+ /**
51
+ * Get the next initializer and set it as the active source.
52
+ * Closes the previous active source. Returns `undefined` when all
53
+ * initializers are exhausted.
54
+ */
55
+ getNextInitializerAndSetActive(): Initializer | undefined;
56
+ /**
57
+ * Get the next available (non-blocked) synchronizer and set it as the
58
+ * active source. Closes the previous active source. Returns `undefined`
59
+ * when all available synchronizers have been visited.
60
+ */
61
+ getNextAvailableSynchronizerAndSetActive(): Synchronizer | undefined;
62
+ /** Mark the current synchronizer as blocked (e.g., after terminal error). */
63
+ blockCurrentSynchronizer(): void;
64
+ /** Reset the synchronizer index to -1 so the next call starts from the beginning. */
65
+ resetSourceIndex(): void;
66
+ /** Block all non-FDv1 synchronizers and unblock FDv1 synchronizers. */
67
+ fdv1Fallback(): void;
68
+ /** True if the current synchronizer is the first available (primary). */
69
+ isPrimeSynchronizer(): boolean;
70
+ /** Count of synchronizers in `'available'` state. */
71
+ getAvailableSynchronizerCount(): number;
72
+ /** True if any synchronizer slot is marked as an FDv1 fallback. */
73
+ hasFDv1Fallback(): boolean;
74
+ /** Close the active source and mark the manager as shut down. */
75
+ close(): void;
76
+ /** True if {@link close} has been called. */
77
+ readonly isShutdown: boolean;
78
+ }
79
+ /**
80
+ * Creates a {@link SourceManager} that coordinates initializer and
81
+ * synchronizer lifecycle.
82
+ *
83
+ * @param initializerFactories Ordered list of initializer factories.
84
+ * @param synchronizerSlots Ordered list of synchronizer slots with state.
85
+ * @param selectorGetter Closure that returns the current selector string.
86
+ */
87
+ export declare function createSourceManager(initializerFactories: InitializerFactory[], synchronizerSlots: SynchronizerSlot[], selectorGetter: () => string | undefined): SourceManager;
88
+ //# sourceMappingURL=SourceManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceManager.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/SourceManager.ts"],"names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AI,IAAI,CAAC;IAEd,6CAA6C;IAC7C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,oBAAoB,EAAE,kBAAkB,EAAE,EAC1C,iBAAiB,EAAE,gBAAgB,EAAE,EACrC,cAAc,EAAE,MAAM,MAAM,GAAG,SAAS,GACvC,aAAa,CAsGf"}
@@ -0,0 +1,11 @@
1
+ import { FDv2SourceResult } from './FDv2SourceResult';
2
+ /**
3
+ * Handler invoked when a legacy `"ping"` event is received on the stream.
4
+ * The implementation should perform an FDv2 poll request (e.g. via
5
+ * {@link poll} from PollingBase) and return the processed result.
6
+ */
7
+ export interface PingHandler {
8
+ /** Perform a poll and return the processed result. */
9
+ handlePing(): Promise<FDv2SourceResult>;
10
+ }
11
+ //# sourceMappingURL=StreamingFDv2Base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingFDv2Base.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/StreamingFDv2Base.ts"],"names":[],"mappings":"AAeA,OAAO,EAML,gBAAgB,EAKjB,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StreamingInitializerFDv2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingInitializerFDv2.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/StreamingInitializerFDv2.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StreamingSynchronizerFDv2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingSynchronizerFDv2.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/StreamingSynchronizerFDv2.ts"],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ import { FDv2SourceResult } from './FDv2SourceResult';
2
+ /**
3
+ * Interface for an asynchronous data source synchronizer.
4
+ *
5
+ * A synchronizer runs continuously and produces a stream of results via
6
+ * successive calls to `next()`. When it experiences a temporary failure,
7
+ * it emits an INTERRUPTED result while attempting to recover. When it
8
+ * receives data, it emits a CHANGESET result. When shut down gracefully,
9
+ * it emits a SHUTDOWN result.
10
+ *
11
+ * `next()` is intended to be driven by a single caller, with one outstanding
12
+ * call at a time. Once SHUTDOWN or TERMINAL_ERROR has been produced, no
13
+ * further calls to `next()` should be made.
14
+ *
15
+ * ```
16
+ * [START]
17
+ * │
18
+ * ▼
19
+ * ┌─────────┐
20
+ * ┌─►│ RUNNING │──┐
21
+ * │ └─────────┘ │
22
+ * │ │ │ │ │ └──► SHUTDOWN ──────► [END]
23
+ * │ │ │ │ └─────► TERMINAL_ERROR ► [END]
24
+ * │ │ │ └────────► GOODBYE ───────┐
25
+ * │ │ └───────────► CHANGESET ─────┤
26
+ * │ └──────────────► INTERRUPTED ───┤
27
+ * └───────────────────────────────────┘
28
+ * ```
29
+ */
30
+ export interface Synchronizer {
31
+ /**
32
+ * Get the next result from the stream.
33
+ *
34
+ * This method is intended to be driven by a single caller, and for there
35
+ * to be a single outstanding call at any given time.
36
+ *
37
+ * Once SHUTDOWN or TERMINAL_ERROR has been produced, no further calls to
38
+ * `next()` should be made.
39
+ *
40
+ * @returns A promise that resolves when the next result is available.
41
+ */
42
+ next(): Promise<FDv2SourceResult>;
43
+ /**
44
+ * Close the synchronizer. The next call to `next()` will resolve with a
45
+ * shutdown result.
46
+ */
47
+ close(): void;
48
+ }
49
+ //# sourceMappingURL=Synchronizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Synchronizer.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/Synchronizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAElC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -0,0 +1,16 @@
1
+ export type { AsyncQueue } from './AsyncQueue';
2
+ export { createAsyncQueue } from './AsyncQueue';
3
+ export type { FDv2PollResponse, FDv2Requestor } from './FDv2Requestor';
4
+ export { makeFDv2Requestor } from './FDv2Requestor';
5
+ export type { ChangeSetResult, FDv2SourceResult, SourceState, StatusResult, } from './FDv2SourceResult';
6
+ export { changeSet, errorInfoFromHttpError, errorInfoFromInvalidData, errorInfoFromNetworkError, errorInfoFromUnknown, goodbye, interrupted, shutdown, terminalError, } from './FDv2SourceResult';
7
+ export type { Initializer } from './Initializer';
8
+ export type { Synchronizer } from './Synchronizer';
9
+ export { poll } from './PollingBase';
10
+ export { createPollingInitializer } from './PollingInitializer';
11
+ export { createPollingSynchronizer } from './PollingSynchronizer';
12
+ export type { PingHandler, StreamingFDv2Base } from './StreamingFDv2Base';
13
+ export { createStreamingBase } from './StreamingFDv2Base';
14
+ export { createStreamingInitializer } from './StreamingInitializerFDv2';
15
+ export { createStreamingSynchronizer } from './StreamingSynchronizerFDv2';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/datasource/fdv2/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,QAAQ,EACR,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC"}
@@ -11,6 +11,7 @@ export type { DataManager, DataManagerFactory, ConnectionParams } from './DataMa
11
11
  export type { FlagManager, LDDebugOverride } from './flag-manager/FlagManager';
12
12
  export { safeRegisterDebugOverridePlugins } from './plugins/safeRegisterDebugOverridePlugins';
13
13
  export type { Configuration } from './configuration/Configuration';
14
+ export { default as validateOptions } from './configuration/validateOptions';
14
15
  export type { LDEmitter };
15
16
  export type { ItemDescriptor } from './flag-manager/ItemDescriptor';
16
17
  export type { Flag } from './types';
@@ -21,4 +22,6 @@ export type { DataSourceEndpoints } from './datasource/Endpoints';
21
22
  export { BaseDataManager } from './DataManager';
22
23
  export { makeRequestor, Requestor };
23
24
  export { DataSourceStatus, DataSourceStatusErrorInfo, LDClientImpl, LDClientInternalOptions, DataSourceState, EventName as LDEmitterEventName, };
25
+ export type { FDv2ConnectionMode, EndpointConfig, CacheDataSourceEntry, PollingDataSourceEntry, StreamingDataSourceEntry, DataSourceEntry, ModeDefinition, LDClientDataSystemOptions, AutomaticModeSwitchingConfig, PlatformDataSystemDefaults, } from './api/datasource';
26
+ export type { ModeTable } from './datasource/ConnectionModeConfig';
24
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,gBAAgB,EAAE,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,yBAAyB,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,cAAc,6BAA6B,CAAC;AAE5C,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAC;AAMxD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,IAAI,EACJ,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,8BAA8B,EAC9B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,SAAS,EACT,eAAe,GAChB,MAAM,OAAO,CAAC;AAEf,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACvF,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EA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F,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { getPollingUri, TypeValidators, createSafeLogger, ServiceEndpoints, ApplicationTags, OptionMessages, NumberWithMinimum, SafeLogger, internal, deepCompact, clone, secondsToMillis, ClientContext, fastDeepEqual, defaultHeaders, Context, LDTimeoutError, AutoEnvAttributes, cancelableTimedPromise, LDClientError, base64UrlEncode, isHttpRecoverable, httpErrorMessage, LDPollingError, DataSourceErrorKind, getStreamingUri, shouldRetry, LDStreamingError } from '@launchdarkly/js-sdk-common';
1
+ import { getPollingUri, isNullish, TypeValidators, OptionMessages, NumberWithMinimum, createSafeLogger, ServiceEndpoints, ApplicationTags, SafeLogger, internal, deepCompact, clone, secondsToMillis, ClientContext, fastDeepEqual, defaultHeaders, Context, LDTimeoutError, AutoEnvAttributes, cancelableTimedPromise, LDClientError, base64UrlEncode, isHttpRecoverable, httpErrorMessage, LDPollingError, DataSourceErrorKind, getStreamingUri, shouldRetry, LDStreamingError } from '@launchdarkly/js-sdk-common';
2
2
  export * from '@launchdarkly/js-sdk-common';
3
3
  import * as jsSdkCommon from '@launchdarkly/js-sdk-common';
4
4
  export { jsSdkCommon as platform };
@@ -204,6 +204,74 @@ function createAsyncTaskQueue(logger) {
204
204
  };
205
205
  }
206
206
 
207
+ function isCompoundValidator(v) {
208
+ return 'validate' in v;
209
+ }
210
+ /**
211
+ * Validates an options object against a map of validators and defaults.
212
+ *
213
+ * If `input` is null, undefined, or not an object the defaults are returned
214
+ * (with a warning for non-nullish non-objects).
215
+ *
216
+ * Supports special validator types created by:
217
+ * - {@link validatorOf}: recursively validates nested objects
218
+ * - {@link arrayOf}: validates arrays with per-item validation
219
+ * - {@link anyOf}: accepts the first matching validator from a list
220
+ * - {@link recordOf}: validates objects with dynamic keys
221
+ */
222
+ function validateOptions(input, validatorMap, defaults, logger, prefix) {
223
+ const result = { ...defaults };
224
+ if (isNullish(input)) {
225
+ return result;
226
+ }
227
+ if (!TypeValidators.Object.is(input)) {
228
+ logger?.warn(OptionMessages.wrongOptionType(prefix ?? 'config', 'object', typeof input));
229
+ return result;
230
+ }
231
+ Object.entries(input).forEach(([key, value]) => {
232
+ const validator = validatorMap[key];
233
+ const name = prefix ? `${prefix}.${key}` : key;
234
+ if (!validator) {
235
+ logger?.warn(OptionMessages.unknownOption(name));
236
+ return;
237
+ }
238
+ if (isNullish(value)) {
239
+ return;
240
+ }
241
+ if (isCompoundValidator(validator)) {
242
+ const validated = validator.validate(value, name, logger, defaults[key]);
243
+ if (validated !== undefined) {
244
+ result[key] = validated.value;
245
+ }
246
+ return;
247
+ }
248
+ if (validator.is(value)) {
249
+ result[key] = value;
250
+ return;
251
+ }
252
+ // Validation failed — apply correction or fall back to default.
253
+ const validatorType = validator.getType();
254
+ if (validatorType === 'boolean') {
255
+ logger?.warn(OptionMessages.wrongOptionTypeBoolean(name, typeof value));
256
+ result[key] = !!value;
257
+ }
258
+ else if (validatorType === 'boolean | undefined | null') {
259
+ logger?.warn(OptionMessages.wrongOptionTypeBoolean(name, typeof value));
260
+ if (typeof value !== 'boolean' && typeof value !== 'undefined' && value !== null) {
261
+ result[key] = !!value;
262
+ }
263
+ }
264
+ else if (validator instanceof NumberWithMinimum && TypeValidators.Number.is(value)) {
265
+ logger?.warn(OptionMessages.optionBelowMinimum(name, value, validator.min));
266
+ result[key] = validator.min;
267
+ }
268
+ else {
269
+ logger?.warn(OptionMessages.wrongOptionType(name, validatorType, typeof value));
270
+ }
271
+ });
272
+ return result;
273
+ }
274
+
207
275
  // eslint-disable-next-line max-classes-per-file
208
276
  const validators = {
209
277
  logger: TypeValidators.Object,
@@ -273,8 +341,12 @@ class ConfigurationImpl {
273
341
  this.hooks = [];
274
342
  this.inspectors = [];
275
343
  this.logger = ensureSafeLogger(pristineOptions.logger);
276
- const errors = this._validateTypesAndNames(pristineOptions);
277
- errors.forEach((e) => this.logger.warn(e));
344
+ const validated = validateOptions(pristineOptions, validators, {}, this.logger);
345
+ Object.entries(validated).forEach(([k, v]) => {
346
+ if (k !== 'logger') {
347
+ this[k] = v;
348
+ }
349
+ });
278
350
  this.serviceEndpoints = new ServiceEndpoints(this.streamUri, this.baseUri, this.eventsUri, internalOptions.analyticsEventPath, internalOptions.diagnosticEventPath, internalOptions.includeAuthorizationHeader, pristineOptions.payloadFilterKey);
279
351
  this.useReport = pristineOptions.useReport ?? false;
280
352
  this.tags = new ApplicationTags({ application: this.applicationInfo, logger: this.logger });
@@ -283,44 +355,6 @@ class ConfigurationImpl {
283
355
  this.credentialType = internalOptions.credentialType;
284
356
  this.getImplementationHooks = internalOptions.getImplementationHooks;
285
357
  }
286
- _validateTypesAndNames(pristineOptions) {
287
- const errors = [];
288
- Object.entries(pristineOptions).forEach(([k, v]) => {
289
- const validator = validators[k];
290
- if (validator) {
291
- if (!validator.is(v)) {
292
- const validatorType = validator.getType();
293
- if (validatorType === 'boolean') {
294
- errors.push(OptionMessages.wrongOptionTypeBoolean(k, typeof v));
295
- this[k] = !!v;
296
- }
297
- else if (validatorType === 'boolean | undefined | null') {
298
- errors.push(OptionMessages.wrongOptionTypeBoolean(k, typeof v));
299
- if (typeof v !== 'boolean' && typeof v !== 'undefined' && v !== null) {
300
- this[k] = !!v;
301
- }
302
- }
303
- else if (validator instanceof NumberWithMinimum && TypeValidators.Number.is(v)) {
304
- const { min } = validator;
305
- errors.push(OptionMessages.optionBelowMinimum(k, v, min));
306
- this[k] = min;
307
- }
308
- else {
309
- errors.push(OptionMessages.wrongOptionType(k, validator.getType(), typeof v));
310
- }
311
- }
312
- else if (k === 'logger') ;
313
- else {
314
- // if an option is explicitly null, coerce to undefined
315
- this[k] = v ?? undefined;
316
- }
317
- }
318
- else {
319
- errors.push(OptionMessages.unknownOption(k));
320
- }
321
- });
322
- return errors;
323
- }
324
358
  }
325
359
 
326
360
  async function digest(hasher, encoding) {
@@ -2524,5 +2558,5 @@ class BaseDataManager {
2524
2558
  }
2525
2559
  }
2526
2560
 
2527
- export { BaseDataManager, DataSourceState, LDClientImpl, browserFdv1Endpoints, fdv2Endpoints, makeRequestor, mobileFdv1Endpoints, readFlagsFromBootstrap, safeRegisterDebugOverridePlugins };
2561
+ export { BaseDataManager, DataSourceState, LDClientImpl, browserFdv1Endpoints, fdv2Endpoints, makeRequestor, mobileFdv1Endpoints, readFlagsFromBootstrap, safeRegisterDebugOverridePlugins, validateOptions };
2528
2562
  //# sourceMappingURL=index.mjs.map