@featbit/js-client-sdk 3.0.13 → 4.0.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.
Files changed (120) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +301 -301
  3. package/dist/esm/FbClientCore.d.ts +6 -5
  4. package/dist/esm/FbClientCore.d.ts.map +1 -1
  5. package/dist/esm/FbClientCore.js +27 -4
  6. package/dist/esm/FbClientCore.js.map +1 -1
  7. package/dist/esm/IFbClientCore.d.ts +8 -7
  8. package/dist/esm/IFbClientCore.d.ts.map +1 -1
  9. package/dist/esm/version.d.ts +1 -1
  10. package/dist/esm/version.d.ts.map +1 -1
  11. package/dist/esm/version.js +1 -1
  12. package/dist/esm/version.js.map +1 -1
  13. package/dist/umd/featbit-js-client-sdk-4.0.0.js +2 -0
  14. package/dist/umd/featbit-js-client-sdk-4.0.0.js.map +1 -0
  15. package/dist/umd/featbit-js-client-sdk.js +1 -1
  16. package/dist/umd/featbit-js-client-sdk.js.map +1 -1
  17. package/package.json +46 -46
  18. package/src/Configuration.ts +232 -232
  19. package/src/Context.ts +61 -61
  20. package/src/FbClientBuilder.ts +167 -167
  21. package/src/FbClientCore.ts +428 -405
  22. package/src/IContextProperty.ts +3 -3
  23. package/src/IDataKind.ts +11 -11
  24. package/src/IFbClient.ts +29 -29
  25. package/src/IFbClientCore.ts +291 -290
  26. package/src/IVersionedData.ts +18 -18
  27. package/src/bootstrap/IBootstrapProvider.ts +4 -4
  28. package/src/bootstrap/JsonBootstrapProvider.ts +34 -34
  29. package/src/bootstrap/NullBootstrapProvider.ts +20 -20
  30. package/src/bootstrap/index.ts +2 -2
  31. package/src/constants.ts +1 -1
  32. package/src/data-sources/DataSourceUpdates.ts +116 -116
  33. package/src/data-sources/createStreamListeners.ts +67 -67
  34. package/src/data-sources/index.ts +1 -1
  35. package/src/data-sync/DataSyncMode.ts +3 -3
  36. package/src/data-sync/IDataSynchronizer.ts +15 -15
  37. package/src/data-sync/IRequestor.ts +10 -10
  38. package/src/data-sync/NullDataSynchronizer.ts +14 -14
  39. package/src/data-sync/PollingDataSynchronizer.ts +125 -125
  40. package/src/data-sync/Requestor.ts +61 -61
  41. package/src/data-sync/WebSocketDataSynchronizer.ts +77 -77
  42. package/src/data-sync/index.ts +8 -8
  43. package/src/data-sync/types.ts +19 -19
  44. package/src/data-sync/utils.ts +31 -31
  45. package/src/errors.ts +47 -47
  46. package/src/evaluation/EvalResult.ts +35 -35
  47. package/src/evaluation/Evaluator.ts +26 -26
  48. package/src/evaluation/IEvalDetail.ts +23 -23
  49. package/src/evaluation/ReasonKinds.ts +9 -9
  50. package/src/evaluation/data/IFlag.ts +29 -29
  51. package/src/evaluation/index.ts +4 -4
  52. package/src/events/DefaultEventProcessor.ts +83 -83
  53. package/src/events/DefaultEventQueue.ts +49 -49
  54. package/src/events/DefaultEventSender.ts +73 -73
  55. package/src/events/DefaultEventSerializer.ts +11 -11
  56. package/src/events/EventDispatcher.ts +127 -127
  57. package/src/events/EventSerializer.ts +4 -4
  58. package/src/events/IEventProcessor.ts +8 -8
  59. package/src/events/IEventQueue.ts +16 -16
  60. package/src/events/IEventSender.ts +13 -13
  61. package/src/events/NullEventProcessor.ts +15 -15
  62. package/src/events/event.ts +129 -129
  63. package/src/events/index.ts +11 -11
  64. package/src/index.ts +21 -21
  65. package/src/integrations/TestLogger.ts +24 -24
  66. package/src/integrations/index.ts +1 -1
  67. package/src/integrations/test_data/FlagBuilder.ts +59 -59
  68. package/src/integrations/test_data/TestData.ts +57 -57
  69. package/src/integrations/test_data/TestDataSynchronizer.ts +49 -49
  70. package/src/integrations/test_data/index.ts +4 -4
  71. package/src/logging/BasicLogger.ts +108 -108
  72. package/src/logging/IBasicLoggerOptions.ts +46 -46
  73. package/src/logging/ILogger.ts +49 -49
  74. package/src/logging/LogLevel.ts +8 -8
  75. package/src/logging/SafeLogger.ts +69 -69
  76. package/src/logging/format.ts +154 -154
  77. package/src/logging/index.ts +5 -5
  78. package/src/options/ClientContext.ts +39 -39
  79. package/src/options/IClientContext.ts +53 -53
  80. package/src/options/IOptions.ts +123 -123
  81. package/src/options/IUser.ts +6 -6
  82. package/src/options/IValidatedOptions.ts +29 -29
  83. package/src/options/OptionMessages.ts +35 -35
  84. package/src/options/UserBuilder.ts +35 -35
  85. package/src/options/Validators.ts +300 -300
  86. package/src/options/index.ts +7 -7
  87. package/src/platform/IInfo.ts +102 -102
  88. package/src/platform/IPlatform.ts +20 -20
  89. package/src/platform/IStore.ts +112 -112
  90. package/src/platform/IWebSocket.ts +22 -22
  91. package/src/platform/browser/BrowserInfo.ts +24 -24
  92. package/src/platform/browser/BrowserPlatform.ts +19 -19
  93. package/src/platform/browser/BrowserRequests.ts +6 -6
  94. package/src/platform/browser/BrowserWebSocket.ts +147 -147
  95. package/src/platform/browser/FbClient.ts +65 -65
  96. package/src/platform/browser/LocalStorageStore.ts +59 -59
  97. package/src/platform/index.ts +11 -11
  98. package/src/platform/requests.ts +76 -76
  99. package/src/store/BaseStore.ts +125 -125
  100. package/src/store/DataKinds.ts +6 -6
  101. package/src/store/IDataSourceUpdates.ts +68 -68
  102. package/src/store/InMemoryStore.ts +36 -36
  103. package/src/store/index.ts +5 -5
  104. package/src/store/serialization.ts +52 -52
  105. package/src/store/store.ts +37 -37
  106. package/src/utils/Emits.ts +75 -75
  107. package/src/utils/EventEmitter.ts +128 -128
  108. package/src/utils/IEventEmitter.ts +14 -14
  109. package/src/utils/Regex.ts +21 -21
  110. package/src/utils/ValueConverters.ts +55 -55
  111. package/src/utils/canonicalizeUri.ts +3 -3
  112. package/src/utils/debounce.ts +33 -33
  113. package/src/utils/http.ts +40 -40
  114. package/src/utils/index.ts +5 -5
  115. package/src/utils/isNullOrUndefined.ts +2 -2
  116. package/src/utils/serializeUser.ts +27 -27
  117. package/src/utils/sleep.ts +5 -5
  118. package/src/version.ts +1 -1
  119. package/dist/umd/featbit-js-client-sdk-3.0.13.js +0 -2
  120. package/dist/umd/featbit-js-client-sdk-3.0.13.js.map +0 -1
