@configdirector/openfeature-server-provider 1.10.0 → 1.11.0
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 +107 -38
- package/dist/configdirector-openfeature-server-provider.d.cts.map +1 -1
- package/dist/configdirector-openfeature-server-provider.d.mts +107 -38
- 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
|
@@ -89,9 +89,90 @@ type ConfigDirectorMetaContext = {
|
|
|
89
89
|
appVersion?: string;
|
|
90
90
|
appName?: string;
|
|
91
91
|
};
|
|
92
|
-
type ConnectionMode = "streaming" | "polling";
|
|
92
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region ../shared/src/native-values.d.ts
|
|
95
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
96
|
+
[key: string]: NativeJsonValue;
|
|
97
|
+
};
|
|
98
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
99
|
+
[key: string]: NativeJsonValue;
|
|
100
|
+
};
|
|
101
|
+
type NativeValues = Record<string, NativeValue>;
|
|
93
102
|
//#endregion
|
|
94
103
|
//#region ../js-server-sdk/src/types.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
106
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
107
|
+
* or array (`json`).
|
|
108
|
+
*/
|
|
109
|
+
type OfflineValue = NativeValue;
|
|
110
|
+
/**
|
|
111
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
112
|
+
* value's config type is decided. Every context receives the same value.
|
|
113
|
+
*/
|
|
114
|
+
type OfflineValues = NativeValues;
|
|
115
|
+
/**
|
|
116
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
117
|
+
*/
|
|
118
|
+
type ConnectionOptions = {
|
|
119
|
+
/**
|
|
120
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
121
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
122
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
123
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
124
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
125
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
126
|
+
* the values read from {@link file} or given in {@link values} to every context, or the in-code
|
|
127
|
+
* default values when neither is given. No SDK key is needed.
|
|
128
|
+
*
|
|
129
|
+
* Defaults to `streaming`
|
|
130
|
+
*/
|
|
131
|
+
mode?: ConnectionMode;
|
|
132
|
+
/**
|
|
133
|
+
* The path of a JSON file holding the values to serve in `offline` mode, resolved against the
|
|
134
|
+
* process working directory. The file holds one object with a value per config key, such as
|
|
135
|
+
* `{ "new-checkout": true, "max-items": 20 }`; see {@link OfflineValue} for how the config type
|
|
136
|
+
* of each value is decided. A file that is missing, unreadable, not a JSON object, or holding a
|
|
137
|
+
* value such as `null` makes `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
138
|
+
*
|
|
139
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
140
|
+
* `initialize` rejects.
|
|
141
|
+
*/
|
|
142
|
+
file?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
145
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
146
|
+
*
|
|
147
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
148
|
+
* `initialize` rejects.
|
|
149
|
+
*/
|
|
150
|
+
values?: OfflineValues;
|
|
151
|
+
/**
|
|
152
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
153
|
+
* effect in the other modes.
|
|
154
|
+
*
|
|
155
|
+
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
156
|
+
* raised to the minimum and a warning is logged.
|
|
157
|
+
*/
|
|
158
|
+
pollingInterval?: number;
|
|
159
|
+
/**
|
|
160
|
+
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
161
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
162
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
163
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
164
|
+
* no effect in `offline` mode.
|
|
165
|
+
*
|
|
166
|
+
* Defaults to 3,000 milliseconds (3 seconds)
|
|
167
|
+
*/
|
|
168
|
+
timeout?: number;
|
|
169
|
+
/**
|
|
170
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
171
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
172
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
173
|
+
*/
|
|
174
|
+
url?: string;
|
|
175
|
+
};
|
|
95
176
|
/**
|
|
96
177
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
97
178
|
*/
|
|
@@ -103,41 +184,7 @@ type ConfigDirectorClientOptions = {
|
|
|
103
184
|
/**
|
|
104
185
|
* Connection options
|
|
105
186
|
*/
|
|
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
|
-
};
|
|
187
|
+
connection?: ConnectionOptions;
|
|
141
188
|
/**
|
|
142
189
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
143
190
|
* logger set to 'warn' level.
|
|
@@ -197,6 +244,14 @@ type ConfigDirectorClientOptions = {
|
|
|
197
244
|
*/
|
|
198
245
|
hooks?: ClientHooks;
|
|
199
246
|
};
|
|
247
|
+
/**
|
|
248
|
+
* The options of a client created without an SDK key: the connection mode is `offline`.
|
|
249
|
+
*/
|
|
250
|
+
type OfflineClientOptions = ConfigDirectorClientOptions & {
|
|
251
|
+
connection: ConnectionOptions & {
|
|
252
|
+
mode: "offline";
|
|
253
|
+
};
|
|
254
|
+
};
|
|
200
255
|
type ClientEvents = {
|
|
201
256
|
configsUpdated: {
|
|
202
257
|
keys: string[];
|
|
@@ -303,6 +358,12 @@ interface ConfigDirectorClient {
|
|
|
303
358
|
dispose(): void;
|
|
304
359
|
}
|
|
305
360
|
//#endregion
|
|
361
|
+
//#region ../shared/src/errors.d.ts
|
|
362
|
+
declare class ConfigDirectorInitializationError extends Error {
|
|
363
|
+
readonly name: string;
|
|
364
|
+
constructor(message: string);
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
306
367
|
//#region src/ConfigDirectorProvider.d.ts
|
|
307
368
|
declare class ConfigDirectorProvider implements Provider {
|
|
308
369
|
private readonly client;
|
|
@@ -310,7 +371,15 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
310
371
|
readonly metadata: ProviderMetadata;
|
|
311
372
|
readonly runsOn: Paradigm;
|
|
312
373
|
readonly events: OpenFeatureEventEmitter;
|
|
313
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Creates a provider connected to ConfigDirector with the given server SDK key.
|
|
376
|
+
*/
|
|
377
|
+
constructor(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions);
|
|
378
|
+
/**
|
|
379
|
+
* Creates a provider in `offline` mode, which needs no server SDK key: it never connects to
|
|
380
|
+
* ConfigDirector and serves `connection.file` or `connection.values` to every evaluation.
|
|
381
|
+
*/
|
|
382
|
+
constructor(clientOptions: OfflineClientOptions);
|
|
314
383
|
initialize(): Promise<void>;
|
|
315
384
|
resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
316
385
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
@@ -321,5 +390,5 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
321
390
|
private mapContext;
|
|
322
391
|
}
|
|
323
392
|
//#endregion
|
|
324
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType };
|
|
393
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType, type OfflineClientOptions, type OfflineValue, type OfflineValues };
|
|
325
394
|
//# 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,KAUA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAAA;EACP,OAAA;EACA,cAAA;EACA,MAAA,EAAQ,gBAAA;EACR,OAAA,GAAU,qBAAA;AAAA;;;;;AA9BZ;KAqCY,qBAAA;;;;;;;;;EASV,EAAA;EAzCK;;;;;;;AAKP;;;;EAiDE,IAAA;EA7CU;;;;EAmDV,IAAA;EAzCU;;;;EA+CV,MAAA;IAAA,CAAY,GAAA;EAAA;EAzCmB;;;;;;;EAkD/B,SAAA;AAAA;;;;AA3CF;KAkDY,yBAAA;EACV,UAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA
|
|
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,KAUA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAAA;EACP,OAAA;EACA,cAAA;EACA,MAAA,EAAQ,gBAAA;EACR,OAAA,GAAU,qBAAA;AAAA;;;;;AA9BZ;KAqCY,qBAAA;;;;;;;;;EASV,EAAA;EAzCK;;;;;;;AAKP;;;;EAiDE,IAAA;EA7CU;;;;EAmDV,IAAA;EAzCU;;;;EA+CV,MAAA;IAAA,CAAY,GAAA;EAAA;EAzCmB;;;;;;;EAkD/B,SAAA;AAAA;;;;AA3CF;KAkDY,yBAAA;EACV,UAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA;;;KCxHA,eAAA,sCAAqD,eAAA;EAAA,CAAuB,GAAA,WAAc,eAAA;AAAA;AAAA,KAE1F,WAAA,+BAA0C,eAAA;EAAA,CAAuB,GAAA,WAAc,eAAA;AAAA;AAAA,KAE/E,YAAA,GAAe,MA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A,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"}
|
|
@@ -89,9 +89,90 @@ type ConfigDirectorMetaContext = {
|
|
|
89
89
|
appVersion?: string;
|
|
90
90
|
appName?: string;
|
|
91
91
|
};
|
|
92
|
-
type ConnectionMode = "streaming" | "polling";
|
|
92
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region ../shared/src/native-values.d.ts
|
|
95
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
96
|
+
[key: string]: NativeJsonValue;
|
|
97
|
+
};
|
|
98
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
99
|
+
[key: string]: NativeJsonValue;
|
|
100
|
+
};
|
|
101
|
+
type NativeValues = Record<string, NativeValue>;
|
|
93
102
|
//#endregion
|
|
94
103
|
//#region ../js-server-sdk/src/types.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
106
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
107
|
+
* or array (`json`).
|
|
108
|
+
*/
|
|
109
|
+
type OfflineValue = NativeValue;
|
|
110
|
+
/**
|
|
111
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
112
|
+
* value's config type is decided. Every context receives the same value.
|
|
113
|
+
*/
|
|
114
|
+
type OfflineValues = NativeValues;
|
|
115
|
+
/**
|
|
116
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
117
|
+
*/
|
|
118
|
+
type ConnectionOptions = {
|
|
119
|
+
/**
|
|
120
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
121
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
122
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
123
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
124
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
125
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
126
|
+
* the values read from {@link file} or given in {@link values} to every context, or the in-code
|
|
127
|
+
* default values when neither is given. No SDK key is needed.
|
|
128
|
+
*
|
|
129
|
+
* Defaults to `streaming`
|
|
130
|
+
*/
|
|
131
|
+
mode?: ConnectionMode;
|
|
132
|
+
/**
|
|
133
|
+
* The path of a JSON file holding the values to serve in `offline` mode, resolved against the
|
|
134
|
+
* process working directory. The file holds one object with a value per config key, such as
|
|
135
|
+
* `{ "new-checkout": true, "max-items": 20 }`; see {@link OfflineValue} for how the config type
|
|
136
|
+
* of each value is decided. A file that is missing, unreadable, not a JSON object, or holding a
|
|
137
|
+
* value such as `null` makes `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
138
|
+
*
|
|
139
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
140
|
+
* `initialize` rejects.
|
|
141
|
+
*/
|
|
142
|
+
file?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
145
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
146
|
+
*
|
|
147
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
148
|
+
* `initialize` rejects.
|
|
149
|
+
*/
|
|
150
|
+
values?: OfflineValues;
|
|
151
|
+
/**
|
|
152
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
153
|
+
* effect in the other modes.
|
|
154
|
+
*
|
|
155
|
+
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
156
|
+
* raised to the minimum and a warning is logged.
|
|
157
|
+
*/
|
|
158
|
+
pollingInterval?: number;
|
|
159
|
+
/**
|
|
160
|
+
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
161
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
162
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
163
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
164
|
+
* no effect in `offline` mode.
|
|
165
|
+
*
|
|
166
|
+
* Defaults to 3,000 milliseconds (3 seconds)
|
|
167
|
+
*/
|
|
168
|
+
timeout?: number;
|
|
169
|
+
/**
|
|
170
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
171
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
172
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
173
|
+
*/
|
|
174
|
+
url?: string;
|
|
175
|
+
};
|
|
95
176
|
/**
|
|
96
177
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
97
178
|
*/
|
|
@@ -103,41 +184,7 @@ type ConfigDirectorClientOptions = {
|
|
|
103
184
|
/**
|
|
104
185
|
* Connection options
|
|
105
186
|
*/
|
|
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
|
-
};
|
|
187
|
+
connection?: ConnectionOptions;
|
|
141
188
|
/**
|
|
142
189
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
143
190
|
* logger set to 'warn' level.
|
|
@@ -197,6 +244,14 @@ type ConfigDirectorClientOptions = {
|
|
|
197
244
|
*/
|
|
198
245
|
hooks?: ClientHooks;
|
|
199
246
|
};
|
|
247
|
+
/**
|
|
248
|
+
* The options of a client created without an SDK key: the connection mode is `offline`.
|
|
249
|
+
*/
|
|
250
|
+
type OfflineClientOptions = ConfigDirectorClientOptions & {
|
|
251
|
+
connection: ConnectionOptions & {
|
|
252
|
+
mode: "offline";
|
|
253
|
+
};
|
|
254
|
+
};
|
|
200
255
|
type ClientEvents = {
|
|
201
256
|
configsUpdated: {
|
|
202
257
|
keys: string[];
|
|
@@ -303,6 +358,12 @@ interface ConfigDirectorClient {
|
|
|
303
358
|
dispose(): void;
|
|
304
359
|
}
|
|
305
360
|
//#endregion
|
|
361
|
+
//#region ../shared/src/errors.d.ts
|
|
362
|
+
declare class ConfigDirectorInitializationError extends Error {
|
|
363
|
+
readonly name: string;
|
|
364
|
+
constructor(message: string);
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
306
367
|
//#region src/ConfigDirectorProvider.d.ts
|
|
307
368
|
declare class ConfigDirectorProvider implements Provider {
|
|
308
369
|
private readonly client;
|
|
@@ -310,7 +371,15 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
310
371
|
readonly metadata: ProviderMetadata;
|
|
311
372
|
readonly runsOn: Paradigm;
|
|
312
373
|
readonly events: OpenFeatureEventEmitter;
|
|
313
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Creates a provider connected to ConfigDirector with the given server SDK key.
|
|
376
|
+
*/
|
|
377
|
+
constructor(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions);
|
|
378
|
+
/**
|
|
379
|
+
* Creates a provider in `offline` mode, which needs no server SDK key: it never connects to
|
|
380
|
+
* ConfigDirector and serves `connection.file` or `connection.values` to every evaluation.
|
|
381
|
+
*/
|
|
382
|
+
constructor(clientOptions: OfflineClientOptions);
|
|
314
383
|
initialize(): Promise<void>;
|
|
315
384
|
resolveBooleanEvaluation(flagKey: string, defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
316
385
|
resolveStringEvaluation(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
@@ -321,5 +390,5 @@ declare class ConfigDirectorProvider implements Provider {
|
|
|
321
390
|
private mapContext;
|
|
322
391
|
}
|
|
323
392
|
//#endregion
|
|
324
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType };
|
|
393
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, ConfigDirectorProvider, type ConfigValueType, type OfflineClientOptions, type OfflineValue, type OfflineValues };
|
|
325
394
|
//# 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,KAUA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAAA;EACP,OAAA;EACA,cAAA;EACA,MAAA,EAAQ,gBAAA;EACR,OAAA,GAAU,qBAAA;AAAA;;;;;AA9BZ;KAqCY,qBAAA;;;;;;;;;EASV,EAAA;EAzCK;;;;;;;AAKP;;;;EAiDE,IAAA;EA7CU;;;;EAmDV,IAAA;EAzCU;;;;EA+CV,MAAA;IAAA,CAAY,GAAA;EAAA;EAzCmB;;;;;;;EAkD/B,SAAA;AAAA;;;;AA3CF;KAkDY,yBAAA;EACV,UAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA
|
|
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,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,KAUA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAAA;EACP,OAAA;EACA,cAAA;EACA,MAAA,EAAQ,gBAAA;EACR,OAAA,GAAU,qBAAA;AAAA;;;;;AA9BZ;KAqCY,qBAAA;;;;;;;;;EASV,EAAA;EAzCK;;;;;;;AAKP;;;;EAiDE,IAAA;EA7CU;;;;EAmDV,IAAA;EAzCU;;;;EA+CV,MAAA;IAAA,CAAY,GAAA;EAAA;EAzCmB;;;;;;;EAkD/B,SAAA;AAAA;;;;AA3CF;KAkDY,yBAAA;EACV,UAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA;;;KCxHA,eAAA,sCAAqD,eAAA;EAAA,CAAuB,GAAA,WAAc,eAAA;AAAA;AAAA,KAE1F,WAAA,+BAA0C,eAAA;EAAA,CAAuB,GAAA,WAAc,eAAA;AAAA;AAAA,KAE/E,YAAA,GAAe,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