@launchdarkly/js-sdk-common 0.1.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 (227) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +25 -0
  3. package/dist/AttributeReference.d.ts +35 -0
  4. package/dist/AttributeReference.d.ts.map +1 -0
  5. package/dist/AttributeReference.js +126 -0
  6. package/dist/AttributeReference.js.map +1 -0
  7. package/dist/Context.d.ts +90 -0
  8. package/dist/Context.d.ts.map +1 -0
  9. package/dist/Context.js +385 -0
  10. package/dist/Context.js.map +1 -0
  11. package/dist/ContextFilter.d.ts +11 -0
  12. package/dist/ContextFilter.d.ts.map +1 -0
  13. package/dist/ContextFilter.js +122 -0
  14. package/dist/ContextFilter.js.map +1 -0
  15. package/dist/api/context/LDContext.d.ts +8 -0
  16. package/dist/api/context/LDContext.d.ts.map +1 -0
  17. package/dist/api/context/LDContext.js +3 -0
  18. package/dist/api/context/LDContext.js.map +1 -0
  19. package/dist/api/context/LDContextCommon.d.ts +29 -0
  20. package/dist/api/context/LDContextCommon.d.ts.map +1 -0
  21. package/dist/api/context/LDContextCommon.js +3 -0
  22. package/dist/api/context/LDContextCommon.js.map +1 -0
  23. package/dist/api/context/LDContextMeta.d.ts +52 -0
  24. package/dist/api/context/LDContextMeta.d.ts.map +1 -0
  25. package/dist/api/context/LDContextMeta.js +3 -0
  26. package/dist/api/context/LDContextMeta.js.map +1 -0
  27. package/dist/api/context/LDMultiKindContext.d.ts +46 -0
  28. package/dist/api/context/LDMultiKindContext.d.ts.map +1 -0
  29. package/dist/api/context/LDMultiKindContext.js +3 -0
  30. package/dist/api/context/LDMultiKindContext.js.map +1 -0
  31. package/dist/api/context/LDSingleKindContext.d.ts +24 -0
  32. package/dist/api/context/LDSingleKindContext.d.ts.map +1 -0
  33. package/dist/api/context/LDSingleKindContext.js +3 -0
  34. package/dist/api/context/LDSingleKindContext.js.map +1 -0
  35. package/dist/api/context/LDUser.d.ts +66 -0
  36. package/dist/api/context/LDUser.d.ts.map +1 -0
  37. package/dist/api/context/LDUser.js +3 -0
  38. package/dist/api/context/LDUser.js.map +1 -0
  39. package/dist/api/context/index.d.ts +7 -0
  40. package/dist/api/context/index.d.ts.map +1 -0
  41. package/dist/api/context/index.js +23 -0
  42. package/dist/api/context/index.js.map +1 -0
  43. package/dist/api/data/LDEvaluationDetail.d.ts +27 -0
  44. package/dist/api/data/LDEvaluationDetail.d.ts.map +1 -0
  45. package/dist/api/data/LDEvaluationDetail.js +3 -0
  46. package/dist/api/data/LDEvaluationDetail.js.map +1 -0
  47. package/dist/api/data/LDEvaluationReason.d.ts +57 -0
  48. package/dist/api/data/LDEvaluationReason.d.ts.map +1 -0
  49. package/dist/api/data/LDEvaluationReason.js +3 -0
  50. package/dist/api/data/LDEvaluationReason.js.map +1 -0
  51. package/dist/api/data/LDFlagSet.d.ts +8 -0
  52. package/dist/api/data/LDFlagSet.d.ts.map +1 -0
  53. package/dist/api/data/LDFlagSet.js +3 -0
  54. package/dist/api/data/LDFlagSet.js.map +1 -0
  55. package/dist/api/data/LDFlagValue.d.ts +7 -0
  56. package/dist/api/data/LDFlagValue.d.ts.map +1 -0
  57. package/dist/api/data/LDFlagValue.js +3 -0
  58. package/dist/api/data/LDFlagValue.js.map +1 -0
  59. package/dist/api/data/index.d.ts +5 -0
  60. package/dist/api/data/index.d.ts.map +1 -0
  61. package/dist/api/data/index.js +21 -0
  62. package/dist/api/data/index.js.map +1 -0
  63. package/dist/api/index.d.ts +7 -0
  64. package/dist/api/index.d.ts.map +1 -0
  65. package/dist/api/index.js +24 -0
  66. package/dist/api/index.js.map +1 -0
  67. package/dist/api/logging/BasicLoggerOptions.d.ts +43 -0
  68. package/dist/api/logging/BasicLoggerOptions.d.ts.map +1 -0
  69. package/dist/api/logging/BasicLoggerOptions.js +3 -0
  70. package/dist/api/logging/BasicLoggerOptions.js.map +1 -0
  71. package/dist/api/logging/LDLogLevel.d.ts +10 -0
  72. package/dist/api/logging/LDLogLevel.d.ts.map +1 -0
  73. package/dist/api/logging/LDLogLevel.js +3 -0
  74. package/dist/api/logging/LDLogLevel.js.map +1 -0
  75. package/dist/api/logging/LDLogger.d.ts +47 -0
  76. package/dist/api/logging/LDLogger.d.ts.map +1 -0
  77. package/dist/api/logging/LDLogger.js +3 -0
  78. package/dist/api/logging/LDLogger.js.map +1 -0
  79. package/dist/api/logging/index.d.ts +4 -0
  80. package/dist/api/logging/index.d.ts.map +1 -0
  81. package/dist/api/logging/index.js +20 -0
  82. package/dist/api/logging/index.js.map +1 -0
  83. package/dist/api/options/LDClientContext.d.ts +43 -0
  84. package/dist/api/options/LDClientContext.d.ts.map +1 -0
  85. package/dist/api/options/LDClientContext.js +3 -0
  86. package/dist/api/options/LDClientContext.js.map +1 -0
  87. package/dist/api/options/index.d.ts +3 -0
  88. package/dist/api/options/index.d.ts.map +1 -0
  89. package/dist/api/options/index.js +3 -0
  90. package/dist/api/options/index.js.map +1 -0
  91. package/dist/api/platform/Crypto.d.ts +31 -0
  92. package/dist/api/platform/Crypto.d.ts.map +1 -0
  93. package/dist/api/platform/Crypto.js +3 -0
  94. package/dist/api/platform/Crypto.js.map +1 -0
  95. package/dist/api/platform/EventSource.d.ts +25 -0
  96. package/dist/api/platform/EventSource.d.ts.map +1 -0
  97. package/dist/api/platform/EventSource.js +3 -0
  98. package/dist/api/platform/EventSource.js.map +1 -0
  99. package/dist/api/platform/Filesystem.d.ts +40 -0
  100. package/dist/api/platform/Filesystem.d.ts.map +1 -0
  101. package/dist/api/platform/Filesystem.js +3 -0
  102. package/dist/api/platform/Filesystem.js.map +1 -0
  103. package/dist/api/platform/Info.d.ts +64 -0
  104. package/dist/api/platform/Info.d.ts.map +1 -0
  105. package/dist/api/platform/Info.js +3 -0
  106. package/dist/api/platform/Info.js.map +1 -0
  107. package/dist/api/platform/Platform.d.ts +25 -0
  108. package/dist/api/platform/Platform.d.ts.map +1 -0
  109. package/dist/api/platform/Platform.js +3 -0
  110. package/dist/api/platform/Platform.js.map +1 -0
  111. package/dist/api/platform/Requests.d.ts +75 -0
  112. package/dist/api/platform/Requests.d.ts.map +1 -0
  113. package/dist/api/platform/Requests.js +6 -0
  114. package/dist/api/platform/Requests.js.map +1 -0
  115. package/dist/api/platform/index.d.ts +7 -0
  116. package/dist/api/platform/index.d.ts.map +1 -0
  117. package/dist/api/platform/index.js +23 -0
  118. package/dist/api/platform/index.js.map +1 -0
  119. package/dist/api/subsystem/LDContextDeduplicator.d.ts +24 -0
  120. package/dist/api/subsystem/LDContextDeduplicator.d.ts.map +1 -0
  121. package/dist/api/subsystem/LDContextDeduplicator.js +3 -0
  122. package/dist/api/subsystem/LDContextDeduplicator.js.map +1 -0
  123. package/dist/api/subsystem/LDEventProcessor.d.ts +7 -0
  124. package/dist/api/subsystem/LDEventProcessor.d.ts.map +1 -0
  125. package/dist/api/subsystem/LDEventProcessor.js +3 -0
  126. package/dist/api/subsystem/LDEventProcessor.js.map +1 -0
  127. package/dist/api/subsystem/LDEventSender.d.ts +18 -0
  128. package/dist/api/subsystem/LDEventSender.d.ts.map +1 -0
  129. package/dist/api/subsystem/LDEventSender.js +15 -0
  130. package/dist/api/subsystem/LDEventSender.js.map +1 -0
  131. package/dist/api/subsystem/index.d.ts +5 -0
  132. package/dist/api/subsystem/index.d.ts.map +1 -0
  133. package/dist/api/subsystem/index.js +7 -0
  134. package/dist/api/subsystem/index.js.map +1 -0
  135. package/dist/index.d.ts +10 -0
  136. package/dist/index.d.ts.map +1 -0
  137. package/dist/index.js +29 -0
  138. package/dist/index.js.map +1 -0
  139. package/dist/internal/events/EventProcessor.d.ts +51 -0
  140. package/dist/internal/events/EventProcessor.d.ts.map +1 -0
  141. package/dist/internal/events/EventProcessor.js +214 -0
  142. package/dist/internal/events/EventProcessor.js.map +1 -0
  143. package/dist/internal/events/EventSummarizer.d.ts +2 -0
  144. package/dist/internal/events/EventSummarizer.d.ts.map +1 -0
  145. package/dist/internal/events/EventSummarizer.js +84 -0
  146. package/dist/internal/events/EventSummarizer.js.map +1 -0
  147. package/dist/internal/events/InputCustomEvent.d.ts +11 -0
  148. package/dist/internal/events/InputCustomEvent.d.ts.map +1 -0
  149. package/dist/internal/events/InputCustomEvent.js +14 -0
  150. package/dist/internal/events/InputCustomEvent.js.map +1 -0
  151. package/dist/internal/events/InputEvalEvent.d.ts +19 -0
  152. package/dist/internal/events/InputEvalEvent.d.ts.map +1 -0
  153. package/dist/internal/events/InputEvalEvent.js +35 -0
  154. package/dist/internal/events/InputEvalEvent.js.map +1 -0
  155. package/dist/internal/events/InputEvent.d.ts +6 -0
  156. package/dist/internal/events/InputEvent.d.ts.map +1 -0
  157. package/dist/internal/events/InputEvent.js +3 -0
  158. package/dist/internal/events/InputEvent.js.map +1 -0
  159. package/dist/internal/events/InputEventBase.d.ts +8 -0
  160. package/dist/internal/events/InputEventBase.d.ts.map +1 -0
  161. package/dist/internal/events/InputEventBase.js +11 -0
  162. package/dist/internal/events/InputEventBase.js.map +1 -0
  163. package/dist/internal/events/InputIdentifyEvent.d.ts +8 -0
  164. package/dist/internal/events/InputIdentifyEvent.d.ts.map +1 -0
  165. package/dist/internal/events/InputIdentifyEvent.js +11 -0
  166. package/dist/internal/events/InputIdentifyEvent.js.map +1 -0
  167. package/dist/internal/events/LDInvalidSDKKeyError.d.ts +4 -0
  168. package/dist/internal/events/LDInvalidSDKKeyError.d.ts.map +1 -0
  169. package/dist/internal/events/LDInvalidSDKKeyError.js +10 -0
  170. package/dist/internal/events/LDInvalidSDKKeyError.js.map +1 -0
  171. package/dist/internal/events/SummaryCounter.d.ts +2 -0
  172. package/dist/internal/events/SummaryCounter.d.ts.map +1 -0
  173. package/dist/internal/events/SummaryCounter.js +20 -0
  174. package/dist/internal/events/SummaryCounter.js.map +1 -0
  175. package/dist/internal/events/guards.d.ts +7 -0
  176. package/dist/internal/events/guards.d.ts.map +1 -0
  177. package/dist/internal/events/guards.js +16 -0
  178. package/dist/internal/events/guards.js.map +1 -0
  179. package/dist/internal/events/index.d.ts +7 -0
  180. package/dist/internal/events/index.d.ts.map +1 -0
  181. package/dist/internal/events/index.js +12 -0
  182. package/dist/internal/events/index.js.map +1 -0
  183. package/dist/internal/index.d.ts +2 -0
  184. package/dist/internal/index.d.ts.map +1 -0
  185. package/dist/internal/index.js +18 -0
  186. package/dist/internal/index.js.map +1 -0
  187. package/dist/logging/BasicLogger.d.ts +27 -0
  188. package/dist/logging/BasicLogger.d.ts.map +1 -0
  189. package/dist/logging/BasicLogger.js +89 -0
  190. package/dist/logging/BasicLogger.js.map +1 -0
  191. package/dist/logging/SafeLogger.d.ts +28 -0
  192. package/dist/logging/SafeLogger.d.ts.map +1 -0
  193. package/dist/logging/SafeLogger.js +63 -0
  194. package/dist/logging/SafeLogger.js.map +1 -0
  195. package/dist/logging/format.d.ts +2 -0
  196. package/dist/logging/format.d.ts.map +1 -0
  197. package/dist/logging/format.js +156 -0
  198. package/dist/logging/format.js.map +1 -0
  199. package/dist/logging/index.d.ts +4 -0
  200. package/dist/logging/index.d.ts.map +1 -0
  201. package/dist/logging/index.js +8 -0
  202. package/dist/logging/index.js.map +1 -0
  203. package/dist/options/ApplicationTags.d.ts +15 -0
  204. package/dist/options/ApplicationTags.d.ts.map +1 -0
  205. package/dist/options/ApplicationTags.js +57 -0
  206. package/dist/options/ApplicationTags.js.map +1 -0
  207. package/dist/options/ClientContext.d.ts +36 -0
  208. package/dist/options/ClientContext.d.ts.map +1 -0
  209. package/dist/options/ClientContext.js +19 -0
  210. package/dist/options/ClientContext.js.map +1 -0
  211. package/dist/options/OptionMessages.d.ts +14 -0
  212. package/dist/options/OptionMessages.d.ts.map +1 -0
  213. package/dist/options/OptionMessages.js +33 -0
  214. package/dist/options/OptionMessages.js.map +1 -0
  215. package/dist/options/ServiceEndpoints.d.ts +10 -0
  216. package/dist/options/ServiceEndpoints.d.ts.map +1 -0
  217. package/dist/options/ServiceEndpoints.js +17 -0
  218. package/dist/options/ServiceEndpoints.js.map +1 -0
  219. package/dist/options/index.d.ts +6 -0
  220. package/dist/options/index.d.ts.map +1 -0
  221. package/dist/options/index.js +12 -0
  222. package/dist/options/index.js.map +1 -0
  223. package/dist/validators.d.ts +84 -0
  224. package/dist/validators.d.ts.map +1 -0
  225. package/dist/validators.js +149 -0
  226. package/dist/validators.js.map +1 -0
  227. package/package.json +40 -0
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * @internal
5
+ */
6
+ class SummaryCounter {
7
+ constructor(count, key, value, defValue, version, variation) {
8
+ this.count = count;
9
+ this.key = key;
10
+ this.value = value;
11
+ this.version = version;
12
+ this.variation = variation;
13
+ this.default = defValue;
14
+ }
15
+ increment() {
16
+ this.count += 1;
17
+ }
18
+ }
19
+ exports.default = SummaryCounter;
20
+ //# sourceMappingURL=SummaryCounter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SummaryCounter.js","sourceRoot":"","sources":["../../../src/internal/events/SummaryCounter.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAqB,cAAc;IAGjC,YACS,KAAa,EACb,GAAW,EACX,KAAU,EACjB,QAAa,EACN,OAAgB,EAChB,SAAkB;QALlB,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAK;QAEV,YAAO,GAAP,OAAO,CAAS;QAChB,cAAS,GAAT,SAAS,CAAS;QAEzB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAClB,CAAC;CACF;AAjBD,iCAiBC"}
@@ -0,0 +1,7 @@
1
+ import InputCustomEvent from './InputCustomEvent';
2
+ import InputEvalEvent from './InputEvalEvent';
3
+ import InputIdentifyEvent from './InputIdentifyEvent';
4
+ export declare function isFeature(u: any): u is InputEvalEvent;
5
+ export declare function isCustom(u: any): u is InputCustomEvent;
6
+ export declare function isIdentify(u: any): u is InputIdentifyEvent;
7
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../../src/internal/events/guards.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,cAAc,CAErD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,gBAAgB,CAEtD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,kBAAkB,CAE1D"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIdentify = exports.isCustom = exports.isFeature = void 0;
4
+ function isFeature(u) {
5
+ return u.kind === 'feature';
6
+ }
7
+ exports.isFeature = isFeature;
8
+ function isCustom(u) {
9
+ return u.kind === 'custom';
10
+ }
11
+ exports.isCustom = isCustom;
12
+ function isIdentify(u) {
13
+ return u.kind === 'identify';
14
+ }
15
+ exports.isIdentify = isIdentify;
16
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../src/internal/events/guards.ts"],"names":[],"mappings":";;;AAIA,SAAgB,SAAS,CAAC,CAAM;IAC9B,OAAO,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;AAC9B,CAAC;AAFD,8BAEC;AAED,SAAgB,QAAQ,CAAC,CAAM;IAC7B,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC7B,CAAC;AAFD,4BAEC;AAED,SAAgB,UAAU,CAAC,CAAM;IAC/B,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;AAC/B,CAAC;AAFD,gCAEC"}
@@ -0,0 +1,7 @@
1
+ import InputCustomEvent from './InputCustomEvent';
2
+ import InputEvalEvent from './InputEvalEvent';
3
+ import InputEvent from './InputEvent';
4
+ import InputIdentifyEvent from './InputIdentifyEvent';
5
+ import EventProcessor from './EventProcessor';
6
+ export { InputCustomEvent, InputEvalEvent, InputEvent, InputIdentifyEvent, EventProcessor };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventProcessor = exports.InputIdentifyEvent = exports.InputEvalEvent = exports.InputCustomEvent = void 0;
4
+ const InputCustomEvent_1 = require("./InputCustomEvent");
5
+ exports.InputCustomEvent = InputCustomEvent_1.default;
6
+ const InputEvalEvent_1 = require("./InputEvalEvent");
7
+ exports.InputEvalEvent = InputEvalEvent_1.default;
8
+ const InputIdentifyEvent_1 = require("./InputIdentifyEvent");
9
+ exports.InputIdentifyEvent = InputIdentifyEvent_1.default;
10
+ const EventProcessor_1 = require("./EventProcessor");
11
+ exports.EventProcessor = EventProcessor_1.default;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/events/index.ts"],"names":[],"mappings":";;;AAAA,yDAAkD;AAMzC,2BANF,0BAAgB,CAME;AALzB,qDAA8C;AAKnB,yBALpB,wBAAc,CAKoB;AAHzC,6DAAsD;AAGC,6BAHhD,4BAAkB,CAGgD;AAFzE,qDAA8C;AAE6B,yBAFpE,wBAAc,CAEoE"}
@@ -0,0 +1,2 @@
1
+ export * from './events';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,18 @@
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("./events"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
@@ -0,0 +1,27 @@
1
+ import { BasicLoggerOptions, LDLogger } from '../api';
2
+ /**
3
+ * A basic logger which handles filtering by level.
4
+ *
5
+ * With the default options it will write to `console.error`
6
+ * and it will use the formatting provided by `console.error`.
7
+ * If the destination is overwritten, then it will use an included
8
+ * formatter similar to `util.format`.
9
+ *
10
+ * If a formatter is available, then that should be overridden
11
+ * as well for performance.
12
+ */
13
+ export default class BasicLogger implements LDLogger {
14
+ private logLevel;
15
+ private name;
16
+ private destination?;
17
+ private formatter?;
18
+ constructor(options: BasicLoggerOptions);
19
+ private tryFormat;
20
+ private tryWrite;
21
+ private log;
22
+ error(...args: any[]): void;
23
+ warn(...args: any[]): void;
24
+ info(...args: any[]): void;
25
+ debug(...args: any[]): void;
26
+ }
27
+ //# sourceMappingURL=BasicLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicLogger.d.ts","sourceRoot":"","sources":["../../src/logging/BasicLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAatD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,YAAW,QAAQ;IAClD,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,IAAI,CAAS;IAErB,OAAO,CAAC,WAAW,CAAC,CAAyB;IAE7C,OAAO,CAAC,SAAS,CAAC,CAA6B;gBAEnC,OAAO,EAAE,kBAAkB;IAQvC,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,GAAG;IAoBX,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAG5B"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const format_1 = require("./format");
4
+ const LogPriority = {
5
+ debug: 0,
6
+ info: 1,
7
+ warn: 2,
8
+ error: 3,
9
+ none: 4,
10
+ };
11
+ const LevelNames = ['debug', 'info', 'warn', 'error', 'none'];
12
+ /**
13
+ * A basic logger which handles filtering by level.
14
+ *
15
+ * With the default options it will write to `console.error`
16
+ * and it will use the formatting provided by `console.error`.
17
+ * If the destination is overwritten, then it will use an included
18
+ * formatter similar to `util.format`.
19
+ *
20
+ * If a formatter is available, then that should be overridden
21
+ * as well for performance.
22
+ */
23
+ class BasicLogger {
24
+ constructor(options) {
25
+ var _a, _b, _c;
26
+ this.logLevel = (_b = LogPriority[(_a = options.level) !== null && _a !== void 0 ? _a : 'info']) !== null && _b !== void 0 ? _b : LogPriority.info;
27
+ this.name = (_c = options.name) !== null && _c !== void 0 ? _c : 'LaunchDarkly';
28
+ // eslint-disable-next-line no-console
29
+ this.destination = options.destination;
30
+ this.formatter = options.formatter;
31
+ }
32
+ tryFormat(...args) {
33
+ var _a;
34
+ try {
35
+ if (this.formatter) {
36
+ // In case the provided formatter fails.
37
+ return (_a = this.formatter) === null || _a === void 0 ? void 0 : _a.call(this, ...args);
38
+ }
39
+ return (0, format_1.default)(...args);
40
+ }
41
+ catch (_b) {
42
+ return (0, format_1.default)(...args);
43
+ }
44
+ }
45
+ tryWrite(msg) {
46
+ try {
47
+ this.destination(msg);
48
+ }
49
+ catch (_a) {
50
+ // eslint-disable-next-line no-console
51
+ console.error(msg);
52
+ }
53
+ }
54
+ log(level, args) {
55
+ if (level >= this.logLevel) {
56
+ const prefix = `${LevelNames[level]}: [${this.name}]`;
57
+ try {
58
+ if (this.destination) {
59
+ this.tryWrite(this.tryFormat(prefix, ...args));
60
+ }
61
+ else {
62
+ // `console.error` has its own formatter.
63
+ // So we don't need to do anything.
64
+ // eslint-disable-next-line no-console
65
+ console.error(...args);
66
+ }
67
+ }
68
+ catch (_a) {
69
+ // If all else fails do not break.
70
+ // eslint-disable-next-line no-console
71
+ console.error(...args);
72
+ }
73
+ }
74
+ }
75
+ error(...args) {
76
+ this.log(LogPriority.error, args);
77
+ }
78
+ warn(...args) {
79
+ this.log(LogPriority.warn, args);
80
+ }
81
+ info(...args) {
82
+ this.log(LogPriority.info, args);
83
+ }
84
+ debug(...args) {
85
+ this.log(LogPriority.debug, args);
86
+ }
87
+ }
88
+ exports.default = BasicLogger;
89
+ //# sourceMappingURL=BasicLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicLogger.js","sourceRoot":"","sources":["../../src/logging/BasicLogger.ts"],"names":[],"mappings":";;AACA,qCAA8B;AAE9B,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAqB,WAAW;IAS9B,YAAY,OAA2B;;QACrC,IAAI,CAAC,QAAQ,GAAG,MAAA,WAAW,CAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,MAAM,CAAC,mCAAI,WAAW,CAAC,IAAI,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,cAAc,CAAC;QAC3C,sCAAsC;QACtC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACrC,CAAC;IAEO,SAAS,CAAC,GAAG,IAAW;;QAC9B,IAAI;YACF,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,wCAAwC;gBACxC,OAAO,MAAA,IAAI,CAAC,SAAS,qDAAG,GAAG,IAAI,CAAC,CAAC;aAClC;YACD,OAAO,IAAA,gBAAM,EAAC,GAAG,IAAI,CAAC,CAAC;SACxB;QAAC,WAAM;YACN,OAAO,IAAA,gBAAM,EAAC,GAAG,IAAI,CAAC,CAAC;SACxB;IACH,CAAC;IAEO,QAAQ,CAAC,GAAW;QAC1B,IAAI;YACF,IAAI,CAAC,WAAY,CAAC,GAAG,CAAC,CAAC;SACxB;QAAC,WAAM;YACN,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpB;IACH,CAAC;IAEO,GAAG,CAAC,KAAa,EAAE,IAAW;QACpC,IAAI,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC1B,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,GAAG,CAAC;YACtD,IAAI;gBACF,IAAI,IAAI,CAAC,WAAW,EAAE;oBACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;iBAChD;qBAAM;oBACL,yCAAyC;oBACzC,mCAAmC;oBACnC,sCAAsC;oBACtC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;iBACxB;aACF;YAAC,WAAM;gBACN,kCAAkC;gBAClC,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;aACxB;SACF;IACH,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAzED,8BAyEC"}
@@ -0,0 +1,28 @@
1
+ import { LDLogger } from '../api';
2
+ /**
3
+ * The safeLogger logic exists because we allow the application to pass in a custom logger, but
4
+ * there is no guarantee that the logger works correctly and if it ever throws exceptions there
5
+ * could be serious consequences (e.g. an uncaught exception within an error event handler, due
6
+ * to the SDK trying to log the error, can terminate the application). An exception could result
7
+ * from faulty logic in the logger implementation, or it could be that this is not a logger at
8
+ * all but some other kind of object; the former is handled by a catch block that logs an error
9
+ * message to the SDK's default logger, and we can at least partly guard against the latter by
10
+ * checking for the presence of required methods at configuration time.
11
+ */
12
+ export default class SafeLogger implements LDLogger {
13
+ private logger;
14
+ private fallback;
15
+ /**
16
+ * Construct a safe logger with the specified logger.
17
+ * @param logger The logger to use.
18
+ * @param fallback A fallback logger to use in case an issue is encountered using
19
+ * the provided logger.
20
+ */
21
+ constructor(logger: LDLogger, fallback: LDLogger);
22
+ private log;
23
+ error(...args: any[]): void;
24
+ warn(...args: any[]): void;
25
+ info(...args: any[]): void;
26
+ debug(...args: any[]): void;
27
+ }
28
+ //# sourceMappingURL=SafeLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeLogger.d.ts","sourceRoot":"","sources":["../../src/logging/SafeLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAUlC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,YAAW,QAAQ;IACjD,OAAO,CAAC,MAAM,CAAW;IAEzB,OAAO,CAAC,QAAQ,CAAW;IAE3B;;;;;OAKG;gBACS,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAchD,OAAO,CAAC,GAAG;IASX,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAG5B"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validators_1 = require("../validators");
4
+ const loggerRequirements = {
5
+ error: validators_1.TypeValidators.Function,
6
+ warn: validators_1.TypeValidators.Function,
7
+ info: validators_1.TypeValidators.Function,
8
+ debug: validators_1.TypeValidators.Function,
9
+ };
10
+ /**
11
+ * The safeLogger logic exists because we allow the application to pass in a custom logger, but
12
+ * there is no guarantee that the logger works correctly and if it ever throws exceptions there
13
+ * could be serious consequences (e.g. an uncaught exception within an error event handler, due
14
+ * to the SDK trying to log the error, can terminate the application). An exception could result
15
+ * from faulty logic in the logger implementation, or it could be that this is not a logger at
16
+ * all but some other kind of object; the former is handled by a catch block that logs an error
17
+ * message to the SDK's default logger, and we can at least partly guard against the latter by
18
+ * checking for the presence of required methods at configuration time.
19
+ */
20
+ class SafeLogger {
21
+ /**
22
+ * Construct a safe logger with the specified logger.
23
+ * @param logger The logger to use.
24
+ * @param fallback A fallback logger to use in case an issue is encountered using
25
+ * the provided logger.
26
+ */
27
+ constructor(logger, fallback) {
28
+ Object.entries(loggerRequirements).forEach(([level, validator]) => {
29
+ if (!validator.is(logger[level])) {
30
+ throw new Error(`Provided logger instance must support logger.${level}(...) method`);
31
+ // Note that the SDK normally does not throw exceptions to the application, but that rule
32
+ // does not apply to LDClient.init() which will throw an exception if the parameters are so
33
+ // invalid that we cannot proceed with creating the client. An invalid logger meets those
34
+ // criteria since the SDK calls the logger during nearly all of its operations.
35
+ }
36
+ });
37
+ this.logger = logger;
38
+ this.fallback = fallback;
39
+ }
40
+ log(level, args) {
41
+ try {
42
+ this.logger[level](...args);
43
+ }
44
+ catch (_a) {
45
+ // If all else fails do not break.
46
+ this.fallback[level](...args);
47
+ }
48
+ }
49
+ error(...args) {
50
+ this.log('error', args);
51
+ }
52
+ warn(...args) {
53
+ this.log('warn', args);
54
+ }
55
+ info(...args) {
56
+ this.log('info', args);
57
+ }
58
+ debug(...args) {
59
+ this.log('debug', args);
60
+ }
61
+ }
62
+ exports.default = SafeLogger;
63
+ //# sourceMappingURL=SafeLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeLogger.js","sourceRoot":"","sources":["../../src/logging/SafeLogger.ts"],"names":[],"mappings":";;AACA,8CAA+C;AAE/C,MAAM,kBAAkB,GAAG;IACzB,KAAK,EAAE,2BAAc,CAAC,QAAQ;IAC9B,IAAI,EAAE,2BAAc,CAAC,QAAQ;IAC7B,IAAI,EAAE,2BAAc,CAAC,QAAQ;IAC7B,KAAK,EAAE,2BAAc,CAAC,QAAQ;CAC/B,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAqB,UAAU;IAK7B;;;;;OAKG;IACH,YAAY,MAAgB,EAAE,QAAkB;QAC9C,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE;YAChE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAE,MAAc,CAAC,KAAK,CAAC,CAAC,EAAE;gBACzC,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,cAAc,CAAC,CAAC;gBACrF,yFAAyF;gBACzF,2FAA2F;gBAC3F,yFAAyF;gBACzF,+EAA+E;aAChF;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEO,GAAG,CAAC,KAA0C,EAAE,IAAW;QACjE,IAAI;YACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;SAC7B;QAAC,WAAM;YACN,kCAAkC;YAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,GAAG,IAAW;QACjB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,GAAG,IAAW;QAClB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAjDD,6BAiDC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/logging/format.ts"],"names":[],"mappings":""}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validators_1 = require("../validators");
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) {
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
+ }
26
+ catch (_a) {
27
+ /* Keep going */
28
+ }
29
+ }
30
+ if (typeof val === 'bigint') {
31
+ return `${val}n`;
32
+ }
33
+ try {
34
+ return JSON.stringify(val);
35
+ }
36
+ catch (error) {
37
+ if (error instanceof TypeError && error.message.indexOf('circular') >= 0) {
38
+ return '[Circular]';
39
+ }
40
+ return '[Not Stringifiable]';
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) {
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
+ * Attempt to produce an integer representation.
62
+ * BigInts have an `n` suffix.
63
+ * @param val
64
+ * @returns The integer representation or 'NaN' if not numeric.
65
+ */
66
+ function toInt(val) {
67
+ if (typeof val === 'symbol') {
68
+ return 'NaN';
69
+ }
70
+ if (typeof val === 'bigint') {
71
+ return `${val}n`;
72
+ }
73
+ return String(parseInt(val, 10));
74
+ }
75
+ /**
76
+ * Attempt to produce a float representation.
77
+ * BigInts have an `n` suffix.
78
+ * @param val
79
+ * @returns The integer representation or 'NaN' if not numeric.
80
+ */
81
+ function toFloat(val) {
82
+ if (typeof val === 'symbol') {
83
+ return 'NaN';
84
+ }
85
+ return String(parseFloat(val));
86
+ }
87
+ // Based on:
88
+ // https://nodejs.org/api/util.html#utilformatformat-args
89
+ // The result will not match node exactly, but it should get the
90
+ // right information through.
91
+ const escapes = {
92
+ s: (val) => tryStringify(val),
93
+ d: (val) => toNumber(val),
94
+ i: (val) => toInt(val),
95
+ f: (val) => toFloat(val),
96
+ j: (val) => tryStringify(val),
97
+ o: (val) => tryStringify(val),
98
+ O: (val) => tryStringify(val),
99
+ c: () => '',
100
+ };
101
+ /**
102
+ * A basic formatted for use where `util.format` is not available.
103
+ * This will not be as performant, but it will produce formatted
104
+ * messages.
105
+ *
106
+ * @internal
107
+ *
108
+ * @param args
109
+ * @returns Formatted string.
110
+ */
111
+ function format(...args) {
112
+ var _a;
113
+ const formatString = args.shift();
114
+ if (validators_1.TypeValidators.String.is(formatString)) {
115
+ let out = '';
116
+ let i = 0;
117
+ while (i < formatString.length) {
118
+ const char = formatString.charAt(i);
119
+ if (char === '%') {
120
+ const nextIndex = i + 1;
121
+ if (nextIndex < formatString.length) {
122
+ const nextChar = formatString.charAt(i + 1);
123
+ if (nextChar in escapes && args.length) {
124
+ const value = args.shift();
125
+ // This rule is for math.
126
+ // eslint-disable-next-line no-unsafe-optional-chaining
127
+ out += (_a = escapes[nextChar]) === null || _a === void 0 ? void 0 : _a.call(escapes, value);
128
+ }
129
+ else if (nextChar === '%') {
130
+ out += '%';
131
+ }
132
+ else {
133
+ out += `%${nextChar}`;
134
+ }
135
+ i += 2;
136
+ }
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
+ }
155
+ exports.default = format;
156
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/logging/format.ts"],"names":[],"mappings":";;AAAA,8CAA+C;AAE/C;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,GAAQ;IAC5B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,GAAG,KAAK,SAAS,EAAE;QACrB,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,GAAG,KAAK,IAAI,EAAE;QAChB,OAAO,MAAM,CAAC;KACf;IACD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE;QACzD,IAAI;YACF,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;SACvB;QAAC,WAAM;YACN,gBAAgB;SACjB;KACF;IAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,GAAG,GAAG,CAAC;KAClB;IACD,IAAI;QACF,OAAO,IAAI,CAAC,SAAS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AAK,CAAC,CAAC;qBACnC;yBAAM,IAAI,QAAQ,KAAK,GAAG,EAAE;wBAC3B,GAAG,IAAI,GAAG,CAAC;qBACZ;yBAAM;wBACL,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;qBACvB;oBACD,CAAC,IAAI,CAAC,CAAC;iBACR;aACF;iBAAM;gBACL,GAAG,IAAI,IAAI,CAAC;gBACZ,CAAC,IAAI,CAAC,CAAC;aACR;SACF;QACD,gEAAgE;QAChE,oCAAoC;QACpC,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,GAAG,CAAC,MAAM,EAAE;gBACd,GAAG,IAAI,GAAG,CAAC;aACZ;YACD,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAvCD,yBAuCC"}
@@ -0,0 +1,4 @@
1
+ import BasicLogger from './BasicLogger';
2
+ import SafeLogger from './SafeLogger';
3
+ export { BasicLogger, SafeLogger };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SafeLogger = exports.BasicLogger = void 0;
4
+ const BasicLogger_1 = require("./BasicLogger");
5
+ exports.BasicLogger = BasicLogger_1.default;
6
+ const SafeLogger_1 = require("./SafeLogger");
7
+ exports.SafeLogger = SafeLogger_1.default;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAG/B,sBAHF,qBAAW,CAGE;AAFpB,6CAAsC;AAEhB,qBAFf,oBAAU,CAEe"}
@@ -0,0 +1,15 @@
1
+ import { LDLogger } from '../api';
2
+ /**
3
+ * Class for managing tags.
4
+ */
5
+ export default class ApplicationTags {
6
+ readonly value?: string;
7
+ constructor(options: {
8
+ application?: {
9
+ id?: string;
10
+ version?: string;
11
+ };
12
+ logger?: LDLogger;
13
+ });
14
+ }
15
+ //# sourceMappingURL=ApplicationTags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplicationTags.d.ts","sourceRoot":"","sources":["../../src/options/ApplicationTags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAuBlC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEnB,OAAO,EAAE;QAAE,WAAW,CAAC,EAAE;YAAE,EAAE,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;KAAE;CA+B5F"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const validators_1 = require("../validators");
4
+ const OptionMessages_1 = require("./OptionMessages");
5
+ /**
6
+ * Expression to validate characters that are allowed in tag keys and values.
7
+ */
8
+ const allowedTagCharacters = /^(\w|\.|-)+$/;
9
+ const regexValidator = validators_1.TypeValidators.stringMatchingRegex(allowedTagCharacters);
10
+ const tagValidator = {
11
+ is: (u, name) => {
12
+ if (regexValidator.is(u)) {
13
+ if (u.length > 64) {
14
+ return { valid: false, message: OptionMessages_1.default.tagValueTooLong(name) };
15
+ }
16
+ return { valid: true };
17
+ }
18
+ return { valid: false, message: OptionMessages_1.default.invalidTagValue(name) };
19
+ },
20
+ };
21
+ /**
22
+ * Class for managing tags.
23
+ */
24
+ class ApplicationTags {
25
+ constructor(options) {
26
+ var _a, _b;
27
+ const tags = {};
28
+ const application = options === null || options === void 0 ? void 0 : options.application;
29
+ if ((application === null || application === void 0 ? void 0 : application.id) !== null && (application === null || application === void 0 ? void 0 : application.id) !== undefined) {
30
+ const { valid, message } = tagValidator.is(application.id, 'application.id');
31
+ if (!valid) {
32
+ (_a = options.logger) === null || _a === void 0 ? void 0 : _a.warn(message);
33
+ }
34
+ else {
35
+ tags['application-id'] = [application.id];
36
+ }
37
+ }
38
+ if ((application === null || application === void 0 ? void 0 : application.version) !== null && (application === null || application === void 0 ? void 0 : application.version) !== undefined) {
39
+ const { valid, message } = tagValidator.is(application.version, 'application.version');
40
+ if (!valid) {
41
+ (_b = options.logger) === null || _b === void 0 ? void 0 : _b.warn(message);
42
+ }
43
+ else {
44
+ tags['application-version'] = [application.version];
45
+ }
46
+ }
47
+ const tagKeys = Object.keys(tags);
48
+ if (tagKeys.length) {
49
+ this.value = tagKeys
50
+ .sort()
51
+ .flatMap((key) => tags[key].sort().map((value) => `${key}/${value}`))
52
+ .join(' ');
53
+ }
54
+ }
55
+ }
56
+ exports.default = ApplicationTags;
57
+ //# sourceMappingURL=ApplicationTags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApplicationTags.js","sourceRoot":"","sources":["../../src/options/ApplicationTags.ts"],"names":[],"mappings":";;AACA,8CAA+C;AAC/C,qDAA8C;AAE9C;;GAEG;AACH,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAE5C,MAAM,cAAc,GAAG,2BAAc,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;AAEhF,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE,CAAC,CAAU,EAAE,IAAY,EAAwC,EAAE;QACrE,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,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