@10x-media/analytics 1.0.0-beta.6 → 1.0.0-beta.8

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 (391) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +13 -3
  3. package/dist/adapters/ga4/ga4.js +3 -2
  4. package/dist/adapters/ga4/ga4.js.map +1 -1
  5. package/dist/adapters/http/fetchJson.js +1 -1
  6. package/dist/adapters/plausible/plausible.d.ts +10 -0
  7. package/dist/adapters/plausible/plausible.js +42 -1
  8. package/dist/adapters/plausible/plausible.js.map +1 -1
  9. package/dist/adapters/posthog/posthog.d.ts +10 -1
  10. package/dist/adapters/posthog/posthog.js +47 -0
  11. package/dist/adapters/posthog/posthog.js.map +1 -1
  12. package/dist/adapters/umami/umami.d.ts +5 -1
  13. package/dist/adapters/umami/umami.js +26 -0
  14. package/dist/adapters/umami/umami.js.map +1 -1
  15. package/dist/capture/getTrackerConfig.d.ts +20 -0
  16. package/dist/capture/getTrackerConfig.js +31 -0
  17. package/dist/capture/getTrackerConfig.js.map +1 -0
  18. package/dist/capture/mountPath.js +14 -0
  19. package/dist/capture/mountPath.js.map +1 -0
  20. package/dist/capture/proxyEndpoint.js +123 -0
  21. package/dist/capture/proxyEndpoint.js.map +1 -0
  22. package/dist/capture/proxyRoutes.js +108 -0
  23. package/dist/capture/proxyRoutes.js.map +1 -0
  24. package/dist/capture/requestBody.js +68 -0
  25. package/dist/capture/requestBody.js.map +1 -0
  26. package/dist/capture/slots.d.ts +8 -0
  27. package/dist/capture/slots.js +54 -0
  28. package/dist/capture/slots.js.map +1 -0
  29. package/dist/capture/trackerConfig.d.ts +33 -0
  30. package/dist/capture/trackerConfig.js +95 -0
  31. package/dist/capture/trackerConfig.js.map +1 -0
  32. package/dist/capture/trackerEndpoint.js +35 -0
  33. package/dist/capture/trackerEndpoint.js.map +1 -0
  34. package/dist/charts/BarList.d.ts +15 -1
  35. package/dist/charts/BarList.js +34 -18
  36. package/dist/charts/BarList.js.map +1 -1
  37. package/dist/charts/TrendChart.d.ts +16 -3
  38. package/dist/charts/TrendChart.js +172 -106
  39. package/dist/charts/TrendChart.js.map +1 -1
  40. package/dist/charts/bars.d.ts +2 -0
  41. package/dist/charts/bars.js +2 -1
  42. package/dist/charts/bars.js.map +1 -1
  43. package/dist/charts/bucket.js +10 -1
  44. package/dist/charts/bucket.js.map +1 -1
  45. package/dist/charts/spline.js +2 -2
  46. package/dist/charts/spline.js.map +1 -1
  47. package/dist/charts/styles.js +18 -1
  48. package/dist/charts/styles.js.map +1 -1
  49. package/dist/core/cacheKey.js +13 -1
  50. package/dist/core/cacheKey.js.map +1 -1
  51. package/dist/core/capture.d.ts +49 -0
  52. package/dist/core/contract.d.ts +35 -4
  53. package/dist/core/contract.js +29 -1
  54. package/dist/core/contract.js.map +1 -1
  55. package/dist/core/granularity.js +1 -1
  56. package/dist/core/options.d.ts +148 -4
  57. package/dist/core/options.js +121 -3
  58. package/dist/core/options.js.map +1 -1
  59. package/dist/core/registry.d.ts +1 -0
  60. package/dist/core/scopeList.js +32 -0
  61. package/dist/core/scopeList.js.map +1 -0
  62. package/dist/core/scopedRead.js +45 -28
  63. package/dist/core/scopedRead.js.map +1 -1
  64. package/dist/core/serverEvent.d.ts +42 -0
  65. package/dist/core/serverEvent.js +12 -0
  66. package/dist/core/serverEvent.js.map +1 -0
  67. package/dist/exports/client.d.ts +8 -2
  68. package/dist/exports/client.js +6 -1
  69. package/dist/exports/next.d.ts +2 -1
  70. package/dist/exports/next.js +2 -1
  71. package/dist/exports/react.d.ts +4 -0
  72. package/dist/exports/react.js +5 -0
  73. package/dist/exports/rsc.d.ts +8 -1
  74. package/dist/exports/rsc.js +7 -2
  75. package/dist/exports/tracker.d.ts +18 -0
  76. package/dist/exports/tracker.js +12 -0
  77. package/dist/exports/types.d.ts +14 -3
  78. package/dist/exports/types.js +2 -2
  79. package/dist/fields/AnalyticsPanelClient.js +2 -2
  80. package/dist/fields/AnalyticsPanelField.js +1 -1
  81. package/dist/fields/AnalyticsStatField.js +2 -2
  82. package/dist/fields/config/MetricSelectField.js +2 -2
  83. package/dist/fields/config/MetricSelectField.js.map +1 -1
  84. package/dist/fields/config/SourceSelectField.js +2 -2
  85. package/dist/fields/config/SourceSelectField.js.map +1 -1
  86. package/dist/fields/config/fetchSources.d.ts +5 -1
  87. package/dist/fields/config/narrow.js +2 -0
  88. package/dist/fields/config/narrow.js.map +1 -1
  89. package/dist/fields/readForDocument.d.ts +5 -0
  90. package/dist/fields/readForDocument.js +6 -6
  91. package/dist/fields/readForDocument.js.map +1 -1
  92. package/dist/goals/GoalSelectField.d.ts +7 -0
  93. package/dist/goals/GoalSelectField.js +77 -0
  94. package/dist/goals/GoalSelectField.js.map +1 -0
  95. package/dist/goals/collection.js +250 -0
  96. package/dist/goals/collection.js.map +1 -0
  97. package/dist/goals/currency.js +14 -0
  98. package/dist/goals/currency.js.map +1 -0
  99. package/dist/goals/fetchGoals.d.ts +18 -0
  100. package/dist/goals/fetchGoals.js +29 -0
  101. package/dist/goals/fetchGoals.js.map +1 -0
  102. package/dist/goals/goalField.d.ts +31 -0
  103. package/dist/goals/goalField.js +56 -0
  104. package/dist/goals/goalField.js.map +1 -0
  105. package/dist/goals/goalsEndpoint.d.ts +1 -0
  106. package/dist/goals/goalsEndpoint.js +55 -0
  107. package/dist/goals/goalsEndpoint.js.map +1 -0
  108. package/dist/goals/match.js +64 -0
  109. package/dist/goals/match.js.map +1 -0
  110. package/dist/goals/resolver.d.ts +8 -0
  111. package/dist/goals/resolver.js +147 -0
  112. package/dist/goals/resolver.js.map +1 -0
  113. package/dist/goals/trackGoalAction.d.ts +74 -0
  114. package/dist/goals/trackGoalAction.js +139 -0
  115. package/dist/goals/trackGoalAction.js.map +1 -0
  116. package/dist/goals/types.d.ts +33 -0
  117. package/dist/goals/types.js +7 -0
  118. package/dist/goals/types.js.map +1 -0
  119. package/dist/goals/useAnalyticsGoals.d.ts +20 -0
  120. package/dist/goals/useAnalyticsGoals.js +67 -0
  121. package/dist/goals/useAnalyticsGoals.js.map +1 -0
  122. package/dist/index.d.ts +11 -3
  123. package/dist/index.js +104 -17
  124. package/dist/index.js.map +1 -1
  125. package/dist/native/collections/events.js +21 -1
  126. package/dist/native/collections/events.js.map +1 -1
  127. package/dist/native/collections/rollups.js +24 -0
  128. package/dist/native/collections/rollups.js.map +1 -1
  129. package/dist/native/geo/maxmindResolver.js +2 -4
  130. package/dist/native/geo/maxmindResolver.js.map +1 -1
  131. package/dist/native/ingest/clientIp.js +15 -0
  132. package/dist/native/ingest/clientIp.js.map +1 -0
  133. package/dist/native/ingest/device.js +11 -3
  134. package/dist/native/ingest/device.js.map +1 -1
  135. package/dist/native/ingest/endpoint.d.ts +1 -0
  136. package/dist/native/ingest/endpoint.js +25 -4
  137. package/dist/native/ingest/endpoint.js.map +1 -1
  138. package/dist/native/ingest/flushBatch.js +4 -13
  139. package/dist/native/ingest/flushBatch.js.map +1 -1
  140. package/dist/native/ingest/normalizeEvent.d.ts +20 -0
  141. package/dist/native/ingest/normalizeEvent.js +78 -10
  142. package/dist/native/ingest/normalizeEvent.js.map +1 -1
  143. package/dist/native/ingest/serverTrack.d.ts +20 -0
  144. package/dist/native/ingest/serverTrack.js +99 -0
  145. package/dist/native/ingest/serverTrack.js.map +1 -0
  146. package/dist/native/ingest/validate.js +27 -0
  147. package/dist/native/ingest/validate.js.map +1 -0
  148. package/dist/native/nativeAdapter.d.ts +1 -1
  149. package/dist/native/nativeAdapter.js +38 -11
  150. package/dist/native/nativeAdapter.js.map +1 -1
  151. package/dist/native/query/eventAgg.js +39 -13
  152. package/dist/native/query/eventAgg.js.map +1 -1
  153. package/dist/native/retention/pruneTask.js +1 -1
  154. package/dist/native/rollupAcc.js +12 -1
  155. package/dist/native/rollupAcc.js.map +1 -1
  156. package/dist/native/rollups/bumpRollup.js +5 -1
  157. package/dist/native/rollups/bumpRollup.js.map +1 -1
  158. package/dist/native/rollups/deltas.js +28 -6
  159. package/dist/native/rollups/deltas.js.map +1 -1
  160. package/dist/native/rollups/insertIfNew.js +36 -2
  161. package/dist/native/rollups/insertIfNew.js.map +1 -1
  162. package/dist/next/captureRewrites.d.ts +41 -0
  163. package/dist/next/captureRewrites.js +56 -0
  164. package/dist/next/captureRewrites.js.map +1 -0
  165. package/dist/next/posthogProxyRewrites.d.ts +5 -0
  166. package/dist/next/posthogProxyRewrites.js +16 -21
  167. package/dist/next/posthogProxyRewrites.js.map +1 -1
  168. package/dist/plugin/documentEndpoint.js +28 -10
  169. package/dist/plugin/documentEndpoint.js.map +1 -1
  170. package/dist/plugin/paths.js +15 -1
  171. package/dist/plugin/paths.js.map +1 -1
  172. package/dist/plugin/queryEndpoint.js +113 -0
  173. package/dist/plugin/queryEndpoint.js.map +1 -0
  174. package/dist/plugin/readContextForRequest.js +71 -0
  175. package/dist/plugin/readContextForRequest.js.map +1 -0
  176. package/dist/plugin/realtimeEndpoint.js +6 -3
  177. package/dist/plugin/realtimeEndpoint.js.map +1 -1
  178. package/dist/plugin/runtime.d.ts +1 -0
  179. package/dist/plugin/runtime.js +31 -1
  180. package/dist/plugin/runtime.js.map +1 -1
  181. package/dist/plugin/scopeFieldBoot.js +22 -0
  182. package/dist/plugin/scopeFieldBoot.js.map +1 -0
  183. package/dist/plugin/sourcesEndpoint.js +13 -39
  184. package/dist/plugin/sourcesEndpoint.js.map +1 -1
  185. package/dist/plugin/warmTask.js +0 -0
  186. package/dist/plugin/warmTask.js.map +1 -1
  187. package/dist/providers/collection.js +71 -25
  188. package/dist/providers/collection.js.map +1 -1
  189. package/dist/providers/factory.js +8 -2
  190. package/dist/providers/factory.js.map +1 -1
  191. package/dist/providers/resolver.js.map +1 -1
  192. package/dist/query/dates.js +64 -0
  193. package/dist/query/dates.js.map +1 -0
  194. package/dist/query/errors.d.ts +17 -0
  195. package/dist/query/errors.js +10 -0
  196. package/dist/query/errors.js.map +1 -0
  197. package/dist/query/fetchQuery.d.ts +59 -0
  198. package/dist/query/fetchQuery.js +110 -0
  199. package/dist/query/fetchQuery.js.map +1 -0
  200. package/dist/query/parse.d.ts +22 -0
  201. package/dist/query/parse.js +168 -0
  202. package/dist/query/parse.js.map +1 -0
  203. package/dist/query/response.d.ts +36 -0
  204. package/dist/react/AnalyticsProvider.d.ts +43 -0
  205. package/dist/react/AnalyticsProvider.js +66 -0
  206. package/dist/react/AnalyticsProvider.js.map +1 -0
  207. package/dist/react/TrackerBoot.d.ts +22 -0
  208. package/dist/react/TrackerBoot.js +30 -0
  209. package/dist/react/TrackerBoot.js.map +1 -0
  210. package/dist/react/useAnalytics.d.ts +17 -0
  211. package/dist/react/useAnalytics.js +36 -0
  212. package/dist/react/useAnalytics.js.map +1 -0
  213. package/dist/rsc/AnalyticsScripts.d.ts +30 -0
  214. package/dist/rsc/AnalyticsScripts.js +41 -0
  215. package/dist/rsc/AnalyticsScripts.js.map +1 -0
  216. package/dist/surfacing/cacheStore.d.ts +1 -0
  217. package/dist/surfacing/cacheStore.js +18 -2
  218. package/dist/surfacing/cacheStore.js.map +1 -1
  219. package/dist/surfacing/engine.d.ts +1 -0
  220. package/dist/surfacing/engine.js +44 -4
  221. package/dist/surfacing/engine.js.map +1 -1
  222. package/dist/surfacing/queue.js +22 -6
  223. package/dist/surfacing/queue.js.map +1 -1
  224. package/dist/surfacing/rateLimiter.js +130 -0
  225. package/dist/surfacing/rateLimiter.js.map +1 -0
  226. package/dist/surfacing/retryPolicy.js +15 -0
  227. package/dist/surfacing/retryPolicy.js.map +1 -0
  228. package/dist/sync/syncTask.js +60 -33
  229. package/dist/sync/syncTask.js.map +1 -1
  230. package/dist/testing/memoryAdapter.d.ts +2 -0
  231. package/dist/testing/memoryAdapter.js +10 -0
  232. package/dist/testing/memoryAdapter.js.map +1 -1
  233. package/dist/timeframe/tz.js +17 -6
  234. package/dist/timeframe/tz.js.map +1 -1
  235. package/dist/tracker/autoCapture.d.ts +48 -0
  236. package/dist/tracker/autoCapture.js +129 -0
  237. package/dist/tracker/autoCapture.js.map +1 -0
  238. package/dist/tracker/consent.d.ts +24 -0
  239. package/dist/tracker/consent.js +48 -0
  240. package/dist/tracker/consent.js.map +1 -0
  241. package/dist/tracker/createTracker.d.ts +18 -0
  242. package/dist/tracker/createTracker.js +163 -0
  243. package/dist/tracker/createTracker.js.map +1 -0
  244. package/dist/tracker/initTracker.d.ts +22 -0
  245. package/dist/tracker/initTracker.js +33 -0
  246. package/dist/tracker/initTracker.js.map +1 -0
  247. package/dist/tracker/loadScript.d.ts +14 -0
  248. package/dist/tracker/loadScript.js +41 -0
  249. package/dist/tracker/loadScript.js.map +1 -0
  250. package/dist/tracker/pageTracking.d.ts +17 -0
  251. package/dist/tracker/pageTracking.js +38 -0
  252. package/dist/tracker/pageTracking.js.map +1 -0
  253. package/dist/tracker/registry.d.ts +27 -0
  254. package/dist/tracker/registry.js +73 -0
  255. package/dist/tracker/registry.js.map +1 -0
  256. package/dist/tracker/sinks/native.d.ts +22 -0
  257. package/dist/tracker/sinks/native.js +56 -0
  258. package/dist/tracker/sinks/native.js.map +1 -0
  259. package/dist/tracker/sinks/plausible.d.ts +14 -0
  260. package/dist/tracker/sinks/plausible.js +25 -0
  261. package/dist/tracker/sinks/plausible.js.map +1 -0
  262. package/dist/tracker/sinks/posthog.d.ts +14 -0
  263. package/dist/tracker/sinks/posthog.js +18 -0
  264. package/dist/tracker/sinks/posthog.js.map +1 -0
  265. package/dist/tracker/sinks/umami.d.ts +13 -0
  266. package/dist/tracker/sinks/umami.js +17 -0
  267. package/dist/tracker/sinks/umami.js.map +1 -0
  268. package/dist/tracker/sinks/vendor.d.ts +14 -0
  269. package/dist/tracker/sinks/vendor.js +66 -0
  270. package/dist/tracker/sinks/vendor.js.map +1 -0
  271. package/dist/tracker/transport.js +28 -0
  272. package/dist/tracker/transport.js.map +1 -0
  273. package/dist/tracker/types.d.ts +66 -0
  274. package/dist/translations/ar.js +104 -1
  275. package/dist/translations/ar.js.map +1 -1
  276. package/dist/translations/de.js +104 -1
  277. package/dist/translations/de.js.map +1 -1
  278. package/dist/translations/en.js +104 -1
  279. package/dist/translations/en.js.map +1 -1
  280. package/dist/translations/es.js +104 -1
  281. package/dist/translations/es.js.map +1 -1
  282. package/dist/translations/fr.js +104 -1
  283. package/dist/translations/fr.js.map +1 -1
  284. package/dist/translations/id.js +104 -1
  285. package/dist/translations/id.js.map +1 -1
  286. package/dist/translations/keys.d.ts +103 -0
  287. package/dist/translations/keys.js +104 -1
  288. package/dist/translations/keys.js.map +1 -1
  289. package/dist/translations/ko.js +104 -1
  290. package/dist/translations/ko.js.map +1 -1
  291. package/dist/translations/metricKeys.js +1 -1
  292. package/dist/translations/metricKeys.js.map +1 -1
  293. package/dist/translations/pt.js +104 -1
  294. package/dist/translations/pt.js.map +1 -1
  295. package/dist/translations/ru.js +104 -1
  296. package/dist/translations/ru.js.map +1 -1
  297. package/dist/translations/uk.js +104 -1
  298. package/dist/translations/uk.js.map +1 -1
  299. package/dist/translations/zh.js +104 -1
  300. package/dist/translations/zh.js.map +1 -1
  301. package/dist/view/AnalyticsNavLink.d.ts +19 -0
  302. package/dist/view/AnalyticsNavLink.js +40 -0
  303. package/dist/view/AnalyticsNavLink.js.map +1 -0
  304. package/dist/view/AnalyticsView.d.ts +23 -0
  305. package/dist/view/AnalyticsView.js +45 -0
  306. package/dist/view/AnalyticsView.js.map +1 -0
  307. package/dist/view/AnalyticsViewClient.d.ts +15 -0
  308. package/dist/view/AnalyticsViewClient.js +189 -0
  309. package/dist/view/AnalyticsViewClient.js.map +1 -0
  310. package/dist/view/authRedirect.js +32 -0
  311. package/dist/view/authRedirect.js.map +1 -0
  312. package/dist/view/conversionRate.js +18 -0
  313. package/dist/view/conversionRate.js.map +1 -0
  314. package/dist/view/dayRange.js +68 -0
  315. package/dist/view/dayRange.js.map +1 -0
  316. package/dist/view/gating.d.ts +1 -0
  317. package/dist/view/gating.js +105 -0
  318. package/dist/view/gating.js.map +1 -0
  319. package/dist/view/labels.js +44 -0
  320. package/dist/view/labels.js.map +1 -0
  321. package/dist/view/registerView.js +48 -0
  322. package/dist/view/registerView.js.map +1 -0
  323. package/dist/view/sections/Breakdowns.js +157 -0
  324. package/dist/view/sections/Breakdowns.js.map +1 -0
  325. package/dist/view/sections/EmptyStates.js +92 -0
  326. package/dist/view/sections/EmptyStates.js.map +1 -0
  327. package/dist/view/sections/FilterChips.js +41 -0
  328. package/dist/view/sections/FilterChips.js.map +1 -0
  329. package/dist/view/sections/GoalsPanel.js +81 -0
  330. package/dist/view/sections/GoalsPanel.js.map +1 -0
  331. package/dist/view/sections/OverviewCards.js +65 -0
  332. package/dist/view/sections/OverviewCards.js.map +1 -0
  333. package/dist/view/sections/RealtimeStrip.js +77 -0
  334. package/dist/view/sections/RealtimeStrip.js.map +1 -0
  335. package/dist/view/sections/Toolbar.js +179 -0
  336. package/dist/view/sections/Toolbar.js.map +1 -0
  337. package/dist/view/sections/Trend.js +119 -0
  338. package/dist/view/sections/Trend.js.map +1 -0
  339. package/dist/view/sections/styles.js +74 -0
  340. package/dist/view/sections/styles.js.map +1 -0
  341. package/dist/view/state.js +206 -0
  342. package/dist/view/state.js.map +1 -0
  343. package/dist/view/useViewQueries.js +150 -0
  344. package/dist/view/useViewQueries.js.map +1 -0
  345. package/dist/view/viewProps.d.ts +40 -0
  346. package/dist/view/viewProps.js +90 -0
  347. package/dist/view/viewProps.js.map +1 -0
  348. package/dist/widgets/AnalyticsBreakdownWidget.d.ts +2 -1
  349. package/dist/widgets/AnalyticsBreakdownWidget.js +22 -4
  350. package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
  351. package/dist/widgets/AnalyticsGoalsWidget.d.ts +14 -0
  352. package/dist/widgets/AnalyticsGoalsWidget.js +188 -0
  353. package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -0
  354. package/dist/widgets/AnalyticsMetricWidget.d.ts +2 -1
  355. package/dist/widgets/AnalyticsMetricWidget.js +35 -12
  356. package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
  357. package/dist/widgets/AnalyticsRealtimeWidget.d.ts +2 -1
  358. package/dist/widgets/AnalyticsRealtimeWidget.js +42 -22
  359. package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
  360. package/dist/widgets/AnalyticsTrendWidget.d.ts +2 -1
  361. package/dist/widgets/AnalyticsTrendWidget.js +51 -15
  362. package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
  363. package/dist/widgets/WidgetViewLink.js +17 -0
  364. package/dist/widgets/WidgetViewLink.js.map +1 -0
  365. package/dist/widgets/breakdownTypes.js +32 -0
  366. package/dist/widgets/breakdownTypes.js.map +1 -1
  367. package/dist/widgets/cardChrome.js +31 -7
  368. package/dist/widgets/cardChrome.js.map +1 -1
  369. package/dist/widgets/range.js +43 -12
  370. package/dist/widgets/range.js.map +1 -1
  371. package/dist/widgets/readForWidget.d.ts +12 -0
  372. package/dist/widgets/readForWidget.js +30 -19
  373. package/dist/widgets/readForWidget.js.map +1 -1
  374. package/dist/widgets/readForWidgetBreakdown.d.ts +15 -0
  375. package/dist/widgets/readForWidgetBreakdown.js +32 -20
  376. package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
  377. package/dist/widgets/readForWidgetGoals.d.ts +57 -0
  378. package/dist/widgets/readForWidgetGoals.js +126 -0
  379. package/dist/widgets/readForWidgetGoals.js.map +1 -0
  380. package/dist/widgets/readForWidgetRealtime.js +1 -1
  381. package/dist/widgets/readForWidgetSeries.d.ts +13 -0
  382. package/dist/widgets/readForWidgetSeries.js +56 -28
  383. package/dist/widgets/readForWidgetSeries.js.map +1 -1
  384. package/dist/widgets/registerWidgets.js +58 -9
  385. package/dist/widgets/registerWidgets.js.map +1 -1
  386. package/dist/widgets/types.js +16 -2
  387. package/dist/widgets/types.js.map +1 -1
  388. package/dist/widgets/viewLink.d.ts +22 -0
  389. package/dist/widgets/viewLink.js +83 -0
  390. package/dist/widgets/viewLink.js.map +1 -0
  391. package/package.json +25 -5
