@metamask-previews/remote-feature-flag-controller 6.1.0-preview-4f4c98e → 6.1.0-preview-c61613ed2

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/client-config-api-service/abstract-client-config-api-service.cjs +3 -0
  3. package/dist/client-config-api-service/abstract-client-config-api-service.cjs.map +1 -0
  4. package/dist/client-config-api-service/{abstract-client-config-api-service.d.ts → abstract-client-config-api-service.d.cts} +3 -3
  5. package/dist/client-config-api-service/abstract-client-config-api-service.d.cts.map +1 -0
  6. package/dist/client-config-api-service/abstract-client-config-api-service.d.mts +17 -0
  7. package/dist/client-config-api-service/abstract-client-config-api-service.d.mts.map +1 -0
  8. package/dist/client-config-api-service/abstract-client-config-api-service.mjs +2 -0
  9. package/dist/client-config-api-service/abstract-client-config-api-service.mjs.map +1 -0
  10. package/dist/client-config-api-service/client-config-api-service.cjs +94 -0
  11. package/dist/client-config-api-service/client-config-api-service.cjs.map +1 -0
  12. package/dist/client-config-api-service/{client-config-api-service.d.ts → client-config-api-service.d.cts} +5 -5
  13. package/dist/client-config-api-service/client-config-api-service.d.cts.map +1 -0
  14. package/dist/client-config-api-service/client-config-api-service.d.mts +108 -0
  15. package/dist/client-config-api-service/client-config-api-service.d.mts.map +1 -0
  16. package/dist/client-config-api-service/{client-config-api-service.js → client-config-api-service.mjs} +3 -3
  17. package/dist/client-config-api-service/client-config-api-service.mjs.map +1 -0
  18. package/dist/constants.cjs +8 -0
  19. package/dist/constants.cjs.map +1 -0
  20. package/dist/{constants.d.ts → constants.d.cts} +1 -1
  21. package/dist/constants.d.cts.map +1 -0
  22. package/dist/constants.d.mts +5 -0
  23. package/dist/constants.d.mts.map +1 -0
  24. package/dist/{constants.js → constants.mjs} +1 -1
  25. package/dist/constants.mjs.map +1 -0
  26. package/dist/index.cjs +15 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.d.cts +8 -0
  29. package/dist/index.d.cts.map +1 -0
  30. package/dist/index.d.mts +8 -0
  31. package/dist/index.d.mts.map +1 -0
  32. package/dist/index.mjs +5 -0
  33. package/dist/index.mjs.map +1 -0
  34. package/dist/remote-feature-flag-controller-method-action-types.cjs +7 -0
  35. package/dist/remote-feature-flag-controller-method-action-types.cjs.map +1 -0
  36. package/dist/{remote-feature-flag-controller-method-action-types.d.ts → remote-feature-flag-controller-method-action-types.d.cts} +2 -2
  37. package/dist/remote-feature-flag-controller-method-action-types.d.cts.map +1 -0
  38. package/dist/remote-feature-flag-controller-method-action-types.d.mts +62 -0
  39. package/dist/remote-feature-flag-controller-method-action-types.d.mts.map +1 -0
  40. package/dist/{remote-feature-flag-controller-method-action-types.js → remote-feature-flag-controller-method-action-types.mjs} +1 -1
  41. package/dist/remote-feature-flag-controller-method-action-types.mjs.map +1 -0
  42. package/dist/remote-feature-flag-controller-types.cjs +32 -0
  43. package/dist/remote-feature-flag-controller-types.cjs.map +1 -0
  44. package/dist/{remote-feature-flag-controller-types.d.ts → remote-feature-flag-controller-types.d.cts} +2 -2
  45. package/dist/remote-feature-flag-controller-types.d.cts.map +1 -0
  46. package/dist/remote-feature-flag-controller-types.d.mts +64 -0
  47. package/dist/remote-feature-flag-controller-types.d.mts.map +1 -0
  48. package/dist/{remote-feature-flag-controller-types.js → remote-feature-flag-controller-types.mjs} +1 -1
  49. package/dist/remote-feature-flag-controller-types.mjs.map +1 -0
  50. package/dist/remote-feature-flag-controller.cjs +436 -0
  51. package/dist/remote-feature-flag-controller.cjs.map +1 -0
  52. package/dist/{remote-feature-flag-controller.d.ts → remote-feature-flag-controller.d.cts} +8 -8
  53. package/dist/remote-feature-flag-controller.d.cts.map +1 -0
  54. package/dist/remote-feature-flag-controller.d.mts +113 -0
  55. package/dist/remote-feature-flag-controller.d.mts.map +1 -0
  56. package/dist/{remote-feature-flag-controller.js → remote-feature-flag-controller.mjs} +5 -5
  57. package/dist/remote-feature-flag-controller.mjs.map +1 -0
  58. package/dist/utils/user-segmentation-utils.cjs +107 -0
  59. package/dist/utils/user-segmentation-utils.cjs.map +1 -0
  60. package/dist/utils/{user-segmentation-utils.d.ts → user-segmentation-utils.d.cts} +3 -3
  61. package/dist/utils/user-segmentation-utils.d.cts.map +1 -0
  62. package/dist/utils/user-segmentation-utils.d.mts +34 -0
  63. package/dist/utils/user-segmentation-utils.d.mts.map +1 -0
  64. package/dist/utils/{user-segmentation-utils.js → user-segmentation-utils.mjs} +3 -3
  65. package/dist/utils/user-segmentation-utils.mjs.map +1 -0
  66. package/dist/utils/version.cjs +78 -0
  67. package/dist/utils/version.cjs.map +1 -0
  68. package/dist/utils/{version.d.ts → version.d.cts} +4 -4
  69. package/dist/utils/version.d.cts.map +1 -0
  70. package/dist/utils/version.d.mts +26 -0
  71. package/dist/utils/version.d.mts.map +1 -0
  72. package/dist/utils/{version.js → version.mjs} +2 -2
  73. package/dist/utils/version.mjs.map +1 -0
  74. package/package.json +16 -12
  75. package/dist/client-config-api-service/abstract-client-config-api-service.d.ts.map +0 -1
  76. package/dist/client-config-api-service/abstract-client-config-api-service.js +0 -2
  77. package/dist/client-config-api-service/abstract-client-config-api-service.js.map +0 -1
  78. package/dist/client-config-api-service/client-config-api-service.d.ts.map +0 -1
  79. package/dist/client-config-api-service/client-config-api-service.js.map +0 -1
  80. package/dist/constants.d.ts.map +0 -1
  81. package/dist/constants.js.map +0 -1
  82. package/dist/index.d.ts +0 -8
  83. package/dist/index.d.ts.map +0 -1
  84. package/dist/index.js +0 -5
  85. package/dist/index.js.map +0 -1
  86. package/dist/remote-feature-flag-controller-method-action-types.d.ts.map +0 -1
  87. package/dist/remote-feature-flag-controller-method-action-types.js.map +0 -1
  88. package/dist/remote-feature-flag-controller-types.d.ts.map +0 -1
  89. package/dist/remote-feature-flag-controller-types.js.map +0 -1
  90. package/dist/remote-feature-flag-controller.d.ts.map +0 -1
  91. package/dist/remote-feature-flag-controller.js.map +0 -1
  92. package/dist/utils/user-segmentation-utils.d.ts.map +0 -1
  93. package/dist/utils/user-segmentation-utils.js.map +0 -1
  94. package/dist/utils/version.d.ts.map +0 -1
  95. package/dist/utils/version.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -51,7 +51,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
