@splitsoftware/splitio-commons 2.10.2-rc.6 → 2.10.2-rc.7
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/CHANGES.txt +1 -1
- package/cjs/readiness/readinessManager.js +2 -1
- package/cjs/readiness/sdkReadinessManager.js +3 -3
- package/esm/readiness/readinessManager.js +2 -1
- package/esm/readiness/sdkReadinessManager.js +3 -3
- package/package.json +1 -1
- package/src/readiness/readinessManager.ts +2 -1
- package/src/readiness/sdkReadinessManager.ts +5 -5
- package/src/readiness/types.ts +2 -12
- package/types/splitio.d.ts +19 -22
package/CHANGES.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
2.11.0 (January
|
|
1
|
+
2.11.0 (January 26, 2026)
|
|
2
2
|
- Added metadata to SDK_UPDATE events to indicate the type of update (FLAGS_UPDATE or SEGMENTS_UPDATE) and the names of updated flags or segments.
|
|
3
3
|
- Added metadata to SDK_READY and SDK_READY_FROM_CACHE events, including `initialCacheLoad` (boolean: `true` for fresh install/first app launch, `false` for warm cache/second app launch) and `lastUpdateTimestamp` (milliseconds since epoch).
|
|
4
4
|
|
|
@@ -154,7 +154,8 @@ function readinessManagerFactory(EventEmitter, settings, splits, isShared) {
|
|
|
154
154
|
hasTimedout: function () { return hasTimedout; },
|
|
155
155
|
isDestroyed: function () { return isDestroyed; },
|
|
156
156
|
isOperational: function () { return (isReady || isReadyFromCache) && !isDestroyed; },
|
|
157
|
-
lastUpdate: function () { return lastUpdate; }
|
|
157
|
+
lastUpdate: function () { return lastUpdate; },
|
|
158
|
+
metadataReady: function () { return metadataReady; }
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
161
|
exports.readinessManagerFactory = readinessManagerFactory;
|
|
@@ -106,7 +106,7 @@ function sdkReadinessManagerFactory(EventEmitter, settings, readinessManager) {
|
|
|
106
106
|
whenReady: function () {
|
|
107
107
|
return new Promise(function (resolve, reject) {
|
|
108
108
|
if (readinessManager.isReady()) {
|
|
109
|
-
resolve();
|
|
109
|
+
resolve(readinessManager.metadataReady());
|
|
110
110
|
}
|
|
111
111
|
else if (readinessManager.hasTimedout()) {
|
|
112
112
|
reject(TIMEOUT_ERROR);
|
|
@@ -120,13 +120,13 @@ function sdkReadinessManagerFactory(EventEmitter, settings, readinessManager) {
|
|
|
120
120
|
whenReadyFromCache: function () {
|
|
121
121
|
return new Promise(function (resolve, reject) {
|
|
122
122
|
if (readinessManager.isReadyFromCache()) {
|
|
123
|
-
resolve(readinessManager.
|
|
123
|
+
resolve(readinessManager.metadataReady());
|
|
124
124
|
}
|
|
125
125
|
else if (readinessManager.hasTimedout()) {
|
|
126
126
|
reject(TIMEOUT_ERROR);
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
|
-
readinessManager.gate.once(constants_1.SDK_READY_FROM_CACHE,
|
|
129
|
+
readinessManager.gate.once(constants_1.SDK_READY_FROM_CACHE, resolve);
|
|
130
130
|
readinessManager.gate.once(constants_1.SDK_READY_TIMED_OUT, function () { return reject(TIMEOUT_ERROR); });
|
|
131
131
|
}
|
|
132
132
|
});
|
|
@@ -151,6 +151,7 @@ export function readinessManagerFactory(EventEmitter, settings, splits, isShared
|
|
|
151
151
|
hasTimedout: function () { return hasTimedout; },
|
|
152
152
|
isDestroyed: function () { return isDestroyed; },
|
|
153
153
|
isOperational: function () { return (isReady || isReadyFromCache) && !isDestroyed; },
|
|
154
|
-
lastUpdate: function () { return lastUpdate; }
|
|
154
|
+
lastUpdate: function () { return lastUpdate; },
|
|
155
|
+
metadataReady: function () { return metadataReady; }
|
|
155
156
|
};
|
|
156
157
|
}
|
|
@@ -103,7 +103,7 @@ export function sdkReadinessManagerFactory(EventEmitter, settings, readinessMana
|
|
|
103
103
|
whenReady: function () {
|
|
104
104
|
return new Promise(function (resolve, reject) {
|
|
105
105
|
if (readinessManager.isReady()) {
|
|
106
|
-
resolve();
|
|
106
|
+
resolve(readinessManager.metadataReady());
|
|
107
107
|
}
|
|
108
108
|
else if (readinessManager.hasTimedout()) {
|
|
109
109
|
reject(TIMEOUT_ERROR);
|
|
@@ -117,13 +117,13 @@ export function sdkReadinessManagerFactory(EventEmitter, settings, readinessMana
|
|
|
117
117
|
whenReadyFromCache: function () {
|
|
118
118
|
return new Promise(function (resolve, reject) {
|
|
119
119
|
if (readinessManager.isReadyFromCache()) {
|
|
120
|
-
resolve(readinessManager.
|
|
120
|
+
resolve(readinessManager.metadataReady());
|
|
121
121
|
}
|
|
122
122
|
else if (readinessManager.hasTimedout()) {
|
|
123
123
|
reject(TIMEOUT_ERROR);
|
|
124
124
|
}
|
|
125
125
|
else {
|
|
126
|
-
readinessManager.gate.once(SDK_READY_FROM_CACHE,
|
|
126
|
+
readinessManager.gate.once(SDK_READY_FROM_CACHE, resolve);
|
|
127
127
|
readinessManager.gate.once(SDK_READY_TIMED_OUT, function () { return reject(TIMEOUT_ERROR); });
|
|
128
128
|
}
|
|
129
129
|
});
|
package/package.json
CHANGED
|
@@ -172,7 +172,8 @@ export function readinessManagerFactory(
|
|
|
172
172
|
hasTimedout() { return hasTimedout; },
|
|
173
173
|
isDestroyed() { return isDestroyed; },
|
|
174
174
|
isOperational() { return (isReady || isReadyFromCache) && !isDestroyed; },
|
|
175
|
-
lastUpdate() { return lastUpdate; }
|
|
175
|
+
lastUpdate() { return lastUpdate; },
|
|
176
|
+
metadataReady() { return metadataReady; }
|
|
176
177
|
};
|
|
177
178
|
|
|
178
179
|
}
|
|
@@ -120,9 +120,9 @@ export function sdkReadinessManagerFactory(
|
|
|
120
120
|
},
|
|
121
121
|
|
|
122
122
|
whenReady() {
|
|
123
|
-
return new Promise<
|
|
123
|
+
return new Promise<SplitIO.SdkReadyMetadata>((resolve, reject) => {
|
|
124
124
|
if (readinessManager.isReady()) {
|
|
125
|
-
resolve();
|
|
125
|
+
resolve(readinessManager.metadataReady());
|
|
126
126
|
} else if (readinessManager.hasTimedout()) {
|
|
127
127
|
reject(TIMEOUT_ERROR);
|
|
128
128
|
} else {
|
|
@@ -133,13 +133,13 @@ export function sdkReadinessManagerFactory(
|
|
|
133
133
|
},
|
|
134
134
|
|
|
135
135
|
whenReadyFromCache() {
|
|
136
|
-
return new Promise<
|
|
136
|
+
return new Promise<SplitIO.SdkReadyMetadata>((resolve, reject) => {
|
|
137
137
|
if (readinessManager.isReadyFromCache()) {
|
|
138
|
-
resolve(readinessManager.
|
|
138
|
+
resolve(readinessManager.metadataReady());
|
|
139
139
|
} else if (readinessManager.hasTimedout()) {
|
|
140
140
|
reject(TIMEOUT_ERROR);
|
|
141
141
|
} else {
|
|
142
|
-
readinessManager.gate.once(SDK_READY_FROM_CACHE,
|
|
142
|
+
readinessManager.gate.once(SDK_READY_FROM_CACHE, resolve);
|
|
143
143
|
readinessManager.gate.once(SDK_READY_TIMED_OUT, () => reject(TIMEOUT_ERROR));
|
|
144
144
|
}
|
|
145
145
|
});
|
package/src/readiness/types.ts
CHANGED
|
@@ -12,19 +12,8 @@ export type IReadinessEvent = SDK_READY_TIMED_OUT | SDK_READY | SDK_READY_FROM_C
|
|
|
12
12
|
|
|
13
13
|
export interface IReadinessEventEmitter extends SplitIO.IEventEmitter {
|
|
14
14
|
emit(event: IReadinessEvent, ...args: any[]): boolean
|
|
15
|
-
on(event: SDK_READY, listener: (metadata: SplitIO.SdkReadyMetadata) => void): this;
|
|
16
|
-
on(event: SDK_READY_FROM_CACHE, listener: (metadata: SplitIO.SdkReadyMetadata) => void): this;
|
|
17
|
-
on(event: SDK_UPDATE, listener: (metadata: SplitIO.SdkUpdateMetadata) => void): this;
|
|
18
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
19
|
-
once(event: SDK_READY, listener: (metadata: SplitIO.SdkReadyMetadata) => void): this;
|
|
20
|
-
once(event: SDK_READY_FROM_CACHE, listener: (metadata: SplitIO.SdkReadyMetadata) => void): this;
|
|
21
|
-
once(event: SDK_UPDATE, listener: (metadata: SplitIO.SdkUpdateMetadata) => void): this;
|
|
22
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
23
|
-
addListener(event: SDK_READY, listener: (metadata: SplitIO.SdkReadyMetadata) => void): this;
|
|
24
|
-
addListener(event: SDK_READY_FROM_CACHE, listener: (metadata: SplitIO.SdkReadyMetadata) => void): this;
|
|
25
|
-
addListener(event: SDK_UPDATE, listener: (metadata: SplitIO.SdkUpdateMetadata) => void): this;
|
|
26
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
27
15
|
}
|
|
16
|
+
|
|
28
17
|
/** Splits data emitter */
|
|
29
18
|
|
|
30
19
|
type SDK_SPLITS_ARRIVED = 'state::splits-arrived'
|
|
@@ -71,6 +60,7 @@ export interface IReadinessManager {
|
|
|
71
60
|
isDestroyed(): boolean,
|
|
72
61
|
isOperational(): boolean,
|
|
73
62
|
lastUpdate(): number,
|
|
63
|
+
metadataReady(): SplitIO.SdkReadyMetadata,
|
|
74
64
|
|
|
75
65
|
timeout(): void,
|
|
76
66
|
setDestroyed(): void,
|
package/types/splitio.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ interface ISharedSettings {
|
|
|
83
83
|
* });
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
|
-
getHeaderOverrides?: (context: { headers: Record<string, string
|
|
86
|
+
getHeaderOverrides?: (context: { headers: Record<string, string>; }) => Record<string, string>;
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
@@ -499,21 +499,17 @@ declare namespace SplitIO {
|
|
|
499
499
|
/**
|
|
500
500
|
* The type of update event.
|
|
501
501
|
*/
|
|
502
|
-
type:
|
|
502
|
+
type: SdkUpdateMetadataType;
|
|
503
503
|
/**
|
|
504
504
|
* The names of the flags or segments that were updated.
|
|
505
505
|
*/
|
|
506
|
-
names: string[]
|
|
506
|
+
names: string[];
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
/**
|
|
510
|
-
* Metadata
|
|
511
|
-
* Use the string literals directly: 'FLAGS_UPDATE' or 'SEGMENTS_UPDATE'
|
|
510
|
+
* Metadata type for SDK update events.
|
|
512
511
|
*/
|
|
513
|
-
type
|
|
514
|
-
FLAGS_UPDATE: 'FLAGS_UPDATE';
|
|
515
|
-
SEGMENTS_UPDATE: 'SEGMENTS_UPDATE';
|
|
516
|
-
};
|
|
512
|
+
type SdkUpdateMetadataType = 'FLAGS_UPDATE' | 'SEGMENTS_UPDATE';
|
|
517
513
|
|
|
518
514
|
/**
|
|
519
515
|
* Metadata for the ready events emitted when the SDK is ready to evaluate feature flags.
|
|
@@ -526,11 +522,11 @@ declare namespace SplitIO {
|
|
|
526
522
|
* - `true` when SDK_READY_FROM_CACHE is emitted because SDK became ready without cache
|
|
527
523
|
* - `true` when SDK_READY is emitted and the SDK was not ready from cache
|
|
528
524
|
*/
|
|
529
|
-
initialCacheLoad: boolean
|
|
525
|
+
initialCacheLoad: boolean;
|
|
530
526
|
/**
|
|
531
527
|
* Timestamp in milliseconds since epoch when the cache was last updated. Undefined if `initialCacheLoad` is `true`.
|
|
532
528
|
*/
|
|
533
|
-
lastUpdateTimestamp?: number
|
|
529
|
+
lastUpdateTimestamp?: number;
|
|
534
530
|
}
|
|
535
531
|
|
|
536
532
|
/**
|
|
@@ -662,7 +658,7 @@ declare namespace SplitIO {
|
|
|
662
658
|
enabled: boolean;
|
|
663
659
|
flagSpecVersion: string;
|
|
664
660
|
requestOptions?: {
|
|
665
|
-
getHeaderOverrides?: (context: { headers: Record<string, string
|
|
661
|
+
getHeaderOverrides?: (context: { headers: Record<string, string>; }) => Record<string, string>;
|
|
666
662
|
};
|
|
667
663
|
};
|
|
668
664
|
readonly runtime: {
|
|
@@ -835,18 +831,19 @@ declare namespace SplitIO {
|
|
|
835
831
|
* As it's meant to provide similar flexibility than event listeners, given that the SDK might be ready after a timeout event, the `whenReady` method will return a resolved promise once the SDK is ready.
|
|
836
832
|
* You must handle the promise rejection to avoid an unhandled promise rejection error, or set the `startup.readyTimeout` configuration option to 0 to avoid the timeout and thus the rejection.
|
|
837
833
|
*
|
|
838
|
-
* @returns A promise that resolves once the SDK_READY event is emitted or rejects if the SDK has timedout.
|
|
834
|
+
* @returns A promise that resolves once the SDK_READY event is emitted or rejects if the SDK has timedout. The promise resolves with a metadata object that contains the `initialCacheLoad` property,
|
|
835
|
+
* which indicates whether the SDK_READY event was emitted together with the SDK_READY_FROM_CACHE event (i.e., fresh install/first app launch) or not (warm cache/subsequent app launch).
|
|
839
836
|
*/
|
|
840
|
-
whenReady(): Promise<
|
|
837
|
+
whenReady(): Promise<SdkReadyMetadata>;
|
|
841
838
|
/**
|
|
842
839
|
* Returns a promise that resolves when the SDK is ready for evaluations using cached data, which might not yet be synchronized with the backend (`SDK_READY_FROM_CACHE` event emitted), or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
|
|
843
840
|
* As it's meant to provide similar flexibility than event listeners, given that the SDK might be ready from cache after a timeout event, the `whenReadyFromCache` method will return a resolved promise once the SDK is ready from cache.
|
|
844
841
|
* You must handle the promise rejection to avoid an unhandled promise rejection error, or set the `startup.readyTimeout` configuration option to 0 to avoid the timeout and thus the rejection.
|
|
845
842
|
*
|
|
846
|
-
* @returns A promise that resolves once the SDK_READY_FROM_CACHE event is emitted or rejects if the SDK has timedout. The promise resolves with a
|
|
847
|
-
* indicates whether the SDK_READY_FROM_CACHE event was emitted together with the SDK_READY event (i.e.,
|
|
843
|
+
* @returns A promise that resolves once the SDK_READY_FROM_CACHE event is emitted or rejects if the SDK has timedout. The promise resolves with a metadata object that contains the `initialCacheLoad` property,
|
|
844
|
+
* which indicates whether the SDK_READY_FROM_CACHE event was emitted together with the SDK_READY event (i.e., fresh install/first app launch) or not (warm cache/subsequent app launch).
|
|
848
845
|
*/
|
|
849
|
-
whenReadyFromCache(): Promise<
|
|
846
|
+
whenReadyFromCache(): Promise<SdkReadyMetadata>;
|
|
850
847
|
}
|
|
851
848
|
/**
|
|
852
849
|
* Common definitions between clients for different environments interface.
|
|
@@ -1100,7 +1097,7 @@ declare namespace SplitIO {
|
|
|
1100
1097
|
/**
|
|
1101
1098
|
* Prerequisites for the feature flag.
|
|
1102
1099
|
*/
|
|
1103
|
-
prerequisites: Array<{ flagName: string
|
|
1100
|
+
prerequisites: Array<{ flagName: string; treatments: string[]; }>;
|
|
1104
1101
|
};
|
|
1105
1102
|
/**
|
|
1106
1103
|
* A promise that resolves to a feature flag view or null if the feature flag is not found.
|
|
@@ -1370,13 +1367,13 @@ declare namespace SplitIO {
|
|
|
1370
1367
|
/**
|
|
1371
1368
|
* Fallback treatment for all flags.
|
|
1372
1369
|
*/
|
|
1373
|
-
global?: Treatment | TreatmentWithConfig
|
|
1370
|
+
global?: Treatment | TreatmentWithConfig;
|
|
1374
1371
|
/**
|
|
1375
1372
|
* Fallback treatments for specific flags. It takes precedence over the global fallback treatment.
|
|
1376
1373
|
*/
|
|
1377
1374
|
byFlag?: {
|
|
1378
|
-
[featureFlagName: string]: Treatment | TreatmentWithConfig
|
|
1379
|
-
}
|
|
1375
|
+
[featureFlagName: string]: Treatment | TreatmentWithConfig;
|
|
1376
|
+
};
|
|
1380
1377
|
}
|
|
1381
1378
|
/**
|
|
1382
1379
|
* Logger. Its interface details are not part of the public API. It shouldn't be used directly.
|
|
@@ -1603,7 +1600,7 @@ declare namespace SplitIO {
|
|
|
1603
1600
|
* });
|
|
1604
1601
|
* ```
|
|
1605
1602
|
*/
|
|
1606
|
-
getHeaderOverrides?: (context: { headers: Record<string, string
|
|
1603
|
+
getHeaderOverrides?: (context: { headers: Record<string, string>; }) => Record<string, string>;
|
|
1607
1604
|
/**
|
|
1608
1605
|
* Custom Node.js HTTP(S) Agent used by the SDK for HTTP(S) requests.
|
|
1609
1606
|
*
|