@@ -1,8 +1,9 @@
1
- import { getRuntime } from "./runtime.js";
1
+ import "./paths.js";
2
+ import { getRuntime, readAccessFor, requestTimezone } from "./runtime.js";
2
3
  import { TIMEFRAME_PRESETS } from "../timeframe/presets.js";
3
- import { readForField } from "../fields/readForDocument.js";
4
4
  import { METRIC_KEYS } from "../translations/metricKeys.js";
5
- import "./paths.js";
5
+ import { readForField } from "../fields/readForDocument.js";
6
+ import { parseDayOrInstant } from "../query/dates.js";
6
7
  //#region src/plugin/documentEndpoint.ts
7
8
  const KNOWN_METRICS = new Set(Object.keys(METRIC_KEYS));
8
9
  const MAX_METRICS = 8;
@@ -11,19 +12,33 @@ const parseMetrics = (raw) => {
11
12
  const metrics = raw.split(",").map((m) => m.trim()).filter((m) => KNOWN_METRICS.has(m));
12
13
  return metrics.length > 0 ? metrics.slice(0, MAX_METRICS) : null;
13
14
  };
14
- const parseRange = (from, to) => {
15
+ /**
16
+ * A custom window from the query string, read exactly like the query endpoint's: a
17
+ * `YYYY-MM-DD` day is the whole calendar day in the reporting timezone (`to` inclusive of
18
+ * its final instant), a datetime must carry `Z` or a `±HH:MM` offset, and anything else,
19
+ * including an offset-less datetime, is rejected. `from` equal to `to` is one whole day for
20
+ * day strings and a zero-width window for two instants, so only the latter is rejected.
21
+ */
22
+ const parseRange = (from, to, timezone) => {
15
23
  if (!from || !to) return null;
16
- const start = new Date(from);
17
- const end = new Date(to);
18
- if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime()) || start >= end) return null;
24
+ const start = parseDayOrInstant(from, {
25
+ timezone,
26
+ edge: "start"
27
+ });
28
+ const end = parseDayOrInstant(to, {
29
+ timezone,
30
+ edge: "end"
31
+ });
32
+ if (!start || !end || end.getTime() <= start.getTime()) return null;
19
33
  return {
20
34
  start,
21
35
  end
22
36
  };
23
37
  };
24
38
  /**
25
- * Authenticated GET handler behind the interactive document analytics panel. The
26
- * caller must be able to read the target document (enforced through `findByID`
39
+ * Authenticated GET handler behind the interactive document analytics panel, gated
40
+ * by `access.read` like every other read endpoint. The caller must also be able to
41
+ * read the target document (enforced through `findByID`
27
42
  * without `overrideAccess`), so analytics never leak for content the user cannot
28
43
  * see; an unreadable or missing document is a uniform 404. Timeframe, metrics, and
29
44
  * data source are whitelist-validated; `timeframe=custom` requires a parseable
@@ -33,12 +48,14 @@ const makeDocumentHandler = () => async (req) => {
33
48
  if (!req.user) return Response.json({ error: "unauthorized" }, { status: 401 });
34
49
  const runtime = getRuntime(req.payload);
35
50
  if (!runtime) return Response.json({ error: "unavailable" }, { status: 503 });
51
+ if (!await readAccessFor(runtime, req)) return Response.json({ error: "forbidden" }, { status: 403 });
36
52
  const params = new URL(req.url ?? "", "http://localhost").searchParams;
37
53
  const collection = params.get("collection") ?? "";
38
54
  const id = params.get("id") ?? "";
39
55
  if (!runtime.bindings[collection] || !id) return Response.json({ error: "not found" }, { status: 404 });
40
56
  const rawTimeframe = params.get("timeframe") ?? "last30days";
41
- const range = rawTimeframe === "custom" ? parseRange(params.get("from"), params.get("to")) : void 0;
57
+ const timezone = rawTimeframe === "custom" ? await requestTimezone(req) : void 0;
58
+ const range = timezone !== void 0 ? parseRange(params.get("from"), params.get("to"), timezone) : void 0;
42
59
  const timeframe = TIMEFRAME_PRESETS.includes(rawTimeframe) ? rawTimeframe : "last30days";
43
60
  if (rawTimeframe === "custom" && !range) return Response.json({ error: "invalid range" }, { status: 400 });
44
61
  const metrics = parseMetrics(params.get("metrics")) ?? [
@@ -67,6 +84,7 @@ const makeDocumentHandler = () => async (req) => {
67
84
  metrics,
68
85
  timeframe,
69
86
  range: range ?? void 0,
87
+ ...timezone !== void 0 ? { timezone } : {},
70
88
  adapterId: params.get("dataSource") ?? void 0,
71
89
  now: /* @__PURE__ */ new Date(),
72
90
  compare: params.get("compare") === "1",