51
51
 
52
52
  ### Changed
53
53
 
54
- - **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
55
54
  - **BREAKING:** Threshold feature flags now return the selected `value` directly instead of a `{ name, value }` wrapper. The selected threshold group name is stored separately in `featureFlagThresholdGroups` on controller state when the selected threshold entry includes `name` ([#9289](https://github.com/MetaMask/core/pull/9289))
56
55
  - Merge `localOverrides` into `remoteFeatureFlags` at the controller level so consumers receive effective flag values directly ([#9259](https://github.com/MetaMask/core/pull/9259))
57
56
  - Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074))
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=abstract-client-config-api-service.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-client-config-api-service.cjs","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,5 +1,5 @@
1
- import type { ServicePolicy } from '@metamask/controller-utils';
2
- import type { ServiceResponse } from '../remote-feature-flag-controller-types.js';
1
+ import type { ServicePolicy } from "@metamask/controller-utils";
2
+ import type { ServiceResponse } from "../remote-feature-flag-controller-types.cjs";
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.ts.map
17
+ //# sourceMappingURL=abstract-client-config-api-service.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-client-config-api-service.d.cts","sourceRoot":"","sources":["../../src/client-config-api-service/abstract-client-config-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,oDAAmD;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,17 @@
1
+ import type { ServicePolicy } from "@metamask/controller-utils";
2
+ import type { ServiceResponse } from "../remote-feature-flag-controller-types.mjs";
3
+ /**
4
+ * A service object responsible for fetching feature flags.
5
+ */
6
+ export type AbstractClientConfigApiService = Partial<Pick<ServicePolicy, 'onBreak' | 'onDegraded'>> & {
7
+ /**
8
+ * Fetches feature flags from the API with specific client, distribution, and
9
+ * environment parameters. Provides structured error handling, including
10
+ * fallback to cached data if available.
11
+ *
12
+ * @returns An object of feature flags and their boolean values or a
13
+ * structured error object.
14
+ */
15
+ fetchRemoteFeatureFlags(): Promise<ServiceResponse>;
16
+ };
17
+ //# sourceMappingURL=abstract-client-config-api-service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-client-config-api-service.d.mts","sourceRoot":"","sources":["../../src/client-config-api-service/abstract-client-config-api-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,oDAAmD;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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=abstract-client-config-api-service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-client-config-api-service.mjs","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"]}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ClientConfigApiService_instances, _ClientConfigApiService_fetch, _ClientConfigApiService_policy, _ClientConfigApiService_client, _ClientConfigApiService_distribution, _ClientConfigApiService_environment, _ClientConfigApiService_flattenFeatureFlags;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ClientConfigApiService = void 0;
16
+ const controller_utils_1 = require("@metamask/controller-utils");
17
+ const constants_js_1 = require("../constants.cjs");
18
+ /**
19
+ * This service is responsible for fetching feature flags from the ClientConfig API.
20
+ */
21
+ class ClientConfigApiService {
22
+ constructor({ fetch: fetchFunction, retries = controller_utils_1.DEFAULT_MAX_RETRIES, maximumConsecutiveFailures = controller_utils_1.DEFAULT_MAX_CONSECUTIVE_FAILURES, circuitBreakDuration = controller_utils_1.DEFAULT_CIRCUIT_BREAK_DURATION, onBreak, onDegraded, config, }) {
23
+ _ClientConfigApiService_instances.add(this);
24
+ _ClientConfigApiService_fetch.set(this, void 0);
25
+ _ClientConfigApiService_policy.set(this, void 0);
26
+ _ClientConfigApiService_client.set(this, void 0);
27
+ _ClientConfigApiService_distribution.set(this, void 0);
28
+ _ClientConfigApiService_environment.set(this, void 0);
29
+ __classPrivateFieldSet(this, _ClientConfigApiService_fetch, fetchFunction, "f");
30
+ __classPrivateFieldSet(this, _ClientConfigApiService_client, config.client, "f");
31
+ __classPrivateFieldSet(this, _ClientConfigApiService_distribution, config.distribution, "f");
32
+ __classPrivateFieldSet(this, _ClientConfigApiService_environment, config.environment, "f");
33
+ __classPrivateFieldSet(this, _ClientConfigApiService_policy, (0, controller_utils_1.createServicePolicy)({
34
+ maxRetries: retries,
35
+ maxConsecutiveFailures: maximumConsecutiveFailures,
36
+ circuitBreakDuration,
37
+ }), "f");
38
+ if (onBreak) {
39
+ __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onBreak(onBreak);
40
+ }
41
+ if (onDegraded) {
42
+ __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onDegraded(onDegraded);
43
+ }
44
+ }
45
+ /**
46
+ * Listens for when the request to the API fails too many times in a row.
47
+ *
48
+ * @param args - The same arguments that {@link ServicePolicy.onBreak}
49
+ * takes.
50
+ * @returns What {@link ServicePolicy.onBreak} returns.
51
+ */
52
+ onBreak(...args) {
53
+ return __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onBreak(...args);
54
+ }
55
+ /**
56
+ * Listens for when the API is degraded.
57
+ *
58
+ * @param args - The same arguments that {@link ServicePolicy.onDegraded}
59
+ * takes.
60
+ * @returns What {@link ServicePolicy.onDegraded} returns.
61
+ */
62
+ onDegraded(...args) {
63
+ return __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").onDegraded(...args);
64
+ }
65
+ /**
66
+ * Fetches feature flags from the API with specific client, distribution, and environment parameters.
67
+ * Provides structured error handling, including fallback to cached data if available.
68
+ *
69
+ * @returns An object of feature flags and their boolean values or a structured error object.
70
+ */
71
+ async fetchRemoteFeatureFlags() {
72
+ const url = `${constants_js_1.BASE_URL}/flags?client=${__classPrivateFieldGet(this, _ClientConfigApiService_client, "f")}&distribution=${__classPrivateFieldGet(this, _ClientConfigApiService_distribution, "f")}&environment=${__classPrivateFieldGet(this, _ClientConfigApiService_environment, "f")}`;
73
+ const response = await __classPrivateFieldGet(this, _ClientConfigApiService_policy, "f").execute(() => __classPrivateFieldGet(this, _ClientConfigApiService_fetch, "f").call(this, url, { cache: 'no-cache' }));
74
+ if (!response.ok) {
75
+ throw new Error('Failed to fetch remote feature flags');
76
+ }
77
+ const data = await response.json();
78
+ if (!Array.isArray(data)) {
79
+ throw new Error('Feature flags api did not return an array');
80
+ }
81
+ const remoteFeatureFlags = __classPrivateFieldGet(this, _ClientConfigApiService_instances, "m", _ClientConfigApiService_flattenFeatureFlags).call(this, data);
82
+ return {
83
+ remoteFeatureFlags,
84
+ cacheTimestamp: Date.now(),
85
+ };
86
+ }
87
+ }
88
+ exports.ClientConfigApiService = ClientConfigApiService;
89
+ _ClientConfigApiService_fetch = new WeakMap(), _ClientConfigApiService_policy = new WeakMap(), _ClientConfigApiService_client = new WeakMap(), _ClientConfigApiService_distribution = new WeakMap(), _ClientConfigApiService_environment = new WeakMap(), _ClientConfigApiService_instances = new WeakSet(), _ClientConfigApiService_flattenFeatureFlags = function _ClientConfigApiService_flattenFeatureFlags(responseData) {
90
+ return responseData.reduce((acc, curr) => {
91
+ return { ...acc, ...curr };
92
+ }, {});
93
+ };
94
+ //# sourceMappingURL=client-config-api-service.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-config-api-service.cjs","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iEAKoC;AAIpC,mDAA2C;AAW3C;;GAEG;AACH,MAAa,sBAAsB;IAwFjC,YAAY,EACV,KAAK,EAAE,aAAa,EACpB,OAAO,GAAG,sCAAmB,EAC7B,0BAA0B,GAAG,mDAAgC,EAC7D,oBAAoB,GAAG,iDAA8B,EACrD,OAAO,EACP,UAAU,EACV,MAAM,GAaP;;QA3GQ,gDAAqB;QAErB,iDAAuB;QAEvB,iDAAoB;QAEpB,uDAAgC;QAEhC,sDAA8B;QAoGrC,uBAAA,IAAI,iCAAU,aAAa,MAAA,CAAC;QAC5B,uBAAA,IAAI,kCAAW,MAAM,CAAC,MAAM,MAAA,CAAC;QAC7B,uBAAA,IAAI,wCAAiB,MAAM,CAAC,YAAY,MAAA,CAAC;QACzC,uBAAA,IAAI,uCAAgB,MAAM,CAAC,WAAW,MAAA,CAAC;QAEvC,uBAAA,IAAI,kCAAW,IAAA,sCAAmB,EAAC;YACjC,UAAU,EAAE,OAAO;YACnB,sBAAsB,EAAE,0BAA0B;YAClD,oBAAoB;SACrB,CAAC,MAAA,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAA0C;QACnD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAA6C;QACzD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,MAAM,GAAG,GAAG,GAAG,uBAAQ,iBAAiB,uBAAA,IAAI,sCAAQ,iBAClD,uBAAA,IAAI,4CACN,gBAAgB,uBAAA,IAAI,2CAAa,EAAE,CAAC;QAEpC,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAC/C,uBAAA,IAAI,qCAAO,MAAX,IAAI,EAAQ,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CACxC,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,kBAAkB,GAAG,uBAAA,IAAI,sFAAqB,MAAzB,IAAI,EAAsB,IAAI,CAAC,CAAC;QAE3D,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC3B,CAAC;IACJ,CAAC;CAgBF;AApMD,wDAoMC;gZALsB,YAA6B;IAChD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACvC,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import {\n createServicePolicy,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n} from '@metamask/controller-utils';\nimport type { ServicePolicy } from '@metamask/controller-utils';\nimport type { IDisposable } from 'cockatiel';\n\nimport { BASE_URL } from '../constants.js';\nimport type {\n FeatureFlags,\n ClientType,\n DistributionType,\n EnvironmentType,\n ServiceResponse,\n ApiDataResponse,\n} from '../remote-feature-flag-controller-types.js';\nimport type { AbstractClientConfigApiService } from './abstract-client-config-api-service.js';\n\n/**\n * This service is responsible for fetching feature flags from the ClientConfig API.\n */\nexport class ClientConfigApiService implements AbstractClientConfigApiService {\n readonly #fetch: typeof fetch;\n\n readonly #policy: ServicePolicy;\n\n readonly #client: ClientType;\n\n readonly #distribution: DistributionType;\n\n readonly #environment: EnvironmentType;\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @deprecated This signature is deprecated; please use the `onBreak` and\n * `onDegraded` methods instead.\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.onBreak - Callback for when the circuit breaks, useful\n * for capturing metrics about network failures.\n * @param args.onDegraded - Callback for when the API responds successfully\n * but takes too long to respond (5 seconds or more).\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n constructor({\n fetch: fetchFunction,\n retries = DEFAULT_MAX_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n onBreak,\n onDegraded,\n config,\n }: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n }) {\n this.#fetch = fetchFunction;\n this.#client = config.client;\n this.#distribution = config.distribution;\n this.#environment = config.environment;\n\n this.#policy = createServicePolicy({\n maxRetries: retries,\n maxConsecutiveFailures: maximumConsecutiveFailures,\n circuitBreakDuration,\n });\n if (onBreak) {\n this.#policy.onBreak(onBreak);\n }\n if (onDegraded) {\n this.#policy.onDegraded(onDegraded);\n }\n }\n\n /**\n * Listens for when the request to the API fails too many times in a row.\n *\n * @param args - The same arguments that {@link ServicePolicy.onBreak}\n * takes.\n * @returns What {@link ServicePolicy.onBreak} returns.\n */\n onBreak(...args: Parameters<ServicePolicy['onBreak']>): IDisposable {\n return this.#policy.onBreak(...args);\n }\n\n /**\n * Listens for when the API is degraded.\n *\n * @param args - The same arguments that {@link ServicePolicy.onDegraded}\n * takes.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n */\n onDegraded(...args: Parameters<ServicePolicy['onDegraded']>): IDisposable {\n return this.#policy.onDegraded(...args);\n }\n\n /**\n * Fetches feature flags from the API with specific client, distribution, and environment parameters.\n * Provides structured error handling, including fallback to cached data if available.\n *\n * @returns An object of feature flags and their boolean values or a structured error object.\n */\n public async fetchRemoteFeatureFlags(): Promise<ServiceResponse> {\n const url = `${BASE_URL}/flags?client=${this.#client}&distribution=${\n this.#distribution\n }&environment=${this.#environment}`;\n\n const response = await this.#policy.execute(() =>\n this.#fetch(url, { cache: 'no-cache' }),\n );\n\n if (!response.ok) {\n throw new Error('Failed to fetch remote feature flags');\n }\n\n const data = await response.json();\n\n if (!Array.isArray(data)) {\n throw new Error('Feature flags api did not return an array');\n }\n\n const remoteFeatureFlags = this.#flattenFeatureFlags(data);\n\n return {\n remoteFeatureFlags,\n cacheTimestamp: Date.now(),\n };\n }\n\n /**\n * Flattens an array of feature flag objects into a single feature flags object.\n *\n * @param responseData - Array of objects containing feature flag key-value pairs\n * @returns A single object containing all feature flags merged together\n * @example\n * // Input: [{ flag1: true }, { flag2: [] }]\n * // Output: { flag1: true, flag2: [] }\n */\n #flattenFeatureFlags(responseData: ApiDataResponse): FeatureFlags {\n return responseData.reduce((acc, curr) => {\n return { ...acc, ...curr };\n }, {});\n }\n}\n"]}
@@ -1,7 +1,7 @@
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';
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.cjs";
4
+ import type { AbstractClientConfigApiService } from "./abstract-client-config-api-service.cjs";
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.ts.map
108
+ //# sourceMappingURL=client-config-api-service.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-config-api-service.d.cts","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAG7C,OAAO,KAAK,EAEV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAEhB,oDAAmD;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,iDAAgD;AAE9F;;GAEG;AACH,qBAAa,sBAAuB,YAAW,8BAA8B;;IAW3E;;;;;;;;;;;;;;;;;;;;;OAqBG;gBACS,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;gBAES,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;QACxB,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAyCD;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,WAAW;IAInE;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG,WAAW;IAIzE;;;;;OAKG;IACU,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC;CAyCjE"}
@@ -0,0 +1,108 @@
1
+ import type { ServicePolicy } from "@metamask/controller-utils";
2
+ import type { IDisposable } from "cockatiel";
3
+ import type { ClientType, DistributionType, EnvironmentType, ServiceResponse } from "../remote-feature-flag-controller-types.mjs";
4
+ import type { AbstractClientConfigApiService } from "./abstract-client-config-api-service.mjs";
5
+ /**
6
+ * This service is responsible for fetching feature flags from the ClientConfig API.
7
+ */
8
+ export declare class ClientConfigApiService implements AbstractClientConfigApiService {
9
+ #private;
10
+ /**
11
+ * Constructs a new ClientConfigApiService object.
12
+ *
13
+ * @param args - The arguments.
14
+ * @param args.fetch - A function that can be used to make an HTTP request.
15
+ * If your JavaScript environment supports `fetch` natively, you'll probably
16
+ * want to pass that; otherwise you can pass an equivalent (such as `fetch`
17
+ * via `node-fetch`).
18
+ * @param args.retries - Number of retry attempts for each fetch request.
19
+ * @param args.maximumConsecutiveFailures - The maximum number of consecutive
20
+ * failures allowed before breaking the circuit and pausing further fetch
21
+ * attempts.
22
+ * @param args.circuitBreakDuration - The amount of time to wait when the
23
+ * circuit breaks from too many consecutive failures.
24
+ * @param args.config - The configuration object, includes client,
25
+ * distribution, and environment.
26
+ * @param args.config.client - The client type (e.g., 'extension', 'mobile').
27
+ * @param args.config.distribution - The distribution type (e.g., 'main',
28
+ * 'flask').
29
+ * @param args.config.environment - The environment type (e.g., 'prod', 'rc',
30
+ * 'dev').
31
+ */
32
+ constructor(args: {
33
+ fetch: typeof fetch;
34
+ retries?: number;
35
+ maximumConsecutiveFailures?: number;
36
+ circuitBreakDuration?: number;
37
+ config: {
38
+ client: ClientType;
39
+ distribution: DistributionType;
40
+ environment: EnvironmentType;
41
+ };
42
+ });
43
+ /**
44
+ * Constructs a new ClientConfigApiService object.
45
+ *
46
+ * @deprecated This signature is deprecated; please use the `onBreak` and
47
+ * `onDegraded` methods instead.
48
+ * @param args - The arguments.
49
+ * @param args.fetch - A function that can be used to make an HTTP request.
50
+ * If your JavaScript environment supports `fetch` natively, you'll probably
51
+ * want to pass that; otherwise you can pass an equivalent (such as `fetch`
52
+ * via `node-fetch`).
53
+ * @param args.retries - Number of retry attempts for each fetch request.
54
+ * @param args.maximumConsecutiveFailures - The maximum number of consecutive
55
+ * failures allowed before breaking the circuit and pausing further fetch
56
+ * attempts.
57
+ * @param args.circuitBreakDuration - The amount of time to wait when the
58
+ * circuit breaks from too many consecutive failures.
59
+ * @param args.onBreak - Callback for when the circuit breaks, useful
60
+ * for capturing metrics about network failures.
61
+ * @param args.onDegraded - Callback for when the API responds successfully
62
+ * but takes too long to respond (5 seconds or more).
63
+ * @param args.config - The configuration object, includes client,
64
+ * distribution, and environment.
65
+ * @param args.config.client - The client type (e.g., 'extension', 'mobile').
66
+ * @param args.config.distribution - The distribution type (e.g., 'main',
67
+ * 'flask').
68
+ * @param args.config.environment - The environment type (e.g., 'prod', 'rc',
69
+ * 'dev').
70
+ */
71
+ constructor(args: {
72
+ fetch: typeof fetch;
73
+ retries?: number;
74
+ maximumConsecutiveFailures?: number;
75
+ circuitBreakDuration?: number;
76
+ onBreak?: () => void;
77
+ onDegraded?: () => void;
78
+ config: {
79
+ client: ClientType;
80
+ distribution: DistributionType;
81
+ environment: EnvironmentType;
82
+ };
83
+ });
84
+ /**
85
+ * Listens for when the request to the API fails too many times in a row.
86
+ *
87
+ * @param args - The same arguments that {@link ServicePolicy.onBreak}
88
+ * takes.
89
+ * @returns What {@link ServicePolicy.onBreak} returns.
90
+ */
91
+ onBreak(...args: Parameters<ServicePolicy['onBreak']>): IDisposable;
92
+ /**
93
+ * Listens for when the API is degraded.
94
+ *
95
+ * @param args - The same arguments that {@link ServicePolicy.onDegraded}
96
+ * takes.
97
+ * @returns What {@link ServicePolicy.onDegraded} returns.
98
+ */
99
+ onDegraded(...args: Parameters<ServicePolicy['onDegraded']>): IDisposable;
100
+ /**
101
+ * Fetches feature flags from the API with specific client, distribution, and environment parameters.
102
+ * Provides structured error handling, including fallback to cached data if available.
103
+ *
104
+ * @returns An object of feature flags and their boolean values or a structured error object.
105
+ */
106
+ fetchRemoteFeatureFlags(): Promise<ServiceResponse>;
107
+ }
108
+ //# sourceMappingURL=client-config-api-service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-config-api-service.d.mts","sourceRoot":"","sources":["../../src/client-config-api-service/client-config-api-service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB;AAG7C,OAAO,KAAK,EAEV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAEhB,oDAAmD;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,iDAAgD;AAE9F;;GAEG;AACH,qBAAa,sBAAuB,YAAW,8BAA8B;;IAW3E;;;;;;;;;;;;;;;;;;;;;OAqBG;gBACS,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;gBAES,IAAI,EAAE;QAChB,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;QACxB,MAAM,EAAE;YACN,MAAM,EAAE,UAAU,CAAC;YACnB,YAAY,EAAE,gBAAgB,CAAC;YAC/B,WAAW,EAAE,eAAe,CAAC;SAC9B,CAAC;KACH;IAyCD;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,WAAW;IAInE;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG,WAAW;IAIzE;;;;;OAKG;IACU,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC;CAyCjE"}
@@ -10,8 +10,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _ClientConfigApiService_instances, _ClientConfigApiService_fetch, _ClientConfigApiService_policy, _ClientConfigApiService_client, _ClientConfigApiService_distribution, _ClientConfigApiService_environment, _ClientConfigApiService_flattenFeatureFlags;
13
- import { createServicePolicy, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES, } from '@metamask/controller-utils';
14
- import { BASE_URL } from '../constants.js';
13
+ import { createServicePolicy, DEFAULT_CIRCUIT_BREAK_DURATION, DEFAULT_MAX_CONSECUTIVE_FAILURES, DEFAULT_MAX_RETRIES } from "@metamask/controller-utils";
14
+ import { BASE_URL } from "../constants.mjs";
15
15
  /**
16
16
  * This service is responsible for fetching feature flags from the ClientConfig API.
17
17
  */
@@ -87,4 +87,4 @@ _ClientConfigApiService_fetch = new WeakMap(), _ClientConfigApiService_policy =
87
87
  return { ...acc, ...curr };
88
88
  }, {});
