@configdirector/openfeature-server-provider 1.10.0 → 1.11.1
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/dist/configdirector-openfeature-server-provider.cjs +2 -2
- package/dist/configdirector-openfeature-server-provider.d.cts +113 -42
- package/dist/configdirector-openfeature-server-provider.d.cts.map +1 -1
- package/dist/configdirector-openfeature-server-provider.d.mts +113 -42
- package/dist/configdirector-openfeature-server-provider.d.mts.map +1 -1
- package/dist/configdirector-openfeature-server-provider.mjs +2 -2
- package/dist/configdirector-openfeature-server-provider.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ interface ConfigDirectorLogger {
|
|
|
24
24
|
interface ConfigDirectorLogMessageDecorator {
|
|
25
25
|
decorateMessage(message: string): string;
|
|
26
26
|
}
|
|
27
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean";
|
|
27
|
+
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
28
28
|
type ConfigEvaluation = {
|
|
29
29
|
key: string;
|
|
30
30
|
value: ConfigValueType;
|
|
@@ -43,9 +43,11 @@ type ConfigDirectorContext = {
|
|
|
43
43
|
* The context's identifier. This should be a value that uniquely identifies the user or other
|
|
44
44
|
* entity among contexts of the same {@link kind}.
|
|
45
45
|
* In the case of anonymous users, you could generate a UUID or alternatively not provide
|
|
46
|
-
* the {@link id}
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* the {@link id}. In a client SDK, ConfigDirector then derives an identifier from an ID the SDK
|
|
47
|
+
* stores for the app install or the website, so it stays the same until the app is uninstalled
|
|
48
|
+
* or the site's data is cleared. However, keep in mind that this value is used for segmenting
|
|
49
|
+
* contexts in percentage rollouts, and changes to the {@link id} could result in the context
|
|
50
|
+
* being assigned to a different percentile.
|
|
49
51
|
*/
|
|
50
52
|
id?: string;
|
|
51
53
|
/**
|
|
@@ -89,9 +91,90 @@ type ConfigDirectorMetaContext = {
|
|
|
89
91
|
appVersion?: string;
|
|
90
92
|
appName?: string;
|
|
91
93
|
};
|
|
92
|
-
type ConnectionMode = "streaming" | "polling";
|
|
94
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../shared/src/native-values.d.ts
|
|
97
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
98
|
+
[key: string]: NativeJsonValue;
|
|
99
|
+
};
|
|
100
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
101
|
+
[key: string]: NativeJsonValue;
|
|
102
|
+
};
|
|
103
|
+
type NativeValues = Record<string, NativeValue>;
|
|
93
104
|
//#endregion
|
|
94
105
|
//#region ../js-server-sdk/src/types.d.ts
|
|
106
|
+
/**
|
|
107
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
108
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
109
|
+
* or array (`json`).
|
|
110
|
+
*/
|
|
111
|
+
type OfflineValue = NativeValue;
|
|
112
|
+
/**
|
|
113
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
114
|
+
* value's config type is decided. Every context receives the same value.
|
|
115
|
+
*/
|
|
116
|
+
type OfflineValues = NativeValues;
|
|
117
|
+
/**
|
|
118
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
119
|
+
*/
|
|
120
|
+
type ConnectionOptions = {
|
|
121
|
+
/**
|
|
122
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
123
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
124
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
125
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
126
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
127
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
128
|
+
* the values read from {@link file} or given in {@link values} to every context, or the in-code
|
|
129
|
+
* default values when neither is given. No SDK key is needed.
|
|
130
|
+
*
|
|
131
|
+
* Defaults to `streaming`
|
|
132
|
+
*/
|
|
133
|
+
mode?: ConnectionMode;
|
|
134
|
+
/**
|
|
135
|
+
* The path of a JSON file holding the values to serve in `offline` mode, resolved against the
|
|
136
|
+
* process working directory. The file holds one object with a value per config key, such as
|
|
137
|
+
* `{ "new-checkout": true, "max-items": 20 }`; see {@link OfflineValue} for how the config type
|
|
138
|
+
* of each value is decided. A file that is missing, unreadable, not a JSON object, or holding a
|
|
139
|
+
* value such as `null` makes `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
140
|
+
*
|
|
141
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
142
|
+
* `initialize` rejects.
|
|
143
|
+
*/
|
|
144
|
+
file?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
147
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
148
|
+
*
|
|
149
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
150
|
+
* `initialize` rejects.
|
|
151
|
+
*/
|
|
152
|
+
values?: OfflineValues;
|
|
153
|
+
/**
|
|
154
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
155
|
+
* effect in the other modes.
|
|
156
|
+
*
|
|
157
|
+
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
158
|
+
* raised to the minimum and a warning is logged.
|
|
159
|
+
*/
|
|
160
|
+
pollingInterval?: number;
|
|
161
|
+
/**
|
|
162
|
+
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
163
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
164
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
165
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
166
|
+
* no effect in `offline` mode.
|
|
167
|
+
*
|
|
168
|
+
* Defaults to 3,000 milliseconds (3 seconds)
|
|
169
|
+
*/
|
|
170
|
+
timeout?: number;
|
|
171
|
+
/**
|
|
172
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
173
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
174
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
175
|
+
*/
|
|
176
|
+
url?: string;
|
|
177
|
+
};
|
|
95
178
|
/**
|
|
96
179
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
97
180
|
*/
|
|
@@ -103,41 +186,7 @@ type ConfigDirectorClientOptions = {
|
|
|
103
186
|
/**
|
|
104
187
|
* Connection options
|
|
105
188
|
*/
|
|
106
|
-
connection?:
|
|
107
|
-
/**
|
|
108
|
-
* The connection mode to be used, one of `streaming` (default) or `polling`.
|
|
109
|
-
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
110
|
-
* config state is updated on the ConfigDirector dashboard.
|
|
111
|
-
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
112
|
-
* initialization, and additional requests on a `pollingInterval`.
|
|
113
|
-
*
|
|
114
|
-
* Defaults to `streaming`
|
|
115
|
-
*/
|
|
116
|
-
mode?: ConnectionMode;
|
|
117
|
-
/**
|
|
118
|
-
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
119
|
-
* effect when the `mode` is set to `streaming`.
|
|
120
|
-
*
|
|
121
|
-
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
122
|
-
* raised to the minimum and a warning is logged.
|
|
123
|
-
*/
|
|
124
|
-
pollingInterval?: number;
|
|
125
|
-
/**
|
|
126
|
-
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
127
|
-
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
128
|
-
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
129
|
-
* If streaming is disabled, if the operation times out, it will not be retried.
|
|
130
|
-
*
|
|
131
|
-
* Defaults to 3,000 milliseconds (3 seconds)
|
|
132
|
-
*/
|
|
133
|
-
timeout?: number;
|
|
134
|
-
/**
|
|
135
|
-
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
136
|
-
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
137
|
-
* a proxy for the client SDK.
|
|
138
|
-
*/
|
|
139
|
-
url?: string;
|
|
140
|
-
};
|
|
189
|
+
connection?: ConnectionOptions;
|
|
141
190
|
/**
|
|
142
191
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
143
192
|
* logger set to 'warn' level.
|
|
@@ -197,6 +246,14 @@ type ConfigDirectorClientOptions = {
|
|
|
197
246
|
*/
|
|
198
247
|
hooks?: ClientHooks;
|
|
199
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* The options of a client created without an SDK key: the connection mode is `offline`.
|
|
251
|
+
*/
|
|
252
|
+
type OfflineClientOptions = ConfigDirectorClientOptions & {
|
|
253
|
+
connection: ConnectionOptions & {
|
|
254
|
+
mode: "offline";
|
|
255
|
+
};
|
|
256
|
+
};
|
|
200
257
|
type ClientEvents = {
|
|
201
258
|
configsUpdated: {
|
|
202
259
|
keys: string[];
|
|
@@ -303,6 +360,12 @@ interface ConfigDirectorClient {
|
|
|
303
360
|
dispose(): void;
|
|
304
361
|
}
|
|
305
362
|
//#endregion
|
|
363
|
+
//#region ../shared/src/errors.d.ts
|
|
364
|
+
declare class ConfigDirectorInitializationError extends Error {
|
|
365
|
+
readonly name: string;
|
|
366
|
+
constructor(message: string);
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
306
369
|
//#region src/ConfigDirectorProvider.d.ts
|
|
307
370
|
declare class ConfigDirectorProvider implements Provider {
|
|
308
371
|
private readonly client;
|
|
@@ -310,7 +373,15 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
310
373
|
readonly metadata: ProviderMetadata;
|
|
311
374
|
readonly runsOn: Paradigm;
|
|
312
375
|
readonly events: OpenFeatureEventEmitter;
|
|
313
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Creates a provider connected to ConfigDirector with the given server SDK key.
|
|
378
|
+
*/
|
|
379
|
+
constructor(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions);
|
|
380
|
+
/**
|
|
381
|
+
* Creates a provider in `offline` mode, which needs no server SDK key: it never connects to
|
|
382
|
+
* ConfigDirector and serves `connection.file` or `connection.values` to every evaluation.
|
|
383
|
+
*/
|
|
384
|
+
constructor(clientOptions: OfflineClientOptions);
|
|
314
385
|
initialize(): Promise<void>;
|
|
315
386
|
resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
316
387
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
@@ -321,5 +392,5 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
321
392
|
private mapContext;
|
|
322
393
|
}
|
|
323
394
|
//#endregion
|
|
324
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType };
|
|
395
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType, type OfflineClientOptions, type OfflineValue, type OfflineValues };
|
|
325
396
|
//# sourceMappingURL=configdirector-openfeature-server-provider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-openfeature-server-provider.d.cts","names":[],"sources":["../../shared/src/types.ts","../../js-server-sdk/src/types.ts","../src/ConfigDirectorProvider.ts"],"mappings":";;;cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;AAAA,KAGN,gBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"configdirector-openfeature-server-provider.d.cts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../../js-server-sdk/src/types.ts","../../shared/src/errors.ts","../src/ConfigDirectorProvider.ts"],"mappings":";;;cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;AAAA,KAGN,gBAAA;AAAA,KAWA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAA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AAW,CAAA,EAAG,OAAA,IAAW,IAAA,EAAM,YAAA,CAAa,CAAA;EA1FxD;;;;;;EAkGtB,OAAA;AAAA;;;cCnRW,iCAAA,SAA0C,KAAA;EAAA,SAC5B,IAAA;cAEb,OAAA;AAAA;;;cCVD,sBAAA,YAAkC,QAAA;EAAA,iBAC5B,MAAA;EAAA,iBACA,YAAA;EAAA,SAER,QAAA,EAAU,gBAAA;EAAA,SAGV,MAAA,EAAQ,QAAA;EAAA,SACR,MAAA,EAAM,uBAAA;EJbK;;;cIkBD,YAAA,UAAsB,aAAA,GAAgB,2BAAA;EJhB/C;;;;cIqBS,aAAA,EAAe,oBAAA;EAc5B,UAAA,CAAA,GAAU,OAAA;EAMhB,wBAAA,CACE,OAAA,UACA,YAAA,WACA,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA;EAIX,uBAAA,CACE,OAAA,UACA,YAAA,UACA,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA;EAIX,uBAAA,CACE,OAAA,UACA,YAAA,UACA,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA;EAIX,uBAAA,WAAkC,SAAA,CAAA,CAChC,OAAA,UACA,YAAA,EAAc,CAAA,EACd,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EAM7B,OAAA,CAAA,CAAA,GAAY,OAAA;EAAA,QAKJ,QAAA;EAAA,QAWA,UAAA;AAAA"}
|
|
@@ -24,7 +24,7 @@ interface ConfigDirectorLogger {
|
|
|
24
24
|
interface ConfigDirectorLogMessageDecorator {
|
|
25
25
|
decorateMessage(message: string): string;
|
|
26
26
|
}
|
|
27
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean";
|
|
27
|
+
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
28
28
|
type ConfigEvaluation = {
|
|
29
29
|
key: string;
|
|
30
30
|
value: ConfigValueType;
|
|
@@ -43,9 +43,11 @@ type ConfigDirectorContext = {
|
|
|
43
43
|
* The context's identifier. This should be a value that uniquely identifies the user or other
|
|
44
44
|
* entity among contexts of the same {@link kind}.
|
|
45
45
|
* In the case of anonymous users, you could generate a UUID or alternatively not provide
|
|
46
|
-
* the {@link id}
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* the {@link id}. In a client SDK, ConfigDirector then derives an identifier from an ID the SDK
|
|
47
|
+
* stores for the app install or the website, so it stays the same until the app is uninstalled
|
|
48
|
+
* or the site's data is cleared. However, keep in mind that this value is used for segmenting
|
|
49
|
+
* contexts in percentage rollouts, and changes to the {@link id} could result in the context
|
|
50
|
+
* being assigned to a different percentile.
|
|
49
51
|
*/
|
|
50
52
|
id?: string;
|
|
51
53
|
/**
|
|
@@ -89,9 +91,90 @@ type ConfigDirectorMetaContext = {
|
|
|
89
91
|
appVersion?: string;
|
|
90
92
|
appName?: string;
|
|
91
93
|
};
|
|
92
|
-
type ConnectionMode = "streaming" | "polling";
|
|
94
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../shared/src/native-values.d.ts
|
|
97
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
98
|
+
[key: string]: NativeJsonValue;
|
|
99
|
+
};
|
|
100
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
101
|
+
[key: string]: NativeJsonValue;
|
|
102
|
+
};
|
|
103
|
+
type NativeValues = Record<string, NativeValue>;
|
|
93
104
|
//#endregion
|
|
94
105
|
//#region ../js-server-sdk/src/types.d.ts
|
|
106
|
+
/**
|
|
107
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
108
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
109
|
+
* or array (`json`).
|
|
110
|
+
*/
|
|
111
|
+
type OfflineValue = NativeValue;
|
|
112
|
+
/**
|
|
113
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
114
|
+
* value's config type is decided. Every context receives the same value.
|
|
115
|
+
*/
|
|
116
|
+
type OfflineValues = NativeValues;
|
|
117
|
+
/**
|
|
118
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
119
|
+
*/
|
|
120
|
+
type ConnectionOptions = {
|
|
121
|
+
/**
|
|
122
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
123
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
124
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
125
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
126
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
127
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
128
|
+
* the values read from {@link file} or given in {@link values} to every context, or the in-code
|
|
129
|
+
* default values when neither is given. No SDK key is needed.
|
|
130
|
+
*
|
|
131
|
+
* Defaults to `streaming`
|
|
132
|
+
*/
|
|
133
|
+
mode?: ConnectionMode;
|
|
134
|
+
/**
|
|
135
|
+
* The path of a JSON file holding the values to serve in `offline` mode, resolved against the
|
|
136
|
+
* process working directory. The file holds one object with a value per config key, such as
|
|
137
|
+
* `{ "new-checkout": true, "max-items": 20 }`; see {@link OfflineValue} for how the config type
|
|
138
|
+
* of each value is decided. A file that is missing, unreadable, not a JSON object, or holding a
|
|
139
|
+
* value such as `null` makes `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
140
|
+
*
|
|
141
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
142
|
+
* `initialize` rejects.
|
|
143
|
+
*/
|
|
144
|
+
file?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
147
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
148
|
+
*
|
|
149
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
150
|
+
* `initialize` rejects.
|
|
151
|
+
*/
|
|
152
|
+
values?: OfflineValues;
|
|
153
|
+
/**
|
|
154
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
155
|
+
* effect in the other modes.
|
|
156
|
+
*
|
|
157
|
+
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
158
|
+
* raised to the minimum and a warning is logged.
|
|
159
|
+
*/
|
|
160
|
+
pollingInterval?: number;
|
|
161
|
+
/**
|
|
162
|
+
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
163
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
164
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
165
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
166
|
+
* no effect in `offline` mode.
|
|
167
|
+
*
|
|
168
|
+
* Defaults to 3,000 milliseconds (3 seconds)
|
|
169
|
+
*/
|
|
170
|
+
timeout?: number;
|
|
171
|
+
/**
|
|
172
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
173
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
174
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
175
|
+
*/
|
|
176
|
+
url?: string;
|
|
177
|
+
};
|
|
95
178
|
/**
|
|
96
179
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
97
180
|
*/
|
|
@@ -103,41 +186,7 @@ type ConfigDirectorClientOptions = {
|
|
|
103
186
|
/**
|
|
104
187
|
* Connection options
|
|
105
188
|
*/
|
|
106
|
-
connection?:
|
|
107
|
-
/**
|
|
108
|
-
* The connection mode to be used, one of `streaming` (default) or `polling`.
|
|
109
|
-
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
110
|
-
* config state is updated on the ConfigDirector dashboard.
|
|
111
|
-
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
112
|
-
* initialization, and additional requests on a `pollingInterval`.
|
|
113
|
-
*
|
|
114
|
-
* Defaults to `streaming`
|
|
115
|
-
*/
|
|
116
|
-
mode?: ConnectionMode;
|
|
117
|
-
/**
|
|
118
|
-
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
119
|
-
* effect when the `mode` is set to `streaming`.
|
|
120
|
-
*
|
|
121
|
-
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
122
|
-
* raised to the minimum and a warning is logged.
|
|
123
|
-
*/
|
|
124
|
-
pollingInterval?: number;
|
|
125
|
-
/**
|
|
126
|
-
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
127
|
-
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
128
|
-
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
129
|
-
* If streaming is disabled, if the operation times out, it will not be retried.
|
|
130
|
-
*
|
|
131
|
-
* Defaults to 3,000 milliseconds (3 seconds)
|
|
132
|
-
*/
|
|
133
|
-
timeout?: number;
|
|
134
|
-
/**
|
|
135
|
-
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
136
|
-
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
137
|
-
* a proxy for the client SDK.
|
|
138
|
-
*/
|
|
139
|
-
url?: string;
|
|
140
|
-
};
|
|
189
|
+
connection?: ConnectionOptions;
|
|
141
190
|
/**
|
|
142
191
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
143
192
|
* logger set to 'warn' level.
|
|
@@ -197,6 +246,14 @@ type ConfigDirectorClientOptions = {
|
|
|
197
246
|
*/
|
|
198
247
|
hooks?: ClientHooks;
|
|
199
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* The options of a client created without an SDK key: the connection mode is `offline`.
|
|
251
|
+
*/
|
|
252
|
+
type OfflineClientOptions = ConfigDirectorClientOptions & {
|
|
253
|
+
connection: ConnectionOptions & {
|
|
254
|
+
mode: "offline";
|
|
255
|
+
};
|
|
256
|
+
};
|
|
200
257
|
type ClientEvents = {
|
|
201
258
|
configsUpdated: {
|
|
202
259
|
keys: string[];
|
|
@@ -303,6 +360,12 @@ interface ConfigDirectorClient {
|
|
|
303
360
|
dispose(): void;
|
|
304
361
|
}
|
|
305
362
|
//#endregion
|
|
363
|
+
//#region ../shared/src/errors.d.ts
|
|
364
|
+
declare class ConfigDirectorInitializationError extends Error {
|
|
365
|
+
readonly name: string;
|
|
366
|
+
constructor(message: string);
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
306
369
|
//#region src/ConfigDirectorProvider.d.ts
|
|
307
370
|
declare class ConfigDirectorProvider implements Provider {
|
|
308
371
|
private readonly client;
|
|
@@ -310,7 +373,15 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
310
373
|
readonly metadata: ProviderMetadata;
|
|
311
374
|
readonly runsOn: Paradigm;
|
|
312
375
|
readonly events: OpenFeatureEventEmitter;
|
|
313
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Creates a provider connected to ConfigDirector with the given server SDK key.
|
|
378
|
+
*/
|
|
379
|
+
constructor(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions);
|
|
380
|
+
/**
|
|
381
|
+
* Creates a provider in `offline` mode, which needs no server SDK key: it never connects to
|
|
382
|
+
* ConfigDirector and serves `connection.file` or `connection.values` to every evaluation.
|
|
383
|
+
*/
|
|
384
|
+
constructor(clientOptions: OfflineClientOptions);
|
|
314
385
|
initialize(): Promise<void>;
|
|
315
386
|
resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
316
387
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
@@ -321,5 +392,5 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
321
392
|
private mapContext;
|
|
322
393
|
}
|
|
323
394
|
//#endregion
|
|
324
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType };
|
|
395
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType, type OfflineClientOptions, type OfflineValue, type OfflineValues };
|
|
325
396
|
//# sourceMappingURL=configdirector-openfeature-server-provider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-openfeature-server-provider.d.mts","names":[],"sources":["../../shared/src/types.ts","../../js-server-sdk/src/types.ts","../src/ConfigDirectorProvider.ts"],"mappings":";;;cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;AAAA,KAGN,gBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"configdirector-openfeature-server-provider.d.mts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../../js-server-sdk/src/types.ts","../../shared/src/errors.ts","../src/ConfigDirectorProvider.ts"],"mappings":";;;cAAa,cAAA;AAAA,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