statsig-node-vercel 0.0.1-beta.1 → 0.0.1-beta.2
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/EdgeConfigDataAdapter.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdapterResponse, IDataAdapter
|
|
1
|
+
import { AdapterResponse, IDataAdapter } from 'statsig-node';
|
|
2
2
|
import { get } from '@vercel/edge-config';
|
|
3
3
|
|
|
4
4
|
type Data = {
|
|
@@ -20,8 +20,8 @@ export class EdgeConfigDataAdapter implements IDataAdapter {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
23
|
-
public async get(key:
|
|
24
|
-
if (key !==
|
|
23
|
+
public async get(key: string): Promise<AdapterResponse> {
|
|
24
|
+
if (key !== "statsig.cache") {
|
|
25
25
|
return { error: new Error(`Edge Config Adapter Only Supports Config Specs`) };
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ export class EdgeConfigDataAdapter implements IDataAdapter {
|
|
|
34
34
|
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
36
36
|
public async set(
|
|
37
|
-
key:
|
|
37
|
+
key: string,
|
|
38
38
|
value: string,
|
|
39
39
|
time?: number | undefined,
|
|
40
40
|
): Promise<void> {
|
|
@@ -54,8 +54,8 @@ export class EdgeConfigDataAdapter implements IDataAdapter {
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
public supportsPollingUpdatesFor(key:
|
|
58
|
-
if (key ===
|
|
57
|
+
public supportsPollingUpdatesFor(key: string): boolean {
|
|
58
|
+
if (key === "statsig.cache") {
|
|
59
59
|
return this.supportConfigSpecPolling;
|
|
60
60
|
}
|
|
61
61
|
return false;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EdgeConfigDataAdapter } from '../EdgeConfigDataAdapter';
|
|
2
2
|
import fetchMock from "jest-fetch-mock"
|
|
3
|
-
import { DataAdapterKey } from 'statsig-node';
|
|
4
3
|
|
|
5
4
|
describe('Validate edge config adapter functionality', () => {
|
|
6
5
|
const dataAdapter = new EdgeConfigDataAdapter(
|
|
@@ -9,10 +8,7 @@ describe('Validate edge config adapter functionality', () => {
|
|
|
9
8
|
|
|
10
9
|
beforeEach(async () => {
|
|
11
10
|
fetchMock.enableMocks()
|
|
12
|
-
fetchMock.mockResponse(
|
|
13
|
-
body: '{ "items": { "statsig-companyid": {} }}',
|
|
14
|
-
})
|
|
15
|
-
);
|
|
11
|
+
fetchMock.mockResponse('"test123"');
|
|
16
12
|
await dataAdapter.initialize();
|
|
17
13
|
});
|
|
18
14
|
|
|
@@ -20,11 +16,11 @@ describe('Validate edge config adapter functionality', () => {
|
|
|
20
16
|
await dataAdapter.shutdown();
|
|
21
17
|
});
|
|
22
18
|
|
|
23
|
-
test('Simple get
|
|
24
|
-
const { result: gates } = await dataAdapter.get(
|
|
19
|
+
test('Simple get', async () => {
|
|
20
|
+
const { result: gates } = await dataAdapter.get("statsig.cache");
|
|
25
21
|
if (gates == null) {
|
|
26
22
|
return;
|
|
27
23
|
}
|
|
28
|
-
expect(gates).toEqual('test123');
|
|
24
|
+
expect(gates).toEqual('"test123"');
|
|
29
25
|
});
|
|
30
26
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "statsig-node-vercel",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@vercel/edge-config": "^0.1.0-canary.15",
|
|
16
|
-
"statsig-node": "5.1.0-beta.
|
|
16
|
+
"statsig-node": "5.1.0-beta.5"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@babel/core": "^7.18.13",
|