89
89
  };
90
- //# sourceMappingURL=client-config-api-service.js.map
90
+ //# 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":";;;;;;;;;;;;AAAA,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,gCAAgC,EAChC,mBAAmB,EACpB,mCAAmC;AAIpC,OAAO,EAAE,QAAQ,EAAE,yBAAwB;AAW3C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAwFjC,YAAY,EACV,KAAK,EAAE,aAAa,EACpB,OAAO,GAAG,mBAAmB,EAC7B,0BAA0B,GAAG,gCAAgC,EAC7D,oBAAoB,GAAG,8BAA8B,EACrD,OAAO,EACP,UAAU,EACV,MAAM,GAaP;;QA3GQ,gDAAqB;QAErB,iDAAuB;QAEvB,iDAAoB;QAEpB,uDAAgC;QAEhC,sDAA8B;QAoGrC,uBAAA,IAAI,iCAAU,aAAa,MAAA,CAAC;QAC5B,uBAAA,IAAI,kCAAW,MAAM,CAAC,MAAM,MAAA,CAAC;QAC7B,uBAAA,IAAI,wCAAiB,MAAM,CAAC,YAAY,MAAA,CAAC;QACzC,uBAAA,IAAI,uCAAgB,MAAM,CAAC,WAAW,MAAA,CAAC;QAEvC,uBAAA,IAAI,kCAAW,mBAAmB,CAAC;YACjC,UAAU,EAAE,OAAO;YACnB,sBAAsB,EAAE,0BAA0B;YAClD,oBAAoB;SACrB,CAAC,MAAA,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,IAA0C;QACnD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,IAA6C;QACzD,OAAO,uBAAA,IAAI,sCAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,uBAAuB;QAClC,MAAM,GAAG,GAAG,GAAG,QAAQ,iBAAiB,uBAAA,IAAI,sCAAQ,iBAClD,uBAAA,IAAI,4CACN,gBAAgB,uBAAA,IAAI,2CAAa,EAAE,CAAC;QAEpC,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,sCAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAC/C,uBAAA,IAAI,qCAAO,MAAX,IAAI,EAAQ,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CACxC,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,kBAAkB,GAAG,uBAAA,IAAI,sFAAqB,MAAzB,IAAI,EAAsB,IAAI,CAAC,CAAC;QAE3D,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC3B,CAAC;IACJ,CAAC;CAgBF;gZALsB,YAA6B;IAChD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACvC,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import {\n createServicePolicy,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n} from '@metamask/controller-utils';\nimport type { ServicePolicy } from '@metamask/controller-utils';\nimport type { IDisposable } from 'cockatiel';\n\nimport { BASE_URL } from '../constants.js';\nimport type {\n FeatureFlags,\n ClientType,\n DistributionType,\n EnvironmentType,\n ServiceResponse,\n ApiDataResponse,\n} from '../remote-feature-flag-controller-types.js';\nimport type { AbstractClientConfigApiService } from './abstract-client-config-api-service.js';\n\n/**\n * This service is responsible for fetching feature flags from the ClientConfig API.\n */\nexport class ClientConfigApiService implements AbstractClientConfigApiService {\n readonly #fetch: typeof fetch;\n\n readonly #policy: ServicePolicy;\n\n readonly #client: ClientType;\n\n readonly #distribution: DistributionType;\n\n readonly #environment: EnvironmentType;\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n /**\n * Constructs a new ClientConfigApiService object.\n *\n * @deprecated This signature is deprecated; please use the `onBreak` and\n * `onDegraded` methods instead.\n * @param args - The arguments.\n * @param args.fetch - A function that can be used to make an HTTP request.\n * If your JavaScript environment supports `fetch` natively, you'll probably\n * want to pass that; otherwise you can pass an equivalent (such as `fetch`\n * via `node-fetch`).\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further fetch\n * attempts.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n * @param args.onBreak - Callback for when the circuit breaks, useful\n * for capturing metrics about network failures.\n * @param args.onDegraded - Callback for when the API responds successfully\n * but takes too long to respond (5 seconds or more).\n * @param args.config - The configuration object, includes client,\n * distribution, and environment.\n * @param args.config.client - The client type (e.g., 'extension', 'mobile').\n * @param args.config.distribution - The distribution type (e.g., 'main',\n * 'flask').\n * @param args.config.environment - The environment type (e.g., 'prod', 'rc',\n * 'dev').\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n constructor(args: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n });\n\n constructor({\n fetch: fetchFunction,\n retries = DEFAULT_MAX_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n onBreak,\n onDegraded,\n config,\n }: {\n fetch: typeof fetch;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n config: {\n client: ClientType;\n distribution: DistributionType;\n environment: EnvironmentType;\n };\n }) {\n this.#fetch = fetchFunction;\n this.#client = config.client;\n this.#distribution = config.distribution;\n this.#environment = config.environment;\n\n this.#policy = createServicePolicy({\n maxRetries: retries,\n maxConsecutiveFailures: maximumConsecutiveFailures,\n circuitBreakDuration,\n });\n if (onBreak) {\n this.#policy.onBreak(onBreak);\n }\n if (onDegraded) {\n this.#policy.onDegraded(onDegraded);\n }\n }\n\n /**\n * Listens for when the request to the API fails too many times in a row.\n *\n * @param args - The same arguments that {@link ServicePolicy.onBreak}\n * takes.\n * @returns What {@link ServicePolicy.onBreak} returns.\n */\n onBreak(...args: Parameters<ServicePolicy['onBreak']>): IDisposable {\n return this.#policy.onBreak(...args);\n }\n\n /**\n * Listens for when the API is degraded.\n *\n * @param args - The same arguments that {@link ServicePolicy.onDegraded}\n * takes.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n */\n onDegraded(...args: Parameters<ServicePolicy['onDegraded']>): IDisposable {\n return this.#policy.onDegraded(...args);\n }\n\n /**\n * Fetches feature flags from the API with specific client, distribution, and environment parameters.\n * Provides structured error handling, including fallback to cached data if available.\n *\n * @returns An object of feature flags and their boolean values or a structured error object.\n */\n public async fetchRemoteFeatureFlags(): Promise<ServiceResponse> {\n const url = `${BASE_URL}/flags?client=${this.#client}&distribution=${\n this.#distribution\n }&environment=${this.#environment}`;\n\n const response = await this.#policy.execute(() =>\n this.#fetch(url, { cache: 'no-cache' }),\n );\n\n if (!response.ok) {\n throw new Error('Failed to fetch remote feature flags');\n }\n\n const data = await response.json();\n\n if (!Array.isArray(data)) {\n throw new Error('Feature flags api did not return an array');\n }\n\n const remoteFeatureFlags = this.#flattenFeatureFlags(data);\n\n return {\n remoteFeatureFlags,\n cacheTimestamp: Date.now(),\n };\n }\n\n /**\n * Flattens an array of feature flag objects into a single feature flags object.\n *\n * @param responseData - Array of objects containing feature flag key-value pairs\n * @returns A single object containing all feature flags merged together\n * @example\n * // Input: [{ flag1: true }, { flag2: [] }]\n * // Output: { flag1: true, flag2: [] }\n */\n #flattenFeatureFlags(responseData: ApiDataResponse): FeatureFlags {\n return responseData.reduce((acc, curr) => {\n return { ...acc, ...curr };\n }, {});\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_URL = void 0;
4
+ /**
5
+ * ClientConfig API base URL.
6
+ */
7
+ exports.BASE_URL = 'https://client-config.api.cx.metamask.io/v1';
8
+ //# sourceMappingURL=constants.cjs.map
@@ -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"]}
@@ -2,4 +2,4 @@
2
2
  * ClientConfig API base URL.