@@ -1,70 +1,70 @@
1
- import { ILogger } from "./ILogger";
2
- import { TypeValidators } from "../options/Validators";
3
-
4
- const loggerRequirements = {
5
- error: TypeValidators.Function,
6
- warn: TypeValidators.Function,
7
- info: TypeValidators.Function,
8
- debug: TypeValidators.Function,
9
- };
10
-
11
- /**
12
- * The safeLogger logic exists because we allow the application to pass in a custom logger, but
13
- * there is no guarantee that the logger works correctly and if it ever throws exceptions there
14
- * could be serious consequences (e.g. an uncaught exception within an error event handler, due
15
- * to the SDK trying to log the error, can terminate the application). An exception could result
16
- * from faulty logic in the logger implementation, or it could be that this is not a logger at
17
- * all but some other kind of object; the former is handled by a catch block that logs an error
18
- * message to the SDK's default logger, and we can at least partly guard against the latter by
19
- * checking for the presence of required methods at configuration time.
20
- */
21
- export class SafeLogger implements ILogger {
22
- private logger: ILogger;
23
-
24
- private fallback: ILogger;
25
-
26
- /**
27
- * Construct a safe logger with the specified logger.
28
- * @param logger The logger to use.
29
- * @param fallback A fallback logger to use in case an issue is encountered using
30
- * the provided logger.
31
- */
32
- constructor(logger: ILogger, fallback: ILogger) {
33
- Object.entries(loggerRequirements).forEach(([level, validator]) => {
34
- if (!validator.is((logger as any)[level])) {
35
- throw new Error(`Provided logger instance must support logger.${ level }(...) method`);
36
- // Note that the SDK normally does not throw exceptions to the application, but that rule
37
- // does not apply to FbClientNode.init() which will throw an exception if the parameters are so
38
- // invalid that we cannot proceed with creating the client. An invalid logger meets those
39
- // criteria since the SDK calls the logger during nearly all of its operations.
40
- }
41
- });
42
- this.logger = logger;
43
- this.fallback = fallback;
44
- }
45
-
46
- private log(level: 'error' | 'warn' | 'info' | 'debug', args: any[]) {
47
- try {
48
- this.logger[level](...args);
49
- } catch {
50
- // If all else fails do not break.
51
- this.fallback[level](...args);
52
- }
53
- }
54
-
55
- error(...args: any[]): void {
56
- this.log('error', args);
57
- }
58
-
59
- warn(...args: any[]): void {
60
- this.log('warn', args);
61
- }
62
-
63
- info(...args: any[]): void {
64
- this.log('info', args);
65
- }
66
-
67
- debug(...args: any[]): void {
68
- this.log('debug', args);
69
- }
1
+ import { ILogger } from "./ILogger";
2
+ import { TypeValidators } from "../options/Validators";
3
+
4
+ const loggerRequirements = {
5
+ error: TypeValidators.Function,
6
+ warn: TypeValidators.Function,
7
+ info: TypeValidators.Function,
8
+ debug: TypeValidators.Function,
9
+ };
10
+
11
+ /**
12
+ * The safeLogger logic exists because we allow the application to pass in a custom logger, but
13
+ * there is no guarantee that the logger works correctly and if it ever throws exceptions there
14
+ * could be serious consequences (e.g. an uncaught exception within an error event handler, due
15
+ * to the SDK trying to log the error, can terminate the application). An exception could result
16
+ * from faulty logic in the logger implementation, or it could be that this is not a logger at
17
+ * all but some other kind of object; the former is handled by a catch block that logs an error
18
+ * message to the SDK's default logger, and we can at least partly guard against the latter by
19
+ * checking for the presence of required methods at configuration time.
20
+ */
21
+ export class SafeLogger implements ILogger {
22
+ private logger: ILogger;
23
+
24
+ private fallback: ILogger;
25
+
26
+ /**
27
+ * Construct a safe logger with the specified logger.
28
+ * @param logger The logger to use.
29
+ * @param fallback A fallback logger to use in case an issue is encountered using
30
+ * the provided logger.
31
+ */
32
+ constructor(logger: ILogger, fallback: ILogger) {
33
+ Object.entries(loggerRequirements).forEach(([level, validator]) => {
34
+ if (!validator.is((logger as any)[level])) {
35
+ throw new Error(`Provided logger instance must support logger.${ level }(...) method`);
36
+ // Note that the SDK normally does not throw exceptions to the application, but that rule
37
+ // does not apply to FbClientNode.init() which will throw an exception if the parameters are so
38
+ // invalid that we cannot proceed with creating the client. An invalid logger meets those
39
+ // criteria since the SDK calls the logger during nearly all of its operations.
40
+ }
41
+ });
42
+ this.logger = logger;
43
+ this.fallback = fallback;
44
+ }
45
+
46
+ private log(level: 'error' | 'warn' | 'info' | 'debug', args: any[]) {
47
+ try {
48
+ this.logger[level](...args);
49
+ } catch {
50
+ // If all else fails do not break.
51
+ this.fallback[level](...args);
52
+ }
53
+ }
54
+
55
+ error(...args: any[]): void {
56
+ this.log('error', args);
57
+ }
58
+
59
+ warn(...args: any[]): void {
60
+ this.log('warn', args);
61
+ }
62
+
63
+ info(...args: any[]): void {
64
+ this.log('info', args);
65
+ }
66
+
67
+ debug(...args: any[]): void {
68
+ this.log('debug', args);
69
+ }
70
70
  }
@@ -1,154 +1,154 @@
1
- import { TypeValidators } from "../options/Validators";
2
-
3
-
4
- /**
5
- * Attempt to produce a string representation of a value.
6
- * The format should be roughly comparable to `util.format`
7
- * aside from object which will be JSON versus the `util.inspect`
8
- * format.
9
- * @param val
10
- * @returns A string representation of the value if possible.
11
- */
12
- function tryStringify(val: any) {
13
- if (typeof val === 'string') {
14
- return val;
15
- }
16
- if (val === undefined) {
17
- return 'undefined';
18
- }
19
- if (val === null) {
20
- return 'null';
21
- }
22
- if (Object.prototype.hasOwnProperty.call(val, 'toString')) {
23
- try {
24
- return val.toString();
25
- } catch {
26
- /* Keep going */
27
- }
28
- }
29
-
30
- if (typeof val === 'bigint') {
31
- return `${ val }n`;
32
- }
33
- try {
34
- return JSON.stringify(val);
35
- } catch (error) {
36
- if (error instanceof TypeError && error.message.indexOf('circular') >= 0) {
37
- return '[Circular]';
38
- }
39
- return '[Not Stringifiable]';
40
- }
41
- }
42
-
43
- /**
44
- * Attempt to produce a numeric representation.
45
- * BigInts have an `n` suffix.
46
- * @param val
47
- * @returns The numeric representation or 'NaN' if not numeric.
48
- */
49
- function toNumber(val: any): string {
50
- // Symbol has to be treated special because it will
51
- // throw an exception if an attempt is made to convert it.
52
- if (typeof val === 'symbol') {
53
- return 'NaN';
54
- }
55
- if (typeof val === 'bigint') {
56
- return `${ val }n`;
57
- }
58
- return String(Number(val));
59
- }
60
-
61
- /**
62
- * Attempt to produce an integer representation.
63
- * BigInts have an `n` suffix.
64
- * @param val
65
- * @returns The integer representation or 'NaN' if not numeric.
66
- */
67
- function toInt(val: any): string {
68
- if (typeof val === 'symbol') {
69
- return 'NaN';
70
- }
71
- if (typeof val === 'bigint') {
72
- return `${ val }n`;
73
- }
74
- return String(parseInt(val, 10));
75
- }
76
-
77
- /**
78
- * Attempt to produce a float representation.
79
- * BigInts have an `n` suffix.
80
- * @param val
81
- * @returns The integer representation or 'NaN' if not numeric.
82
- */
83
- function toFloat(val: any): string {
84
- if (typeof val === 'symbol') {
85
- return 'NaN';
86
- }
87
- return String(parseFloat(val));
88
- }
89
-
90
- // Based on:
91
- // https://nodejs.org/api/util.html#utilformatformat-args
92
- // The result will not match browser exactly, but it should get the
93
- // right information through.
94
- const escapes: Record<string, (val: any) => string> = {
95
- s: (val: any) => tryStringify(val),
96
- d: (val: any) => toNumber(val),
97
- i: (val: any) => toInt(val),
98
- f: (val: any) => toFloat(val),
99
- j: (val: any) => tryStringify(val),
100
- o: (val: any) => tryStringify(val),
101
- O: (val: any) => tryStringify(val),
102
- c: () => '',
103
- };
104
-
105
- /**
106
- * A basic formatted for use where `util.format` is not available.
107
- * This will not be as performant, but it will produce formatted
108
- * messages.
109
- *
110
- * @internal
111
- *
112
- * @param args
113
- * @returns Formatted string.
114
- */
115
- export default function format(...args: any[]): string {
116
- const formatString = args.shift();
117
- if (TypeValidators.String.is(formatString)) {
118
- let out = '';
119
- let i = 0;
120
- while (i < formatString.length) {
121
- const char = formatString.charAt(i);
122
- if (char === '%') {
123
- const nextIndex = i + 1;
124
- if (nextIndex < formatString.length) {
125
- const nextChar = formatString.charAt(i + 1);
126
- if (nextChar in escapes && args.length) {
127
- const value = args.shift();
128
- // This rule is for math.
129
- // eslint-disable-next-line no-unsafe-optional-chaining
130
- out += escapes[nextChar]?.(value);
131
- } else if (nextChar === '%') {
132
- out += '%';
133
- } else {
134
- out += `%${ nextChar }`;
135
- }
136
- i += 2;
137
- }
138
- } else {
139
- out += char;
140
- i += 1;
141
- }
142
- }
143
- // If there are any args left after we exhaust the format string
144
- // then just stick those on the end.
145
- if (args.length) {
146
- if (out.length) {
147
- out += ' ';
148
- }
149
- out += args.map(tryStringify).join(' ');
150
- }
151
- return out;
152
- }
153
- return args.map(tryStringify).join(' ');
154
- }
1
+ import { TypeValidators } from "../options/Validators";
2
+
3
+
4
+ /**
5
+ * Attempt to produce a string representation of a value.
6
+ * The format should be roughly comparable to `util.format`
7
+ * aside from object which will be JSON versus the `util.inspect`
8
+ * format.
9
+ * @param val
10
+ * @returns A string representation of the value if possible.
11
+ */
12
+ function tryStringify(val: any) {
13
+ if (typeof val === 'string') {
14
+ return val;
15
+ }
16
+ if (val === undefined) {
17
+ return 'undefined';
18
+ }
19
+ if (val === null) {
20
+ return 'null';
21
+ }
22
+ if (Object.prototype.hasOwnProperty.call(val, 'toString')) {
23
+ try {
24
+ return val.toString();
25
+ } catch {
26
+ /* Keep going */
27
+ }
28
+ }
29
+
30
+ if (typeof val === 'bigint') {
31
+ return `${ val }n`;
32
+ }
33
+ try {
34
+ return JSON.stringify(val);
35
+ } catch (error) {
36
+ if (error instanceof TypeError && error.message.indexOf('circular') >= 0) {
37
+ return '[Circular]';
38
+ }
39
+ return '[Not Stringifiable]';
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Attempt to produce a numeric representation.
45
+ * BigInts have an `n` suffix.
46
+ * @param val
47
+ * @returns The numeric representation or 'NaN' if not numeric.
48
+ */
49
+ function toNumber(val: any): string {
50
+ // Symbol has to be treated special because it will
51
+ // throw an exception if an attempt is made to convert it.
52
+ if (typeof val === 'symbol') {
53
+ return 'NaN';
54
+ }
55
+ if (typeof val === 'bigint') {
56
+ return `${ val }n`;
57
+ }
58
+ return String(Number(val));
59
+ }
60
+
61
+ /**
62
+ * Attempt to produce an integer representation.
63
+ * BigInts have an `n` suffix.
64
+ * @param val
65
+ * @returns The integer representation or 'NaN' if not numeric.
66
+ */
67
+ function toInt(val: any): string {
68
+ if (typeof val === 'symbol') {
69
+ return 'NaN';
70
+ }
71
+ if (typeof val === 'bigint') {
72
+ return `${ val }n`;
73
+ }
74
+ return String(parseInt(val, 10));
75
+ }
76
+
77
+ /**
78
+ * Attempt to produce a float representation.
79
+ * BigInts have an `n` suffix.
80
+ * @param val
81
+ * @returns The integer representation or 'NaN' if not numeric.
82
+ */
83
+ function toFloat(val: any): string {
84
+ if (typeof val === 'symbol') {
85
+ return 'NaN';
86
+ }
87
+ return String(parseFloat(val));
88
+ }
89
+
90
+ // Based on:
91
+ // https://nodejs.org/api/util.html#utilformatformat-args
92
+ // The result will not match browser exactly, but it should get the
93
+ // right information through.
94
+ const escapes: Record<string, (val: any) => string> = {
95
+ s: (val: any) => tryStringify(val),
96
+ d: (val: any) => toNumber(val),
97
+ i: (val: any) => toInt(val),
98
+ f: (val: any) => toFloat(val),
99
+ j: (val: any) => tryStringify(val),
100
+ o: (val: any) => tryStringify(val),
101
+ O: (val: any) => tryStringify(val),
102
+ c: () => '',
103
+ };
104
+
105
+ /**
106
+ * A basic formatted for use where `util.format` is not available.
107
+ * This will not be as performant, but it will produce formatted
108
+ * messages.
109
+ *
110
+ * @internal
111
+ *
112
+ * @param args
113
+ * @returns Formatted string.
114
+ */
115
+ export default function format(...args: any[]): string {
116
+ const formatString = args.shift();
117
+ if (TypeValidators.String.is(formatString)) {
118
+ let out = '';
119
+ let i = 0;
120
+ while (i < formatString.length) {
121
+ const char = formatString.charAt(i);
122
+ if (char === '%') {
123
+ const nextIndex = i + 1;
124
+ if (nextIndex < formatString.length) {
125
+ const nextChar = formatString.charAt(i + 1);
126
+ if (nextChar in escapes && args.length) {
127
+ const value = args.shift();
128
+ // This rule is for math.
129
+ // eslint-disable-next-line no-unsafe-optional-chaining
130
+ out += escapes[nextChar]?.(value);
131
+ } else if (nextChar === '%') {
132
+ out += '%';
133
+ } else {
134
+ out += `%${ nextChar }`;
135
+ }
136
+ i += 2;
137
+ }
138
+ } else {
139
+ out += char;
140
+ i += 1;
141
+ }
142
+ }
143
+ // If there are any args left after we exhaust the format string
144
+ // then just stick those on the end.
145
+ if (args.length) {
146
+ if (out.length) {
147
+ out += ' ';
148
+ }
149
+ out += args.map(tryStringify).join(' ');
150
+ }
151
+ return out;
152
+ }
153
+ return args.map(tryStringify).join(' ');
154
+ }
@@ -1,6 +1,6 @@
1
- export * from './BasicLogger';
2
- export * from './format';
3
- export * from './IBasicLoggerOptions';
4
- export * from './ILogger';
5
- export * from './LogLevel';
1
+ export * from './BasicLogger';
2
+ export * from './format';
3
+ export * from './IBasicLoggerOptions';
4
+ export * from './ILogger';
5
+ export * from './LogLevel';
6
6
  export * from './SafeLogger';
@@ -1,40 +1,40 @@
1
- import { ILogger } from "../logging/ILogger";
2
- import { IPlatform } from "../platform/IPlatform";
3
- import { IClientContext } from "./IClientContext";
4
- import { IUser } from "./IUser";
5
-
6
- /**
7
- * The client context provides basic configuration and platform support which are required
8
- * when building SDK components.
9
- */
10
- export default class ClientContext implements IClientContext {
11
- flushInterval: number;
12
- maxEventsInQueue: number;
13
- offline: boolean;
14
- logger: ILogger;
15
- eventsUri: string;
16
- pollingUri: string;
17
- streamingUri: string;
18
-
19
- constructor(
20
- public readonly sdkKey: string,
21
- configuration: {
22
- logger?: ILogger;
23
- offline?: boolean;
24
- flushInterval: number;
25
- maxEventsInQueue: number;
26
- streamingUri: string;
27
- pollingUri: string;
28
- eventsUri: string;
29
- },
30
- public readonly platform: IPlatform,
31
- ) {
32
- this.logger = configuration.logger!;
33
- this.offline = configuration.offline!;
34
- this.flushInterval = configuration.flushInterval;
35
- this.maxEventsInQueue = configuration.maxEventsInQueue;
36
- this.streamingUri = configuration.streamingUri;
37
- this.pollingUri = configuration.pollingUri;
38
- this.eventsUri = configuration.eventsUri;
39
- }
1
+ import { ILogger } from "../logging/ILogger";
2
+ import { IPlatform } from "../platform/IPlatform";
3
+ import { IClientContext } from "./IClientContext";
4
+ import { IUser } from "./IUser";
5
+
6
+ /**
7
+ * The client context provides basic configuration and platform support which are required
8
+ * when building SDK components.
9
+ */
10
+ export default class ClientContext implements IClientContext {
11
+ flushInterval: number;
12
+ maxEventsInQueue: number;
13
+ offline: boolean;
14
+ logger: ILogger;
15
+ eventsUri: string;
16
+ pollingUri: string;
17
+ streamingUri: string;
18
+
19
+ constructor(
20
+ public readonly sdkKey: string,
21
+ configuration: {
22
+ logger?: ILogger;
23
+ offline?: boolean;
24
+ flushInterval: number;
25
+ maxEventsInQueue: number;
26
+ streamingUri: string;
27
+ pollingUri: string;
28
+ eventsUri: string;
29
+ },
30
+ public readonly platform: IPlatform,
31
+ ) {
32
+ this.logger = configuration.logger!;
33
+ this.offline = configuration.offline!;
34
+ this.flushInterval = configuration.flushInterval;
35
+ this.maxEventsInQueue = configuration.maxEventsInQueue;
36
+ this.streamingUri = configuration.streamingUri;
37
+ this.pollingUri = configuration.pollingUri;
38
+ this.eventsUri = configuration.eventsUri;
39
+ }
40
40
  }
@@ -1,54 +1,54 @@
1
- import { ILogger } from "../logging/ILogger";
2
- import { IPlatform } from "../platform/IPlatform";
3
-
4
- /**
5
- * Factory methods receive this class as a parameter.
6
- *
7
- * Its public properties provide information about the SDK configuration and environment. The SDK
8
- * may also include non-public properties that are relevant only when creating one of the built-in
9
- * component types and are not accessible to custom components.
10
- */
11
- export interface IClientContext {
12
-
13
- logger?: ILogger;
14
-
15
- /**
16
- * True if the SDK was configured to be completely offline.
17
- */
18
- offline?: boolean;
19
-
20
- /**
21
- * The configured SDK key.
22
- */
23
- sdkKey: string;
24
-
25
- /**
26
- * The base URI of the data-sync service
27
- */
28
- streamingUri: string;
29
-
30
- /**
31
- * The base URI of the polling service
32
- */
33
- pollingUri: string;
34
-
35
- /**
36
- * The base URI of the event service
37
- */
38
- eventsUri: string;
39
-
40
- /**
41
- * The interval in between flushes of events queue, in milliseconds.
42
- */
43
- flushInterval: number;
44
-
45
- /**
46
- * The max number of events in the events queue.
47
- */
48
- maxEventsInQueue: number;
49
-
50
- /**
51
- * Interfaces providing platform specific information and functionality.
52
- */
53
- platform: IPlatform;
1
+ import { ILogger } from "../logging/ILogger";
2
+ import { IPlatform } from "../platform/IPlatform";
3
+
4
+ /**
5
+ * Factory methods receive this class as a parameter.
6
+ *
7
+ * Its public properties provide information about the SDK configuration and environment. The SDK
8
+ * may also include non-public properties that are relevant only when creating one of the built-in
9
+ * component types and are not accessible to custom components.
10
+ */
11
+ export interface IClientContext {
12
+
13
+ logger?: ILogger;
14
+
15
+ /**
16
+ * True if the SDK was configured to be completely offline.
17
+ */
18
+ offline?: boolean;
19
+
20
+ /**
21
+ * The configured SDK key.
22
+ */
23
+ sdkKey: string;
24
+
25
+ /**
26
+ * The base URI of the data-sync service
27
+ */
28
+ streamingUri: string;
29
+
30
+ /**
31
+ * The base URI of the polling service
32
+ */
33
+ pollingUri: string;
34
+
35
+ /**
36
+ * The base URI of the event service
37
+ */
38
+ eventsUri: string;
39
+
40
+ /**
41
+ * The interval in between flushes of events queue, in milliseconds.
42
+ */
43
+ flushInterval: number;
44
+
45
+ /**
46
+ * The max number of events in the events queue.
47
+ */
48
+ maxEventsInQueue: number;
49
+
50
+ /**
51
+ * Interfaces providing platform specific information and functionality.
52
+ */
53
+ platform: IPlatform;
54
54
  }