@10x-media/analytics 1.0.0-beta.8 → 4.0.0-alpha.1
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.
- package/CHANGELOG.md +780 -0
- package/LICENSE +21 -21
- package/README.md +35 -36
- package/dist/access/adminUser.d.ts +15 -0
- package/dist/access/adminUser.js +13 -0
- package/dist/access/adminUser.js.map +1 -0
- package/dist/access/decideOnce.js +16 -0
- package/dist/access/decideOnce.js.map +1 -0
- package/dist/access/membership.d.ts +23 -0
- package/dist/access/membership.js +63 -0
- package/dist/access/membership.js.map +1 -0
- package/dist/access/principal.d.ts +37 -0
- package/dist/access/principal.js +29 -0
- package/dist/access/principal.js.map +1 -0
- package/dist/access/readGate.js +16 -0
- package/dist/access/readGate.js.map +1 -0
- package/dist/adapters/ga4/disableKey.js +19 -0
- package/dist/adapters/ga4/disableKey.js.map +1 -0
- package/dist/adapters/ga4/eventName.d.ts +9 -0
- package/dist/adapters/ga4/eventName.js +13 -0
- package/dist/adapters/ga4/eventName.js.map +1 -0
- package/dist/adapters/ga4/ga4.d.ts +29 -0
- package/dist/adapters/ga4/ga4.js +324 -112
- package/dist/adapters/ga4/ga4.js.map +1 -1
- package/dist/adapters/ga4/measurementId.js +14 -0
- package/dist/adapters/ga4/measurementId.js.map +1 -0
- package/dist/adapters/goalRead.js +112 -0
- package/dist/adapters/goalRead.js.map +1 -0
- package/dist/adapters/http/baseUrl.js +15 -0
- package/dist/adapters/http/baseUrl.js.map +1 -0
- package/dist/adapters/http/fetchJson.d.ts +19 -0
- package/dist/adapters/http/fetchJson.js +27 -8
- package/dist/adapters/http/fetchJson.js.map +1 -1
- package/dist/adapters/mapping.js +52 -0
- package/dist/adapters/mapping.js.map +1 -0
- package/dist/adapters/plausible/plausible.d.ts +30 -3
- package/dist/adapters/plausible/plausible.js +198 -110
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/plausible/scriptId.js +19 -0
- package/dist/adapters/plausible/scriptId.js.map +1 -0
- package/dist/adapters/posthog/posthog.d.ts +33 -9
- package/dist/adapters/posthog/posthog.js +307 -127
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/posthog/projectCheck.js +56 -0
- package/dist/adapters/posthog/projectCheck.js.map +1 -0
- package/dist/adapters/readTime.js +7 -0
- package/dist/adapters/readTime.js.map +1 -0
- package/dist/adapters/series.js +14 -8
- package/dist/adapters/series.js.map +1 -1
- package/dist/adapters/umami/umami.d.ts +21 -3
- package/dist/adapters/umami/umami.js +334 -95
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/adapters/upstream.js +16 -0
- package/dist/adapters/upstream.js.map +1 -0
- package/dist/binding/report.d.ts +8 -0
- package/dist/binding/report.js +24 -0
- package/dist/binding/report.js.map +1 -0
- package/dist/binding/resolvePath.js +28 -25
- package/dist/binding/resolvePath.js.map +1 -1
- package/dist/binding/types.d.ts +14 -29
- package/dist/capture/captureRequest.js +28 -0
- package/dist/capture/captureRequest.js.map +1 -0
- package/dist/capture/exclusionEndpoint.js +98 -0
- package/dist/capture/exclusionEndpoint.js.map +1 -0
- package/dist/capture/exclusionPrelude.js +14 -0
- package/dist/capture/exclusionPrelude.js.map +1 -0
- package/dist/capture/exclusionToken.js +23 -0
- package/dist/capture/exclusionToken.js.map +1 -0
- package/dist/capture/jsLiteral.js +19 -0
- package/dist/capture/jsLiteral.js.map +1 -0
- package/dist/capture/mountPath.js +2 -3
- package/dist/capture/mountPath.js.map +1 -1
- package/dist/capture/proxyEndpoint.js +49 -92
- package/dist/capture/proxyEndpoint.js.map +1 -1
- package/dist/capture/proxyRoutes.js +58 -21
- package/dist/capture/proxyRoutes.js.map +1 -1
- package/dist/capture/relay.js +91 -0
- package/dist/capture/relay.js.map +1 -0
- package/dist/capture/requestBody.js +2 -6
- package/dist/capture/requestBody.js.map +1 -1
- package/dist/capture/requestTrust.js +45 -0
- package/dist/capture/requestTrust.js.map +1 -0
- package/dist/capture/sameSite.js +40 -0
- package/dist/capture/sameSite.js.map +1 -0
- package/dist/capture/slots.js +50 -25
- package/dist/capture/slots.js.map +1 -1
- package/dist/capture/trackerConfig.js +131 -36
- package/dist/capture/trackerConfig.js.map +1 -1
- package/dist/capture/trackerEndpoint.js +22 -21
- package/dist/capture/trackerEndpoint.js.map +1 -1
- package/dist/capture/withoutConsent.js +91 -0
- package/dist/capture/withoutConsent.js.map +1 -0
- package/dist/charts/BarList.d.ts +27 -13
- package/dist/charts/BarList.js +38 -77
- package/dist/charts/BarList.js.map +1 -1
- package/dist/charts/TrendChart.d.ts +40 -7
- package/dist/charts/TrendChart.js +243 -215
- package/dist/charts/TrendChart.js.map +1 -1
- package/dist/charts/bars.d.ts +17 -1
- package/dist/charts/bars.js +12 -11
- package/dist/charts/bars.js.map +1 -1
- package/dist/charts/bucket.js +106 -73
- package/dist/charts/bucket.js.map +1 -1
- package/dist/charts/inProgress.js +22 -0
- package/dist/charts/inProgress.js.map +1 -0
- package/dist/charts/series.d.ts +15 -0
- package/dist/charts/series.js +123 -0
- package/dist/charts/series.js.map +1 -0
- package/dist/charts/spline.js +91 -25
- package/dist/charts/spline.js.map +1 -1
- package/dist/charts/trendGeometry.js +91 -0
- package/dist/charts/trendGeometry.js.map +1 -0
- package/dist/core/adminOptions.d.ts +1 -0
- package/dist/core/adminOptions.js +198 -0
- package/dist/core/adminOptions.js.map +1 -0
- package/dist/core/budget.js +24 -0
- package/dist/core/budget.js.map +1 -0
- package/dist/core/cacheKey.d.ts +1 -0
- package/dist/core/cacheKey.js +51 -29
- package/dist/core/cacheKey.js.map +1 -1
- package/dist/core/cacheOptions.js +165 -0
- package/dist/core/cacheOptions.js.map +1 -0
- package/dist/core/capabilities.d.ts +24 -11
- package/dist/core/capabilities.js +101 -17
- package/dist/core/capabilities.js.map +1 -1
- package/dist/core/capture.d.ts +59 -26
- package/dist/core/captureOptions.d.ts +1 -0
- package/dist/core/captureOptions.js +347 -0
- package/dist/core/captureOptions.js.map +1 -0
- package/dist/core/clock.js +13 -0
- package/dist/core/clock.js.map +1 -0
- package/dist/core/collectionOption.d.ts +17 -0
- package/dist/core/collectionOption.js +105 -0
- package/dist/core/collectionOption.js.map +1 -0
- package/dist/core/collectionSlug.js +7 -0
- package/dist/core/collectionSlug.js.map +1 -0
- package/dist/core/contract.d.ts +340 -49
- package/dist/core/contract.js +7 -4
- package/dist/core/contract.js.map +1 -1
- package/dist/core/cron.js +57 -0
- package/dist/core/cron.js.map +1 -0
- package/dist/core/fetch.d.ts +17 -0
- package/dist/core/goalOptions.d.ts +1 -0
- package/dist/core/goalOptions.js +166 -0
- package/dist/core/goalOptions.js.map +1 -0
- package/dist/core/granularity.js +3 -2
- package/dist/core/granularity.js.map +1 -1
- package/dist/core/guards.js +17 -0
- package/dist/core/guards.js.map +1 -0
- package/dist/core/jobs.d.ts +40 -0
- package/dist/core/jobs.js +132 -0
- package/dist/core/jobs.js.map +1 -0
- package/dist/core/legacyOptions.js +145 -0
- package/dist/core/legacyOptions.js.map +1 -0
- package/dist/core/metricAliases.js +81 -0
- package/dist/core/metricAliases.js.map +1 -0
- package/dist/core/metricValues.js +57 -0
- package/dist/core/metricValues.js.map +1 -0
- package/dist/core/monotonic.js +10 -0
- package/dist/core/monotonic.js.map +1 -0
- package/dist/core/optionChecks.js +51 -0
- package/dist/core/optionChecks.js.map +1 -0
- package/dist/core/options.d.ts +535 -151
- package/dist/core/options.js +158 -214
- package/dist/core/options.js.map +1 -1
- package/dist/core/registry.js +45 -5
- package/dist/core/registry.js.map +1 -1
- package/dist/core/scopeList.js +7 -9
- package/dist/core/scopeList.js.map +1 -1
- package/dist/core/scopeOptions.d.ts +1 -0
- package/dist/core/scopeOptions.js +114 -0
- package/dist/core/scopeOptions.js.map +1 -0
- package/dist/core/scopedRead.js +349 -36
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/core/sdks.d.ts +81 -0
- package/dist/core/sdks.js +23 -0
- package/dist/core/sdks.js.map +1 -0
- package/dist/core/serverEvent.d.ts +50 -14
- package/dist/core/serverEvent.js.map +1 -1
- package/dist/core/siteAddress.js +20 -0
- package/dist/core/siteAddress.js.map +1 -0
- package/dist/core/sourceErrors.js +109 -0
- package/dist/core/sourceErrors.js.map +1 -0
- package/dist/core/sourceLabel.d.ts +10 -0
- package/dist/core/sourceLabel.js +63 -0
- package/dist/core/sourceLabel.js.map +1 -0
- package/dist/core/sourceOptions.js +107 -0
- package/dist/core/sourceOptions.js.map +1 -0
- package/dist/core/sourcePolicy.d.ts +55 -0
- package/dist/core/sourcePolicy.js +51 -0
- package/dist/core/sourcePolicy.js.map +1 -0
- package/dist/core/throttle.js +18 -0
- package/dist/core/throttle.js.map +1 -0
- package/dist/core/values.js +61 -0
- package/dist/core/values.js.map +1 -0
- package/dist/core/widgetSlugs.d.ts +17 -0
- package/dist/core/widgetSlugs.js +29 -0
- package/dist/core/widgetSlugs.js.map +1 -0
- package/dist/db/detachedWrite.js +36 -0
- package/dist/db/detachedWrite.js.map +1 -0
- package/dist/db/errors.js +182 -0
- package/dist/db/errors.js.map +1 -0
- package/dist/db/kind.js +32 -0
- package/dist/db/kind.js.map +1 -0
- package/dist/db/openTransaction.js +51 -0
- package/dist/db/openTransaction.js.map +1 -0
- package/dist/exports/adapters/contract.d.ts +15 -0
- package/dist/exports/adapters/ga4.d.ts +17 -1
- package/dist/exports/adapters/ga4.js +2 -1
- package/dist/exports/adapters/native.d.ts +29 -2
- package/dist/exports/adapters/native.js +5 -1
- package/dist/exports/adapters/plausible.d.ts +16 -1
- package/dist/exports/adapters/posthog.d.ts +16 -1
- package/dist/exports/adapters/umami.d.ts +16 -1
- package/dist/exports/attributes.d.ts +42 -0
- package/dist/exports/attributes.js +83 -0
- package/dist/exports/attributes.js.map +1 -0
- package/dist/exports/client.d.ts +45 -11
- package/dist/exports/client.js +23 -6
- package/dist/exports/geo.d.ts +4 -2
- package/dist/exports/geo.js +1 -1
- package/dist/exports/i18n.d.ts +2 -2
- package/dist/exports/i18n.js +2 -2
- package/dist/exports/migrations.d.ts +2 -0
- package/dist/exports/migrations.js +2 -0
- package/dist/exports/react.d.ts +5 -3
- package/dist/exports/react.js +1 -2
- package/dist/exports/routes.d.ts +19 -0
- package/dist/exports/routes.js +3 -0
- package/dist/exports/rsc.d.ts +33 -14
- package/dist/exports/rsc.js +11 -6
- package/dist/exports/site.d.ts +5 -0
- package/dist/exports/site.js +3 -0
- package/dist/exports/testing.d.ts +18 -0
- package/dist/exports/testing.js +3 -0
- package/dist/exports/tracker.d.ts +6 -17
- package/dist/exports/tracker.js +3 -11
- package/dist/exports/types.d.ts +46 -14
- package/dist/exports/types.js +7 -1
- package/dist/fields/AnalyticsPanelClient.js +265 -154
- package/dist/fields/AnalyticsPanelClient.js.map +1 -1
- package/dist/fields/AnalyticsPanelField.d.ts +19 -7
- package/dist/fields/AnalyticsPanelField.js +123 -30
- package/dist/fields/AnalyticsPanelField.js.map +1 -1
- package/dist/fields/AnalyticsStatField.d.ts +17 -6
- package/dist/fields/AnalyticsStatField.js +98 -63
- package/dist/fields/AnalyticsStatField.js.map +1 -1
- package/dist/fields/FieldShimmer.js +15 -0
- package/dist/fields/FieldShimmer.js.map +1 -0
- package/dist/fields/PanelContent.js +222 -0
- package/dist/fields/PanelContent.js.map +1 -0
- package/dist/fields/PanelList.js +82 -0
- package/dist/fields/PanelList.js.map +1 -0
- package/dist/fields/PanelLiveCounter.js +63 -0
- package/dist/fields/PanelLiveCounter.js.map +1 -0
- package/dist/fields/PanelSkeleton.js +63 -0
- package/dist/fields/PanelSkeleton.js.map +1 -0
- package/dist/fields/componentPaths.js +8 -0
- package/dist/fields/componentPaths.js.map +1 -0
- package/dist/fields/config/FilterDimensionSelectField.d.ts +14 -0
- package/dist/fields/config/FilterDimensionSelectField.js +49 -0
- package/dist/fields/config/FilterDimensionSelectField.js.map +1 -0
- package/dist/fields/config/FilterKeySelect.js +66 -0
- package/dist/fields/config/FilterKeySelect.js.map +1 -0
- package/dist/fields/config/FilterOperatorSelectField.d.ts +19 -0
- package/dist/fields/config/FilterOperatorSelectField.js +59 -0
- package/dist/fields/config/FilterOperatorSelectField.js.map +1 -0
- package/dist/fields/config/FilterValueField.d.ts +17 -0
- package/dist/fields/config/FilterValueField.js +130 -0
- package/dist/fields/config/FilterValueField.js.map +1 -0
- package/dist/fields/config/MetricSelectField.d.ts +5 -12
- package/dist/fields/config/MetricSelectField.js +19 -31
- package/dist/fields/config/MetricSelectField.js.map +1 -1
- package/dist/fields/config/OptionSelect.js +52 -0
- package/dist/fields/config/OptionSelect.js.map +1 -0
- package/dist/fields/config/SourceSelectField.js +16 -31
- package/dist/fields/config/SourceSelectField.js.map +1 -1
- package/dist/fields/config/fetchSources.d.ts +3 -0
- package/dist/fields/config/fetchSources.js +17 -23
- package/dist/fields/config/fetchSources.js.map +1 -1
- package/dist/fields/config/filterValues.js +106 -0
- package/dist/fields/config/filterValues.js.map +1 -0
- package/dist/fields/config/narrow.js +8 -10
- package/dist/fields/config/narrow.js.map +1 -1
- package/dist/fields/config/retiredPickers.d.ts +45 -0
- package/dist/fields/config/retiredPickers.js +46 -0
- package/dist/fields/config/retiredPickers.js.map +1 -0
- package/dist/fields/config/scopedFields.d.ts +40 -0
- package/dist/fields/config/scopedFields.js +68 -0
- package/dist/fields/config/scopedFields.js.map +1 -0
- package/dist/fields/config/sourcesState.js +19 -3
- package/dist/fields/config/sourcesState.js.map +1 -1
- package/dist/fields/config/toSelectOption.js +13 -7
- package/dist/fields/config/toSelectOption.js.map +1 -1
- package/dist/fields/config/useAnalyticsSources.d.ts +10 -7
- package/dist/fields/config/useAnalyticsSources.js +23 -24
- package/dist/fields/config/useAnalyticsSources.js.map +1 -1
- package/dist/fields/config/useFilterCapabilities.d.ts +31 -0
- package/dist/fields/config/useFilterCapabilities.js +60 -0
- package/dist/fields/config/useFilterCapabilities.js.map +1 -0
- package/dist/fields/config/useFormString.js +12 -0
- package/dist/fields/config/useFormString.js.map +1 -0
- package/dist/fields/dateRange/field.js +7 -19
- package/dist/fields/dateRange/field.js.map +1 -1
- package/dist/fields/dateRange/types.d.ts +5 -1
- package/dist/fields/dateRange/ui.d.ts +3 -2
- package/dist/fields/dateRange/ui.js +57 -319
- package/dist/fields/dateRange/ui.js.map +1 -1
- package/dist/fields/documentScope.js +21 -0
- package/dist/fields/documentScope.js.map +1 -0
- package/dist/fields/emptyState.js +30 -26
- package/dist/fields/emptyState.js.map +1 -1
- package/dist/fields/factories.d.ts +35 -16
- package/dist/fields/factories.js +67 -38
- package/dist/fields/factories.js.map +1 -1
- package/dist/fields/format.d.ts +12 -3
- package/dist/fields/format.js +77 -13
- package/dist/fields/format.js.map +1 -1
- package/dist/fields/itemReport.js +45 -0
- package/dist/fields/itemReport.js.map +1 -0
- package/dist/fields/readForDocument.d.ts +79 -26
- package/dist/fields/readForDocument.js +451 -105
- package/dist/fields/readForDocument.js.map +1 -1
- package/dist/fields/stateKeys.js +20 -0
- package/dist/fields/stateKeys.js.map +1 -0
- package/dist/goals/GoalAmountField.d.ts +10 -0
- package/dist/goals/GoalAmountField.js +179 -0
- package/dist/goals/GoalAmountField.js.map +1 -0
- package/dist/goals/GoalSelectField.js +89 -40
- package/dist/goals/GoalSelectField.js.map +1 -1
- package/dist/goals/GoalSelectFieldServer.d.ts +13 -0
- package/dist/goals/GoalSelectFieldServer.js +21 -0
- package/dist/goals/GoalSelectFieldServer.js.map +1 -0
- package/dist/goals/amountField.d.ts +20 -0
- package/dist/goals/amountField.js +37 -0
- package/dist/goals/amountField.js.map +1 -0
- package/dist/goals/builtin.js +17 -0
- package/dist/goals/builtin.js.map +1 -0
- package/dist/goals/collection.d.ts +22 -0
- package/dist/goals/collection.js +143 -124
- package/dist/goals/collection.js.map +1 -1
- package/dist/goals/constants.d.ts +38 -0
- package/dist/goals/constants.js +49 -0
- package/dist/goals/constants.js.map +1 -0
- package/dist/goals/currency.d.ts +16 -0
- package/dist/goals/currency.js +46 -4
- package/dist/goals/currency.js.map +1 -1
- package/dist/goals/currencyOptions.js +70 -0
- package/dist/goals/currencyOptions.js.map +1 -0
- package/dist/goals/fetchGoals.d.ts +10 -0
- package/dist/goals/fetchGoals.js +12 -22
- package/dist/goals/fetchGoals.js.map +1 -1
- package/dist/goals/goalField.d.ts +4 -6
- package/dist/goals/goalField.js +9 -19
- package/dist/goals/goalField.js.map +1 -1
- package/dist/goals/goalsEndpoint.js +40 -38
- package/dist/goals/goalsEndpoint.js.map +1 -1
- package/dist/goals/items.js +35 -0
- package/dist/goals/items.js.map +1 -0
- package/dist/goals/latent.js +9 -0
- package/dist/goals/latent.js.map +1 -0
- package/dist/goals/linkFields.d.ts +35 -0
- package/dist/goals/linkFields.js +31 -0
- package/dist/goals/linkFields.js.map +1 -0
- package/dist/goals/match.d.ts +14 -0
- package/dist/goals/match.js +67 -46
- package/dist/goals/match.js.map +1 -1
- package/dist/goals/moneyFields.js +56 -0
- package/dist/goals/moneyFields.js.map +1 -0
- package/dist/goals/pathMatch.js +122 -0
- package/dist/goals/pathMatch.js.map +1 -0
- package/dist/goals/placeholder.js +12 -0
- package/dist/goals/placeholder.js.map +1 -0
- package/dist/goals/resolver.d.ts +3 -3
- package/dist/goals/resolver.js +155 -47
- package/dist/goals/resolver.js.map +1 -1
- package/dist/goals/serverRevenue.d.ts +60 -0
- package/dist/goals/serverRevenue.js +41 -0
- package/dist/goals/serverRevenue.js.map +1 -0
- package/dist/goals/trackGoalAction.d.ts +26 -25
- package/dist/goals/trackGoalAction.js +71 -66
- package/dist/goals/trackGoalAction.js.map +1 -1
- package/dist/goals/types.d.ts +13 -28
- package/dist/goals/types.js +1 -1
- package/dist/goals/types.js.map +1 -1
- package/dist/goals/useAnalyticsGoals.d.ts +6 -5
- package/dist/goals/useAnalyticsGoals.js +17 -18
- package/dist/goals/useAnalyticsGoals.js.map +1 -1
- package/dist/index.d.ts +69 -11
- package/dist/index.js +262 -192
- package/dist/index.js.map +1 -1
- package/dist/items/collectionIdType.js +20 -0
- package/dist/items/collectionIdType.js.map +1 -0
- package/dist/items/idType.js +31 -0
- package/dist/items/idType.js.map +1 -0
- package/dist/items/ref.js +73 -0
- package/dist/items/ref.js.map +1 -0
- package/dist/maintenance/apiTaskState.js +141 -0
- package/dist/maintenance/apiTaskState.js.map +1 -0
- package/dist/maintenance/heartbeat.js +51 -0
- package/dist/maintenance/heartbeat.js.map +1 -0
- package/dist/maintenance/lease.d.ts +1 -0
- package/dist/maintenance/lease.js +79 -0
- package/dist/maintenance/lease.js.map +1 -0
- package/dist/maintenance/taskSchedule.js +27 -0
- package/dist/maintenance/taskSchedule.js.map +1 -0
- package/dist/maintenance/underLease.js +35 -0
- package/dist/maintenance/underLease.js.map +1 -0
- package/dist/migrations/legacy.d.ts +54 -0
- package/dist/migrations/legacy.js +117 -0
- package/dist/migrations/legacy.js.map +1 -0
- package/dist/migrations/predefined/dropLegacyMongo.d.ts +11 -0
- package/dist/migrations/predefined/dropLegacyMongo.js +12 -0
- package/dist/migrations/predefined/dropLegacyMongo.js.map +1 -0
- package/dist/native/collections/aggregates.js +54 -0
- package/dist/native/collections/aggregates.js.map +1 -0
- package/dist/native/collections/hits.js +103 -0
- package/dist/native/collections/hits.js.map +1 -0
- package/dist/native/collections/slugs.d.ts +10 -0
- package/dist/native/collections/slugs.js +16 -0
- package/dist/native/collections/slugs.js.map +1 -0
- package/dist/native/collections/state.js +84 -0
- package/dist/native/collections/state.js.map +1 -0
- package/dist/native/collections/storeCollection.js +31 -0
- package/dist/native/collections/storeCollection.js.map +1 -0
- package/dist/native/engine/buckets.d.ts +1 -0
- package/dist/native/engine/buckets.js +53 -0
- package/dist/native/engine/buckets.js.map +1 -0
- package/dist/native/engine/capabilities.js +87 -0
- package/dist/native/engine/capabilities.js.map +1 -0
- package/dist/native/engine/cost.js +72 -0
- package/dist/native/engine/cost.js.map +1 -0
- package/dist/native/engine/days.d.ts +1 -0
- package/dist/native/engine/days.js +182 -0
- package/dist/native/engine/days.js.map +1 -0
- package/dist/native/engine/engine.d.ts +1 -0
- package/dist/native/engine/engine.js +1627 -0
- package/dist/native/engine/engine.js.map +1 -0
- package/dist/native/engine/instance.js +58 -0
- package/dist/native/engine/instance.js.map +1 -0
- package/dist/native/engine/maintenance.d.ts +1 -0
- package/dist/native/engine/maintenance.js +677 -0
- package/dist/native/engine/maintenance.js.map +1 -0
- package/dist/native/engine/merge.js +41 -0
- package/dist/native/engine/merge.js.map +1 -0
- package/dist/native/engine/nudge.js +26 -0
- package/dist/native/engine/nudge.js.map +1 -0
- package/dist/native/engine/planner.js +199 -0
- package/dist/native/engine/planner.js.map +1 -0
- package/dist/native/engine/rebuild.d.ts +22 -0
- package/dist/native/engine/rebuild.js +76 -0
- package/dist/native/engine/rebuild.js.map +1 -0
- package/dist/native/engine/recent.js +17 -0
- package/dist/native/engine/recent.js.map +1 -0
- package/dist/native/engine/salt.d.ts +1 -0
- package/dist/native/engine/salt.js +98 -0
- package/dist/native/engine/salt.js.map +1 -0
- package/dist/native/engine/siteHosts.d.ts +1 -0
- package/dist/native/engine/siteHosts.js +58 -0
- package/dist/native/engine/siteHosts.js.map +1 -0
- package/dist/native/engine/toHit.js +110 -0
- package/dist/native/engine/toHit.js.map +1 -0
- package/dist/native/engine/writeBuffer.d.ts +14 -0
- package/dist/native/engine/writeBuffer.js +317 -0
- package/dist/native/engine/writeBuffer.js.map +1 -0
- package/dist/native/geo/composeGeoResolvers.d.ts +1 -0
- package/dist/native/geo/composeGeoResolvers.js +5 -2
- package/dist/native/geo/composeGeoResolvers.js.map +1 -1
- package/dist/native/geo/geoResolver.d.ts +27 -2
- package/dist/native/geo/geoResolver.js +42 -6
- package/dist/native/geo/geoResolver.js.map +1 -1
- package/dist/native/geo/maxmindResolver.d.ts +8 -4
- package/dist/native/geo/maxmindResolver.js +20 -16
- package/dist/native/geo/maxmindResolver.js.map +1 -1
- package/dist/native/geo/resolveGeo.js +31 -0
- package/dist/native/geo/resolveGeo.js.map +1 -0
- package/dist/native/ingest/bots.d.ts +10 -0
- package/dist/native/ingest/bots.js +66 -0
- package/dist/native/ingest/bots.js.map +1 -0
- package/dist/native/ingest/browser.js +45 -0
- package/dist/native/ingest/browser.js.map +1 -0
- package/dist/native/ingest/clientIp.js +34 -8
- package/dist/native/ingest/clientIp.js.map +1 -1
- package/dist/native/ingest/device.js +4 -6
- package/dist/native/ingest/device.js.map +1 -1
- package/dist/native/ingest/endpoint.d.ts +1 -1
- package/dist/native/ingest/endpoint.js +185 -32
- package/dist/native/ingest/endpoint.js.map +1 -1
- package/dist/native/ingest/itemSignature.d.ts +26 -0
- package/dist/native/ingest/itemSignature.js +45 -0
- package/dist/native/ingest/itemSignature.js.map +1 -0
- package/dist/native/ingest/language.js +13 -0
- package/dist/native/ingest/language.js.map +1 -0
- package/dist/native/ingest/normalizeEvent.d.ts +73 -5
- package/dist/native/ingest/normalizeEvent.js +257 -51
- package/dist/native/ingest/normalizeEvent.js.map +1 -1
- package/dist/native/ingest/orderSignature.d.ts +13 -0
- package/dist/native/ingest/orderSignature.js +50 -0
- package/dist/native/ingest/orderSignature.js.map +1 -0
- package/dist/native/ingest/referrer.js +46 -0
- package/dist/native/ingest/referrer.js.map +1 -0
- package/dist/native/ingest/requestHost.js +44 -0
- package/dist/native/ingest/requestHost.js.map +1 -0
- package/dist/native/ingest/resolveHostname.d.ts +20 -0
- package/dist/native/ingest/resolveHostname.js +51 -0
- package/dist/native/ingest/resolveHostname.js.map +1 -0
- package/dist/native/ingest/revenue.d.ts +1 -0
- package/dist/native/ingest/revenue.js +121 -0
- package/dist/native/ingest/revenue.js.map +1 -0
- package/dist/native/ingest/route.d.ts +10 -0
- package/dist/native/ingest/route.js +85 -0
- package/dist/native/ingest/route.js.map +1 -0
- package/dist/native/ingest/serverTrack.d.ts +2 -10
- package/dist/native/ingest/serverTrack.js +188 -68
- package/dist/native/ingest/serverTrack.js.map +1 -1
- package/dist/native/ingest/signature.js +28 -0
- package/dist/native/ingest/signature.js.map +1 -0
- package/dist/native/ingest/source.d.ts +10 -0
- package/dist/native/ingest/source.js +245 -16
- package/dist/native/ingest/source.js.map +1 -1
- package/dist/native/ingest/utm.js +33 -0
- package/dist/native/ingest/utm.js.map +1 -0
- package/dist/native/ingest/validate.js +25 -13
- package/dist/native/ingest/validate.js.map +1 -1
- package/dist/native/ingest/visitorHash.js +6 -8
- package/dist/native/ingest/visitorHash.js.map +1 -1
- package/dist/native/nativeAdapter.d.ts +128 -9
- package/dist/native/nativeAdapter.js +395 -281
- package/dist/native/nativeAdapter.js.map +1 -1
- package/dist/native/rebuildDays.d.ts +12 -0
- package/dist/native/rebuildDays.js +16 -0
- package/dist/native/rebuildDays.js.map +1 -0
- package/dist/native/store/aggregate.js +450 -0
- package/dist/native/store/aggregate.js.map +1 -0
- package/dist/native/store/caps.d.ts +18 -0
- package/dist/native/store/caps.js +76 -0
- package/dist/native/store/caps.js.map +1 -0
- package/dist/native/store/chunks.js +34 -0
- package/dist/native/store/chunks.js.map +1 -0
- package/dist/native/store/columnValues.js +31 -0
- package/dist/native/store/columnValues.js.map +1 -0
- package/dist/native/store/dialect.js +106 -0
- package/dist/native/store/dialect.js.map +1 -0
- package/dist/native/store/eventStore.js +44 -0
- package/dist/native/store/eventStore.js.map +1 -0
- package/dist/native/store/hitRow.js +119 -0
- package/dist/native/store/hitRow.js.map +1 -0
- package/dist/native/store/hits.js +65 -0
- package/dist/native/store/hits.js.map +1 -0
- package/dist/native/store/ids.js +105 -0
- package/dist/native/store/ids.js.map +1 -0
- package/dist/native/store/mongo/aggregatePipelines.js +438 -0
- package/dist/native/store/mongo/aggregatePipelines.js.map +1 -0
- package/dist/native/store/mongo/mongoState.js +375 -0
- package/dist/native/store/mongo/mongoState.js.map +1 -0
- package/dist/native/store/mongo/mongoStore.js +618 -0
- package/dist/native/store/mongo/mongoStore.js.map +1 -0
- package/dist/native/store/mongo/pipelines.js +705 -0
- package/dist/native/store/mongo/pipelines.js.map +1 -0
- package/dist/native/store/mongo/results.js +20 -0
- package/dist/native/store/mongo/results.js.map +1 -0
- package/dist/native/store/parts.d.ts +1 -0
- package/dist/native/store/parts.js +101 -0
- package/dist/native/store/parts.js.map +1 -0
- package/dist/native/store/pattern.js +213 -0
- package/dist/native/store/pattern.js.map +1 -0
- package/dist/native/store/rawRead.d.ts +23 -0
- package/dist/native/store/rawRead.js +387 -0
- package/dist/native/store/rawRead.js.map +1 -0
- package/dist/native/store/reclassify.js +53 -0
- package/dist/native/store/reclassify.js.map +1 -0
- package/dist/native/store/sql/aggregateSql.js +349 -0
- package/dist/native/store/sql/aggregateSql.js.map +1 -0
- package/dist/native/store/sql/columns.js +49 -0
- package/dist/native/store/sql/columns.js.map +1 -0
- package/dist/native/store/sql/compile.js +668 -0
- package/dist/native/store/sql/compile.js.map +1 -0
- package/dist/native/store/sql/drivers.js +218 -0
- package/dist/native/store/sql/drivers.js.map +1 -0
- package/dist/native/store/sql/executor.js +132 -0
- package/dist/native/store/sql/executor.js.map +1 -0
- package/dist/native/store/sql/fragment.js +104 -0
- package/dist/native/store/sql/fragment.js.map +1 -0
- package/dist/native/store/sql/maintenanceSql.js +59 -0
- package/dist/native/store/sql/maintenanceSql.js.map +1 -0
- package/dist/native/store/sql/ownConnection.js +107 -0
- package/dist/native/store/sql/ownConnection.js.map +1 -0
- package/dist/native/store/sql/poolShare.js +101 -0
- package/dist/native/store/sql/poolShare.js.map +1 -0
- package/dist/native/store/sql/sqlState.js +325 -0
- package/dist/native/store/sql/sqlState.js.map +1 -0
- package/dist/native/store/sql/sqlStore.js +355 -0
- package/dist/native/store/sql/sqlStore.js.map +1 -0
- package/dist/native/store/sql/sqliteThread.d.ts +9 -0
- package/dist/native/store/sql/sqliteThread.js +314 -0
- package/dist/native/store/sql/sqliteThread.js.map +1 -0
- package/dist/native/store/sql/sqliteWorker.js +327 -0
- package/dist/native/store/sql/sqliteWorker.js.map +1 -0
- package/dist/native/store/sql/sqliteWorkerSource.js +347 -0
- package/dist/native/store/sql/sqliteWorkerSource.js.map +1 -0
- package/dist/native/store/state.js +151 -0
- package/dist/native/store/state.js.map +1 -0
- package/dist/native/store/stateStore.js +29 -0
- package/dist/native/store/stateStore.js.map +1 -0
- package/dist/native/store/types.d.ts +15 -0
- package/dist/native/store/types.js +10 -0
- package/dist/native/store/types.js.map +1 -0
- package/dist/native/tasks/maintainTask.d.ts +19 -0
- package/dist/native/tasks/maintainTask.js +57 -0
- package/dist/native/tasks/maintainTask.js.map +1 -0
- package/dist/net/guardedFetch.d.ts +32 -0
- package/dist/net/guardedFetch.js +220 -0
- package/dist/net/guardedFetch.js.map +1 -0
- package/dist/net/origin.js +40 -0
- package/dist/net/origin.js.map +1 -0
- package/dist/net/platform.d.ts +9 -0
- package/dist/net/platform.js +35 -0
- package/dist/net/platform.js.map +1 -0
- package/dist/plugin/adminDependencies.js +34 -0
- package/dist/plugin/adminDependencies.js.map +1 -0
- package/dist/plugin/apiPath.js +23 -0
- package/dist/plugin/apiPath.js.map +1 -0
- package/dist/plugin/boundDocument.js +58 -0
- package/dist/plugin/boundDocument.js.map +1 -0
- package/dist/plugin/buildPhase.js +10 -0
- package/dist/plugin/buildPhase.js.map +1 -0
- package/dist/plugin/collectionChecks.js +232 -0
- package/dist/plugin/collectionChecks.js.map +1 -0
- package/dist/plugin/collectionFields.d.ts +13 -0
- package/dist/plugin/collectionFields.js +22 -0
- package/dist/plugin/collectionFields.js.map +1 -0
- package/dist/plugin/createRuntime.js +346 -0
- package/dist/plugin/createRuntime.js.map +1 -0
- package/dist/plugin/destroy.js +58 -0
- package/dist/plugin/destroy.js.map +1 -0
- package/dist/plugin/documentEndpoint.js +106 -53
- package/dist/plugin/documentEndpoint.js.map +1 -1
- package/dist/plugin/documentScopes.js +37 -0
- package/dist/plugin/documentScopes.js.map +1 -0
- package/dist/plugin/encrypted.js +25 -0
- package/dist/plugin/encrypted.js.map +1 -0
- package/dist/plugin/errors.d.ts +24 -0
- package/dist/plugin/errors.js +86 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/flagsEndpoint.js +41 -0
- package/dist/plugin/flagsEndpoint.js.map +1 -0
- package/dist/plugin/goalHint.d.ts +1 -0
- package/dist/plugin/goalHint.js +35 -0
- package/dist/plugin/goalHint.js.map +1 -0
- package/dist/plugin/itemLabels.js +114 -0
- package/dist/plugin/itemLabels.js.map +1 -0
- package/dist/plugin/keepAlive.js +48 -0
- package/dist/plugin/keepAlive.js.map +1 -0
- package/dist/plugin/peerImportError.js +3 -6
- package/dist/plugin/peerImportError.js.map +1 -1
- package/dist/plugin/peers.js +64 -0
- package/dist/plugin/peers.js.map +1 -0
- package/dist/plugin/pluginCollections.js +161 -0
- package/dist/plugin/pluginCollections.js.map +1 -0
- package/dist/plugin/queryEndpoint.js +88 -52
- package/dist/plugin/queryEndpoint.js.map +1 -1
- package/dist/plugin/queryParams.js +7 -0
- package/dist/plugin/queryParams.js.map +1 -0
- package/dist/plugin/readContextForRequest.d.ts +11 -0
- package/dist/plugin/readContextForRequest.js +79 -32
- package/dist/plugin/readContextForRequest.js.map +1 -1
- package/dist/plugin/readFailure.js +22 -0
- package/dist/plugin/readFailure.js.map +1 -0
- package/dist/plugin/readableProviders.js +67 -0
- package/dist/plugin/readableProviders.js.map +1 -0
- package/dist/plugin/realtimeEndpoint.js +91 -21
- package/dist/plugin/realtimeEndpoint.js.map +1 -1
- package/dist/plugin/refreshEndpoint.js +138 -0
- package/dist/plugin/refreshEndpoint.js.map +1 -0
- package/dist/plugin/relabelFields.js +36 -0
- package/dist/plugin/relabelFields.js.map +1 -0
- package/dist/plugin/requestMemo.js +35 -0
- package/dist/plugin/requestMemo.js.map +1 -0
- package/dist/plugin/routeChecks.js +39 -0
- package/dist/plugin/routeChecks.js.map +1 -0
- package/dist/plugin/routes.d.ts +53 -0
- package/dist/plugin/routes.js +92 -0
- package/dist/plugin/routes.js.map +1 -0
- package/dist/plugin/runtime.d.ts +1 -1
- package/dist/plugin/runtime.js +235 -29
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/plugin/schemaOnly.js +61 -0
- package/dist/plugin/schemaOnly.js.map +1 -0
- package/dist/plugin/scopeChange.js +23 -0
- package/dist/plugin/scopeChange.js.map +1 -0
- package/dist/plugin/scopeFieldBoot.js +4 -4
- package/dist/plugin/scopeFieldBoot.js.map +1 -1
- package/dist/plugin/scopeToken.js +33 -0
- package/dist/plugin/scopeToken.js.map +1 -0
- package/dist/plugin/sourcesEndpoint.js +50 -16
- package/dist/plugin/sourcesEndpoint.js.map +1 -1
- package/dist/plugin/unbundledLanguages.js +25 -0
- package/dist/plugin/unbundledLanguages.js.map +1 -0
- package/dist/plugin/walkFields.js +24 -0
- package/dist/plugin/walkFields.js.map +1 -0
- package/dist/plugin/warmTask.js +0 -0
- package/dist/plugin/warmTask.js.map +1 -1
- package/dist/providers/ProvidersListNotice.d.ts +11 -0
- package/dist/providers/ProvidersListNotice.js +36 -0
- package/dist/providers/ProvidersListNotice.js.map +1 -0
- package/dist/providers/access.d.ts +1 -0
- package/dist/providers/access.js +35 -26
- package/dist/providers/access.js.map +1 -1
- package/dist/providers/adapterPool.js +121 -0
- package/dist/providers/adapterPool.js.map +1 -0
- package/dist/providers/collection.d.ts +63 -0
- package/dist/providers/collection.js +372 -143
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/factory.d.ts +84 -0
- package/dist/providers/factory.js +86 -25
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/hosts.d.ts +25 -0
- package/dist/providers/hosts.js +128 -0
- package/dist/providers/hosts.js.map +1 -0
- package/dist/providers/probe.d.ts +1 -0
- package/dist/providers/probe.js +105 -0
- package/dist/providers/probe.js.map +1 -0
- package/dist/providers/refresh.d.ts +18 -0
- package/dist/providers/refresh.js +49 -0
- package/dist/providers/refresh.js.map +1 -0
- package/dist/providers/registry.js +329 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/resolver.js +26 -88
- package/dist/providers/resolver.js.map +1 -1
- package/dist/providers/retarget.js +45 -0
- package/dist/providers/retarget.js.map +1 -0
- package/dist/providers/scopeUnique.js +41 -0
- package/dist/providers/scopeUnique.js.map +1 -0
- package/dist/providers/secrets.d.ts +26 -0
- package/dist/providers/secrets.js +61 -4
- package/dist/providers/secrets.js.map +1 -1
- package/dist/providers/stampScope.js +9 -6
- package/dist/providers/stampScope.js.map +1 -1
- package/dist/query/dates.js +10 -12
- package/dist/query/dates.js.map +1 -1
- package/dist/query/errors.d.ts +6 -13
- package/dist/query/fetchQuery.d.ts +36 -23
- package/dist/query/fetchQuery.js +96 -89
- package/dist/query/fetchQuery.js.map +1 -1
- package/dist/query/limits.js +8 -0
- package/dist/query/limits.js.map +1 -0
- package/dist/query/parse.d.ts +8 -2
- package/dist/query/parse.js +155 -108
- package/dist/query/parse.js.map +1 -1
- package/dist/query/response.d.ts +27 -4
- package/dist/query/response.js +18 -0
- package/dist/query/response.js.map +1 -0
- package/dist/react/AnalyticsProvider.d.ts +42 -20
- package/dist/react/AnalyticsProvider.js +24 -22
- package/dist/react/AnalyticsProvider.js.map +1 -1
- package/dist/react/TrackerBoot.js +15 -9
- package/dist/react/TrackerBoot.js.map +1 -1
- package/dist/react/useAnalytics.d.ts +2 -8
- package/dist/react/useAnalytics.js +31 -13
- package/dist/react/useAnalytics.js.map +1 -1
- package/dist/routes/captureRoute.d.ts +28 -0
- package/dist/routes/captureRoute.js +67 -0
- package/dist/routes/captureRoute.js.map +1 -0
- package/dist/routes/ingestRoute.d.ts +17 -0
- package/dist/routes/ingestRoute.js +17 -0
- package/dist/routes/ingestRoute.js.map +1 -0
- package/dist/site/AnalyticsScripts.d.ts +35 -0
- package/dist/site/AnalyticsScripts.js +44 -0
- package/dist/site/AnalyticsScripts.js.map +1 -0
- package/dist/site/getTrackerConfig.d.ts +15 -0
- package/dist/site/getTrackerConfig.js +43 -0
- package/dist/site/getTrackerConfig.js.map +1 -0
- package/dist/surfacing/afterRead.d.ts +37 -0
- package/dist/surfacing/bounded.js +38 -0
- package/dist/surfacing/bounded.js.map +1 -0
- package/dist/surfacing/breaker.js +107 -0
- package/dist/surfacing/breaker.js.map +1 -0
- package/dist/surfacing/cacheCollection.d.ts +8 -0
- package/dist/surfacing/cacheCollection.js +71 -0
- package/dist/surfacing/cacheCollection.js.map +1 -0
- package/dist/surfacing/cacheStore.d.ts +71 -1
- package/dist/surfacing/cacheStore.js +16 -37
- package/dist/surfacing/cacheStore.js.map +1 -1
- package/dist/surfacing/cacheSweep.d.ts +1 -0
- package/dist/surfacing/cacheSweep.js +59 -0
- package/dist/surfacing/cacheSweep.js.map +1 -0
- package/dist/surfacing/classifyError.js +282 -0
- package/dist/surfacing/classifyError.js.map +1 -0
- package/dist/surfacing/coalesce.js +2 -1
- package/dist/surfacing/coalesce.js.map +1 -1
- package/dist/surfacing/coldBudget.js +60 -0
- package/dist/surfacing/coldBudget.js.map +1 -0
- package/dist/surfacing/collectionCacheStore.js +183 -0
- package/dist/surfacing/collectionCacheStore.js.map +1 -0
- package/dist/surfacing/engine.d.ts +1 -1
- package/dist/surfacing/engine.js +514 -71
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/epoch.d.ts +1 -0
- package/dist/surfacing/epoch.js +116 -0
- package/dist/surfacing/epoch.js.map +1 -0
- package/dist/surfacing/lanes.d.ts +1 -0
- package/dist/surfacing/lanes.js +297 -0
- package/dist/surfacing/lanes.js.map +1 -0
- package/dist/surfacing/memo.js +40 -0
- package/dist/surfacing/memo.js.map +1 -0
- package/dist/surfacing/rateLimiter.d.ts +1 -0
- package/dist/surfacing/rateLimiter.js +69 -94
- package/dist/surfacing/rateLimiter.js.map +1 -1
- package/dist/surfacing/rebucket.js +178 -0
- package/dist/surfacing/rebucket.js.map +1 -0
- package/dist/surfacing/recipe.js +28 -0
- package/dist/surfacing/recipe.js.map +1 -0
- package/dist/surfacing/shape.js +22 -0
- package/dist/surfacing/shape.js.map +1 -0
- package/dist/surfacing/todaySplit.js +119 -0
- package/dist/surfacing/todaySplit.js.map +1 -0
- package/dist/sync/collection.d.ts +8 -0
- package/dist/sync/collection.js +30 -18
- package/dist/sync/collection.js.map +1 -1
- package/dist/sync/rekeyDurations.js +70 -0
- package/dist/sync/rekeyDurations.js.map +1 -0
- package/dist/sync/syncTask.js +222 -109
- package/dist/sync/syncTask.js.map +1 -1
- package/dist/testing/memoryAdapter.d.ts +6 -3
- package/dist/testing/memoryAdapter.js +12 -11
- package/dist/testing/memoryAdapter.js.map +1 -1
- package/dist/testing/settle.d.ts +11 -0
- package/dist/testing/settle.js +19 -0
- package/dist/testing/settle.js.map +1 -0
- package/dist/timeframe/calendar.js +65 -0
- package/dist/timeframe/calendar.js.map +1 -0
- package/dist/timeframe/comparison.js +46 -0
- package/dist/timeframe/comparison.js.map +1 -0
- package/dist/timeframe/presets.d.ts +1 -1
- package/dist/timeframe/presets.js +5 -5
- package/dist/timeframe/presets.js.map +1 -1
- package/dist/timeframe/reportingTimezone.d.ts +1 -0
- package/dist/timeframe/reportingTimezone.js +64 -0
- package/dist/timeframe/reportingTimezone.js.map +1 -0
- package/dist/timeframe/tz.js +55 -39
- package/dist/timeframe/tz.js.map +1 -1
- package/dist/tracker/autoCapture.js +125 -38
- package/dist/tracker/autoCapture.js.map +1 -1
- package/dist/tracker/campaign.js +52 -0
- package/dist/tracker/campaign.js.map +1 -0
- package/dist/tracker/config.d.ts +174 -0
- package/dist/tracker/config.js +25 -0
- package/dist/tracker/config.js.map +1 -0
- package/dist/tracker/createTracker.d.ts +5 -10
- package/dist/tracker/createTracker.js +437 -82
- package/dist/tracker/createTracker.js.map +1 -1
- package/dist/tracker/digest.js +28 -0
- package/dist/tracker/digest.js.map +1 -0
- package/dist/tracker/engagement.js +100 -0
- package/dist/tracker/engagement.js.map +1 -0
- package/dist/tracker/events.js +37 -0
- package/dist/tracker/events.js.map +1 -0
- package/dist/tracker/exclusion.d.ts +8 -0
- package/dist/tracker/exclusion.js +82 -0
- package/dist/tracker/exclusion.js.map +1 -0
- package/dist/tracker/gate.d.ts +8 -0
- package/dist/tracker/gate.js +244 -0
- package/dist/tracker/gate.js.map +1 -0
- package/dist/tracker/initTracker.d.ts +5 -8
- package/dist/tracker/initTracker.js +42 -14
- package/dist/tracker/initTracker.js.map +1 -1
- package/dist/tracker/itemCapture.js +224 -0
- package/dist/tracker/itemCapture.js.map +1 -0
- package/dist/tracker/loadScript.js +23 -15
- package/dist/tracker/loadScript.js.map +1 -1
- package/dist/tracker/pageTracking.js +6 -6
- package/dist/tracker/pageTracking.js.map +1 -1
- package/dist/tracker/registry.js +129 -30
- package/dist/tracker/registry.js.map +1 -1
- package/dist/tracker/sinks/createSink.js +60 -0
- package/dist/tracker/sinks/createSink.js.map +1 -0
- package/dist/tracker/sinks/ga4.js +106 -0
- package/dist/tracker/sinks/ga4.js.map +1 -0
- package/dist/tracker/sinks/native.js +21 -42
- package/dist/tracker/sinks/native.js.map +1 -1
- package/dist/tracker/sinks/plausible.js +36 -18
- package/dist/tracker/sinks/plausible.js.map +1 -1
- package/dist/tracker/sinks/posthog.js +145 -9
- package/dist/tracker/sinks/posthog.js.map +1 -1
- package/dist/tracker/sinks/umami.js +18 -10
- package/dist/tracker/sinks/umami.js.map +1 -1
- package/dist/tracker/sinks/vendor.js +54 -22
- package/dist/tracker/sinks/vendor.js.map +1 -1
- package/dist/tracker/skip.js +81 -0
- package/dist/tracker/skip.js.map +1 -0
- package/dist/tracker/storage.js +23 -0
- package/dist/tracker/storage.js.map +1 -0
- package/dist/tracker/transport.js +2 -5
- package/dist/tracker/transport.js.map +1 -1
- package/dist/tracker/types.d.ts +99 -44
- package/dist/tracker/window.js +7 -0
- package/dist/tracker/window.js.map +1 -0
- package/dist/translations/ar.js +266 -56
- package/dist/translations/ar.js.map +1 -1
- package/dist/translations/de.js +256 -55
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +253 -56
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +261 -57
- package/dist/translations/es.js.map +1 -1
- package/dist/translations/fr.js +265 -61
- package/dist/translations/fr.js.map +1 -1
- package/dist/translations/id.js +256 -56
- package/dist/translations/id.js.map +1 -1
- package/dist/translations/index.d.ts +1 -1
- package/dist/translations/index.js +5 -7
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/intl.js +71 -0
- package/dist/translations/intl.js.map +1 -0
- package/dist/translations/keys.d.ts +240 -14
- package/dist/translations/keys.js +245 -14
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +258 -58
- package/dist/translations/ko.js.map +1 -1
- package/dist/translations/labelMap.d.ts +10 -0
- package/dist/translations/labelMap.js +22 -0
- package/dist/translations/labelMap.js.map +1 -0
- package/dist/translations/metricKeys.js +16 -2
- package/dist/translations/metricKeys.js.map +1 -1
- package/dist/translations/parts.js +20 -0
- package/dist/translations/parts.js.map +1 -0
- package/dist/translations/plural.js +61 -0
- package/dist/translations/plural.js.map +1 -0
- package/dist/translations/pt.js +270 -66
- package/dist/translations/pt.js.map +1 -1
- package/dist/translations/ru.js +261 -55
- package/dist/translations/ru.js.map +1 -1
- package/dist/translations/server.d.ts +1 -0
- package/dist/translations/server.js +2 -3
- package/dist/translations/server.js.map +1 -1
- package/dist/translations/staticLabel.js +69 -0
- package/dist/translations/staticLabel.js.map +1 -0
- package/dist/translations/uk.js +261 -55
- package/dist/translations/uk.js.map +1 -1
- package/dist/translations/zh.js +256 -56
- package/dist/translations/zh.js.map +1 -1
- package/dist/ui/RangePicker.js +110 -0
- package/dist/ui/RangePicker.js.map +1 -0
- package/dist/ui/analytics.css +1667 -0
- package/dist/ui/calendarDays.js +27 -0
- package/dist/ui/calendarDays.js.map +1 -0
- package/dist/ui/classNames.js +7 -0
- package/dist/ui/classNames.js.map +1 -0
- package/dist/ui/components/Card.d.ts +28 -0
- package/dist/ui/components/Card.js +21 -0
- package/dist/ui/components/Card.js.map +1 -0
- package/dist/ui/components/ChartDataTable.d.ts +41 -0
- package/dist/ui/components/ChartDataTable.js +48 -0
- package/dist/ui/components/ChartDataTable.js.map +1 -0
- package/dist/ui/components/ChoiceMenu.js +48 -0
- package/dist/ui/components/ChoiceMenu.js.map +1 -0
- package/dist/ui/components/DataTable.d.ts +82 -0
- package/dist/ui/components/DataTable.js +214 -0
- package/dist/ui/components/DataTable.js.map +1 -0
- package/dist/ui/components/LabeledSelect.js +62 -0
- package/dist/ui/components/LabeledSelect.js.map +1 -0
- package/dist/ui/components/LiveAnnouncement.js +21 -0
- package/dist/ui/components/LiveAnnouncement.js.map +1 -0
- package/dist/ui/components/MetricCard.d.ts +38 -0
- package/dist/ui/components/MetricCard.js +39 -0
- package/dist/ui/components/MetricCard.js.map +1 -0
- package/dist/ui/components/NoValue.js +22 -0
- package/dist/ui/components/NoValue.js.map +1 -0
- package/dist/ui/components/ReadState.js +27 -0
- package/dist/ui/components/ReadState.js.map +1 -0
- package/dist/ui/components/RefreshButton.js +25 -0
- package/dist/ui/components/RefreshButton.js.map +1 -0
- package/dist/ui/components/SourcesNoticeBanner.js +20 -0
- package/dist/ui/components/SourcesNoticeBanner.js.map +1 -0
- package/dist/ui/cssVars.js +7 -0
- package/dist/ui/cssVars.js.map +1 -0
- package/dist/ui/data/WithScopeToken.d.ts +20 -0
- package/dist/ui/data/WithScopeToken.js +20 -0
- package/dist/ui/data/WithScopeToken.js.map +1 -0
- package/dist/ui/data/clientFieldProps.js +16 -0
- package/dist/ui/data/clientFieldProps.js.map +1 -0
- package/dist/ui/data/request.d.ts +46 -0
- package/dist/ui/data/request.js +119 -0
- package/dist/ui/data/request.js.map +1 -0
- package/dist/ui/data/scopeTokenContext.js +18 -0
- package/dist/ui/data/scopeTokenContext.js.map +1 -0
- package/dist/ui/data/sharedCache.js +48 -0
- package/dist/ui/data/sharedCache.js.map +1 -0
- package/dist/ui/data/useRequest.d.ts +19 -0
- package/dist/ui/data/useRequest.js +123 -0
- package/dist/ui/data/useRequest.js.map +1 -0
- package/dist/ui/data/useRequestScope.js +25 -0
- package/dist/ui/data/useRequestScope.js.map +1 -0
- package/dist/ui/hooks/useDirection.js +47 -0
- package/dist/ui/hooks/useDirection.js.map +1 -0
- package/dist/ui/hooks/useDismissOnEscape.js +25 -0
- package/dist/ui/hooks/useDismissOnEscape.js.map +1 -0
- package/dist/ui/hooks/useLiveAnnouncement.js +57 -0
- package/dist/ui/hooks/useLiveAnnouncement.js.map +1 -0
- package/dist/ui/hooks/useRealtimePoll.js +112 -0
- package/dist/ui/hooks/useRealtimePoll.js.map +1 -0
- package/dist/ui/readState.js +19 -0
- package/dist/ui/readState.js.map +1 -0
- package/dist/ui/rows/toDisplayRows.js +49 -0
- package/dist/ui/rows/toDisplayRows.js.map +1 -0
- package/dist/ui/viewerClock.js +7 -0
- package/dist/ui/viewerClock.js.map +1 -0
- package/dist/view/AnalyticsNavLink.d.ts +5 -3
- package/dist/view/AnalyticsNavLink.js +12 -8
- package/dist/view/AnalyticsNavLink.js.map +1 -1
- package/dist/view/AnalyticsView.d.ts +9 -10
- package/dist/view/AnalyticsView.js +47 -19
- package/dist/view/AnalyticsView.js.map +1 -1
- package/dist/view/AnalyticsViewClient.d.ts +4 -7
- package/dist/view/AnalyticsViewClient.js +15 -174
- package/dist/view/AnalyticsViewClient.js.map +1 -1
- package/dist/view/CountryFlag.d.ts +27 -0
- package/dist/view/CountryFlag.js +44 -0
- package/dist/view/CountryFlag.js.map +1 -0
- package/dist/view/DocumentTitle.js +27 -0
- package/dist/view/DocumentTitle.js.map +1 -0
- package/dist/view/ViewRoot.d.ts +21 -0
- package/dist/view/ViewRoot.js +155 -0
- package/dist/view/ViewRoot.js.map +1 -0
- package/dist/view/ViewSections.d.ts +38 -0
- package/dist/view/ViewSections.js +190 -0
- package/dist/view/ViewSections.js.map +1 -0
- package/dist/view/authRedirect.js +2 -4
- package/dist/view/authRedirect.js.map +1 -1
- package/dist/view/consentShare.js +15 -0
- package/dist/view/consentShare.js.map +1 -0
- package/dist/view/conversionRate.js +9 -7
- package/dist/view/conversionRate.js.map +1 -1
- package/dist/view/dayRange.js +6 -10
- package/dist/view/dayRange.js.map +1 -1
- package/dist/view/exclusionLink.d.ts +27 -0
- package/dist/view/exclusionLink.js +46 -0
- package/dist/view/exclusionLink.js.map +1 -0
- package/dist/view/flagSrc.js +14 -0
- package/dist/view/flagSrc.js.map +1 -0
- package/dist/view/gating.d.ts +15 -1
- package/dist/view/gating.js +92 -20
- package/dist/view/gating.js.map +1 -1
- package/dist/view/hostCountryFlag.js +41 -0
- package/dist/view/hostCountryFlag.js.map +1 -0
- package/dist/view/labels.js +120 -3
- package/dist/view/labels.js.map +1 -1
- package/dist/view/metricAliases.js +10 -0
- package/dist/view/metricAliases.js.map +1 -0
- package/dist/view/navLabel.js +15 -0
- package/dist/view/navLabel.js.map +1 -0
- package/dist/view/registerView.js +13 -11
- package/dist/view/registerView.js.map +1 -1
- package/dist/view/scopeLabel.js +21 -0
- package/dist/view/scopeLabel.js.map +1 -0
- package/dist/view/sections/Breakdowns.js +221 -118
- package/dist/view/sections/Breakdowns.js.map +1 -1
- package/dist/view/sections/EmptyStates.js +120 -32
- package/dist/view/sections/EmptyStates.js.map +1 -1
- package/dist/view/sections/ExcludeBrowser.js +188 -0
- package/dist/view/sections/ExcludeBrowser.js.map +1 -0
- package/dist/view/sections/FilterChips.js +130 -25
- package/dist/view/sections/FilterChips.js.map +1 -1
- package/dist/view/sections/GoalsPanel.js +68 -59
- package/dist/view/sections/GoalsPanel.js.map +1 -1
- package/dist/view/sections/OverviewCards.js +42 -36
- package/dist/view/sections/OverviewCards.js.map +1 -1
- package/dist/view/sections/RealtimeStrip.js +70 -56
- package/dist/view/sections/RealtimeStrip.js.map +1 -1
- package/dist/view/sections/SectionBoundary.js +34 -0
- package/dist/view/sections/SectionBoundary.js.map +1 -0
- package/dist/view/sections/Toolbar.d.ts +11 -0
- package/dist/view/sections/Toolbar.js +182 -116
- package/dist/view/sections/Toolbar.js.map +1 -1
- package/dist/view/sections/Trend.js +179 -73
- package/dist/view/sections/Trend.js.map +1 -1
- package/dist/view/state.d.ts +42 -0
- package/dist/view/state.js +97 -53
- package/dist/view/state.js.map +1 -1
- package/dist/view/useViewClock.js +31 -0
- package/dist/view/useViewClock.js.map +1 -0
- package/dist/view/useViewQueries.d.ts +21 -0
- package/dist/view/useViewQueries.js +50 -79
- package/dist/view/useViewQueries.js.map +1 -1
- package/dist/view/useViewState.js +42 -0
- package/dist/view/useViewState.js.map +1 -0
- package/dist/view/useViewUrl.js +52 -0
- package/dist/view/useViewUrl.js.map +1 -0
- package/dist/view/viewBody.js +30 -0
- package/dist/view/viewBody.js.map +1 -0
- package/dist/view/viewContext.d.ts +81 -0
- package/dist/view/viewContext.js +49 -0
- package/dist/view/viewContext.js.map +1 -0
- package/dist/view/viewProps.d.ts +65 -8
- package/dist/view/viewProps.js +123 -36
- package/dist/view/viewProps.js.map +1 -1
- package/dist/widgets/AnalyticsBreakdownWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsBreakdownWidget.js +153 -78
- package/dist/widgets/AnalyticsBreakdownWidget.js.map +1 -1
- package/dist/widgets/AnalyticsGoalsWidget.d.ts +6 -7
- package/dist/widgets/AnalyticsGoalsWidget.js +126 -159
- package/dist/widgets/AnalyticsGoalsWidget.js.map +1 -1
- package/dist/widgets/AnalyticsMetricWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsMetricWidget.js +85 -83
- package/dist/widgets/AnalyticsMetricWidget.js.map +1 -1
- package/dist/widgets/AnalyticsRealtimeWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsRealtimeWidget.js +81 -61
- package/dist/widgets/AnalyticsRealtimeWidget.js.map +1 -1
- package/dist/widgets/AnalyticsTrendWidget.d.ts +7 -3
- package/dist/widgets/AnalyticsTrendWidget.js +134 -100
- package/dist/widgets/AnalyticsTrendWidget.js.map +1 -1
- package/dist/widgets/ComparisonDelta.js +33 -42
- package/dist/widgets/ComparisonDelta.js.map +1 -1
- package/dist/widgets/RealtimeCounter.d.ts +27 -3
- package/dist/widgets/RealtimeCounter.js +90 -62
- package/dist/widgets/RealtimeCounter.js.map +1 -1
- package/dist/widgets/WidgetCard.d.ts +80 -0
- package/dist/widgets/WidgetCard.js +99 -0
- package/dist/widgets/WidgetCard.js.map +1 -0
- package/dist/widgets/WidgetFrame.js +42 -0
- package/dist/widgets/WidgetFrame.js.map +1 -0
- package/dist/widgets/WidgetShimmer.d.ts +55 -0
- package/dist/widgets/WidgetShimmer.js +86 -0
- package/dist/widgets/WidgetShimmer.js.map +1 -0
- package/dist/widgets/breakdownTypes.js +18 -2
- package/dist/widgets/breakdownTypes.js.map +1 -1
- package/dist/widgets/customWidget.d.ts +5 -1
- package/dist/widgets/customWidget.js +6 -7
- package/dist/widgets/customWidget.js.map +1 -1
- package/dist/widgets/defaultLayout.d.ts +26 -0
- package/dist/widgets/defaultLayout.js +51 -0
- package/dist/widgets/defaultLayout.js.map +1 -0
- package/dist/widgets/defaults.d.ts +4 -3
- package/dist/widgets/defaults.js +76 -24
- package/dist/widgets/defaults.js.map +1 -1
- package/dist/widgets/fieldRows.js +14 -0
- package/dist/widgets/fieldRows.js.map +1 -0
- package/dist/widgets/filterCaption.js +26 -0
- package/dist/widgets/filterCaption.js.map +1 -0
- package/dist/widgets/filterField.d.ts +15 -0
- package/dist/widgets/filterField.js +86 -0
- package/dist/widgets/filterField.js.map +1 -0
- package/dist/widgets/filterValueLabel.d.ts +1 -0
- package/dist/widgets/filterValueLabel.js +45 -0
- package/dist/widgets/filterValueLabel.js.map +1 -0
- package/dist/widgets/notices.js +79 -0
- package/dist/widgets/notices.js.map +1 -0
- package/dist/widgets/prepareWidgetRead.d.ts +24 -0
- package/dist/widgets/prepareWidgetRead.js +110 -0
- package/dist/widgets/prepareWidgetRead.js.map +1 -0
- package/dist/widgets/range.js +26 -21
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/readForWidget.d.ts +32 -13
- package/dist/widgets/readForWidget.js +52 -63
- package/dist/widgets/readForWidget.js.map +1 -1
- package/dist/widgets/readForWidgetBreakdown.d.ts +45 -18
- package/dist/widgets/readForWidgetBreakdown.js +71 -58
- package/dist/widgets/readForWidgetBreakdown.js.map +1 -1
- package/dist/widgets/readForWidgetGoals.d.ts +21 -17
- package/dist/widgets/readForWidgetGoals.js +72 -52
- package/dist/widgets/readForWidgetGoals.js.map +1 -1
- package/dist/widgets/readForWidgetRealtime.d.ts +24 -11
- package/dist/widgets/readForWidgetRealtime.js +69 -41
- package/dist/widgets/readForWidgetRealtime.js.map +1 -1
- package/dist/widgets/readForWidgetSeries.d.ts +29 -24
- package/dist/widgets/readForWidgetSeries.js +66 -114
- package/dist/widgets/readForWidgetSeries.js.map +1 -1
- package/dist/widgets/readMeta.d.ts +48 -0
- package/dist/widgets/readMeta.js +66 -0
- package/dist/widgets/readMeta.js.map +1 -0
- package/dist/widgets/realtimePoll.d.ts +1 -0
- package/dist/widgets/realtimePoll.js +56 -16
- package/dist/widgets/realtimePoll.js.map +1 -1
- package/dist/widgets/registerWidgets.js +207 -124
- package/dist/widgets/registerWidgets.js.map +1 -1
- package/dist/widgets/stateKeys.js +30 -0
- package/dist/widgets/stateKeys.js.map +1 -0
- package/dist/widgets/titleForecast.js +89 -0
- package/dist/widgets/titleForecast.js.map +1 -0
- package/dist/widgets/types.d.ts +16 -0
- package/dist/widgets/types.js +2 -0
- package/dist/widgets/types.js.map +1 -1
- package/dist/widgets/viewLink.d.ts +24 -6
- package/dist/widgets/viewLink.js +36 -26
- package/dist/widgets/viewLink.js.map +1 -1
- package/dist/widgets/widgetData.js +34 -0
- package/dist/widgets/widgetData.js.map +1 -0
- package/dist/widgets/widgetWindow.d.ts +1 -0
- package/dist/widgets/widgetWindow.js +51 -0
- package/dist/widgets/widgetWindow.js.map +1 -0
- package/package.json +61 -42
- package/dist/capture/getTrackerConfig.d.ts +0 -20
- package/dist/capture/getTrackerConfig.js +0 -31
- package/dist/capture/getTrackerConfig.js.map +0 -1
- package/dist/capture/slots.d.ts +0 -8
- package/dist/capture/trackerConfig.d.ts +0 -33
- package/dist/charts/styles.js +0 -59
- package/dist/charts/styles.js.map +0 -1
- package/dist/exports/next.d.ts +0 -3
- package/dist/exports/next.js +0 -3
- package/dist/fields/config/SourceSelectField.d.ts +0 -14
- package/dist/fields/dateRange/styles.js +0 -23
- package/dist/fields/dateRange/styles.js.map +0 -1
- package/dist/goals/GoalSelectField.d.ts +0 -7
- package/dist/native/collections/events.js +0 -121
- package/dist/native/collections/events.js.map +0 -1
- package/dist/native/collections/rollups.js +0 -151
- package/dist/native/collections/rollups.js.map +0 -1
- package/dist/native/collections/seen.js +0 -47
- package/dist/native/collections/seen.js.map +0 -1
- package/dist/native/ingest/flushBatch.js +0 -60
- package/dist/native/ingest/flushBatch.js.map +0 -1
- package/dist/native/ingest/salt.js +0 -14
- package/dist/native/ingest/salt.js.map +0 -1
- package/dist/native/ingest/writeBuffer.js +0 -55
- package/dist/native/ingest/writeBuffer.js.map +0 -1
- package/dist/native/ingest/writeEvent.js +0 -14
- package/dist/native/ingest/writeEvent.js.map +0 -1
- package/dist/native/query/eventAgg.js +0 -161
- package/dist/native/query/eventAgg.js.map +0 -1
- package/dist/native/realtime/buildRealtime.js +0 -53
- package/dist/native/realtime/buildRealtime.js.map +0 -1
- package/dist/native/retention/pruneTask.js +0 -29
- package/dist/native/retention/pruneTask.js.map +0 -1
- package/dist/native/rollupAcc.js +0 -64
- package/dist/native/rollupAcc.js.map +0 -1
- package/dist/native/rollups/applyDistinctDeltas.js +0 -9
- package/dist/native/rollups/applyDistinctDeltas.js.map +0 -1
- package/dist/native/rollups/bumpRollup.js +0 -73
- package/dist/native/rollups/bumpRollup.js.map +0 -1
- package/dist/native/rollups/deltas.js +0 -90
- package/dist/native/rollups/deltas.js.map +0 -1
- package/dist/native/rollups/insertIfNew.js +0 -53
- package/dist/native/rollups/insertIfNew.js.map +0 -1
- package/dist/next/captureRewrites.d.ts +0 -41
- package/dist/next/captureRewrites.js +0 -56
- package/dist/next/captureRewrites.js.map +0 -1
- package/dist/next/posthogProxyRewrites.d.ts +0 -41
- package/dist/next/posthogProxyRewrites.js +0 -45
- package/dist/next/posthogProxyRewrites.js.map +0 -1
- package/dist/plugin/paths.js +0 -27
- package/dist/plugin/paths.js.map +0 -1
- package/dist/query/errors.js +0 -10
- package/dist/query/errors.js.map +0 -1
- package/dist/react/TrackerBoot.d.ts +0 -22
- package/dist/rsc/AnalyticsScripts.d.ts +0 -30
- package/dist/rsc/AnalyticsScripts.js +0 -41
- package/dist/rsc/AnalyticsScripts.js.map +0 -1
- package/dist/surfacing/queue.js +0 -60
- package/dist/surfacing/queue.js.map +0 -1
- package/dist/surfacing/retryPolicy.js +0 -15
- package/dist/surfacing/retryPolicy.js.map +0 -1
- package/dist/tracker/autoCapture.d.ts +0 -48
- package/dist/tracker/consent.d.ts +0 -24
- package/dist/tracker/consent.js +0 -48
- package/dist/tracker/consent.js.map +0 -1
- package/dist/tracker/loadScript.d.ts +0 -14
- package/dist/tracker/pageTracking.d.ts +0 -17
- package/dist/tracker/registry.d.ts +0 -27
- package/dist/tracker/sinks/native.d.ts +0 -22
- package/dist/tracker/sinks/plausible.d.ts +0 -14
- package/dist/tracker/sinks/posthog.d.ts +0 -14
- package/dist/tracker/sinks/umami.d.ts +0 -13
- package/dist/tracker/sinks/vendor.d.ts +0 -14
- package/dist/view/sections/styles.js +0 -74
- package/dist/view/sections/styles.js.map +0 -1
- package/dist/widgets/WidgetViewLink.js +0 -17
- package/dist/widgets/WidgetViewLink.js.map +0 -1
- package/dist/widgets/cardChrome.d.ts +0 -8
- package/dist/widgets/cardChrome.js +0 -46
- package/dist/widgets/cardChrome.js.map +0 -1
- package/dist/widgets/comparison.js +0 -43
- package/dist/widgets/comparison.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/native/store/types.ts"],"sourcesContent":["import type { AnalyticsFilter, DimensionKey, FilterOperatorMap } from '../../core/contract'\nimport type { GoalCompletion } from '../../goals/match'\nimport type { CalendarDay } from '../../timeframe/calendar'\nimport type { CardinalityCaps } from './caps'\nimport type { MetricParts } from './parts'\nimport type { RawDimension } from './rawRead'\n\n/**\n * What a hit was: an engagement adds time, scroll and items seen to the pageview before it.\n * @beta\n */\nexport type HitType = 'pageview' | 'event' | 'goal' | 'engagement'\n\n/**\n * How a hit was measured, as the page states it: `c` cookieless, `a` anonymous (no visitor id,\n * country alone, no engagement), `f` full. A statement of the page, not proof of consent.\n * @beta\n */\nexport type HitMode = 'c' | 'a' | 'f'\n\nexport const HIT_MODES: readonly HitMode[] = ['c', 'a', 'f']\n\n/**\n * One row of `analytics-hits`; an absent field is a null column. An engagement row carries no\n * visitor attributes: its pageview's row has them.\n */\nexport interface HitRow {\n\t/**\n\t * A ULID of `ts`, or `o` + an order's dedupe key, which refuses a retried order: `ow.` for the\n\t * browser's record of a sale, `os.` for the server's, one digest behind both.\n\t */\n\tid: string\n\t/** `''` on an unscoped install. */\n\tscope: string\n\t/** When it happened; an engagement's is its pageview's. */\n\tts: Date\n\t/** An engagement's arrival, where the reading time it reports ends. */\n\tlastAt?: Date\n\ttype: HitType\n\thostname: string\n\tpath: string\n\t/** The day's visitor id; `''` for a server event that came with no visitor at all. */\n\tv: string\n\t/** A pageview opening a visit from outside the site, or with no referrer at all. */\n\tlanding: boolean\n\t/** Recorded by server code. */\n\tserver: boolean\n\t/** Absent on a hit stored before modes existed, which counts as `f`. */\n\tmode?: HitMode\n\tname?: string\n\t/** The other site a landing came from, as a bare host. */\n\tref?: string\n\tsource?: string\n\tchannel?: string\n\t/** The channel taxonomy `channel` was decided under. */\n\tchannelVersion?: number\n\t/** The ad click id the page's query carried, by name (`gclid`), never its value. */\n\tclickId?: string\n\tutmSource?: string\n\tutmMedium?: string\n\tutmCampaign?: string\n\tutmContent?: string\n\tutmTerm?: string\n\tcountry?: string\n\tregion?: string\n\tcity?: string\n\tlanguage?: string\n\tdevice?: string\n\tbrowser?: string\n\tos?: string\n\tdurationMs?: number\n\tscrollDepth?: number\n\tvalue?: number\n\toriginalValue?: number\n\t/** Goals the hit completed, how many. */\n\tconversions?: number\n\t/** What the goals it completed were worth together. */\n\trevenue?: number\n\tcurrency?: string\n\toriginalCurrency?: string\n\titem?: string\n\tprops?: Record<string, unknown>\n\tgoals?: GoalCompletion[]\n\t/** On an engagement only: the item refs seen since its previous one. */\n\timpressions?: string[]\n}\n\n/** What one `append` did: rows written, and hits whose id the table already held. */\nexport interface AppendResult {\n\twritten: number\n\tduplicates: number\n}\n\n/** One scope's hits from `start` up to, not including, `end`. */\nexport interface TimeWindow {\n\tscope: string\n\tstart: Date\n\tend: Date\n}\n\n/** The hits of one scope, of several, or of every one, from `start` up to `end`. */\nexport interface HitWindow {\n\tscope?: string\n\tscopes?: readonly string[]\n\tstart: Date\n\tend: Date\n\thostname?: string\n}\n\n/** How a raw read ranks its rows before `limit` cuts them; ties go by value, then bucket. */\nexport interface RawOrder {\n\tpart: keyof MetricParts\n\t/** Ranks by `part / per` instead; a row with none of `per` comes last either way. */\n\tper?: keyof MetricParts\n\t/** Taken off `per` first, a null one as none: the pageviews time on page does not average over. */\n\tless?: keyof MetricParts\n\tdir: 'asc' | 'desc'\n}\n\n/**\n * A read of the raw hits, grouped, ordered and limited by the database. Visit dimensions read the\n * visit a hit belongs to (`rawRead.ts` says how visits are cut); every other dimension the hit.\n */\nexport interface RawRead {\n\t/** One scope's hits; absent reads every scope's, or those `scopes` names. */\n\tscope?: string\n\t/** Several scopes' hits, `scope` left out: one read for scopes whose days are cut alike. */\n\tscopes?: readonly string[]\n\tstart: Date\n\t/** Exclusive. */\n\tend: Date\n\t/** Where cutting visits starts (the local day's start), so an earlier visit keeps its entry. */\n\tfrom?: Date\n\thostname?: string\n\tpath?: string\n\t/** Only this item's views and clicks. */\n\titem?: string\n\tfilters: readonly AnalyticsFilter[]\n\tgroupBy?: DimensionKey\n\t/** Ascending bucket starts, the first at or before `start`. */\n\tbuckets?: readonly Date[]\n\t/** Count visits; a visit dimension in `groupBy` or `filters` counts them anyway. */\n\tsessions: boolean\n\t/** Only these values of `groupBy`, to fill in rows another read ranked. */\n\tvalues?: readonly string[]\n\torder?: RawOrder\n\tlimit?: number\n\ttimeoutMs: number\n\t/** The read's own: aborted, a statement still waiting for a connection is dropped unrun. */\n\tsignal?: AbortSignal\n}\n\n/**\n * A value of `groupBy` (null without one), the index of its bucket, and its parts, a part the read\n * does not count being null. With neither `groupBy` nor `buckets` a read answers exactly one row.\n */\nexport interface RawRow {\n\tvalue: string | null\n\tbucket?: number\n\tparts: MetricParts\n}\n\n/** What a realtime read answers beside the window's totals. */\nexport type RealtimePart = 'minutes' | 'pages' | 'sources'\n\n/** Who is on the site in a recent window, normally the last 5 to 60 minutes. */\nexport interface RealtimeRead {\n\t/** One scope's hits; absent reads every scope's, or those `scopes` names. */\n\tscope?: string\n\t/** Several scopes' hits, `scope` left out: the `(scope, ts)` index serves an All sites read. */\n\tscopes?: readonly string[]\n\tstart: Date\n\tend: Date\n\t/** Where the visits behind `sources` start reading, as `RawRead.from`. */\n\tfrom?: Date\n\thostname?: string\n\tpath?: string\n\t/** How many pages and sources to rank by visitors. Default 10. */\n\ttop?: number\n\t/** The parts it reads beside the totals; every part when absent. */\n\tparts?: readonly RealtimePart[]\n\ttimeoutMs: number\n\t/** As `RawRead.signal`. */\n\tsignal?: AbortSignal\n}\n\nexport interface RealtimeCount {\n\t/** Visitors with a pageview, an event or a goal in the window. */\n\tvisitors: number\n\tpageviews: number\n}\n\ninterface RealtimeMinute extends RealtimeCount {\n\t/** Only minutes with activity are listed. */\n\tminute: Date\n}\n\nexport interface RealtimeTop extends RealtimeCount {\n\tvalue: string\n}\n\nexport interface RealtimeResult extends RealtimeCount {\n\tminutes: RealtimeMinute[]\n\tpages: RealtimeTop[]\n\tsources: RealtimeTop[]\n}\n\n/** A local day of one scope, as the instants it runs between in its zone (see `dayWindow`). */\nexport interface DayWindow {\n\tscope: string\n\tday: CalendarDay\n\ttz: string\n\t/**\n\t * Where counting starts: the day's first instant in `tz`, or where the count of the day before\n\t * ended when that one is fixed in another zone (see `windowOf`).\n\t */\n\tstart: Date\n\t/** The next day's first instant in `tz`, which is not always 24 hours on. */\n\tend: Date\n}\n\n/** A dimension aggregate rows are kept by; `''` is the site row's, which has none. */\nexport type AggDim = RawDimension | ''\n\n/**\n * What a completed day's marker says: `partial` for a snapshot of a day still running,\n * `provisional` for a closed day aggregated once, `final` for its last aggregation.\n */\nexport type CompletedDayStatus = 'partial' | 'provisional' | 'final'\n\nexport interface AggregateRun {\n\t/**\n\t * The owner of the day's lease (`day:<scope>:<day>`), claimed before the call. Nothing the run\n\t * writes is read unless it still holds that lease when the day is completed.\n\t */\n\trunId: string\n\tcaps: CardinalityCaps\n\tstatus: CompletedDayStatus\n\t/** Keeps the item by page rows; false when the install counts items without their pages. */\n\titemPages?: boolean\n\t/** Ms its count may run where the database can stop it: set for a count a read started alone. */\n\ttimeoutMs?: number\n}\n\nexport interface AggregateResult {\n\t/** False when the run did not hold the day's lease, or lost it: nothing it wrote is read. */\n\tcompleted: boolean\n\t/** Hits the run counted; 0 when it was refused before reading any. */\n\thits: number\n\t/** Rows the day now holds from this run, `(other)` rows included; 0 unless completed. */\n\trows: number\n}\n\n/** Steps of a day's write where a test fails a run or lets another run in; unset in production. */\nexport interface AggregateHooks {\n\t/** The rows are counted and capped; nothing is written yet. */\n\tbeforeWrite?: () => Promise<void>\n\t/** A chunk of rows of the new generation is written, which no read counts yet. */\n\tafterChunk?: (written: number) => Promise<void>\n\t/** The day is completed and its previous generation not dropped yet. */\n\tafterComplete?: () => Promise<void>\n}\n\n/**\n * A sum over completed days' aggregate rows. Visitors add up across hostnames exactly (an id is per\n * hostname), and across days as a sum of daily visitors (an id is per day too).\n */\nexport interface AggregateRead {\n\t/** One scope's rows; absent sums every scope's (or `scopes`), each over its own local days. */\n\tscope?: string\n\t/** Several scopes' rows, `scope` left out. */\n\tscopes?: readonly string[]\n\t/** Ranges of local days, both ends included. */\n\tdays: ReadonlyArray<readonly [CalendarDay, CalendarDay]>\n\t/** One hostname's rows; absent sums every hostname's. */\n\thostname?: string\n\tdim: AggDim\n\t/** A pair's second dimension (`goal` by `channel`, `item` by `page`); absent: no pair. */\n\tdim2?: AggDim\n\t/** Only the rows of this value of `dim`. */\n\tvalue?: string\n\t/** Only these values of the grouped dimension, to fill in rows another read ranked. */\n\tvalues?: readonly string[]\n\t/** One row, one per day, one per value of `dim`, or one per value of `dim2`. */\n\tgroupBy: 'total' | 'day' | 'value' | 'value2'\n\torder?: RawOrder\n\tlimit?: number\n\t/** As `RawRead.signal`. */\n\tsignal?: AbortSignal\n}\n\n/**\n * Shaped like a raw read's row, so the two merge directly: the grouped value (null for a total or\n * a day series), the day of a series, and the summed parts. A grouped read leaves `(other)` out.\n */\nexport interface AggregateRow {\n\tvalue: string | null\n\tday?: CalendarDay\n\tparts: MetricParts\n}\n\n/**\n * Which completed days of one scope folded one value into an `(other)` row: a dimension's value\n * (`dim2` absent), or the second values of a pair's first value (`dim2` set).\n */\nexport interface FoldRead {\n\tscope: string\n\t/** Ranges of local days, both ends included. */\n\tdays: ReadonlyArray<readonly [CalendarDay, CalendarDay]>\n\t/** One hostname's rows; absent reads every hostname's. */\n\thostname?: string\n\tdim: AggDim\n\tdim2?: AggDim\n\tvalue: string\n}\n\n/** What a stored hit's channel is classified from, each null where the hit has none. */\nexport interface ChannelTuple {\n\tref: string | null\n\tutmSource: string | null\n\tutmMedium: string | null\n\tclickId: string | null\n}\n\n/** A scope's hits of a window to classify again, the ones decided under an older taxonomy. */\nexport interface ReclassifyRun extends TimeWindow {\n\t/** The taxonomy hits are classified under now; only hits of an older one are read. */\n\tversion: number\n\t/** The channel a tuple classifies into under `version`. */\n\tclassify: (tuple: ChannelTuple) => string\n}\n\n/** At most `limit` rows of one scope, older than a cut: one chunk of a prune. */\ninterface PruneChunk {\n\tscope: string\n\tlimit: number\n}\n\n/** An order record's place in `ordersIn`'s order: its time, then its id. */\nexport interface OrderKey {\n\tid: string\n\tts: Date\n}\n\n/** One visitor's hits on one hostname from `start` through `end`. */\nexport interface LandingProbe {\n\tscope: string\n\thostname: string\n\tv: string\n\tstart: Date\n\tend: Date\n}\n\n/**\n * Where hits are kept and read from. `append` never runs inside a transaction the host holds, so a\n * hit lands whether the host's own work commits or not.\n */\nexport interface EventStore {\n\treadonly id: string\n\treadonly features: {\n\t\t/** Keeps daily aggregates beside the raw hits. */\n\t\taggregates: boolean\n\t\t/** Answers a raw read over any range, rather than the raw retention window alone. */\n\t\trawAnyRange: boolean\n\t\t/** The operators `readRaw` filters each dimension with; any other filter is refused. */\n\t\tfilters: FilterOperatorMap\n\t}\n\t/**\n\t * How long one statement may hold up this process's thread, in ms: set where statements run on\n\t * it to their end (SQLite without its worker threads), null or absent where they never do.\n\t */\n\tblockingBudgetMs?(): Promise<number | null>\n\t/** Writes every hit whose id is new; an id already stored or repeated in the call is skipped. */\n\tappend(hits: readonly HitRow[]): Promise<AppendResult>\n\t/** The hit stored under `id`, null when none is: one primary key lookup. */\n\thitById(id: string): Promise<HitRow | null>\n\t/**\n\t * The latest landing pageview of one visitor from `start` through `end`, null when there is\n\t * none: read backwards off the `(scope, ts)` index from `end`, so it costs the hits in between.\n\t */\n\tlatestLanding(probe: LandingProbe): Promise<HitRow | null>\n\t/**\n\t * The ids and times of a scope's order records (`o` ids) in a window, oldest first by time then\n\t * id, at most `limit`; with `after`, only those that come after it in that order.\n\t */\n\tordersIn(window: TimeWindow & { limit: number; after?: OrderKey }): Promise<OrderKey[]>\n\t/**\n\t * Refused with a `ReadTimeoutError` past `timeoutMs`, or on SQLite before reading more than it\n\t * allows. An order both sides recorded counts as `countedHit` says, as in a day's aggregation.\n\t */\n\treadRaw(read: RawRead): Promise<RawRow[]>\n\trealtime(read: RealtimeRead): Promise<RealtimeResult>\n\thasHits(window: TimeWindow): Promise<boolean>\n\t/**\n\t * A scope's hits in a window, counted off the `(scope, ts)` index no further than `atMost` + 1:\n\t * an answer above `atMost` says only that there are more.\n\t */\n\tcountHits(window: TimeWindow, atMost: number): Promise<number>\n\t/** {@link countHits} of several scopes over one window, in one statement per share of them. */\n\tcountEach(\n\t\tscopes: readonly string[],\n\t\twindow: Omit<TimeWindow, 'scope'>,\n\t\tatMost: number\n\t): Promise<Map<string, number>>\n\t/** Every scope with hits (`''` for unscoped ones), in code point order. */\n\tscopes(): Promise<string[]>\n\t/**\n\t * Counts and writes a day beside its old rows, swapped whole at completion on `run.runId`'s\n\t * lease; an order both sides recorded counts as `countedHit` says.\n\t */\n\taggregateDay(window: DayWindow, run: AggregateRun): Promise<AggregateResult>\n\t/** Reads only completed days: a row counts when its `gen` is its day marker's. */\n\treadAggregates(read: AggregateRead): Promise<AggregateRow[]>\n\t/**\n\t * The completed days on which some hostname read folded `value` into an `(other)` row: kept no\n\t * row of it beside one (a dimension), or kept one for the first value (a pair). Oldest first.\n\t */\n\tfoldedDays(read: FoldRead): Promise<CalendarDay[]>\n\t/** Hostnames a scope's daily totals hold rows of from `since` on, whatever their generation. */\n\thostnames(scope: string, since: CalendarDay): Promise<string[]>\n\t/** The earliest hit a scope holds, an order's tombstone included, or null when it holds none. */\n\toldestHit(scope: string): Promise<Date | null>\n\t/**\n\t * Deletes up to `limit` of a scope's hits before `before`, but turns an order's record into its\n\t * tombstone (`tombstoneOf`) until `expireOrders` deletes it. Answers how many it changed.\n\t */\n\tpruneHits(chunk: PruneChunk & { before: Date; from?: Date }): Promise<number>\n\t/** Deletes up to `limit` of a scope's order records from before `before`, answering how many. */\n\texpireOrders(chunk: PruneChunk & { before: Date }): Promise<number>\n\t/** Deletes up to `limit` of a scope's aggregate rows of days before `beforeDay`. */\n\tpruneAggregates(chunk: PruneChunk & { beforeDay: CalendarDay }): Promise<number>\n\t/**\n\t * Deletes a day's rows of every generation but `keep`, the one its marker names (`''` keeps\n\t * none): what a run that stopped before clearing them left. The caller holds the day's lease.\n\t */\n\tsweepGenerations(day: { scope: string; day: CalendarDay }, keep: string): Promise<number>\n\t/**\n\t * Classifies a window's hits of an older taxonomy again, a day and a few tuples per statement,\n\t * matching each tuple null-safely. Answers how many hits it changed.\n\t */\n\treclassify(run: ReclassifyRun): Promise<number>\n}\n\n/**\n * `open` never counted since it closed, `partial` a snapshot, `provisional` counted once closed,\n * `dirty` to count again, `failed` given up on (whatever count it had kept).\n */\nexport type DayStatus = 'open' | 'partial' | 'provisional' | 'final' | 'empty' | 'dirty' | 'failed'\n\n/** Where one local day of one scope stands. */\nexport interface DayMarker {\n\tscope: string\n\tday: CalendarDay\n\t/** The zone the day is cut in; once completed, the zone its aggregates were counted in. */\n\ttz: string\n\t/**\n\t * Where its count started when that was not the day's own start in `tz`: where the fixed count\n\t * of the day before ended, in an older zone. Null: the day's own start.\n\t */\n\tstart: Date | null\n\tstatus: DayStatus\n\t/** The aggregation version the day's rows were written with. */\n\tversion: number | null\n\t/** The generation of the day's readable rows, set by the run that completed it; null before. */\n\tgen: string | null\n\t/** How many hits that run counted. */\n\thits: number | null\n\tleaseOwner: string | null\n\tleaseUntil: Date | null\n\t/** When the day is aggregated a last time and turns final: its end plus a day and 15 minutes. */\n\tfinalAfter: Date | null\n\taggregatedAt: Date | null\n\t/** Counts maintenance started since the day was last counted; absent: none. */\n\tfailures?: number\n}\n\n/** What a completion also asks of the marker it replaces. */\nexport interface CompleteGuard {\n\t/** Refused while the day is dirty: a hit landed on it after the run read it. */\n\tclean?: boolean\n}\n\n/** A day to keep a marker for: created `open` when it has none, left alone when it has one. */\nexport type NewDayMarker = Pick<DayMarker, 'scope' | 'day' | 'tz'>\n\n/**\n * A day a run writes a generation beside the readable one on, noted before it writes any row: a\n * run that stops before clearing the dead generation leaves the note for maintenance to finish.\n */\nexport interface DropNote {\n\tscope: string\n\tday: CalendarDay\n\t/** The generation the run writes. */\n\tgen: string\n}\n\n/**\n * The engine's coordination rows. Every write runs on the store's own connection, outside any\n * transaction the host holds, and every lease is one conditional write.\n */\nexport interface StateStore {\n\t/** A day's salt, created on first use; concurrent creators all get the one the database kept. */\n\tsalt(day: CalendarDay): Promise<string>\n\t/** A scope's markers from `from` through `to`, oldest first; a day without one is absent. */\n\tmarkers(scope: string, from: CalendarDay, to: CalendarDay): Promise<DayMarker[]>\n\t/** The markers of several scopes from `from` through `to`, by scope and then day. */\n\tmarkersIn(scopes: readonly string[], from: CalendarDay, to: CalendarDay): Promise<DayMarker[]>\n\tensureMarkers(markers: readonly NewDayMarker[]): Promise<void>\n\t/**\n\t * Won when the lease is free, expired or already `owner`'s (a renewal). A `lease:` row is\n\t * created on first claim; a `day:` key needs its marker first.\n\t */\n\tclaim(key: string, owner: string, ttlMs: number): Promise<boolean>\n\t/**\n\t * Extends a lease `owner` still holds, expired or not: false once another run took it or a\n\t * dirty mark revoked it, where `claim` would take a free lease back.\n\t */\n\trenew(key: string, owner: string, ttlMs: number): Promise<boolean>\n\t/** Gives a lease back early; false when `owner` no longer holds it. */\n\trelease(key: string, owner: string): Promise<boolean>\n\t/** Whether someone holds a `lease:` key now: claimed, and neither expired nor released. */\n\theld(key: string): Promise<boolean>\n\t/**\n\t * Writes a day's new state and clears its lease, refused unless `owner` still holds the lease,\n\t * and with `clean` also while the day is marked dirty.\n\t */\n\tcomplete(marker: DayMarker, owner: string, guard?: CompleteGuard): Promise<boolean>\n\t/**\n\t * Writes a day's status and failures while `owner` keeps its lease; false when it no longer\n\t * holds it.\n\t */\n\tattempt(marker: DayMarker, owner: string): Promise<boolean>\n\t/**\n\t * Marks days for another aggregation, forgetting their failures, and revokes their leases: a\n\t * running owner can neither complete nor renew one, and the next run may claim it at once.\n\t */\n\tmarkDirty(scope: string, days: readonly CalendarDay[]): Promise<void>\n\t/**\n\t * Unleased days due for aggregation at `now`, oldest first by day and then scope; with `after`,\n\t * only those that come after it in that order.\n\t */\n\tpending(now: Date, limit: number, after?: Pick<DayMarker, 'scope' | 'day'>): Promise<DayMarker[]>\n\t/** Deletes a scope's day markers before `beforeDay`, once their aggregate rows are gone. */\n\tdropMarkers(scope: string, beforeDay: CalendarDay): Promise<number>\n\t/**\n\t * The instant before which a scope's raw hits may have been deleted, null while none ever was:\n\t * the one definition of what raw hits still cover.\n\t */\n\tprunedBefore(scope: string): Promise<Date | null>\n\t/** {@link prunedBefore} of several scopes, a scope never pruned absent. */\n\tprunedBeforeIn(scopes: readonly string[]): Promise<Map<string, Date>>\n\t/** Records a prune's cut before it deletes, kept only when later than the one recorded. */\n\trecordPruned(scope: string, before: Date): Promise<void>\n\t/** The zone of the scope's newest day counted at least once: its last good zone. */\n\tlastZone(scope: string): Promise<string | null>\n\t/** Every scope holding a day marker, in code point order. */\n\tscopes(): Promise<string[]>\n\tnoteDrop(note: DropNote): Promise<void>\n\t/** At most `limit` notes, of any age. */\n\tdrops(limit: number): Promise<DropNote[]>\n\tclearDrop(note: DropNote): Promise<void>\n\t/** Deletes the expired salts, answering how many. */\n\tsweep(now: Date): Promise<number>\n\t/** Records that a task finished a run now. */\n\tbeat(task: string): Promise<void>\n\tlastBeat(task: string): Promise<Date | null>\n\t/** Where a task's last run stopped short, for the next to start from; null when it finished. */\n\tcursor(task: string): Promise<string | null>\n\t/** Records where a task's run stopped short, or with null that it finished. */\n\tsetCursor(task: string, cursor: string | null): Promise<void>\n\t/** A scope's configuration token, null while none was ever stored. */\n\tconfigToken(scope: string): Promise<string | null>\n\tsetConfigToken(scope: string, token: string): Promise<void>\n}\n\n/** What sync, warm and cache sweep tasks keep in `analytics-state`: leases, heartbeats, cursors. */\nexport type TaskStateStore = Pick<\n\tStateStore,\n\t'claim' | 'release' | 'held' | 'beat' | 'lastBeat' | 'cursor' | 'setCursor'\n>\n\nexport interface StateStoreOptions {\n\t/** Clock leases and heartbeats are stamped with; plugin's clock (`currentDate`) by default. */\n\tnow?: () => Date\n\t/** The state collection's slug; `analytics-state` by default. */\n\tslug?: string\n}\n"],"mappings":";AAoBA,MAAa,YAAgC;CAAC;CAAK;CAAK;AAAG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PayloadRequest } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/native/tasks/maintainTask.d.ts
|
|
4
|
+
declare const MAINTAIN_TASK_SLUG: "analytics-maintain";
|
|
5
|
+
/**
|
|
6
|
+
* The task's input when queued by hand: a stretch of days to count again. A job's input is stored
|
|
7
|
+
* as JSON, so the instants arrive as ISO text whichever way they were queued.
|
|
8
|
+
*/
|
|
9
|
+
interface MaintainTaskInput {
|
|
10
|
+
rebuild?: {
|
|
11
|
+
scope?: string;
|
|
12
|
+
from: string | Date;
|
|
13
|
+
to: string | Date;
|
|
14
|
+
reclassify?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MAINTAIN_TASK_SLUG, MaintainTaskInput };
|
|
19
|
+
//# sourceMappingURL=maintainTask.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isRecord } from "../../core/values.js";
|
|
2
|
+
import { TASK_SLUGS } from "../../core/jobs.js";
|
|
3
|
+
import { concurrencyFor, scheduleFor } from "../../maintenance/taskSchedule.js";
|
|
4
|
+
import { checkRebuildInput } from "../engine/rebuild.js";
|
|
5
|
+
//#region src/native/tasks/maintainTask.ts
|
|
6
|
+
const MAINTAIN_TASK_SLUG = TASK_SLUGS.maintain;
|
|
7
|
+
/** How long one run of the task works before it leaves the rest to the next. */
|
|
8
|
+
const MAINTAIN_TASK_BUDGET_MS = 24e4;
|
|
9
|
+
const refuse = (message) => {
|
|
10
|
+
throw new Error(`analytics: the ${MAINTAIN_TASK_SLUG} task's ${message}`);
|
|
11
|
+
};
|
|
12
|
+
const instantOf = (value, name) => {
|
|
13
|
+
const date = value instanceof Date ? value : typeof value === "string" ? new Date(value) : null;
|
|
14
|
+
return date !== null && !Number.isNaN(date.getTime()) ? date : refuse(`rebuild.${name} must be an ISO instant`);
|
|
15
|
+
};
|
|
16
|
+
/** The task's input checked: a rebuild needs two instants, and anything malformed fails the job. */
|
|
17
|
+
const parseMaintainInput = (input) => {
|
|
18
|
+
if (input === void 0 || input === null) return {};
|
|
19
|
+
if (!isRecord(input) || Array.isArray(input)) return refuse("input must be an object such as { rebuild: { from, to } }");
|
|
20
|
+
const { rebuild } = input;
|
|
21
|
+
if (rebuild === void 0 || rebuild === null) return {};
|
|
22
|
+
if (!isRecord(rebuild) || Array.isArray(rebuild)) return refuse("rebuild must be an object such as { from, to }");
|
|
23
|
+
const { scope, reclassify } = rebuild;
|
|
24
|
+
if (scope !== void 0 && typeof scope !== "string") refuse("rebuild.scope must be a scope id");
|
|
25
|
+
if (reclassify !== void 0 && typeof reclassify !== "boolean") refuse("rebuild.reclassify must be true or false");
|
|
26
|
+
return { rebuild: checkRebuildInput({
|
|
27
|
+
from: instantOf(rebuild.from, "from"),
|
|
28
|
+
to: instantOf(rebuild.to, "to"),
|
|
29
|
+
...typeof scope === "string" ? { scope } : {},
|
|
30
|
+
...typeof reclassify === "boolean" ? { reclassify } : {}
|
|
31
|
+
}) };
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The concurrency key of a run: `analytics:maintain` for upkeep, and one per rebuild window, so a
|
|
35
|
+
* scheduled run never replaces a rebuild someone queued.
|
|
36
|
+
*/
|
|
37
|
+
const maintainKey = (input) => {
|
|
38
|
+
const rebuild = isRecord(input) ? input.rebuild : void 0;
|
|
39
|
+
if (!isRecord(rebuild)) return "analytics:maintain";
|
|
40
|
+
const part = (value) => value instanceof Date ? value.toISOString() : typeof value === "string" ? value : "";
|
|
41
|
+
return `analytics:maintain:rebuild:${part(rebuild.scope)}:${part(rebuild.from)}:${part(rebuild.to)}`;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Never retried: the next run carries on. The leases a run takes, not Payload's concurrency keys,
|
|
45
|
+
* keep two runs from doing the work twice.
|
|
46
|
+
*/
|
|
47
|
+
const maintainTask = (args) => ({
|
|
48
|
+
slug: MAINTAIN_TASK_SLUG,
|
|
49
|
+
retries: 0,
|
|
50
|
+
handler: async ({ input, req }) => ({ output: await args.run(req, parseMaintainInput(input)) }),
|
|
51
|
+
...scheduleFor(args.schedule),
|
|
52
|
+
...concurrencyFor("maintain", maintainKey)
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { MAINTAIN_TASK_BUDGET_MS, MAINTAIN_TASK_SLUG, maintainTask };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=maintainTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintainTask.js","names":[],"sources":["../../../src/native/tasks/maintainTask.ts"],"sourcesContent":["import type { PayloadRequest, TaskConfig } from 'payload'\nimport { type ScheduledTask, TASK_SLUGS } from '../../core/jobs'\nimport { isRecord } from '../../core/values'\nimport { concurrencyFor, scheduleFor } from '../../maintenance/taskSchedule'\nimport type { MaintainReport } from '../engine/maintenance'\nimport { checkRebuildInput, type RebuildDaysInput } from '../engine/rebuild'\n\nexport const MAINTAIN_TASK_SLUG = TASK_SLUGS.maintain\n\n/** How long one run of the task works before it leaves the rest to the next. */\nexport const MAINTAIN_TASK_BUDGET_MS = 240_000\n\n/**\n * The task's input when queued by hand: a stretch of days to count again. A job's input is stored\n * as JSON, so the instants arrive as ISO text whichever way they were queued.\n */\nexport interface MaintainTaskInput {\n\trebuild?: {\n\t\tscope?: string\n\t\tfrom: string | Date\n\t\tto: string | Date\n\t\treclassify?: boolean\n\t}\n}\n\nconst refuse = (message: string): never => {\n\tthrow new Error(`analytics: the ${MAINTAIN_TASK_SLUG} task's ${message}`)\n}\n\nconst instantOf = (value: unknown, name: string): Date => {\n\tconst date = value instanceof Date ? value : typeof value === 'string' ? new Date(value) : null\n\treturn date !== null && !Number.isNaN(date.getTime())\n\t\t? date\n\t\t: refuse(`rebuild.${name} must be an ISO instant`)\n}\n\n/** The task's input checked: a rebuild needs two instants, and anything malformed fails the job. */\nexport const parseMaintainInput = (input: unknown): { rebuild?: RebuildDaysInput } => {\n\tif (input === undefined || input === null) {\n\t\treturn {}\n\t}\n\tif (!isRecord(input) || Array.isArray(input)) {\n\t\treturn refuse('input must be an object such as { rebuild: { from, to } }')\n\t}\n\tconst { rebuild } = input\n\tif (rebuild === undefined || rebuild === null) {\n\t\treturn {}\n\t}\n\tif (!isRecord(rebuild) || Array.isArray(rebuild)) {\n\t\treturn refuse('rebuild must be an object such as { from, to }')\n\t}\n\tconst { scope, reclassify } = rebuild\n\tif (scope !== undefined && typeof scope !== 'string') {\n\t\trefuse('rebuild.scope must be a scope id')\n\t}\n\tif (reclassify !== undefined && typeof reclassify !== 'boolean') {\n\t\trefuse('rebuild.reclassify must be true or false')\n\t}\n\treturn {\n\t\trebuild: checkRebuildInput({\n\t\t\tfrom: instantOf(rebuild.from, 'from'),\n\t\t\tto: instantOf(rebuild.to, 'to'),\n\t\t\t...(typeof scope === 'string' ? { scope } : {}),\n\t\t\t...(typeof reclassify === 'boolean' ? { reclassify } : {}),\n\t\t}),\n\t}\n}\n\n/** What one run did: the engine's upkeep, and the expired read cache entries it deleted. */\nexport interface MaintainTaskOutput extends MaintainReport {\n\tsweptCache: number\n}\n\n/**\n * The concurrency key of a run: `analytics:maintain` for upkeep, and one per rebuild window, so a\n * scheduled run never replaces a rebuild someone queued.\n */\nconst maintainKey = (input: unknown): string => {\n\tconst rebuild = isRecord(input) ? input.rebuild : undefined\n\tif (!isRecord(rebuild)) {\n\t\treturn 'analytics:maintain'\n\t}\n\tconst part = (value: unknown): string =>\n\t\tvalue instanceof Date ? value.toISOString() : typeof value === 'string' ? value : ''\n\treturn `analytics:maintain:rebuild:${part(rebuild.scope)}:${part(rebuild.from)}:${part(rebuild.to)}`\n}\n\n/**\n * Never retried: the next run carries on. The leases a run takes, not Payload's concurrency keys,\n * keep two runs from doing the work twice.\n */\nexport const maintainTask = (args: {\n\tschedule: ScheduledTask\n\trun: (req: PayloadRequest, input: { rebuild?: RebuildDaysInput }) => Promise<MaintainTaskOutput>\n}): TaskConfig<{ input: MaintainTaskInput; output: MaintainTaskOutput }> => ({\n\tslug: MAINTAIN_TASK_SLUG,\n\tretries: 0,\n\thandler: async ({ input, req }) => ({ output: await args.run(req, parseMaintainInput(input)) }),\n\t...scheduleFor(args.schedule),\n\t...concurrencyFor('maintain', maintainKey),\n})\n"],"mappings":";;;;;AAOA,MAAa,qBAAqB,WAAW;;AAG7C,MAAa,0BAA0B;AAevC,MAAM,UAAU,YAA2B;CAC1C,MAAM,IAAI,MAAM,kBAAkB,mBAAmB,UAAU,SAAS;AACzE;AAEA,MAAM,aAAa,OAAgB,SAAuB;CACzD,MAAM,OAAO,iBAAiB,OAAO,QAAQ,OAAO,UAAU,WAAW,IAAI,KAAK,KAAK,IAAI;CAC3F,OAAO,SAAS,QAAQ,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,IACjD,OACA,OAAO,WAAW,KAAK,wBAAwB;AACnD;;AAGA,MAAa,sBAAsB,UAAmD;CACrF,IAAI,UAAU,KAAA,KAAa,UAAU,MACpC,OAAO,CAAC;CAET,IAAI,CAAC,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,GAC1C,OAAO,OAAO,2DAA2D;CAE1E,MAAM,EAAE,YAAY;CACpB,IAAI,YAAY,KAAA,KAAa,YAAY,MACxC,OAAO,CAAC;CAET,IAAI,CAAC,SAAS,OAAO,KAAK,MAAM,QAAQ,OAAO,GAC9C,OAAO,OAAO,gDAAgD;CAE/D,MAAM,EAAE,OAAO,eAAe;CAC9B,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC3C,OAAO,kCAAkC;CAE1C,IAAI,eAAe,KAAA,KAAa,OAAO,eAAe,WACrD,OAAO,0CAA0C;CAElD,OAAO,EACN,SAAS,kBAAkB;EAC1B,MAAM,UAAU,QAAQ,MAAM,MAAM;EACpC,IAAI,UAAU,QAAQ,IAAI,IAAI;EAC9B,GAAI,OAAO,UAAU,WAAW,EAAE,MAAM,IAAI,CAAC;EAC7C,GAAI,OAAO,eAAe,YAAY,EAAE,WAAW,IAAI,CAAC;CACzD,CAAC,EACF;AACD;;;;;AAWA,MAAM,eAAe,UAA2B;CAC/C,MAAM,UAAU,SAAS,KAAK,IAAI,MAAM,UAAU,KAAA;CAClD,IAAI,CAAC,SAAS,OAAO,GACpB,OAAO;CAER,MAAM,QAAQ,UACb,iBAAiB,OAAO,MAAM,YAAY,IAAI,OAAO,UAAU,WAAW,QAAQ;CACnF,OAAO,8BAA8B,KAAK,QAAQ,KAAK,EAAE,GAAG,KAAK,QAAQ,IAAI,EAAE,GAAG,KAAK,QAAQ,EAAE;AAClG;;;;;AAMA,MAAa,gBAAgB,UAGgD;CAC5E,MAAM;CACN,SAAS;CACT,SAAS,OAAO,EAAE,OAAO,WAAW,EAAE,QAAQ,MAAM,KAAK,IAAI,KAAK,mBAAmB,KAAK,CAAC,EAAE;CAC7F,GAAG,YAAY,KAAK,QAAQ;CAC5B,GAAG,eAAe,YAAY,WAAW;AAC1C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FetchLike } from "../core/fetch.js";
|
|
2
|
+
import { fetch } from "undici";
|
|
3
|
+
import { LookupFunction } from "node:net";
|
|
4
|
+
|
|
5
|
+
//#region src/net/guardedFetch.d.ts
|
|
6
|
+
/** @beta */
|
|
7
|
+
interface GuardedFetchOptions {
|
|
8
|
+
/** Resolves a name for each new connection. Node's own `dns.lookup` unless a test swaps it. */
|
|
9
|
+
lookup?: LookupFunction;
|
|
10
|
+
/** Reaches every address over http or https, private networks included, with no checks at all. */
|
|
11
|
+
allowPrivateNetwork?: boolean;
|
|
12
|
+
/** Where the hint about a local proxy's fake-IP mode goes (see {@link fakeIpHint}). */
|
|
13
|
+
warn?: (message: string) => void;
|
|
14
|
+
/** The clock that hint is limited by; `monotonicMs` unless a test swaps it. */
|
|
15
|
+
now?: () => number;
|
|
16
|
+
}
|
|
17
|
+
/** @beta */
|
|
18
|
+
interface GuardedFetch {
|
|
19
|
+
fetch: FetchLike;
|
|
20
|
+
/** Closes the connection pool once the requests in flight finish. */
|
|
21
|
+
close: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetch for adapters built from provider documents: refuses a host resolving to a non-public
|
|
25
|
+
* address, on every connection and redirect hop, with a `HostRefusedError`.
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
declare const createGuardedFetch: (options?: GuardedFetchOptions) => GuardedFetch;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { GuardedFetch, GuardedFetchOptions, createGuardedFetch };
|
|
32
|
+
//# sourceMappingURL=guardedFetch.d.ts.map
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { HostRefusedError } from "../core/sourceErrors.js";
|
|
2
|
+
import { monotonicMs } from "../core/monotonic.js";
|
|
3
|
+
import { lookup } from "node:dns";
|
|
4
|
+
import ipaddr from "ipaddr.js";
|
|
5
|
+
import { Agent, fetch as fetch$1 } from "undici";
|
|
6
|
+
const REDIRECT_STATUSES = new Set([
|
|
7
|
+
301,
|
|
8
|
+
302,
|
|
9
|
+
303,
|
|
10
|
+
307,
|
|
11
|
+
308
|
|
12
|
+
]);
|
|
13
|
+
const NULL_BODY_STATUSES = new Set([
|
|
14
|
+
101,
|
|
15
|
+
103,
|
|
16
|
+
204,
|
|
17
|
+
205,
|
|
18
|
+
304
|
|
19
|
+
]);
|
|
20
|
+
/** What a hop to another origin keeps: none of these can carry a credential. */
|
|
21
|
+
const CROSS_ORIGIN_HEADERS = new Set([
|
|
22
|
+
"accept",
|
|
23
|
+
"accept-language",
|
|
24
|
+
"content-language",
|
|
25
|
+
"content-type",
|
|
26
|
+
"user-agent"
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* Only a public unicast address is reachable. Loopback, private, link-local, carrier-grade NAT,
|
|
30
|
+
* IPv4-mapped IPv6 and every other special range ipaddr.js knows are refused.
|
|
31
|
+
*/
|
|
32
|
+
const isPublicAddress = (ip) => {
|
|
33
|
+
if (!ipaddr.isValid(ip)) return false;
|
|
34
|
+
try {
|
|
35
|
+
return ipaddr.parse(ip).range() === "unicast";
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const FAKE_IP_RANGE = ipaddr.IPv4.parseCIDR("198.18.0.0/15");
|
|
41
|
+
/**
|
|
42
|
+
* Whether `ip` is in 198.18.0.0/15, the benchmarking range local proxies such as Clash or Surge
|
|
43
|
+
* hand out in fake-IP mode, written as IPv4 or as IPv4-mapped IPv6.
|
|
44
|
+
*/
|
|
45
|
+
const isFakeIpAddress = (ip) => {
|
|
46
|
+
if (!ipaddr.isValid(ip)) return false;
|
|
47
|
+
const parsed = ipaddr.process(ip);
|
|
48
|
+
return parsed instanceof ipaddr.IPv4 && parsed.match(FAKE_IP_RANGE);
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A lookup that hands on public addresses only. It runs for every new connection, so a name that
|
|
52
|
+
* answers a public address first and a private one later is refused the second time.
|
|
53
|
+
*/
|
|
54
|
+
const guardLookup = (lookup, onRefused) => (hostname, options, callback) => {
|
|
55
|
+
lookup(hostname, options, (err, address, family) => {
|
|
56
|
+
if (err) {
|
|
57
|
+
callback(err, address, family);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const addresses = Array.isArray(address) ? address.map((entry) => entry.address) : [address];
|
|
61
|
+
if (addresses.length === 0 || !addresses.every((ip) => isPublicAddress(ip))) {
|
|
62
|
+
onRefused?.(hostname, addresses);
|
|
63
|
+
callback(new HostRefusedError(hostname, "it resolves to a private or reserved address"), address, family);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
callback(null, address, family);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Explains, at most once per {@link FAKE_IP_HINT_MS}, a refusal into 198.18.0.0/15: most likely a
|
|
71
|
+
* local proxy's fake-IP mode, which only a development machine should let past.
|
|
72
|
+
*/
|
|
73
|
+
const fakeIpHint = (warn, now) => {
|
|
74
|
+
let saidAt = null;
|
|
75
|
+
return (hostname, addresses) => {
|
|
76
|
+
const fake = addresses.find(isFakeIpAddress);
|
|
77
|
+
const at = now();
|
|
78
|
+
if (fake === void 0 || saidAt !== null && at - saidAt < 6e4) return;
|
|
79
|
+
saidAt = at;
|
|
80
|
+
warn(`analytics: ${hostname} is refused because it resolves to ${fake}, in 198.18.0.0/15, which looks like a local proxy's fake-IP mode (Clash, Surge). In development, set providers.hosts.allowPrivateNetwork to reach it through the proxy. Logged at most once a minute.`);
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/** The host without an IPv6 literal's brackets, which `URL.hostname` keeps. */
|
|
84
|
+
const literalHost = (url) => url.hostname.startsWith("[") && url.hostname.endsWith("]") ? url.hostname.slice(1, -1) : url.hostname;
|
|
85
|
+
/**
|
|
86
|
+
* What every hop has to pass before it is sent: https, and a host that is not a private address
|
|
87
|
+
* written out. A name is checked at connect time instead, by {@link guardLookup}.
|
|
88
|
+
*/
|
|
89
|
+
const assertReachable = (url) => {
|
|
90
|
+
if (url.protocol !== "https:") throw new HostRefusedError(url.host, `${url.protocol} is not https`);
|
|
91
|
+
const host = literalHost(url);
|
|
92
|
+
if (ipaddr.isValid(host) && !isPublicAddress(host)) throw new HostRefusedError(url.host, "it is a private or reserved address");
|
|
93
|
+
};
|
|
94
|
+
const headerRecord = (init) => {
|
|
95
|
+
const record = {};
|
|
96
|
+
new Headers(init).forEach((value, name) => {
|
|
97
|
+
record[name] = value;
|
|
98
|
+
});
|
|
99
|
+
return record;
|
|
100
|
+
};
|
|
101
|
+
const pickHeaders = (headers, keep) => Object.fromEntries(Object.entries(headers).filter(([name]) => keep(name)));
|
|
102
|
+
/**
|
|
103
|
+
* Next hop as fetch would send it: a 303, or a 301/302 answering a POST, becomes a bodiless GET; a
|
|
104
|
+
* hop to another origin drops every header that could carry a credential.
|
|
105
|
+
*/
|
|
106
|
+
const nextHop = (hop, status, url) => {
|
|
107
|
+
const headers = url.origin === hop.url.origin ? hop.headers : pickHeaders(hop.headers, (name) => CROSS_ORIGIN_HEADERS.has(name));
|
|
108
|
+
if (!(status === 303 ? hop.method !== "HEAD" : (status === 301 || status === 302) && hop.method === "POST")) return {
|
|
109
|
+
url,
|
|
110
|
+
method: hop.method,
|
|
111
|
+
headers,
|
|
112
|
+
body: hop.body
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
url,
|
|
116
|
+
method: "GET",
|
|
117
|
+
headers: pickHeaders(headers, (name) => !name.startsWith("content-")),
|
|
118
|
+
body: null
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Follows at most {@link MAX_REDIRECTS} redirects itself so each hop passes the first's checks.
|
|
123
|
+
* `redirect: 'manual'` hands a redirect back unfollowed, `'error'` refuses it.
|
|
124
|
+
*/
|
|
125
|
+
const followRedirects = async (send, input, init = {}) => {
|
|
126
|
+
const mode = init.redirect ?? "follow";
|
|
127
|
+
const signal = init.signal ?? void 0;
|
|
128
|
+
let hop = {
|
|
129
|
+
url: new URL(input),
|
|
130
|
+
method: (init.method ?? "GET").toUpperCase(),
|
|
131
|
+
headers: headerRecord(init.headers),
|
|
132
|
+
body: init.body ?? null
|
|
133
|
+
};
|
|
134
|
+
for (let redirects = 0;; redirects++) {
|
|
135
|
+
assertReachable(hop.url);
|
|
136
|
+
const res = await send(hop, signal);
|
|
137
|
+
const location = res.headers.get("location");
|
|
138
|
+
if (mode === "manual" || !REDIRECT_STATUSES.has(res.status) || location === null) return res;
|
|
139
|
+
await res.body?.cancel();
|
|
140
|
+
if (mode === "error") throw new TypeError(`analytics: ${hop.url.host} answered a redirect`);
|
|
141
|
+
if (redirects >= 3) throw new HostRefusedError(hop.url.host, `it redirected more than 3 times`);
|
|
142
|
+
hop = nextHop(hop, res.status, new URL(location, hop.url));
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/** How deep undici may wrap a lookup's refusal in `cause`s. */
|
|
146
|
+
const MAX_CAUSE_DEPTH = 5;
|
|
147
|
+
/** The refusal behind an undici failure, so callers see the `HostRefusedError` itself. */
|
|
148
|
+
const refusalIn = (err) => {
|
|
149
|
+
let current = err;
|
|
150
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {
|
|
151
|
+
if (current instanceof HostRefusedError) return current;
|
|
152
|
+
if (typeof current !== "object" || current === null) return null;
|
|
153
|
+
current = Reflect.get(current, "cause");
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
};
|
|
157
|
+
const standardBody = (res) => {
|
|
158
|
+
const source = res.body;
|
|
159
|
+
if (source === null || NULL_BODY_STATUSES.has(res.status)) return null;
|
|
160
|
+
const reader = source.getReader();
|
|
161
|
+
return new ReadableStream({
|
|
162
|
+
pull: async (controller) => {
|
|
163
|
+
const chunk = await reader.read();
|
|
164
|
+
if (chunk.done) {
|
|
165
|
+
controller.close();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
controller.enqueue(chunk.value);
|
|
169
|
+
},
|
|
170
|
+
cancel: (reason) => reader.cancel(reason)
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
/** undici's answer as a standard `Response`, its body still streaming. */
|
|
174
|
+
const toStandardResponse = (res) => {
|
|
175
|
+
const headers = new Headers();
|
|
176
|
+
res.headers.forEach((value, name) => {
|
|
177
|
+
headers.append(name, value);
|
|
178
|
+
});
|
|
179
|
+
return new Response(standardBody(res), {
|
|
180
|
+
status: res.status,
|
|
181
|
+
statusText: res.statusText,
|
|
182
|
+
headers
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Fetch for adapters built from provider documents: refuses a host resolving to a non-public
|
|
187
|
+
* address, on every connection and redirect hop, with a `HostRefusedError`.
|
|
188
|
+
*
|
|
189
|
+
* @beta
|
|
190
|
+
*/
|
|
191
|
+
const createGuardedFetch = (options = {}) => {
|
|
192
|
+
if (options.allowPrivateNetwork === true) return {
|
|
193
|
+
fetch: (input, init) => fetch(input, init),
|
|
194
|
+
close: async () => void 0
|
|
195
|
+
};
|
|
196
|
+
const onRefused = options.warn ? fakeIpHint(options.warn, options.now ?? monotonicMs) : void 0;
|
|
197
|
+
const agent = new Agent({ connect: { lookup: guardLookup(options.lookup ?? lookup, onRefused) } });
|
|
198
|
+
const send = async (hop, signal) => {
|
|
199
|
+
try {
|
|
200
|
+
return toStandardResponse(await fetch$1(hop.url.href, {
|
|
201
|
+
method: hop.method,
|
|
202
|
+
headers: hop.headers,
|
|
203
|
+
body: hop.body,
|
|
204
|
+
redirect: "manual",
|
|
205
|
+
dispatcher: agent,
|
|
206
|
+
...signal ? { signal } : {}
|
|
207
|
+
}));
|
|
208
|
+
} catch (err) {
|
|
209
|
+
throw refusalIn(err) ?? err;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
fetch: (input, init) => followRedirects(send, input, init),
|
|
214
|
+
close: () => agent.close()
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
//#endregion
|
|
218
|
+
export { createGuardedFetch };
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=guardedFetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardedFetch.js","names":["dnsLookup","undiciFetch"],"sources":["../../src/net/guardedFetch.ts"],"sourcesContent":["import { lookup as dnsLookup } from 'node:dns'\nimport type { LookupFunction } from 'node:net'\nimport ipaddr from 'ipaddr.js'\nimport { Agent, fetch as undiciFetch } from 'undici'\nimport type { FetchInit, FetchLike } from '../core/fetch'\nimport { monotonicMs } from '../core/monotonic'\nimport { HostRefusedError } from '../core/sourceErrors'\n\n/** Redirects followed before a request gives up; every hop is checked like the first. */\nexport const MAX_REDIRECTS = 3\n\nconst REDIRECT_STATUSES: ReadonlySet<number> = new Set([301, 302, 303, 307, 308])\n\nconst NULL_BODY_STATUSES: ReadonlySet<number> = new Set([101, 103, 204, 205, 304])\n\n/** What a hop to another origin keeps: none of these can carry a credential. */\nconst CROSS_ORIGIN_HEADERS: ReadonlySet<string> = new Set([\n\t'accept',\n\t'accept-language',\n\t'content-language',\n\t'content-type',\n\t'user-agent',\n])\n\n/**\n * Only a public unicast address is reachable. Loopback, private, link-local, carrier-grade NAT,\n * IPv4-mapped IPv6 and every other special range ipaddr.js knows are refused.\n */\nexport const isPublicAddress = (ip: string): boolean => {\n\tif (!ipaddr.isValid(ip)) {\n\t\treturn false\n\t}\n\ttry {\n\t\treturn ipaddr.parse(ip).range() === 'unicast'\n\t} catch {\n\t\treturn false\n\t}\n}\n\nconst FAKE_IP_RANGE = ipaddr.IPv4.parseCIDR('198.18.0.0/15')\n\n/**\n * Whether `ip` is in 198.18.0.0/15, the benchmarking range local proxies such as Clash or Surge\n * hand out in fake-IP mode, written as IPv4 or as IPv4-mapped IPv6.\n */\nexport const isFakeIpAddress = (ip: string): boolean => {\n\tif (!ipaddr.isValid(ip)) {\n\t\treturn false\n\t}\n\tconst parsed = ipaddr.process(ip)\n\treturn parsed instanceof ipaddr.IPv4 && parsed.match(FAKE_IP_RANGE)\n}\n\n/** Told the name and every address of each lookup refused. */\ntype OnRefused = (hostname: string, addresses: readonly string[]) => void\n\n/**\n * A lookup that hands on public addresses only. It runs for every new connection, so a name that\n * answers a public address first and a private one later is refused the second time.\n */\nexport const guardLookup =\n\t(lookup: LookupFunction, onRefused?: OnRefused): LookupFunction =>\n\t(hostname, options, callback) => {\n\t\tlookup(hostname, options, (err, address, family) => {\n\t\t\tif (err) {\n\t\t\t\tcallback(err, address, family)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst addresses = Array.isArray(address) ? address.map((entry) => entry.address) : [address]\n\t\t\tif (addresses.length === 0 || !addresses.every((ip) => isPublicAddress(ip))) {\n\t\t\t\tonRefused?.(hostname, addresses)\n\t\t\t\tcallback(\n\t\t\t\t\tnew HostRefusedError(hostname, 'it resolves to a private or reserved address'),\n\t\t\t\t\taddress,\n\t\t\t\t\tfamily\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcallback(null, address, family)\n\t\t})\n\t}\n\n/** One fake-IP hint at most this often: on such a machine every vendor is refused the same way. */\nexport const FAKE_IP_HINT_MS = 60_000\n\n/**\n * Explains, at most once per {@link FAKE_IP_HINT_MS}, a refusal into 198.18.0.0/15: most likely a\n * local proxy's fake-IP mode, which only a development machine should let past.\n */\nexport const fakeIpHint = (warn: (message: string) => void, now: () => number): OnRefused => {\n\tlet saidAt: number | null = null\n\treturn (hostname, addresses) => {\n\t\tconst fake = addresses.find(isFakeIpAddress)\n\t\tconst at = now()\n\t\tif (fake === undefined || (saidAt !== null && at - saidAt < FAKE_IP_HINT_MS)) {\n\t\t\treturn\n\t\t}\n\t\tsaidAt = at\n\t\twarn(\n\t\t\t`analytics: ${hostname} is refused because it resolves to ${fake}, in 198.18.0.0/15, which looks like a local proxy's fake-IP mode (Clash, Surge). In development, set providers.hosts.allowPrivateNetwork to reach it through the proxy. Logged at most once a minute.`\n\t\t)\n\t}\n}\n\n/** One request of a chain, before redirects are followed. */\nexport interface Hop {\n\turl: URL\n\tmethod: string\n\theaders: Record<string, string>\n\tbody: string | ArrayBuffer | null\n}\n\n/** Sends one hop as it stands, following nothing. */\nexport type SendHop = (hop: Hop, signal?: AbortSignal) => Promise<Response>\n\n/** The host without an IPv6 literal's brackets, which `URL.hostname` keeps. */\nconst literalHost = (url: URL): string =>\n\turl.hostname.startsWith('[') && url.hostname.endsWith(']')\n\t\t? url.hostname.slice(1, -1)\n\t\t: url.hostname\n\n/**\n * What every hop has to pass before it is sent: https, and a host that is not a private address\n * written out. A name is checked at connect time instead, by {@link guardLookup}.\n */\nconst assertReachable = (url: URL): void => {\n\tif (url.protocol !== 'https:') {\n\t\tthrow new HostRefusedError(url.host, `${url.protocol} is not https`)\n\t}\n\tconst host = literalHost(url)\n\tif (ipaddr.isValid(host) && !isPublicAddress(host)) {\n\t\tthrow new HostRefusedError(url.host, 'it is a private or reserved address')\n\t}\n}\n\nconst headerRecord = (init: HeadersInit | undefined): Record<string, string> => {\n\tconst record: Record<string, string> = {}\n\tnew Headers(init).forEach((value, name) => {\n\t\trecord[name] = value\n\t})\n\treturn record\n}\n\nconst pickHeaders = (\n\theaders: Record<string, string>,\n\tkeep: (name: string) => boolean\n): Record<string, string> =>\n\tObject.fromEntries(Object.entries(headers).filter(([name]) => keep(name)))\n\n/**\n * Next hop as fetch would send it: a 303, or a 301/302 answering a POST, becomes a bodiless GET; a\n * hop to another origin drops every header that could carry a credential.\n */\nconst nextHop = (hop: Hop, status: number, url: URL): Hop => {\n\tconst headers =\n\t\turl.origin === hop.url.origin\n\t\t\t? hop.headers\n\t\t\t: pickHeaders(hop.headers, (name) => CROSS_ORIGIN_HEADERS.has(name))\n\tconst toGet =\n\t\tstatus === 303\n\t\t\t? hop.method !== 'HEAD'\n\t\t\t: (status === 301 || status === 302) && hop.method === 'POST'\n\tif (!toGet) {\n\t\treturn { url, method: hop.method, headers, body: hop.body }\n\t}\n\treturn {\n\t\turl,\n\t\tmethod: 'GET',\n\t\theaders: pickHeaders(headers, (name) => !name.startsWith('content-')),\n\t\tbody: null,\n\t}\n}\n\n/**\n * Follows at most {@link MAX_REDIRECTS} redirects itself so each hop passes the first's checks.\n * `redirect: 'manual'` hands a redirect back unfollowed, `'error'` refuses it.\n */\nexport const followRedirects = async (\n\tsend: SendHop,\n\tinput: string | URL,\n\tinit: FetchInit = {}\n): Promise<Response> => {\n\tconst mode = init.redirect ?? 'follow'\n\tconst signal = init.signal ?? undefined\n\tlet hop: Hop = {\n\t\turl: new URL(input),\n\t\tmethod: (init.method ?? 'GET').toUpperCase(),\n\t\theaders: headerRecord(init.headers),\n\t\tbody: init.body ?? null,\n\t}\n\tfor (let redirects = 0; ; redirects++) {\n\t\tassertReachable(hop.url)\n\t\tconst res = await send(hop, signal)\n\t\tconst location = res.headers.get('location')\n\t\tif (mode === 'manual' || !REDIRECT_STATUSES.has(res.status) || location === null) {\n\t\t\treturn res\n\t\t}\n\t\tawait res.body?.cancel()\n\t\tif (mode === 'error') {\n\t\t\tthrow new TypeError(`analytics: ${hop.url.host} answered a redirect`)\n\t\t}\n\t\tif (redirects >= MAX_REDIRECTS) {\n\t\t\tthrow new HostRefusedError(hop.url.host, `it redirected more than ${MAX_REDIRECTS} times`)\n\t\t}\n\t\thop = nextHop(hop, res.status, new URL(location, hop.url))\n\t}\n}\n\n/** How deep undici may wrap a lookup's refusal in `cause`s. */\nconst MAX_CAUSE_DEPTH = 5\n\n/** The refusal behind an undici failure, so callers see the `HostRefusedError` itself. */\nconst refusalIn = (err: unknown): HostRefusedError | null => {\n\tlet current: unknown = err\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (current instanceof HostRefusedError) {\n\t\t\treturn current\n\t\t}\n\t\tif (typeof current !== 'object' || current === null) {\n\t\t\treturn null\n\t\t}\n\t\tcurrent = Reflect.get(current, 'cause')\n\t}\n\treturn null\n}\n\ntype UndiciResponse = Awaited<ReturnType<typeof undiciFetch>>\n\nconst standardBody = (res: UndiciResponse): ReadableStream<Uint8Array> | null => {\n\tconst source = res.body\n\tif (source === null || NULL_BODY_STATUSES.has(res.status)) {\n\t\treturn null\n\t}\n\tconst reader = source.getReader()\n\treturn new ReadableStream<Uint8Array>({\n\t\tpull: async (controller) => {\n\t\t\tconst chunk = await reader.read()\n\t\t\tif (chunk.done) {\n\t\t\t\tcontroller.close()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcontroller.enqueue(chunk.value)\n\t\t},\n\t\tcancel: (reason) => reader.cancel(reason),\n\t})\n}\n\n/** undici's answer as a standard `Response`, its body still streaming. */\nexport const toStandardResponse = (res: UndiciResponse): Response => {\n\tconst headers = new Headers()\n\tres.headers.forEach((value, name) => {\n\t\theaders.append(name, value)\n\t})\n\treturn new Response(standardBody(res), {\n\t\tstatus: res.status,\n\t\tstatusText: res.statusText,\n\t\theaders,\n\t})\n}\n\n/** @beta */\nexport interface GuardedFetchOptions {\n\t/** Resolves a name for each new connection. Node's own `dns.lookup` unless a test swaps it. */\n\tlookup?: LookupFunction\n\t/** Reaches every address over http or https, private networks included, with no checks at all. */\n\tallowPrivateNetwork?: boolean\n\t/** Where the hint about a local proxy's fake-IP mode goes (see {@link fakeIpHint}). */\n\twarn?: (message: string) => void\n\t/** The clock that hint is limited by; `monotonicMs` unless a test swaps it. */\n\tnow?: () => number\n}\n\n/** @beta */\nexport interface GuardedFetch {\n\tfetch: FetchLike\n\t/** Closes the connection pool once the requests in flight finish. */\n\tclose: () => Promise<void>\n}\n\n/**\n * Fetch for adapters built from provider documents: refuses a host resolving to a non-public\n * address, on every connection and redirect hop, with a `HostRefusedError`.\n *\n * @beta\n */\nexport const createGuardedFetch = (options: GuardedFetchOptions = {}): GuardedFetch => {\n\tif (options.allowPrivateNetwork === true) {\n\t\treturn { fetch: (input, init) => fetch(input, init), close: async () => undefined }\n\t}\n\tconst onRefused = options.warn ? fakeIpHint(options.warn, options.now ?? monotonicMs) : undefined\n\tconst agent = new Agent({\n\t\tconnect: { lookup: guardLookup(options.lookup ?? dnsLookup, onRefused) },\n\t})\n\tconst send: SendHop = async (hop, signal) => {\n\t\ttry {\n\t\t\tconst res = await undiciFetch(hop.url.href, {\n\t\t\t\tmethod: hop.method,\n\t\t\t\theaders: hop.headers,\n\t\t\t\tbody: hop.body,\n\t\t\t\tredirect: 'manual',\n\t\t\t\tdispatcher: agent,\n\t\t\t\t...(signal ? { signal } : {}),\n\t\t\t})\n\t\t\treturn toStandardResponse(res)\n\t\t} catch (err) {\n\t\t\tthrow refusalIn(err) ?? err\n\t\t}\n\t}\n\treturn {\n\t\tfetch: (input, init) => followRedirects(send, input, init),\n\t\tclose: () => agent.close(),\n\t}\n}\n"],"mappings":";;;;;AAWA,MAAM,oBAAyC,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;AAEhF,MAAM,qBAA0C,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;;AAGjF,MAAM,uBAA4C,IAAI,IAAI;CACzD;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;AAMD,MAAa,mBAAmB,OAAwB;CACvD,IAAI,CAAC,OAAO,QAAQ,EAAE,GACrB,OAAO;CAER,IAAI;EACH,OAAO,OAAO,MAAM,EAAE,EAAE,MAAM,MAAM;CACrC,QAAQ;EACP,OAAO;CACR;AACD;AAEA,MAAM,gBAAgB,OAAO,KAAK,UAAU,eAAe;;;;;AAM3D,MAAa,mBAAmB,OAAwB;CACvD,IAAI,CAAC,OAAO,QAAQ,EAAE,GACrB,OAAO;CAER,MAAM,SAAS,OAAO,QAAQ,EAAE;CAChC,OAAO,kBAAkB,OAAO,QAAQ,OAAO,MAAM,aAAa;AACnE;;;;;AASA,MAAa,eACX,QAAwB,eACxB,UAAU,SAAS,aAAa;CAChC,OAAO,UAAU,UAAU,KAAK,SAAS,WAAW;EACnD,IAAI,KAAK;GACR,SAAS,KAAK,SAAS,MAAM;GAC7B;EACD;EACA,MAAM,YAAY,MAAM,QAAQ,OAAO,IAAI,QAAQ,KAAK,UAAU,MAAM,OAAO,IAAI,CAAC,OAAO;EAC3F,IAAI,UAAU,WAAW,KAAK,CAAC,UAAU,OAAO,OAAO,gBAAgB,EAAE,CAAC,GAAG;GAC5E,YAAY,UAAU,SAAS;GAC/B,SACC,IAAI,iBAAiB,UAAU,8CAA8C,GAC7E,SACA,MACD;GACA;EACD;EACA,SAAS,MAAM,SAAS,MAAM;CAC/B,CAAC;AACF;;;;;AASD,MAAa,cAAc,MAAiC,QAAiC;CAC5F,IAAI,SAAwB;CAC5B,QAAQ,UAAU,cAAc;EAC/B,MAAM,OAAO,UAAU,KAAK,eAAe;EAC3C,MAAM,KAAK,IAAI;EACf,IAAI,SAAS,KAAA,KAAc,WAAW,QAAQ,KAAK,SAAA,KAClD;EAED,SAAS;EACT,KACC,cAAc,SAAS,qCAAqC,KAAK,uMAClE;CACD;AACD;;AAcA,MAAM,eAAe,QACpB,IAAI,SAAS,WAAW,GAAG,KAAK,IAAI,SAAS,SAAS,GAAG,IACtD,IAAI,SAAS,MAAM,GAAG,EAAE,IACxB,IAAI;;;;;AAMR,MAAM,mBAAmB,QAAmB;CAC3C,IAAI,IAAI,aAAa,UACpB,MAAM,IAAI,iBAAiB,IAAI,MAAM,GAAG,IAAI,SAAS,cAAc;CAEpE,MAAM,OAAO,YAAY,GAAG;CAC5B,IAAI,OAAO,QAAQ,IAAI,KAAK,CAAC,gBAAgB,IAAI,GAChD,MAAM,IAAI,iBAAiB,IAAI,MAAM,qCAAqC;AAE5E;AAEA,MAAM,gBAAgB,SAA0D;CAC/E,MAAM,SAAiC,CAAC;CACxC,IAAI,QAAQ,IAAI,EAAE,SAAS,OAAO,SAAS;EAC1C,OAAO,QAAQ;CAChB,CAAC;CACD,OAAO;AACR;AAEA,MAAM,eACL,SACA,SAEA,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,QAAQ,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC;;;;;AAM1E,MAAM,WAAW,KAAU,QAAgB,QAAkB;CAC5D,MAAM,UACL,IAAI,WAAW,IAAI,IAAI,SACpB,IAAI,UACJ,YAAY,IAAI,UAAU,SAAS,qBAAqB,IAAI,IAAI,CAAC;CAKrE,IAAI,EAHH,WAAW,MACR,IAAI,WAAW,UACd,WAAW,OAAO,WAAW,QAAQ,IAAI,WAAW,SAExD,OAAO;EAAE;EAAK,QAAQ,IAAI;EAAQ;EAAS,MAAM,IAAI;CAAK;CAE3D,OAAO;EACN;EACA,QAAQ;EACR,SAAS,YAAY,UAAU,SAAS,CAAC,KAAK,WAAW,UAAU,CAAC;EACpE,MAAM;CACP;AACD;;;;;AAMA,MAAa,kBAAkB,OAC9B,MACA,OACA,OAAkB,CAAC,MACI;CACvB,MAAM,OAAO,KAAK,YAAY;CAC9B,MAAM,SAAS,KAAK,UAAU,KAAA;CAC9B,IAAI,MAAW;EACd,KAAK,IAAI,IAAI,KAAK;EAClB,SAAS,KAAK,UAAU,OAAO,YAAY;EAC3C,SAAS,aAAa,KAAK,OAAO;EAClC,MAAM,KAAK,QAAQ;CACpB;CACA,KAAK,IAAI,YAAY,IAAK,aAAa;EACtC,gBAAgB,IAAI,GAAG;EACvB,MAAM,MAAM,MAAM,KAAK,KAAK,MAAM;EAClC,MAAM,WAAW,IAAI,QAAQ,IAAI,UAAU;EAC3C,IAAI,SAAS,YAAY,CAAC,kBAAkB,IAAI,IAAI,MAAM,KAAK,aAAa,MAC3E,OAAO;EAER,MAAM,IAAI,MAAM,OAAO;EACvB,IAAI,SAAS,SACZ,MAAM,IAAI,UAAU,cAAc,IAAI,IAAI,KAAK,qBAAqB;EAErE,IAAI,aAAA,GACH,MAAM,IAAI,iBAAiB,IAAI,IAAI,MAAM,iCAAgD;EAE1F,MAAM,QAAQ,KAAK,IAAI,QAAQ,IAAI,IAAI,UAAU,IAAI,GAAG,CAAC;CAC1D;AACD;;AAGA,MAAM,kBAAkB;;AAGxB,MAAM,aAAa,QAA0C;CAC5D,IAAI,UAAmB;CACvB,KAAK,IAAI,QAAQ,GAAG,QAAQ,iBAAiB,SAAS;EACrD,IAAI,mBAAmB,kBACtB,OAAO;EAER,IAAI,OAAO,YAAY,YAAY,YAAY,MAC9C,OAAO;EAER,UAAU,QAAQ,IAAI,SAAS,OAAO;CACvC;CACA,OAAO;AACR;AAIA,MAAM,gBAAgB,QAA2D;CAChF,MAAM,SAAS,IAAI;CACnB,IAAI,WAAW,QAAQ,mBAAmB,IAAI,IAAI,MAAM,GACvD,OAAO;CAER,MAAM,SAAS,OAAO,UAAU;CAChC,OAAO,IAAI,eAA2B;EACrC,MAAM,OAAO,eAAe;GAC3B,MAAM,QAAQ,MAAM,OAAO,KAAK;GAChC,IAAI,MAAM,MAAM;IACf,WAAW,MAAM;IACjB;GACD;GACA,WAAW,QAAQ,MAAM,KAAK;EAC/B;EACA,SAAS,WAAW,OAAO,OAAO,MAAM;CACzC,CAAC;AACF;;AAGA,MAAa,sBAAsB,QAAkC;CACpE,MAAM,UAAU,IAAI,QAAQ;CAC5B,IAAI,QAAQ,SAAS,OAAO,SAAS;EACpC,QAAQ,OAAO,MAAM,KAAK;CAC3B,CAAC;CACD,OAAO,IAAI,SAAS,aAAa,GAAG,GAAG;EACtC,QAAQ,IAAI;EACZ,YAAY,IAAI;EAChB;CACD,CAAC;AACF;;;;;;;AA2BA,MAAa,sBAAsB,UAA+B,CAAC,MAAoB;CACtF,IAAI,QAAQ,wBAAwB,MACnC,OAAO;EAAE,QAAQ,OAAO,SAAS,MAAM,OAAO,IAAI;EAAG,OAAO,YAAY,KAAA;CAAU;CAEnF,MAAM,YAAY,QAAQ,OAAO,WAAW,QAAQ,MAAM,QAAQ,OAAO,WAAW,IAAI,KAAA;CACxF,MAAM,QAAQ,IAAI,MAAM,EACvB,SAAS,EAAE,QAAQ,YAAY,QAAQ,UAAUA,QAAW,SAAS,EAAE,EACxE,CAAC;CACD,MAAM,OAAgB,OAAO,KAAK,WAAW;EAC5C,IAAI;GASH,OAAO,mBAAmB,MARRC,QAAY,IAAI,IAAI,MAAM;IAC3C,QAAQ,IAAI;IACZ,SAAS,IAAI;IACb,MAAM,IAAI;IACV,UAAU;IACV,YAAY;IACZ,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;GAC5B,CAAC,CAC4B;EAC9B,SAAS,KAAK;GACb,MAAM,UAAU,GAAG,KAAK;EACzB;CACD;CACA,OAAO;EACN,QAAQ,OAAO,SAAS,gBAAgB,MAAM,OAAO,IAAI;EACzD,aAAa,MAAM,MAAM;CAC1B;AACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/net/origin.ts
|
|
2
|
+
const urlOf = (value) => {
|
|
3
|
+
try {
|
|
4
|
+
return new URL(value.trim());
|
|
5
|
+
} catch {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const isHttp = (url) => url.protocol === "https:" || url.protocol === "http:";
|
|
10
|
+
/** `value` as an http(s) URL with no credentials, query or fragment; http only with `allowHttp`. */
|
|
11
|
+
const parseHttpUrl = (value, allowHttp) => {
|
|
12
|
+
const url = urlOf(value);
|
|
13
|
+
if (!url) return { problem: "format" };
|
|
14
|
+
if (url.protocol === "http:" && !allowHttp) return { problem: "insecure" };
|
|
15
|
+
if (!isHttp(url)) return { problem: "format" };
|
|
16
|
+
if (url.username || url.password || url.search || url.hash) return { problem: "format" };
|
|
17
|
+
return url;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The origin `value` names when it is nothing but one: a scheme, a host and maybe a port, with no
|
|
21
|
+
* credentials, path, query, fragment or wildcard. `http` only when `allowHttp`.
|
|
22
|
+
*/
|
|
23
|
+
const parseOrigin = (value, allowHttp) => {
|
|
24
|
+
if (value.includes("*")) return { problem: "format" };
|
|
25
|
+
const url = parseHttpUrl(value, allowHttp);
|
|
26
|
+
if (!(url instanceof URL)) return url;
|
|
27
|
+
return url.pathname === "/" ? { origin: url.origin } : { problem: "format" };
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* An origin as a browser writes `Origin`: lowercased, default port dropped. Null for anything not
|
|
31
|
+
* http(s), the literal `null` of an opaque document included.
|
|
32
|
+
*/
|
|
33
|
+
const normalizeOrigin = (value) => {
|
|
34
|
+
const url = urlOf(value);
|
|
35
|
+
return url && isHttp(url) ? url.origin : null;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { normalizeOrigin, parseHttpUrl, parseOrigin };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=origin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"origin.js","names":[],"sources":["../../src/net/origin.ts"],"sourcesContent":["/** Why a value is not an address the plugin accepts: malformed, or http where https is due. */\nexport type OriginProblem = 'format' | 'insecure'\n\nconst urlOf = (value: string): URL | null => {\n\ttry {\n\t\treturn new URL(value.trim())\n\t} catch {\n\t\treturn null\n\t}\n}\n\nconst isHttp = (url: URL): boolean => url.protocol === 'https:' || url.protocol === 'http:'\n\n/** `value` as an http(s) URL with no credentials, query or fragment; http only with `allowHttp`. */\nexport const parseHttpUrl = (\n\tvalue: string,\n\tallowHttp: boolean\n): URL | { problem: OriginProblem } => {\n\tconst url = urlOf(value)\n\tif (!url) {\n\t\treturn { problem: 'format' }\n\t}\n\tif (url.protocol === 'http:' && !allowHttp) {\n\t\treturn { problem: 'insecure' }\n\t}\n\tif (!isHttp(url)) {\n\t\treturn { problem: 'format' }\n\t}\n\tif (url.username || url.password || url.search || url.hash) {\n\t\treturn { problem: 'format' }\n\t}\n\treturn url\n}\n\n/**\n * The origin `value` names when it is nothing but one: a scheme, a host and maybe a port, with no\n * credentials, path, query, fragment or wildcard. `http` only when `allowHttp`.\n */\nexport const parseOrigin = (\n\tvalue: string,\n\tallowHttp: boolean\n): { origin: string } | { problem: OriginProblem } => {\n\tif (value.includes('*')) {\n\t\treturn { problem: 'format' }\n\t}\n\tconst url = parseHttpUrl(value, allowHttp)\n\tif (!(url instanceof URL)) {\n\t\treturn url\n\t}\n\treturn url.pathname === '/' ? { origin: url.origin } : { problem: 'format' }\n}\n\n/**\n * An origin as a browser writes `Origin`: lowercased, default port dropped. Null for anything not\n * http(s), the literal `null` of an opaque document included.\n */\nexport const normalizeOrigin = (value: string): string | null => {\n\tconst url = urlOf(value)\n\treturn url && isHttp(url) ? url.origin : null\n}\n"],"mappings":";AAGA,MAAM,SAAS,UAA8B;CAC5C,IAAI;EACH,OAAO,IAAI,IAAI,MAAM,KAAK,CAAC;CAC5B,QAAQ;EACP,OAAO;CACR;AACD;AAEA,MAAM,UAAU,QAAsB,IAAI,aAAa,YAAY,IAAI,aAAa;;AAGpF,MAAa,gBACZ,OACA,cACsC;CACtC,MAAM,MAAM,MAAM,KAAK;CACvB,IAAI,CAAC,KACJ,OAAO,EAAE,SAAS,SAAS;CAE5B,IAAI,IAAI,aAAa,WAAW,CAAC,WAChC,OAAO,EAAE,SAAS,WAAW;CAE9B,IAAI,CAAC,OAAO,GAAG,GACd,OAAO,EAAE,SAAS,SAAS;CAE5B,IAAI,IAAI,YAAY,IAAI,YAAY,IAAI,UAAU,IAAI,MACrD,OAAO,EAAE,SAAS,SAAS;CAE5B,OAAO;AACR;;;;;AAMA,MAAa,eACZ,OACA,cACqD;CACrD,IAAI,MAAM,SAAS,GAAG,GACrB,OAAO,EAAE,SAAS,SAAS;CAE5B,MAAM,MAAM,aAAa,OAAO,SAAS;CACzC,IAAI,EAAE,eAAe,MACpB,OAAO;CAER,OAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,IAAI,OAAO,IAAI,EAAE,SAAS,SAAS;AAC5E;;;;;AAMA,MAAa,mBAAmB,UAAiC;CAChE,MAAM,MAAM,MAAM,KAAK;CACvB,OAAO,OAAO,OAAO,GAAG,IAAI,IAAI,SAAS;AAC1C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/net/platform.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A hosting platform whose edge writes the visitor's address and location into request headers,
|
|
4
|
+
* replacing whatever the visitor sent under those names. Only then is reading them safe.
|
|
5
|
+
*/
|
|
6
|
+
type TrustedPlatform = 'vercel' | 'cloudflare';
|
|
7
|
+
//#endregion
|
|
8
|
+
export { TrustedPlatform };
|
|
9
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/net/platform.ts
|
|
2
|
+
const isTrustedPlatform = (value) => value === "vercel" || value === "cloudflare";
|
|
3
|
+
/**
|
|
4
|
+
* Cloudflare sends `cf-region-code` and `cf-ipcity` only once its visitor location headers are
|
|
5
|
+
* turned on.
|
|
6
|
+
*/
|
|
7
|
+
const PLATFORM_HEADERS = {
|
|
8
|
+
vercel: {
|
|
9
|
+
ip: "x-real-ip",
|
|
10
|
+
country: "x-vercel-ip-country",
|
|
11
|
+
region: "x-vercel-ip-country-region",
|
|
12
|
+
city: "x-vercel-ip-city"
|
|
13
|
+
},
|
|
14
|
+
cloudflare: {
|
|
15
|
+
ip: "cf-connecting-ip",
|
|
16
|
+
country: "cf-ipcountry",
|
|
17
|
+
region: "cf-region-code",
|
|
18
|
+
city: "cf-ipcity"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Every header an edge writes about the visitor. None is relayed raw: an upstream learns only the
|
|
23
|
+
* address the install's own trust settings resolved.
|
|
24
|
+
*/
|
|
25
|
+
const VISITOR_HEADERS = [
|
|
26
|
+
...Object.values(PLATFORM_HEADERS).flatMap((headers) => Object.values(headers)),
|
|
27
|
+
"x-vercel-forwarded-for",
|
|
28
|
+
"cf-connecting-ipv6",
|
|
29
|
+
"cf-region",
|
|
30
|
+
"true-client-ip"
|
|
31
|
+
];
|
|
32
|
+
//#endregion
|
|
33
|
+
export { PLATFORM_HEADERS, VISITOR_HEADERS, isTrustedPlatform };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","names":[],"sources":["../../src/net/platform.ts"],"sourcesContent":["/**\n * A hosting platform whose edge writes the visitor's address and location into request headers,\n * replacing whatever the visitor sent under those names. Only then is reading them safe.\n */\nexport type TrustedPlatform = 'vercel' | 'cloudflare'\n\nexport const isTrustedPlatform = (value: unknown): value is TrustedPlatform =>\n\tvalue === 'vercel' || value === 'cloudflare'\n\n/** Where one platform puts the visitor's address and location. */\ninterface PlatformHeaders {\n\tip: string\n\tcountry: string\n\tregion: string\n\tcity: string\n}\n\n/**\n * Cloudflare sends `cf-region-code` and `cf-ipcity` only once its visitor location headers are\n * turned on.\n */\nexport const PLATFORM_HEADERS: Readonly<Record<TrustedPlatform, PlatformHeaders>> = {\n\tvercel: {\n\t\tip: 'x-real-ip',\n\t\tcountry: 'x-vercel-ip-country',\n\t\tregion: 'x-vercel-ip-country-region',\n\t\tcity: 'x-vercel-ip-city',\n\t},\n\tcloudflare: {\n\t\tip: 'cf-connecting-ip',\n\t\tcountry: 'cf-ipcountry',\n\t\tregion: 'cf-region-code',\n\t\tcity: 'cf-ipcity',\n\t},\n}\n\n/**\n * Every header an edge writes about the visitor. None is relayed raw: an upstream learns only the\n * address the install's own trust settings resolved.\n */\nexport const VISITOR_HEADERS: readonly string[] = [\n\t...Object.values(PLATFORM_HEADERS).flatMap((headers) => Object.values(headers)),\n\t'x-vercel-forwarded-for',\n\t'cf-connecting-ipv6',\n\t'cf-region',\n\t'true-client-ip',\n]\n"],"mappings":";AAMA,MAAa,qBAAqB,UACjC,UAAU,YAAY,UAAU;;;;;AAcjC,MAAa,mBAAuE;CACnF,QAAQ;EACP,IAAI;EACJ,SAAS;EACT,QAAQ;EACR,MAAM;CACP;CACA,YAAY;EACX,IAAI;EACJ,SAAS;EACT,QAAQ;EACR,MAAM;CACP;AACD;;;;;AAMA,MAAa,kBAAqC;CACjD,GAAG,OAAO,OAAO,gBAAgB,EAAE,SAAS,YAAY,OAAO,OAAO,OAAO,CAAC;CAC9E;CACA;CACA;CACA;AACD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { parsePayloadComponent } from "payload/shared";
|
|
2
|
+
//#region src/plugin/adminDependencies.ts
|
|
3
|
+
/** Where the host's `countryFlags.Component` sits in `admin.dependencies`. */
|
|
4
|
+
const FLAG_DEPENDENCY = "@10x-media/analytics:countryFlag";
|
|
5
|
+
/** Where the host's `view.Component` sits in `admin.dependencies`. */
|
|
6
|
+
const VIEW_DEPENDENCY = "@10x-media/analytics:view";
|
|
7
|
+
/**
|
|
8
|
+
* The one string the import map keys a component under, `path#export`: `payload generate:importmap`
|
|
9
|
+
* reads a dependency's `path` alone, so an export named in `exportName` has to move into it.
|
|
10
|
+
*/
|
|
11
|
+
const importMapPath = (component) => {
|
|
12
|
+
const { path, exportName } = parsePayloadComponent(component);
|
|
13
|
+
return `${path}#${exportName}`;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A host component the plugin renders itself via `RenderServerComponent`, which Payload's config
|
|
17
|
+
* walk never sees; `admin.dependencies` is where `generate:importmap` picks it up.
|
|
18
|
+
*/
|
|
19
|
+
const addComponentDependency = (config, key, component) => {
|
|
20
|
+
config.admin = {
|
|
21
|
+
...config.admin,
|
|
22
|
+
dependencies: {
|
|
23
|
+
...config.admin?.dependencies,
|
|
24
|
+
[key]: {
|
|
25
|
+
type: "component",
|
|
26
|
+
path: importMapPath(component)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { FLAG_DEPENDENCY, VIEW_DEPENDENCY, addComponentDependency };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=adminDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adminDependencies.js","names":[],"sources":["../../src/plugin/adminDependencies.ts"],"sourcesContent":["import type { Config } from 'payload'\nimport { parsePayloadComponent } from 'payload/shared'\nimport type { AnalyticsComponent } from '../core/options'\n\n/** Where the host's `countryFlags.Component` sits in `admin.dependencies`. */\nexport const FLAG_DEPENDENCY = '@10x-media/analytics:countryFlag'\n\n/** Where the host's `view.Component` sits in `admin.dependencies`. */\nexport const VIEW_DEPENDENCY = '@10x-media/analytics:view'\n\n/**\n * The one string the import map keys a component under, `path#export`: `payload generate:importmap`\n * reads a dependency's `path` alone, so an export named in `exportName` has to move into it.\n */\nexport const importMapPath = (component: AnalyticsComponent): string => {\n\tconst { path, exportName } = parsePayloadComponent(component)\n\treturn `${path}#${exportName}`\n}\n\n/**\n * A host component the plugin renders itself via `RenderServerComponent`, which Payload's config\n * walk never sees; `admin.dependencies` is where `generate:importmap` picks it up.\n */\nexport const addComponentDependency = (\n\tconfig: Config,\n\tkey: string,\n\tcomponent: AnalyticsComponent\n): void => {\n\tconfig.admin = {\n\t\t...config.admin,\n\t\tdependencies: {\n\t\t\t...config.admin?.dependencies,\n\t\t\t[key]: { type: 'component', path: importMapPath(component) },\n\t\t},\n\t}\n}\n"],"mappings":";;;AAKA,MAAa,kBAAkB;;AAG/B,MAAa,kBAAkB;;;;;AAM/B,MAAa,iBAAiB,cAA0C;CACvE,MAAM,EAAE,MAAM,eAAe,sBAAsB,SAAS;CAC5D,OAAO,GAAG,KAAK,GAAG;AACnB;;;;;AAMA,MAAa,0BACZ,QACA,KACA,cACU;CACV,OAAO,QAAQ;EACd,GAAG,OAAO;EACV,cAAc;GACb,GAAG,OAAO,OAAO;IAChB,MAAM;IAAE,MAAM;IAAa,MAAM,cAAc,SAAS;GAAE;EAC5D;CACD;AACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { formatAdminURL } from "payload/shared";
|
|
2
|
+
//#region src/plugin/apiPath.ts
|
|
3
|
+
const isRooted = (path) => path.startsWith("/");
|
|
4
|
+
const rooted = (path) => isRooted(path) ? path : `/${path}`;
|
|
5
|
+
/**
|
|
6
|
+
* A relative path under the app's `routes.api`, behind the Next `basePath` `withPayload` publishes,
|
|
7
|
+
* built the way Payload's own admin builds its fetches.
|
|
8
|
+
*/
|
|
9
|
+
const apiPath = (config, path) => formatAdminURL({
|
|
10
|
+
apiRoute: config.routes?.api ?? "/api",
|
|
11
|
+
path: rooted(path),
|
|
12
|
+
relative: true
|
|
13
|
+
});
|
|
14
|
+
/** An app path behind the Next `basePath`, for a mount the host serves through Next rewrites. */
|
|
15
|
+
const appPath = (path) => formatAdminURL({
|
|
16
|
+
apiRoute: "",
|
|
17
|
+
path: rooted(path),
|
|
18
|
+
relative: true
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { apiPath, appPath };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=apiPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiPath.js","names":[],"sources":["../../src/plugin/apiPath.ts"],"sourcesContent":["import { formatAdminURL } from 'payload/shared'\n\n/** The slice of a Payload config, server or client, the plugin's paths are built from. */\nexport interface ApiPathConfigSource {\n\troutes?: { api?: string | undefined } | undefined\n}\n\nconst isRooted = (path: string): path is `/${string}` => path.startsWith('/')\n\nconst rooted = (path: string): `/${string}` => (isRooted(path) ? path : `/${path}`)\n\n/**\n * A relative path under the app's `routes.api`, behind the Next `basePath` `withPayload` publishes,\n * built the way Payload's own admin builds its fetches.\n */\nexport const apiPath = (config: ApiPathConfigSource, path: string): string =>\n\tformatAdminURL({ apiRoute: config.routes?.api ?? '/api', path: rooted(path), relative: true })\n\n/** An app path behind the Next `basePath`, for a mount the host serves through Next rewrites. */\nexport const appPath = (path: string): string =>\n\tformatAdminURL({ apiRoute: '', path: rooted(path), relative: true })\n"],"mappings":";;AAOA,MAAM,YAAY,SAAuC,KAAK,WAAW,GAAG;AAE5E,MAAM,UAAU,SAAgC,SAAS,IAAI,IAAI,OAAO,IAAI;;;;;AAM5E,MAAa,WAAW,QAA6B,SACpD,eAAe;CAAE,UAAU,OAAO,QAAQ,OAAO;CAAQ,MAAM,OAAO,IAAI;CAAG,UAAU;AAAK,CAAC;;AAG9F,MAAa,WAAW,SACvB,eAAe;CAAE,UAAU;CAAI,MAAM,OAAO,IAAI;CAAG,UAAU;AAAK,CAAC"}
|