@@ -1 +1 @@
1
- {"version":3,"file":"documentEndpoint.js","names":[],"sources":["../../src/plugin/documentEndpoint.ts"],"sourcesContent":["import type { CollectionSlug, PayloadHandler } from 'payload'\nimport type { BindingDoc } from '../binding/types'\nimport type { DateRange, MetricKey } from '../core/contract'\nimport { readForField } from '../fields/readForDocument'\nimport { TIMEFRAME_PRESETS, type TimeframePreset } from '../timeframe/presets'\nimport { METRIC_KEYS } from '../translations/metricKeys'\nimport { DOCUMENT_PATH } from './paths'\nimport { getRuntime } from './runtime'\n\nexport { DOCUMENT_PATH }\n\nconst KNOWN_METRICS = new Set(Object.keys(METRIC_KEYS) as MetricKey[])\nconst MAX_METRICS = 8\n\nconst parseMetrics = (raw: string | null): MetricKey[] | null => {\n\tif (!raw) {\n\t\treturn null\n\t}\n\tconst metrics = raw\n\t\t.split(',')\n\t\t.map((m) => m.trim())\n\t\t.filter((m): m is MetricKey => KNOWN_METRICS.has(m as MetricKey))\n\treturn metrics.length > 0 ? metrics.slice(0, MAX_METRICS) : null\n}\n\nconst parseRange = (from: string | null, to: string | null): DateRange | null => {\n\tif (!from || !to) {\n\t\treturn null\n\t}\n\tconst start = new Date(from)\n\tconst end = new Date(to)\n\tif (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime()) || start >= end) {\n\t\treturn null\n\t}\n\treturn { start, end }\n}\n\n/**\n * Authenticated GET handler behind the interactive document analytics panel. The\n * caller must be able to read the target document (enforced through `findByID`\n * without `overrideAccess`), so analytics never leak for content the user cannot\n * see; an unreadable or missing document is a uniform 404. Timeframe, metrics, and\n * data source are whitelist-validated; `timeframe=custom` requires a parseable\n * `from`/`to` pair.\n */\nexport const makeDocumentHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn Response.json({ error: 'unavailable' }, { status: 503 })\n\t}\n\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\tconst collection = params.get('collection') ?? ''\n\tconst id = params.get('id') ?? ''\n\tif (!runtime.bindings[collection] || !id) {\n\t\treturn Response.json({ error: 'not found' }, { status: 404 })\n\t}\n\tconst rawTimeframe = params.get('timeframe') ?? 'last30days'\n\tconst range =\n\t\trawTimeframe === 'custom' ? parseRange(params.get('from'), params.get('to')) : undefined\n\tconst timeframe: TimeframePreset = TIMEFRAME_PRESETS.includes(rawTimeframe as TimeframePreset)\n\t\t? (rawTimeframe as TimeframePreset)\n\t\t: 'last30days'\n\tif (rawTimeframe === 'custom' && !range) {\n\t\treturn Response.json({ error: 'invalid range' }, { status: 400 })\n\t}\n\tconst metrics = parseMetrics(params.get('metrics')) ?? [\n\t\t'pageviews',\n\t\t'visitors',\n\t\t'sessions',\n\t\t'avgDuration',\n\t]\n\tlet data: BindingDoc\n\ttry {\n\t\tdata = (await req.payload.findByID({\n\t\t\tcollection: collection as CollectionSlug,\n\t\t\tid,\n\t\t\tdepth: 0,\n\t\t\toverrideAccess: false,\n\t\t\tuser: req.user,\n\t\t\treq,\n\t\t})) as BindingDoc\n\t} catch {\n\t\treturn Response.json({ error: 'not found' }, { status: 404 })\n\t}\n\tconst result = await readForField({\n\t\treq,\n\t\tcollectionSlug: collection,\n\t\tdata,\n\t\tmetrics,\n\t\ttimeframe,\n\t\trange: range ?? undefined,\n\t\tadapterId: params.get('dataSource') ?? undefined,\n\t\tnow: new Date(),\n\t\tcompare: params.get('compare') === '1',\n\t\tseries: params.get('series') === '1',\n\t})\n\treturn Response.json(result)\n}\n"],"mappings":";;;;;;AAWA,MAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,WAAW,CAAgB;AACrE,MAAM,cAAc;AAEpB,MAAM,gBAAgB,QAA2C;CAChE,IAAI,CAAC,KACJ,OAAO;CAER,MAAM,UAAU,IACd,MAAM,GAAG,EACT,KAAK,MAAM,EAAE,KAAK,CAAC,EACnB,QAAQ,MAAsB,cAAc,IAAI,CAAc,CAAC;CACjE,OAAO,QAAQ,SAAS,IAAI,QAAQ,MAAM,GAAG,WAAW,IAAI;AAC7D;AAEA,MAAM,cAAc,MAAqB,OAAwC;CAChF,IAAI,CAAC,QAAQ,CAAC,IACb,OAAO;CAER,MAAM,QAAQ,IAAI,KAAK,IAAI;CAC3B,MAAM,MAAM,IAAI,KAAK,EAAE;CACvB,IAAI,OAAO,MAAM,MAAM,QAAQ,CAAC,KAAK,OAAO,MAAM,IAAI,QAAQ,CAAC,KAAK,SAAS,KAC5E,OAAO;CAER,OAAO;EAAE;EAAO;CAAI;AACrB;;;;;;;;;AAUA,MAAa,4BAA4C,OAAO,QAAQ;CACvE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO,SAAS,KAAK,EAAE,OAAO,cAAc,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE/D,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;CAC1D,MAAM,aAAa,OAAO,IAAI,YAAY,KAAK;CAC/C,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK;CAC/B,IAAI,CAAC,QAAQ,SAAS,eAAe,CAAC,IACrC,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE7D,MAAM,eAAe,OAAO,IAAI,WAAW,KAAK;CAChD,MAAM,QACL,iBAAiB,WAAW,WAAW,OAAO,IAAI,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,KAAA;CAChF,MAAM,YAA6B,kBAAkB,SAAS,YAA+B,IACzF,eACD;CACH,IAAI,iBAAiB,YAAY,CAAC,OACjC,OAAO,SAAS,KAAK,EAAE,OAAO,gBAAgB,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEjE,MAAM,UAAU,aAAa,OAAO,IAAI,SAAS,CAAC,KAAK;EACtD;EACA;EACA;EACA;CACD;CACA,IAAI;CACJ,IAAI;EACH,OAAQ,MAAM,IAAI,QAAQ,SAAS;GACtB;GACZ;GACA,OAAO;GACP,gBAAgB;GAChB,MAAM,IAAI;GACV;EACD,CAAC;CACF,QAAQ;EACP,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAC7D;CACA,MAAM,SAAS,MAAM,aAAa;EACjC;EACA,gBAAgB;EAChB;EACA;EACA;EACA,OAAO,SAAS,KAAA;EAChB,WAAW,OAAO,IAAI,YAAY,KAAK,KAAA;EACvC,qBAAK,IAAI,KAAK;EACd,SAAS,OAAO,IAAI,SAAS,MAAM;EACnC,QAAQ,OAAO,IAAI,QAAQ,MAAM;CAClC,CAAC;CACD,OAAO,SAAS,KAAK,MAAM;AAC5B"}
1
+ {"version":3,"file":"documentEndpoint.js","names":[],"sources":["../../src/plugin/documentEndpoint.ts"],"sourcesContent":["import type { CollectionSlug, PayloadHandler } from 'payload'\nimport type { BindingDoc } from '../binding/types'\nimport type { DateRange, MetricKey } from '../core/contract'\nimport { readForField } from '../fields/readForDocument'\nimport { parseDayOrInstant } from '../query/dates'\nimport { TIMEFRAME_PRESETS, type TimeframePreset } from '../timeframe/presets'\nimport { METRIC_KEYS } from '../translations/metricKeys'\nimport { DOCUMENT_PATH } from './paths'\nimport { getRuntime, readAccessFor, requestTimezone } from './runtime'\n\nexport { DOCUMENT_PATH }\n\nconst KNOWN_METRICS = new Set(Object.keys(METRIC_KEYS) as MetricKey[])\nconst MAX_METRICS = 8\n\nconst parseMetrics = (raw: string | null): MetricKey[] | null => {\n\tif (!raw) {\n\t\treturn null\n\t}\n\tconst metrics = raw\n\t\t.split(',')\n\t\t.map((m) => m.trim())\n\t\t.filter((m): m is MetricKey => KNOWN_METRICS.has(m as MetricKey))\n\treturn metrics.length > 0 ? metrics.slice(0, MAX_METRICS) : null\n}\n\n/**\n * A custom window from the query string, read exactly like the query endpoint's: a\n * `YYYY-MM-DD` day is the whole calendar day in the reporting timezone (`to` inclusive of\n * its final instant), a datetime must carry `Z` or a `±HH:MM` offset, and anything else,\n * including an offset-less datetime, is rejected. `from` equal to `to` is one whole day for\n * day strings and a zero-width window for two instants, so only the latter is rejected.\n */\nconst parseRange = (from: string | null, to: string | null, timezone: string): DateRange | null => {\n\tif (!from || !to) {\n\t\treturn null\n\t}\n\tconst start = parseDayOrInstant(from, { timezone, edge: 'start' })\n\tconst end = parseDayOrInstant(to, { timezone, edge: 'end' })\n\tif (!start || !end || end.getTime() <= start.getTime()) {\n\t\treturn null\n\t}\n\treturn { start, end }\n}\n\n/**\n * Authenticated GET handler behind the interactive document analytics panel, gated\n * by `access.read` like every other read endpoint. The caller must also be able to\n * read the target document (enforced through `findByID`\n * without `overrideAccess`), so analytics never leak for content the user cannot\n * see; an unreadable or missing document is a uniform 404. Timeframe, metrics, and\n * data source are whitelist-validated; `timeframe=custom` requires a parseable\n * `from`/`to` pair.\n */\nexport const makeDocumentHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn Response.json({ error: 'unavailable' }, { status: 503 })\n\t}\n\tif (!(await readAccessFor(runtime, req))) {\n\t\treturn Response.json({ error: 'forbidden' }, { status: 403 })\n\t}\n\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\tconst collection = params.get('collection') ?? ''\n\tconst id = params.get('id') ?? ''\n\tif (!runtime.bindings[collection] || !id) {\n\t\treturn Response.json({ error: 'not found' }, { status: 404 })\n\t}\n\tconst rawTimeframe = params.get('timeframe') ?? 'last30days'\n\t// Custom bounds name calendar days, so the reporting timezone has to be resolved before\n\t// they can be read; a preset resolves its window inside `readForField` as before.\n\tconst timezone = rawTimeframe === 'custom' ? await requestTimezone(req) : undefined\n\tconst range =\n\t\ttimezone !== undefined ? parseRange(params.get('from'), params.get('to'), timezone) : undefined\n\tconst timeframe: TimeframePreset = TIMEFRAME_PRESETS.includes(rawTimeframe as TimeframePreset)\n\t\t? (rawTimeframe as TimeframePreset)\n\t\t: 'last30days'\n\tif (rawTimeframe === 'custom' && !range) {\n\t\treturn Response.json({ error: 'invalid range' }, { status: 400 })\n\t}\n\tconst metrics = parseMetrics(params.get('metrics')) ?? [\n\t\t'pageviews',\n\t\t'visitors',\n\t\t'sessions',\n\t\t'avgDuration',\n\t]\n\tlet data: BindingDoc\n\ttry {\n\t\tdata = (await req.payload.findByID({\n\t\t\tcollection: collection as CollectionSlug,\n\t\t\tid,\n\t\t\tdepth: 0,\n\t\t\toverrideAccess: false,\n\t\t\tuser: req.user,\n\t\t\treq,\n\t\t})) as BindingDoc\n\t} catch {\n\t\treturn Response.json({ error: 'not found' }, { status: 404 })\n\t}\n\tconst result = await readForField({\n\t\treq,\n\t\tcollectionSlug: collection,\n\t\tdata,\n\t\tmetrics,\n\t\ttimeframe,\n\t\trange: range ?? undefined,\n\t\t...(timezone !== undefined ? { timezone } : {}),\n\t\tadapterId: params.get('dataSource') ?? undefined,\n\t\tnow: new Date(),\n\t\tcompare: params.get('compare') === '1',\n\t\tseries: params.get('series') === '1',\n\t})\n\treturn Response.json(result)\n}\n"],"mappings":";;;;;;;AAYA,MAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,WAAW,CAAgB;AACrE,MAAM,cAAc;AAEpB,MAAM,gBAAgB,QAA2C;CAChE,IAAI,CAAC,KACJ,OAAO;CAER,MAAM,UAAU,IACd,MAAM,GAAG,EACT,KAAK,MAAM,EAAE,KAAK,CAAC,EACnB,QAAQ,MAAsB,cAAc,IAAI,CAAc,CAAC;CACjE,OAAO,QAAQ,SAAS,IAAI,QAAQ,MAAM,GAAG,WAAW,IAAI;AAC7D;;;;;;;;AASA,MAAM,cAAc,MAAqB,IAAmB,aAAuC;CAClG,IAAI,CAAC,QAAQ,CAAC,IACb,OAAO;CAER,MAAM,QAAQ,kBAAkB,MAAM;EAAE;EAAU,MAAM;CAAQ,CAAC;CACjE,MAAM,MAAM,kBAAkB,IAAI;EAAE;EAAU,MAAM;CAAM,CAAC;CAC3D,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,QAAQ,KAAK,MAAM,QAAQ,GACpD,OAAO;CAER,OAAO;EAAE;EAAO;CAAI;AACrB;;;;;;;;;;AAWA,MAAa,4BAA4C,OAAO,QAAQ;CACvE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO,SAAS,KAAK,EAAE,OAAO,cAAc,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE/D,IAAI,CAAE,MAAM,cAAc,SAAS,GAAG,GACrC,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE7D,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;CAC1D,MAAM,aAAa,OAAO,IAAI,YAAY,KAAK;CAC/C,MAAM,KAAK,OAAO,IAAI,IAAI,KAAK;CAC/B,IAAI,CAAC,QAAQ,SAAS,eAAe,CAAC,IACrC,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE7D,MAAM,eAAe,OAAO,IAAI,WAAW,KAAK;CAGhD,MAAM,WAAW,iBAAiB,WAAW,MAAM,gBAAgB,GAAG,IAAI,KAAA;CAC1E,MAAM,QACL,aAAa,KAAA,IAAY,WAAW,OAAO,IAAI,MAAM,GAAG,OAAO,IAAI,IAAI,GAAG,QAAQ,IAAI,KAAA;CACvF,MAAM,YAA6B,kBAAkB,SAAS,YAA+B,IACzF,eACD;CACH,IAAI,iBAAiB,YAAY,CAAC,OACjC,OAAO,SAAS,KAAK,EAAE,OAAO,gBAAgB,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEjE,MAAM,UAAU,aAAa,OAAO,IAAI,SAAS,CAAC,KAAK;EACtD;EACA;EACA;EACA;CACD;CACA,IAAI;CACJ,IAAI;EACH,OAAQ,MAAM,IAAI,QAAQ,SAAS;GACtB;GACZ;GACA,OAAO;GACP,gBAAgB;GAChB,MAAM,IAAI;GACV;EACD,CAAC;CACF,QAAQ;EACP,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAC7D;CACA,MAAM,SAAS,MAAM,aAAa;EACjC;EACA,gBAAgB;EAChB;EACA;EACA;EACA,OAAO,SAAS,KAAA;EAChB,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,WAAW,OAAO,IAAI,YAAY,KAAK,KAAA;EACvC,qBAAK,IAAI,KAAK;EACd,SAAS,OAAO,IAAI,SAAS,MAAM;EACnC,QAAQ,OAAO,IAAI,QAAQ,MAAM;CAClC,CAAC;CACD,OAAO,SAAS,KAAK,MAAM;AAC5B"}
@@ -6,8 +6,22 @@
6
6
  */
