@metamask-previews/remote-feature-flag-controller 6.1.0-preview-8c2a2eeb2 → 6.1.0-preview-4f4c98e
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 +1 -0
- package/dist/client-config-api-service/{abstract-client-config-api-service.d.mts → abstract-client-config-api-service.d.ts} +3 -3
- package/dist/client-config-api-service/abstract-client-config-api-service.d.ts.map +1 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.js +2 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.js.map +1 -0
- package/dist/client-config-api-service/{client-config-api-service.d.cts → client-config-api-service.d.ts} +5 -5
- package/dist/client-config-api-service/client-config-api-service.d.ts.map +1 -0
- package/dist/client-config-api-service/{client-config-api-service.mjs → client-config-api-service.js} +3 -3
- package/dist/client-config-api-service/client-config-api-service.js.map +1 -0
- package/dist/{constants.d.cts → constants.d.ts} +1 -1
- package/dist/constants.d.ts.map +1 -0
- package/dist/{constants.mjs → constants.js} +1 -1
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/{remote-feature-flag-controller-method-action-types.d.cts → remote-feature-flag-controller-method-action-types.d.ts} +2 -2
- package/dist/remote-feature-flag-controller-method-action-types.d.ts.map +1 -0
- package/dist/{remote-feature-flag-controller-method-action-types.mjs → remote-feature-flag-controller-method-action-types.js} +1 -1
- package/dist/remote-feature-flag-controller-method-action-types.js.map +1 -0
- package/dist/{remote-feature-flag-controller-types.d.mts → remote-feature-flag-controller-types.d.ts} +2 -2
- package/dist/remote-feature-flag-controller-types.d.ts.map +1 -0
- package/dist/{remote-feature-flag-controller-types.mjs → remote-feature-flag-controller-types.js} +1 -1
- package/dist/remote-feature-flag-controller-types.js.map +1 -0
- package/dist/{remote-feature-flag-controller.d.cts → remote-feature-flag-controller.d.ts} +8 -8
- package/dist/remote-feature-flag-controller.d.ts.map +1 -0
- package/dist/{remote-feature-flag-controller.mjs → remote-feature-flag-controller.js} +5 -5
- package/dist/remote-feature-flag-controller.js.map +1 -0
- package/dist/utils/{user-segmentation-utils.d.cts → user-segmentation-utils.d.ts} +3 -3
- package/dist/utils/user-segmentation-utils.d.ts.map +1 -0
- package/dist/utils/{user-segmentation-utils.mjs → user-segmentation-utils.js} +3 -3
- package/dist/utils/user-segmentation-utils.js.map +1 -0
- package/dist/utils/{version.d.cts → version.d.ts} +4 -4
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/{version.mjs → version.js} +2 -2
- package/dist/utils/version.js.map +1 -0
- package/package.json +12 -16
- package/dist/client-config-api-service/abstract-client-config-api-service.cjs +0 -3
- package/dist/client-config-api-service/abstract-client-config-api-service.cjs.map +0 -1
- package/dist/client-config-api-service/abstract-client-config-api-service.d.cts +0 -17
- package/dist/client-config-api-service/abstract-client-config-api-service.d.cts.map +0 -1
- package/dist/client-config-api-service/abstract-client-config-api-service.d.mts.map +0 -1
- package/dist/client-config-api-service/abstract-client-config-api-service.mjs +0 -2
- package/dist/client-config-api-service/abstract-client-config-api-service.mjs.map +0 -1
- package/dist/client-config-api-service/client-config-api-service.cjs +0 -94
- package/dist/client-config-api-service/client-config-api-service.cjs.map +0 -1
- package/dist/client-config-api-service/client-config-api-service.d.cts.map +0 -1
- package/dist/client-config-api-service/client-config-api-service.d.mts +0 -108
- package/dist/client-config-api-service/client-config-api-service.d.mts.map +0 -1
- package/dist/client-config-api-service/client-config-api-service.mjs.map +0 -1
- package/dist/constants.cjs +0 -8
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.mts +0 -5
- package/dist/constants.d.mts.map +0 -1
- package/dist/constants.mjs.map +0 -1
- package/dist/index.cjs +0 -15
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -8
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -8
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -5
- package/dist/index.mjs.map +0 -1
- package/dist/remote-feature-flag-controller-method-action-types.cjs +0 -7
- package/dist/remote-feature-flag-controller-method-action-types.cjs.map +0 -1
- package/dist/remote-feature-flag-controller-method-action-types.d.cts.map +0 -1
- package/dist/remote-feature-flag-controller-method-action-types.d.mts +0 -62
- package/dist/remote-feature-flag-controller-method-action-types.d.mts.map +0 -1
- package/dist/remote-feature-flag-controller-method-action-types.mjs.map +0 -1
- package/dist/remote-feature-flag-controller-types.cjs +0 -32
- package/dist/remote-feature-flag-controller-types.cjs.map +0 -1
- package/dist/remote-feature-flag-controller-types.d.cts +0 -64
- package/dist/remote-feature-flag-controller-types.d.cts.map +0 -1
- package/dist/remote-feature-flag-controller-types.d.mts.map +0 -1
- package/dist/remote-feature-flag-controller-types.mjs.map +0 -1
- package/dist/remote-feature-flag-controller.cjs +0 -436
- package/dist/remote-feature-flag-controller.cjs.map +0 -1
- package/dist/remote-feature-flag-controller.d.cts.map +0 -1
- package/dist/remote-feature-flag-controller.d.mts +0 -113
- package/dist/remote-feature-flag-controller.d.mts.map +0 -1
- package/dist/remote-feature-flag-controller.mjs.map +0 -1
- package/dist/utils/user-segmentation-utils.cjs +0 -107
- package/dist/utils/user-segmentation-utils.cjs.map +0 -1
- package/dist/utils/user-segmentation-utils.d.cts.map +0 -1
- package/dist/utils/user-segmentation-utils.d.mts +0 -34
- package/dist/utils/user-segmentation-utils.d.mts.map +0 -1
- package/dist/utils/user-segmentation-utils.mjs.map +0 -1
- package/dist/utils/version.cjs +0 -78
- package/dist/utils/version.cjs.map +0 -1
- package/dist/utils/version.d.cts.map +0 -1
- package/dist/utils/version.d.mts +0 -26
- package/dist/utils/version.d.mts.map +0 -1
- package/dist/utils/version.mjs.map +0 -1
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _ClientConfigApiService_instances, _ClientConfigApiService_fetch, _ClientConfigApiService_policy, _ClientConfigApiService_client, _ClientConfigApiService_distribution, _ClientConfigApiService_environment, _ClientConfigApiService_flattenFeatureFlags;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ClientConfigApiService = void 0;
|
|
16
|
-
const controller_utils_1 = require("@metamask/controller-utils");
|
|
17
|
-
const constants_js_1 = require("../constants.cjs");
|
|
18
|
-
/**
|
|
19
|
-
* This service is responsible for fetching feature flags from the ClientConfig API.
|
|
20
|
-
*/
|
|
21
|
-
class ClientConfigApiService {
|
|
22
|
-
constructor({ fetch: fetchFunction, retries = controller_utils_1.DEFAULT_MAX_RETRIES, maximumConsecutiveFailures = controller_utils_1.DEFAULT_MAX_CONSECUTIVE_FAILURES, circuitBreakDuration = controller_utils_1.DEFAULT_CIRCUIT_BREAK_DURATION, onBreak, onDegraded, config, }) {
|
|
23
|
-
_ClientConfigApiService_instances.add(this);
|
|
24
|
-
_ClientConfigApiService_fetch.set(this, void 0);
|
|
25
|
-
_ClientConfigApiService_policy.set(this, void 0);
|
|
26
|
-
_ClientConfigApiService_client.set(this, void 0);
|
|
27
|
-
_ClientConfigApiService_distribution.set(this, void 0);
|
|
28
|
-
_ClientConfigApiService_environment.set(this, void 0);
|
|
29
|
-
__classPrivateFieldSet(this, _ClientConfigApiService_fetch, fetchFunction, "f");
|
|
30
|
-
__classPrivateFieldSet(this, _ClientConfigApiService_client, config.client, "f");
|
|
31
|
-
__classPrivateFieldSet(this, _ClientConfigApiService_distribution, config.distribution, "f");
|
|
32
|
-
__classPrivateFieldSet(this, _ClientConfigApiService_environment, config.environment, "f");
|
|
33
|
-
__classPrivateFieldSet(this, _ClientConfigApiService_policy, (0, controller_utils_1.createServicePolicy)({
|
|
34
|
-
maxRetries: retries,
|
|
35
|
-
maxConsecutiveFailures: maximumConsecutiveFailures,
|
|
36
|
-
circuitBreakDuration,
|
|
37
|
-
}), "f");
|
|
38
|
-
if (onBreak) {
|
|
39
|
-
__classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onBreak(onBreak);
|
|
40
|
-
}
|
|
41
|
-
if (onDegraded) {
|
|
42
|
-
__classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onDegraded(onDegraded);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Listens for when the request to the API fails too many times in a row.
|
|
47
|
-
*
|
|
48
|
-
* @param args - The same arguments that {@link ServicePolicy.onBreak}
|
|
49
|
-
* takes.
|
|
50
|
-
* @returns What {@link ServicePolicy.onBreak} returns.
|
|
51
|
-
*/
|
|
52
|
-
onBreak(...args) {
|
|
53
|
-
return __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onBreak(...args);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Listens for when the API is degraded.
|
|
57
|
-
*
|
|
58
|
-
* @param args - The same arguments that {@link ServicePolicy.onDegraded}
|
|
59
|
-
* takes.
|
|
60
|
-
* @returns What {@link ServicePolicy.onDegraded} returns.
|
|
61
|
-
*/
|
|
62
|
-
onDegraded(...args) {
|
|
63
|
-
return __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onDegraded(...args);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Fetches feature flags from the API with specific client, distribution, and environment parameters.
|
|
67
|
-
* Provides structured error handling, including fallback to cached data if available.
|
|
68
|
-
*
|
|
69
|
-
* @returns An object of feature flags and their boolean values or a structured error object.
|
|
70
|
-
*/
|
|
71
|
-
async fetchRemoteFeatureFlags() {
|
|
72
|
-
const url = `${constants_js_1.BASE_URL}/flags?client=${__classPrivateFieldGet(this, _ClientConfigApiService_client, "f")}&distribution=${__classPrivateFieldGet(this, _ClientConfigApiService_distribution, "f")}&environment=${__classPrivateFieldGet(this, _ClientConfigApiService_environment, "f")}`;
|
|
73
|
-
const response = await __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").execute(() => __classPrivateFieldGet(this, _ClientConfigApiService_fetch, "f").call(this, url, { cache: 'no-cache' }));
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
throw new Error('Failed to fetch remote feature flags');
|
|
76
|
-
}
|
|
77
|
-
const data = await response.json();
|
|
78
|
-
if (!Array.isArray(data)) {
|
|
79
|
-
throw new Error('Feature flags api did not return an array');
|
|
80
|
-
}
|
|
81
|
-
const remoteFeatureFlags = __classPrivateFieldGet(this, _ClientConfigApiService_instances, "m", _ClientConfigApiService_flattenFeatureFlags).call(this, data);
|
|
82
|
-
return {
|
|
83
|
-
remoteFeatureFlags,
|
|
84
|
-
cacheTimestamp: Date.now(),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.ClientConfigApiService = ClientConfigApiService;
|
|
89
|
-
_ClientConfigApiService_fetch = new WeakMap(), _ClientConfigApiService_policy = new WeakMap(), _ClientConfigApiService_client = new WeakMap(), _ClientConfigApiService_distribution = new WeakMap(), _ClientConfigApiService_environment = new WeakMap(), _ClientConfigApiService_instances = new WeakSet(), _ClientConfigApiService_flattenFeatureFlags = function _ClientConfigApiService_flattenFeatureFlags(responseData) {
|
|
90
|
-
return responseData.reduce((acc, curr) => {
|
|
91
|
-
return { ...acc, ...curr };
|
|
92
|
-
}, {});
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=client-config-api-service.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-config-api-service.cjs","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iEAKoC;AAIpC,mDAA2C;AAW3C;;GAEG;AACH,MAAa,sBAAsB;IAwFjC,YAAY,EACV,KAAK,EAAE,aAAa,EACpB,OAAO,GAAG,sCAAmB,EAC7B,0BAA0B,GAAG,mDAAgC,EAC7D,oBAAoB,GAAG,iDAA8B,EACrD,OAAO,EACP,UAAU,EACV,MAAM,GAaP;;QA3GQ,gDAAqB;QAErB,iDAAuB;QAEvB,iDAAoB;QAEpB,uDAAgC;QAEhC,sDAA8B;QAoGrC,uBAAA,IAAI,iCAAU,aAAa,MAAA,CAAC;QAC5B,uBAAA,IAAI,kCAAW,MAAM,CAAC,MAAM,MAAA,CAAC;QAC7B,uBAAA,IAAI,wCAAiB,MAAM,CAAC,YAAY,MAAA,CAAC;QACzC,uBAAA,IAAI,uCAAgB,MAAM,CAAC,WAAW,MAAA,CAAC;QAEvC,uBAAA,IAAI,kCAAW,IAAA,sCAAmB,EAAC;YACjC,UAAU,EAAE,OAAO;YACnB,sBAAsB,EAAE,0BAA0B;YAClD,oBAAoB;SACrB,CAAC,MAAA,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAA0C;QACnD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAA6C;QACzD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,MAAM,GAAG,GAAG,GAAG,uBAAQ,iBAAiB,uBAAA,IAAI,sCAAQ,iBAClD,uBAAA,IAAI,4CACN,gBAAgB,uBAAA,IAAI,2CAAa,EAAE,CAAC;QAEpC,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAC/C,uBAAA,IAAI,qCAAO,MAAX,IAAI,EAAQ,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CACxC,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,kBAAkB,GAAG,uBAAA,IAAI,sFAAqB,MAAzB,IAAI,EAAsB,IAAI,CAAC,CAAC;QAE3D,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC3B,CAAC;IACJ,CAAC;CAgBF;AApMD,wDAoMC;gZALsB,YAA6B;IAChD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACvC,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import {\n createServicePolicy,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n} from '@metamask/controller-utils';\nimport type { ServicePolicy } from '@metamask/controller-utils';\nimport type { IDisposable } from 'cockatiel';\n\nimport { BASE_URL } from '../constants.js';\nimport type {\n FeatureFlags,\n ClientType,\n DistributionType,\n EnvironmentType,\n ServiceResponse,\n ApiDataResponse,\n} from '../remote-feature-flag-controller-types.js';\nimport type { AbstractClientConfigApiService } from './abstract-client-config-api-service.js';\n\n/**\n * This service is responsible for fetching feature flags from the ClientConfig API.\n */\nexport class ClientConfigApiService implements AbstractClientConfigApiService {\n readonly #fetch: typeof fetch;\n\n readonly #policy: ServicePolicy;\n\n readonly #client: ClientType;\n\n readonly #distribution: DistributionType;\n\n readonly #environment: EnvironmentType;\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @deprecated This signature is deprecated; please use the `onBreak` and\n * `onDegraded` methods instead.\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.onBreak - Callback for when the circuit breaks, useful\n * for capturing metrics about network failures.\n * @param args.onDegraded - Callback for when the API responds successfully\n * but takes too long to respond (5 seconds or more).\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n constructor({\n fetch: fetchFunction,\n retries = DEFAULT_MAX_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n onBreak,\n onDegraded,\n config,\n }: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n }) {\n this.#fetch = fetchFunction;\n this.#client = config.client;\n this.#distribution = config.distribution;\n this.#environment = config.environment;\n\n this.#policy = createServicePolicy({\n maxRetries: retries,\n maxConsecutiveFailures: maximumConsecutiveFailures,\n circuitBreakDuration,\n });\n if (onBreak) {\n this.#policy.onBreak(onBreak);\n }\n if (onDegraded) {\n this.#policy.onDegraded(onDegraded);\n }\n }\n\n /**\n * Listens for when the request to the API fails too many times in a row.\n *\n * @param args - The same arguments that {@link ServicePolicy.onBreak}\n * takes.\n * @returns What {@link ServicePolicy.onBreak} returns.\n */\n onBreak(...args: Parameters<ServicePolicy['onBreak']>): IDisposable {\n return this.#policy.onBreak(...args);\n }\n\n /**\n * Listens for when the API is degraded.\n *\n * @param args - The same arguments that {@link ServicePolicy.onDegraded}\n * takes.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n */\n onDegraded(...args: Parameters<ServicePolicy['onDegraded']>): IDisposable {\n return this.#policy.onDegraded(...args);\n }\n\n /**\n * Fetches feature flags from the API with specific client, distribution, and environment parameters.\n * Provides structured error handling, including fallback to cached data if available.\n *\n * @returns An object of feature flags and their boolean values or a structured error object.\n */\n public async fetchRemoteFeatureFlags(): Promise<ServiceResponse> {\n const url = `${BASE_URL}/flags?client=${this.#client}&distribution=${\n this.#distribution\n }&environment=${this.#environment}`;\n\n const response = await this.#policy.execute(() =>\n this.#fetch(url, { cache: 'no-cache' }),\n );\n\n if (!response.ok) {\n throw new Error('Failed to fetch remote feature flags');\n }\n\n const data = await response.json();\n\n if (!Array.isArray(data)) {\n throw new Error('Feature flags api did not return an array');\n }\n\n const remoteFeatureFlags = this.#flattenFeatureFlags(data);\n\n return {\n remoteFeatureFlags,\n cacheTimestamp: Date.now(),\n };\n }\n\n /**\n * Flattens an array of feature flag objects into a single feature flags object.\n *\n * @param responseData - Array of objects containing feature flag key-value pairs\n * @returns A single object containing all feature flags merged together\n * @example\n * // Input: [{ flag1: true }, { flag2: [] }]\n * // Output: { flag1: true, flag2: [] }\n */\n #flattenFeatureFlags(responseData: ApiDataResponse): FeatureFlags {\n return responseData.reduce((acc, curr) => {\n return { ...acc, ...curr };\n }, {});\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-config-api-service.d.cts","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAG7C,OAAO,KAAK,EAEV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAEhB,oDAAmD;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,iDAAgD;AAE9F;;GAEG;AACH,qBAAa,sBAAuB,YAAW,8BAA8B;;IAW3E;;;;;;;;;;;;;;;;;;;;;OAqBG;gBACS,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;gBAES,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;QACxB,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAyCD;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,WAAW;IAInE;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG,WAAW;IAIzE;;;;;OAKG;IACU,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC;CAyCjE"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { ServicePolicy } from "@metamask/controller-utils";
|
|
2
|
-
import type { IDisposable } from "cockatiel";
|
|
3
|
-
import type { ClientType, DistributionType, EnvironmentType, ServiceResponse } from "../remote-feature-flag-controller-types.mjs";
|
|
4
|
-
import type { AbstractClientConfigApiService } from "./abstract-client-config-api-service.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* This service is responsible for fetching feature flags from the ClientConfig API.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ClientConfigApiService implements AbstractClientConfigApiService {
|
|
9
|
-
#private;
|
|
10
|
-
/**
|
|
11
|
-
* Constructs a new ClientConfigApiService object.
|
|
12
|
-
*
|
|
13
|
-
* @param args - The arguments.
|
|
14
|
-
* @param args.fetch - A function that can be used to make an HTTP request.
|
|
15
|
-
* If your JavaScript environment supports `fetch` natively, you'll probably
|
|
16
|
-
* want to pass that; otherwise you can pass an equivalent (such as `fetch`
|
|
17
|
-
* via `node-fetch`).
|
|
18
|
-
* @param args.retries - Number of retry attempts for each fetch request.
|
|
19
|
-
* @param args.maximumConsecutiveFailures - The maximum number of consecutive
|
|
20
|
-
* failures allowed before breaking the circuit and pausing further fetch
|
|
21
|
-
* attempts.
|
|
22
|
-
* @param args.circuitBreakDuration - The amount of time to wait when the
|
|
23
|
-
* circuit breaks from too many consecutive failures.
|
|
24
|
-
* @param args.config - The configuration object, includes client,
|
|
25
|
-
* distribution, and environment.
|
|
26
|
-
* @param args.config.client - The client type (e.g., 'extension', 'mobile').
|
|
27
|
-
* @param args.config.distribution - The distribution type (e.g., 'main',
|
|
28
|
-
* 'flask').
|
|
29
|
-
* @param args.config.environment - The environment type (e.g., 'prod', 'rc',
|
|
30
|
-
* 'dev').
|
|
31
|
-
*/
|
|
32
|
-
constructor(args: {
|
|
33
|
-
fetch: typeof fetch;
|
|
34
|
-
retries?: number;
|
|
35
|
-
maximumConsecutiveFailures?: number;
|
|
36
|
-
circuitBreakDuration?: number;
|
|
37
|
-
config: {
|
|
38
|
-
client: ClientType;
|
|
39
|
-
distribution: DistributionType;
|
|
40
|
-
environment: EnvironmentType;
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
/**
|
|
44
|
-
* Constructs a new ClientConfigApiService object.
|
|
45
|
-
*
|
|
46
|
-
* @deprecated This signature is deprecated; please use the `onBreak` and
|
|
47
|
-
* `onDegraded` methods instead.
|
|
48
|
-
* @param args - The arguments.
|
|
49
|
-
* @param args.fetch - A function that can be used to make an HTTP request.
|
|
50
|
-
* If your JavaScript environment supports `fetch` natively, you'll probably
|
|
51
|
-
* want to pass that; otherwise you can pass an equivalent (such as `fetch`
|
|
52
|
-
* via `node-fetch`).
|
|
53
|
-
* @param args.retries - Number of retry attempts for each fetch request.
|
|
54
|
-
* @param args.maximumConsecutiveFailures - The maximum number of consecutive
|
|
55
|
-
* failures allowed before breaking the circuit and pausing further fetch
|
|
56
|
-
* attempts.
|
|
57
|
-
* @param args.circuitBreakDuration - The amount of time to wait when the
|
|
58
|
-
* circuit breaks from too many consecutive failures.
|
|
59
|
-
* @param args.onBreak - Callback for when the circuit breaks, useful
|
|
60
|
-
* for capturing metrics about network failures.
|
|
61
|
-
* @param args.onDegraded - Callback for when the API responds successfully
|
|
62
|
-
* but takes too long to respond (5 seconds or more).
|
|
63
|
-
* @param args.config - The configuration object, includes client,
|
|
64
|
-
* distribution, and environment.
|
|
65
|
-
* @param args.config.client - The client type (e.g., 'extension', 'mobile').
|
|
66
|
-
* @param args.config.distribution - The distribution type (e.g., 'main',
|
|
67
|
-
* 'flask').
|
|
68
|
-
* @param args.config.environment - The environment type (e.g., 'prod', 'rc',
|
|
69
|
-
* 'dev').
|
|
70
|
-
*/
|
|
71
|
-
constructor(args: {
|
|
72
|
-
fetch: typeof fetch;
|
|
73
|
-
retries?: number;
|
|
74
|
-
maximumConsecutiveFailures?: number;
|
|
75
|
-
circuitBreakDuration?: number;
|
|
76
|
-
onBreak?: () => void;
|
|
77
|
-
onDegraded?: () => void;
|
|
78
|
-
config: {
|
|
79
|
-
client: ClientType;
|
|
80
|
-
distribution: DistributionType;
|
|
81
|
-
environment: EnvironmentType;
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
/**
|
|
85
|
-
* Listens for when the request to the API fails too many times in a row.
|
|
86
|
-
*
|
|
87
|
-
* @param args - The same arguments that {@link ServicePolicy.onBreak}
|
|
88
|
-
* takes.
|
|
89
|
-
* @returns What {@link ServicePolicy.onBreak} returns.
|
|
90
|
-
*/
|
|
91
|
-
onBreak(...args: Parameters<ServicePolicy['onBreak']>): IDisposable;
|
|
92
|
-
/**
|
|
93
|
-
* Listens for when the API is degraded.
|
|
94
|
-
*
|
|
95
|
-
* @param args - The same arguments that {@link ServicePolicy.onDegraded}
|
|
96
|
-
* takes.
|
|
97
|
-
* @returns What {@link ServicePolicy.onDegraded} returns.
|
|
98
|
-
*/
|
|
99
|
-
onDegraded(...args: Parameters<ServicePolicy['onDegraded']>): IDisposable;
|
|
100
|
-
/**
|
|
101
|
-
* Fetches feature flags from the API with specific client, distribution, and environment parameters.
|
|
102
|
-
* Provides structured error handling, including fallback to cached data if available.
|
|
103
|
-
*
|
|
104
|
-
* @returns An object of feature flags and their boolean values or a structured error object.
|
|
105
|
-
*/
|
|
106
|
-
fetchRemoteFeatureFlags(): Promise<ServiceResponse>;
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=client-config-api-service.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-config-api-service.d.mts","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAG7C,OAAO,KAAK,EAEV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAEhB,oDAAmD;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,iDAAgD;AAE9F;;GAEG;AACH,qBAAa,sBAAuB,YAAW,8BAA8B;;IAW3E;;;;;;;;;;;;;;;;;;;;;OAqBG;gBACS,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;gBAES,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;QACxB,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAyCD;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,WAAW;IAInE;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG,WAAW;IAIzE;;;;;OAKG;IACU,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC;CAyCjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-config-api-service.mjs","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,gCAAgC,EAChC,mBAAmB,EACpB,mCAAmC;AAIpC,OAAO,EAAE,QAAQ,EAAE,yBAAwB;AAW3C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAwFjC,YAAY,EACV,KAAK,EAAE,aAAa,EACpB,OAAO,GAAG,mBAAmB,EAC7B,0BAA0B,GAAG,gCAAgC,EAC7D,oBAAoB,GAAG,8BAA8B,EACrD,OAAO,EACP,UAAU,EACV,MAAM,GAaP;;QA3GQ,gDAAqB;QAErB,iDAAuB;QAEvB,iDAAoB;QAEpB,uDAAgC;QAEhC,sDAA8B;QAoGrC,uBAAA,IAAI,iCAAU,aAAa,MAAA,CAAC;QAC5B,uBAAA,IAAI,kCAAW,MAAM,CAAC,MAAM,MAAA,CAAC;QAC7B,uBAAA,IAAI,wCAAiB,MAAM,CAAC,YAAY,MAAA,CAAC;QACzC,uBAAA,IAAI,uCAAgB,MAAM,CAAC,WAAW,MAAA,CAAC;QAEvC,uBAAA,IAAI,kCAAW,mBAAmB,CAAC;YACjC,UAAU,EAAE,OAAO;YACnB,sBAAsB,EAAE,0BAA0B;YAClD,oBAAoB;SACrB,CAAC,MAAA,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAA0C;QACnD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAA6C;QACzD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,MAAM,GAAG,GAAG,GAAG,QAAQ,iBAAiB,uBAAA,IAAI,sCAAQ,iBAClD,uBAAA,IAAI,4CACN,gBAAgB,uBAAA,IAAI,2CAAa,EAAE,CAAC;QAEpC,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAC/C,uBAAA,IAAI,qCAAO,MAAX,IAAI,EAAQ,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CACxC,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,kBAAkB,GAAG,uBAAA,IAAI,sFAAqB,MAAzB,IAAI,EAAsB,IAAI,CAAC,CAAC;QAE3D,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC3B,CAAC;IACJ,CAAC;CAgBF;gZALsB,YAA6B;IAChD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACvC,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import {\n createServicePolicy,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n} from '@metamask/controller-utils';\nimport type { ServicePolicy } from '@metamask/controller-utils';\nimport type { IDisposable } from 'cockatiel';\n\nimport { BASE_URL } from '../constants.js';\nimport type {\n FeatureFlags,\n ClientType,\n DistributionType,\n EnvironmentType,\n ServiceResponse,\n ApiDataResponse,\n} from '../remote-feature-flag-controller-types.js';\nimport type { AbstractClientConfigApiService } from './abstract-client-config-api-service.js';\n\n/**\n * This service is responsible for fetching feature flags from the ClientConfig API.\n */\nexport class ClientConfigApiService implements AbstractClientConfigApiService {\n readonly #fetch: typeof fetch;\n\n readonly #policy: ServicePolicy;\n\n readonly #client: ClientType;\n\n readonly #distribution: DistributionType;\n\n readonly #environment: EnvironmentType;\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @deprecated This signature is deprecated; please use the `onBreak` and\n * `onDegraded` methods instead.\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.onBreak - Callback for when the circuit breaks, useful\n * for capturing metrics about network failures.\n * @param args.onDegraded - Callback for when the API responds successfully\n * but takes too long to respond (5 seconds or more).\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n constructor({\n fetch: fetchFunction,\n retries = DEFAULT_MAX_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n onBreak,\n onDegraded,\n config,\n }: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n }) {\n this.#fetch = fetchFunction;\n this.#client = config.client;\n this.#distribution = config.distribution;\n this.#environment = config.environment;\n\n this.#policy = createServicePolicy({\n maxRetries: retries,\n maxConsecutiveFailures: maximumConsecutiveFailures,\n circuitBreakDuration,\n });\n if (onBreak) {\n this.#policy.onBreak(onBreak);\n }\n if (onDegraded) {\n this.#policy.onDegraded(onDegraded);\n }\n }\n\n /**\n * Listens for when the request to the API fails too many times in a row.\n *\n * @param args - The same arguments that {@link ServicePolicy.onBreak}\n * takes.\n * @returns What {@link ServicePolicy.onBreak} returns.\n */\n onBreak(...args: Parameters<ServicePolicy['onBreak']>): IDisposable {\n return this.#policy.onBreak(...args);\n }\n\n /**\n * Listens for when the API is degraded.\n *\n * @param args - The same arguments that {@link ServicePolicy.onDegraded}\n * takes.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n */\n onDegraded(...args: Parameters<ServicePolicy['onDegraded']>): IDisposable {\n return this.#policy.onDegraded(...args);\n }\n\n /**\n * Fetches feature flags from the API with specific client, distribution, and environment parameters.\n * Provides structured error handling, including fallback to cached data if available.\n *\n * @returns An object of feature flags and their boolean values or a structured error object.\n */\n public async fetchRemoteFeatureFlags(): Promise<ServiceResponse> {\n const url = `${BASE_URL}/flags?client=${this.#client}&distribution=${\n this.#distribution\n }&environment=${this.#environment}`;\n\n const response = await this.#policy.execute(() =>\n this.#fetch(url, { cache: 'no-cache' }),\n );\n\n if (!response.ok) {\n throw new Error('Failed to fetch remote feature flags');\n }\n\n const data = await response.json();\n\n if (!Array.isArray(data)) {\n throw new Error('Feature flags api did not return an array');\n }\n\n const remoteFeatureFlags = this.#flattenFeatureFlags(data);\n\n return {\n remoteFeatureFlags,\n cacheTimestamp: Date.now(),\n };\n }\n\n /**\n * Flattens an array of feature flag objects into a single feature flags object.\n *\n * @param responseData - Array of objects containing feature flag key-value pairs\n * @returns A single object containing all feature flags merged together\n * @example\n * // Input: [{ flag1: true }, { flag2: [] }]\n * // Output: { flag1: true, flag2: [] }\n */\n #flattenFeatureFlags(responseData: ApiDataResponse): FeatureFlags {\n return responseData.reduce((acc, curr) => {\n return { ...acc, ...curr };\n }, {});\n }\n}\n"]}
|
package/dist/constants.cjs
DELETED
package/dist/constants.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,QAAQ,GAAG,6CAA6C,CAAC","sourcesContent":["/**\n * ClientConfig API base URL.\n */\nexport const BASE_URL = 'https://client-config.api.cx.metamask.io/v1';\n"]}
|
package/dist/constants.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,gDAAgD,CAAC"}
|
package/dist/constants.d.mts
DELETED
package/dist/constants.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,gDAAgD,CAAC"}
|
package/dist/constants.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,6CAA6C,CAAC","sourcesContent":["/**\n * ClientConfig API base URL.\n */\nexport const BASE_URL = 'https://client-config.api.cx.metamask.io/v1';\n"]}
|
package/dist/index.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateDeterministicRandomNumber = exports.ClientConfigApiService = exports.ThresholdVersion = exports.EnvironmentType = exports.DistributionType = exports.ClientType = exports.RemoteFeatureFlagController = void 0;
|
|
4
|
-
var remote_feature_flag_controller_js_1 = require("./remote-feature-flag-controller.cjs");
|
|
5
|
-
Object.defineProperty(exports, "RemoteFeatureFlagController", { enumerable: true, get: function () { return remote_feature_flag_controller_js_1.RemoteFeatureFlagController; } });
|
|
6
|
-
var remote_feature_flag_controller_types_js_1 = require("./remote-feature-flag-controller-types.cjs");
|
|
7
|
-
Object.defineProperty(exports, "ClientType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.ClientType; } });
|
|
8
|
-
Object.defineProperty(exports, "DistributionType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.DistributionType; } });
|
|
9
|
-
Object.defineProperty(exports, "EnvironmentType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.EnvironmentType; } });
|
|
10
|
-
Object.defineProperty(exports, "ThresholdVersion", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.ThresholdVersion; } });
|
|
11
|
-
var client_config_api_service_js_1 = require("./client-config-api-service/client-config-api-service.cjs");
|
|
12
|
-
Object.defineProperty(exports, "ClientConfigApiService", { enumerable: true, get: function () { return client_config_api_service_js_1.ClientConfigApiService; } });
|
|
13
|
-
var user_segmentation_utils_js_1 = require("./utils/user-segmentation-utils.cjs");
|
|
14
|
-
Object.defineProperty(exports, "generateDeterministicRandomNumber", { enumerable: true, get: function () { return user_segmentation_utils_js_1.generateDeterministicRandomNumber; } });
|
|
15
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,0FAAkF;AAAzE,gJAAA,2BAA2B,OAAA;AAkBpC,sGAKmD;AAJjD,qIAAA,UAAU,OAAA;AACV,2IAAA,gBAAgB,OAAA;AAChB,0IAAA,eAAe,OAAA;AACf,2IAAA,gBAAgB,OAAA;AAIlB,0GAAkG;AAAzF,sIAAA,sBAAsB,OAAA;AAC/B,kFAAuF;AAA9E,+IAAA,iCAAiC,OAAA","sourcesContent":["export { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerMessenger,\n RemoteFeatureFlagControllerActions,\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerEvents,\n RemoteFeatureFlagControllerStateChangeEvent,\n} from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerClearAllFlagOverridesAction,\n RemoteFeatureFlagControllerDisableAction,\n RemoteFeatureFlagControllerEnableAction,\n RemoteFeatureFlagControllerMethodActions,\n RemoteFeatureFlagControllerRemoveFlagOverrideAction,\n RemoteFeatureFlagControllerSetFlagOverrideAction,\n RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction,\n} from './remote-feature-flag-controller-method-action-types.js';\nexport {\n ClientType,\n DistributionType,\n EnvironmentType,\n ThresholdVersion,\n} from './remote-feature-flag-controller-types.js';\n\nexport type { FeatureFlags } from './remote-feature-flag-controller-types.js';\nexport { ClientConfigApiService } from './client-config-api-service/client-config-api-service.js';\nexport { generateDeterministicRandomNumber } from './utils/user-segmentation-utils.js';\n"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.cjs";
|
|
2
|
-
export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerMessenger, RemoteFeatureFlagControllerActions, RemoteFeatureFlagControllerGetStateAction, RemoteFeatureFlagControllerEvents, RemoteFeatureFlagControllerStateChangeEvent, } from "./remote-feature-flag-controller.cjs";
|
|
3
|
-
export type { RemoteFeatureFlagControllerClearAllFlagOverridesAction, RemoteFeatureFlagControllerDisableAction, RemoteFeatureFlagControllerEnableAction, RemoteFeatureFlagControllerMethodActions, RemoteFeatureFlagControllerRemoveFlagOverrideAction, RemoteFeatureFlagControllerSetFlagOverrideAction, RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction, } from "./remote-feature-flag-controller-method-action-types.cjs";
|
|
4
|
-
export { ClientType, DistributionType, EnvironmentType, ThresholdVersion, } from "./remote-feature-flag-controller-types.cjs";
|
|
5
|
-
export type { FeatureFlags } from "./remote-feature-flag-controller-types.cjs";
|
|
6
|
-
export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.cjs";
|
|
7
|
-
export { generateDeterministicRandomNumber } from "./utils/user-segmentation-utils.cjs";
|
|
8
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAA4C;AAClF,YAAY,EACV,gCAAgC,EAChC,oCAAoC,EACpC,kCAAkC,EAClC,yCAAyC,EACzC,iCAAiC,EACjC,2CAA2C,GAC5C,6CAA4C;AAC7C,YAAY,EACV,sDAAsD,EACtD,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,mDAAmD,EACnD,gDAAgD,EAChD,yDAAyD,GAC1D,iEAAgE;AACjE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,mDAAkD;AAEnD,YAAY,EAAE,YAAY,EAAE,mDAAkD;AAC9E,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,OAAO,EAAE,iCAAiC,EAAE,4CAA2C"}
|
package/dist/index.d.mts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
|
|
2
|
-
export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerMessenger, RemoteFeatureFlagControllerActions, RemoteFeatureFlagControllerGetStateAction, RemoteFeatureFlagControllerEvents, RemoteFeatureFlagControllerStateChangeEvent, } from "./remote-feature-flag-controller.mjs";
|
|
3
|
-
export type { RemoteFeatureFlagControllerClearAllFlagOverridesAction, RemoteFeatureFlagControllerDisableAction, RemoteFeatureFlagControllerEnableAction, RemoteFeatureFlagControllerMethodActions, RemoteFeatureFlagControllerRemoveFlagOverrideAction, RemoteFeatureFlagControllerSetFlagOverrideAction, RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction, } from "./remote-feature-flag-controller-method-action-types.mjs";
|
|
4
|
-
export { ClientType, DistributionType, EnvironmentType, ThresholdVersion, } from "./remote-feature-flag-controller-types.mjs";
|
|
5
|
-
export type { FeatureFlags } from "./remote-feature-flag-controller-types.mjs";
|
|
6
|
-
export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.mjs";
|
|
7
|
-
export { generateDeterministicRandomNumber } from "./utils/user-segmentation-utils.mjs";
|
|
8
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAA4C;AAClF,YAAY,EACV,gCAAgC,EAChC,oCAAoC,EACpC,kCAAkC,EAClC,yCAAyC,EACzC,iCAAiC,EACjC,2CAA2C,GAC5C,6CAA4C;AAC7C,YAAY,EACV,sDAAsD,EACtD,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,mDAAmD,EACnD,gDAAgD,EAChD,yDAAyD,GAC1D,iEAAgE;AACjE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,mDAAkD;AAEnD,YAAY,EAAE,YAAY,EAAE,mDAAkD;AAC9E,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,OAAO,EAAE,iCAAiC,EAAE,4CAA2C"}
|
package/dist/index.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
|
|
2
|
-
export { ClientType, DistributionType, EnvironmentType, ThresholdVersion } from "./remote-feature-flag-controller-types.mjs";
|
|
3
|
-
export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.mjs";
|
|
4
|
-
export { generateDeterministicRandomNumber } from "./utils/user-segmentation-utils.mjs";
|
|
5
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAA4C;AAkBlF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,mDAAkD;AAGnD,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,OAAO,EAAE,iCAAiC,EAAE,4CAA2C","sourcesContent":["export { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerMessenger,\n RemoteFeatureFlagControllerActions,\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerEvents,\n RemoteFeatureFlagControllerStateChangeEvent,\n} from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerClearAllFlagOverridesAction,\n RemoteFeatureFlagControllerDisableAction,\n RemoteFeatureFlagControllerEnableAction,\n RemoteFeatureFlagControllerMethodActions,\n RemoteFeatureFlagControllerRemoveFlagOverrideAction,\n RemoteFeatureFlagControllerSetFlagOverrideAction,\n RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction,\n} from './remote-feature-flag-controller-method-action-types.js';\nexport {\n ClientType,\n DistributionType,\n EnvironmentType,\n ThresholdVersion,\n} from './remote-feature-flag-controller-types.js';\n\nexport type { FeatureFlags } from './remote-feature-flag-controller-types.js';\nexport { ClientConfigApiService } from './client-config-api-service/client-config-api-service.js';\nexport { generateDeterministicRandomNumber } from './utils/user-segmentation-utils.js';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\n\n/**\n * Retrieves the remote feature flags, fetching from the API if necessary.\n * Uses caching to prevent redundant API calls and handles concurrent fetches.\n *\n * @param force - When `true`, fetch even if the cache has not expired.\n * Defaults to `false`. Has no effect when the controller is disabled.\n * @returns A promise that resolves to the current set of feature flags.\n */\nexport type RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction = {\n type: `RemoteFeatureFlagController:updateRemoteFeatureFlags`;\n handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];\n};\n\n/**\n * Enables the controller, allowing it to make network requests.\n */\nexport type RemoteFeatureFlagControllerEnableAction = {\n type: `RemoteFeatureFlagController:enable`;\n handler: RemoteFeatureFlagController['enable'];\n};\n\n/**\n * Disables the controller, preventing it from making network requests.\n */\nexport type RemoteFeatureFlagControllerDisableAction = {\n type: `RemoteFeatureFlagController:disable`;\n handler: RemoteFeatureFlagController['disable'];\n};\n\n/**\n * Sets a local override for a specific feature flag.\n *\n * @param flagName - The name of the feature flag to override.\n * @param value - The override value for the feature flag.\n */\nexport type RemoteFeatureFlagControllerSetFlagOverrideAction = {\n type: `RemoteFeatureFlagController:setFlagOverride`;\n handler: RemoteFeatureFlagController['setFlagOverride'];\n};\n\n/**\n * Clears the local override for a specific feature flag.\n *\n * @param flagName - The name of the feature flag to clear.\n */\nexport type RemoteFeatureFlagControllerRemoveFlagOverrideAction = {\n type: `RemoteFeatureFlagController:removeFlagOverride`;\n handler: RemoteFeatureFlagController['removeFlagOverride'];\n};\n\n/**\n * Clears all local feature flag overrides.\n */\nexport type RemoteFeatureFlagControllerClearAllFlagOverridesAction = {\n type: `RemoteFeatureFlagController:clearAllFlagOverrides`;\n handler: RemoteFeatureFlagController['clearAllFlagOverrides'];\n};\n\n/**\n * Union of all RemoteFeatureFlagController action types.\n */\nexport type RemoteFeatureFlagControllerMethodActions =\n | RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction\n | RemoteFeatureFlagControllerEnableAction\n | RemoteFeatureFlagControllerDisableAction\n | RemoteFeatureFlagControllerSetFlagOverrideAction\n | RemoteFeatureFlagControllerRemoveFlagOverrideAction\n | RemoteFeatureFlagControllerClearAllFlagOverridesAction;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,6CAA4C;AAEvF;;;;;;;GAOG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,2BAA2B,CAAC,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,yDAAyD,GACzD,uCAAuC,GACvC,wCAAwC,GACxC,gDAAgD,GAChD,mDAAmD,GACnD,sDAAsD,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves the remote feature flags, fetching from the API if necessary.
|
|
8
|
-
* Uses caching to prevent redundant API calls and handles concurrent fetches.
|
|
9
|
-
*
|
|
10
|
-
* @param force - When `true`, fetch even if the cache has not expired.
|
|
11
|
-
* Defaults to `false`. Has no effect when the controller is disabled.
|
|
12
|
-
* @returns A promise that resolves to the current set of feature flags.
|
|
13
|
-
*/
|
|
14
|
-
export type RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction = {
|
|
15
|
-
type: `RemoteFeatureFlagController:updateRemoteFeatureFlags`;
|
|
16
|
-
handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Enables the controller, allowing it to make network requests.
|
|
20
|
-
*/
|
|
21
|
-
export type RemoteFeatureFlagControllerEnableAction = {
|
|
22
|
-
type: `RemoteFeatureFlagController:enable`;
|
|
23
|
-
handler: RemoteFeatureFlagController['enable'];
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Disables the controller, preventing it from making network requests.
|
|
27
|
-
*/
|
|
28
|
-
export type RemoteFeatureFlagControllerDisableAction = {
|
|
29
|
-
type: `RemoteFeatureFlagController:disable`;
|
|
30
|
-
handler: RemoteFeatureFlagController['disable'];
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Sets a local override for a specific feature flag.
|
|
34
|
-
*
|
|
35
|
-
* @param flagName - The name of the feature flag to override.
|
|
36
|
-
* @param value - The override value for the feature flag.
|
|
37
|
-
*/
|
|
38
|
-
export type RemoteFeatureFlagControllerSetFlagOverrideAction = {
|
|
39
|
-
type: `RemoteFeatureFlagController:setFlagOverride`;
|
|
40
|
-
handler: RemoteFeatureFlagController['setFlagOverride'];
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Clears the local override for a specific feature flag.
|
|
44
|
-
*
|
|
45
|
-
* @param flagName - The name of the feature flag to clear.
|
|
46
|
-
*/
|
|
47
|
-
export type RemoteFeatureFlagControllerRemoveFlagOverrideAction = {
|
|
48
|
-
type: `RemoteFeatureFlagController:removeFlagOverride`;
|
|
49
|
-
handler: RemoteFeatureFlagController['removeFlagOverride'];
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Clears all local feature flag overrides.
|
|
53
|
-
*/
|
|
54
|
-
export type RemoteFeatureFlagControllerClearAllFlagOverridesAction = {
|
|
55
|
-
type: `RemoteFeatureFlagController:clearAllFlagOverrides`;
|
|
56
|
-
handler: RemoteFeatureFlagController['clearAllFlagOverrides'];
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Union of all RemoteFeatureFlagController action types.
|
|
60
|
-
*/
|
|
61
|
-
export type RemoteFeatureFlagControllerMethodActions = RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction | RemoteFeatureFlagControllerEnableAction | RemoteFeatureFlagControllerDisableAction | RemoteFeatureFlagControllerSetFlagOverrideAction | RemoteFeatureFlagControllerRemoveFlagOverrideAction | RemoteFeatureFlagControllerClearAllFlagOverridesAction;
|
|
62
|
-
//# sourceMappingURL=remote-feature-flag-controller-method-action-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,6CAA4C;AAEvF;;;;;;;GAOG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,2BAA2B,CAAC,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,yDAAyD,GACzD,uCAAuC,GACvC,wCAAwC,GACxC,gDAAgD,GAChD,mDAAmD,GACnD,sDAAsD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\n\n/**\n * Retrieves the remote feature flags, fetching from the API if necessary.\n * Uses caching to prevent redundant API calls and handles concurrent fetches.\n *\n * @param force - When `true`, fetch even if the cache has not expired.\n * Defaults to `false`. Has no effect when the controller is disabled.\n * @returns A promise that resolves to the current set of feature flags.\n */\nexport type RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction = {\n type: `RemoteFeatureFlagController:updateRemoteFeatureFlags`;\n handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];\n};\n\n/**\n * Enables the controller, allowing it to make network requests.\n */\nexport type RemoteFeatureFlagControllerEnableAction = {\n type: `RemoteFeatureFlagController:enable`;\n handler: RemoteFeatureFlagController['enable'];\n};\n\n/**\n * Disables the controller, preventing it from making network requests.\n */\nexport type RemoteFeatureFlagControllerDisableAction = {\n type: `RemoteFeatureFlagController:disable`;\n handler: RemoteFeatureFlagController['disable'];\n};\n\n/**\n * Sets a local override for a specific feature flag.\n *\n * @param flagName - The name of the feature flag to override.\n * @param value - The override value for the feature flag.\n */\nexport type RemoteFeatureFlagControllerSetFlagOverrideAction = {\n type: `RemoteFeatureFlagController:setFlagOverride`;\n handler: RemoteFeatureFlagController['setFlagOverride'];\n};\n\n/**\n * Clears the local override for a specific feature flag.\n *\n * @param flagName - The name of the feature flag to clear.\n */\nexport type RemoteFeatureFlagControllerRemoveFlagOverrideAction = {\n type: `RemoteFeatureFlagController:removeFlagOverride`;\n handler: RemoteFeatureFlagController['removeFlagOverride'];\n};\n\n/**\n * Clears all local feature flag overrides.\n */\nexport type RemoteFeatureFlagControllerClearAllFlagOverridesAction = {\n type: `RemoteFeatureFlagController:clearAllFlagOverrides`;\n handler: RemoteFeatureFlagController['clearAllFlagOverrides'];\n};\n\n/**\n * Union of all RemoteFeatureFlagController action types.\n */\nexport type RemoteFeatureFlagControllerMethodActions =\n | RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction\n | RemoteFeatureFlagControllerEnableAction\n | RemoteFeatureFlagControllerDisableAction\n | RemoteFeatureFlagControllerSetFlagOverrideAction\n | RemoteFeatureFlagControllerRemoveFlagOverrideAction\n | RemoteFeatureFlagControllerClearAllFlagOverridesAction;\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThresholdVersion = exports.EnvironmentType = exports.DistributionType = exports.ClientType = void 0;
|
|
4
|
-
// Define accepted values for client, distribution, and environment
|
|
5
|
-
var ClientType;
|
|
6
|
-
(function (ClientType) {
|
|
7
|
-
ClientType["Extension"] = "extension";
|
|
8
|
-
ClientType["Mobile"] = "mobile";
|
|
9
|
-
})(ClientType || (exports.ClientType = ClientType = {}));
|
|
10
|
-
var DistributionType;
|
|
11
|
-
(function (DistributionType) {
|
|
12
|
-
DistributionType["Main"] = "main";
|
|
13
|
-
DistributionType["Flask"] = "flask";
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use DistributionType Main with EnvironmentType Beta instead
|
|
16
|
-
*/
|
|
17
|
-
DistributionType["Beta"] = "beta";
|
|
18
|
-
})(DistributionType || (exports.DistributionType = DistributionType = {}));
|
|
19
|
-
var EnvironmentType;
|
|
20
|
-
(function (EnvironmentType) {
|
|
21
|
-
EnvironmentType["Production"] = "prod";
|
|
22
|
-
EnvironmentType["ReleaseCandidate"] = "rc";
|
|
23
|
-
EnvironmentType["Development"] = "dev";
|
|
24
|
-
EnvironmentType["Beta"] = "beta";
|
|
25
|
-
EnvironmentType["Test"] = "test";
|
|
26
|
-
EnvironmentType["Exp"] = "exp";
|
|
27
|
-
})(EnvironmentType || (exports.EnvironmentType = EnvironmentType = {}));
|
|
28
|
-
var ThresholdVersion;
|
|
29
|
-
(function (ThresholdVersion) {
|
|
30
|
-
ThresholdVersion[ThresholdVersion["DirectValue"] = 2] = "DirectValue";
|
|
31
|
-
})(ThresholdVersion || (exports.ThresholdVersion = ThresholdVersion = {}));
|
|
32
|
-
//# sourceMappingURL=remote-feature-flag-controller-types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-types.cjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":";;;AAEA,mEAAmE;AACnE,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,mCAAe,CAAA;IACf;;OAEG;IACH,iCAAa,CAAA;AACf,CAAC,EAPW,gBAAgB,gCAAhB,gBAAgB,QAO3B;AAED,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,8BAAW,CAAA;AACb,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAiBD,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,qEAAe,CAAA;AACjB,CAAC,EAFW,gBAAgB,gCAAhB,gBAAgB,QAE3B","sourcesContent":["import type { Json, SemVerVersion } from '@metamask/utils';\n\n// Define accepted values for client, distribution, and environment\nexport enum ClientType {\n Extension = 'extension',\n Mobile = 'mobile',\n}\n\nexport enum DistributionType {\n Main = 'main',\n Flask = 'flask',\n /**\n * @deprecated Use DistributionType Main with EnvironmentType Beta instead\n */\n Beta = 'beta',\n}\n\nexport enum EnvironmentType {\n Production = 'prod',\n ReleaseCandidate = 'rc',\n Development = 'dev',\n Beta = 'beta',\n Test = 'test',\n Exp = 'exp',\n}\n\n/** Type representing a feature flag with multiple version entries */\nexport type MultiVersionFeatureFlagValue = {\n versions: Record<SemVerVersion, Json>;\n};\n\n/** Type representing the feature flags collection */\nexport type FeatureFlags = {\n [key: string]: Json;\n};\n\nexport type FeatureFlagScope = {\n type: string;\n value: number;\n};\n\nexport enum ThresholdVersion {\n DirectValue = 2,\n}\n\nexport type FeatureFlagScopeValue = {\n name: string;\n /**\n * Optional label for direct-value threshold entries. This replaces `name` in\n * v2 configurations and is not emitted in processed controller state.\n */\n thresholdName?: string;\n /**\n * Selects the threshold entry output shape. Unrecognized versions fall back\n * to the legacy `{ name, value }` wrapper for backwards compatibility.\n */\n thresholdVersion?: ThresholdVersion;\n scope: FeatureFlagScope;\n value: Json;\n /**\n * Optional list of MetaMetrics IDs to explicitly target. When the current\n * user's MetaMetrics ID matches any entry in this list, this threshold group\n * is selected immediately, bypassing hash-based rollout. Intended for QA and\n * Product Manager testing only, not general-purpose segmentation.\n */\n metaMetricsIds?: string[];\n};\n\nexport type ApiDataResponse = FeatureFlags[];\n\nexport type ServiceResponse = {\n remoteFeatureFlags: FeatureFlags;\n cacheTimestamp: number | null;\n};\n"]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Json, SemVerVersion } from "@metamask/utils";
|
|
2
|
-
export declare enum ClientType {
|
|
3
|
-
Extension = "extension",
|
|
4
|
-
Mobile = "mobile"
|
|
5
|
-
}
|
|
6
|
-
export declare enum DistributionType {
|
|
7
|
-
Main = "main",
|
|
8
|
-
Flask = "flask",
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use DistributionType Main with EnvironmentType Beta instead
|
|
11
|
-
*/
|
|
12
|
-
Beta = "beta"
|
|
13
|
-
}
|
|
14
|
-
export declare enum EnvironmentType {
|
|
15
|
-
Production = "prod",
|
|
16
|
-
ReleaseCandidate = "rc",
|
|
17
|
-
Development = "dev",
|
|
18
|
-
Beta = "beta",
|
|
19
|
-
Test = "test",
|
|
20
|
-
Exp = "exp"
|
|
21
|
-
}
|
|
22
|
-
/** Type representing a feature flag with multiple version entries */
|
|
23
|
-
export type MultiVersionFeatureFlagValue = {
|
|
24
|
-
versions: Record<SemVerVersion, Json>;
|
|
25
|
-
};
|
|
26
|
-
/** Type representing the feature flags collection */
|
|
27
|
-
export type FeatureFlags = {
|
|
28
|
-
[key: string]: Json;
|
|
29
|
-
};
|
|
30
|
-
export type FeatureFlagScope = {
|
|
31
|
-
type: string;
|
|
32
|
-
value: number;
|
|
33
|
-
};
|
|
34
|
-
export declare enum ThresholdVersion {
|
|
35
|
-
DirectValue = 2
|
|
36
|
-
}
|
|
37
|
-
export type FeatureFlagScopeValue = {
|
|
38
|
-
name: string;
|
|
39
|
-
/**
|
|
40
|
-
* Optional label for direct-value threshold entries. This replaces `name` in
|
|
41
|
-
* v2 configurations and is not emitted in processed controller state.
|
|
42
|
-
*/
|
|
43
|
-
thresholdName?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Selects the threshold entry output shape. Unrecognized versions fall back
|
|
46
|
-
* to the legacy `{ name, value }` wrapper for backwards compatibility.
|
|
47
|
-
*/
|
|
48
|
-
thresholdVersion?: ThresholdVersion;
|
|
49
|
-
scope: FeatureFlagScope;
|
|
50
|
-
value: Json;
|
|
51
|
-
/**
|
|
52
|
-
* Optional list of MetaMetrics IDs to explicitly target. When the current
|
|
53
|
-
* user's MetaMetrics ID matches any entry in this list, this threshold group
|
|
54
|
-
* is selected immediately, bypassing hash-based rollout. Intended for QA and
|
|
55
|
-
* Product Manager testing only, not general-purpose segmentation.
|
|
56
|
-
*/
|
|
57
|
-
metaMetricsIds?: string[];
|
|
58
|
-
};
|
|
59
|
-
export type ApiDataResponse = FeatureFlags[];
|
|
60
|
-
export type ServiceResponse = {
|
|
61
|
-
remoteFeatureFlags: FeatureFlags;
|
|
62
|
-
cacheTimestamp: number | null;
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=remote-feature-flag-controller-types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-types.d.cts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,oBAAY,UAAU;IACpB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,KAAK,UAAU;IACf;;OAEG;IACH,IAAI,SAAS;CACd;AAED,oBAAY,eAAe;IACzB,UAAU,SAAS;IACnB,gBAAgB,OAAO;IACvB,WAAW,QAAQ;IACnB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ;AAED,qEAAqE;AACrE,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,gBAAgB;IAC1B,WAAW,IAAI;CAChB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,IAAI,CAAC;IACZ;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,EAAE,CAAC;AAE7C,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,YAAY,CAAC;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-types.d.mts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,oBAAY,UAAU;IACpB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,KAAK,UAAU;IACf;;OAEG;IACH,IAAI,SAAS;CACd;AAED,oBAAY,eAAe;IACzB,UAAU,SAAS;IACnB,gBAAgB,OAAO;IACvB,WAAW,QAAQ;IACnB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ;AAED,qEAAqE;AACrE,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,EAAE,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,gBAAgB;IAC1B,WAAW,IAAI;CAChB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,IAAI,CAAC;IACZ;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,EAAE,CAAC;AAE7C,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,YAAY,CAAC;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-feature-flag-controller-types.mjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAED,MAAM,CAAN,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,mCAAe,CAAA;IACf;;OAEG;IACH,iCAAa,CAAA;AACf,CAAC,EAPW,gBAAgB,KAAhB,gBAAgB,QAO3B;AAED,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,8BAAW,CAAA;AACb,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAiBD,MAAM,CAAN,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC1B,qEAAe,CAAA;AACjB,CAAC,EAFW,gBAAgB,KAAhB,gBAAgB,QAE3B","sourcesContent":["import type { Json, SemVerVersion } from '@metamask/utils';\n\n// Define accepted values for client, distribution, and environment\nexport enum ClientType {\n Extension = 'extension',\n Mobile = 'mobile',\n}\n\nexport enum DistributionType {\n Main = 'main',\n Flask = 'flask',\n /**\n * @deprecated Use DistributionType Main with EnvironmentType Beta instead\n */\n Beta = 'beta',\n}\n\nexport enum EnvironmentType {\n Production = 'prod',\n ReleaseCandidate = 'rc',\n Development = 'dev',\n Beta = 'beta',\n Test = 'test',\n Exp = 'exp',\n}\n\n/** Type representing a feature flag with multiple version entries */\nexport type MultiVersionFeatureFlagValue = {\n versions: Record<SemVerVersion, Json>;\n};\n\n/** Type representing the feature flags collection */\nexport type FeatureFlags = {\n [key: string]: Json;\n};\n\nexport type FeatureFlagScope = {\n type: string;\n value: number;\n};\n\nexport enum ThresholdVersion {\n DirectValue = 2,\n}\n\nexport type FeatureFlagScopeValue = {\n name: string;\n /**\n * Optional label for direct-value threshold entries. This replaces `name` in\n * v2 configurations and is not emitted in processed controller state.\n */\n thresholdName?: string;\n /**\n * Selects the threshold entry output shape. Unrecognized versions fall back\n * to the legacy `{ name, value }` wrapper for backwards compatibility.\n */\n thresholdVersion?: ThresholdVersion;\n scope: FeatureFlagScope;\n value: Json;\n /**\n * Optional list of MetaMetrics IDs to explicitly target. When the current\n * user's MetaMetrics ID matches any entry in this list, this threshold group\n * is selected immediately, bypassing hash-based rollout. Intended for QA and\n * Product Manager testing only, not general-purpose segmentation.\n */\n metaMetricsIds?: string[];\n};\n\nexport type ApiDataResponse = FeatureFlags[];\n\nexport type ServiceResponse = {\n remoteFeatureFlags: FeatureFlags;\n cacheTimestamp: number | null;\n};\n"]}
|