@spotify-confidence/openfeature-server-provider-local 0.6.0 → 0.7.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.
- package/CHANGELOG.md +14 -0
- package/README.md +74 -15
- package/dist/confidence_resolver.wasm +0 -0
- package/dist/index.fetch.d.ts +466 -0
- package/dist/{index.browser.js → index.fetch.js} +21 -13
- package/dist/{index.browser.d.ts → index.inlined.d.ts} +6 -4
- package/dist/index.inlined.js +2958 -0
- package/dist/index.node.d.ts +11 -4
- package/dist/index.node.js +25 -17
- package/package.json +13 -16
|
@@ -1238,7 +1238,7 @@ function isObject(value) {
|
|
|
1238
1238
|
function isSet$3(value) {
|
|
1239
1239
|
return value !== null && value !== void 0;
|
|
1240
1240
|
}
|
|
1241
|
-
const VERSION = "0.
|
|
1241
|
+
const VERSION = "0.7.0";
|
|
1242
1242
|
const NOOP_LOG_FN = Object.assign(() => {}, { enabled: false });
|
|
1243
1243
|
const debugBackend = loadDebug();
|
|
1244
1244
|
const logger$2 = new class LoggerImpl {
|
|
@@ -2382,8 +2382,12 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2382
2382
|
flushInterval;
|
|
2383
2383
|
materializationStore;
|
|
2384
2384
|
stateEtag = null;
|
|
2385
|
-
|
|
2386
|
-
this.
|
|
2385
|
+
get resolver() {
|
|
2386
|
+
if (this.resolverOrPromise instanceof Promise) throw new Error("Resolver not ready");
|
|
2387
|
+
return this.resolverOrPromise;
|
|
2388
|
+
}
|
|
2389
|
+
constructor(resolverOrPromise, options) {
|
|
2390
|
+
this.resolverOrPromise = resolverOrPromise;
|
|
2387
2391
|
this.options = options;
|
|
2388
2392
|
this.stateUpdateInterval = options.stateUpdateInterval ?? DEFAULT_STATE_INTERVAL;
|
|
2389
2393
|
if (!Number.isInteger(this.stateUpdateInterval) || this.stateUpdateInterval < 1e3) throw new Error(`stateUpdateInterval must be an integer >= 1000 (1s), currently: ${this.stateUpdateInterval}`);
|
|
@@ -2421,6 +2425,7 @@ var ConfidenceServerProviderLocal = class ConfidenceServerProviderLocal {
|
|
|
2421
2425
|
const signal = this.main.signal;
|
|
2422
2426
|
const initialUpdateSignal = AbortSignal.any([signal, timeoutSignal(this.options.initializeTimeout ?? DEFAULT_INITIALIZE_TIMEOUT)]);
|
|
2423
2427
|
try {
|
|
2428
|
+
this.resolverOrPromise = await this.resolverOrPromise;
|
|
2424
2429
|
await this.updateState(initialUpdateSignal);
|
|
2425
2430
|
scheduleWithFixedInterval((signal$1) => this.flush(signal$1), this.flushInterval, {
|
|
2426
2431
|
maxConcurrent: 3,
|
|
@@ -2818,8 +2823,8 @@ function verifyExports(exports) {
|
|
|
2818
2823
|
var UnsafeWasmResolver = class {
|
|
2819
2824
|
exports;
|
|
2820
2825
|
flushCount = 0;
|
|
2821
|
-
constructor(module
|
|
2822
|
-
const { exports } = new WebAssembly.Instance(module
|
|
2826
|
+
constructor(module) {
|
|
2827
|
+
const { exports } = new WebAssembly.Instance(module, { wasm_msg: { wasm_msg_host_current_time: () => {
|
|
2823
2828
|
const epochMillisecond = Date.now();
|
|
2824
2829
|
const seconds = Math.floor(epochMillisecond / 1e3);
|
|
2825
2830
|
const nanos = (epochMillisecond - 1e3 * seconds) * 1e6;
|
|
@@ -2882,15 +2887,15 @@ var UnsafeWasmResolver = class {
|
|
|
2882
2887
|
this.exports.wasm_msg_free(ptr);
|
|
2883
2888
|
}
|
|
2884
2889
|
};
|
|
2885
|
-
const DEFAULT_DELEGATE_FACTORY = (module
|
|
2890
|
+
const DEFAULT_DELEGATE_FACTORY = (module) => new UnsafeWasmResolver(module);
|
|
2886
2891
|
var WasmResolver = class {
|
|
2887
2892
|
delegate;
|
|
2888
2893
|
currentState;
|
|
2889
2894
|
bufferedLogs = [];
|
|
2890
|
-
constructor(module
|
|
2891
|
-
this.module = module
|
|
2895
|
+
constructor(module, delegateFactory = DEFAULT_DELEGATE_FACTORY) {
|
|
2896
|
+
this.module = module;
|
|
2892
2897
|
this.delegateFactory = delegateFactory;
|
|
2893
|
-
this.delegate = delegateFactory(module
|
|
2898
|
+
this.delegate = delegateFactory(module);
|
|
2894
2899
|
}
|
|
2895
2900
|
reloadInstance(error) {
|
|
2896
2901
|
logger.error("Failure calling into wasm:", error);
|
|
@@ -2940,10 +2945,13 @@ var WasmResolver = class {
|
|
|
2940
2945
|
return this.delegate.flushAssigned();
|
|
2941
2946
|
}
|
|
2942
2947
|
};
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
function createConfidenceServerProvider(options) {
|
|
2948
|
+
let resolver = null;
|
|
2949
|
+
function createConfidenceServerProvider({ wasmUrl,...options }) {
|
|
2950
|
+
if (!resolver) resolver = createResolver(wasmUrl ?? new URL("confidence_resolver.wasm", import.meta.url));
|
|
2947
2951
|
return new ConfidenceServerProviderLocal(resolver, options);
|
|
2948
2952
|
}
|
|
2953
|
+
async function createResolver(wasmUrl) {
|
|
2954
|
+
const module = await WebAssembly.compileStreaming(fetch(wasmUrl));
|
|
2955
|
+
return new WasmResolver(module);
|
|
2956
|
+
}
|
|
2949
2957
|
export { createConfidenceServerProvider };
|
|
@@ -414,7 +414,7 @@ interface ProviderOptions {
|
|
|
414
414
|
* @public
|
|
415
415
|
*/
|
|
416
416
|
declare class ConfidenceServerProviderLocal implements Provider {
|
|
417
|
-
private
|
|
417
|
+
private resolverOrPromise;
|
|
418
418
|
private options;
|
|
419
419
|
/** Static data about the provider */
|
|
420
420
|
readonly metadata: ProviderMetadata;
|
|
@@ -426,7 +426,8 @@ declare class ConfidenceServerProviderLocal implements Provider {
|
|
|
426
426
|
private readonly flushInterval;
|
|
427
427
|
private readonly materializationStore;
|
|
428
428
|
private stateEtag;
|
|
429
|
-
|
|
429
|
+
private get resolver();
|
|
430
|
+
constructor(resolverOrPromise: LocalResolver | Promise<LocalResolver>, options: ProviderOptions);
|
|
430
431
|
initialize(context?: EvaluationContext): Promise<void>;
|
|
431
432
|
onClose(): Promise<void>;
|
|
432
433
|
evaluate<T>(flagKey: string, defaultValue: T, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
@@ -453,7 +454,8 @@ declare class ConfidenceServerProviderLocal implements Provider {
|
|
|
453
454
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
454
455
|
}
|
|
455
456
|
//#endregion
|
|
456
|
-
//#region src/index.
|
|
457
|
+
//#region src/index.inlined.d.ts
|
|
458
|
+
type ProviderOptionsExt = ProviderOptions;
|
|
457
459
|
declare function createConfidenceServerProvider(options: ProviderOptions): ConfidenceServerProviderLocal;
|
|
458
460
|
//#endregion
|
|
459
|
-
export { type MaterializationStore, createConfidenceServerProvider };
|
|
461
|
+
export { type MaterializationStore, ProviderOptionsExt, createConfidenceServerProvider };
|