@launchdarkly/js-client-sdk-common 0.1.0-alpha

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 (75) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +1 -0
  3. package/dist/LDClientImpl.d.ts +65 -0
  4. package/dist/LDClientImpl.d.ts.map +1 -0
  5. package/dist/LDClientImpl.js +304 -0
  6. package/dist/LDClientImpl.js.map +1 -0
  7. package/dist/api/LDClient.d.ts +285 -0
  8. package/dist/api/LDClient.d.ts.map +1 -0
  9. package/dist/api/LDClient.js +3 -0
  10. package/dist/api/LDClient.js.map +1 -0
  11. package/dist/api/LDEmitter.d.ts +37 -0
  12. package/dist/api/LDEmitter.d.ts.map +1 -0
  13. package/dist/api/LDEmitter.js +88 -0
  14. package/dist/api/LDEmitter.js.map +1 -0
  15. package/dist/api/LDInspection.d.ts +88 -0
  16. package/dist/api/LDInspection.d.ts.map +1 -0
  17. package/dist/api/LDInspection.js +3 -0
  18. package/dist/api/LDInspection.js.map +1 -0
  19. package/dist/api/LDOptions.d.ts +172 -0
  20. package/dist/api/LDOptions.d.ts.map +1 -0
  21. package/dist/api/LDOptions.js +3 -0
  22. package/dist/api/LDOptions.js.map +1 -0
  23. package/dist/api/index.d.ts +3 -0
  24. package/dist/api/index.d.ts.map +1 -0
  25. package/dist/api/index.js +19 -0
  26. package/dist/api/index.js.map +1 -0
  27. package/dist/configuration/Configuration.d.ts +39 -0
  28. package/dist/configuration/Configuration.d.ts.map +1 -0
  29. package/dist/configuration/Configuration.js +69 -0
  30. package/dist/configuration/Configuration.js.map +1 -0
  31. package/dist/configuration/index.d.ts +3 -0
  32. package/dist/configuration/index.d.ts.map +1 -0
  33. package/dist/configuration/index.js +5 -0
  34. package/dist/configuration/index.js.map +1 -0
  35. package/dist/configuration/validators.d.ts +5 -0
  36. package/dist/configuration/validators.d.ts.map +1 -0
  37. package/dist/configuration/validators.js +38 -0
  38. package/dist/configuration/validators.js.map +1 -0
  39. package/dist/diagnostics/createDiagnosticsInitConfig.d.ts +16 -0
  40. package/dist/diagnostics/createDiagnosticsInitConfig.d.ts.map +1 -0
  41. package/dist/diagnostics/createDiagnosticsInitConfig.js +18 -0
  42. package/dist/diagnostics/createDiagnosticsInitConfig.js.map +1 -0
  43. package/dist/diagnostics/createDiagnosticsManager.d.ts +5 -0
  44. package/dist/diagnostics/createDiagnosticsManager.d.ts.map +1 -0
  45. package/dist/diagnostics/createDiagnosticsManager.js +12 -0
  46. package/dist/diagnostics/createDiagnosticsManager.js.map +1 -0
  47. package/dist/evaluation/fetchFlags.d.ts +6 -0
  48. package/dist/evaluation/fetchFlags.d.ts.map +1 -0
  49. package/dist/evaluation/fetchFlags.js +12 -0
  50. package/dist/evaluation/fetchFlags.js.map +1 -0
  51. package/dist/evaluation/fetchUtils.d.ts +7 -0
  52. package/dist/evaluation/fetchUtils.d.ts.map +1 -0
  53. package/dist/evaluation/fetchUtils.js +46 -0
  54. package/dist/evaluation/fetchUtils.js.map +1 -0
  55. package/dist/events/EventFactory.d.ts +2 -0
  56. package/dist/events/EventFactory.d.ts.map +1 -0
  57. package/dist/events/EventFactory.js +25 -0
  58. package/dist/events/EventFactory.js.map +1 -0
  59. package/dist/events/createEventProcessor.d.ts +5 -0
  60. package/dist/events/createEventProcessor.d.ts.map +1 -0
  61. package/dist/events/createEventProcessor.js +8 -0
  62. package/dist/events/createEventProcessor.js.map +1 -0
  63. package/dist/index.d.ts +6 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +23 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/types/index.d.ts +20 -0
  68. package/dist/types/index.d.ts.map +1 -0
  69. package/dist/types/index.js +3 -0
  70. package/dist/types/index.js.map +1 -0
  71. package/dist/utils/index.d.ts +3 -0
  72. package/dist/utils/index.d.ts.map +1 -0
  73. package/dist/utils/index.js +24 -0
  74. package/dist/utils/index.js.map +1 -0
  75. package/package.json +58 -0