7
7
  const DOCUMENT_PATH = "/analytics/document";
8
8
  const SOURCES_PATH = "/analytics/sources";
9
+ /** Authenticated goal list for the admin goal picker, per-request scope. */
10
+ const GOALS_PATH = "/analytics/goals";
11
+ /** Authenticated read endpoint over the surfacing engine, per-request scope. */
12
+ const QUERY_PATH = "/analytics/query";
9
13
  const REALTIME_PATH = "/analytics/realtime";
14
+ /** Mount of the public capture proxy; each slot is served under `${PROXY_PATH}/<slot>`. */
15
+ const PROXY_PATH = "/analytics/p";
16
+ /** Public tracker config, per-request scope. */
17
+ const TRACKER_PATH = "/analytics/tracker";
18
+ /**
19
+ * Default mount of the native ingest endpoint, and the fallback for the `ingestPath` the
20
+ * tracker config hands the browser. `native({ ingestPath })` moves both: the adapter
21
+ * declares the override through `ingest.path`, which the runtime lifts onto the config.
22
+ */
23
+ const INGEST_PATH = "/analytics/ingest";
10
24
  //#endregion
11
- export { DOCUMENT_PATH, REALTIME_PATH, SOURCES_PATH };
25
+ export { DOCUMENT_PATH, GOALS_PATH, INGEST_PATH, PROXY_PATH, QUERY_PATH, REALTIME_PATH, SOURCES_PATH, TRACKER_PATH };
12
26
 
13
27
  //# sourceMappingURL=paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","names":[],"sources":["../../src/plugin/paths.ts"],"sourcesContent":["/**\n * Endpoint paths shared between server registration and client fetchers. Kept in a\n * dependency-free leaf module so client components can import the path without\n * pulling server code into the bundle.\n */\nexport const DOCUMENT_PATH = '/analytics/document'\nexport const SOURCES_PATH = '/analytics/sources'\nexport const REALTIME_PATH = '/analytics/realtime'\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAC5B,MAAa,gBAAgB"}
