dd-trace 6.9.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +0 -17
  2. package/ci/vitest-no-worker-init-setup.mjs +112 -10
  3. package/index.d.ts +150 -3
  4. package/initialize.mjs +28 -17
  5. package/openfeature.js +2 -2
  6. package/package.json +14 -10
  7. package/packages/datadog-esbuild/index.js +0 -34
  8. package/packages/datadog-instrumentations/src/anthropic.js +210 -15
  9. package/packages/datadog-instrumentations/src/aws-sdk.js +9 -1
  10. package/packages/datadog-instrumentations/src/browser-bunyan.js +11 -0
  11. package/packages/datadog-instrumentations/src/bunyan.js +3 -16
  12. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +111 -6
  13. package/packages/datadog-instrumentations/src/cucumber.js +26 -11
  14. package/packages/datadog-instrumentations/src/cypress-config.js +182 -16
  15. package/packages/datadog-instrumentations/src/cypress-legacy-finalizers.js +30 -0
  16. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  17. package/packages/datadog-instrumentations/src/fastify.js +2 -0
  18. package/packages/datadog-instrumentations/src/helpers/bunyan.js +22 -0
  19. package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
  20. package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +634 -0
  21. package/packages/datadog-instrumentations/src/helpers/register.js +10 -8
  22. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -1
  23. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +81 -0
  24. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +1 -0
  25. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +83 -1
  26. package/packages/datadog-instrumentations/src/jest.js +26 -18
  27. package/packages/datadog-instrumentations/src/mariadb.js +278 -21
  28. package/packages/datadog-instrumentations/src/mocha/main.js +540 -56
  29. package/packages/datadog-instrumentations/src/mocha/utils.js +132 -25
  30. package/packages/datadog-instrumentations/src/mysql.js +45 -15
  31. package/packages/datadog-instrumentations/src/mysql2.js +119 -18
  32. package/packages/datadog-instrumentations/src/path-to-regexp.js +67 -1
  33. package/packages/datadog-instrumentations/src/pg.js +116 -92
  34. package/packages/datadog-instrumentations/src/playwright-reporter.js +99 -0
  35. package/packages/datadog-instrumentations/src/playwright.js +149 -2
  36. package/packages/datadog-instrumentations/src/router.js +2 -0
  37. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +43 -4
  38. package/packages/datadog-instrumentations/src/vitest-main.js +180 -20
  39. package/packages/datadog-instrumentations/src/vitest-util.js +64 -5
  40. package/packages/datadog-instrumentations/src/vitest-worker.js +150 -25
  41. package/packages/datadog-instrumentations/src/webdriverio.js +31 -17
  42. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +12 -6
  43. package/packages/datadog-plugin-aws-sdk/src/base.js +1 -0
  44. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +163 -44
  45. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -13
  46. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -5
  47. package/packages/datadog-plugin-azure-functions/src/index.js +1 -1
  48. package/packages/datadog-plugin-browser-bunyan/src/index.js +9 -0
  49. package/packages/datadog-plugin-bunyan/src/index.js +5 -8
  50. package/packages/datadog-plugin-cucumber/src/index.js +11 -0
  51. package/packages/datadog-plugin-cypress/src/after-run.js +5 -1
  52. package/packages/datadog-plugin-cypress/src/after-spec.js +5 -1
  53. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +82 -30
  54. package/packages/datadog-plugin-cypress/src/finalization.js +76 -0
  55. package/packages/datadog-plugin-cypress/src/index.js +12 -6
  56. package/packages/datadog-plugin-cypress/src/plugin.js +16 -3
  57. package/packages/datadog-plugin-dd-trace-api/src/index.js +4 -0
  58. package/packages/datadog-plugin-electron/src/index.js +2 -0
  59. package/packages/datadog-plugin-fs/src/index.js +1 -1
  60. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +31 -17
  61. package/packages/datadog-plugin-jest/src/index.js +11 -4
  62. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -3
  63. package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -3
  64. package/packages/datadog-plugin-kafkajs/src/producer.js +3 -2
  65. package/packages/datadog-plugin-kafkajs/src/utils.js +65 -7
  66. package/packages/datadog-plugin-mocha/src/index.js +606 -40
  67. package/packages/datadog-plugin-mysql/src/index.js +37 -0
  68. package/packages/datadog-plugin-nats/src/index.js +1 -1
  69. package/packages/datadog-plugin-next/src/index.js +1 -19
  70. package/packages/datadog-plugin-openai/src/tracing.js +41 -30
  71. package/packages/datadog-plugin-openai-agents/src/integration.js +279 -69
  72. package/packages/datadog-plugin-openai-agents/src/processor.js +16 -4
  73. package/packages/datadog-plugin-pg/src/index.js +1 -0
  74. package/packages/datadog-plugin-playwright/src/index.js +42 -13
  75. package/packages/datadog-plugin-vitest/src/index.js +14 -20
  76. package/packages/datadog-plugin-ws/src/util.js +2 -1
  77. package/packages/datadog-webpack/index.js +0 -11
  78. package/packages/dd-trace/index.js +0 -1
  79. package/packages/dd-trace/src/agent/info.js +6 -5
  80. package/packages/dd-trace/src/aiguard/client.js +100 -1
  81. package/packages/dd-trace/src/aiguard/errors.js +41 -0
  82. package/packages/dd-trace/src/aiguard/evaluation.js +357 -0
  83. package/packages/dd-trace/src/aiguard/integrations/anthropic.js +70 -0
  84. package/packages/dd-trace/src/aiguard/integrations/index.js +4 -0
  85. package/packages/dd-trace/src/aiguard/messages/anthropic.js +423 -0
  86. package/packages/dd-trace/src/aiguard/messages/openai.js +1 -24
  87. package/packages/dd-trace/src/aiguard/messages/utils.js +28 -0
  88. package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +1 -11
  89. package/packages/dd-trace/src/aiguard/sdk.js +22 -278
  90. package/packages/dd-trace/src/appsec/api_security/normalized-route.js +453 -0
  91. package/packages/dd-trace/src/appsec/handlers/http-request.js +13 -0
  92. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -12
  93. package/packages/dd-trace/src/carrier.js +356 -0
  94. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +1 -0
  95. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +27 -3
  96. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +22 -6
  97. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +21 -5
  98. package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +164 -0
  99. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +22 -6
  100. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +365 -32
  101. package/packages/dd-trace/src/ci-visibility/exporters/request.js +201 -0
  102. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -3
  103. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +9 -5
  104. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
  105. package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +39 -0
  106. package/packages/dd-trace/src/ci-visibility/requests/request.js +3 -6
  107. package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +6 -2
  108. package/packages/dd-trace/src/config/generated-config-types.d.ts +7 -0
  109. package/packages/dd-trace/src/config/index.js +13 -2
  110. package/packages/dd-trace/src/config/major-overrides.js +7 -0
  111. package/packages/dd-trace/src/config/supported-configurations.json +24 -0
  112. package/packages/dd-trace/src/datastreams/context.js +6 -1
  113. package/packages/dd-trace/src/datastreams/index.js +2 -0
  114. package/packages/dd-trace/src/datastreams/manager.js +14 -3
  115. package/packages/dd-trace/src/datastreams/pathway.js +23 -22
  116. package/packages/dd-trace/src/datastreams/processor.js +16 -13
  117. package/packages/dd-trace/src/datastreams/size.js +5 -0
  118. package/packages/dd-trace/src/debugger/devtools_client/index.js +3 -2
  119. package/packages/dd-trace/src/exporters/agent/writer.js +49 -9
  120. package/packages/dd-trace/src/exporters/common/buffering-exporter.js +6 -4
  121. package/packages/dd-trace/src/exporters/common/writer.js +11 -6
  122. package/packages/dd-trace/src/llmobs/constants/tags.js +5 -0
  123. package/packages/dd-trace/src/llmobs/experiments/client.js +163 -5
  124. package/packages/dd-trace/src/llmobs/experiments/dataset.js +241 -87
  125. package/packages/dd-trace/src/llmobs/experiments/experiment.js +280 -20
  126. package/packages/dd-trace/src/llmobs/experiments/index.js +58 -59
  127. package/packages/dd-trace/src/llmobs/experiments/noop.js +71 -3
  128. package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
  129. package/packages/dd-trace/src/llmobs/experiments/util.js +41 -5
  130. package/packages/dd-trace/src/llmobs/index.js +34 -2
  131. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +12 -3
  132. package/packages/dd-trace/src/llmobs/plugins/base.js +4 -2
  133. package/packages/dd-trace/src/llmobs/span_processor.js +16 -0
  134. package/packages/dd-trace/src/llmobs/tagger.js +96 -0
  135. package/packages/dd-trace/src/llmobs/util.js +78 -0
  136. package/packages/dd-trace/src/noop/proxy.js +3 -4
  137. package/packages/dd-trace/src/openfeature/flagging_provider.js +18 -2
  138. package/packages/dd-trace/src/openfeature/remote_config.js +1 -1
  139. package/packages/dd-trace/src/opentelemetry/context_manager.js +7 -7
  140. package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +2 -1
  141. package/packages/dd-trace/src/opentelemetry/logs/logger.js +67 -11
  142. package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +14 -3
  143. package/packages/dd-trace/src/opentelemetry/metrics/index.js +25 -12
  144. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +2 -5
  145. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +96 -43
  146. package/packages/dd-trace/src/opentracing/propagation/text_map.js +126 -120
  147. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +4 -8
  148. package/packages/dd-trace/src/opentracing/tracer.js +5 -2
  149. package/packages/dd-trace/src/otel-thread-ctx.js +387 -0
  150. package/packages/dd-trace/src/plugin_manager.js +5 -3
  151. package/packages/dd-trace/src/plugins/ci_plugin.js +6 -1
  152. package/packages/dd-trace/src/plugins/index.js +1 -0
  153. package/packages/{datadog-plugin-jest/src/util.js → dd-trace/src/plugins/util/jest.js} +5 -65
  154. package/packages/dd-trace/src/plugins/util/test.js +93 -14
  155. package/packages/dd-trace/src/plugins/util/web.js +56 -2
  156. package/packages/dd-trace/src/profiling/profiler.js +1 -1
  157. package/packages/dd-trace/src/profiling/profilers/space.js +1 -3
  158. package/packages/dd-trace/src/profiling/profilers/wall.js +37 -90
  159. package/packages/dd-trace/src/profiling/webspan-utils.js +45 -0
  160. package/packages/dd-trace/src/proxy.js +38 -29
  161. package/packages/dd-trace/src/ritm.js +9 -2
  162. package/packages/dd-trace/src/serverless.js +37 -0
  163. package/packages/dd-trace/src/span_format.js +1 -0
  164. package/packages/dd-trace/src/span_stats.js +30 -3
  165. package/packages/dd-trace/src/storage-channels.js +86 -0
  166. package/packages/dd-trace/src/tracer.js +9 -2
  167. package/packages/dd-trace/src/tracer_metadata.js +14 -1
  168. package/packages/dd-trace/src/web-tags-cache.js +132 -0
  169. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +201 -0
  170. package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -0
  171. package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +0 -65
  172. package/packages/datadog-webpack/src/optional-peer-loader.js +0 -17
  173. package/packages/dd-trace/src/feature-registry.js +0 -29
  174. package/packages/dd-trace/src/openfeature/register.js +0 -35
  175. package/packages/dd-trace/src/openfeature/require-provider.js +0 -18
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025-present Datadog, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ (()=>{var e={"./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractAssignmentCache=void 0,t.assignmentCacheKeyToString=assignmentCacheKeyToString,t.assignmentCacheValueToString=assignmentCacheValueToString;let r=a("./@datadog/flagging-core/cjs/obfuscation.js");function assignmentCacheKeyToString(e){let t={flag:{key:e.flag.key},subject:{id:e.subject.id,attributes:e.subject.attributes}};return(0,r.getMD5Hash)(JSON.stringify(t))}function assignmentCacheValueToString(e){return(0,r.getMD5Hash)(JSON.stringify(e))}let AbstractAssignmentCache=class AbstractAssignmentCache{constructor(e){this.delegate=e}init(){return Promise.resolve()}has(e){return this.get(e)===assignmentCacheValueToString(e)}get(e){return this.delegate.get(assignmentCacheKeyToString(e))}set(e){this.delegate.set(assignmentCacheKeyToString(e),assignmentCacheValueToString(e))}entries(){return this.delegate.entries()}clear(){this.delegate.clear()}};t.AbstractAssignmentCache=AbstractAssignmentCache},"./@datadog/flagging-core/cjs/cache/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js"),t),n(a("./@datadog/flagging-core/cjs/cache/lru-in-memory-assignment-cache.js"),t),n(a("./@datadog/flagging-core/cjs/cache/non-expiring-in-memory-cache-assignment.js"),t)},"./@datadog/flagging-core/cjs/cache/lru-cache.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LRUCache=void 0;let LRUCache=class LRUCache{constructor(e){this.capacity=e,this.cache=new Map}entries(){return this.cache.entries()}clear(){this.cache.clear()}delete(e){return this.cache.delete(e)}keys(){return this.cache.keys()}values(){return this.cache.values()}has(e){return this.cache.has(e)}get(e){if(!this.has(e))return;let t=this.cache.get(e);return void 0!==t&&(this.delete(e),this.cache.set(e,t)),t}set(e,t){if(0===this.capacity)return this;if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){let e=this.cache.keys().next().value;e&&this.delete(e)}return this.cache.set(e,t),this}};t.LRUCache=LRUCache},"./@datadog/flagging-core/cjs/cache/lru-in-memory-assignment-cache.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LRUInMemoryAssignmentCache=void 0;let r=a("./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js"),n=a("./@datadog/flagging-core/cjs/cache/lru-cache.js");let LRUInMemoryAssignmentCache=class LRUInMemoryAssignmentCache extends r.AbstractAssignmentCache{constructor(e){super(new n.LRUCache(e))}};t.LRUInMemoryAssignmentCache=LRUInMemoryAssignmentCache},"./@datadog/flagging-core/cjs/cache/non-expiring-in-memory-cache-assignment.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NonExpiringInMemoryAssignmentCache=void 0;let r=a("./@datadog/flagging-core/cjs/cache/abstract-assignment-cache.js");let NonExpiringInMemoryAssignmentCache=class NonExpiringInMemoryAssignmentCache extends r.AbstractAssignmentCache{constructor(e=new Map){super(e)}};t.NonExpiringInMemoryAssignmentCache=NonExpiringInMemoryAssignmentCache},"./@datadog/flagging-core/cjs/configuration/configuration.js"(e,t){"use strict";function configMatchesContext(e,t){if(!(null==e?void 0:e.precomputed))return!1;let a=e.precomputed.context;return!a||contextsEqual(a,t)}function contextsEqual(e,t){return objectsEqual(e,t)}function objectsEqual(e,t){let a=Object.keys(e).sort(),r=Object.keys(t).sort();if(a.length!==r.length)return!1;for(let n=0;n<a.length;n++)if(a[n]!==r[n]||!valuesEqual(e[a[n]],t[r[n]]))return!1;return!0}function isRecord(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function valuesEqual(e,t){return e===t||null!=e&&null!=t&&typeof e==typeof t&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,a)=>valuesEqual(e,t[a])):!!(isRecord(e)&&isRecord(t))&&objectsEqual(e,t))}Object.defineProperty(t,"__esModule",{value:!0}),t.configMatchesContext=configMatchesContext},"./@datadog/flagging-core/cjs/configuration/exposureEvent.js"(e,t){"use strict";function createExposureEvent(e,t){var a,r;if(!(null==(a=t.flagMetadata)?void 0:a.doLog))return;let n=null==(r=t.flagMetadata)?void 0:r.allocationKey,i=t.variant;if(!n||!i)return;let{targetingKey:o="",...s}=e;return{allocation:{key:n},flag:{key:t.flagKey},variant:{key:i},subject:{id:o,attributes:s}}}Object.defineProperty(t,"__esModule",{value:!0}),t.createExposureEvent=createExposureEvent},"./@datadog/flagging-core/cjs/configuration/exposureEvent.types.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},"./@datadog/flagging-core/cjs/configuration/flagEvaluationAggregator.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlagEvaluationAggregator=void 0;let r=a("./@datadog/flagging-core/cjs/obfuscation.js"),n=a("./@datadog/flagging-core/cjs/time.js"),i=a("./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.js");let FlagEvaluationAggregator=class FlagEvaluationAggregator{constructor(e,t){this.aggregatedData=new Map,this.flushInterval=e,this.onFlush=t}start(){this.intervalId=setInterval(()=>{this.flush()},this.flushInterval)}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.flush()}addEvaluation(e,t,a){var r,n;let i=this.createAggregationKeyString(e,t,a),o=getEvaluationTimestamp(t),s=this.aggregatedData.get(i);if(s)s.count++,s.lastEvaluation=o,a&&(s.error=a);else{let s=isRuntimeDefaultUsed(t),l=null==(r=t.flagMetadata)?void 0:r.allocationKey,u=null==(n=t.flagMetadata)?void 0:n.targetingRuleKey,{targetingKey:c,...g}=e;this.aggregatedData.set(i,{flagKey:t.flagKey,variantKey:t.variant,allocationKey:l,targetingRuleKey:u,targetingKey:c,targetingContext:g,count:1,firstEvaluation:o,lastEvaluation:o,runtimeDefaultUsed:s,error:a})}}flush(){if(0===this.aggregatedData.size)return;let e=(0,n.timeStampNow)(),t=Array.from(this.aggregatedData.values()).map(t=>(0,i.createFlagEvaluationEvent)(t,e));this.aggregatedData.clear(),this.onFlush(t)}createAggregationKeyString(e,t,a){var n,i;let o=null==(n=t.flagMetadata)?void 0:n.allocationKey,s=null==(i=t.flagMetadata)?void 0:i.targetingRuleKey,{targetingKey:l,...u}=e;return(0,r.getMD5Hash)(JSON.stringify({flagKey:t.flagKey,variant:t.variant||"",allocationKey:o||"",targetingRuleKey:s||"",targetingKey:l||"",targetingContext:u,error:a||""}))}};function getEvaluationTimestamp(e){var t;let a=null==(t=e.flagMetadata)?void 0:t.__dd_eval_timestamp_ms;return Number.isFinite(a)?a:(0,n.timeStampNow)()}function isRuntimeDefaultUsed(e){return null==e.variant}t.FlagEvaluationAggregator=FlagEvaluationAggregator},"./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.js"(e,t){"use strict";function createFlagEvaluationEvent(e,t){let a={flag:{key:e.flagKey},first_evaluation:e.firstEvaluation,last_evaluation:e.lastEvaluation,evaluation_count:e.count,runtime_default_used:e.runtimeDefaultUsed,timestamp:t};return null!=e.targetingKey&&(a.targeting_key=e.targetingKey),e.error&&(a.error={message:e.error}),e.variantKey&&(a.variant={key:e.variantKey}),e.allocationKey&&(a.allocation={key:e.allocationKey}),e.targetingRuleKey&&(a.targeting_rule={key:e.targetingRuleKey}),e.targetingContext&&Object.keys(e.targetingContext).length>0&&(a.context={evaluation:e.targetingContext}),a}Object.defineProperty(t,"__esModule",{value:!0}),t.createFlagEvaluationEvent=createFlagEvaluationEvent},"./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.types.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},"./@datadog/flagging-core/cjs/configuration/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/configuration/configuration.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/exposureEvent.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/exposureEvent.types.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/flagEvaluationAggregator.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/flagEvaluationEvent.types.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/wire.js"),t)},"./@datadog/flagging-core/cjs/configuration/wire.js"(e,t){"use strict";function configurationFromString(e){try{let t=JSON.parse(e);if(1!==t.version)return{};let a={};return t.precomputed&&(a.precomputed={...t.precomputed,response:JSON.parse(t.precomputed.response)}),a}catch(e){return{}}}function configurationToString(e){let t={version:1};return e.precomputed&&(t.precomputed={...e.precomputed,response:JSON.stringify(e.precomputed.response)}),JSON.stringify(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.configurationFromString=configurationFromString,t.configurationToString=configurationToString},"./@datadog/flagging-core/cjs/evaluation/errors.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TargetingKeyMissingError=void 0;let TargetingKeyMissingError=class TargetingKeyMissingError extends Error{constructor(){super("Targeting key is required for split evaluation"),this.name="TargetingKeyMissingError"}};t.TargetingKeyMissingError=TargetingKeyMissingError},"./@datadog/flagging-core/cjs/evaluation/evaluateForSubject.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateForSubject=evaluateForSubject,t.containsMatchingRule=containsMatchingRule;let r=a("./@datadog/flagging-core/cjs/time.js"),n=a("./@datadog/flagging-core/cjs/evaluation/errors.js"),i=a("./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js"),o=a("./@datadog/flagging-core/cjs/evaluation/matchesShard.js"),s=a("./@datadog/flagging-core/cjs/evaluation/rules.js"),l=a("./@datadog/flagging-core/cjs/evaluation/ufc-v1.js");function evaluateForSubject(e,t,a,n,o,s,u=(0,r.timeStampNow)()){var c;if(!e.enabled)return s.debug("returning default assignment because flag is disabled",{flagKey:e.key,subjectKey:a}),{value:o,reason:"DISABLED",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)};if(!isValidFlag(e))return s.debug("returning default assignment because flag configuration is invalid",{flagKey:e.key,subjectKey:a}),{value:o,reason:"DEFAULT",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)};if(!validateTypeMatch(t,e.variationType))return s.debug("variant value type mismatch, returning default value",{flagKey:e.key,subjectKey:a,expectedType:t,variantType:e.variationType}),{value:o,reason:"ERROR",errorCode:"TYPE_MISMATCH",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)};let g=new Date(u);for(let t of e.allocations){if(t.startAt&&g<new Date(t.startAt)){s.debug("allocation before start date",{flagKey:e.key,subjectKey:a,allocationKey:t.key,startAt:t.startAt});continue}if(t.endAt&&g>=new Date(t.endAt)){s.debug("allocation after end date",{flagKey:e.key,subjectKey:a,allocationKey:t.key,endAt:t.endAt});continue}if(!containsMatchingRule(t.rules,n,s))continue;let r=selectSplitUsingSharding(t.splits,a,e.key,s);if(r){let n=e.variations[r.variationKey];if(n){s.debug("evaluated a flag",{flagKey:e.key,subjectKey:a,assignment:n.value});let o=(null==(c=t.rules)?void 0:c.length)?"TARGETING_MATCH":r.shards.length?"SPLIT":t.startAt||t.endAt?"DEFAULT":"STATIC";return{value:n.value,reason:o,variant:n.key,flagMetadata:{...(0,i.createEvaluationTimestampMetadata)(u),__dd_allocation_key:t.key,__dd_do_log:!!t.doLog,__dd_split_serial_id:r.serialId,allocationKey:t.key,variationType:(0,l.variantTypeToFlagValueType)(e.variationType),doLog:!!t.doLog}}}}else s.debug("no matching split found for subject",{flagKey:e.key,subjectKey:a,allocationKey:t.key})}return s.debug("returning default assignment because no allocation matched",{flagKey:e.key,subjectKey:a}),{value:o,reason:"DEFAULT",flagMetadata:(0,i.createEvaluationTimestampMetadata)(u)}}function validateTypeMatch(e,t){if("boolean"===e)return"BOOLEAN"===t;if("string"===e)return"STRING"===t;if("number"===e)return"INTEGER"===t||"NUMERIC"===t;if("object"===e)return"JSON"===t;throw Error(`Invalid expected type: ${e}`)}function isValidFlag(e){return Array.isArray(e.allocations)&&e.allocations.every(e=>Array.isArray(e.splits)&&e.splits.every(e=>Array.isArray(e.shards))&&(void 0===e.rules||Array.isArray(e.rules)&&e.rules.every(e=>(0,s.isValidRule)(e))))}function containsMatchingRule(e,t,a){return null==e||!e.length||(a.debug("evaluating rules",{rules:JSON.stringify(e),subjectAttributes:t}),e.some(e=>(0,s.matchesRule)(e,t)))}function selectSplitUsingSharding(e,t,a,r){if(!e||0===e.length)return null;for(let i of e)if(r.debug("evaluating split sharding",{flagKey:a,subjectKey:t,variationKey:i.variationKey,shards:i.shards}),i.shards.every(e=>{if(null==t)throw new n.TargetingKeyMissingError;let s=(0,o.matchesShard)(e,t);return r.debug("shard match result",{flagKey:a,subjectKey:t,variationKey:i.variationKey,shard:e,matches:s}),s}))return r.debug("subject matches split",{flagKey:a,subjectKey:t,variationKey:i.variationKey}),i;return r.debug("subject matches no splits",{flagKey:a,subjectKey:t}),null}},"./@datadog/flagging-core/cjs/evaluation/evaluation.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateRulesBasedConfiguration=evaluateRulesBasedConfiguration;let r=a("./@datadog/flagging-core/cjs/time.js"),n=a("./@datadog/flagging-core/cjs/evaluation/errors.js"),i=a("./@datadog/flagging-core/cjs/evaluation/evaluateForSubject.js"),o=a("./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js");function evaluateRulesBasedConfiguration(e,t,a,s,l,u){let c=(0,r.timeStampNow)();if(!e)return{value:s,reason:"ERROR",errorCode:"PROVIDER_NOT_READY",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)};let{targetingKey:g,...d}=l,f={...null!=g?{id:g}:{},...d},h=e.flags[a];if(!h)return u.debug("returning default value because flag is not found",{flagKey:a,subjectKey:g}),{value:s,reason:"ERROR",errorCode:"FLAG_NOT_FOUND",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)};try{return(0,i.evaluateForSubject)(h,t,g,f,s,u,c)}catch(e){if(e instanceof n.TargetingKeyMissingError)return{value:s,reason:"ERROR",errorCode:"TARGETING_KEY_MISSING",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)};return u.error("Error evaluating flag",{error:e}),{value:s,reason:"ERROR",errorCode:"GENERAL",flagMetadata:(0,o.createEvaluationTimestampMetadata)(c)}}}},"./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js"(e,t){"use strict";function createEvaluationTimestampMetadata(e){return{__dd_eval_timestamp_ms:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createEvaluationTimestampMetadata=createEvaluationTimestampMetadata},"./@datadog/flagging-core/cjs/evaluation/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/evaluation/errors.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/evaluateForSubject.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/evaluation.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/evaluationMetadata.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/matchesShard.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/rules.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/sharders.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/ufc-v1.js"),t)},"./@datadog/flagging-core/cjs/evaluation/matchesShard.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchesShard=matchesShard;let r=a("./@datadog/flagging-core/cjs/evaluation/sharders.js");function matchesShard(e,t,a){let n=(null!=a?a:new r.MD5Sharder).getShard(hashKey(e.salt,t),e.totalShards);return e.ranges.some(e=>isInShardRange(n,e))}function isInShardRange(e,t){return t.start<=e&&e<t.end}function hashKey(e,t){return`${e}-${t}`}},"./@datadog/flagging-core/cjs/evaluation/rules.js"(e,t){"use strict";var a,r;Object.defineProperty(t,"__esModule",{value:!0}),t.OperatorType=void 0,t.isValidRule=isValidRule,t.matchesRule=matchesRule,(r=a||(t.OperatorType=a={})).MATCHES="MATCHES",r.NOT_MATCHES="NOT_MATCHES",r.GTE="GTE",r.GT="GT",r.LTE="LTE",r.LT="LT",r.ONE_OF="ONE_OF",r.NOT_ONE_OF="NOT_ONE_OF",r.IS_NULL="IS_NULL";let n=new Set(Object.values(a));function isValidRule(e){return!!Array.isArray(e.conditions)&&e.conditions.every(e=>{if(!n.has(e.operator))return!1;if(e.operator!==a.MATCHES&&e.operator!==a.NOT_MATCHES)return!0;try{return compileRegex(e.value),!0}catch(e){return!1}})}function matchesRule(e,t){return!evaluateRuleConditions(t,e.conditions).includes(!1)}function evaluateRuleConditions(e,t){return t.map(t=>evaluateCondition(e,t))}function evaluateCondition(e,t){let r=e[t.attribute];if(t.operator===a.IS_NULL)return t.value?null==r:null!=r;if(null!=r)switch(t.operator){case a.GTE:case a.GT:case a.LTE:case a.LT:return compareNumber(r,t.value,(e,r)=>t.operator===a.GTE?e>=r:t.operator===a.GT?e>r:t.operator===a.LTE?e<=r:e<r);case a.MATCHES:return compileRegex(t.value).test(String(r));case a.NOT_MATCHES:return!compileRegex(t.value).test(String(r));case a.ONE_OF:var n;return n=r.toString(),t.value.includes(n);case a.NOT_ONE_OF:return isNotOneOf(r.toString(),t.value)}return!1}function compileRegex(e){let t=e.match(/^\(\?([imsu]+)\)/),a=t?[...new Set(t[1])].join(""):"";return new RegExp((t?e.slice(t[0].length):e).split("[:alnum:]").join("A-Za-z0-9"),a)}function isNotOneOf(e,t){return!t.includes(e)}function compareNumber(e,t,a){return a(Number(e),Number(t))}},"./@datadog/flagging-core/cjs/evaluation/sharders.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeterministicSharder=t.MD5Sharder=t.Sharder=void 0;let r=a("./@datadog/flagging-core/cjs/obfuscation.js");let Sharder=class Sharder{};t.Sharder=Sharder;let MD5Sharder=class MD5Sharder extends Sharder{getShard(e,t){return parseInt((0,r.getMD5Hash)(e).slice(0,8),16)%t}};t.MD5Sharder=MD5Sharder;let DeterministicSharder=class DeterministicSharder extends Sharder{constructor(e){super(),this.lookup=e}getShard(e,t){var a;return null!=(a=this.lookup[e])?a:0}};t.DeterministicSharder=DeterministicSharder},"./@datadog/flagging-core/cjs/evaluation/ufc-v1.js"(e,t){"use strict";function variantTypeToFlagValueType(e){if("BOOLEAN"===e)return"boolean";if("STRING"===e)return"string";if("INTEGER"===e||"NUMERIC"===e)return"number";if("JSON"===e)return"object";throw Error(`Cannot convert variant type to flag value type: ${e}`)}Object.defineProperty(t,"__esModule",{value:!0}),t.variantTypeToFlagValueType=variantTypeToFlagValueType},"./@datadog/flagging-core/cjs/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/flagging-core/cjs/cache/index.js"),t),n(a("./@datadog/flagging-core/cjs/configuration/index.js"),t),n(a("./@datadog/flagging-core/cjs/evaluation/index.js"),t),n(a("./@datadog/flagging-core/cjs/obfuscation.js"),t),n(a("./@datadog/flagging-core/cjs/time.js"),t)},"./@datadog/flagging-core/cjs/obfuscation.js"(e,t,a){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMD5Hash=getMD5Hash,t.buildStorageKeySuffix=buildStorageKeySuffix;let n=r(a("./spark-md5/spark-md5.js"));function getMD5Hash(e,t=""){return new n.default().append(t).append(e).end()}function buildStorageKeySuffix(e){return getMD5Hash(e).slice(0,16)}},"./@datadog/flagging-core/cjs/time.js"(e,t){"use strict";function timeStampNow(){return new Date().getTime()}Object.defineProperty(t,"__esModule",{value:!0}),t.timeStampNow=timeStampNow},"./@datadog/openfeature-node-server/cjs/configuration/evaluation.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluate=void 0;var r=a("./@datadog/flagging-core/cjs/index.js");Object.defineProperty(t,"evaluate",{enumerable:!0,get:function(){return r.evaluateRulesBasedConfiguration}})},"./@datadog/openfeature-node-server/cjs/index.js"(e,t,a){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=this&&this.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),n(a("./@datadog/openfeature-node-server/cjs/provider.js"),t)},"./@datadog/openfeature-node-server/cjs/initialization-controller.js"(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InitializationController=void 0;let InitializationController=class InitializationController{constructor(e,t){this.promise=Promise.race([new Promise((e,t)=>{this.resolve=()=>{this.cleanup(),e()},this.reject=e=>{this.cleanup(),t(e)}}),new Promise(()=>{this.timeoutId=setTimeout(()=>{t()},e)})])}async wait(){try{await this.promise}finally{this.cleanup()}}complete(){this.resolve&&this.resolve()}fail(e){this.reject&&this.reject(e)}isInitializing(){return void 0!==this.resolve}cleanup(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=void 0),this.resolve=void 0,this.reject=void 0}};t.InitializationController=InitializationController},"./@datadog/openfeature-node-server/cjs/provider-event-emitter.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NodeProviderEventEmitter=void 0;let r=a("node:events");let NodeProviderEventEmitter=class NodeProviderEventEmitter{constructor(){this.eventEmitter=new r.EventEmitter,this.handlers=new Map}emit(e,t){this.eventEmitter.emit(e,t)}addHandler(e,t){var a,r;let asyncHandler=async e=>{try{await t(e)}catch(e){this.logHandlerError(e)}},n=null!=(a=this.handlers.get(e))?a:new Map,i=null!=(r=n.get(t))?r:[];i.push(asyncHandler),n.set(t,i),this.handlers.set(e,n),this.eventEmitter.on(e,asyncHandler)}removeHandler(e,t){let a=this.handlers.get(e),r=null==a?void 0:a.get(t),n=null==r?void 0:r.pop();n&&this.eventEmitter.removeListener(e,n),(null==r?void 0:r.length)===0&&(null==a||a.delete(t)),(null==a?void 0:a.size)===0&&this.handlers.delete(e)}removeAllHandlers(e){if(e){this.eventEmitter.removeAllListeners(e),this.handlers.delete(e);return}this.eventEmitter.removeAllListeners(),this.handlers.clear()}getHandlers(e){return this.eventEmitter.listeners(e)}setLogger(e){return this.logger=e,this}logHandlerError(e){var t;try{null==(t=this.logger)||t.error("Error running event handler:",e)}catch(e){}}};t.NodeProviderEventEmitter=NodeProviderEventEmitter},"./@datadog/openfeature-node-server/cjs/provider.js"(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DatadogNodeServerProvider=void 0;let r=a("./@datadog/flagging-core/cjs/index.js"),n=a("./@datadog/openfeature-node-server/cjs/configuration/evaluation.js"),i=a("./@datadog/openfeature-node-server/cjs/initialization-controller.js"),o=a("./@datadog/openfeature-node-server/cjs/provider-event-emitter.js");let DatadogNodeServerProvider=class DatadogNodeServerProvider{constructor(e){this.options=e,this.metadata={name:"datadog-node-server"},this.runsOn="server",this.hooks=[],this.events=new o.NodeProviderEventEmitter,this.exposureCache=new r.LRUInMemoryAssignmentCache(5e4)}getConfiguration(){return this.configuration}setConfiguration(e){var t,a,r;let n=null==(t=this.configuration)?void 0:t.createdAt,i=!!this.configuration;if(i&&this.configuration!==e){this.events.emit("PROVIDER_CONFIGURATION_CHANGED"),n!==(null==e?void 0:e.createdAt)&&(null==(a=this.exposureCache)||a.clear()),this.configuration=e;return}this.configuration=e,(null==(r=this.initController)?void 0:r.isInitializing())?this.initController.complete():i||this.events.emit("PROVIDER_READY")}setError(e){var t;(null==(t=this.initController)?void 0:t.isInitializing())?this.initController.fail(e):this.events.emit("PROVIDER_ERROR",{error:e})}async initialize(){var e,t;if(this.configuration)return;let a=null!=(e=this.options.initializationTimeoutMs)?e:3e4;this.initController=new i.InitializationController(a,()=>this.setError(Error(`Initialization timeout after ${a}ms`))),await this.initController.wait(),await (null==(t=this.exposureCache)?void 0:t.init())}async resolveBooleanEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"boolean",e,t,a,r);return this.handleExposure(e,a,i),i}async resolveStringEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"string",e,t,a,r);return this.handleExposure(e,a,i),i}async resolveNumberEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"number",e,t,a,r);return this.handleExposure(e,a,i),i}async resolveObjectEvaluation(e,t,a,r){let i=(0,n.evaluate)(this.configuration,"object",e,t,a,r);return this.handleExposure(e,a,i),i}handleExposure(e,t,a){var n,i,o;let s=(0,r.timeStampNow)(),l={...a,flagKey:e,flagMetadata:null!=(n=a.flagMetadata)?n:{}},u=(0,r.createExposureEvent)(t,l);!u||(null==(i=this.exposureCache)?void 0:i.has(u))||this.options.exposureChannel.hasSubscribers&&(this.options.exposureChannel.publish({...u,timestamp:s}),null==(o=this.exposureCache)||o.set(u))}};t.DatadogNodeServerProvider=DatadogNodeServerProvider},"./spark-md5/spark-md5.js"(e){e.exports=function(){"use strict";var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function md5cycle(e,t){var a=e[0],r=e[1],n=e[2],i=e[3];a+=(r&n|~r&i)+t[0]-0x28955b88|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[1]-0x173848aa|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[2]+0x242070db|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[3]-0x3e423112|0,a+=((r=(r<<22|r>>>10)+n|0)&n|~r&i)+t[4]-0xa83f051|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[5]+0x4787c62a|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[6]-0x57cfb9ed|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[7]-0x2b96aff|0,a+=((r=(r<<22|r>>>10)+n|0)&n|~r&i)+t[8]+0x698098d8|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[9]-0x74bb0851|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[10]-42063|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[11]-0x76a32842|0,a+=((r=(r<<22|r>>>10)+n|0)&n|~r&i)+t[12]+0x6b901122|0,i+=((a=(a<<7|a>>>25)+r|0)&r|~a&n)+t[13]-0x2678e6d|0,n+=((i=(i<<12|i>>>20)+a|0)&a|~i&r)+t[14]-0x5986bc72|0,r+=((n=(n<<17|n>>>15)+i|0)&i|~n&a)+t[15]+0x49b40821|0,a+=((r=(r<<22|r>>>10)+n|0)&i|n&~i)+t[1]-0x9e1da9e|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[6]-0x3fbf4cc0|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[11]+0x265e5a51|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[0]-0x16493856|0,a+=((r=(r<<20|r>>>12)+n|0)&i|n&~i)+t[5]-0x29d0efa3|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[10]+0x2441453|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[15]-0x275e197f|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[4]-0x182c0438|0,a+=((r=(r<<20|r>>>12)+n|0)&i|n&~i)+t[9]+0x21e1cde6|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[14]-0x3cc8f82a|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[3]-0xb2af279|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[8]+0x455a14ed|0,a+=((r=(r<<20|r>>>12)+n|0)&i|n&~i)+t[13]-0x561c16fb|0,i+=((a=(a<<5|a>>>27)+r|0)&n|r&~n)+t[2]-0x3105c08|0,n+=((i=(i<<9|i>>>23)+a|0)&r|a&~r)+t[7]+0x676f02d9|0,r+=((n=(n<<14|n>>>18)+i|0)&a|i&~a)+t[12]-0x72d5b376|0,a+=((r=(r<<20|r>>>12)+n|0)^n^i)+t[5]-378558|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[8]-0x788e097f|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[11]+0x6d9d6122|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[14]-0x21ac7f4|0,a+=((r=(r<<23|r>>>9)+n|0)^n^i)+t[1]-0x5b4115bc|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[4]+0x4bdecfa9|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[7]-0x944b4a0|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[10]-0x41404390|0,a+=((r=(r<<23|r>>>9)+n|0)^n^i)+t[13]+0x289b7ec6|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[0]-0x155ed806|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[3]-0x2b10cf7b|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[6]+0x4881d05|0,a+=((r=(r<<23|r>>>9)+n|0)^n^i)+t[9]-0x262b2fc7|0,i+=((a=(a<<4|a>>>28)+r|0)^r^n)+t[12]-0x1924661b|0,n+=((i=(i<<11|i>>>21)+a|0)^a^r)+t[15]+0x1fa27cf8|0,r+=((n=(n<<16|n>>>16)+i|0)^i^a)+t[2]-0x3b53a99b|0,r=(r<<23|r>>>9)+n|0,a+=(n^(r|~i))+t[0]-0xbd6ddbc|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[7]+0x432aff97|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[14]-0x546bdc59|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[5]-0x36c5fc7|0,r=(r<<21|r>>>11)+n|0,a+=(n^(r|~i))+t[12]+0x655b59c3|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[3]-0x70f3336e|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[10]-1051523|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[1]-0x7a7ba22f|0,r=(r<<21|r>>>11)+n|0,a+=(n^(r|~i))+t[8]+0x6fa87e4f|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[15]-0x1d31920|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[6]-0x5cfebcec|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[13]+0x4e0811a1|0,r=(r<<21|r>>>11)+n|0,a+=(n^(r|~i))+t[4]-0x8ac817e|0,a=(a<<6|a>>>26)+r|0,i+=(r^(a|~n))+t[11]-0x42c50dcb|0,i=(i<<10|i>>>22)+a|0,n+=(a^(i|~r))+t[2]+0x2ad7d2bb|0,n=(n<<15|n>>>17)+i|0,r+=(i^(n|~a))+t[9]-0x14792c6f|0,r=(r<<21|r>>>11)+n|0,e[0]=a+e[0]|0,e[1]=r+e[1]|0,e[2]=n+e[2]|0,e[3]=i+e[3]|0}function md5blk(e){var t,a=[];for(t=0;t<64;t+=4)a[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return a}function md5blk_array(e){var t,a=[];for(t=0;t<64;t+=4)a[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return a}function md51(e){var t,a,r,n,i,o,s=e.length,l=[0x67452301,-0x10325477,-0x67452302,0x10325476];for(t=64;t<=s;t+=64)md5cycle(l,md5blk(e.substring(t-64,t)));for(a=(e=e.substring(t-64)).length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(md5cycle(l,r),t=0;t<16;t+=1)r[t]=0;return i=parseInt((n=(n=8*s).toString(16).match(/(.*?)(.{0,8})$/))[2],16),o=parseInt(n[1],16)||0,r[14]=i,r[15]=o,md5cycle(l,r),l}function md51_array(e){var t,a,r,n,i,o,s=e.length,l=[0x67452301,-0x10325477,-0x67452302,0x10325476];for(t=64;t<=s;t+=64)md5cycle(l,md5blk_array(e.subarray(t-64,t)));for(a=(e=t-64<s?e.subarray(t-64):new Uint8Array(0)).length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)r[t>>2]|=e[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(md5cycle(l,r),t=0;t<16;t+=1)r[t]=0;return i=parseInt((n=(n=8*s).toString(16).match(/(.*?)(.{0,8})$/))[2],16),o=parseInt(n[1],16)||0,r[14]=i,r[15]=o,md5cycle(l,r),l}function rhex(t){var a,r="";for(a=0;a<4;a+=1)r+=e[t>>8*a+4&15]+e[t>>8*a&15];return r}function hex(e){var t;for(t=0;t<e.length;t+=1)e[t]=rhex(e[t]);return e.join("")}function toUtf8(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function utf8Str2ArrayBuffer(e,t){var a,r=e.length,n=new ArrayBuffer(r),i=new Uint8Array(n);for(a=0;a<r;a+=1)i[a]=e.charCodeAt(a);return t?i:n}function arrayBuffer2Utf8Str(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function concatenateArrayBuffers(e,t,a){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),a?r:r.buffer}function hexToBinaryString(e){var t,a=[],r=e.length;for(t=0;t<r-1;t+=2)a.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,a)}function SparkMD5(){this.reset()}return hex(md51("hello")),"u">typeof ArrayBuffer&&!ArrayBuffer.prototype.slice&&function(){function clamp(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(e,t){var a,r,n,i,o=this.byteLength,s=clamp(e,o),l=o;return(void 0!==t&&(l=clamp(t,o)),s>l)?new ArrayBuffer(0):(n=new Uint8Array(r=new ArrayBuffer(a=l-s)),i=new Uint8Array(this,s,a),n.set(i),r)}}(),SparkMD5.prototype.append=function(e){return this.appendBinary(toUtf8(e)),this},SparkMD5.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,a=this._buff.length;for(t=64;t<=a;t+=64)md5cycle(this._hash,md5blk(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},SparkMD5.prototype.end=function(e){var t,a,r=this._buff,n=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<n;t+=1)i[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(i,n),a=hex(this._hash),e&&(a=hexToBinaryString(a)),this.reset(),a},SparkMD5.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[0x67452301,-0x10325477,-0x67452302,0x10325476],this},SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},SparkMD5.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},SparkMD5.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},SparkMD5.prototype._finish=function(e,t){var a,r,n,i=t;if(e[i>>2]|=128<<(i%4<<3),i>55)for(md5cycle(this._hash,e),i=0;i<16;i+=1)e[i]=0;r=parseInt((a=(a=8*this._length).toString(16).match(/(.*?)(.{0,8})$/))[2],16),n=parseInt(a[1],16)||0,e[14]=r,e[15]=n,md5cycle(this._hash,e)},SparkMD5.hash=function(e,t){return SparkMD5.hashBinary(toUtf8(e),t)},SparkMD5.hashBinary=function(e,t){var a=hex(md51(e));return t?hexToBinaryString(a):a},SparkMD5.ArrayBuffer=function(){this.reset()},SparkMD5.ArrayBuffer.prototype.append=function(e){var t,a=concatenateArrayBuffers(this._buff.buffer,e,!0),r=a.length;for(this._length+=e.byteLength,t=64;t<=r;t+=64)md5cycle(this._hash,md5blk_array(a.subarray(t-64,t)));return this._buff=new Uint8Array(t-64<r?a.buffer.slice(t-64):0),this},SparkMD5.ArrayBuffer.prototype.end=function(e){var t,a,r=this._buff,n=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<n;t+=1)i[t>>2]|=r[t]<<(t%4<<3);return this._finish(i,n),a=hex(this._hash),e&&(a=hexToBinaryString(a)),this.reset(),a},SparkMD5.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[0x67452301,-0x10325477,-0x67452302,0x10325476],this},SparkMD5.ArrayBuffer.prototype.getState=function(){var e=SparkMD5.prototype.getState.call(this);return e.buff=arrayBuffer2Utf8Str(e.buff),e},SparkMD5.ArrayBuffer.prototype.setState=function(e){return e.buff=utf8Str2ArrayBuffer(e.buff,!0),SparkMD5.prototype.setState.call(this,e)},SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy,SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish,SparkMD5.ArrayBuffer.hash=function(e,t){var a=hex(md51_array(new Uint8Array(e)));return t?hexToBinaryString(a):a},SparkMD5}()},"node:events"(e){"use strict";e.exports=require("node:events")}},t={};function __webpack_require__(a){var r=t[a];if(void 0!==r)return r.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,__webpack_require__),n.exports}var a=__webpack_require__("./@datadog/openfeature-node-server/cjs/index.js");module.exports=a})();
@@ -1,65 +0,0 @@
1
- 'use strict'
2
-
3
- const path = require('node:path')
4
-
5
- // Build-time half of the optional-peer mechanism shared by the webpack and esbuild plugins.
6
- //
7
- // Runtime files load an optional peer through a local `requireOptionalPeer('name')` wrapper.
8
- // File tracers recognize its bound-require shape, while bundlers cannot follow the dynamic
9
- // argument, so a build that does not opt into the feature never pulls in the peer's dependency
10
- // chain (#8635). When the peer is installed at build time the user has opted in, so the plugins
11
- // rewrite the call into a literal `require('name')` and let the bundler inline the peer, which
12
- // keeps it working after the bundle is relocated without the peer on disk (#8980). Peers that
13
- // are absent at build time stay opaque, so the rewrite is a no-op and the #8635 guarantee holds.
14
-
15
- // Files that load an optional peer this way, as suffixes of the resolved module path. The same
16
- // suffix matches the repo layout and `node_modules/dd-trace`. Add a file here to extend the
17
- // mechanism to a new optional peer; no plugin change is needed.
18
- const OPTIONAL_PEER_FILES = [
19
- 'packages/dd-trace/src/openfeature/require-provider.js',
20
- ]
21
-
22
- // Captures the peer name from `requireOptionalPeer('name')` / `requireOptionalPeer("name")`.
23
- const OPTIONAL_PEER_LOAD = /requireOptionalPeer\((['"])(.+?)\1\)/g
24
-
25
- // esbuild's `onLoad` needs a path filter; match the basenames so the callback only fires for
26
- // the candidate files, then `matchesOptionalPeerFile` confirms the full suffix on a normalized
27
- // path (basenames carry no separators, so the filter is OS-agnostic).
28
- const OPTIONAL_PEER_FILTER = new RegExp(
29
- `(?:${OPTIONAL_PEER_FILES.map((file) => path.basename(file).replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)).join('|')})$`
30
- )
31
-
32
- /**
33
- * @param {string} normalizedResource - Resolved module path with forward slashes
34
- * @returns {boolean} Whether the module is one of the optional-peer loader files
35
- */
36
- function matchesOptionalPeerFile (normalizedResource) {
37
- return OPTIONAL_PEER_FILES.some((suffix) => normalizedResource.endsWith(suffix))
38
- }
39
-
40
- /**
41
- * Rewrites each `requireOptionalPeer('name')` whose peer resolves from `fromDir` into a literal
42
- * `require('name')` so the bundler inlines it. Peers that do not resolve stay opaque, so a build
43
- * without the peer keeps the #8635 guarantee.
44
- *
45
- * @param {string} source - Source of an optional-peer loader file
46
- * @param {string} fromDir - Directory to resolve the optional peers from
47
- * @returns {string} Source with installed optional peers turned into literal requires
48
- */
49
- function rewriteOptionalPeerLoads (source, fromDir) {
50
- return source.replaceAll(OPTIONAL_PEER_LOAD, (match, _quote, request) => {
51
- try {
52
- require.resolve(request, { paths: [fromDir] })
53
- } catch {
54
- return match
55
- }
56
- return `require('${request}')`
57
- })
58
- }
59
-
60
- module.exports = {
61
- OPTIONAL_PEER_FILES,
62
- OPTIONAL_PEER_FILTER,
63
- matchesOptionalPeerFile,
64
- rewriteOptionalPeerLoads,
65
- }
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- const { rewriteOptionalPeerLoads } = require('../../datadog-instrumentations/src/helpers/optional-peer-bundler')
4
-
5
- /**
6
- * Webpack loader applied to the optional-peer loader files. Rewrites each
7
- * `requireOptionalPeer('name')` whose peer is installed at build time into a literal
8
- * `require('name')` so webpack bundles the peer (#8980). Peers that are absent stay opaque, so
9
- * builds that do not opt into the feature keep the #8635 guarantee.
10
- *
11
- * @param {string} source
12
- * @returns {string}
13
- */
14
- module.exports = function optionalPeerLoader (source) {
15
- this.cacheable(false)
16
- return rewriteOptionalPeerLoads(source, this.context)
17
- }
@@ -1,29 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @typedef {{ enable: (config: import('./config/config-base')) => void, disable: () => void }} FeatureModule
5
- * @typedef {new (tracer: import('./tracer'), config: import('./config/config-base')) => object} FeatureProvider
6
- */
7
-
8
- /**
9
- * @typedef {object} Feature
10
- * @property {string} name
11
- * @property {object} noop
12
- * @property {() => FeatureModule} factory
13
- * @property {(config: import('./config/config-base')) => boolean} isEnabled
14
- * @property {() => FeatureProvider} provider
15
- * @property {(rc: import('./remote_config'), config: import('./config/config-base'),
16
- * proxy: import('./proxy')) => void} [remoteConfig]
17
- */
18
-
19
- /** @type {{ [name: string]: Feature }} */
20
- const features = {}
21
-
22
- /**
23
- * @param {Feature} feature
24
- */
25
- function registerFeature (feature) {
26
- features[feature.name] = feature
27
- }
28
-
29
- module.exports = { features, registerFeature }
@@ -1,35 +0,0 @@
1
- 'use strict'
2
-
3
- const { registerFeature } = require('../feature-registry')
4
-
5
- const noop = new (require('./noop'))()
6
-
7
- /** @typedef {import('../proxy') & { openfeature: object }} OpenFeatureProxy */
8
-
9
- registerFeature({
10
- name: 'openfeature',
11
- noop,
12
- factory: () => require('./index'),
13
- provider: () => require('./flagging_provider'),
14
-
15
- /** @param {import('../config/config-base')} config */
16
- isEnabled (config) {
17
- return config.featureFlags.DD_FEATURE_FLAGS_ENABLED
18
- },
19
-
20
- /**
21
- * @param {import('../remote_config')} rc - RemoteConfig instance
22
- * @param {import('../config/config-base')} config
23
- * @param {OpenFeatureProxy} proxy
24
- */
25
- remoteConfig (rc, config, proxy) {
26
- const openfeatureRemoteConfig = require('./remote_config')
27
- const subscribe = config.featureFlags.DD_FEATURE_FLAGS_ENABLED &&
28
- config.featureFlags.DD_FEATURE_FLAGS_CONFIGURATION_SOURCE === 'remote_config'
29
- openfeatureRemoteConfig.enable(
30
- rc,
31
- () => proxy.openfeature,
32
- subscribe
33
- )
34
- },
35
- })
@@ -1,18 +0,0 @@
1
- 'use strict'
2
-
3
- /** @type {(request: string) => typeof import('@datadog/openfeature-node-server')} */
4
- let requireOptionalPeer
5
-
6
- // @ts-expect-error webpack exposes this escape hatch as a free variable.
7
- // eslint-disable-next-line camelcase
8
- if (typeof __non_webpack_require__ === 'function') {
9
- // eslint-disable-next-line camelcase, no-undef
10
- requireOptionalPeer = __non_webpack_require__
11
- } else {
12
- // nft recognizes createRequire through a binding named `module`.
13
- const module = require('node:module')
14
- const runtimeRequire = module.createRequire(__filename)
15
- requireOptionalPeer = runtimeRequire
16
- }
17
-
18
- module.exports = requireOptionalPeer('@datadog/openfeature-node-server')