3
3
  */
4
4
  export declare const BASE_URL = "https://client-config.api.cx.metamask.io/v1";
5
- //# sourceMappingURL=constants.d.ts.map
5
+ //# sourceMappingURL=constants.d.cts.map
@@ -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,5 @@
1
+ /**
2
+ * ClientConfig API base URL.
3
+ */
4
+ export declare const BASE_URL = "https://client-config.api.cx.metamask.io/v1";
5
+ //# sourceMappingURL=constants.d.mts.map
@@ -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"}
@@ -2,4 +2,4 @@
2
2
  * ClientConfig API base URL.
3
3
  */
4
4
  export const BASE_URL = 'https://client-config.api.cx.metamask.io/v1';
5
- //# sourceMappingURL=constants.js.map
5
+ //# sourceMappingURL=constants.mjs.map
@@ -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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDeterministicRandomNumber = exports.ClientConfigApiService = exports.ThresholdVersion = exports.EnvironmentType = exports.DistributionType = exports.ClientType = exports.RemoteFeatureFlagController = void 0;
4
+ var remote_feature_flag_controller_js_1 = require("./remote-feature-flag-controller.cjs");
5
+ Object.defineProperty(exports, "RemoteFeatureFlagController", { enumerable: true, get: function () { return remote_feature_flag_controller_js_1.RemoteFeatureFlagController; } });
6
+ var remote_feature_flag_controller_types_js_1 = require("./remote-feature-flag-controller-types.cjs");
7
+ Object.defineProperty(exports, "ClientType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.ClientType; } });
8
+ Object.defineProperty(exports, "DistributionType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.DistributionType; } });
9
+ Object.defineProperty(exports, "EnvironmentType", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.EnvironmentType; } });
10
+ Object.defineProperty(exports, "ThresholdVersion", { enumerable: true, get: function () { return remote_feature_flag_controller_types_js_1.ThresholdVersion; } });
11
+ var client_config_api_service_js_1 = require("./client-config-api-service/client-config-api-service.cjs");
12
+ Object.defineProperty(exports, "ClientConfigApiService", { enumerable: true, get: function () { return client_config_api_service_js_1.ClientConfigApiService; } });
13
+ var user_segmentation_utils_js_1 = require("./utils/user-segmentation-utils.cjs");
14
+ Object.defineProperty(exports, "generateDeterministicRandomNumber", { enumerable: true, get: function () { return user_segmentation_utils_js_1.generateDeterministicRandomNumber; } });
15
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,0FAAkF;AAAzE,gJAAA,2BAA2B,OAAA;AAkBpC,sGAKmD;AAJjD,qIAAA,UAAU,OAAA;AACV,2IAAA,gBAAgB,OAAA;AAChB,0IAAA,eAAe,OAAA;AACf,2IAAA,gBAAgB,OAAA;AAIlB,0GAAkG;AAAzF,sIAAA,sBAAsB,OAAA;AAC/B,kFAAuF;AAA9E,+IAAA,iCAAiC,OAAA","sourcesContent":["export { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerMessenger,\n RemoteFeatureFlagControllerActions,\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerEvents,\n RemoteFeatureFlagControllerStateChangeEvent,\n} from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerClearAllFlagOverridesAction,\n RemoteFeatureFlagControllerDisableAction,\n RemoteFeatureFlagControllerEnableAction,\n RemoteFeatureFlagControllerMethodActions,\n RemoteFeatureFlagControllerRemoveFlagOverrideAction,\n RemoteFeatureFlagControllerSetFlagOverrideAction,\n RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction,\n} from './remote-feature-flag-controller-method-action-types.js';\nexport {\n ClientType,\n DistributionType,\n EnvironmentType,\n ThresholdVersion,\n} from './remote-feature-flag-controller-types.js';\n\nexport type { FeatureFlags } from './remote-feature-flag-controller-types.js';\nexport { ClientConfigApiService } from './client-config-api-service/client-config-api-service.js';\nexport { generateDeterministicRandomNumber } from './utils/user-segmentation-utils.js';\n"]}
@@ -0,0 +1,8 @@
1
+ export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.cjs";
2
+ export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerMessenger, RemoteFeatureFlagControllerActions, RemoteFeatureFlagControllerGetStateAction, RemoteFeatureFlagControllerEvents, RemoteFeatureFlagControllerStateChangeEvent, } from "./remote-feature-flag-controller.cjs";
3
+ export type { RemoteFeatureFlagControllerClearAllFlagOverridesAction, RemoteFeatureFlagControllerDisableAction, RemoteFeatureFlagControllerEnableAction, RemoteFeatureFlagControllerMethodActions, RemoteFeatureFlagControllerRemoveFlagOverrideAction, RemoteFeatureFlagControllerSetFlagOverrideAction, RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction, } from "./remote-feature-flag-controller-method-action-types.cjs";
4
+ export { ClientType, DistributionType, EnvironmentType, ThresholdVersion, } from "./remote-feature-flag-controller-types.cjs";
5
+ export type { FeatureFlags } from "./remote-feature-flag-controller-types.cjs";
6
+ export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.cjs";
7
+ export { generateDeterministicRandomNumber } from "./utils/user-segmentation-utils.cjs";
8
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAA4C;AAClF,YAAY,EACV,gCAAgC,EAChC,oCAAoC,EACpC,kCAAkC,EAClC,yCAAyC,EACzC,iCAAiC,EACjC,2CAA2C,GAC5C,6CAA4C;AAC7C,YAAY,EACV,sDAAsD,EACtD,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,mDAAmD,EACnD,gDAAgD,EAChD,yDAAyD,GAC1D,iEAAgE;AACjE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,mDAAkD;AAEnD,YAAY,EAAE,YAAY,EAAE,mDAAkD;AAC9E,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,OAAO,EAAE,iCAAiC,EAAE,4CAA2C"}
@@ -0,0 +1,8 @@
1
+ export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
2
+ export type { RemoteFeatureFlagControllerState, RemoteFeatureFlagControllerMessenger, RemoteFeatureFlagControllerActions, RemoteFeatureFlagControllerGetStateAction, RemoteFeatureFlagControllerEvents, RemoteFeatureFlagControllerStateChangeEvent, } from "./remote-feature-flag-controller.mjs";
3
+ export type { RemoteFeatureFlagControllerClearAllFlagOverridesAction, RemoteFeatureFlagControllerDisableAction, RemoteFeatureFlagControllerEnableAction, RemoteFeatureFlagControllerMethodActions, RemoteFeatureFlagControllerRemoveFlagOverrideAction, RemoteFeatureFlagControllerSetFlagOverrideAction, RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction, } from "./remote-feature-flag-controller-method-action-types.mjs";
4
+ export { ClientType, DistributionType, EnvironmentType, ThresholdVersion, } from "./remote-feature-flag-controller-types.mjs";
5
+ export type { FeatureFlags } from "./remote-feature-flag-controller-types.mjs";
6
+ export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.mjs";
7
+ export { generateDeterministicRandomNumber } from "./utils/user-segmentation-utils.mjs";
8
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAA4C;AAClF,YAAY,EACV,gCAAgC,EAChC,oCAAoC,EACpC,kCAAkC,EAClC,yCAAyC,EACzC,iCAAiC,EACjC,2CAA2C,GAC5C,6CAA4C;AAC7C,YAAY,EACV,sDAAsD,EACtD,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,mDAAmD,EACnD,gDAAgD,EAChD,yDAAyD,GAC1D,iEAAgE;AACjE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,mDAAkD;AAEnD,YAAY,EAAE,YAAY,EAAE,mDAAkD;AAC9E,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,OAAO,EAAE,iCAAiC,EAAE,4CAA2C"}
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ export { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
2
+ export { ClientType, DistributionType, EnvironmentType, ThresholdVersion } from "./remote-feature-flag-controller-types.mjs";
3
+ export { ClientConfigApiService } from "./client-config-api-service/client-config-api-service.mjs";
4
+ export { generateDeterministicRandomNumber } from "./utils/user-segmentation-utils.mjs";
5
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,6CAA4C;AAkBlF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,mDAAkD;AAGnD,OAAO,EAAE,sBAAsB,EAAE,kEAAiE;AAClG,OAAO,EAAE,iCAAiC,EAAE,4CAA2C","sourcesContent":["export { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerState,\n RemoteFeatureFlagControllerMessenger,\n RemoteFeatureFlagControllerActions,\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerEvents,\n RemoteFeatureFlagControllerStateChangeEvent,\n} from './remote-feature-flag-controller.js';\nexport type {\n RemoteFeatureFlagControllerClearAllFlagOverridesAction,\n RemoteFeatureFlagControllerDisableAction,\n RemoteFeatureFlagControllerEnableAction,\n RemoteFeatureFlagControllerMethodActions,\n RemoteFeatureFlagControllerRemoveFlagOverrideAction,\n RemoteFeatureFlagControllerSetFlagOverrideAction,\n RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction,\n} from './remote-feature-flag-controller-method-action-types.js';\nexport {\n ClientType,\n DistributionType,\n EnvironmentType,\n ThresholdVersion,\n} from './remote-feature-flag-controller-types.js';\n\nexport type { FeatureFlags } from './remote-feature-flag-controller-types.js';\nexport { ClientConfigApiService } from './client-config-api-service/client-config-api-service.js';\nexport { generateDeterministicRandomNumber } from './utils/user-segmentation-utils.js';\n"]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=remote-feature-flag-controller-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-feature-flag-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';\n\n/**\n * Retrieves the remote feature flags, fetching from the API if necessary.\n * Uses caching to prevent redundant API calls and handles concurrent fetches.\n *\n * @param force - When `true`, fetch even if the cache has not expired.\n * Defaults to `false`. Has no effect when the controller is disabled.\n * @returns A promise that resolves to the current set of feature flags.\n */\nexport type RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction = {\n type: `RemoteFeatureFlagController:updateRemoteFeatureFlags`;\n handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];\n};\n\n/**\n * Enables the controller, allowing it to make network requests.\n */\nexport type RemoteFeatureFlagControllerEnableAction = {\n type: `RemoteFeatureFlagController:enable`;\n handler: RemoteFeatureFlagController['enable'];\n};\n\n/**\n * Disables the controller, preventing it from making network requests.\n */\nexport type RemoteFeatureFlagControllerDisableAction = {\n type: `RemoteFeatureFlagController:disable`;\n handler: RemoteFeatureFlagController['disable'];\n};\n\n/**\n * Sets a local override for a specific feature flag.\n *\n * @param flagName - The name of the feature flag to override.\n * @param value - The override value for the feature flag.\n */\nexport type RemoteFeatureFlagControllerSetFlagOverrideAction = {\n type: `RemoteFeatureFlagController:setFlagOverride`;\n handler: RemoteFeatureFlagController['setFlagOverride'];\n};\n\n/**\n * Clears the local override for a specific feature flag.\n *\n * @param flagName - The name of the feature flag to clear.\n */\nexport type RemoteFeatureFlagControllerRemoveFlagOverrideAction = {\n type: `RemoteFeatureFlagController:removeFlagOverride`;\n handler: RemoteFeatureFlagController['removeFlagOverride'];\n};\n\n/**\n * Clears all local feature flag overrides.\n */\nexport type RemoteFeatureFlagControllerClearAllFlagOverridesAction = {\n type: `RemoteFeatureFlagController:clearAllFlagOverrides`;\n handler: RemoteFeatureFlagController['clearAllFlagOverrides'];\n};\n\n/**\n * Union of all RemoteFeatureFlagController action types.\n */\nexport type RemoteFeatureFlagControllerMethodActions =\n | RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction\n | RemoteFeatureFlagControllerEnableAction\n | RemoteFeatureFlagControllerDisableAction\n | RemoteFeatureFlagControllerSetFlagOverrideAction\n | RemoteFeatureFlagControllerRemoveFlagOverrideAction\n | RemoteFeatureFlagControllerClearAllFlagOverridesAction;\n"]}
@@ -2,7 +2,7 @@
2
2
  * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