@@ -0,0 +1,172 @@
1
+ import type { LDFlagSet, LDLogger } from '@launchdarkly/js-sdk-common';
2
+ import type { LDInspection } from './LDInspection';
3
+ export interface LDOptions {
4
+ /**
5
+ * An object that will perform logging for the client.
6
+ *
7
+ * If not specified, the default is to use `basicLogger`.
8
+ */
9
+ logger?: LDLogger;
10
+ /**
11
+ * The initial set of flags to use until the remote set is retrieved.
12
+ *
13
+ * If `"localStorage"` is specified, the flags will be saved and retrieved from browser local
14
+ * storage. Alternatively, an {@link LDFlagSet} can be specified which will be used as the initial
15
+ * source of flag values. In the latter case, the flag values will be available via {@link LDClient.variation}
16
+ * immediately after calling `initialize()` (normally they would not be available until the
17
+ * client signals that it is ready).
18
+ *
19
+ * For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/features/bootstrapping#javascript).
20
+ */
21
+ bootstrap?: 'localStorage' | LDFlagSet;
22
+ /**
23
+ * The base uri for the LaunchDarkly server.
24
+ *
25
+ * Most users should use the default value.
26
+ */
27
+ baseUri?: string;
28
+ /**
29
+ * The base uri for the LaunchDarkly events server.
30
+ *
31
+ * Most users should use the default value.
32
+ */
33
+ eventsUri?: string;
34
+ /**
35
+ * The base uri for the LaunchDarkly streaming server.
36
+ *
37
+ * Most users should use the default value.
38
+ */
39
+ streamUri?: string;
40
+ /**
41
+ * Whether LaunchDarkly should provide additional information about how flag values were
42
+ * calculated.
43
+ *
44
+ * The additional information will then be available through the client's
45
+ * {@link LDClient.variationDetail} method. Since this increases the size of network requests,
46
+ * such information is not sent unless you set this option to true.
47
+ */
48
+ withReasons?: boolean;
49
+ /**
50
+ * Whether to send analytics events back to LaunchDarkly. By default, this is true.
51
+ */
52
+ sendEvents?: boolean;
53
+ /**
54
+ * Whether all context attributes (except the context key) should be marked as private, and
55
+ * not sent to LaunchDarkly in analytics events.
56
+ *
57
+ * By default, this is false.
58
+ */
59
+ allAttributesPrivate?: boolean;
60
+ /**
61
+ * Specifies a list of attribute names (either built-in or custom) which should be marked as
62
+ * private, and not sent to LaunchDarkly in analytics events. You can also specify this on a
63
+ * per-context basis with {@link LDContextMeta.privateAttributes}.
64
+ *
65
+ * Any contexts sent to LaunchDarkly with this configuration active will have attributes with
66
+ * these names removed in analytic events. This is in addition to any attributes that were
67
+ * marked as private for an individual context with {@link LDContextMeta.privateAttributes}.
68
+ * Setting {@link LDOptions.allAttributesPrivate} to true overrides this.
69
+ *
70
+ * If and only if a parameter starts with a slash, it is interpreted as a slash-delimited path
71
+ * that can denote a nested property within a JSON object. For instance, "/address/street" means
72
+ * that if there is an attribute called "address" that is a JSON object, and one of the object's
73
+ * properties is "street", the "street" property will be redacted from the analytics data but
74
+ * other properties within "address" will still be sent. This syntax also uses the JSON Pointer
75
+ * convention of escaping a literal slash character as "~1" and a tilde as "~0".
76
+ */
77
+ privateAttributes?: Array<string>;
78
+ /**
79
+ * The capacity of the analytics events queue.
80
+ *
81
+ * The client buffers up to this many events in memory before flushing. If the capacity is exceeded
82
+ * before the queue is flushed, events will be discarded. Increasing the capacity means that events
83
+ * are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage
84
+ * flag evaluations do not produce individual events, only summary counts, so you only need a large
85
+ * capacity if you are generating a large number of click, pageview, or identify events (or if you
86
+ * are using the event debugger).
87
+ *
88
+ * The default value is 100.
89
+ */
90
+ capacity?: number;
91
+ /**
92
+ * The interval in between flushes of the analytics events queue, in seconds.
93
+ *
94
+ * The default value is 2s.
95
+ */
96
+ flushInterval?: number;
97
+ /**
98
+ * Sets the initial reconnect delay for the streaming connection, in seconds.
99
+ *
100
+ * The streaming service uses a backoff algorithm (with jitter) every time the connection needs
101
+ * to be reestablished. The delay for the first reconnection will start near this value, and then
102
+ * increase exponentially for any subsequent connection failures.
103
+ *
104
+ * The default value is 1.
105
+ */
106
+ streamInitialReconnectDelay?: number;
107
+ /**
108
+ * Set to true to opt out of sending diagnostics data.
109
+ *
110
+ * Unless `diagnosticOptOut` is set to true, the client will send some diagnostics data to the LaunchDarkly
111
+ * servers in order to assist in the development of future SDK improvements. These diagnostics consist of
112
+ * an initial payload containing some details of SDK in use, the SDK's configuration, and the platform the
113
+ * SDK is being run on, as well as payloads sent periodically with information on irregular occurrences such
114
+ * as dropped events.
115
+ */
116
+ diagnosticOptOut?: boolean;
117
+ /**
118
+ * The interval at which periodic diagnostic data is sent, in seconds.
119
+ *
120
+ * The default is 900 (every 15 minutes) and the minimum value is 6. See {@link diagnosticOptOut}
121
+ * for more information on the diagnostics data being sent.
122
+ */
123
+ diagnosticRecordingInterval?: number;
124
+ /**
125
+ * For use by wrapper libraries to set an identifying name for the wrapper being used.
126
+ *
127
+ * This will be sent as diagnostic information to the LaunchDarkly servers to allow recording
128
+ * metrics on the usage of these wrapper libraries.
129
+ */
130
+ wrapperName?: string;
131
+ /**
132
+ * For use by wrapper libraries to set version to be included alongside `wrapperName`.
133
+ *
134
+ * If `wrapperName` is unset, this field will be ignored.
135
+ */
136
+ wrapperVersion?: string;
137
+ /**
138
+ * Information about the application where the LaunchDarkly SDK is running.
139
+ */
140
+ application?: {
141
+ /**
142
+ * A unique identifier representing the application where the LaunchDarkly SDK is running.
143
+ *
144
+ * This can be specified as any string value as long as it only uses the following characters: ASCII letters,
145
+ * ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
146
+ *
147
+ * Example: `authentication-service`
148
+ */
149
+ id?: string;
150
+ /**
151
+ * A unique identifier representing the version of the application where the LaunchDarkly SDK is running.
152
+ *
153
+ * This can be specified as any string value as long as it only uses the following characters: ASCII letters,
154
+ * ASCII digits, period, hyphen, underscore. A string containing any other characters will be ignored.
155
+ *
156
+ * Example: `1.0.0` (standard version string) or `abcdef` (sha prefix)
157
+ */
158
+ version?: string;
159
+ };
160
+ /**
161
+ * Inspectors can be used for collecting information for monitoring, analytics, and debugging.
162
+ */
163
+ inspectors?: LDInspection[];
164
+ /**
165
+ * The signed context key for Secure Mode.
166
+ *
167
+ * For more information, see the JavaScript SDK Reference Guide on
168
+ * [Secure mode](https://docs.launchdarkly.com/sdk/features/secure-mode#configuring-secure-mode-in-the-javascript-client-side-sdk).
169
+ */
170
+ hash?: string;
171
+ }
172
+ //# sourceMappingURL=LDOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDOptions.d.ts","sourceRoot":"","sources":["../../src/api/LDOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC;IAElB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAEvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAElC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;;OAQG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ;;;;;;;WAOG;QACH,EAAE,CAAC,EAAE,MAAM,CAAC;QAEZ;;;;;;;WAOG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF;;OAEG;IACH,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LDOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDOptions.js","sourceRoot":"","sources":["../../src/api/LDOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './LDOptions';
2
+ export * from './LDClient';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./LDOptions"), exports);
18
+ __exportStar(require("./LDClient"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B"}
@@ -0,0 +1,39 @@
1
+ import { ApplicationTags, internal, LDFlagSet, ServiceEndpoints } from '@launchdarkly/js-sdk-common';
2
+ import { type LDOptions } from '../api';
3
+ import { LDInspection } from '../api/LDInspection';
4
+ export default class Configuration {
5
+ static DEFAULT_POLLING: string;
6
+ static DEFAULT_STREAM: string;
7
+ readonly logger: import("@launchdarkly/js-sdk-common").BasicLogger | import("@launchdarkly/js-sdk-common").SafeLogger;
8
+ readonly baseUri: string;
9
+ readonly eventsUri: string;
10
+ readonly streamUri: string;
11
+ readonly capacity = 100;
12
+ readonly diagnosticRecordingInterval = 900;
13
+ readonly flushInterval = 2;
14
+ readonly streamInitialReconnectDelay = 1;
15
+ readonly allAttributesPrivate = false;
16
+ readonly diagnosticOptOut = false;
17
+ readonly withReasons = false;
18
+ readonly sendEvents = true;
19
+ readonly sendLDHeaders = true;
20
+ readonly useReport = false;
21
+ readonly inspectors: LDInspection[];
22
+ readonly privateAttributes: string[];
23
+ readonly tags: ApplicationTags;
24
+ readonly application?: {
25
+ id?: string;
26
+ version?: string;
27
+ };
28
+ readonly bootstrap?: 'localStorage' | LDFlagSet;
29
+ readonly requestHeaderTransform?: (headers: Map<string, string>) => Map<string, string>;
30
+ readonly stream?: boolean;
31
+ readonly hash?: string;
32
+ readonly wrapperName?: string;
33
+ readonly wrapperVersion?: string;
34
+ readonly serviceEndpoints: ServiceEndpoints;
35
+ [index: string]: any;
36
+ constructor(pristineOptions?: LDOptions, internalOptions?: internal.LDInternalOptions);
37
+ validateTypesAndNames(pristineOptions: LDOptions): string[];
38
+ }
39
+ //# sourceMappingURL=Configuration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Configuration.d.ts","sourceRoot":"","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,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExC,SAAgB,gBAAgB,EAAE,gBAAgB,CAAC;IAGnD,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;gBAET,eAAe,GAAE,SAAc,EAAE,eAAe,GAAE,QAAQ,CAAC,iBAAsB;IAe7F,qBAAqB,CAAC,eAAe,EAAE,SAAS,GAAG,MAAM,EAAE;CAqC5D"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
4
+ const validators_1 = require("./validators");
5
+ class Configuration {
6
+ constructor(pristineOptions = {}, internalOptions = {}) {
7
+ this.logger = (0, js_sdk_common_1.createSafeLogger)();
8
+ this.baseUri = Configuration.DEFAULT_POLLING;
9
+ this.eventsUri = js_sdk_common_1.ServiceEndpoints.DEFAULT_EVENTS;
10
+ this.streamUri = Configuration.DEFAULT_STREAM;
11
+ this.capacity = 100;
12
+ this.diagnosticRecordingInterval = 900;
13
+ this.flushInterval = 2;
14
+ this.streamInitialReconnectDelay = 1;
15
+ this.allAttributesPrivate = false;
16
+ this.diagnosticOptOut = false;
17
+ this.withReasons = false;
18
+ this.sendEvents = true;
19
+ this.sendLDHeaders = true;
20
+ this.useReport = false;
21
+ this.inspectors = [];
22
+ this.privateAttributes = [];
23
+ const errors = this.validateTypesAndNames(pristineOptions);
24
+ errors.forEach((e) => this.logger.warn(e));
25
+ this.serviceEndpoints = new js_sdk_common_1.ServiceEndpoints(this.streamUri, this.baseUri, this.eventsUri, internalOptions.analyticsEventPath, internalOptions.diagnosticEventPath, internalOptions.includeAuthorizationHeader);
26
+ this.tags = new js_sdk_common_1.ApplicationTags({ application: this.application, logger: this.logger });
27
+ }
28
+ validateTypesAndNames(pristineOptions) {
29
+ const errors = [];
30
+ Object.entries(pristineOptions).forEach(([k, v]) => {
31
+ const validator = validators_1.default[k];
32
+ if (validator) {
33
+ if (!validator.is(v)) {
34
+ const validatorType = validator.getType();
35
+ if (validatorType === 'boolean') {
36
+ errors.push(js_sdk_common_1.OptionMessages.wrongOptionTypeBoolean(k, typeof v));
37
+ this[k] = !!v;
38
+ }
39
+ else if (validatorType === 'boolean | undefined | null') {
40
+ errors.push(js_sdk_common_1.OptionMessages.wrongOptionTypeBoolean(k, typeof v));
41
+ if (typeof v !== 'boolean' && typeof v !== 'undefined' && v !== null) {
42
+ this[k] = !!v;
43
+ }
44
+ }
45
+ else if (validator instanceof js_sdk_common_1.NumberWithMinimum && js_sdk_common_1.TypeValidators.Number.is(v)) {
46
+ const { min } = validator;
47
+ errors.push(js_sdk_common_1.OptionMessages.optionBelowMinimum(k, v, min));
48
+ this[k] = min;
49
+ }
50
+ else {
51
+ errors.push(js_sdk_common_1.OptionMessages.wrongOptionType(k, validator.getType(), typeof v));
52
+ }
53
+ }
54
+ else {
55
+ // if an option is explicitly null, coerce to undefined
56
+ this[k] = v !== null && v !== void 0 ? v : undefined;
57
+ }
58
+ }
59
+ else {
60
+ errors.push(js_sdk_common_1.OptionMessages.unknownOption(k));
61
+ }
62
+ });
63
+ return errors;
64
+ }
65
+ }
66
+ Configuration.DEFAULT_POLLING = 'https://sdk.launchdarkly.com';
67
+ Configuration.DEFAULT_STREAM = 'https://clientstream.launchdarkly.com';
68
+ exports.default = Configuration;
69
+ //# sourceMappingURL=Configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../src/configuration/Configuration.ts"],"names":[],"mappings":";;AAAA,+DASqC;AAIrC,6CAAsC;AAEtC,MAAqB,aAAa;IAuChC,YAAY,kBAA6B,EAAE,EAAE,kBAA8C,EAAE;QAnC7E,WAAM,GAAG,IAAA,gCAAgB,GAAE,CAAC;QAE5B,YAAO,GAAG,aAAa,CAAC,eAAe,CAAC;QACxC,cAAS,GAAG,gCAAgB,CAAC,cAAc,CAAC;QAC5C,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CAAC,IAAI,CAAC,8BAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;;AAzFa,6BAAe,GAAG,8BAA8B,AAAjC,CAAkC;AACjD,4BAAc,GAAG,uCAAuC,AAA1C,CAA2C;kBAFpD,aAAa"}
@@ -0,0 +1,3 @@
1
+ import Configuration from './Configuration';
2
+ export default Configuration;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,eAAe,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Configuration_1 = require("./Configuration");
4
+ exports.default = Configuration_1.default;
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;AAAA,mDAA4C;AAE5C,kBAAe,uBAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { TypeValidator } from '@launchdarkly/js-sdk-common';
2
+ import { type LDOptions } from '../api';
3
+ declare const validators: Record<keyof LDOptions, TypeValidator>;
4
+ export default validators;
5
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/configuration/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,aAAa,EAAkB,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAaxC,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,SAAS,EAAE,aAAa,CA6BtD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
4
+ class BootStrapValidator {
5
+ is(u) {
6
+ return u === 'localStorage' || typeof u === 'object' || typeof u === 'undefined' || u === null;
7
+ }
8
+ getType() {
9
+ return `'localStorage' | LDFlagSet`;
10
+ }
11
+ }
12
+ const validators = {
13
+ logger: js_sdk_common_1.TypeValidators.Object,
14
+ baseUri: js_sdk_common_1.TypeValidators.String,
15
+ streamUri: js_sdk_common_1.TypeValidators.String,
16
+ eventsUri: js_sdk_common_1.TypeValidators.String,
17
+ capacity: js_sdk_common_1.TypeValidators.numberWithMin(1),
18
+ diagnosticRecordingInterval: js_sdk_common_1.TypeValidators.numberWithMin(2),
19
+ flushInterval: js_sdk_common_1.TypeValidators.numberWithMin(2),
20
+ streamInitialReconnectDelay: js_sdk_common_1.TypeValidators.numberWithMin(0),
21
+ allAttributesPrivate: js_sdk_common_1.TypeValidators.Boolean,
22
+ diagnosticOptOut: js_sdk_common_1.TypeValidators.Boolean,
23
+ withReasons: js_sdk_common_1.TypeValidators.Boolean,
24
+ sendEvents: js_sdk_common_1.TypeValidators.Boolean,
25
+ inspectors: js_sdk_common_1.TypeValidators.createTypeArray('LDInspection[]', {
26
+ type: 'flag-used',
27
+ method: js_sdk_common_1.noop,
28
+ name: '',
29
+ }),
30
+ privateAttributes: js_sdk_common_1.TypeValidators.StringArray,
31
+ application: js_sdk_common_1.TypeValidators.Object,
32
+ bootstrap: new BootStrapValidator(),
33
+ wrapperName: js_sdk_common_1.TypeValidators.String,
34
+ wrapperVersion: js_sdk_common_1.TypeValidators.String,
35
+ hash: js_sdk_common_1.TypeValidators.String,
36
+ };
37
+ exports.default = validators;
38
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/configuration/validators.ts"],"names":[],"mappings":";;AAAA,+DAAkF;AAKlF,MAAM,kBAAkB;IAC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osticsInitConfig = {
3
+ customBaseURI: boolean;
4
+ customStreamURI: boolean;
5
+ customEventsURI: boolean;
6
+ eventsCapacity: number;
7
+ eventsFlushIntervalMillis: number;
8
+ reconnectTimeMillis: number;
9
+ diagnosticRecordingIntervalMillis: number;
10
+ allAttributesPrivate: boolean;
11
+ usingSecureMode: boolean;
12
+ bootstrapMode: boolean;
13
+ };
14
+ declare const createDiagnosticsInitConfig: (config: Configuration) => DiagnosticsInitConfig;
15
+ export default createDiagnosticsInitConfig;
16
+ //# sourceMappingURL=createDiagnosticsInitConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDiagnosticsInitConfig.d.ts","sourceRoot":"","sources":["../../src/diagnostics/createDiagnosticsInitConfig.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,MAAM,qBAAqB,GAAG;IAElC,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB,EAAE,MAAM,CAAC;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iCAAiC,EAAE,MAAM,CAAC;IAC1C,oBAAoB,EAAE,OAAO,CAAC;IAG9B,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AACF,QAAA,MAAM,2BAA2B,WAAY,aAAa,KAAG,qBAW3D,CAAC;AAEH,eAAe,2BAA2B,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
4
+ const configuration_1 = require("../configuration");
5
+ const createDiagnosticsInitConfig = (config) => ({
6
+ customBaseURI: config.baseUri !== configuration_1.default.DEFAULT_POLLING,
7
+ customStreamURI: config.streamUri !== configuration_1.default.DEFAULT_STREAM,
8
+ customEventsURI: config.eventsUri !== js_sdk_common_1.ServiceEndpoints.DEFAULT_EVENTS,
9
+ eventsCapacity: config.capacity,
10
+ eventsFlushIntervalMillis: (0, js_sdk_common_1.secondsToMillis)(config.flushInterval),
11
+ reconnectTimeMillis: (0, js_sdk_common_1.secondsToMillis)(config.streamInitialReconnectDelay),
12
+ diagnosticRecordingIntervalMillis: (0, js_sdk_common_1.secondsToMillis)(config.diagnosticRecordingInterval),
13
+ allAttributesPrivate: config.allAttributesPrivate,
14
+ usingSecureMode: !!config.hash,
15
+ bootstrapMode: !!config.bootstrap,
16
+ });
17
+ exports.default = createDiagnosticsInitConfig;
18
+ //# sourceMappingURL=createDiagnosticsInitConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDiagnosticsInitConfig.js","sourceRoot":"","sources":["../../src/diagnostics/createDiagnosticsInitConfig.ts"],"names":[],"mappings":";;AAAA,+DAAgF;AAEhF,oDAA6C;AAiB7C,MAAM,2BAA2B,GAAG,CAAC,MAAqB,EAAyB,EAAE,CAAC,CAAC;IACrF,aAAa,EAAE,MAAM,CAAC,OAAO,KAAK,uBAAa,CAAC,eAAe;IAC/D,eAAe,EAAE,MAAM,CAAC,SAAS,KAAK,uBAAa,CAAC,cAAc;IAClE,eAAe,EAAE,MAAM,CAAC,SAAS,KAAK,gCAAgB,CAAC,cAAc;IACrE,cAAc,EAAE,MAAM,CAAC,QAAQ;IAC/B,yBAAyB,EAAE,IAAA,+BAAe,EAAC,MAAM,CAAC,aAAa,CAAC;IAChE,mBAAmB,EAAE,IAAA,+BAAe,EAAC,MAAM,CAAC,2BAA2B,CAAC;IACxE,iCAAiC,EAAE,IAAA,+BAAe,EAAC,MAAM,CAAC,2BAA2B,CAAC;IACtF,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;IACjD,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI;IAC9B,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS;CAClC,CAAC,CAAC;AAEH,kBAAe,2BAA2B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { internal, Platform } from '@launchdarkly/js-sdk-common';
2
+ import Configuration from '../configuration';
3
+ declare const createDiagnosticsManager: (clientSideID: string, config: Configuration, platform: Platform) => internal.DiagnosticsManager | undefined;
4
+ export default createDiagnosticsManager;
5
+ //# sourceMappingURL=createDiagnosticsManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDiagnosticsManager.d.ts","sourceRoot":"","sources":["../../src/diagnostics/createDiagnosticsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAG7C,QAAA,MAAM,wBAAwB,iBACd,MAAM,UACZ,aAAa,YACX,QAAQ,4CAWnB,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
4
+ const createDiagnosticsInitConfig_1 = require("./createDiagnosticsInitConfig");
5
+ const createDiagnosticsManager = (clientSideID, config, platform) => {
6
+ if (config.sendEvents && !config.diagnosticOptOut) {
7
+ return new js_sdk_common_1.internal.DiagnosticsManager(clientSideID, platform, (0, createDiagnosticsInitConfig_1.default)(config));
8
+ }
9
+ return undefined;
10
+ };
11
+ exports.default = createDiagnosticsManager;
12
+ //# sourceMappingURL=createDiagnosticsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDiagnosticsManager.js","sourceRoot":"","sources":["../../src/diagnostics/createDiagnosticsManager.ts"],"names":[],"mappings":";;AAAA,+DAAiE;AAGjE,+EAAwE;AAExE,MAAM,wBAAwB,GAAG,CAC/B,YAAoB,EACpB,MAAqB,EACrB,QAAkB,EAClB,EAAE;IACF,IAAI,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;QACjD,OAAO,IAAI,wBAAQ,CAAC,kBAAkB,CACpC,YAAY,EACZ,QAAQ,EACR,IAAA,qCAA2B,EAAC,MAAM,CAAC,CACpC,CAAC;KACH;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { LDContext, Platform } from '@launchdarkly/js-sdk-common';
2
+ import Configuration from '../configuration';
3
+ import { Flags } from '../types';
4
+ declare const fetchFlags: (sdkKey: string, context: LDContext, config: Configuration, { encoding, info, requests }: Platform) => Promise<Flags>;
5
+ export default fetchFlags;
6
+ //# sourceMappingURL=fetchFlags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchFlags.d.ts","sourceRoot":"","sources":["../../src/evaluation/fetchFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,QAAA,MAAM,UAAU,WACN,MAAM,WACL,SAAS,UACV,aAAa,gCACS,QAAQ,KACrC,QAAQ,KAAK,CAOf,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fetchUtils_1 = require("./fetchUtils");
4
+ const fetchFlags = async (sdkKey, context, config, { encoding, info, requests }) => {
5
+ const fetchUrl = (0, fetchUtils_1.createFetchUrl)(sdkKey, context, config, encoding);
6
+ const fetchOptions = (0, fetchUtils_1.createFetchOptions)(sdkKey, context, config, info);
7
+ // TODO: add error handling, retry and timeout
8
+ const response = await requests.fetch(fetchUrl, fetchOptions);
9
+ return response.json();
10
+ };
11
+ exports.default = fetchFlags;
12
+ //# sourceMappingURL=fetchFlags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchFlags.js","sourceRoot":"","sources":["../../src/evaluation/fetchFlags.ts"],"names":[],"mappings":";;AAIA,6CAAkE;AAElE,MAAM,UAAU,GAAG,KAAK,EACtB,MAAc,EACd,OAAkB,EAClB,MAAqB,EACrB,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAY,EACtB,EAAE;IAClB,MAAM,QAAQ,GAAG,IAAA,2BAAc,EAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAS,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,IAAA,+BAAkB,EAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEvE,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAC9D,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Encoding, Info, LDContext, Options } from '@launchdarkly/js-sdk-common';
2
+ import Configuration from '../configuration';
3
+ export declare const createFetchPath: (sdkKey: string, context: LDContext, baseUrlPolling: string, useReport: boolean, encoding: Encoding) => string;
4
+ export declare const createQueryString: (hash: string | undefined, withReasons: boolean) => string;
5
+ export declare const createFetchUrl: (sdkKey: string, context: LDContext, config: Configuration, encoding: Encoding) => string;
6
+ export declare const createFetchOptions: (sdkKey: string, context: LDContext, config: Configuration, info: Info) => Options;
7
+ //# sourceMappingURL=fetchUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchUtils.d.ts","sourceRoot":"","sources":["../../src/evaluation/fetchUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,OAAO,EACR,MAAM,6BAA6B,CAAC;AAErC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,eAAO,MAAM,eAAe,WAClB,MAAM,WACL,SAAS,kBACF,MAAM,aACX,OAAO,YACR,QAAQ,WAOX,CAAC;AAEV,eAAO,MAAM,iBAAiB,SAAU,MAAM,GAAG,SAAS,eAAe,OAAO,WAc/E,CAAC;AAEF,eAAO,MAAM,cAAc,WACjB,MAAM,WACL,SAAS,UACV,aAAa,YACX,QAAQ,WAYnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,WACrB,MAAM,WACL,SAAS,UACV,aAAa,QACf,IAAI,KACT,OAgBF,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFetchOptions = exports.createFetchUrl = exports.createQueryString = exports.createFetchPath = void 0;
4
+ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
5
+ const createFetchPath = (sdkKey, context, baseUrlPolling, useReport, encoding) => useReport
6
+ ? `${baseUrlPolling}/sdk/evalx/${sdkKey}/context`
7
+ : `${baseUrlPolling}/sdk/evalx/${sdkKey}/contexts/${(0, js_sdk_common_1.base64UrlEncode)(JSON.stringify(context), encoding)}`;
8
+ exports.createFetchPath = createFetchPath;
9
+ const createQueryString = (hash, withReasons) => {
10
+ const qs = {
11
+ h: hash,
12
+ withReasons,
13
+ };
14
+ const qsArray = [];
15
+ Object.entries(qs).forEach(([key, value]) => {
16
+ if (value) {
17
+ qsArray.push(`${key}=${value}`);
18
+ }
19
+ });
20
+ return qsArray.join('&');
21
+ };
22
+ exports.createQueryString = createQueryString;
23
+ const createFetchUrl = (sdkKey, context, config, encoding) => {
24
+ const { withReasons, hash, serviceEndpoints: { polling }, useReport, } = config;
25
+ const path = (0, exports.createFetchPath)(sdkKey, context, polling, useReport, encoding);
26
+ const qs = (0, exports.createQueryString)(hash, withReasons);
27
+ return qs ? `${path}?${qs}` : path;
28
+ };
29
+ exports.createFetchUrl = createFetchUrl;
30
+ const createFetchOptions = (sdkKey, context, config, info) => {
31
+ const { useReport, tags } = config;
32
+ const headers = (0, js_sdk_common_1.defaultHeaders)(sdkKey, info, tags);
33
+ if (useReport) {
34
+ return {
35
+ method: 'REPORT',
36
+ headers: Object.assign(Object.assign({}, headers), { 'content-type': 'application/json' }),
37
+ body: JSON.stringify(context),
38
+ };
39
+ }
40
+ return {
41
+ method: 'GET',
42
+ headers,
43
+ };
44
+ };
45
+ exports.createFetchOptions = createFetchOptions;
46
+ //# sourceMappingURL=fetchUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchUtils.js","sourceRoot":"","sources":["../../src/evaluation/fetchUtils.ts"],"names":[],"mappings":";;;AAAA,+DAOqC;AAI9B,MAAM,eAAe,GAAG,CAC7B,MAAc,EACd,OAAkB,EAClB,cAAsB,EACtB,SAAkB,EAClB,QAAkB,EAClB,EAAE,CACF,SAAS;IACP,CAAC,CAAC,GAAG,cAAc,cAAc,MAAM,UAAU;IACjD,CAAC,CAAC,GAAG,cAAc,cAAc,MAAM,aAAa,IAAA,+BAAe,EAC/D,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EACvB,QAAQ,CACT,EAAE,CAAC;AAZG,QAAA,eAAe,mBAYlB;AAEH,MAAM,iBAAiB,GAAG,CAAC,IAAwB,EAAE,WAAoB,EAAE,EAAE;IAClF,MAAM,EAAE,GAAG;QACT,CAAC,EAAE,IAAI;QACP,WAAW;KACZ,CAAC;IAEF,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC1C,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC;SACjC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC;AAdW,QAAA,iBAAiB,qBAc5B;AAEK,MAAM,cAAc,GAAG,CAC5B,MAAc,EACd,OAAkB,EAClB,MAAqB,EACrB,QAAkB,EAClB,EAAE;IACF,MAAM,EACJ,WAAW,EACX,IAAI,EACJ,gBAAgB,EAAE,EAAE,OAAO,EAAE,EAC7B,SAAS,GACV,GAAG,MAAM,CAAC;IACX,MAAM,IAAI,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5E,MAAM,EAAE,GAAG,IAAA,yBAAiB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEhD,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB;AAEK,MAAM,kBAAkB,GAAG,CAChC,MAAc,EACd,OAAkB,EAClB,MAAqB,EACrB,IAAU,EACD,EAAE;IACX,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACnC,MAAM,OAAO,GAAG,IAAA,8BAAc,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAEnD,IAAI,SAAS,EAAE;QACb,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,OAAO,kCAAO,OAAO,KAAE,cAAc,EAAE,kBAAkB,GAAE;YAC3D,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CAAC;KACH;IAED,OAAO;QACL,MAAM,EAAE,KAAK;QACb,OAAO;KACR,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EventFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventFactory.d.ts","sourceRoot":"","sources":["../../src/events/EventFactory.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const js_sdk_common_1 = require("@launchdarkly/js-sdk-common");
4
+ /**
5
+ * @internal
6
+ */
7
+ class EventFactory extends js_sdk_common_1.internal.EventFactoryBase {
8
+ evalEventClient(flagKey, value, defaultVal, flag, context, reason) {
9
+ const { trackEvents, debugEventsUntilDate, trackReason, version, variation } = flag;
10
+ return super.evalEvent({
11
+ addExperimentData: trackReason,
12
+ context,
13
+ debugEventsUntilDate,
14
+ defaultVal,
15
+ flagKey,
16
+ reason,
17
+ trackEvents,
18
+ value,
19
+ variation,
20
+ version,
21
+ });
22
+ }
23
+ }
24
+ exports.default = EventFactory;
25
+ //# sourceMappingURL=EventFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventFactory.js","sourceRoot":"","sources":["../../src/events/EventFactory.ts"],"names":[],"mappings":";;AAAA,+DAAiG;AAIjG;;GAEG;AACH,MAAqB,YAAa,SAAQ,wBAAQ,CAAC,gBAAgB;IACjE,eAAe,CACb,OAAe,EACf,KAAkB,EAClB,UAAe,EACf,IAAU,EACV,OAAgB,EAChB,MAA2B;QAE3B,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAEpF,OAAO,KAAK,CAAC,SAAS,CAAC;YACrB,iBAAiB,EAAE,WAAW;YAC9B,OAAO;YACP,oBAAoB;YACpB,UAAU;YACV,OAAO;YACP,MAAM;YACN,WAAW;YACX,KAAK;YACL,SAAS;YACT,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AAxBD,+BAwBC"}
@@ -0,0 +1,5 @@
1
+ import { internal, Platform, subsystem } from '@launchdarkly/js-sdk-common';
2
+ import Configuration from '../configuration';
3
+ declare const createEventProcessor: (clientSideID: string, config: Configuration, platform: Platform, diagnosticsManager?: internal.DiagnosticsManager) => subsystem.LDEventProcessor;
4
+ export default createEventProcessor;
5
+ //# sourceMappingURL=createEventProcessor.d.ts.map