@messagevisor/module-featurevisor 0.0.1 → 0.1.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 +16 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/jest.config.js +11 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +29 -0
- package/lib/index.js.map +1 -0
- package/package.json +48 -13
- package/src/index.spec.ts +240 -0
- package/src/index.ts +40 -0
- package/tsconfig.cjs.json +14 -0
- package/tsconfig.typecheck.json +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [0.1.0](https://github.com/messagevisor/messagevisor/compare/v0.0.2...v0.1.0) (2026-05-31)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @messagevisor/module-featurevisor
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 0.0.2 (2026-05-31)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @messagevisor/module-featurevisor
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fahad Heylaal (https://fahad19.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @messagevisor/module-featurevisor
|
|
2
|
+
|
|
3
|
+
Visit [https://messagevisor.com/docs/modules/featurevisor/](https://messagevisor.com/docs/modules/featurevisor/) for more information.
|
|
4
|
+
|
|
5
|
+
Featurevisor docs available at: [https://featurevisor.com](https://featurevisor.com)
|
|
6
|
+
|
|
7
|
+
## License
|
|
8
|
+
|
|
9
|
+
MIT © [Fahad Heylaal](https://fahad19.com)
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const base = require("../../jest.config");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
...base,
|
|
5
|
+
rootDir: "../..",
|
|
6
|
+
testRegex: undefined,
|
|
7
|
+
testMatch: ["<rootDir>/packages/module-featurevisor/src/**/*.spec.ts"],
|
|
8
|
+
moduleNameMapper: {
|
|
9
|
+
"^@messagevisor/sdk$": "<rootDir>/packages/sdk/src/index.ts",
|
|
10
|
+
},
|
|
11
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FeaturevisorInstance } from "@featurevisor/sdk";
|
|
2
|
+
import type { MessagevisorModule } from "@messagevisor/sdk";
|
|
3
|
+
export interface FeaturevisorModuleOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
instance: FeaturevisorInstance;
|
|
6
|
+
passContext?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function createFeaturevisorModule(options: FeaturevisorModuleOptions): MessagevisorModule;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFeaturevisorModule = createFeaturevisorModule;
|
|
4
|
+
function createFeaturevisorModule(options) {
|
|
5
|
+
const name = options.name || "featurevisor";
|
|
6
|
+
const instance = options.instance;
|
|
7
|
+
const passContext = options.passContext === true;
|
|
8
|
+
if (!instance) {
|
|
9
|
+
throw new Error("Featurevisor module requires an instance.");
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
setup({ setFlagResolver, setVariationResolver }) {
|
|
14
|
+
setFlagResolver((featureKey, context) => {
|
|
15
|
+
if (passContext) {
|
|
16
|
+
return instance.isEnabled(featureKey, context);
|
|
17
|
+
}
|
|
18
|
+
return instance.isEnabled(featureKey);
|
|
19
|
+
});
|
|
20
|
+
setVariationResolver((experimentKey, context) => {
|
|
21
|
+
const variation = passContext
|
|
22
|
+
? instance.getVariation(experimentKey, context)
|
|
23
|
+
: instance.getVariation(experimentKey);
|
|
24
|
+
return variation !== null && variation !== void 0 ? variation : null;
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAUA,4DA6BC;AA7BD,SAAgB,wBAAwB,CAAC,OAAkC;IACzE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,cAAc,CAAC;IAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC;IAEjD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK,CAAC,EAAE,eAAe,EAAE,oBAAoB,EAAE;YAC7C,eAAe,CAAC,CAAC,UAAU,EAAE,OAAiB,EAAE,EAAE;gBAChD,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,OAA8B,CAAC,CAAC;gBACxE,CAAC;gBAED,OAAO,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;YAEH,oBAAoB,CAAC,CAAC,aAAa,EAAE,OAAiB,EAAE,EAAE;gBACxD,MAAM,SAAS,GAAG,WAAW;oBAC3B,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,OAA8B,CAAC;oBACtE,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;gBAEzC,OAAO,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"name": "@messagevisor/module-featurevisor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Featurevisor integration module for Messagevisor",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"require": "./lib/index.js",
|
|
12
|
+
"import": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"transpile": "rimraf lib && tsc --project tsconfig.cjs.json",
|
|
18
|
+
"dist": "echo 'Nothing to dist here'",
|
|
19
|
+
"build": "npm run transpile",
|
|
20
|
+
"test": "jest --config jest.config.js --verbose",
|
|
21
|
+
"typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.typecheck.json"
|
|
22
|
+
},
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Fahad Heylaal",
|
|
25
|
+
"url": "https://fahad19.com"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://messagevisor.com",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/messagevisor/messagevisor.git"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/messagevisor/messagevisor/issues"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@messagevisor/sdk": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@featurevisor/sdk": ">=2.27.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@featurevisor/sdk": "^2.27.0"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "555119ab05473127a658ed0cfb6a2743ea3a6db8"
|
|
15
50
|
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { createInstance, type FeaturevisorInstance } from "@featurevisor/sdk";
|
|
2
|
+
import { createMessagevisor } from "@messagevisor/sdk";
|
|
3
|
+
import type { DatafileContent } from "@messagevisor/types";
|
|
4
|
+
|
|
5
|
+
import { createFeaturevisorModule } from "./index";
|
|
6
|
+
|
|
7
|
+
const datafile: DatafileContent = {
|
|
8
|
+
schemaVersion: "1",
|
|
9
|
+
messagevisorVersion: "0.0.1",
|
|
10
|
+
revision: "1",
|
|
11
|
+
target: "web",
|
|
12
|
+
locale: "en-US",
|
|
13
|
+
segments: {},
|
|
14
|
+
messages: {
|
|
15
|
+
checkout: {
|
|
16
|
+
overrides: [
|
|
17
|
+
{
|
|
18
|
+
key: "feature-enabled",
|
|
19
|
+
conditions: {
|
|
20
|
+
feature: "new-checkout",
|
|
21
|
+
operator: "isEnabled",
|
|
22
|
+
},
|
|
23
|
+
translation: "Fast checkout",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: "feature-disabled",
|
|
27
|
+
conditions: {
|
|
28
|
+
feature: "legacy-checkout",
|
|
29
|
+
operator: "isDisabled",
|
|
30
|
+
},
|
|
31
|
+
translation: "Classic checkout",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
experiment: {
|
|
36
|
+
overrides: [
|
|
37
|
+
{
|
|
38
|
+
key: "bold-copy",
|
|
39
|
+
conditions: {
|
|
40
|
+
experiment: "checkout-copy",
|
|
41
|
+
operator: "hasVariation",
|
|
42
|
+
value: "bold",
|
|
43
|
+
},
|
|
44
|
+
translation: "Bold checkout copy",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
missingExperiment: {
|
|
49
|
+
overrides: [
|
|
50
|
+
{
|
|
51
|
+
key: "missing",
|
|
52
|
+
conditions: {
|
|
53
|
+
experiment: "missing-copy",
|
|
54
|
+
operator: "hasVariation",
|
|
55
|
+
value: "bold",
|
|
56
|
+
},
|
|
57
|
+
translation: "Missing experiment matched",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
translations: {
|
|
63
|
+
checkout: "Default checkout",
|
|
64
|
+
experiment: "Default experiment",
|
|
65
|
+
missingExperiment: "Default missing experiment",
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
describe("@messagevisor/module-featurevisor", function () {
|
|
70
|
+
it("connects feature and experiment conditions to a Featurevisor instance", function () {
|
|
71
|
+
const f = createInstance({
|
|
72
|
+
logLevel: "fatal",
|
|
73
|
+
sticky: {
|
|
74
|
+
"new-checkout": {
|
|
75
|
+
enabled: true,
|
|
76
|
+
},
|
|
77
|
+
"legacy-checkout": {
|
|
78
|
+
enabled: false,
|
|
79
|
+
},
|
|
80
|
+
"checkout-copy": {
|
|
81
|
+
enabled: true,
|
|
82
|
+
variation: "bold",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const m = createMessagevisor({
|
|
87
|
+
datafile,
|
|
88
|
+
logLevel: "fatal",
|
|
89
|
+
modules: [createFeaturevisorModule({ instance: f })],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(m.translate("checkout")).toEqual("Fast checkout");
|
|
93
|
+
expect(m.translate("experiment")).toEqual("Bold checkout copy");
|
|
94
|
+
expect(m.translate("missingExperiment")).toEqual("Default missing experiment");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("supports isDisabled feature conditions", function () {
|
|
98
|
+
const f = createInstance({
|
|
99
|
+
logLevel: "fatal",
|
|
100
|
+
sticky: {
|
|
101
|
+
"new-checkout": {
|
|
102
|
+
enabled: false,
|
|
103
|
+
},
|
|
104
|
+
"legacy-checkout": {
|
|
105
|
+
enabled: false,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
const m = createMessagevisor({
|
|
110
|
+
datafile,
|
|
111
|
+
logLevel: "fatal",
|
|
112
|
+
modules: [createFeaturevisorModule({ instance: f })],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(m.translate("checkout")).toEqual("Classic checkout");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("does not pass Messagevisor context to Featurevisor evaluations by default", function () {
|
|
119
|
+
const calls: Array<{ method: string; key: string; context: unknown }> = [];
|
|
120
|
+
const instance = {
|
|
121
|
+
isEnabled(featureKey, context) {
|
|
122
|
+
calls.push({ method: "isEnabled", key: featureKey, context });
|
|
123
|
+
return true;
|
|
124
|
+
},
|
|
125
|
+
getVariation(experimentKey, context) {
|
|
126
|
+
calls.push({ method: "getVariation", key: experimentKey, context });
|
|
127
|
+
return "bold";
|
|
128
|
+
},
|
|
129
|
+
} as unknown as FeaturevisorInstance;
|
|
130
|
+
const m = createMessagevisor({
|
|
131
|
+
datafile,
|
|
132
|
+
logLevel: "fatal",
|
|
133
|
+
context: {
|
|
134
|
+
platform: "web",
|
|
135
|
+
plan: "pro",
|
|
136
|
+
},
|
|
137
|
+
modules: [createFeaturevisorModule({ instance })],
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
expect(m.translate("checkout", {}, { context: { userId: "user-123" } })).toEqual(
|
|
141
|
+
"Fast checkout",
|
|
142
|
+
);
|
|
143
|
+
expect(m.translate("experiment")).toEqual("Bold checkout copy");
|
|
144
|
+
expect(calls).toEqual([
|
|
145
|
+
{
|
|
146
|
+
method: "isEnabled",
|
|
147
|
+
key: "new-checkout",
|
|
148
|
+
context: undefined,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
method: "getVariation",
|
|
152
|
+
key: "checkout-copy",
|
|
153
|
+
context: undefined,
|
|
154
|
+
},
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("passes merged Messagevisor context to Featurevisor evaluations when enabled", function () {
|
|
159
|
+
const calls: Array<{ method: string; key: string; context: unknown }> = [];
|
|
160
|
+
const instance = {
|
|
161
|
+
isEnabled(featureKey, context) {
|
|
162
|
+
calls.push({ method: "isEnabled", key: featureKey, context });
|
|
163
|
+
return context?.platform === "web" && context?.userId === "user-123";
|
|
164
|
+
},
|
|
165
|
+
getVariation(experimentKey, context) {
|
|
166
|
+
calls.push({ method: "getVariation", key: experimentKey, context });
|
|
167
|
+
return context?.plan === "pro" ? "bold" : null;
|
|
168
|
+
},
|
|
169
|
+
} as unknown as FeaturevisorInstance;
|
|
170
|
+
const m = createMessagevisor({
|
|
171
|
+
datafile,
|
|
172
|
+
logLevel: "fatal",
|
|
173
|
+
context: {
|
|
174
|
+
platform: "web",
|
|
175
|
+
plan: "pro",
|
|
176
|
+
},
|
|
177
|
+
modules: [createFeaturevisorModule({ instance, passContext: true })],
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
expect(m.translate("checkout", {}, { context: { userId: "user-123" } })).toEqual(
|
|
181
|
+
"Fast checkout",
|
|
182
|
+
);
|
|
183
|
+
expect(m.translate("experiment")).toEqual("Bold checkout copy");
|
|
184
|
+
expect(calls).toEqual([
|
|
185
|
+
{
|
|
186
|
+
method: "isEnabled",
|
|
187
|
+
key: "new-checkout",
|
|
188
|
+
context: {
|
|
189
|
+
platform: "web",
|
|
190
|
+
plan: "pro",
|
|
191
|
+
userId: "user-123",
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
method: "getVariation",
|
|
196
|
+
key: "checkout-copy",
|
|
197
|
+
context: {
|
|
198
|
+
platform: "web",
|
|
199
|
+
plan: "pro",
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
]);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("converts null variations to non-matches", function () {
|
|
206
|
+
const instance = {
|
|
207
|
+
isEnabled() {
|
|
208
|
+
return false;
|
|
209
|
+
},
|
|
210
|
+
getVariation() {
|
|
211
|
+
return null;
|
|
212
|
+
},
|
|
213
|
+
} as unknown as FeaturevisorInstance;
|
|
214
|
+
const m = createMessagevisor({
|
|
215
|
+
datafile,
|
|
216
|
+
logLevel: "fatal",
|
|
217
|
+
modules: [createFeaturevisorModule({ instance })],
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
expect(m.translate("experiment")).toEqual("Default experiment");
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("uses a stable default module name and supports custom names", function () {
|
|
224
|
+
expect(createFeaturevisorModule({ instance: {} as FeaturevisorInstance }).name).toEqual(
|
|
225
|
+
"featurevisor",
|
|
226
|
+
);
|
|
227
|
+
expect(
|
|
228
|
+
createFeaturevisorModule({
|
|
229
|
+
name: "flags",
|
|
230
|
+
instance: {} as FeaturevisorInstance,
|
|
231
|
+
}).name,
|
|
232
|
+
).toEqual("flags");
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("requires a Featurevisor instance", function () {
|
|
236
|
+
expect(() => createFeaturevisorModule({ instance: undefined as any })).toThrow(
|
|
237
|
+
"Featurevisor module requires an instance.",
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Context as FeaturevisorContext, FeaturevisorInstance } from "@featurevisor/sdk";
|
|
2
|
+
import type { MessagevisorModule } from "@messagevisor/sdk";
|
|
3
|
+
import type { Context } from "@messagevisor/types";
|
|
4
|
+
|
|
5
|
+
export interface FeaturevisorModuleOptions {
|
|
6
|
+
name?: string;
|
|
7
|
+
instance: FeaturevisorInstance;
|
|
8
|
+
passContext?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createFeaturevisorModule(options: FeaturevisorModuleOptions): MessagevisorModule {
|
|
12
|
+
const name = options.name || "featurevisor";
|
|
13
|
+
const instance = options.instance;
|
|
14
|
+
const passContext = options.passContext === true;
|
|
15
|
+
|
|
16
|
+
if (!instance) {
|
|
17
|
+
throw new Error("Featurevisor module requires an instance.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
name,
|
|
22
|
+
setup({ setFlagResolver, setVariationResolver }) {
|
|
23
|
+
setFlagResolver((featureKey, context?: Context) => {
|
|
24
|
+
if (passContext) {
|
|
25
|
+
return instance.isEnabled(featureKey, context as FeaturevisorContext);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return instance.isEnabled(featureKey);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
setVariationResolver((experimentKey, context?: Context) => {
|
|
32
|
+
const variation = passContext
|
|
33
|
+
? instance.getVariation(experimentKey, context as FeaturevisorContext)
|
|
34
|
+
: instance.getVariation(experimentKey);
|
|
35
|
+
|
|
36
|
+
return variation ?? null;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.cjs.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"target": "es2018",
|
|
9
|
+
"lib": ["es2021", "es2021.intl", "dom"],
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["./src/**/*.ts"],
|
|
13
|
+
"exclude": ["./src/**/*.spec.ts"]
|
|
14
|
+
}
|