flagsmith-nodejs 3.1.0 → 3.1.1
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/build/sdk/index.d.ts +0 -1
- package/build/sdk/index.js +3 -3
- package/package.json +1 -1
- package/sdk/index.ts +2 -3
- package/tests/sdk/flagsmith.test.ts +10 -1
package/build/sdk/index.d.ts
CHANGED
package/build/sdk/index.js
CHANGED
|
@@ -89,6 +89,7 @@ Object.defineProperty(exports, "Flags", { enumerable: true, get: function () { r
|
|
|
89
89
|
var polling_manager_2 = require("./polling_manager");
|
|
90
90
|
Object.defineProperty(exports, "EnvironmentDataPollingManager", { enumerable: true, get: function () { return polling_manager_2.EnvironmentDataPollingManager; } });
|
|
91
91
|
var DEFAULT_API_URL = 'https://edge.api.flagsmith.com/api/v1/';
|
|
92
|
+
var DEFAULT_REQUEST_TIMEOUT_SECONDS = 10;
|
|
92
93
|
var Flagsmith = /** @class */ (function () {
|
|
93
94
|
/**
|
|
94
95
|
* A Flagsmith client.
|
|
@@ -122,8 +123,8 @@ var Flagsmith = /** @class */ (function () {
|
|
|
122
123
|
@param data.logger: an instance of the pino Logger class to use for logging
|
|
123
124
|
*/
|
|
124
125
|
function Flagsmith(data) {
|
|
126
|
+
var _a;
|
|
125
127
|
this.apiUrl = DEFAULT_API_URL;
|
|
126
|
-
this.requestTimeoutSeconds = 10;
|
|
127
128
|
this.enableLocalEvaluation = false;
|
|
128
129
|
this.environmentRefreshIntervalSeconds = 60;
|
|
129
130
|
this.enableAnalytics = false;
|
|
@@ -131,8 +132,7 @@ var Flagsmith = /** @class */ (function () {
|
|
|
131
132
|
this.environmentKey = data.environmentKey;
|
|
132
133
|
this.apiUrl = data.apiUrl || this.apiUrl;
|
|
133
134
|
this.customHeaders = data.customHeaders;
|
|
134
|
-
this.
|
|
135
|
-
this.requestTimeoutMs = data.requestTimeoutSeconds ? data.requestTimeoutSeconds * 1000 : undefined;
|
|
135
|
+
this.requestTimeoutMs = 1000 * ((_a = data.requestTimeoutSeconds) !== null && _a !== void 0 ? _a : DEFAULT_REQUEST_TIMEOUT_SECONDS);
|
|
136
136
|
this.enableLocalEvaluation = data.enableLocalEvaluation;
|
|
137
137
|
this.environmentRefreshIntervalSeconds =
|
|
138
138
|
data.environmentRefreshIntervalSeconds || this.environmentRefreshIntervalSeconds;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagsmith-nodejs",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Flagsmith lets you manage features flags and remote config across web, mobile and server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"repository": {
|
package/sdk/index.ts
CHANGED
|
@@ -24,13 +24,13 @@ export { EnvironmentDataPollingManager } from './polling_manager';
|
|
|
24
24
|
export { FlagsmithCache, FlagsmithConfig } from './types';
|
|
25
25
|
|
|
26
26
|
const DEFAULT_API_URL = 'https://edge.api.flagsmith.com/api/v1/';
|
|
27
|
+
const DEFAULT_REQUEST_TIMEOUT_SECONDS = 10;
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
export class Flagsmith {
|
|
30
31
|
environmentKey?: string;
|
|
31
32
|
apiUrl: string = DEFAULT_API_URL;
|
|
32
33
|
customHeaders?: { [key: string]: any };
|
|
33
|
-
requestTimeoutSeconds?: number = 10;
|
|
34
34
|
agent: RequestInit['agent'];
|
|
35
35
|
requestTimeoutMs?: number;
|
|
36
36
|
enableLocalEvaluation?: boolean = false;
|
|
@@ -87,8 +87,7 @@ export class Flagsmith {
|
|
|
87
87
|
this.environmentKey = data.environmentKey;
|
|
88
88
|
this.apiUrl = data.apiUrl || this.apiUrl;
|
|
89
89
|
this.customHeaders = data.customHeaders;
|
|
90
|
-
this.
|
|
91
|
-
this.requestTimeoutMs = data.requestTimeoutSeconds ? data.requestTimeoutSeconds * 1000 : undefined;
|
|
90
|
+
this.requestTimeoutMs = 1000 * (data.requestTimeoutSeconds ?? DEFAULT_REQUEST_TIMEOUT_SECONDS);
|
|
92
91
|
this.enableLocalEvaluation = data.enableLocalEvaluation;
|
|
93
92
|
this.environmentRefreshIntervalSeconds =
|
|
94
93
|
data.environmentRefreshIntervalSeconds || this.environmentRefreshIntervalSeconds;
|
|
@@ -183,7 +183,7 @@ test('default flag handler used when timeout occurs', async () => {
|
|
|
183
183
|
const flg = new Flagsmith({
|
|
184
184
|
environmentKey: 'key',
|
|
185
185
|
defaultFlagHandler: defaultFlagHandler,
|
|
186
|
-
requestTimeoutSeconds: 0.
|
|
186
|
+
requestTimeoutSeconds: 0.001,
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
const flags = await flg.getEnvironmentFlags();
|
|
@@ -193,6 +193,15 @@ test('default flag handler used when timeout occurs', async () => {
|
|
|
193
193
|
expect(flag.value).toBe(defaultFlag.value);
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
+
test('request timeout uses default if not provided', async () => {
|
|
197
|
+
|
|
198
|
+
const flg = new Flagsmith({
|
|
199
|
+
environmentKey: 'key',
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
expect(flg.requestTimeoutMs).toBe(10000);
|
|
203
|
+
})
|
|
204
|
+
|
|
196
205
|
test('test_throws_when_no_identity_flags_returned_due_to_error', async () => {
|
|
197
206
|
// @ts-ignore
|
|
198
207
|
fetch.mockReturnValue(Promise.resolve(new Response('bad data')));
|