1
+ {"version":3,"file":"paths.js","names":[],"sources":["../../src/plugin/paths.ts"],"sourcesContent":["/**\n * Endpoint paths shared between server registration and client fetchers. Kept in a\n * dependency-free leaf module so client components can import the path without\n * pulling server code into the bundle.\n */\nexport const DOCUMENT_PATH = '/analytics/document'\nexport const SOURCES_PATH = '/analytics/sources'\n/** Authenticated goal list for the admin goal picker, per-request scope. */\nexport const GOALS_PATH = '/analytics/goals'\n/** Authenticated read endpoint over the surfacing engine, per-request scope. */\nexport const QUERY_PATH = '/analytics/query'\nexport const REALTIME_PATH = '/analytics/realtime'\n/** Mount of the public capture proxy; each slot is served under `${PROXY_PATH}/<slot>`. */\nexport const PROXY_PATH = '/analytics/p'\n/** Public tracker config, per-request scope. */\nexport const TRACKER_PATH = '/analytics/tracker'\n/**\n * Default mount of the native ingest endpoint, and the fallback for the `ingestPath` the\n * tracker config hands the browser. `native({ ingestPath })` moves both: the adapter\n * declares the override through `ingest.path`, which the runtime lifts onto the config.\n */\nexport const INGEST_PATH = '/analytics/ingest'\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,eAAe;;AAE5B,MAAa,aAAa;;AAE1B,MAAa,aAAa;AAC1B,MAAa,gBAAgB;;AAE7B,MAAa,aAAa;;AAE1B,MAAa,eAAe;;;;;;AAM5B,MAAa,cAAc"}
@@ -0,0 +1,113 @@
1
+ import "./paths.js";
2
+ import "../core/contract.js";
3
+ import { getRuntime, platformReadGate, readAccessFor, resolveTimezoneFor } from "./runtime.js";
4
+ import { serializeCapabilities } from "../core/capabilities.js";
5
+ import { resolveQueryScope } from "../core/scopedRead.js";
6
+ import { previousWindow } from "../widgets/comparison.js";
7
+ import { queryError } from "../query/errors.js";
8
+ import { parseQueryParams, readParam } from "../query/parse.js";
9
+ import { resolveSourcesForRequest } from "./readContextForRequest.js";
10
+ //#region src/plugin/queryEndpoint.ts
11
+ /** Scope depends on the caller's cookies, so no shared cache may ever hold an answer. */
12
+ const NO_STORE = { "Cache-Control": "private, no-store" };
13
+ const errorResponse = (status, error, headers = {}) => Response.json({ error }, {
14
+ status,
15
+ headers: {
16
+ ...NO_STORE,
17
+ ...headers
18
+ }
19
+ });
20
+ const RETRY_AFTER = { "Retry-After": "30" };
21
+ const serializeQuery = (query) => ({
22
+ ...query,
23
+ dateRange: {
24
+ start: query.dateRange.start.toISOString(),
25
+ end: query.dateRange.end.toISOString()
26
+ }
27
+ });
28
+ /**
29
+ * Authenticated GET over the surfacing engine: the public read primitive the admin view
30
+ * and consumers' own dashboards are built on. Gating runs in a fixed order so a caller
31
+ * learns nothing from the answer it is not already entitled to: authentication, then
32
+ * `access.read`, then scope and source resolution (shared with the sources endpoint, so a
33
+ * tenant can select no source that endpoint does not list), then capability validation of
34
+ * every parameter against the selected source. Being listed is not sufficient: a shared
35
+ * source that cannot narrow to the caller's scope answers 403 with `param: 'source'`.
36
+ * Errors carry a code and the parameter at fault; adapter configuration and upstream error
37
+ * text never reach the response.
38
+ */
39
+ const makeQueryHandler = () => async (req) => {
40
+ if (!req.user) return errorResponse(401, queryError("unauthorized", "analytics: authentication required"));
41
+ const runtime = getRuntime(req.payload);
42
+ if (!runtime) return errorResponse(503, queryError("unavailable", "analytics: not available"), RETRY_AFTER);
43
+ let adapterId = "unresolved";
44
+ try {
45
+ if (!await readAccessFor(runtime, req)) return errorResponse(403, queryError("forbidden", "analytics: read access denied"));
46
+ const params = new URL(req.url ?? "", "http://localhost").searchParams;
47
+ const platformRead = platformReadGate(runtime, req);
48
+ const requestedScope = readParam(params, "scope");
49
+ if (requestedScope !== null && !await platformRead()) return errorResponse(400, queryError("untrusted_scope", "analytics: scope is not permitted for this request", "scope"));
50
+ const context = await resolveSourcesForRequest(req, {
51
+ platformRead,
52
+ ...requestedScope === null ? {} : { scope: requestedScope }
53
+ });
54
+ if (context.adapters.size === 0) return errorResponse(404, queryError("unknown_source", "analytics: no source is available for this request"));
55
+ const requestedSource = readParam(params, "source");
56
+ const adapter = context.adapters.get(requestedSource ?? context.defaultId ?? "");
57
+ if (!adapter) return errorResponse(404, queryError("unknown_source", "analytics: unknown source", "source"));
58
+ adapterId = adapter.id;
59
+ const queryScope = await resolveQueryScope({
60
+ runtime,
61
+ req,
62
+ scope: context.scope,
63
+ adapter,
64
+ platformRead
65
+ });
66
+ if (!queryScope.ok) return errorResponse(403, queryError("forbidden", "analytics: this source cannot be read for your scope", "source"));
67
+ const capabilities = serializeCapabilities(adapter.capabilities);
68
+ const parsed = parseQueryParams(params, {
69
+ capabilities,
70
+ timezone: await resolveTimezoneFor(runtime, req, context.scope === "*" ? null : context.scope)
71
+ });
72
+ if (!parsed.ok) return errorResponse(400, parsed.error);
73
+ const query = {
74
+ ...parsed.value.query,
75
+ ...queryScope.queryScope === void 0 ? {} : { scope: queryScope.queryScope }
76
+ };
77
+ let comparisonRange = null;
78
+ if (parsed.value.compare === "previous") {
79
+ comparisonRange = previousWindow(query.dateRange, query.timezone);
80
+ if (!comparisonRange) return errorResponse(400, queryError("invalid_param", "analytics: the range is too long to compare against a previous period", "compare"));
81
+ }
82
+ let result;
83
+ let comparison;
84
+ try {
85
+ [result, comparison] = await Promise.all([runtime.engine.read(adapter, query), comparisonRange ? runtime.engine.read(adapter, {
86
+ ...query,
87
+ dateRange: comparisonRange
88
+ }) : void 0]);
89
+ } catch (err) {
90
+ req.payload.logger?.warn(`analytics: query read failed for adapter "${adapter.id}": ${String(err)}`);
91
+ return errorResponse(503, queryError("unavailable", "analytics: source is temporarily unavailable"), RETRY_AFTER);
92
+ }
93
+ const body = {
94
+ result,
95
+ ...comparison ? { comparison } : {},
96
+ source: {
97
+ id: adapter.id,
98
+ label: adapter.label,
99
+ kind: runtime.configAdapterIds.has(adapter.id) ? "config" : "runtime"
100
+ },
101
+ capabilities,
102
+ query: serializeQuery(query)
103
+ };
104
+ return Response.json(body, { headers: NO_STORE });
105
+ } catch (err) {
106
+ req.payload.logger?.warn(`analytics: query failed for adapter "${adapterId}": ${String(err)}`);
107
+ return errorResponse(500, queryError("internal", "analytics: query failed"));
108
+ }
109
+ };
110
+ //#endregion
111
+ export { makeQueryHandler };
112
+
113
+ //# sourceMappingURL=queryEndpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryEndpoint.js","names":[],"sources":["../../src/plugin/queryEndpoint.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\nimport { serializeCapabilities } from '../core/capabilities'\nimport {\n\ttype AnalyticsQuery,\n\ttype AnalyticsResult,\n\ttype DateRange,\n\tPLATFORM_SCOPE,\n} from '../core/contract'\nimport { resolveQueryScope } from '../core/scopedRead'\nimport { type QueryError, queryError } from '../query/errors'\nimport { parseQueryParams, readParam } from '../query/parse'\nimport type { QueryResponse, SerializedAnalyticsQuery } from '../query/response'\nimport { previousWindow } from '../widgets/comparison'\nimport { QUERY_PATH } from './paths'\nimport { resolveSourcesForRequest } from './readContextForRequest'\nimport { getRuntime, platformReadGate, readAccessFor, resolveTimezoneFor } from './runtime'\n\nexport { QUERY_PATH }\n\n/** Scope depends on the caller's cookies, so no shared cache may ever hold an answer. */\nconst NO_STORE = { 'Cache-Control': 'private, no-store' }\n\nconst errorResponse = (\n\tstatus: number,\n\terror: QueryError,\n\theaders: Record<string, string> = {}\n): Response => Response.json({ error }, { status, headers: { ...NO_STORE, ...headers } })\n\n/** How long a client should wait out a provider outage before retrying the same read. */\nconst RETRY_AFTER_SECONDS = '30'\nconst RETRY_AFTER = { 'Retry-After': RETRY_AFTER_SECONDS }\n\nconst serializeQuery = (query: AnalyticsQuery): SerializedAnalyticsQuery => ({\n\t...query,\n\tdateRange: {\n\t\tstart: query.dateRange.start.toISOString(),\n\t\tend: query.dateRange.end.toISOString(),\n\t},\n})\n\n/**\n * Authenticated GET over the surfacing engine: the public read primitive the admin view\n * and consumers' own dashboards are built on. Gating runs in a fixed order so a caller\n * learns nothing from the answer it is not already entitled to: authentication, then\n * `access.read`, then scope and source resolution (shared with the sources endpoint, so a\n * tenant can select no source that endpoint does not list), then capability validation of\n * every parameter against the selected source. Being listed is not sufficient: a shared\n * source that cannot narrow to the caller's scope answers 403 with `param: 'source'`.\n * Errors carry a code and the parameter at fault; adapter configuration and upstream error\n * text never reach the response.\n */\nexport const makeQueryHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn errorResponse(401, queryError('unauthorized', 'analytics: authentication required'))\n\t}\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\t// Both `unavailable` answers are retryable, so both carry the same delay: a client\n\t\t// backs off identically whether the plugin is still booting or a provider is down.\n\t\treturn errorResponse(503, queryError('unavailable', 'analytics: not available'), RETRY_AFTER)\n\t}\n\tlet adapterId = 'unresolved'\n\ttry {\n\t\tif (!(await readAccessFor(runtime, req))) {\n\t\t\treturn errorResponse(403, queryError('forbidden', 'analytics: read access denied'))\n\t\t}\n\t\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\t\tconst platformRead = platformReadGate(runtime, req)\n\t\tconst requestedScope = readParam(params, 'scope')\n\t\tif (requestedScope !== null && !(await platformRead())) {\n\t\t\treturn errorResponse(\n\t\t\t\t400,\n\t\t\t\tqueryError('untrusted_scope', 'analytics: scope is not permitted for this request', 'scope')\n\t\t\t)\n\t\t}\n\t\tconst context = await resolveSourcesForRequest(req, {\n\t\t\tplatformRead,\n\t\t\t...(requestedScope === null ? {} : { scope: requestedScope }),\n\t\t})\n\t\tif (context.adapters.size === 0) {\n\t\t\treturn errorResponse(\n\t\t\t\t404,\n\t\t\t\tqueryError('unknown_source', 'analytics: no source is available for this request')\n\t\t\t)\n\t\t}\n\t\tconst requestedSource = readParam(params, 'source')\n\t\tconst adapter = context.adapters.get(requestedSource ?? context.defaultId ?? '')\n\t\tif (!adapter) {\n\t\t\treturn errorResponse(404, queryError('unknown_source', 'analytics: unknown source', 'source'))\n\t\t}\n\t\tadapterId = adapter.id\n\t\tconst queryScope = await resolveQueryScope({\n\t\t\truntime,\n\t\t\treq,\n\t\t\tscope: context.scope,\n\t\t\tadapter,\n\t\t\tplatformRead,\n\t\t})\n\t\tif (!queryScope.ok) {\n\t\t\treturn errorResponse(\n\t\t\t\t403,\n\t\t\t\tqueryError('forbidden', 'analytics: this source cannot be read for your scope', 'source')\n\t\t\t)\n\t\t}\n\t\tconst capabilities = serializeCapabilities(adapter.capabilities)\n\t\tconst timezone = await resolveTimezoneFor(\n\t\t\truntime,\n\t\t\treq,\n\t\t\tcontext.scope === PLATFORM_SCOPE ? null : context.scope\n\t\t)\n\t\tconst parsed = parseQueryParams(params, { capabilities, timezone })\n\t\tif (!parsed.ok) {\n\t\t\treturn errorResponse(400, parsed.error)\n\t\t}\n\t\tconst query: AnalyticsQuery = {\n\t\t\t...parsed.value.query,\n\t\t\t...(queryScope.queryScope === undefined ? {} : { scope: queryScope.queryScope }),\n\t\t}\n\t\tlet comparisonRange: DateRange | null = null\n\t\tif (parsed.value.compare === 'previous') {\n\t\t\tcomparisonRange = previousWindow(query.dateRange, query.timezone)\n\t\t\tif (!comparisonRange) {\n\t\t\t\treturn errorResponse(\n\t\t\t\t\t400,\n\t\t\t\t\tqueryError(\n\t\t\t\t\t\t'invalid_param',\n\t\t\t\t\t\t'analytics: the range is too long to compare against a previous period',\n\t\t\t\t\t\t'compare'\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tlet result: AnalyticsResult\n\t\tlet comparison: AnalyticsResult | undefined\n\t\ttry {\n\t\t\t;[result, comparison] = await Promise.all([\n\t\t\t\truntime.engine.read(adapter, query),\n\t\t\t\tcomparisonRange\n\t\t\t\t\t? runtime.engine.read(adapter, { ...query, dateRange: comparisonRange })\n\t\t\t\t\t: undefined,\n\t\t\t])\n\t\t} catch (err) {\n\t\t\t// Neither a fresh nor a stale entry survived the read: the source is down, not the\n\t\t\t// request wrong, so the client is told to retry rather than to change anything.\n\t\t\treq.payload.logger?.warn(\n\t\t\t\t`analytics: query read failed for adapter \"${adapter.id}\": ${String(err)}`\n\t\t\t)\n\t\t\treturn errorResponse(\n\t\t\t\t503,\n\t\t\t\tqueryError('unavailable', 'analytics: source is temporarily unavailable'),\n\t\t\t\tRETRY_AFTER\n\t\t\t)\n\t\t}\n\t\tconst body: QueryResponse = {\n\t\t\tresult,\n\t\t\t...(comparison ? { comparison } : {}),\n\t\t\tsource: {\n\t\t\t\tid: adapter.id,\n\t\t\t\tlabel: adapter.label,\n\t\t\t\tkind: runtime.configAdapterIds.has(adapter.id) ? 'config' : 'runtime',\n\t\t\t},\n\t\t\tcapabilities,\n\t\t\tquery: serializeQuery(query),\n\t\t}\n\t\treturn Response.json(body, { headers: NO_STORE })\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: query failed for adapter \"${adapterId}\": ${String(err)}`)\n\t\treturn errorResponse(500, queryError('internal', 'analytics: query failed'))\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,WAAW,EAAE,iBAAiB,oBAAoB;AAExD,MAAM,iBACL,QACA,OACA,UAAkC,CAAC,MACrB,SAAS,KAAK,EAAE,MAAM,GAAG;CAAE;CAAQ,SAAS;EAAE,GAAG;EAAU,GAAG;CAAQ;AAAE,CAAC;AAIxF,MAAM,cAAc,EAAE,eAAe,KAAoB;AAEzD,MAAM,kBAAkB,WAAqD;CAC5E,GAAG;CACH,WAAW;EACV,OAAO,MAAM,UAAU,MAAM,YAAY;EACzC,KAAK,MAAM,UAAU,IAAI,YAAY;CACtC;AACD;;;;;;;;;;;;AAaA,MAAa,yBAAyC,OAAO,QAAQ;CACpE,IAAI,CAAC,IAAI,MACR,OAAO,cAAc,KAAK,WAAW,gBAAgB,oCAAoC,CAAC;CAE3F,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SAGJ,OAAO,cAAc,KAAK,WAAW,eAAe,0BAA0B,GAAG,WAAW;CAE7F,IAAI,YAAY;CAChB,IAAI;EACH,IAAI,CAAE,MAAM,cAAc,SAAS,GAAG,GACrC,OAAO,cAAc,KAAK,WAAW,aAAa,+BAA+B,CAAC;EAEnF,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;EAC1D,MAAM,eAAe,iBAAiB,SAAS,GAAG;EAClD,MAAM,iBAAiB,UAAU,QAAQ,OAAO;EAChD,IAAI,mBAAmB,QAAQ,CAAE,MAAM,aAAa,GACnD,OAAO,cACN,KACA,WAAW,mBAAmB,sDAAsD,OAAO,CAC5F;EAED,MAAM,UAAU,MAAM,yBAAyB,KAAK;GACnD;GACA,GAAI,mBAAmB,OAAO,CAAC,IAAI,EAAE,OAAO,eAAe;EAC5D,CAAC;EACD,IAAI,QAAQ,SAAS,SAAS,GAC7B,OAAO,cACN,KACA,WAAW,kBAAkB,oDAAoD,CAClF;EAED,MAAM,kBAAkB,UAAU,QAAQ,QAAQ;EAClD,MAAM,UAAU,QAAQ,SAAS,IAAI,mBAAmB,QAAQ,aAAa,EAAE;EAC/E,IAAI,CAAC,SACJ,OAAO,cAAc,KAAK,WAAW,kBAAkB,6BAA6B,QAAQ,CAAC;EAE9F,YAAY,QAAQ;EACpB,MAAM,aAAa,MAAM,kBAAkB;GAC1C;GACA;GACA,OAAO,QAAQ;GACf;GACA;EACD,CAAC;EACD,IAAI,CAAC,WAAW,IACf,OAAO,cACN,KACA,WAAW,aAAa,wDAAwD,QAAQ,CACzF;EAED,MAAM,eAAe,sBAAsB,QAAQ,YAAY;EAM/D,MAAM,SAAS,iBAAiB,QAAQ;GAAE;GAAc,UAAA,MALjC,mBACtB,SACA,KACA,QAAQ,UAAA,MAA2B,OAAO,QAAQ,KACnD;EACiE,CAAC;EAClE,IAAI,CAAC,OAAO,IACX,OAAO,cAAc,KAAK,OAAO,KAAK;EAEvC,MAAM,QAAwB;GAC7B,GAAG,OAAO,MAAM;GAChB,GAAI,WAAW,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,WAAW,WAAW;EAC/E;EACA,IAAI,kBAAoC;EACxC,IAAI,OAAO,MAAM,YAAY,YAAY;GACxC,kBAAkB,eAAe,MAAM,WAAW,MAAM,QAAQ;GAChE,IAAI,CAAC,iBACJ,OAAO,cACN,KACA,WACC,iBACA,yEACA,SACD,CACD;EAEF;EACA,IAAI;EACJ,IAAI;EACJ,IAAI;GACF,CAAC,QAAQ,cAAc,MAAM,QAAQ,IAAI,CACzC,QAAQ,OAAO,KAAK,SAAS,KAAK,GAClC,kBACG,QAAQ,OAAO,KAAK,SAAS;IAAE,GAAG;IAAO,WAAW;GAAgB,CAAC,IACrE,KAAA,CACJ,CAAC;EACF,SAAS,KAAK;GAGb,IAAI,QAAQ,QAAQ,KACnB,6CAA6C,QAAQ,GAAG,KAAK,OAAO,GAAG,GACxE;GACA,OAAO,cACN,KACA,WAAW,eAAe,8CAA8C,GACxE,WACD;EACD;EACA,MAAM,OAAsB;GAC3B;GACA,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;GACnC,QAAQ;IACP,IAAI,QAAQ;IACZ,OAAO,QAAQ;IACf,MAAM,QAAQ,iBAAiB,IAAI,QAAQ,EAAE,IAAI,WAAW;GAC7D;GACA;GACA,OAAO,eAAe,KAAK;EAC5B;EACA,OAAO,SAAS,KAAK,MAAM,EAAE,SAAS,SAAS,CAAC;CACjD,SAAS,KAAK;EACb,IAAI,QAAQ,QAAQ,KAAK,wCAAwC,UAAU,KAAK,OAAO,GAAG,GAAG;EAC7F,OAAO,cAAc,KAAK,WAAW,YAAY,yBAAyB,CAAC;CAC5E;AACD"}
@@ -0,0 +1,71 @@
1
+ import "../core/contract.js";
2
+ import { getRuntime, platformReadGate, resolveRegistryFor, resolveScopeFor } from "./runtime.js";
3
+ import { serializeCapabilities } from "../core/capabilities.js";
4
+ //#region src/plugin/readContextForRequest.ts
5
+ const empty = () => ({
6
+ sources: [],
7
+ defaultId: null,
8
+ adapters: /* @__PURE__ */ new Map(),
9
+ scope: null
10
+ });
11
+ const fromRegistry = (args) => {
12
+ const { runtime, registry, scope } = args;
13
+ const adapters = registry.all();
14
+ return {
15
+ sources: adapters.map((adapter) => ({
16
+ id: adapter.id,
17
+ label: adapter.label,
18
+ kind: runtime.configAdapterIds.has(adapter.id) ? "config" : "runtime",
19
+ capabilities: serializeCapabilities(adapter.capabilities)
20
+ })),
21
+ defaultId: registry.default().id,
22
+ adapters: new Map(adapters.map((adapter) => [adapter.id, adapter])),
23
+ scope
24
+ };
25
+ };
26
+ /**
27
+ * The sources a request may read, resolved once for both read endpoints: the request's
28
+ * own scope (or a trusted explicit one), the per-scope registry, and each adapter's
29
+ * serialized capabilities. Two resolutions are cross-scope and fail closed behind
30
+ * `platformRead`: a scopeResolver answering the `'*'` marker, and, on a scoped install, one
31
+ * answering no scope at all, which is ambiguous rather than install-wide (returning null
32
+ * usually means "no tenant selected"). A failed resolution resolves nothing too, since it is
33
+ * indistinguishable from a forged one. An unscoped install falls back to the static config
34
+ * registry on failure.
35
+ */
36
+ const resolveSourcesForRequest = async (req, args = {}) => {
37
+ const runtime = getRuntime(req.payload);
38
+ if (!runtime) return empty();
39
+ const allowed = args.platformRead ?? platformReadGate(runtime, req);
40
+ try {
41
+ let scope;
42
+ if (args.scope !== void 0) {
43
+ if (!await allowed()) return empty();
44
+ scope = args.scope;
45
+ } else {
46
+ scope = await resolveScopeFor(runtime, req);
47
+ if ((scope === "*" || runtime.scoped && scope === null) && !await allowed()) return empty();
48
+ }
49
+ return fromRegistry({
50
+ runtime,
51
+ registry: await resolveRegistryFor(runtime, {
52
+ payload: req.payload,
53
+ req,
54
+ scope: scope === "*" ? null : scope
55
+ }),
56
+ scope
57
+ });
58
+ } catch (err) {
59
+ req.payload.logger?.warn(`analytics: source resolution failed: ${String(err)}`);
60
+ if (runtime.scoped) return empty();
61
+ return fromRegistry({
62
+ runtime,
63
+ registry: runtime.registry,
64
+ scope: null
65
+ });
66
+ }
67
+ };
68
+ //#endregion
69
+ export { resolveSourcesForRequest };
70
+
71
+ //# sourceMappingURL=readContextForRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readContextForRequest.js","names":[],"sources":["../../src/plugin/readContextForRequest.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { type SerializedCapabilities, serializeCapabilities } from '../core/capabilities'\nimport { type AnalyticsAdapter, PLATFORM_SCOPE } from '../core/contract'\nimport type { AdapterRegistry } from '../core/registry'\nimport type { QuerySourceRef } from '../query/response'\nimport {\n\ttype AnalyticsRuntime,\n\tgetRuntime,\n\ttype PlatformReadGate,\n\tplatformReadGate,\n\tresolveRegistryFor,\n\tresolveScopeFor,\n} from './runtime'\n\n/** One readable source on the wire: its identity plus the capabilities a client gates on. */\nexport interface RequestSource extends QuerySourceRef {\n\tcapabilities: SerializedCapabilities\n}\n\nexport interface RequestSources {\n\t/** Wire rows for the resolved scope, in registry order; empty when none resolve. */\n\tsources: RequestSource[]\n\tdefaultId: string | null\n\t/** The adapters behind `sources`, for callers that read through them. */\n\tadapters: ReadonlyMap<string, AnalyticsAdapter>\n\t/** Scope the sources were resolved for; null is install-wide, `*` is cross-scope. */\n\tscope: string | null\n}\n\nexport interface ResolveSourcesArgs {\n\t/**\n\t * Read another scope's sources instead of the request's own. Evaluated behind\n\t * `access.platformRead`; a denied override resolves nothing at all.\n\t */\n\tscope?: string | null\n\t/** Shared `platformRead` decision; one is created per call when omitted. */\n\tplatformRead?: PlatformReadGate\n}\n\nconst empty = (): RequestSources => ({\n\tsources: [],\n\tdefaultId: null,\n\tadapters: new Map(),\n\tscope: null,\n})\n\nconst fromRegistry = (args: {\n\truntime: AnalyticsRuntime\n\tregistry: AdapterRegistry\n\tscope: string | null\n}): RequestSources => {\n\tconst { runtime, registry, scope } = args\n\tconst adapters = registry.all()\n\treturn {\n\t\tsources: adapters.map((adapter) => ({\n\t\t\tid: adapter.id,\n\t\t\tlabel: adapter.label,\n\t\t\tkind: runtime.configAdapterIds.has(adapter.id) ? ('config' as const) : ('runtime' as const),\n\t\t\tcapabilities: serializeCapabilities(adapter.capabilities),\n\t\t})),\n\t\tdefaultId: registry.default().id,\n\t\tadapters: new Map(adapters.map((adapter) => [adapter.id, adapter])),\n\t\tscope,\n\t}\n}\n\n/**\n * The sources a request may read, resolved once for both read endpoints: the request's\n * own scope (or a trusted explicit one), the per-scope registry, and each adapter's\n * serialized capabilities. Two resolutions are cross-scope and fail closed behind\n * `platformRead`: a scopeResolver answering the `'*'` marker, and, on a scoped install, one\n * answering no scope at all, which is ambiguous rather than install-wide (returning null\n * usually means \"no tenant selected\"). A failed resolution resolves nothing too, since it is\n * indistinguishable from a forged one. An unscoped install falls back to the static config\n * registry on failure.\n */\nexport const resolveSourcesForRequest = async (\n\treq: PayloadRequest,\n\targs: ResolveSourcesArgs = {}\n): Promise<RequestSources> => {\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn empty()\n\t}\n\tconst allowed = args.platformRead ?? platformReadGate(runtime, req)\n\ttry {\n\t\tlet scope: string | null\n\t\tif (args.scope !== undefined) {\n\t\t\tif (!(await allowed())) {\n\t\t\t\treturn empty()\n\t\t\t}\n\t\t\tscope = args.scope\n\t\t} else {\n\t\t\tscope = await resolveScopeFor(runtime, req)\n\t\t\tconst crossScope = scope === PLATFORM_SCOPE || (runtime.scoped && scope === null)\n\t\t\tif (crossScope && !(await allowed())) {\n\t\t\t\treturn empty()\n\t\t\t}\n\t\t}\n\t\tconst registry = await resolveRegistryFor(runtime, {\n\t\t\tpayload: req.payload,\n\t\t\treq,\n\t\t\tscope: scope === PLATFORM_SCOPE ? null : scope,\n\t\t})\n\t\treturn fromRegistry({ runtime, registry, scope })\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: source resolution failed: ${String(err)}`)\n\t\tif (runtime.scoped) {\n\t\t\treturn empty()\n\t\t}\n\t\treturn fromRegistry({ runtime, registry: runtime.registry, scope: null })\n\t}\n}\n"],"mappings":";;;;AAuCA,MAAM,eAA+B;CACpC,SAAS,CAAC;CACV,WAAW;CACX,0BAAU,IAAI,IAAI;CAClB,OAAO;AACR;AAEA,MAAM,gBAAgB,SAIA;CACrB,MAAM,EAAE,SAAS,UAAU,UAAU;CACrC,MAAM,WAAW,SAAS,IAAI;CAC9B,OAAO;EACN,SAAS,SAAS,KAAK,aAAa;GACnC,IAAI,QAAQ;GACZ,OAAO,QAAQ;GACf,MAAM,QAAQ,iBAAiB,IAAI,QAAQ,EAAE,IAAK,WAAsB;GACxE,cAAc,sBAAsB,QAAQ,YAAY;EACzD,EAAE;EACF,WAAW,SAAS,QAAQ,EAAE;EAC9B,UAAU,IAAI,IAAI,SAAS,KAAK,YAAY,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;EAClE;CACD;AACD;;;;;;;;;;;AAYA,MAAa,2BAA2B,OACvC,KACA,OAA2B,CAAC,MACC;CAC7B,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO,MAAM;CAEd,MAAM,UAAU,KAAK,gBAAgB,iBAAiB,SAAS,GAAG;CAClE,IAAI;EACH,IAAI;EACJ,IAAI,KAAK,UAAU,KAAA,GAAW;GAC7B,IAAI,CAAE,MAAM,QAAQ,GACnB,OAAO,MAAM;GAEd,QAAQ,KAAK;EACd,OAAO;GACN,QAAQ,MAAM,gBAAgB,SAAS,GAAG;GAE1C,KADmB,UAAA,OAA6B,QAAQ,UAAU,UAAU,SAC1D,CAAE,MAAM,QAAQ,GACjC,OAAO,MAAM;EAEf;EAMA,OAAO,aAAa;GAAE;GAAS,UAAA,MALR,mBAAmB,SAAS;IAClD,SAAS,IAAI;IACb;IACA,OAAO,UAAA,MAA2B,OAAO;GAC1C,CAAC;GACwC;EAAM,CAAC;CACjD,SAAS,KAAK;EACb,IAAI,QAAQ,QAAQ,KAAK,wCAAwC,OAAO,GAAG,GAAG;EAC9E,IAAI,QAAQ,QACX,OAAO,MAAM;EAEd,OAAO,aAAa;GAAE;GAAS,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;CACzE;AACD"}
@@ -1,4 +1,5 @@
1
1
  import "./paths.js";
2
+ import { getRuntime, readAccessFor } from "./runtime.js";
2
3
  import { readForWidgetRealtime } from "../widgets/readForWidgetRealtime.js";
3
4
  //#region src/plugin/realtimeEndpoint.ts
4
5
  const ALLOWED_METRICS = ["visitors", "pageviews"];
@@ -11,12 +12,14 @@ const ALLOWED_WINDOWS = [
11
12
  const DEFAULT_WINDOW = 30;
12
13
  /**
13
14
  * Authenticated GET handler for the realtime widget poller. Reads + clamps the query
14
- * params, then delegates to readForWidgetRealtime. Returns 401 for an anonymous request.
15
- * The gate is any authenticated user (not admin-panel access specifically); the response
16
- * is integer counts only. Tightening to admin-only is a post-v1 option.
15
+ * params, then delegates to readForWidgetRealtime. Returns 401 for an anonymous request
16
+ * and 403 when `access.read` denies, which defaults to any authenticated user (not
17
+ * admin-panel access specifically); the response is integer counts only.
17
18
  */
18
19
  const makeRealtimeHandler = () => async (req) => {
19
20
  if (!req.user) return Response.json({ error: "unauthorized" }, { status: 401 });
21
+ const runtime = getRuntime(req.payload);
22
+ if (runtime && !await readAccessFor(runtime, req)) return Response.json({ error: "forbidden" }, { status: 403 });
20
23
  const params = new URL(req.url ?? "", "http://localhost").searchParams;
21
24
  const rawMetric = params.get("metric");
22
25
  const metric = ALLOWED_METRICS.includes(rawMetric) ? rawMetric : "visitors";
@@ -1 +1 @@
1
- {"version":3,"file":"realtimeEndpoint.js","names":[],"sources":["../../src/plugin/realtimeEndpoint.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\nimport type { MetricKey } from '../core/contract'\nimport { readForWidgetRealtime } from '../widgets/readForWidgetRealtime'\nimport { REALTIME_PATH } from './paths'\n\nexport { REALTIME_PATH }\n\nconst ALLOWED_METRICS: MetricKey[] = ['visitors', 'pageviews']\nconst ALLOWED_WINDOWS = [5, 15, 30, 60]\nconst DEFAULT_WINDOW = 30\n\n/**\n * Authenticated GET handler for the realtime widget poller. Reads + clamps the query\n * params, then delegates to readForWidgetRealtime. Returns 401 for an anonymous request.\n * The gate is any authenticated user (not admin-panel access specifically); the response\n * is integer counts only. Tightening to admin-only is a post-v1 option.\n */\nexport const makeRealtimeHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\tconst rawMetric = params.get('metric')\n\tconst metric: MetricKey = ALLOWED_METRICS.includes(rawMetric as MetricKey)\n\t\t? (rawMetric as MetricKey)\n\t\t: 'visitors'\n\tconst rawWindow = Number(params.get('windowMinutes'))\n\tconst windowMinutes = ALLOWED_WINDOWS.includes(rawWindow) ? rawWindow : DEFAULT_WINDOW\n\tconst dataSource = params.get('dataSource') ?? undefined\n\tconst result = await readForWidgetRealtime({\n\t\treq,\n\t\tmetric,\n\t\twindowMinutes,\n\t\tadapterId: dataSource,\n\t\tnow: new Date(),\n\t})\n\treturn Response.json(result)\n}\n"],"mappings":";;;AAOA,MAAM,kBAA+B,CAAC,YAAY,WAAW;AAC7D,MAAM,kBAAkB;CAAC;CAAG;CAAI;CAAI;AAAE;AACtC,MAAM,iBAAiB;;;;;;;AAQvB,MAAa,4BAA4C,OAAO,QAAQ;CACvE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;CAC1D,MAAM,YAAY,OAAO,IAAI,QAAQ;CACrC,MAAM,SAAoB,gBAAgB,SAAS,SAAsB,IACrE,YACD;CACH,MAAM,YAAY,OAAO,OAAO,IAAI,eAAe,CAAC;CAGpD,MAAM,SAAS,MAAM,sBAAsB;EAC1C;EACA;EACA,eALqB,gBAAgB,SAAS,SAAS,IAAI,YAAY;EAMvE,WALkB,OAAO,IAAI,YAAY,KAAK,KAAA;EAM9C,qBAAK,IAAI,KAAK;CACf,CAAC;CACD,OAAO,SAAS,KAAK,MAAM;AAC5B"}
1
+ {"version":3,"file":"realtimeEndpoint.js","names":[],"sources":["../../src/plugin/realtimeEndpoint.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\nimport type { MetricKey } from '../core/contract'\nimport { readForWidgetRealtime } from '../widgets/readForWidgetRealtime'\nimport { REALTIME_PATH } from './paths'\nimport { getRuntime, readAccessFor } from './runtime'\n\nexport { REALTIME_PATH }\n\nconst ALLOWED_METRICS: MetricKey[] = ['visitors', 'pageviews']\nconst ALLOWED_WINDOWS = [5, 15, 30, 60]\nconst DEFAULT_WINDOW = 30\n\n/**\n * Authenticated GET handler for the realtime widget poller. Reads + clamps the query\n * params, then delegates to readForWidgetRealtime. Returns 401 for an anonymous request\n * and 403 when `access.read` denies, which defaults to any authenticated user (not\n * admin-panel access specifically); the response is integer counts only.\n */\nexport const makeRealtimeHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst runtime = getRuntime(req.payload)\n\t// No runtime means no adapter to read, so the skipped gate protects no data.\n\tif (runtime && !(await readAccessFor(runtime, req))) {\n\t\treturn Response.json({ error: 'forbidden' }, { status: 403 })\n\t}\n\tconst params = new URL(req.url ?? '', 'http://localhost').searchParams\n\tconst rawMetric = params.get('metric')\n\tconst metric: MetricKey = ALLOWED_METRICS.includes(rawMetric as MetricKey)\n\t\t? (rawMetric as MetricKey)\n\t\t: 'visitors'\n\tconst rawWindow = Number(params.get('windowMinutes'))\n\tconst windowMinutes = ALLOWED_WINDOWS.includes(rawWindow) ? rawWindow : DEFAULT_WINDOW\n\tconst dataSource = params.get('dataSource') ?? undefined\n\tconst result = await readForWidgetRealtime({\n\t\treq,\n\t\tmetric,\n\t\twindowMinutes,\n\t\tadapterId: dataSource,\n\t\tnow: new Date(),\n\t})\n\treturn Response.json(result)\n}\n"],"mappings":";;;;AAQA,MAAM,kBAA+B,CAAC,YAAY,WAAW;AAC7D,MAAM,kBAAkB;CAAC;CAAG;CAAI;CAAI;AAAE;AACtC,MAAM,iBAAiB;;;;;;;AAQvB,MAAa,4BAA4C,OAAO,QAAQ;CACvE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,UAAU,WAAW,IAAI,OAAO;CAEtC,IAAI,WAAW,CAAE,MAAM,cAAc,SAAS,GAAG,GAChD,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE7D,MAAM,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,kBAAkB,EAAE;CAC1D,MAAM,YAAY,OAAO,IAAI,QAAQ;CACrC,MAAM,SAAoB,gBAAgB,SAAS,SAAsB,IACrE,YACD;CACH,MAAM,YAAY,OAAO,OAAO,IAAI,eAAe,CAAC;CAGpD,MAAM,SAAS,MAAM,sBAAsB;EAC1C;EACA;EACA,eALqB,gBAAgB,SAAS,SAAS,IAAI,YAAY;EAMvE,WALkB,OAAO,IAAI,YAAY,KAAK,KAAA;EAM9C,qBAAK,IAAI,KAAK;CACf,CAAC;CACD,OAAO,SAAS,KAAK,MAAM;AAC5B"}
@@ -0,0 +1 @@
1
+ import { Payload, PayloadRequest } from "payload";
@@ -1,3 +1,4 @@
1
+ import "../core/contract.js";
1
2
  //#region src/plugin/runtime.ts
2
3
  /**
3
4
  * Stored on the Payload instance (not a module global) so the runtime survives the
@@ -13,9 +14,38 @@ const setRuntime = (payload, runtime) => {
13
14
  const getRuntime = (payload) => payload[RUNTIME_KEY];
14
15
  const resolveScopeFor = (runtime, req) => runtime.resolveScope?.(req) ?? Promise.resolve(null);
15
16
  const resolveTimezoneFor = (runtime, req, scope) => runtime.resolveTimezone?.(req, scope) ?? Promise.resolve("UTC");
17
+ /**
18
+ * The reporting timezone of a request, resolving its scope first and falling back to UTC
19
+ * when the plugin is not booted or resolution throws. Callers that must interpret a
20
+ * client-supplied or stored calendar day before the read begins use this; a read path
21
+ * already holding a resolved scope calls {@link resolveTimezoneFor} directly.
22
+ */
23
+ const requestTimezone = async (req) => {
24
+ const runtime = getRuntime(req.payload);
25
+ if (!runtime) return "UTC";
26
+ try {
27
+ const scope = await resolveScopeFor(runtime, req);
28
+ return await resolveTimezoneFor(runtime, req, scope === "*" ? null : scope);
29
+ } catch {
30
+ return "UTC";
31
+ }
32
+ };
16
33
  const resolveRegistryFor = (runtime, args) => runtime.resolveRegistry?.(args) ?? Promise.resolve(runtime.registry);
34
+ const resolveGoalsFor = (runtime, req, scope) => runtime.resolveGoals?.(req, scope) ?? Promise.resolve(runtime.goals ?? []);
35
+ const resolveGoalsDetailedFor = (runtime, req, scope) => runtime.resolveGoalsDetailed?.(req, scope) ?? Promise.resolve((runtime.goals ?? []).map((goal) => ({
36
+ goal,
37
+ source: "config"
38
+ })));
39
+ const readAccessFor = async (runtime, req) => runtime.readAccess ? await runtime.readAccess({ req }) : Boolean(req.user);
17
40
  const platformReadFor = async (runtime, req) => runtime.platformRead ? await runtime.platformRead({ req }) : Boolean(req.user);
41
+ const platformReadGate = (runtime, req) => {
42
+ let pending;
43
+ return () => {
44
+ pending ??= platformReadFor(runtime, req);
45
+ return pending;
46
+ };
47
+ };
18
48
  //#endregion
19
- export { getRuntime, platformReadFor, resolveRegistryFor, resolveScopeFor, resolveTimezoneFor, setRuntime };
49
+ export { getRuntime, platformReadFor, platformReadGate, readAccessFor, requestTimezone, resolveGoalsDetailedFor, resolveGoalsFor, resolveRegistryFor, resolveScopeFor, resolveTimezoneFor, setRuntime };
20
50
 
21
51
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../../src/plugin/runtime.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\nimport type { ResolvedBinding } from '../binding/types'\nimport type { AdapterRegistry, RegistryResolver, ResolveRegistryArgs } from '../core/registry'\nimport type { Engine } from '../surfacing/engine'\nimport { DEFAULT_TIMEZONE } from '../timeframe/tz'\n\nexport interface AnalyticsRuntime {\n\tregistry: AdapterRegistry\n\t/** Per-scope adapter resolution; absent runtimes fall back to the static registry. */\n\tresolveRegistry?: RegistryResolver\n\t/** The plugin's scopeResolver bound at init; absent runtimes resolve null. */\n\tresolveScope?: (req: PayloadRequest) => Promise<string | null>\n\t/** The plugin's reportingTimezone bound at init; absent runtimes resolve 'UTC'. */\n\tresolveTimezone?: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/** Id of the config adapter shared by every scope, when one is designated. */\n\tplatformAdapterId?: string\n\t/**\n\t * Ids of the config-time adapters shared by every scope (the ones passed to\n\t * `adapters` in plugin options). Runtime provider adapters (resolved per scope\n\t * from the providers collection or `providers.resolve`) are never in it.\n\t */\n\tconfigAdapterIds: ReadonlySet<string>\n\t/** Gate for cross-scope reads; absent runtimes require an authenticated user. */\n\tplatformRead?: (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\tbindings: Record<string, ResolvedBinding>\n\tengine: Engine\n\t/** Explicit TTL overrides; when a value is unset the adapter's recommendedTtl applies. */\n\tttl: { aggregate?: number; realtime?: number }\n\t/** Widget period-over-period comparison; false skips the previous-window read. */\n\tcomparison: boolean\n}\n\n/**\n * Stored on the Payload instance (not a module global) so the runtime survives the\n * separate `.` and `/rsc` bundles a consumer loads: a server-component bundle that\n * imported its own copy of a module-level map would never see what the plugin wrote.\n * `Symbol.for` keys into the cross-realm global symbol registry, so both bundles\n * resolve the same key on the same `payload` object.\n */\nconst RUNTIME_KEY = Symbol.for('@10x-media/analytics/runtime')\n\ntype RuntimeHost = { [RUNTIME_KEY]?: AnalyticsRuntime }\n\nexport const setRuntime = (payload: Payload, runtime: AnalyticsRuntime): void => {\n\t;(payload as unknown as RuntimeHost)[RUNTIME_KEY] = runtime\n}\n\nexport const getRuntime = (payload: Payload): AnalyticsRuntime | undefined =>\n\t(payload as unknown as RuntimeHost)[RUNTIME_KEY]\n\nexport const resolveScopeFor = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest\n): Promise<string | null> => runtime.resolveScope?.(req) ?? Promise.resolve(null)\n\nexport const resolveTimezoneFor = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope?: string | null\n): Promise<string> => runtime.resolveTimezone?.(req, scope) ?? Promise.resolve(DEFAULT_TIMEZONE)\n\nexport const resolveRegistryFor = (\n\truntime: AnalyticsRuntime,\n\targs: ResolveRegistryArgs\n): Promise<AdapterRegistry> => runtime.resolveRegistry?.(args) ?? Promise.resolve(runtime.registry)\n\nexport const platformReadFor = async (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest\n): Promise<boolean> =>\n\truntime.platformRead ? await runtime.platformRead({ req }) : Boolean(req.user)\n"],"mappings":";;;;;;;;AAuCA,MAAM,cAAc,OAAO,IAAI,8BAA8B;AAI7D,MAAa,cAAc,SAAkB,YAAoC;CAC/E,QAAoC,eAAe;AACrD;AAEA,MAAa,cAAc,YACzB,QAAmC;AAErC,MAAa,mBACZ,SACA,QAC4B,QAAQ,eAAe,GAAG,KAAK,QAAQ,QAAQ,IAAI;AAEhF,MAAa,sBACZ,SACA,KACA,UACqB,QAAQ,kBAAkB,KAAK,KAAK,KAAK,QAAQ,QAAA,KAAwB;AAE/F,MAAa,sBACZ,SACA,SAC8B,QAAQ,kBAAkB,IAAI,KAAK,QAAQ,QAAQ,QAAQ,QAAQ;AAElG,MAAa,kBAAkB,OAC9B,SACA,QAEA,QAAQ,eAAe,MAAM,QAAQ,aAAa,EAAE,IAAI,CAAC,IAAI,QAAQ,IAAI,IAAI"}
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../src/plugin/runtime.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\nimport type { ResolvedBinding } from '../binding/types'\nimport { PLATFORM_SCOPE } from '../core/contract'\nimport type { CaptureSlotOption, ConsentPolicy, ResolvedAutoCapture } from '../core/options'\nimport type { AdapterRegistry, RegistryResolver, ResolveRegistryArgs } from '../core/registry'\nimport type { ServerTrack } from '../core/serverEvent'\nimport type { GoalsResolver, ResolvedGoal } from '../goals/resolver'\nimport type { Goal } from '../goals/types'\nimport type { Engine } from '../surfacing/engine'\nimport { DEFAULT_TIMEZONE } from '../timeframe/tz'\n\nexport interface AnalyticsRuntime {\n\tregistry: AdapterRegistry\n\t/** Per-scope adapter resolution; absent runtimes fall back to the static registry. */\n\tresolveRegistry?: RegistryResolver\n\t/** The plugin's scopeResolver bound at init; absent runtimes resolve null. */\n\tresolveScope?: (req: PayloadRequest) => Promise<string | null>\n\t/** The plugin's reportingTimezone bound at init; absent runtimes resolve 'UTC'. */\n\tresolveTimezone?: (req: PayloadRequest, scope?: string | null) => Promise<string>\n\t/** Id of the config adapter shared by every scope, when one is designated. */\n\tplatformAdapterId?: string\n\t/** `capture.slots` overrides naming the adapter that fills each capture slot. */\n\tcaptureSlots?: { global?: CaptureSlotOption; tenant?: CaptureSlotOption }\n\t/**\n\t * `capture.paths` overrides for a slot's mount. Unset, the tracker config derives the\n\t * runtime proxy mount; set when the slot is served through Next rewrites instead.\n\t */\n\tcapturePaths?: { global?: string; tenant?: string }\n\t/**\n\t * Whether a slot's tracker waits for consent, evaluated per request-resolved adapter.\n\t * Absent runtimes fall back to the default: no gate for native, one for a vendor.\n\t */\n\tconsentFor?: ConsentPolicy\n\t/** Browser auto-capture toggles handed to the tracker; absent runtimes default all on. */\n\tautoCapture?: ResolvedAutoCapture\n\t/** Config goals, and the fallback wherever the merged resolution is unavailable. */\n\tgoals?: Goal[]\n\t/**\n\t * Config goals merged with the goals collection for a request's scope. Absent runtimes\n\t * fall back to `goals`.\n\t */\n\tresolveGoals?: GoalsResolver['resolve']\n\t/** The same merge, each goal tagged with where it came from. */\n\tresolveGoalsDetailed?: GoalsResolver['resolveDetailed']\n\t/** Slug of the goals collection when the install enabled it; the picker links to it. */\n\tgoalsCollectionSlug?: string\n\t/**\n\t * Records an event from server code, through whichever registered adapter accepts\n\t * server events. Rejects with an `AnalyticsTrackError` when none does.\n\t */\n\ttrack?: ServerTrack\n\t/**\n\t * Where the ingest endpoint listens, relative to `routes.api`, lifted at init from the\n\t * adapter that registered one. Absent runtimes fall back to the default mount.\n\t */\n\tingestPath?: string\n\t/**\n\t * `capture.proxy` limits for the runtime capture proxy. Deliberately separate from\n\t * `cache.timeoutMs`: that is a per-read provider deadline for authenticated dashboard\n\t * queries, this is a public request path with entirely different traffic.\n\t */\n\tcaptureProxy?: { timeoutMs: number; maxBodyBytes: number }\n\t/** True when the app configured a scopeResolver (scoped install); mirrors `resolved.scoped`. */\n\tscoped?: boolean\n\t/**\n\t * Ids of the config-time adapters shared by every scope (the ones passed to\n\t * `adapters` in plugin options). Runtime provider adapters (resolved per scope\n\t * from the providers collection or `providers.resolve`) are never in it.\n\t */\n\tconfigAdapterIds: ReadonlySet<string>\n\t/** Gate for cross-scope reads; absent runtimes require an authenticated user. */\n\tplatformRead?: (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\t/** Gate for the query endpoint; absent runtimes require an authenticated user. */\n\treadAccess?: (args: { req: PayloadRequest }) => boolean | Promise<boolean>\n\tbindings: Record<string, ResolvedBinding>\n\tengine: Engine\n\t/** Explicit TTL overrides; when a value is unset the adapter's recommendedTtl applies. */\n\tttl: { aggregate?: number; realtime?: number }\n\t/** Widget period-over-period comparison; false skips the previous-window read. */\n\tcomparison: boolean\n}\n\n/**\n * Stored on the Payload instance (not a module global) so the runtime survives the\n * separate `.` and `/rsc` bundles a consumer loads: a server-component bundle that\n * imported its own copy of a module-level map would never see what the plugin wrote.\n * `Symbol.for` keys into the cross-realm global symbol registry, so both bundles\n * resolve the same key on the same `payload` object.\n */\nconst RUNTIME_KEY = Symbol.for('@10x-media/analytics/runtime')\n\ntype RuntimeHost = { [RUNTIME_KEY]?: AnalyticsRuntime }\n\nexport const setRuntime = (payload: Payload, runtime: AnalyticsRuntime): void => {\n\t;(payload as unknown as RuntimeHost)[RUNTIME_KEY] = runtime\n}\n\nexport const getRuntime = (payload: Payload): AnalyticsRuntime | undefined =>\n\t(payload as unknown as RuntimeHost)[RUNTIME_KEY]\n\nexport const resolveScopeFor = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest\n): Promise<string | null> => runtime.resolveScope?.(req) ?? Promise.resolve(null)\n\nexport const resolveTimezoneFor = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope?: string | null\n): Promise<string> => runtime.resolveTimezone?.(req, scope) ?? Promise.resolve(DEFAULT_TIMEZONE)\n\n/**\n * The reporting timezone of a request, resolving its scope first and falling back to UTC\n * when the plugin is not booted or resolution throws. Callers that must interpret a\n * client-supplied or stored calendar day before the read begins use this; a read path\n * already holding a resolved scope calls {@link resolveTimezoneFor} directly.\n */\nexport const requestTimezone = async (req: PayloadRequest): Promise<string> => {\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn DEFAULT_TIMEZONE\n\t}\n\ttry {\n\t\t// The cross-scope marker is not a scope a reporting timezone can be resolved for;\n\t\t// `resolveReadContext` narrows it to null the same way.\n\t\tconst scope = await resolveScopeFor(runtime, req)\n\t\treturn await resolveTimezoneFor(runtime, req, scope === PLATFORM_SCOPE ? null : scope)\n\t} catch {\n\t\treturn DEFAULT_TIMEZONE\n\t}\n}\n\nexport const resolveRegistryFor = (\n\truntime: AnalyticsRuntime,\n\targs: ResolveRegistryArgs\n): Promise<AdapterRegistry> => runtime.resolveRegistry?.(args) ?? Promise.resolve(runtime.registry)\n\nexport const resolveGoalsFor = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope?: string | null\n): Promise<Goal[]> => runtime.resolveGoals?.(req, scope) ?? Promise.resolve(runtime.goals ?? [])\n\nexport const resolveGoalsDetailedFor = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope?: string | null\n): Promise<ResolvedGoal[]> =>\n\truntime.resolveGoalsDetailed?.(req, scope) ??\n\tPromise.resolve((runtime.goals ?? []).map((goal) => ({ goal, source: 'config' as const })))\n\nexport const readAccessFor = async (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest\n): Promise<boolean> => (runtime.readAccess ? await runtime.readAccess({ req }) : Boolean(req.user))\n\nexport const platformReadFor = async (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest\n): Promise<boolean> =>\n\truntime.platformRead ? await runtime.platformRead({ req }) : Boolean(req.user)\n\n/** A `platformRead` decision evaluated at most once, however many gates consult it. */\nexport type PlatformReadGate = () => Promise<boolean>\n\nexport const platformReadGate = (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest\n): PlatformReadGate => {\n\tlet pending: Promise<boolean> | undefined\n\treturn () => {\n\t\tpending ??= platformReadFor(runtime, req)\n\t\treturn pending\n\t}\n}\n"],"mappings":";;;;;;;;;AAyFA,MAAM,cAAc,OAAO,IAAI,8BAA8B;AAI7D,MAAa,cAAc,SAAkB,YAAoC;CAC/E,QAAoC,eAAe;AACrD;AAEA,MAAa,cAAc,YACzB,QAAmC;AAErC,MAAa,mBACZ,SACA,QAC4B,QAAQ,eAAe,GAAG,KAAK,QAAQ,QAAQ,IAAI;AAEhF,MAAa,sBACZ,SACA,KACA,UACqB,QAAQ,kBAAkB,KAAK,KAAK,KAAK,QAAQ,QAAA,KAAwB;;;;;;;AAQ/F,MAAa,kBAAkB,OAAO,QAAyC;CAC9E,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAA;CAED,IAAI;EAGH,MAAM,QAAQ,MAAM,gBAAgB,SAAS,GAAG;EAChD,OAAO,MAAM,mBAAmB,SAAS,KAAK,UAAA,MAA2B,OAAO,KAAK;CACtF,QAAQ;EACP,OAAA;CACD;AACD;AAEA,MAAa,sBACZ,SACA,SAC8B,QAAQ,kBAAkB,IAAI,KAAK,QAAQ,QAAQ,QAAQ,QAAQ;AAElG,MAAa,mBACZ,SACA,KACA,UACqB,QAAQ,eAAe,KAAK,KAAK,KAAK,QAAQ,QAAQ,QAAQ,SAAS,CAAC,CAAC;AAE/F,MAAa,2BACZ,SACA,KACA,UAEA,QAAQ,uBAAuB,KAAK,KAAK,KACzC,QAAQ,SAAS,QAAQ,SAAS,CAAC,GAAG,KAAK,UAAU;CAAE;CAAM,QAAQ;AAAkB,EAAE,CAAC;AAE3F,MAAa,gBAAgB,OAC5B,SACA,QACuB,QAAQ,aAAa,MAAM,QAAQ,WAAW,EAAE,IAAI,CAAC,IAAI,QAAQ,IAAI,IAAI;AAEjG,MAAa,kBAAkB,OAC9B,SACA,QAEA,QAAQ,eAAe,MAAM,QAAQ,aAAa,EAAE,IAAI,CAAC,IAAI,QAAQ,IAAI,IAAI;AAK9E,MAAa,oBACZ,SACA,QACsB;CACtB,IAAI;CACJ,aAAa;EACZ,YAAY,gBAAgB,SAAS,GAAG;EACxC,OAAO;CACR;AACD"}
@@ -0,0 +1,22 @@
1
+ //#region src/plugin/scopeFieldBoot.ts
2
+ /** Whether a top-level field of that name exists, looking through presentational wrappers. */
3
+ const hasField = (fields, name) => fields.some((field) => {
4
+ if ("name" in field && field.name) return field.name === name;
5
+ if ("fields" in field) return hasField(field.fields, name);
6
+ if ("tabs" in field) return field.tabs.some((tab) => !("name" in tab && tab.name) && hasField(tab.fields, name));
7
+ return false;
8
+ });
9
+ /**
10
+ * Fails the boot when a `scopeField` the plugin does not own never materialized on the
11
+ * collection. A tenant plugin registers its field after this plugin runs, so the check
12
+ * waits for the assembled config at init rather than guessing at config time.
13
+ */
14
+ const validateScopeField = (payload, args) => {
15
+ const collection = payload.config.collections.find((c) => c.slug === args.slug);
16
+ if (!collection || hasField(collection.fields, args.scopeField)) return;
17
+ throw new Error(`analytics: ${args.option} "${args.scopeField}" does not exist on ${args.slug}; register the collection with your tenant plugin or use the default scope field`);
18
+ };
19
+ //#endregion
20
+ export { validateScopeField };
21
+
22
+ //# sourceMappingURL=scopeFieldBoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopeFieldBoot.js","names":[],"sources":["../../src/plugin/scopeFieldBoot.ts"],"sourcesContent":["import type { Field, Payload } from 'payload'\n\n/** Whether a top-level field of that name exists, looking through presentational wrappers. */\nconst hasField = (fields: Field[], name: string): boolean =>\n\tfields.some((field) => {\n\t\tif ('name' in field && field.name) {\n\t\t\treturn field.name === name\n\t\t}\n\t\tif ('fields' in field) {\n\t\t\treturn hasField(field.fields, name)\n\t\t}\n\t\tif ('tabs' in field) {\n\t\t\treturn field.tabs.some(\n\t\t\t\t(tab) => !('name' in tab && tab.name) && hasField(tab.fields as Field[], name)\n\t\t\t)\n\t\t}\n\t\treturn false\n\t})\n\nexport interface ValidateScopeFieldArgs {\n\t/** Option path quoted in the error, e.g. `goals.collection.scopeField`. */\n\toption: string\n\tslug: string\n\tscopeField: string\n}\n\n/**\n * Fails the boot when a `scopeField` the plugin does not own never materialized on the\n * collection. A tenant plugin registers its field after this plugin runs, so the check\n * waits for the assembled config at init rather than guessing at config time.\n */\nexport const validateScopeField = (payload: Payload, args: ValidateScopeFieldArgs): void => {\n\tconst collection = payload.config.collections.find((c) => c.slug === args.slug)\n\tif (!collection || hasField(collection.fields, args.scopeField)) {\n\t\treturn\n\t}\n\tthrow new Error(\n\t\t`analytics: ${args.option} \"${args.scopeField}\" does not exist on ${args.slug}; register the collection with your tenant plugin or use the default scope field`\n\t)\n}\n"],"mappings":";;AAGA,MAAM,YAAY,QAAiB,SAClC,OAAO,MAAM,UAAU;CACtB,IAAI,UAAU,SAAS,MAAM,MAC5B,OAAO,MAAM,SAAS;CAEvB,IAAI,YAAY,OACf,OAAO,SAAS,MAAM,QAAQ,IAAI;CAEnC,IAAI,UAAU,OACb,OAAO,MAAM,KAAK,MAChB,QAAQ,EAAE,UAAU,OAAO,IAAI,SAAS,SAAS,IAAI,QAAmB,IAAI,CAC9E;CAED,OAAO;AACR,CAAC;;;;;;AAcF,MAAa,sBAAsB,SAAkB,SAAuC;CAC3F,MAAM,aAAa,QAAQ,OAAO,YAAY,MAAM,MAAM,EAAE,SAAS,KAAK,IAAI;CAC9E,IAAI,CAAC,cAAc,SAAS,WAAW,QAAQ,KAAK,UAAU,GAC7D;CAED,MAAM,IAAI,MACT,cAAc,KAAK,OAAO,IAAI,KAAK,WAAW,sBAAsB,KAAK,KAAK,iFAC/E;AACD"}
@@ -1,51 +1,25 @@
1
- import { serializeCapabilities } from "../core/capabilities.js";
2
- import { getRuntime, resolveRegistryFor, resolveScopeFor } from "./runtime.js";
3
1
  import "./paths.js";
2
+ import { getRuntime, readAccessFor } from "./runtime.js";
3
+ import { resolveSourcesForRequest } from "./readContextForRequest.js";
4
4
  //#region src/plugin/sourcesEndpoint.ts
5
5
  /**
6
6
  * Authenticated GET listing the adapters visible to the requesting scope, with
7
- * serialized capabilities for client-side pickers. Always answers for the
8
- * caller's own resolved scope; there is deliberately no scope parameter, so a
9
- * tenant can never enumerate another tenant's sources. Resolution failures
10
- * degrade to the static config registry the same way reads do.
7
+ * serialized capabilities for client-side pickers. Gated by `access.read` like
8
+ * every other read endpoint. Always answers for the caller's own resolved scope;
9
+ * there is deliberately no scope parameter, so a tenant can never enumerate
10
+ * another tenant's sources. Everything else about the resolution, including how a
11
+ * null scope and a failed resolution fail closed, lives in
12
+ * {@link resolveSourcesForRequest}, which the query endpoint shares.
11
13
  */
12
14
  const makeSourcesHandler = () => async (req) => {
13
15
  if (!req.user) return Response.json({ error: "unauthorized" }, { status: 401 });
14
16
  const runtime = getRuntime(req.payload);
15
- if (!runtime) return Response.json({
16
- defaultId: null,
17
- sources: []
17
+ if (runtime && !await readAccessFor(runtime, req)) return Response.json({ error: "forbidden" }, { status: 403 });
18
+ const { sources, defaultId } = await resolveSourcesForRequest(req);
19
+ return Response.json({
20
+ defaultId,
21
+ sources
18
22
  });
19
- try {
20
- const scope = await resolveScopeFor(runtime, req);
21
- const registry = await resolveRegistryFor(runtime, {
22
- payload: req.payload,
23
- req,
24
- scope
25
- });
26
- const sources = registry.all().map((a) => ({
27
- id: a.id,
28
- label: a.label,
29
- kind: runtime.configAdapterIds.has(a.id) ? "config" : "runtime",
30
- capabilities: serializeCapabilities(a.capabilities)
31
- }));
32
- return Response.json({
33
- defaultId: registry.default().id,
34
- sources
35
- });
36
- } catch (err) {
37
- req.payload.logger?.warn(`analytics: sources listing failed: ${String(err)}`);
38
- const sources = runtime.registry.all().map((a) => ({
39
- id: a.id,
40
- label: a.label,
41
- kind: "config",
42
- capabilities: serializeCapabilities(a.capabilities)
43
- }));
44
- return Response.json({
45
- defaultId: runtime.registry.default().id,
46
- sources
47
- });
48
- }
49
23
  };
50
24
  //#endregion
51
25
  export { makeSourcesHandler };
@@ -1 +1 @@
1
- {"version":3,"file":"sourcesEndpoint.js","names":[],"sources":["../../src/plugin/sourcesEndpoint.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\nimport { serializeCapabilities } from '../core/capabilities'\nimport { SOURCES_PATH } from './paths'\nimport { getRuntime, resolveRegistryFor, resolveScopeFor } from './runtime'\n\nexport { SOURCES_PATH }\n\n/**\n * Authenticated GET listing the adapters visible to the requesting scope, with\n * serialized capabilities for client-side pickers. Always answers for the\n * caller's own resolved scope; there is deliberately no scope parameter, so a\n * tenant can never enumerate another tenant's sources. Resolution failures\n * degrade to the static config registry the same way reads do.\n */\nexport const makeSourcesHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst runtime = getRuntime(req.payload)\n\tif (!runtime) {\n\t\treturn Response.json({ defaultId: null, sources: [] })\n\t}\n\ttry {\n\t\tconst scope = await resolveScopeFor(runtime, req)\n\t\tconst registry = await resolveRegistryFor(runtime, { payload: req.payload, req, scope })\n\t\tconst sources = registry.all().map((a) => ({\n\t\t\tid: a.id,\n\t\t\tlabel: a.label,\n\t\t\tkind: runtime.configAdapterIds.has(a.id) ? ('config' as const) : ('runtime' as const),\n\t\t\tcapabilities: serializeCapabilities(a.capabilities),\n\t\t}))\n\t\treturn Response.json({ defaultId: registry.default().id, sources })\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: sources listing failed: ${String(err)}`)\n\t\tconst sources = runtime.registry.all().map((a) => ({\n\t\t\tid: a.id,\n\t\t\tlabel: a.label,\n\t\t\tkind: 'config' as const,\n\t\t\tcapabilities: serializeCapabilities(a.capabilities),\n\t\t}))\n\t\treturn Response.json({ defaultId: runtime.registry.default().id, sources })\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,2BAA2C,OAAO,QAAQ;CACtE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,UAAU,WAAW,IAAI,OAAO;CACtC,IAAI,CAAC,SACJ,OAAO,SAAS,KAAK;EAAE,WAAW;EAAM,SAAS,CAAC;CAAE,CAAC;CAEtD,IAAI;EACH,MAAM,QAAQ,MAAM,gBAAgB,SAAS,GAAG;EAChD,MAAM,WAAW,MAAM,mBAAmB,SAAS;GAAE,SAAS,IAAI;GAAS;GAAK;EAAM,CAAC;EACvF,MAAM,UAAU,SAAS,IAAI,EAAE,KAAK,OAAO;GAC1C,IAAI,EAAE;GACN,OAAO,EAAE;GACT,MAAM,QAAQ,iBAAiB,IAAI,EAAE,EAAE,IAAK,WAAsB;GAClE,cAAc,sBAAsB,EAAE,YAAY;EACnD,EAAE;EACF,OAAO,SAAS,KAAK;GAAE,WAAW,SAAS,QAAQ,EAAE;GAAI;EAAQ,CAAC;CACnE,SAAS,KAAK;EACb,IAAI,QAAQ,QAAQ,KAAK,sCAAsC,OAAO,GAAG,GAAG;EAC5E,MAAM,UAAU,QAAQ,SAAS,IAAI,EAAE,KAAK,OAAO;GAClD,IAAI,EAAE;GACN,OAAO,EAAE;GACT,MAAM;GACN,cAAc,sBAAsB,EAAE,YAAY;EACnD,EAAE;EACF,OAAO,SAAS,KAAK;GAAE,WAAW,QAAQ,SAAS,QAAQ,EAAE;GAAI;EAAQ,CAAC;CAC3E;AACD"}
1
+ {"version":3,"file":"sourcesEndpoint.js","names":[],"sources":["../../src/plugin/sourcesEndpoint.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\nimport { SOURCES_PATH } from './paths'\nimport { resolveSourcesForRequest } from './readContextForRequest'\nimport { getRuntime, readAccessFor } from './runtime'\n\nexport { SOURCES_PATH }\n\n/**\n * Authenticated GET listing the adapters visible to the requesting scope, with\n * serialized capabilities for client-side pickers. Gated by `access.read` like\n * every other read endpoint. Always answers for the caller's own resolved scope;\n * there is deliberately no scope parameter, so a tenant can never enumerate\n * another tenant's sources. Everything else about the resolution, including how a\n * null scope and a failed resolution fail closed, lives in\n * {@link resolveSourcesForRequest}, which the query endpoint shares.\n */\nexport const makeSourcesHandler = (): PayloadHandler => async (req) => {\n\tif (!req.user) {\n\t\treturn Response.json({ error: 'unauthorized' }, { status: 401 })\n\t}\n\tconst runtime = getRuntime(req.payload)\n\t// No runtime means the plugin served nothing to gate: the listing below is empty anyway.\n\tif (runtime && !(await readAccessFor(runtime, req))) {\n\t\treturn Response.json({ error: 'forbidden' }, { status: 403 })\n\t}\n\tconst { sources, defaultId } = await resolveSourcesForRequest(req)\n\treturn Response.json({ defaultId, sources })\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,2BAA2C,OAAO,QAAQ;CACtE,IAAI,CAAC,IAAI,MACR,OAAO,SAAS,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;CAEhE,MAAM,UAAU,WAAW,IAAI,OAAO;CAEtC,IAAI,WAAW,CAAE,MAAM,cAAc,SAAS,GAAG,GAChD,OAAO,SAAS,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;CAE7D,MAAM,EAAE,SAAS,cAAc,MAAM,yBAAyB,GAAG;CACjE,OAAO,SAAS,KAAK;EAAE;EAAW;CAAQ,CAAC;AAC5C"}
Binary file