@metamask-previews/remote-feature-flag-controller 6.1.1-preview-abca9bcea → 7.0.0-preview-97d6b86c0
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 +19 -1
- 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.js +86 -0
- 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.js +470 -0
- package/dist/{remote-feature-flag-controller.cjs.map → remote-feature-flag-controller.js.map} +1 -1
- 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} +5 -5
- 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 +16 -20
- 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 +0 -90
- 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 -453
- 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 +0 -448
- 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
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Bump `uuid` from `^8.3.2` to `^9.0.1` ([#10117](https://github.com/MetaMask/core/pull/10117))
|
|
13
|
+
|
|
14
|
+
## [7.0.0]
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536))
|
|
19
|
+
- This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions.
|
|
20
|
+
- **BREAKING:** Bump minimum Node.js version to 22 ([#9976](https://github.com/MetaMask/core/pull/9976))
|
|
21
|
+
- **BREAKING:** Bump TypeScript target to ES2022 ([#10019](https://github.com/MetaMask/core/pull/10019))
|
|
22
|
+
- This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume.
|
|
23
|
+
- Bump `@metamask/base-controller` from `^9.1.0` to `^10.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
|
|
24
|
+
- Bump `@metamask/controller-utils` from `^12.3.0` to `^13.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
|
|
25
|
+
- Bump `@metamask/messenger` from `^2.0.0` to `^3.0.0` ([#10160](https://github.com/MetaMask/core/pull/10160))
|
|
26
|
+
|
|
10
27
|
## [6.1.1]
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -282,7 +299,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
282
299
|
- Initial release of the RemoteFeatureFlagController. ([#4931](https://github.com/MetaMask/core/pull/4931))
|
|
283
300
|
- This controller manages the retrieval and caching of remote feature flags. It fetches feature flags from a remote API, caches them, and provides methods to access and manage these flags. The controller ensures that feature flags are refreshed based on a specified interval and handles cases where the controller is disabled or the network is unavailable.
|
|
284
301
|
|
|
285
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/remote-feature-flag-controller@
|
|
302
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/remote-feature-flag-controller@7.0.0...HEAD
|
|
303
|
+
[7.0.0]: https://github.com/MetaMask/core/compare/@metamask/remote-feature-flag-controller@6.1.1...@metamask/remote-feature-flag-controller@7.0.0
|
|
286
304
|
[6.1.1]: https://github.com/MetaMask/core/compare/@metamask/remote-feature-flag-controller@6.1.0...@metamask/remote-feature-flag-controller@6.1.1
|
|
287
305
|
[6.1.0]: https://github.com/MetaMask/core/compare/@metamask/remote-feature-flag-controller@6.0.0...@metamask/remote-feature-flag-controller@6.1.0
|
|
288
306
|
[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/remote-feature-flag-controller@5.0.0...@metamask/remote-feature-flag-controller@6.0.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServicePolicy } from
|
|
2
|
-
import type { ServiceResponse } from
|
|
1
|
+
import type { ServicePolicy } from '@metamask/controller-utils';
|
|
2
|
+
import type { ServiceResponse } from '../remote-feature-flag-controller-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* A service object responsible for fetching feature flags.
|
|
5
5
|
*/
|
|
@@ -14,4 +14,4 @@ export type AbstractClientConfigApiService = Partial<Pick<ServicePolicy, 'onBrea
|
|
|
14
14
|
*/
|
|
15
15
|
fetchRemoteFeatureFlags(): Promise<ServiceResponse>;
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=abstract-client-config-api-service.d.
|
|
17
|
+
//# sourceMappingURL=abstract-client-config-api-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-client-config-api-service.d.ts","sourceRoot":"","sources":["../../src/client-config-api-service/abstract-client-config-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,OAAO,CAClD,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,CAAC,CAC9C,GAAG;IACF;;;;;;;OAOG;IACH,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-client-config-api-service.js","sourceRoot":"","sources":["../../src/client-config-api-service/abstract-client-config-api-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\n\nimport type { ServiceResponse } from '../remote-feature-flag-controller-types.js';\n\n/**\n * A service object responsible for fetching feature flags.\n */\nexport type AbstractClientConfigApiService = Partial<\n Pick<ServicePolicy, 'onBreak' | 'onDegraded'>\n> & {\n /**\n * Fetches feature flags from the API with specific client, distribution, and\n * environment parameters. Provides structured error handling, including\n * fallback to cached data if available.\n *\n * @returns An object of feature flags and their boolean values or a\n * structured error object.\n */\n fetchRemoteFeatureFlags(): Promise<ServiceResponse>;\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ServicePolicy } from
|
|
2
|
-
import type { IDisposable } from
|
|
3
|
-
import type { ClientType, DistributionType, EnvironmentType, ServiceResponse } from
|
|
4
|
-
import type { AbstractClientConfigApiService } from
|
|
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.js';
|
|
4
|
+
import type { AbstractClientConfigApiService } from './abstract-client-config-api-service.js';
|
|
5
5
|
/**
|
|
6
6
|
* This service is responsible for fetching feature flags from the ClientConfig API.
|
|
7
7
|
*/
|
|
@@ -105,4 +105,4 @@ export declare class ClientConfigApiService implements AbstractClientConfigApiSe
|
|
|
105
105
|
*/
|
|
106
106
|
fetchRemoteFeatureFlags(): Promise<ServiceResponse>;
|
|
107
107
|
}
|
|
108
|
-
//# sourceMappingURL=client-config-api-service.d.
|
|
108
|
+
//# sourceMappingURL=client-config-api-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-config-api-service.d.ts","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EAEV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAEhB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAE9F;;GAEG;AACH,qBAAa,sBAAuB,YAAW,8BAA8B;;IAW3E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,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,EAAE;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IAEH,YAAY,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,EAAE;IAyCH;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,WAAW,CAElE;IAED;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG,WAAW,CAExE;IAED;;;;;OAKG;IACU,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC,CAyB/D;CAgBF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createServicePolicy, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, } from '@metamask/controller-utils';
|
|
2
|
+
import { BASE_URL } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* This service is responsible for fetching feature flags from the ClientConfig API.
|
|
5
|
+
*/
|
|
6
|
+
export class ClientConfigApiService {
|
|
7
|
+
#fetch;
|
|
8
|
+
#policy;
|
|
9
|
+
#client;
|
|
10
|
+
#distribution;
|
|
11
|
+
#environment;
|
|
12
|
+
constructor({ fetch: fetchFunction, retries = DEFAULT_MAX_RETRIES, maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES, circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION, onBreak, onDegraded, config, }) {
|
|
13
|
+
this.#fetch = fetchFunction;
|
|
14
|
+
this.#client = config.client;
|
|
15
|
+
this.#distribution = config.distribution;
|
|
16
|
+
this.#environment = config.environment;
|
|
17
|
+
this.#policy = createServicePolicy({
|
|
18
|
+
maxRetries: retries,
|
|
19
|
+
maxConsecutiveFailures: maximumConsecutiveFailures,
|
|
20
|
+
circuitBreakDuration,
|
|
21
|
+
});
|
|
22
|
+
if (onBreak) {
|
|
23
|
+
this.#policy.onBreak(onBreak);
|
|
24
|
+
}
|
|
25
|
+
if (onDegraded) {
|
|
26
|
+
this.#policy.onDegraded(onDegraded);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Listens for when the request to the API fails too many times in a row.
|
|
31
|
+
*
|
|
32
|
+
* @param args - The same arguments that {@link ServicePolicy.onBreak}
|
|
33
|
+
* takes.
|
|
34
|
+
* @returns What {@link ServicePolicy.onBreak} returns.
|
|
35
|
+
*/
|
|
36
|
+
onBreak(...args) {
|
|
37
|
+
return this.#policy.onBreak(...args);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Listens for when the API is degraded.
|
|
41
|
+
*
|
|
42
|
+
* @param args - The same arguments that {@link ServicePolicy.onDegraded}
|
|
43
|
+
* takes.
|
|
44
|
+
* @returns What {@link ServicePolicy.onDegraded} returns.
|
|
45
|
+
*/
|
|
46
|
+
onDegraded(...args) {
|
|
47
|
+
return this.#policy.onDegraded(...args);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fetches feature flags from the API with specific client, distribution, and environment parameters.
|
|
51
|
+
* Provides structured error handling, including fallback to cached data if available.
|
|
52
|
+
*
|
|
53
|
+
* @returns An object of feature flags and their boolean values or a structured error object.
|
|
54
|
+
*/
|
|
55
|
+
async fetchRemoteFeatureFlags() {
|
|
56
|
+
const url = `${BASE_URL}/flags?client=${this.#client}&distribution=${this.#distribution}&environment=${this.#environment}`;
|
|
57
|
+
const response = await this.#policy.execute(() => this.#fetch(url, { cache: 'no-cache' }));
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
throw new Error('Failed to fetch remote feature flags');
|
|
60
|
+
}
|
|
61
|
+
const data = await response.json();
|
|
62
|
+
if (!Array.isArray(data)) {
|
|
63
|
+
throw new Error('Feature flags api did not return an array');
|
|
64
|
+
}
|
|
65
|
+
const remoteFeatureFlags = this.#flattenFeatureFlags(data);
|
|
66
|
+
return {
|
|
67
|
+
remoteFeatureFlags,
|
|
68
|
+
cacheTimestamp: Date.now(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Flattens an array of feature flag objects into a single feature flags object.
|
|
73
|
+
*
|
|
74
|
+
* @param responseData - Array of objects containing feature flag key-value pairs
|
|
75
|
+
* @returns A single object containing all feature flags merged together
|
|
76
|
+
* @example
|
|
77
|
+
* // Input: [{ flag1: true }, { flag2: [] }]
|
|
78
|
+
* // Output: { flag1: true, flag2: [] }
|
|
79
|
+
*/
|
|
80
|
+
#flattenFeatureFlags(responseData) {
|
|
81
|
+
return responseData.reduce((acc, curr) => {
|
|
82
|
+
return { ...acc, ...curr };
|
|
83
|
+
}, {});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=client-config-api-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-config-api-service.js","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,gCAAgC,EAChC,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAW3C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACxB,MAAM,CAAe;IAErB,OAAO,CAAgB;IAEvB,OAAO,CAAa;IAEpB,aAAa,CAAmB;IAEhC,YAAY,CAAkB;IA+EvC,YAAY,EACV,KAAK,EAAE,aAAa,EACpB,OAAO,GAAG,mBAAmB,EAC7B,0BAA0B,GAAG,gCAAgC,EAC7D,oBAAoB,GAAG,8BAA8B,EACrD,OAAO,EACP,UAAU,EACV,MAAM,GAaP;QACC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC;QAEvC,IA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D,CAAC;QAED,MAAM,kBAAkB,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAE3D,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC3B,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,oBAAoB,CAAC,YAA6B;QAChD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACvC,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;QAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,gDAAgD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","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.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';
|
|
2
|
+
export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerMessenger, RemoteFeatureFlagControllerActions, RemoteFeatureFlagControllerGetStateAction, RemoteFeatureFlagControllerEvents, RemoteFeatureFlagControllerStateChangeEvent, } from './remote-feature-flag-controller.js';
|
|
3
|
+
export type { RemoteFeatureFlagControllerClearAllFlagOverridesAction, RemoteFeatureFlagControllerDisableAction, RemoteFeatureFlagControllerEnableAction, RemoteFeatureFlagControllerMethodActions, RemoteFeatureFlagControllerRemoveFlagOverrideAction, RemoteFeatureFlagControllerSetFlagOverrideAction, RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction, } from './remote-feature-flag-controller-method-action-types.js';
|
|
4
|
+
export { ClientType, DistributionType, EnvironmentType, ThresholdVersion, } from './remote-feature-flag-controller-types.js';
|
|
5
|
+
export type { FeatureFlags } from './remote-feature-flag-controller-types.js';
|
|
6
|
+
export { ClientConfigApiService } from './client-config-api-service/client-config-api-service.js';
|
|
7
|
+
export { generateDeterministicRandomNumber } from './utils/user-segmentation-utils.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,YAAY,EACV,gCAAgC,EAChC,oCAAoC,EACpC,kCAAkC,EAClC,yCAAyC,EACzC,iCAAiC,EACjC,2CAA2C,GAC5C,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACV,sDAAsD,EACtD,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,mDAAmD,EACnD,gDAAgD,EAChD,yDAAyD,GAC1D,MAAM,yDAAyD,CAAC;AACjE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,2CAA2C,CAAC;AAEnD,YAAY,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';
|
|
2
|
+
export { ClientType, DistributionType, EnvironmentType, ThresholdVersion, } from './remote-feature-flag-controller-types.js';
|
|
3
|
+
export { ClientConfigApiService } from './client-config-api-service/client-config-api-service.js';
|
|
4
|
+
export { generateDeterministicRandomNumber } from './utils/user-segmentation-utils.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAkBlF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC","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"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This file is auto generated.
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
|
-
import type { RemoteFeatureFlagController } from
|
|
5
|
+
import type { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';
|
|
6
6
|
/**
|
|
7
7
|
* Retrieves the remote feature flags, fetching from the API if necessary.
|
|
8
8
|
* Uses caching to prevent redundant API calls and handles concurrent fetches.
|
|
@@ -59,4 +59,4 @@ export type RemoteFeatureFlagControllerClearAllFlagOverridesAction = {
|
|
|
59
59
|
* Union of all RemoteFeatureFlagController action types.
|
|
60
60
|
*/
|
|
61
61
|
export type RemoteFeatureFlagControllerMethodActions = RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction | RemoteFeatureFlagControllerEnableAction | RemoteFeatureFlagControllerDisableAction | RemoteFeatureFlagControllerSetFlagOverrideAction | RemoteFeatureFlagControllerRemoveFlagOverrideAction | RemoteFeatureFlagControllerClearAllFlagOverridesAction;
|
|
62
|
-
//# sourceMappingURL=remote-feature-flag-controller-method-action-types.d.
|
|
62
|
+
//# sourceMappingURL=remote-feature-flag-controller-method-action-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller-method-action-types.d.ts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller-method-action-types.js","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,4 +1,4 @@
|
|
|
1
|
-
import type { Json, SemVerVersion } from
|
|
1
|
+
import type { Json, SemVerVersion } from '@metamask/utils';
|
|
2
2
|
export declare enum ClientType {
|
|
3
3
|
Extension = "extension",
|
|
4
4
|
Mobile = "mobile"
|
|
@@ -61,4 +61,4 @@ export type ServiceResponse = {
|
|
|
61
61
|
remoteFeatureFlags: FeatureFlags;
|
|
62
62
|
cacheTimestamp: number | null;
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=remote-feature-flag-controller-types.d.
|
|
64
|
+
//# sourceMappingURL=remote-feature-flag-controller-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller-types.d.ts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;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"}
|
package/dist/{remote-feature-flag-controller-types.mjs → remote-feature-flag-controller-types.js}
RENAMED
|
@@ -26,4 +26,4 @@ export var ThresholdVersion;
|
|
|
26
26
|
(function (ThresholdVersion) {
|
|
27
27
|
ThresholdVersion[ThresholdVersion["DirectValue"] = 2] = "DirectValue";
|
|
28
28
|
})(ThresholdVersion || (ThresholdVersion = {}));
|
|
29
|
-
//# sourceMappingURL=remote-feature-flag-controller-types.
|
|
29
|
+
//# sourceMappingURL=remote-feature-flag-controller-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller-types.js","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"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseController, ControllerGetStateAction } from
|
|
2
|
-
import type { ControllerStateChangeEvent } from
|
|
3
|
-
import type { Messenger } from
|
|
4
|
-
import type { Json } from
|
|
5
|
-
import type { AbstractClientConfigApiService } from
|
|
6
|
-
import type { RemoteFeatureFlagControllerMethodActions } from
|
|
7
|
-
import type { FeatureFlags } from
|
|
1
|
+
import { BaseController, ControllerGetStateAction } from '@metamask/base-controller';
|
|
2
|
+
import type { ControllerStateChangeEvent } from '@metamask/base-controller';
|
|
3
|
+
import type { Messenger } from '@metamask/messenger';
|
|
4
|
+
import type { Json } from '@metamask/utils';
|
|
5
|
+
import type { AbstractClientConfigApiService } from './client-config-api-service/abstract-client-config-api-service.js';
|
|
6
|
+
import type { RemoteFeatureFlagControllerMethodActions } from './remote-feature-flag-controller-method-action-types.js';
|
|
7
|
+
import type { FeatureFlags } from './remote-feature-flag-controller-types.js';
|
|
8
8
|
export declare const controllerName = "RemoteFeatureFlagController";
|
|
9
9
|
export declare const DEFAULT_CACHE_DURATION: number;
|
|
10
10
|
export type RemoteFeatureFlagControllerState = {
|
|
@@ -110,4 +110,4 @@ export declare class RemoteFeatureFlagController extends BaseController<typeof c
|
|
|
110
110
|
*/
|
|
111
111
|
clearAllFlagOverrides(): void;
|
|
112
112
|
}
|
|
113
|
-
//# sourceMappingURL=remote-feature-flag-controller.d.
|
|
113
|
+
//# sourceMappingURL=remote-feature-flag-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller.d.ts","sourceRoot":"","sources":["../src/remote-feature-flag-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mEAAmE,CAAC;AACxH,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,yDAAyD,CAAC;AACxH,OAAO,KAAK,EACV,YAAY,EAGb,MA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