@openfeature/ofrep-web-provider 0.3.2 → 0.3.3
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/index.cjs.js
CHANGED
|
@@ -73,7 +73,7 @@ class OFREPWebProvider {
|
|
|
73
73
|
this._logger = logger;
|
|
74
74
|
this._etag = null;
|
|
75
75
|
this._ofrepAPI = new ofrepCore.OFREPApi(this._options, this._options.fetchImplementation);
|
|
76
|
-
this._pollingInterval = (_a = this._options.pollInterval) !== null && _a !==
|
|
76
|
+
this._pollingInterval = (_a = this._options.pollInterval) !== null && _a !== void 0 ? _a : this.DEFAULT_POLL_INTERVAL;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Returns a shallow copy of the flag cache, which is updated at initialization/context-change/configuration-change once the flags are re-evaluated.
|
|
@@ -86,7 +86,7 @@ class OFREPWebProvider {
|
|
|
86
86
|
* @param context - the context to use for the evaluation
|
|
87
87
|
*/
|
|
88
88
|
initialize(context) {
|
|
89
|
-
return __awaiter(this,
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
var _a;
|
|
91
91
|
try {
|
|
92
92
|
this._context = context;
|
|
@@ -125,7 +125,7 @@ class OFREPWebProvider {
|
|
|
125
125
|
* @param newContext - the new evaluation context
|
|
126
126
|
*/
|
|
127
127
|
onContextChange(oldContext, newContext) {
|
|
128
|
-
return __awaiter(this,
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
129
|
var _a, _b, _c;
|
|
130
130
|
try {
|
|
131
131
|
this._context = newContext;
|
|
@@ -138,17 +138,17 @@ class OFREPWebProvider {
|
|
|
138
138
|
}
|
|
139
139
|
catch (error) {
|
|
140
140
|
if (error instanceof ofrepCore.OFREPApiTooManyRequestsError) {
|
|
141
|
-
(_a = this.events) === null || _a ===
|
|
141
|
+
(_a = this.events) === null || _a === void 0 ? void 0 : _a.emit(webSdk.ClientProviderEvents.Stale, { message: `${error.name}: ${error.message}` });
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
if (error instanceof webSdk.OpenFeatureError ||
|
|
145
145
|
error instanceof ofrepCore.OFREPApiFetchError ||
|
|
146
146
|
error instanceof ofrepCore.OFREPApiUnauthorizedError ||
|
|
147
147
|
error instanceof ofrepCore.OFREPForbiddenError) {
|
|
148
|
-
(_b = this.events) === null || _b ===
|
|
148
|
+
(_b = this.events) === null || _b === void 0 ? void 0 : _b.emit(webSdk.ClientProviderEvents.Error, { message: `${error.name}: ${error.message}` });
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
(_c = this.events) === null || _c ===
|
|
151
|
+
(_c = this.events) === null || _c === void 0 ? void 0 : _c.emit(webSdk.ClientProviderEvents.Error, { message: `Unknown error: ${error}` });
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
}
|
|
@@ -170,7 +170,7 @@ class OFREPWebProvider {
|
|
|
170
170
|
* @throws GeneralError if the API returned a 400 with an unknown error code
|
|
171
171
|
*/
|
|
172
172
|
_fetchFlags(context) {
|
|
173
|
-
return __awaiter(this,
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
174
|
var _a;
|
|
175
175
|
try {
|
|
176
176
|
const evalReq = {
|
|
@@ -292,7 +292,7 @@ class OFREPWebProvider {
|
|
|
292
292
|
* @private
|
|
293
293
|
*/
|
|
294
294
|
startPolling() {
|
|
295
|
-
this._pollingIntervalId = setInterval(() => __awaiter(this,
|
|
295
|
+
this._pollingIntervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
296
296
|
var _a, _b;
|
|
297
297
|
try {
|
|
298
298
|
const now = new Date();
|
|
@@ -308,7 +308,7 @@ class OFREPWebProvider {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
catch (error) {
|
|
311
|
-
(_b = this.events) === null || _b ===
|
|
311
|
+
(_b = this.events) === null || _b === void 0 ? void 0 : _b.emit(webSdk.ClientProviderEvents.Stale, { message: `Error while polling: ${error}` });
|
|
312
312
|
}
|
|
313
313
|
}), this._pollingInterval);
|
|
314
314
|
}
|
package/index.esm.js
CHANGED
|
@@ -71,7 +71,7 @@ class OFREPWebProvider {
|
|
|
71
71
|
this._logger = logger;
|
|
72
72
|
this._etag = null;
|
|
73
73
|
this._ofrepAPI = new OFREPApi(this._options, this._options.fetchImplementation);
|
|
74
|
-
this._pollingInterval = (_a = this._options.pollInterval) !== null && _a !==
|
|
74
|
+
this._pollingInterval = (_a = this._options.pollInterval) !== null && _a !== void 0 ? _a : this.DEFAULT_POLL_INTERVAL;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Returns a shallow copy of the flag cache, which is updated at initialization/context-change/configuration-change once the flags are re-evaluated.
|
|
@@ -84,7 +84,7 @@ class OFREPWebProvider {
|
|
|
84
84
|
* @param context - the context to use for the evaluation
|
|
85
85
|
*/
|
|
86
86
|
initialize(context) {
|
|
87
|
-
return __awaiter(this,
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
88
|
var _a;
|
|
89
89
|
try {
|
|
90
90
|
this._context = context;
|
|
@@ -123,7 +123,7 @@ class OFREPWebProvider {
|
|
|
123
123
|
* @param newContext - the new evaluation context
|
|
124
124
|
*/
|
|
125
125
|
onContextChange(oldContext, newContext) {
|
|
126
|
-
return __awaiter(this,
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
127
|
var _a, _b, _c;
|
|
128
128
|
try {
|
|
129
129
|
this._context = newContext;
|
|
@@ -136,17 +136,17 @@ class OFREPWebProvider {
|
|
|
136
136
|
}
|
|
137
137
|
catch (error) {
|
|
138
138
|
if (error instanceof OFREPApiTooManyRequestsError) {
|
|
139
|
-
(_a = this.events) === null || _a ===
|
|
139
|
+
(_a = this.events) === null || _a === void 0 ? void 0 : _a.emit(ClientProviderEvents.Stale, { message: `${error.name}: ${error.message}` });
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
if (error instanceof OpenFeatureError ||
|
|
143
143
|
error instanceof OFREPApiFetchError ||
|
|
144
144
|
error instanceof OFREPApiUnauthorizedError ||
|
|
145
145
|
error instanceof OFREPForbiddenError) {
|
|
146
|
-
(_b = this.events) === null || _b ===
|
|
146
|
+
(_b = this.events) === null || _b === void 0 ? void 0 : _b.emit(ClientProviderEvents.Error, { message: `${error.name}: ${error.message}` });
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
(_c = this.events) === null || _c ===
|
|
149
|
+
(_c = this.events) === null || _c === void 0 ? void 0 : _c.emit(ClientProviderEvents.Error, { message: `Unknown error: ${error}` });
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
}
|
|
@@ -168,7 +168,7 @@ class OFREPWebProvider {
|
|
|
168
168
|
* @throws GeneralError if the API returned a 400 with an unknown error code
|
|
169
169
|
*/
|
|
170
170
|
_fetchFlags(context) {
|
|
171
|
-
return __awaiter(this,
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
172
|
var _a;
|
|
173
173
|
try {
|
|
174
174
|
const evalReq = {
|
|
@@ -290,7 +290,7 @@ class OFREPWebProvider {
|
|
|
290
290
|
* @private
|
|
291
291
|
*/
|
|
292
292
|
startPolling() {
|
|
293
|
-
this._pollingIntervalId = setInterval(() => __awaiter(this,
|
|
293
|
+
this._pollingIntervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
294
294
|
var _a, _b;
|
|
295
295
|
try {
|
|
296
296
|
const now = new Date();
|
|
@@ -306,7 +306,7 @@ class OFREPWebProvider {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
catch (error) {
|
|
309
|
-
(_b = this.events) === null || _b ===
|
|
309
|
+
(_b = this.events) === null || _b === void 0 ? void 0 : _b.emit(ClientProviderEvents.Stale, { message: `Error while polling: ${error}` });
|
|
310
310
|
}
|
|
311
311
|
}), this._pollingInterval);
|
|
312
312
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfeature/ofrep-web-provider",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./index.cjs.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"@openfeature/web-sdk": "^1.4.0"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"undici": "^5.0.0",
|
|
16
15
|
"@openfeature/ofrep-core": "^1.0.0"
|
|
17
16
|
},
|
|
18
17
|
"exports": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OFREPProviderBaseOptions } from '@openfeature/ofrep-core';
|
|
1
|
+
import type { OFREPProviderBaseOptions } from '@openfeature/ofrep-core';
|
|
2
2
|
export type OFREPWebProviderOptions = OFREPProviderBaseOptions & {
|
|
3
3
|
/**
|
|
4
4
|
* pollInterval is the time in milliseconds to wait between we call the OFREP
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EvaluationContext, Hook, JsonValue, Logger,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { EvaluationContext, Hook, JsonValue, Logger, Provider, ResolutionDetails } from '@openfeature/web-sdk';
|
|
2
|
+
import { OpenFeatureEventEmitter } from '@openfeature/web-sdk';
|
|
3
|
+
import type { FlagCache } from './model/in-memory-cache';
|
|
4
|
+
import type { OFREPWebProviderOptions } from './model/ofrep-web-provider-options';
|
|
4
5
|
export declare class OFREPWebProvider implements Provider {
|
|
5
6
|
DEFAULT_POLL_INTERVAL: number;
|
|
6
7
|
readonly metadata: {
|