- import type { RemoteFeatureFlagController } from './remote-feature-flag-controller.js';
5
+ import type { RemoteFeatureFlagController } from "./remote-feature-flag-controller.cjs";
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.ts.map
62
+ //# sourceMappingURL=remote-feature-flag-controller-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-feature-flag-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,6CAA4C;AAEvF;;;;;;;GAOG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,2BAA2B,CAAC,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,yDAAyD,GACzD,uCAAuC,GACvC,wCAAwC,GACxC,gDAAgD,GAChD,mDAAmD,GACnD,sDAAsD,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { RemoteFeatureFlagController } from "./remote-feature-flag-controller.mjs";
6
+ /**
7
+ * Retrieves the remote feature flags, fetching from the API if necessary.
8
+ * Uses caching to prevent redundant API calls and handles concurrent fetches.
9
+ *
10
+ * @param force - When `true`, fetch even if the cache has not expired.
11
+ * Defaults to `false`. Has no effect when the controller is disabled.
12
+ * @returns A promise that resolves to the current set of feature flags.
13
+ */
14
+ export type RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction = {
15
+ type: `RemoteFeatureFlagController:updateRemoteFeatureFlags`;
16
+ handler: RemoteFeatureFlagController['updateRemoteFeatureFlags'];
17
+ };
18
+ /**
19
+ * Enables the controller, allowing it to make network requests.
20
+ */
21
+ export type RemoteFeatureFlagControllerEnableAction = {
22
+ type: `RemoteFeatureFlagController:enable`;
23
+ handler: RemoteFeatureFlagController['enable'];
24
+ };
25
+ /**
26
+ * Disables the controller, preventing it from making network requests.
27
+ */
28
+ export type RemoteFeatureFlagControllerDisableAction = {
29
+ type: `RemoteFeatureFlagController:disable`;
30
+ handler: RemoteFeatureFlagController['disable'];
31
+ };
32
+ /**
33
+ * Sets a local override for a specific feature flag.
34
+ *
35
+ * @param flagName - The name of the feature flag to override.
36
+ * @param value - The override value for the feature flag.
37
+ */
38
+ export type RemoteFeatureFlagControllerSetFlagOverrideAction = {
39
+ type: `RemoteFeatureFlagController:setFlagOverride`;
40
+ handler: RemoteFeatureFlagController['setFlagOverride'];
41
+ };
42
+ /**
43
+ * Clears the local override for a specific feature flag.
44
+ *
45
+ * @param flagName - The name of the feature flag to clear.
46
+ */
47
+ export type RemoteFeatureFlagControllerRemoveFlagOverrideAction = {
48
+ type: `RemoteFeatureFlagController:removeFlagOverride`;
49
+ handler: RemoteFeatureFlagController['removeFlagOverride'];
50
+ };
51
+ /**
52
+ * Clears all local feature flag overrides.
53
+ */
54
+ export type RemoteFeatureFlagControllerClearAllFlagOverridesAction = {
55
+ type: `RemoteFeatureFlagController:clearAllFlagOverrides`;
56
+ handler: RemoteFeatureFlagController['clearAllFlagOverrides'];
57
+ };
58
+ /**
59
+ * Union of all RemoteFeatureFlagController action types.
60
+ */
61
+ export type RemoteFeatureFlagControllerMethodActions = RemoteFeatureFlagControllerUpdateRemoteFeatureFlagsAction | RemoteFeatureFlagControllerEnableAction | RemoteFeatureFlagControllerDisableAction | RemoteFeatureFlagControllerSetFlagOverrideAction | RemoteFeatureFlagControllerRemoveFlagOverrideAction | RemoteFeatureFlagControllerClearAllFlagOverridesAction;
62
+ //# sourceMappingURL=remote-feature-flag-controller-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-feature-flag-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/remote-feature-flag-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,6CAA4C;AAEvF;;;;;;;GAOG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,2BAA2B,CAAC,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,yDAAyD,GACzD,uCAAuC,GACvC,wCAAwC,GACxC,gDAAgD,GAChD,mDAAmD,GACnD,sDAAsD,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=remote-feature-flag-controller-method-action-types.js.map
6
+ //# sourceMappingURL=remote-feature-flag-controller-method-action-types.mjs.map