launchdarkly-js-sdk-common 3.3.4 → 3.5.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/CHANGELOG.md +11 -0
- package/dist/ldclient-common.cjs.js +1 -1
- package/dist/ldclient-common.cjs.js.map +1 -1
- package/dist/ldclient-common.es.js +1 -1
- package/dist/ldclient-common.es.js.map +1 -1
- package/dist/ldclient-common.min.js +1 -1
- package/dist/ldclient-common.min.js.map +1 -1
- package/package.json +2 -2
- package/typings.d.ts +104 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "launchdarkly-js-sdk-common",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "LaunchDarkly SDK for JavaScript - common code",
|
|
5
5
|
"author": "LaunchDarkly <team@launchdarkly.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"rollup-plugin-uglify": "6.0.4",
|
|
69
69
|
"semver": "^5.5.0",
|
|
70
70
|
"semver-compare": "^1.0.0",
|
|
71
|
-
"typescript": "
|
|
71
|
+
"typescript": "~4.4.4"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"base64-js": "^1.3.0",
|
package/typings.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
53
53
|
* respectively.
|
|
54
54
|
*
|
|
55
55
|
* To make LDClient use this logger, put it in the `logger` property of [[LDOptions]].
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Please use `basicLogger` instead.
|
|
56
58
|
*/
|
|
57
59
|
export function createConsoleLogger(minimumLevel: string): LDLogger;
|
|
58
60
|
|
|
@@ -66,8 +68,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
66
68
|
/**
|
|
67
69
|
* An object that will perform logging for the client.
|
|
68
70
|
*
|
|
69
|
-
* If not specified, the default is
|
|
70
|
-
* from the `winston` package in Electron.
|
|
71
|
+
* If not specified, the default is to use `basicLogger`.
|
|
71
72
|
*/
|
|
72
73
|
logger?: LDLogger;
|
|
73
74
|
|
|
@@ -139,6 +140,14 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
139
140
|
*/
|
|
140
141
|
sendLDHeaders?: boolean;
|
|
141
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A transform function for dynamic configuration of HTTP headers.
|
|
145
|
+
*
|
|
146
|
+
* This method will run last in the header generation sequence, so the function should have
|
|
147
|
+
* all system generated headers in case those also need to be modified.
|
|
148
|
+
*/
|
|
149
|
+
requestHeaderTransform?: (headers: Map<string, string>) => Map<string, string>;
|
|
150
|
+
|
|
142
151
|
/**
|
|
143
152
|
* Whether LaunchDarkly should provide additional information about how flag values were
|
|
144
153
|
* calculated.
|
|
@@ -442,8 +451,7 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
442
451
|
}
|
|
443
452
|
|
|
444
453
|
/**
|
|
445
|
-
* The basic interface for the LaunchDarkly client.
|
|
446
|
-
* use this, but may add some methods of their own.
|
|
454
|
+
* The basic interface for the LaunchDarkly client. Platform-specific SDKs may add some methods of their own.
|
|
447
455
|
*
|
|
448
456
|
* @see https://docs.launchdarkly.com/sdk/client-side/javascript
|
|
449
457
|
*
|
|
@@ -727,4 +735,96 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
727
735
|
*/
|
|
728
736
|
close(onDone?: () => void): Promise<void>;
|
|
729
737
|
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Provides a simple [[LDLogger]] implementation.
|
|
741
|
+
*
|
|
742
|
+
* This logging implementation uses a simple format that includes only the log level
|
|
743
|
+
* and the message text. Output is written to the console unless otherwise specified.
|
|
744
|
+
* You can filter by log level as described in [[BasicLoggerOptions.level]].
|
|
745
|
+
*
|
|
746
|
+
* To use the logger created by this function, put it into [[LDOptions.logger]]. If
|
|
747
|
+
* you do not set [[LDOptions.logger]] to anything, the SDK uses a default logger
|
|
748
|
+
* that is equivalent to `ld.basicLogger({ level: 'info' })`.
|
|
749
|
+
*
|
|
750
|
+
* @param options Configuration for the logger. If no options are specified, the
|
|
751
|
+
* logger uses `{ level: 'info' }`.
|
|
752
|
+
*
|
|
753
|
+
* @param formatter An optional function equivalent to Node's util.format, allowing
|
|
754
|
+
* for parameter substitution in log messages. If this is omitted, parameter
|
|
755
|
+
* substitution is not available.
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* This example shows how to use `basicLogger` in your SDK options to enable console
|
|
759
|
+
* logging only at `warn` and `error` levels.
|
|
760
|
+
* ```javascript
|
|
761
|
+
* const ldOptions = {
|
|
762
|
+
* logger: ld.basicLogger({ level: 'warn' }),
|
|
763
|
+
* };
|
|
764
|
+
* ```
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* This example shows how to use `basicLogger` in your SDK options to cause log
|
|
768
|
+
* output to always go to `console.error` instead of `console.log`.
|
|
769
|
+
* ```javascript
|
|
770
|
+
* const ldOptions = {
|
|
771
|
+
* logger: ld.basicLogger({ destination: console.error }),
|
|
772
|
+
* };
|
|
773
|
+
* ```
|
|
774
|
+
*
|
|
775
|
+
* @ignore (don't need to show this separately in TypeDoc output; each SDK should provide its own
|
|
776
|
+
* basicLogger function that delegates to this and sets the formatter parameter)
|
|
777
|
+
*/
|
|
778
|
+
export function commonBasicLogger(
|
|
779
|
+
options?: BasicLoggerOptions,
|
|
780
|
+
formatter?: (format: string, ...args: any[]) => void
|
|
781
|
+
): LDLogger;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Configuration for [[basicLogger]].
|
|
785
|
+
*/
|
|
786
|
+
export interface BasicLoggerOptions {
|
|
787
|
+
/**
|
|
788
|
+
* The lowest level of log message to enable.
|
|
789
|
+
*
|
|
790
|
+
* See [[LDLogLevel]] for a list of possible levels. Setting a level here causes
|
|
791
|
+
* all lower-importance levels to be disabled: for instance, if you specify
|
|
792
|
+
* `'warn'`, then `'debug'` and `'info'` are disabled.
|
|
793
|
+
*
|
|
794
|
+
* If not specified, the default is `'info'` (meaning that `'debug'` is disabled).
|
|
795
|
+
*/
|
|
796
|
+
level?: LDLogLevel;
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* A string to prepend to all log output. If not specified, the default is
|
|
800
|
+
* "[LaunchDarkly] ".
|
|
801
|
+
*/
|
|
802
|
+
prefix?: string;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* An optional function to use to print each log line.
|
|
806
|
+
*
|
|
807
|
+
* If this is specified, `basicLogger` calls it to write each line of output. The
|
|
808
|
+
* argument is a fully formatted log line, not including a linefeed. The function
|
|
809
|
+
* is only called for log levels that are enabled.
|
|
810
|
+
*
|
|
811
|
+
* If not specified, the default in browsers is to use `console.log`, `console.info`,
|
|
812
|
+
* `console.warn`, or `console.error` according to the level; the default in
|
|
813
|
+
* Node.js and Electron is to always use `console.log`.
|
|
814
|
+
*
|
|
815
|
+
* Setting this property to anything other than a function will cause SDK
|
|
816
|
+
* initialization to fail.
|
|
817
|
+
*/
|
|
818
|
+
destination?: (line: string) => void,
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Logging levels that can be used with [[basicLogger]].
|
|
823
|
+
*
|
|
824
|
+
* Set [[BasicLoggerOptions.level]] to one of these values to control what levels
|
|
825
|
+
* of log messages are enabled. Going from lowest importance (and most verbose)
|
|
826
|
+
* to most importance, the levels are `'debug'`, `'info'`, `'warn'`, and `'error'`.
|
|
827
|
+
* You can also specify `'none'` instead to disable all logging.
|
|
828
|
+
*/
|
|
829
|
+
export type LDLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
730
830
|
}
|