@metamask-previews/remote-feature-flag-controller 1.0.0-preview-a82fd89
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 +23 -0
- package/LICENSE +6 -0
- package/LICENSE.APACHE2 +201 -0
- package/LICENSE.MIT +20 -0
- package/README.md +15 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.cjs +3 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.cjs.map +1 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.d.cts +7 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.d.cts.map +1 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.d.mts +7 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.d.mts.map +1 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.mjs +2 -0
- package/dist/client-config-api-service/abstract-client-config-api-service.mjs.map +1 -0
- package/dist/client-config-api-service/client-config-api-service.cjs +117 -0
- package/dist/client-config-api-service/client-config-api-service.cjs.map +1 -0
- package/dist/client-config-api-service/client-config-api-service.d.cts +54 -0
- package/dist/client-config-api-service/client-config-api-service.d.cts.map +1 -0
- package/dist/client-config-api-service/client-config-api-service.d.mts +54 -0
- package/dist/client-config-api-service/client-config-api-service.d.mts.map +1 -0
- package/dist/client-config-api-service/client-config-api-service.mjs +113 -0
- package/dist/client-config-api-service/client-config-api-service.mjs.map +1 -0
- package/dist/constants.cjs +8 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +5 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +5 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +5 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/remote-feature-flag-controller-types.cjs +21 -0
- package/dist/remote-feature-flag-controller-types.cjs.map +1 -0
- package/dist/remote-feature-flag-controller-types.d.cts +42 -0
- package/dist/remote-feature-flag-controller-types.d.cts.map +1 -0
- package/dist/remote-feature-flag-controller-types.d.mts +42 -0
- package/dist/remote-feature-flag-controller-types.d.mts.map +1 -0
- package/dist/remote-feature-flag-controller-types.mjs +18 -0
- package/dist/remote-feature-flag-controller-types.mjs.map +1 -0
- package/dist/remote-feature-flag-controller.cjs +120 -0
- package/dist/remote-feature-flag-controller.cjs.map +1 -0
- package/dist/remote-feature-flag-controller.d.cts +69 -0
- package/dist/remote-feature-flag-controller.d.cts.map +1 -0
- package/dist/remote-feature-flag-controller.d.mts +69 -0
- package/dist/remote-feature-flag-controller.d.mts.map +1 -0
- package/dist/remote-feature-flag-controller.mjs +115 -0
- package/dist/remote-feature-flag-controller.mjs.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ClientConfigApiService_fetch, _ClientConfigApiService_policy, _ClientConfigApiService_client, _ClientConfigApiService_distribution, _ClientConfigApiService_environment;
|
|
13
|
+
import { circuitBreaker, ConsecutiveBreaker, ExponentialBackoff, handleAll, retry, wrap, CircuitState } from "cockatiel";
|
|
14
|
+
import { BASE_URL } from "../constants.mjs";
|
|
15
|
+
const DEFAULT_FETCH_RETRIES = 3;
|
|
16
|
+
// Each update attempt will result (1 + retries) calls if the server is down
|
|
17
|
+
const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_FETCH_RETRIES) * 3;
|
|
18
|
+
export const DEFAULT_DEGRADED_THRESHOLD = 5000;
|
|
19
|
+
/**
|
|
20
|
+
* This service is responsible for fetching feature flags from the ClientConfig API.
|
|
21
|
+
*/
|
|
22
|
+
export class ClientConfigApiService {
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new ClientConfigApiService object.
|
|
25
|
+
*
|
|
26
|
+
* @param args - The arguments.
|
|
27
|
+
* @param args.fetch - A function that can be used to make an HTTP request.
|
|
28
|
+
* @param args.retries - Number of retry attempts for each fetch request.
|
|
29
|
+
* @param args.maximumConsecutiveFailures - The maximum number of consecutive failures
|
|
30
|
+
* allowed before breaking the circuit and pausing further fetch attempts.
|
|
31
|
+
* @param args.circuitBreakDuration - The duration for which the circuit remains open after
|
|
32
|
+
* too many consecutive failures.
|
|
33
|
+
* @param args.onBreak - Callback invoked when the circuit breaks.
|
|
34
|
+
* @param args.onDegraded - Callback invoked when the service is degraded (requests resolving too slowly).
|
|
35
|
+
* @param args.config - The configuration object, includes client, distribution, and environment.
|
|
36
|
+
* @param args.config.client - The client type (e.g., 'extension', 'mobile').
|
|
37
|
+
* @param args.config.distribution - The distribution type (e.g., 'main', 'flask').
|
|
38
|
+
* @param args.config.environment - The environment type (e.g., 'prod', 'rc', 'dev').
|
|
39
|
+
*/
|
|
40
|
+
constructor({ fetch: fetchFunction, retries = DEFAULT_FETCH_RETRIES, maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES, circuitBreakDuration = 30 * 60 * 1000, onBreak, onDegraded, config, }) {
|
|
41
|
+
_ClientConfigApiService_fetch.set(this, void 0);
|
|
42
|
+
_ClientConfigApiService_policy.set(this, void 0);
|
|
43
|
+
_ClientConfigApiService_client.set(this, void 0);
|
|
44
|
+
_ClientConfigApiService_distribution.set(this, void 0);
|
|
45
|
+
_ClientConfigApiService_environment.set(this, void 0);
|
|
46
|
+
__classPrivateFieldSet(this, _ClientConfigApiService_fetch, fetchFunction, "f");
|
|
47
|
+
__classPrivateFieldSet(this, _ClientConfigApiService_client, config.client, "f");
|
|
48
|
+
__classPrivateFieldSet(this, _ClientConfigApiService_distribution, config.distribution, "f");
|
|
49
|
+
__classPrivateFieldSet(this, _ClientConfigApiService_environment, config.environment, "f");
|
|
50
|
+
const retryPolicy = retry(handleAll, {
|
|
51
|
+
maxAttempts: retries,
|
|
52
|
+
backoff: new ExponentialBackoff(),
|
|
53
|
+
});
|
|
54
|
+
const circuitBreakerPolicy = circuitBreaker(handleAll, {
|
|
55
|
+
halfOpenAfter: circuitBreakDuration,
|
|
56
|
+
breaker: new ConsecutiveBreaker(maximumConsecutiveFailures),
|
|
57
|
+
});
|
|
58
|
+
if (onBreak) {
|
|
59
|
+
circuitBreakerPolicy.onBreak(onBreak);
|
|
60
|
+
}
|
|
61
|
+
if (onDegraded) {
|
|
62
|
+
retryPolicy.onGiveUp(() => {
|
|
63
|
+
if (circuitBreakerPolicy.state === CircuitState.Closed) {
|
|
64
|
+
onDegraded();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
retryPolicy.onSuccess(({ duration }) => {
|
|
68
|
+
if (circuitBreakerPolicy.state === CircuitState.Closed &&
|
|
69
|
+
duration > DEFAULT_DEGRADED_THRESHOLD // Default degraded threshold
|
|
70
|
+
) {
|
|
71
|
+
onDegraded();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
__classPrivateFieldSet(this, _ClientConfigApiService_policy, wrap(retryPolicy, circuitBreakerPolicy), "f");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Fetches feature flags from the API with specific client, distribution, and environment parameters.
|
|
79
|
+
* Provides structured error handling, including fallback to cached data if available.
|
|
80
|
+
* @returns An object of feature flags and their boolean values or a structured error object.
|
|
81
|
+
*/
|
|
82
|
+
async fetchRemoteFeatureFlags() {
|
|
83
|
+
const url = `${BASE_URL}/flags?client=${__classPrivateFieldGet(this, _ClientConfigApiService_client, "f")}&distribution=${__classPrivateFieldGet(this, _ClientConfigApiService_distribution, "f")}&environment=${__classPrivateFieldGet(this, _ClientConfigApiService_environment, "f")}`;
|
|
84
|
+
const response = await __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").execute(() => __classPrivateFieldGet(this, _ClientConfigApiService_fetch, "f").call(this, url, { cache: 'no-cache' }));
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
throw new Error('Failed to fetch remote feature flags');
|
|
87
|
+
}
|
|
88
|
+
const data = await response.json();
|
|
89
|
+
if (!Array.isArray(data)) {
|
|
90
|
+
throw new Error('Feature flags api did not return an array');
|
|
91
|
+
}
|
|
92
|
+
const remoteFeatureFlags = this.flattenFeatureFlags(data);
|
|
93
|
+
return {
|
|
94
|
+
remoteFeatureFlags,
|
|
95
|
+
cacheTimestamp: Date.now(),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Flattens an array of feature flag objects into a single feature flags object.
|
|
100
|
+
* @param responseData - Array of objects containing feature flag key-value pairs
|
|
101
|
+
* @returns A single object containing all feature flags merged together
|
|
102
|
+
* @example
|
|
103
|
+
* // Input: [{ flag1: true }, { flag2: [] }]
|
|
104
|
+
* // Output: { flag1: true, flag2: [] }
|
|
105
|
+
*/
|
|
106
|
+
flattenFeatureFlags(responseData) {
|
|
107
|
+
return responseData.reduce((acc, curr) => {
|
|
108
|
+
return { ...acc, ...curr };
|
|
109
|
+
}, {});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
_ClientConfigApiService_fetch = new WeakMap(), _ClientConfigApiService_policy = new WeakMap(), _ClientConfigApiService_client = new WeakMap(), _ClientConfigApiService_distribution = new WeakMap(), _ClientConfigApiService_environment = new WeakMap();
|
|
113
|
+
//# sourceMappingURL=client-config-api-service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-config-api-service.mjs","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n circuitBreaker,\n ConsecutiveBreaker,\n ExponentialBackoff,\n handleAll,\n type IPolicy,\n retry,\n wrap,\n CircuitState,\n} from 'cockatiel';\n\nimport { BASE_URL } from '../constants';\nimport type {\n FeatureFlags,\n ClientType,\n DistributionType,\n EnvironmentType,\n ServiceResponse,\n ApiDataResponse,\n} from '../remote-feature-flag-controller-types';\n\nconst DEFAULT_FETCH_RETRIES = 3;\n// Each update attempt will result (1 + retries) calls if the server is down\nconst DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_FETCH_RETRIES) * 3;\n\nexport const DEFAULT_DEGRADED_THRESHOLD = 5000;\n\n/**\n * This service is responsible for fetching feature flags from the ClientConfig API.\n */\nexport class ClientConfigApiService {\n #fetch: typeof fetch;\n\n #policy: IPolicy;\n\n #client: ClientType;\n\n #distribution: DistributionType;\n\n #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 * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive failures\n * allowed before breaking the circuit and pausing further fetch attempts.\n * @param args.circuitBreakDuration - The duration for which the circuit remains open after\n * too many consecutive failures.\n * @param args.onBreak - Callback invoked when the circuit breaks.\n * @param args.onDegraded - Callback invoked when the service is degraded (requests resolving too slowly).\n * @param args.config - The configuration object, includes client, 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', 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc', 'dev').\n */\n constructor({\n fetch: fetchFunction,\n retries = DEFAULT_FETCH_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = 30 * 60 * 1000,\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 const retryPolicy = retry(handleAll, {\n maxAttempts: retries,\n backoff: new ExponentialBackoff(),\n });\n\n const circuitBreakerPolicy = circuitBreaker(handleAll, {\n halfOpenAfter: circuitBreakDuration,\n breaker: new ConsecutiveBreaker(maximumConsecutiveFailures),\n });\n\n if (onBreak) {\n circuitBreakerPolicy.onBreak(onBreak);\n }\n\n if (onDegraded) {\n retryPolicy.onGiveUp(() => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n onDegraded();\n }\n });\n\n retryPolicy.onSuccess(({ duration }) => {\n if (\n circuitBreakerPolicy.state === CircuitState.Closed &&\n duration > DEFAULT_DEGRADED_THRESHOLD // Default degraded threshold\n ) {\n onDegraded();\n }\n });\n }\n\n this.#policy = wrap(retryPolicy, circuitBreakerPolicy);\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 * @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 * @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 private 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.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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,gDAAgD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,gDAAgD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientConfigApiService = exports.EnvironmentType = exports.DistributionType = exports.ClientType = exports.RemoteFeatureFlagController = void 0;
|
|
4
|
+
var remote_feature_flag_controller_1 = require("./remote-feature-flag-controller.cjs");
|
|
5
|
+
Object.defineProperty(exports, "RemoteFeatureFlagController", { enumerable: true, get: function () { return remote_feature_flag_controller_1.RemoteFeatureFlagController; } });
|
|
6
|
+
var remote_feature_flag_controller_types_1 = require("./remote-feature-flag-controller-types.cjs");
|
|
7
|
+
Object.defineProperty(exports, "ClientType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_1.ClientType; } });
|
|
8
|
+
Object.defineProperty(exports, "DistributionType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_1.DistributionType; } });
|
|
9
|
+
Object.defineProperty(exports, "EnvironmentType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_1.EnvironmentType; } });
|
|
10
|
+
var client_config_api_service_1 = require("./client-config-api-service/client-config-api-service.cjs");
|
|
11
|
+
Object.defineProperty(exports, "ClientConfigApiService", { enumerable: true, get: function () { return client_config_api_service_1.ClientConfigApiService; } });
|
|
12
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uFAA+E;AAAtE,6IAAA,2BAA2B,OAAA;AAEpC,mGAIgD;AAH9C,kIAAA,UAAU,OAAA;AACV,wIAAA,gBAAgB,OAAA;AAChB,uIAAA,eAAe,OAAA;AAQjB,uGAA+F;AAAtF,mIAAA,sBAAsB,OAAA","sourcesContent":["export { RemoteFeatureFlagController } from './remote-feature-flag-controller';\nexport type { RemoteFeatureFlagControllerMessenger } from './remote-feature-flag-controller';\nexport {\n ClientType,\n DistributionType,\n EnvironmentType,\n} from './remote-feature-flag-controller-types';\n\nexport type {\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerGetStateAction,\n FeatureFlags,\n} from './remote-feature-flag-controller-types';\nexport { ClientConfigApiService } from './client-config-api-service/client-config-api-service';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.cjs";
|
|
2
|
+
export type { RemoteFeatureFlagControllerMessenger } from "./remote-feature-flag-controller.cjs";
|
|
3
|
+
export { ClientType, DistributionType, EnvironmentType, } from "./remote-feature-flag-controller-types.cjs";
|
|
4
|
+
export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerGetStateAction, FeatureFlags, } from "./remote-feature-flag-controller-types.cjs";
|
|
5
|
+
export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.cjs";
|
|
6
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAAyC;AAC/E,YAAY,EAAE,oCAAoC,EAAE,6CAAyC;AAC7F,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,GAChB,mDAA+C;AAEhD,YAAY,EACV,gCAAgC,EAChC,yCAAyC,EACzC,YAAY,GACb,mDAA+C;AAChD,OAAO,EAAE,sBAAsB,EAAE,kEAA8D"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
|
|
2
|
+
export type { RemoteFeatureFlagControllerMessenger } from "./remote-feature-flag-controller.mjs";
|
|
3
|
+
export { ClientType, DistributionType, EnvironmentType, } from "./remote-feature-flag-controller-types.mjs";
|
|
4
|
+
export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerGetStateAction, FeatureFlags, } from "./remote-feature-flag-controller-types.mjs";
|
|
5
|
+
export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.mjs";
|
|
6
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAAyC;AAC/E,YAAY,EAAE,oCAAoC,EAAE,6CAAyC;AAC7F,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,GAChB,mDAA+C;AAEhD,YAAY,EACV,gCAAgC,EAChC,yCAAyC,EACzC,YAAY,GACb,mDAA+C;AAChD,OAAO,EAAE,sBAAsB,EAAE,kEAA8D"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
|
|
2
|
+
export { ClientType, DistributionType, EnvironmentType } from "./remote-feature-flag-controller-types.mjs";
|
|
3
|
+
export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.mjs";
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAAyC;AAE/E,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EAChB,mDAA+C;AAOhD,OAAO,EAAE,sBAAsB,EAAE,kEAA8D","sourcesContent":["export { RemoteFeatureFlagController } from './remote-feature-flag-controller';\nexport type { RemoteFeatureFlagControllerMessenger } from './remote-feature-flag-controller';\nexport {\n ClientType,\n DistributionType,\n EnvironmentType,\n} from './remote-feature-flag-controller-types';\n\nexport type {\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerGetStateAction,\n FeatureFlags,\n} from './remote-feature-flag-controller-types';\nexport { ClientConfigApiService } from './client-config-api-service/client-config-api-service';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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
|
+
})(DistributionType || (exports.DistributionType = DistributionType = {}));
|
|
15
|
+
var EnvironmentType;
|
|
16
|
+
(function (EnvironmentType) {
|
|
17
|
+
EnvironmentType["Production"] = "prod";
|
|
18
|
+
EnvironmentType["ReleaseCandidate"] = "rc";
|
|
19
|
+
EnvironmentType["Development"] = "dev";
|
|
20
|
+
})(EnvironmentType || (exports.EnvironmentType = EnvironmentType = {}));
|
|
21
|
+
//# sourceMappingURL=remote-feature-flag-controller-types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller-types.cjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":";;;AAGA,mEAAmE;AACnE,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;AACrB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B","sourcesContent":["import type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { Json } 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\nexport enum EnvironmentType {\n Production = 'prod',\n ReleaseCandidate = 'rc',\n Development = 'dev',\n}\n\n/** Type representing the feature flags collection */\nexport type FeatureFlags = {\n [key: string]: Json;\n};\n\nexport type ApiDataResponse = FeatureFlags[];\n\nexport type ServiceResponse = {\n remoteFeatureFlags: FeatureFlags;\n cacheTimestamp: number | null;\n};\n\n/**\n * Describes the shape of the state object for the {@link RemoteFeatureFlagController}.\n */\nexport type RemoteFeatureFlagControllerState = {\n /**\n * The collection of feature flags and their respective values, which can be objects.\n */\n remoteFeatureFlags: FeatureFlags;\n /**\n * The timestamp of the last successful feature flag cache.\n */\n cacheTimestamp: number;\n};\n\n/**\n * The action to retrieve the state of the {@link RemoteFeatureFlagController}.\n */\nexport type RemoteFeatureFlagControllerGetStateAction =\n ControllerGetStateAction<\n 'RemoteFeatureFlagController',\n RemoteFeatureFlagControllerState\n >;\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ControllerGetStateAction } from "@metamask/base-controller";
|
|
2
|
+
import type { Json } from "@metamask/utils";
|
|
3
|
+
export declare enum ClientType {
|
|
4
|
+
Extension = "extension",
|
|
5
|
+
Mobile = "mobile"
|
|
6
|
+
}
|
|
7
|
+
export declare enum DistributionType {
|
|
8
|
+
Main = "main",
|
|
9
|
+
Flask = "flask"
|
|
10
|
+
}
|
|
11
|
+
export declare enum EnvironmentType {
|
|
12
|
+
Production = "prod",
|
|
13
|
+
ReleaseCandidate = "rc",
|
|
14
|
+
Development = "dev"
|
|
15
|
+
}
|
|
16
|
+
/** Type representing the feature flags collection */
|
|
17
|
+
export type FeatureFlags = {
|
|
18
|
+
[key: string]: Json;
|
|
19
|
+
};
|
|
20
|
+
export type ApiDataResponse = FeatureFlags[];
|
|
21
|
+
export type ServiceResponse = {
|
|
22
|
+
remoteFeatureFlags: FeatureFlags;
|
|
23
|
+
cacheTimestamp: number | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Describes the shape of the state object for the {@link RemoteFeatureFlagController}.
|
|
27
|
+
*/
|
|
28
|
+
export type RemoteFeatureFlagControllerState = {
|
|
29
|
+
/**
|
|
30
|
+
* The collection of feature flags and their respective values, which can be objects.
|
|
31
|
+
*/
|
|
32
|
+
remoteFeatureFlags: FeatureFlags;
|
|
33
|
+
/**
|
|
34
|
+
* The timestamp of the last successful feature flag cache.
|
|
35
|
+
*/
|
|
36
|
+
cacheTimestamp: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The action to retrieve the state of the {@link RemoteFeatureFlagController}.
|
|
40
|
+
*/
|
|
41
|
+
export type RemoteFeatureFlagControllerGetStateAction = ControllerGetStateAction<'RemoteFeatureFlagController', RemoteFeatureFlagControllerState>;
|
|
42
|
+
//# sourceMappingURL=remote-feature-flag-controller-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,wBAAwB,EAAE,kCAAkC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,oBAAY,UAAU;IACpB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,eAAe;IACzB,UAAU,SAAS;IACnB,gBAAgB,OAAO;IACvB,WAAW,QAAQ;CACpB;AAED,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,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;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,kBAAkB,EAAE,YAAY,CAAC;IACjC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yCAAyC,GACnD,wBAAwB,CACtB,6BAA6B,EAC7B,gCAAgC,CACjC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ControllerGetStateAction } from "@metamask/base-controller";
|
|
2
|
+
import type { Json } from "@metamask/utils";
|
|
3
|
+
export declare enum ClientType {
|
|
4
|
+
Extension = "extension",
|
|
5
|
+
Mobile = "mobile"
|
|
6
|
+
}
|
|
7
|
+
export declare enum DistributionType {
|
|
8
|
+
Main = "main",
|
|
9
|
+
Flask = "flask"
|
|
10
|
+
}
|
|
11
|
+
export declare enum EnvironmentType {
|
|
12
|
+
Production = "prod",
|
|
13
|
+
ReleaseCandidate = "rc",
|
|
14
|
+
Development = "dev"
|
|
15
|
+
}
|
|
16
|
+
/** Type representing the feature flags collection */
|
|
17
|
+
export type FeatureFlags = {
|
|
18
|
+
[key: string]: Json;
|
|
19
|
+
};
|
|
20
|
+
export type ApiDataResponse = FeatureFlags[];
|
|
21
|
+
export type ServiceResponse = {
|
|
22
|
+
remoteFeatureFlags: FeatureFlags;
|
|
23
|
+
cacheTimestamp: number | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Describes the shape of the state object for the {@link RemoteFeatureFlagController}.
|
|
27
|
+
*/
|
|
28
|
+
export type RemoteFeatureFlagControllerState = {
|
|
29
|
+
/**
|
|
30
|
+
* The collection of feature flags and their respective values, which can be objects.
|
|
31
|
+
*/
|
|
32
|
+
remoteFeatureFlags: FeatureFlags;
|
|
33
|
+
/**
|
|
34
|
+
* The timestamp of the last successful feature flag cache.
|
|
35
|
+
*/
|
|
36
|
+
cacheTimestamp: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The action to retrieve the state of the {@link RemoteFeatureFlagController}.
|
|
40
|
+
*/
|
|
41
|
+
export type RemoteFeatureFlagControllerGetStateAction = ControllerGetStateAction<'RemoteFeatureFlagController', RemoteFeatureFlagControllerState>;
|
|
42
|
+
//# sourceMappingURL=remote-feature-flag-controller-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,wBAAwB,EAAE,kCAAkC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,oBAAY,UAAU;IACpB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,eAAe;IACzB,UAAU,SAAS;IACnB,gBAAgB,OAAO;IACvB,WAAW,QAAQ;CACpB;AAED,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,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;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,kBAAkB,EAAE,YAAY,CAAC;IACjC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yCAAyC,GACnD,wBAAwB,CACtB,6BAA6B,EAC7B,gCAAgC,CACjC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Define accepted values for client, distribution, and environment
|
|
2
|
+
export var ClientType;
|
|
3
|
+
(function (ClientType) {
|
|
4
|
+
ClientType["Extension"] = "extension";
|
|
5
|
+
ClientType["Mobile"] = "mobile";
|
|
6
|
+
})(ClientType || (ClientType = {}));
|
|
7
|
+
export var DistributionType;
|
|
8
|
+
(function (DistributionType) {
|
|
9
|
+
DistributionType["Main"] = "main";
|
|
10
|
+
DistributionType["Flask"] = "flask";
|
|
11
|
+
})(DistributionType || (DistributionType = {}));
|
|
12
|
+
export var EnvironmentType;
|
|
13
|
+
(function (EnvironmentType) {
|
|
14
|
+
EnvironmentType["Production"] = "prod";
|
|
15
|
+
EnvironmentType["ReleaseCandidate"] = "rc";
|
|
16
|
+
EnvironmentType["Development"] = "dev";
|
|
17
|
+
})(EnvironmentType || (EnvironmentType = {}));
|
|
18
|
+
//# sourceMappingURL=remote-feature-flag-controller-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller-types.mjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-types.ts"],"names":[],"mappings":"AAGA,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,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;AACrB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B","sourcesContent":["import type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { Json } 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\nexport enum EnvironmentType {\n Production = 'prod',\n ReleaseCandidate = 'rc',\n Development = 'dev',\n}\n\n/** Type representing the feature flags collection */\nexport type FeatureFlags = {\n [key: string]: Json;\n};\n\nexport type ApiDataResponse = FeatureFlags[];\n\nexport type ServiceResponse = {\n remoteFeatureFlags: FeatureFlags;\n cacheTimestamp: number | null;\n};\n\n/**\n * Describes the shape of the state object for the {@link RemoteFeatureFlagController}.\n */\nexport type RemoteFeatureFlagControllerState = {\n /**\n * The collection of feature flags and their respective values, which can be objects.\n */\n remoteFeatureFlags: FeatureFlags;\n /**\n * The timestamp of the last successful feature flag cache.\n */\n cacheTimestamp: number;\n};\n\n/**\n * The action to retrieve the state of the {@link RemoteFeatureFlagController}.\n */\nexport type RemoteFeatureFlagControllerGetStateAction =\n ControllerGetStateAction<\n 'RemoteFeatureFlagController',\n RemoteFeatureFlagControllerState\n >;\n"]}
|
|
@@ -0,0 +1,120 @@
|
|
|
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 _RemoteFeatureFlagController_instances, _RemoteFeatureFlagController_fetchInterval, _RemoteFeatureFlagController_disabled, _RemoteFeatureFlagController_clientConfigApiService, _RemoteFeatureFlagController_inProgressFlagUpdate, _RemoteFeatureFlagController_isCacheExpired, _RemoteFeatureFlagController_updateCache;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RemoteFeatureFlagController = exports.getDefaultRemoteFeatureFlagControllerState = exports.DEFAULT_CACHE_DURATION = exports.controllerName = void 0;
|
|
16
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
+
// === GENERAL ===
|
|
18
|
+
exports.controllerName = 'RemoteFeatureFlagController';
|
|
19
|
+
exports.DEFAULT_CACHE_DURATION = 24 * 60 * 60 * 1000; // 1 day
|
|
20
|
+
const remoteFeatureFlagControllerMetadata = {
|
|
21
|
+
remoteFeatureFlags: { persist: true, anonymous: true },
|
|
22
|
+
cacheTimestamp: { persist: true, anonymous: true },
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Returns the default state for the RemoteFeatureFlagController.
|
|
26
|
+
*
|
|
27
|
+
* @returns The default controller state.
|
|
28
|
+
*/
|
|
29
|
+
function getDefaultRemoteFeatureFlagControllerState() {
|
|
30
|
+
return {
|
|
31
|
+
remoteFeatureFlags: {},
|
|
32
|
+
cacheTimestamp: 0,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.getDefaultRemoteFeatureFlagControllerState = getDefaultRemoteFeatureFlagControllerState;
|
|
36
|
+
/**
|
|
37
|
+
* The RemoteFeatureFlagController manages the retrieval and caching of remote feature flags.
|
|
38
|
+
* It fetches feature flags from a remote API, caches them, and provides methods to access
|
|
39
|
+
* and manage these flags. The controller ensures that feature flags are refreshed based on
|
|
40
|
+
* a specified interval and handles cases where the controller is disabled or the network is unavailable.
|
|
41
|
+
*/
|
|
42
|
+
class RemoteFeatureFlagController extends base_controller_1.BaseController {
|
|
43
|
+
/**
|
|
44
|
+
* Constructs a new RemoteFeatureFlagController instance.
|
|
45
|
+
*
|
|
46
|
+
* @param options - The controller options.
|
|
47
|
+
* @param options.messenger - The controller messenger used for communication.
|
|
48
|
+
* @param options.state - The initial state of the controller.
|
|
49
|
+
* @param options.clientConfigApiService - The service instance to fetch remote feature flags.
|
|
50
|
+
* @param options.fetchInterval - The interval in milliseconds before cached flags expire. Defaults to 1 day.
|
|
51
|
+
* @param options.disabled - Determines if the controller should be disabled initially. Defaults to false.
|
|
52
|
+
*/
|
|
53
|
+
constructor({ messenger, state, clientConfigApiService, fetchInterval = exports.DEFAULT_CACHE_DURATION, disabled = false, }) {
|
|
54
|
+
super({
|
|
55
|
+
name: exports.controllerName,
|
|
56
|
+
metadata: remoteFeatureFlagControllerMetadata,
|
|
57
|
+
messenger,
|
|
58
|
+
state: {
|
|
59
|
+
...getDefaultRemoteFeatureFlagControllerState(),
|
|
60
|
+
...state,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
_RemoteFeatureFlagController_instances.add(this);
|
|
64
|
+
_RemoteFeatureFlagController_fetchInterval.set(this, void 0);
|
|
65
|
+
_RemoteFeatureFlagController_disabled.set(this, void 0);
|
|
66
|
+
_RemoteFeatureFlagController_clientConfigApiService.set(this, void 0);
|
|
67
|
+
_RemoteFeatureFlagController_inProgressFlagUpdate.set(this, void 0);
|
|
68
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_fetchInterval, fetchInterval, "f");
|
|
69
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_disabled, disabled, "f");
|
|
70
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_clientConfigApiService, clientConfigApiService, "f");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the remote feature flags, fetching from the API if necessary.
|
|
74
|
+
* Uses caching to prevent redundant API calls and handles concurrent fetches.
|
|
75
|
+
*
|
|
76
|
+
* @returns A promise that resolves to the current set of feature flags.
|
|
77
|
+
*/
|
|
78
|
+
async updateRemoteFeatureFlags() {
|
|
79
|
+
if (__classPrivateFieldGet(this, _RemoteFeatureFlagController_disabled, "f") || !__classPrivateFieldGet(this, _RemoteFeatureFlagController_instances, "m", _RemoteFeatureFlagController_isCacheExpired).call(this)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let serverData;
|
|
83
|
+
if (__classPrivateFieldGet(this, _RemoteFeatureFlagController_inProgressFlagUpdate, "f")) {
|
|
84
|
+
await __classPrivateFieldGet(this, _RemoteFeatureFlagController_inProgressFlagUpdate, "f");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_inProgressFlagUpdate, __classPrivateFieldGet(this, _RemoteFeatureFlagController_clientConfigApiService, "f").fetchRemoteFeatureFlags(), "f");
|
|
89
|
+
serverData = await __classPrivateFieldGet(this, _RemoteFeatureFlagController_inProgressFlagUpdate, "f");
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_inProgressFlagUpdate, undefined, "f");
|
|
93
|
+
}
|
|
94
|
+
__classPrivateFieldGet(this, _RemoteFeatureFlagController_instances, "m", _RemoteFeatureFlagController_updateCache).call(this, serverData.remoteFeatureFlags);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enables the controller, allowing it to make network requests.
|
|
98
|
+
*/
|
|
99
|
+
enable() {
|
|
100
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_disabled, false, "f");
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Disables the controller, preventing it from making network requests.
|
|
104
|
+
*/
|
|
105
|
+
disable() {
|
|
106
|
+
__classPrivateFieldSet(this, _RemoteFeatureFlagController_disabled, true, "f");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.RemoteFeatureFlagController = RemoteFeatureFlagController;
|
|
110
|
+
_RemoteFeatureFlagController_fetchInterval = new WeakMap(), _RemoteFeatureFlagController_disabled = new WeakMap(), _RemoteFeatureFlagController_clientConfigApiService = new WeakMap(), _RemoteFeatureFlagController_inProgressFlagUpdate = new WeakMap(), _RemoteFeatureFlagController_instances = new WeakSet(), _RemoteFeatureFlagController_isCacheExpired = function _RemoteFeatureFlagController_isCacheExpired() {
|
|
111
|
+
return Date.now() - this.state.cacheTimestamp > __classPrivateFieldGet(this, _RemoteFeatureFlagController_fetchInterval, "f");
|
|
112
|
+
}, _RemoteFeatureFlagController_updateCache = function _RemoteFeatureFlagController_updateCache(remoteFeatureFlags) {
|
|
113
|
+
this.update(() => {
|
|
114
|
+
return {
|
|
115
|
+
remoteFeatureFlags,
|
|
116
|
+
cacheTimestamp: Date.now(),
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=remote-feature-flag-controller.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller.cjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+DAA2D;AAQ3D,kBAAkB;AAEL,QAAA,cAAc,GAAG,6BAA6B,CAAC;AAC/C,QAAA,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,QAAQ;AASnE,MAAM,mCAAmC,GAAG;IAC1C,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;IACtD,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;CACnD,CAAC;AAwCF;;;;GAIG;AACH,SAAgB,0CAA0C;IACxD,OAAO;QACL,kBAAkB,EAAE,EAAE;QACtB,cAAc,EAAE,CAAC;KAClB,CAAC;AACJ,CAAC;AALD,gGAKC;AAED;;;;;GAKG;AACH,MAAa,2BAA4B,SAAQ,gCAIhD;IASC;;;;;;;;;OASG;IACH,YAAY,EACV,SAAS,EACT,KAAK,EACL,sBAAsB,EACtB,aAAa,GAAG,8BAAsB,EACtC,QAAQ,GAAG,KAAK,GAOjB;QACC,KAAK,CAAC;YACJ,IAAI,EAAE,sBAAc;YACpB,QAAQ,EAAE,mCAAmC;YAC7C,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,0CAA0C,EAAE;gBAC/C,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAvCI,6DAAuB;QAEhC,wDAAmB;QAEnB,sEAAwD;QAExD,oEAAiD;QAmC/C,uBAAA,IAAI,8CAAkB,aAAa,MAAA,CAAC;QACpC,uBAAA,IAAI,yCAAa,QAAQ,MAAA,CAAC;QAC1B,uBAAA,IAAI,uDAA2B,sBAAsB,MAAA,CAAC;IACxD,CAAC;IAYD;;;;;OAKG;IACH,KAAK,CAAC,wBAAwB;QAC5B,IAAI,uBAAA,IAAI,6CAAU,IAAI,CAAC,uBAAA,IAAI,2FAAgB,MAApB,IAAI,CAAkB,EAAE;YAC7C,OAAO;SACR;QAED,IAAI,UAAU,CAAC;QAEf,IAAI,uBAAA,IAAI,yDAAsB,EAAE;YAC9B,MAAM,uBAAA,IAAI,yDAAsB,CAAC;YACjC,OAAO;SACR;QAED,IAAI;YACF,uBAAA,IAAI,qDACF,uBAAA,IAAI,2DAAwB,CAAC,uBAAuB,EAAE,MAAA,CAAC;YAEzD,UAAU,GAAG,MAAM,uBAAA,IAAI,yDAAsB,CAAC;SAC/C;gBAAS;YACR,uBAAA,IAAI,qDAAyB,SAAS,MAAA,CAAC;SACxC;QAED,uBAAA,IAAI,wFAAa,MAAjB,IAAI,EAAc,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACnD,CAAC;IAiBD;;OAEG;IACH,MAAM;QACJ,uBAAA,IAAI,yCAAa,KAAK,MAAA,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,uBAAA,IAAI,yCAAa,IAAI,MAAA,CAAC;IACxB,CAAC;CACF;AAvHD,kEAuHC;;IA7DG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,uBAAA,IAAI,kDAAe,CAAC;AACtE,CAAC,+FAsCY,kBAAgC;IAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;QACf,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\n\nimport type { AbstractClientConfigApiService } from './client-config-api-service/abstract-client-config-api-service';\nimport type {\n FeatureFlags,\n ServiceResponse,\n} from './remote-feature-flag-controller-types';\n\n// === GENERAL ===\n\nexport const controllerName = 'RemoteFeatureFlagController';\nexport const DEFAULT_CACHE_DURATION = 24 * 60 * 60 * 1000; // 1 day\n\n// === STATE ===\n\nexport type RemoteFeatureFlagControllerState = {\n remoteFeatureFlags: FeatureFlags;\n cacheTimestamp: number;\n};\n\nconst remoteFeatureFlagControllerMetadata = {\n remoteFeatureFlags: { persist: true, anonymous: true },\n cacheTimestamp: { persist: true, anonymous: true },\n};\n\n// === MESSENGER ===\n\nexport type RemoteFeatureFlagControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n RemoteFeatureFlagControllerState\n >;\n\nexport type RemoteFeatureFlagControllerGetRemoteFeatureFlagAction = {\n type: `${typeof controllerName}:updateRemoteFeatureFlags`;\n handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];\n};\n\nexport type RemoteFeatureFlagControllerActions =\n RemoteFeatureFlagControllerGetStateAction;\n\nexport type AllowedActions = never;\n\nexport type RemoteFeatureFlagControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n RemoteFeatureFlagControllerState\n >;\n\nexport type RemoteFeatureFlagControllerEvents =\n RemoteFeatureFlagControllerStateChangeEvent;\n\nexport type AllowedEvents = never;\n\nexport type RemoteFeatureFlagControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n RemoteFeatureFlagControllerActions | AllowedActions,\n RemoteFeatureFlagControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\n/**\n * Returns the default state for the RemoteFeatureFlagController.\n *\n * @returns The default controller state.\n */\nexport function getDefaultRemoteFeatureFlagControllerState(): RemoteFeatureFlagControllerState {\n return {\n remoteFeatureFlags: {},\n cacheTimestamp: 0,\n };\n}\n\n/**\n * The RemoteFeatureFlagController manages the retrieval and caching of remote feature flags.\n * It fetches feature flags from a remote API, caches them, and provides methods to access\n * and manage these flags. The controller ensures that feature flags are refreshed based on\n * a specified interval and handles cases where the controller is disabled or the network is unavailable.\n */\nexport class RemoteFeatureFlagController extends BaseController<\n typeof controllerName,\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerMessenger\n> {\n readonly #fetchInterval: number;\n\n #disabled: boolean;\n\n #clientConfigApiService: AbstractClientConfigApiService;\n\n #inProgressFlagUpdate?: Promise<ServiceResponse>;\n\n /**\n * Constructs a new RemoteFeatureFlagController instance.\n *\n * @param options - The controller options.\n * @param options.messenger - The controller messenger used for communication.\n * @param options.state - The initial state of the controller.\n * @param options.clientConfigApiService - The service instance to fetch remote feature flags.\n * @param options.fetchInterval - The interval in milliseconds before cached flags expire. Defaults to 1 day.\n * @param options.disabled - Determines if the controller should be disabled initially. Defaults to false.\n */\n constructor({\n messenger,\n state,\n clientConfigApiService,\n fetchInterval = DEFAULT_CACHE_DURATION,\n disabled = false,\n }: {\n messenger: RemoteFeatureFlagControllerMessenger;\n state?: Partial<RemoteFeatureFlagControllerState>;\n clientConfigApiService: AbstractClientConfigApiService;\n fetchInterval?: number;\n disabled?: boolean;\n }) {\n super({\n name: controllerName,\n metadata: remoteFeatureFlagControllerMetadata,\n messenger,\n state: {\n ...getDefaultRemoteFeatureFlagControllerState(),\n ...state,\n },\n });\n\n this.#fetchInterval = fetchInterval;\n this.#disabled = disabled;\n this.#clientConfigApiService = clientConfigApiService;\n }\n\n /**\n * Checks if the cached feature flags are expired based on the fetch interval.\n *\n * @returns Whether the cache is expired (`true`) or still valid (`false`).\n * @private\n */\n #isCacheExpired(): boolean {\n return Date.now() - this.state.cacheTimestamp > this.#fetchInterval;\n }\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 * @returns A promise that resolves to the current set of feature flags.\n */\n async updateRemoteFeatureFlags(): Promise<void> {\n if (this.#disabled || !this.#isCacheExpired()) {\n return;\n }\n\n let serverData;\n\n if (this.#inProgressFlagUpdate) {\n await this.#inProgressFlagUpdate;\n return;\n }\n\n try {\n this.#inProgressFlagUpdate =\n this.#clientConfigApiService.fetchRemoteFeatureFlags();\n\n serverData = await this.#inProgressFlagUpdate;\n } finally {\n this.#inProgressFlagUpdate = undefined;\n }\n\n this.#updateCache(serverData.remoteFeatureFlags);\n }\n\n /**\n * Updates the controller's state with new feature flags and resets the cache timestamp.\n *\n * @param remoteFeatureFlags - The new feature flags to cache.\n * @private\n */\n #updateCache(remoteFeatureFlags: FeatureFlags) {\n this.update(() => {\n return {\n remoteFeatureFlags,\n cacheTimestamp: Date.now(),\n };\n });\n }\n\n /**\n * Enables the controller, allowing it to make network requests.\n */\n enable(): void {\n this.#disabled = false;\n }\n\n /**\n * Disables the controller, preventing it from making network requests.\n */\n disable(): void {\n this.#disabled = true;\n }\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from "@metamask/base-controller";
|
|
2
|
+
import { BaseController } from "@metamask/base-controller";
|
|
3
|
+
import type { AbstractClientConfigApiService } from "./client-config-api-service/abstract-client-config-api-service.cjs";
|
|
4
|
+
import type { FeatureFlags } from "./remote-feature-flag-controller-types.cjs";
|
|
5
|
+
export declare const controllerName = "RemoteFeatureFlagController";
|
|
6
|
+
export declare const DEFAULT_CACHE_DURATION: number;
|
|
7
|
+
export type RemoteFeatureFlagControllerState = {
|
|
8
|
+
remoteFeatureFlags: FeatureFlags;
|
|
9
|
+
cacheTimestamp: number;
|
|
10
|
+
};
|
|
11
|
+
export type RemoteFeatureFlagControllerGetStateAction = ControllerGetStateAction<typeof controllerName, RemoteFeatureFlagControllerState>;
|
|
12
|
+
export type RemoteFeatureFlagControllerGetRemoteFeatureFlagAction = {
|
|
13
|
+
type: `${typeof controllerName}:updateRemoteFeatureFlags`;
|
|
14
|
+
handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];
|
|
15
|
+
};
|
|
16
|
+
export type RemoteFeatureFlagControllerActions = RemoteFeatureFlagControllerGetStateAction;
|
|
17
|
+
export type AllowedActions = never;
|
|
18
|
+
export type RemoteFeatureFlagControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, RemoteFeatureFlagControllerState>;
|
|
19
|
+
export type RemoteFeatureFlagControllerEvents = RemoteFeatureFlagControllerStateChangeEvent;
|
|
20
|
+
export type AllowedEvents = never;
|
|
21
|
+
export type RemoteFeatureFlagControllerMessenger = RestrictedControllerMessenger<typeof controllerName, RemoteFeatureFlagControllerActions | AllowedActions, RemoteFeatureFlagControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the default state for the RemoteFeatureFlagController.
|
|
24
|
+
*
|
|
25
|
+
* @returns The default controller state.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDefaultRemoteFeatureFlagControllerState(): RemoteFeatureFlagControllerState;
|
|
28
|
+
/**
|
|
29
|
+
* The RemoteFeatureFlagController manages the retrieval and caching of remote feature flags.
|
|
30
|
+
* It fetches feature flags from a remote API, caches them, and provides methods to access
|
|
31
|
+
* and manage these flags. The controller ensures that feature flags are refreshed based on
|
|
32
|
+
* a specified interval and handles cases where the controller is disabled or the network is unavailable.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RemoteFeatureFlagController extends BaseController<typeof controllerName, RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerMessenger> {
|
|
35
|
+
#private;
|
|
36
|
+
/**
|
|
37
|
+
* Constructs a new RemoteFeatureFlagController instance.
|
|
38
|
+
*
|
|
39
|
+
* @param options - The controller options.
|
|
40
|
+
* @param options.messenger - The controller messenger used for communication.
|
|
41
|
+
* @param options.state - The initial state of the controller.
|
|
42
|
+
* @param options.clientConfigApiService - The service instance to fetch remote feature flags.
|
|
43
|
+
* @param options.fetchInterval - The interval in milliseconds before cached flags expire. Defaults to 1 day.
|
|
44
|
+
* @param options.disabled - Determines if the controller should be disabled initially. Defaults to false.
|
|
45
|
+
*/
|
|
46
|
+
constructor({ messenger, state, clientConfigApiService, fetchInterval, disabled, }: {
|
|
47
|
+
messenger: RemoteFeatureFlagControllerMessenger;
|
|
48
|
+
state?: Partial<RemoteFeatureFlagControllerState>;
|
|
49
|
+
clientConfigApiService: AbstractClientConfigApiService;
|
|
50
|
+
fetchInterval?: number;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the remote feature flags, fetching from the API if necessary.
|
|
55
|
+
* Uses caching to prevent redundant API calls and handles concurrent fetches.
|
|
56
|
+
*
|
|
57
|
+
* @returns A promise that resolves to the current set of feature flags.
|
|
58
|
+
*/
|
|
59
|
+
updateRemoteFeatureFlags(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Enables the controller, allowing it to make network requests.
|
|
62
|
+
*/
|
|
63
|
+
enable(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Disables the controller, preventing it from making network requests.
|
|
66
|
+
*/
|
|
67
|
+
disable(): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=remote-feature-flag-controller.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-feature-flag-controller.d.cts","sourceRoot":"","sources":["../src/remote-feature-flag-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC9B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,KAAK,EAAE,8BAA8B,EAAE,2EAAuE;AACrH,OAAO,KAAK,EACV,YAAY,EAEb,mDAA+C;AAIhD,eAAO,MAAM,cAAc,gCAAgC,CAAC;AAC5D,eAAO,MAAM,sBAAsB,QAAsB,CAAC;AAI1D,MAAM,MAAM,gCAAgC,GAAG;IAC7C,kBAAkB,EAAE,YAAY,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AASF,MAAM,MAAM,yCAAyC,GACnD,wBAAwB,CACtB,OAAO,cAAc,EACrB,gCAAgC,CACjC,CAAC;AAEJ,MAAM,MAAM,qDAAqD,GAAG;IAClE,IAAI,EAAE,GAAG,OAAO,cAAc,2BAA2B,CAAC;IAC1D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAC5C,yCAAyC,CAAC;AAE5C,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC;AAEnC,MAAM,MAAM,2CAA2C,GACrD,0BAA0B,CACxB,OAAO,cAAc,EACrB,gCAAgC,CACjC,CAAC;AAEJ,MAAM,MAAM,iCAAiC,GAC3C,2CAA2C,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAElC,MAAM,MAAM,oCAAoC,GAC9C,6BAA6B,CAC3B,OAAO,cAAc,EACrB,kCAAkC,GAAG,cAAc,EACnD,iCAAiC,GAAG,aAAa,EACjD,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,0CAA0C,IAAI,gCAAgC,CAK7F;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,SAAQ,cAAc,CAC7D,OAAO,cAAc,EACrB,gCAAgC,EAChC,oCAAoC,CACrC;;IASC;;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,KAAK,EACL,sBAAsB,EACtB,aAAsC,EACtC,QAAgB,GACjB,EAAE;QACD,SAAS,EAAE,oCAAoC,CAAC;QAChD,KAAK,CAAC,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC;QAClD,sBAAsB,EAAE,8BAA8B,CAAC;QACvD,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;IA0BD;;;;;OAKG;IACG,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuC/C;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB"}
|