@breadstone/archipel-mcp 0.0.30 → 0.0.32
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/data/guides/feature-flags.md +358 -0
- package/data/guides/index.md +1 -0
- package/data/packages/platform-feature-flags/api/Class.AzureFeatureFlagReader.md +230 -0
- package/data/packages/platform-feature-flags/api/Class.AzureFeatureFlagWriter.md +235 -0
- package/data/packages/platform-feature-flags/api/Class.FeatureFlagError.md +65 -0
- package/data/packages/platform-feature-flags/api/Class.FeatureFlagGuard.md +68 -0
- package/data/packages/platform-feature-flags/api/Class.FeatureFlagModule.md +49 -0
- package/data/packages/platform-feature-flags/api/Class.FeatureFlagReaderPort.md +150 -0
- package/data/packages/platform-feature-flags/api/Class.FeatureFlagWriterPort.md +180 -0
- package/data/packages/platform-feature-flags/api/Class.VercelFeatureFlagReader.md +223 -0
- package/data/packages/platform-feature-flags/api/Class.VercelFeatureFlagWriter.md +240 -0
- package/data/packages/platform-feature-flags/api/Function.FeatureFlag.md +25 -0
- package/data/packages/platform-feature-flags/api/Interface.IFeatureFlagContext.md +46 -0
- package/data/packages/platform-feature-flags/api/Interface.IFeatureFlagDefinition.md +70 -0
- package/data/packages/platform-feature-flags/api/Interface.IFeatureFlagEvaluation.md +46 -0
- package/data/packages/platform-feature-flags/api/Interface.IFeatureFlagModuleOptions.md +61 -0
- package/data/packages/platform-feature-flags/api/Variable.AZURE_APPCONFIG_CONNECTION_STRING.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.AZURE_APPCONFIG_ENDPOINT.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.AZURE_FEATURE_FLAG_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.AZURE_FEATURE_FLAG_KEY_FILTER.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.AZURE_FEATURE_FLAG_REFRESH_INTERVAL.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.FEATURE_FLAG_KEY_METADATA.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.PLATFORM_FEATURE_FLAGS_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_API_TOKEN.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_EDGE_CONFIG.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_EDGE_CONFIG_ID.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_EDGE_CONFIG_TOKEN.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_FEATURE_FLAG_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_FEATURE_FLAG_PREFIX.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_FEATURE_FLAG_WRITER_CONFIG_ENTRIES.md +14 -0
- package/data/packages/platform-feature-flags/api/Variable.VERCEL_TEAM_ID.md +14 -0
- package/data/packages/platform-feature-flags/api/index.md +55 -0
- package/data/packages/platform-openapi/api/Class.SwaggerFeatureDiscovery.md +54 -3
- package/data/packages/platform-openapi/api/Class.SwaggerMultiDocumentService.md +7 -5
- package/data/packages/platform-openapi/api/Class.SwaggerTheme.md +24 -7
- package/data/packages/platform-openapi/api/Function.SwaggerFeature.md +18 -6
- package/data/packages/platform-openapi/api/Function.getRegisteredSwaggerFeatures.md +9 -2
- package/data/packages/platform-openapi/api/Function.getSwaggerFeatureMetadata.md +8 -5
- package/data/packages/platform-openapi/api/Interface.ISwaggerFeatureMetadata.md +33 -7
- package/data/packages/platform-openapi/api/Interface.ISwaggerThemeConfig.md +59 -0
- package/data/packages/platform-openapi/api/Variable.SWAGGER_FEATURE_METADATA_KEY.md +4 -1
- package/data/packages/platform-openapi/api/index.md +6 -5
- package/package.json +1 -1
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Feature Flags
|
|
3
|
+
description: Toggle features at runtime with Azure App Configuration or Vercel Edge Config — without redeploying.
|
|
4
|
+
order: 26
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Feature Flags
|
|
8
|
+
|
|
9
|
+
This guide covers feature flag management with `platform-feature-flags`: choosing a provider, evaluating flags and variants, protecting routes with a guard, and refreshing flag state at runtime.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @breadstone/archipel-platform-feature-flags
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Choose a Provider
|
|
22
|
+
|
|
23
|
+
`platform-feature-flags` abstracts feature flag operations behind a `FeatureFlagReaderPort`. Supported providers:
|
|
24
|
+
|
|
25
|
+
| Provider | Subpath Import | SDK | Best for |
|
|
26
|
+
| --------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------- |
|
|
27
|
+
| **Azure App Configuration** | `@breadstone/archipel-platform-feature-flags/azure` | `@azure/app-configuration-provider` + `@microsoft/feature-management` | Enterprise apps with Azure infrastructure |
|
|
28
|
+
| **Vercel Edge Config** | `@breadstone/archipel-platform-feature-flags/vercel` | `@vercel/edge-config` | Vercel-hosted apps needing low-latency reads |
|
|
29
|
+
|
|
30
|
+
Install the provider SDK you need:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Azure
|
|
34
|
+
yarn add @azure/app-configuration-provider @microsoft/feature-management @azure/identity
|
|
35
|
+
|
|
36
|
+
# Vercel
|
|
37
|
+
yarn add @vercel/edge-config
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
### Azure App Configuration
|
|
45
|
+
|
|
46
|
+
| Variable | Required | Description |
|
|
47
|
+
| ------------------------------------ | -------- | ------------------------------------------------------------------ |
|
|
48
|
+
| `AZURE_APPCONFIG_ENDPOINT` | No* | Azure App Configuration endpoint URL. Required for Entra ID auth. |
|
|
49
|
+
| `AZURE_APPCONFIG_CONNECTION_STRING` | No* | Connection string. Alternative to endpoint + Entra ID. |
|
|
50
|
+
| `AZURE_FEATURE_FLAG_REFRESH_INTERVAL`| No | Refresh interval in ms. Defaults to `30000`. |
|
|
51
|
+
| `AZURE_FEATURE_FLAG_KEY_FILTER` | No | Key filter for selecting flags. Defaults to `*` (all). |
|
|
52
|
+
|
|
53
|
+
> \* At least one of `AZURE_APPCONFIG_ENDPOINT` or `AZURE_APPCONFIG_CONNECTION_STRING` must be set.
|
|
54
|
+
|
|
55
|
+
### Vercel Edge Config
|
|
56
|
+
|
|
57
|
+
| Variable | Required | Description |
|
|
58
|
+
| --------------------------- | -------- | ------------------------------------------------------------------- |
|
|
59
|
+
| `EDGE_CONFIG` | Yes | Vercel Edge Config connection string (includes store ID and token). |
|
|
60
|
+
| `VERCEL_EDGE_CONFIG_TOKEN` | No | Read access token (when not embedded in connection string). |
|
|
61
|
+
| `VERCEL_FEATURE_FLAG_PREFIX`| No | Key prefix in Edge Config. Defaults to `featureFlags`. |
|
|
62
|
+
|
|
63
|
+
### Using Config Keys
|
|
64
|
+
|
|
65
|
+
Import the typed config entries and pass them to the module:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { AZURE_FEATURE_FLAG_CONFIG_ENTRIES } from '@breadstone/archipel-platform-feature-flags/azure';
|
|
69
|
+
import { VERCEL_FEATURE_FLAG_CONFIG_ENTRIES } from '@breadstone/archipel-platform-feature-flags/vercel';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Module Registration
|
|
75
|
+
|
|
76
|
+
### Azure Provider
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { Module } from '@nestjs/common';
|
|
80
|
+
import { FeatureFlagModule } from '@breadstone/archipel-platform-feature-flags';
|
|
81
|
+
import { AzureFeatureFlagReader, AZURE_FEATURE_FLAG_CONFIG_ENTRIES } from '@breadstone/archipel-platform-feature-flags/azure';
|
|
82
|
+
|
|
83
|
+
@Module({
|
|
84
|
+
imports: [
|
|
85
|
+
FeatureFlagModule.register({
|
|
86
|
+
featureFlagReader: AzureFeatureFlagReader,
|
|
87
|
+
configEntries: [...AZURE_FEATURE_FLAG_CONFIG_ENTRIES],
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
})
|
|
91
|
+
export class AppModule {}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Vercel Provider
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { Module } from '@nestjs/common';
|
|
98
|
+
import { FeatureFlagModule } from '@breadstone/archipel-platform-feature-flags';
|
|
99
|
+
import { VercelFeatureFlagReader, VERCEL_FEATURE_FLAG_CONFIG_ENTRIES } from '@breadstone/archipel-platform-feature-flags/vercel';
|
|
100
|
+
|
|
101
|
+
@Module({
|
|
102
|
+
imports: [
|
|
103
|
+
FeatureFlagModule.register({
|
|
104
|
+
featureFlagReader: VercelFeatureFlagReader,
|
|
105
|
+
configEntries: [...VERCEL_FEATURE_FLAG_CONFIG_ENTRIES],
|
|
106
|
+
}),
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
export class AppModule {}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The module is registered **globally** by default. Pass `isGlobal: false` to scope it to a feature module.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Evaluating Feature Flags
|
|
117
|
+
|
|
118
|
+
Inject the `FeatureFlagReaderPort` to evaluate flags in your services:
|
|
119
|
+
|
|
120
|
+
### Simple On/Off Flags
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { Injectable } from '@nestjs/common';
|
|
124
|
+
import { FeatureFlagReaderPort } from '@breadstone/archipel-platform-feature-flags';
|
|
125
|
+
|
|
126
|
+
@Injectable()
|
|
127
|
+
export class CheckoutService {
|
|
128
|
+
private readonly _featureFlagReader: FeatureFlagReaderPort;
|
|
129
|
+
|
|
130
|
+
public constructor(featureFlagReader: FeatureFlagReaderPort) {
|
|
131
|
+
this._featureFlagReader = featureFlagReader;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public async processCheckout(userId: string): Promise<void> {
|
|
135
|
+
const useNewFlow = await this._featureFlagReader.isEnabled('new-checkout-flow', {
|
|
136
|
+
userId,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (useNewFlow) {
|
|
140
|
+
// New checkout logic
|
|
141
|
+
} else {
|
|
142
|
+
// Legacy checkout logic
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Multivariate Flags / A/B Testing
|
|
149
|
+
|
|
150
|
+
Use `getVariant()` to retrieve typed variant values for experiments and graduated rollouts:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const tier = await this._featureFlagReader.getVariant<string>(
|
|
154
|
+
'pricing-tier',
|
|
155
|
+
'free', // default value
|
|
156
|
+
{ userId },
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const maxUploadMb = await this._featureFlagReader.getVariant<number>(
|
|
160
|
+
'max-upload-size',
|
|
161
|
+
10, // default value
|
|
162
|
+
);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Listing All Flags
|
|
166
|
+
|
|
167
|
+
Retrieve every known flag with its current state — useful for debugging or admin dashboards:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const flags = await this._featureFlagReader.getAllFlags();
|
|
171
|
+
// [{ key: 'new-checkout-flow', enabled: true }, { key: 'dark-mode', enabled: false }]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Route Guard
|
|
177
|
+
|
|
178
|
+
The `FeatureFlagGuard` combined with the `@FeatureFlag()` decorator lets you gate entire endpoints behind a feature flag:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
182
|
+
import { FeatureFlagGuard, FeatureFlag } from '@breadstone/archipel-platform-feature-flags';
|
|
183
|
+
|
|
184
|
+
@Controller('experiments')
|
|
185
|
+
export class ExperimentController {
|
|
186
|
+
@Get('new-dashboard')
|
|
187
|
+
@UseGuards(FeatureFlagGuard)
|
|
188
|
+
@FeatureFlag('new-dashboard')
|
|
189
|
+
public async getNewDashboard(): Promise<string> {
|
|
190
|
+
return 'Welcome to the new dashboard!';
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
When the flag is **disabled**, the guard returns `false` and NestJS responds with `403 Forbidden`. If no `@FeatureFlag()` metadata is set, the guard allows access unconditionally.
|
|
196
|
+
|
|
197
|
+
The guard automatically passes the `userId` from `request.user` (if available) to the flag evaluation context, enabling per-user targeting.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Evaluation Context
|
|
202
|
+
|
|
203
|
+
Both `isEnabled()` and `getVariant()` accept an optional `IFeatureFlagContext` for targeting and segmentation:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
await this._featureFlagReader.isEnabled('beta-feature', {
|
|
207
|
+
userId: 'usr_abc123',
|
|
208
|
+
groups: ['beta-testers', 'enterprise'],
|
|
209
|
+
attributes: {
|
|
210
|
+
region: 'eu-west',
|
|
211
|
+
plan: 'pro',
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
| Property | Type | Description |
|
|
217
|
+
| ------------ | ----------------------------- | -------------------------------------------------- |
|
|
218
|
+
| `userId` | `string` | Unique user identifier for per-user targeting. |
|
|
219
|
+
| `groups` | `ReadonlyArray<string>` | Segments the user belongs to (e.g. beta, internal).|
|
|
220
|
+
| `attributes` | `Record<string, unknown>` | Custom key-value pairs for targeting rules. |
|
|
221
|
+
|
|
222
|
+
> **Note:** How the context is evaluated depends on the provider. Azure App Configuration uses targeting filters configured in the portal. Vercel Edge Config does not natively support targeting — context is available for custom evaluation logic.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Refreshing Flag State
|
|
227
|
+
|
|
228
|
+
### Azure
|
|
229
|
+
|
|
230
|
+
The Azure provider automatically refreshes flag state in the background at the configured interval (`AZURE_FEATURE_FLAG_REFRESH_INTERVAL`). You can also trigger an immediate refresh:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
await this._featureFlagReader.refresh();
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Vercel
|
|
237
|
+
|
|
238
|
+
Vercel Edge Config is near-realtime. The `refresh()` method is a no-op — changes propagate automatically at the edge.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Health Checks
|
|
243
|
+
|
|
244
|
+
Both providers implement a `ping()` method that returns `true` if the provider is reachable. Integrate it with `platform-health` for monitoring:
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import { Injectable } from '@nestjs/common';
|
|
248
|
+
import { FeatureFlagReaderPort } from '@breadstone/archipel-platform-feature-flags';
|
|
249
|
+
|
|
250
|
+
@Injectable()
|
|
251
|
+
export class FeatureFlagHealthIndicator {
|
|
252
|
+
private readonly _reader: FeatureFlagReaderPort;
|
|
253
|
+
|
|
254
|
+
public constructor(reader: FeatureFlagReaderPort) {
|
|
255
|
+
this._reader = reader;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public async isHealthy(): Promise<boolean> {
|
|
259
|
+
return this._reader.ping();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Error Handling
|
|
267
|
+
|
|
268
|
+
All provider errors are wrapped in a `FeatureFlagError` with the provider name and original cause:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { FeatureFlagError } from '@breadstone/archipel-platform-feature-flags';
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
await featureFlagReader.isEnabled('some-flag');
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (error instanceof FeatureFlagError) {
|
|
277
|
+
console.error(`Provider: ${error.provider}, Message: ${error.message}`);
|
|
278
|
+
// error.cause contains the original SDK error
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Map `FeatureFlagError` to an appropriate HTTP response in your global exception filter.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Architecture
|
|
288
|
+
|
|
289
|
+
```mermaid
|
|
290
|
+
flowchart TB
|
|
291
|
+
App["Application"]
|
|
292
|
+
Module["FeatureFlagModule"]
|
|
293
|
+
Port["FeatureFlagReaderPort"]
|
|
294
|
+
Guard["FeatureFlagGuard"]
|
|
295
|
+
Decorator["@FeatureFlag()"]
|
|
296
|
+
Azure["AzureFeatureFlagReader"]
|
|
297
|
+
Vercel["VercelFeatureFlagReader"]
|
|
298
|
+
AzureSDK["Azure App Configuration SDK"]
|
|
299
|
+
VercelSDK["Vercel Edge Config SDK"]
|
|
300
|
+
|
|
301
|
+
App --> Module
|
|
302
|
+
Module --> Port
|
|
303
|
+
Module --> Guard
|
|
304
|
+
Guard --> Decorator
|
|
305
|
+
Guard --> Port
|
|
306
|
+
Port --> Azure
|
|
307
|
+
Port --> Vercel
|
|
308
|
+
Azure --> AzureSDK
|
|
309
|
+
Vercel --> VercelSDK
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Vercel Edge Config Data Structure
|
|
315
|
+
|
|
316
|
+
Vercel Edge Config expects feature flags to be stored as a single object under the configured prefix key:
|
|
317
|
+
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"featureFlags": {
|
|
321
|
+
"new-checkout-flow": true,
|
|
322
|
+
"dark-mode": false,
|
|
323
|
+
"pricing-tier": "enterprise",
|
|
324
|
+
"max-upload-size": 100
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
- Boolean values map to simple on/off flags (`isEnabled` returns the boolean directly).
|
|
330
|
+
- Non-boolean values are returned as variants (`getVariant` returns the value as-is).
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Testing
|
|
335
|
+
|
|
336
|
+
Mock the `FeatureFlagReaderPort` in unit tests:
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
import { Test } from '@nestjs/testing';
|
|
340
|
+
import { FeatureFlagReaderPort } from '@breadstone/archipel-platform-feature-flags';
|
|
341
|
+
|
|
342
|
+
const mockReader = {
|
|
343
|
+
isEnabled: vi.fn().mockResolvedValue(true),
|
|
344
|
+
getVariant: vi.fn().mockResolvedValue('enterprise'),
|
|
345
|
+
getAllFlags: vi.fn().mockResolvedValue([]),
|
|
346
|
+
refresh: vi.fn().mockResolvedValue(undefined),
|
|
347
|
+
ping: vi.fn().mockResolvedValue(true),
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const module = await Test.createTestingModule({
|
|
351
|
+
providers: [
|
|
352
|
+
{ provide: FeatureFlagReaderPort, useValue: mockReader },
|
|
353
|
+
CheckoutService,
|
|
354
|
+
],
|
|
355
|
+
}).compile();
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
See the [Testing guide](./testing) for more patterns.
|
package/data/guides/index.md
CHANGED
|
@@ -49,6 +49,7 @@ Practical guides for working with Archipel packages in your NestJS application.
|
|
|
49
49
|
|
|
50
50
|
| Guide | What you'll learn |
|
|
51
51
|
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
|
|
52
|
+
| [Feature Flags](./feature-flags) | Toggle features at runtime with Azure App Configuration or Vercel Edge Config. |
|
|
52
53
|
| [Telemetry & Observability](./telemetry-and-observability) | OpenTelemetry metrics, distributed tracing, and structured logging. |
|
|
53
54
|
| [Analytics & Error Tracking](./analytics-and-error-tracking) | Capture errors and user context with Sentry, AppInsights, or Datadog. |
|
|
54
55
|
| [Caching](./caching) | In-memory LRU and Redis layered caches with TTL, stale-while-revalidate, and metrics. |
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Class: AzureFeatureFlagReader'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Class: AzureFeatureFlagReader
|
|
7
|
+
|
|
8
|
+
Defined in: azure/AzureFeatureFlagReader.ts:36
|
|
9
|
+
|
|
10
|
+
Azure App Configuration implementation of the [FeatureFlagReaderPort](Class.FeatureFlagReaderPort).
|
|
11
|
+
Uses `@azure/app-configuration-provider` for connecting to Azure App Configuration
|
|
12
|
+
and `@microsoft/feature-management` for evaluating feature flags.
|
|
13
|
+
|
|
14
|
+
## Extends
|
|
15
|
+
|
|
16
|
+
- [`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort)
|
|
17
|
+
|
|
18
|
+
## Implements
|
|
19
|
+
|
|
20
|
+
- `OnModuleInit`
|
|
21
|
+
- `OnModuleDestroy`
|
|
22
|
+
|
|
23
|
+
## Constructors
|
|
24
|
+
|
|
25
|
+
### Constructor
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
new AzureFeatureFlagReader(configService): AzureFeatureFlagReader;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Defined in: azure/AzureFeatureFlagReader.ts:49
|
|
32
|
+
|
|
33
|
+
#### Parameters
|
|
34
|
+
|
|
35
|
+
| Parameter | Type |
|
|
36
|
+
| ------ | ------ |
|
|
37
|
+
| `configService` | `ConfigService` |
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`AzureFeatureFlagReader`
|
|
42
|
+
|
|
43
|
+
#### Overrides
|
|
44
|
+
|
|
45
|
+
[`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort).[`constructor`](Class.FeatureFlagReaderPort#constructor)
|
|
46
|
+
|
|
47
|
+
## Methods
|
|
48
|
+
|
|
49
|
+
### getAllFlags()
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
getAllFlags(_context?): Promise<readonly IFeatureFlagEvaluation[]>;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Defined in: azure/AzureFeatureFlagReader.ts:167
|
|
56
|
+
|
|
57
|
+
Returns all known feature flags with their current evaluation.
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
| Parameter | Type | Description |
|
|
62
|
+
| ------ | ------ | ------ |
|
|
63
|
+
| `_context?` | [`IFeatureFlagContext`](Interface.IFeatureFlagContext) | Optional evaluation context for targeting and segmentation. |
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
66
|
+
|
|
67
|
+
`Promise`\<readonly [`IFeatureFlagEvaluation`](Interface.IFeatureFlagEvaluation)[]\>
|
|
68
|
+
|
|
69
|
+
Array of evaluated feature flags.
|
|
70
|
+
|
|
71
|
+
#### Overrides
|
|
72
|
+
|
|
73
|
+
[`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort).[`getAllFlags`](Class.FeatureFlagReaderPort#getallflags)
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
### getVariant()
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
getVariant<T>(
|
|
81
|
+
key,
|
|
82
|
+
defaultValue,
|
|
83
|
+
_context?): Promise<T>;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Defined in: azure/AzureFeatureFlagReader.ts:146
|
|
87
|
+
|
|
88
|
+
Returns the variant value of a feature flag for multivariate flags and A/B testing.
|
|
89
|
+
|
|
90
|
+
#### Type Parameters
|
|
91
|
+
|
|
92
|
+
| Type Parameter | Default type |
|
|
93
|
+
| ------ | ------ |
|
|
94
|
+
| `T` | `unknown` |
|
|
95
|
+
|
|
96
|
+
#### Parameters
|
|
97
|
+
|
|
98
|
+
| Parameter | Type | Description |
|
|
99
|
+
| ------ | ------ | ------ |
|
|
100
|
+
| `key` | `string` | The unique key identifying the feature flag. |
|
|
101
|
+
| `defaultValue` | `T` | The default value to return if the flag is not found. |
|
|
102
|
+
| `_context?` | [`IFeatureFlagContext`](Interface.IFeatureFlagContext) | Optional evaluation context for targeting and segmentation. |
|
|
103
|
+
|
|
104
|
+
#### Returns
|
|
105
|
+
|
|
106
|
+
`Promise`\<`T`\>
|
|
107
|
+
|
|
108
|
+
The variant value of the feature flag.
|
|
109
|
+
|
|
110
|
+
#### Overrides
|
|
111
|
+
|
|
112
|
+
[`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort).[`getVariant`](Class.FeatureFlagReaderPort#getvariant)
|
|
113
|
+
|
|
114
|
+
***
|
|
115
|
+
|
|
116
|
+
### isEnabled()
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
isEnabled(key, _context?): Promise<boolean>;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Defined in: azure/AzureFeatureFlagReader.ts:131
|
|
123
|
+
|
|
124
|
+
Evaluates whether a feature flag is enabled.
|
|
125
|
+
|
|
126
|
+
#### Parameters
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Description |
|
|
129
|
+
| ------ | ------ | ------ |
|
|
130
|
+
| `key` | `string` | The unique key identifying the feature flag. |
|
|
131
|
+
| `_context?` | [`IFeatureFlagContext`](Interface.IFeatureFlagContext) | Optional evaluation context for targeting and segmentation. |
|
|
132
|
+
|
|
133
|
+
#### Returns
|
|
134
|
+
|
|
135
|
+
`Promise`\<`boolean`\>
|
|
136
|
+
|
|
137
|
+
`true` if the feature flag is enabled.
|
|
138
|
+
|
|
139
|
+
#### Overrides
|
|
140
|
+
|
|
141
|
+
[`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort).[`isEnabled`](Class.FeatureFlagReaderPort#isenabled)
|
|
142
|
+
|
|
143
|
+
***
|
|
144
|
+
|
|
145
|
+
### onModuleDestroy()
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
onModuleDestroy(): void;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Defined in: azure/AzureFeatureFlagReader.ts:123
|
|
152
|
+
|
|
153
|
+
Cleans up the refresh interval on module destruction.
|
|
154
|
+
|
|
155
|
+
#### Returns
|
|
156
|
+
|
|
157
|
+
`void`
|
|
158
|
+
|
|
159
|
+
#### Implementation of
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
OnModuleDestroy.onModuleDestroy
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
***
|
|
166
|
+
|
|
167
|
+
### onModuleInit()
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
onModuleInit(): Promise<void>;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Defined in: azure/AzureFeatureFlagReader.ts:63
|
|
174
|
+
|
|
175
|
+
Initializes the Azure App Configuration connection and feature manager.
|
|
176
|
+
|
|
177
|
+
#### Returns
|
|
178
|
+
|
|
179
|
+
`Promise`\<`void`\>
|
|
180
|
+
|
|
181
|
+
#### Implementation of
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
OnModuleInit.onModuleInit
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
***
|
|
188
|
+
|
|
189
|
+
### ping()
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
ping(): Promise<boolean>;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Defined in: azure/AzureFeatureFlagReader.ts:207
|
|
196
|
+
|
|
197
|
+
Lightweight connectivity check for the feature flag provider.
|
|
198
|
+
Override in adapters to perform a real API call.
|
|
199
|
+
Defaults to `true` if not overridden.
|
|
200
|
+
|
|
201
|
+
#### Returns
|
|
202
|
+
|
|
203
|
+
`Promise`\<`boolean`\>
|
|
204
|
+
|
|
205
|
+
`true` if the provider is reachable.
|
|
206
|
+
|
|
207
|
+
#### Overrides
|
|
208
|
+
|
|
209
|
+
[`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort).[`ping`](Class.FeatureFlagReaderPort#ping)
|
|
210
|
+
|
|
211
|
+
***
|
|
212
|
+
|
|
213
|
+
### refresh()
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
refresh(): Promise<void>;
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Defined in: azure/AzureFeatureFlagReader.ts:193
|
|
220
|
+
|
|
221
|
+
Refreshes the flag state from the remote provider.
|
|
222
|
+
Implementations should reload configuration from the upstream source.
|
|
223
|
+
|
|
224
|
+
#### Returns
|
|
225
|
+
|
|
226
|
+
`Promise`\<`void`\>
|
|
227
|
+
|
|
228
|
+
#### Overrides
|
|
229
|
+
|
|
230
|
+
[`FeatureFlagReaderPort`](Class.FeatureFlagReaderPort).[`refresh`](Class.FeatureFlagReaderPort#refresh)
|