@10x-media/analytics 1.0.0-beta.16 → 1.0.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/adapters/ga4/ga4.js +33 -2
  3. package/dist/adapters/ga4/ga4.js.map +1 -1
  4. package/dist/adapters/ga4/measurementId.js +4 -1
  5. package/dist/adapters/ga4/measurementId.js.map +1 -1
  6. package/dist/adapters/ga4/propertyId.js +17 -0
  7. package/dist/adapters/ga4/propertyId.js.map +1 -0
  8. package/dist/adapters/http/fetchJson.js +24 -1
  9. package/dist/adapters/http/fetchJson.js.map +1 -1
  10. package/dist/adapters/plausible/plausible.js +16 -1
  11. package/dist/adapters/plausible/plausible.js.map +1 -1
  12. package/dist/adapters/plausible/siteId.js +31 -0
  13. package/dist/adapters/plausible/siteId.js.map +1 -0
  14. package/dist/adapters/posthog/posthog.js +17 -3
  15. package/dist/adapters/posthog/posthog.js.map +1 -1
  16. package/dist/adapters/umami/umami.js +34 -7
  17. package/dist/adapters/umami/umami.js.map +1 -1
  18. package/dist/charts/series.js +1 -1
  19. package/dist/core/contract.d.ts +16 -1
  20. package/dist/core/contract.js.map +1 -1
  21. package/dist/core/options.d.ts +1 -1
  22. package/dist/core/options.js +1 -1
  23. package/dist/core/options.js.map +1 -1
  24. package/dist/core/scopedRead.js +62 -14
  25. package/dist/core/scopedRead.js.map +1 -1
  26. package/dist/core/sourceErrors.js +12 -1
  27. package/dist/core/sourceErrors.js.map +1 -1
  28. package/dist/core/sourceOptions.js +1 -1
  29. package/dist/core/sourceOptions.js.map +1 -1
  30. package/dist/core/sourcePolicy.d.ts +8 -1
  31. package/dist/core/sourcePolicy.js.map +1 -1
  32. package/dist/core/throttle.js +3 -1
  33. package/dist/core/throttle.js.map +1 -1
  34. package/dist/exports/adapters/contract.d.ts +1 -1
  35. package/dist/exports/adapters/ga4.d.ts +2 -2
  36. package/dist/exports/adapters/native.d.ts +2 -2
  37. package/dist/exports/adapters/plausible.d.ts +2 -2
  38. package/dist/exports/adapters/posthog.d.ts +2 -2
  39. package/dist/exports/adapters/umami.d.ts +2 -2
  40. package/dist/exports/client.d.ts +3 -1
  41. package/dist/exports/client.js +3 -1
  42. package/dist/exports/next.d.ts +2 -2
  43. package/dist/exports/testing.d.ts +2 -2
  44. package/dist/exports/types.d.ts +3 -3
  45. package/dist/fields/config/fetchSources.js +1 -1
  46. package/dist/fields/config/fetchSources.js.map +1 -1
  47. package/dist/goals/collection.js +3 -2
  48. package/dist/goals/collection.js.map +1 -1
  49. package/dist/goals/resolver.js +1 -1
  50. package/dist/index.d.ts +4 -3
  51. package/dist/index.js +50 -4
  52. package/dist/index.js.map +1 -1
  53. package/dist/native/geo/maxmindResolver.js +1 -1
  54. package/dist/native/nativeAdapter.js +1 -1
  55. package/dist/plugin/createRuntime.js +57 -13
  56. package/dist/plugin/createRuntime.js.map +1 -1
  57. package/dist/plugin/pluginCollections.js +4 -1
  58. package/dist/plugin/pluginCollections.js.map +1 -1
  59. package/dist/plugin/providerStatusEndpoint.js +80 -0
  60. package/dist/plugin/providerStatusEndpoint.js.map +1 -0
  61. package/dist/plugin/queryEndpoint.js +1 -1
  62. package/dist/plugin/queryEndpoint.js.map +1 -1
  63. package/dist/plugin/readContextForRequest.d.ts +4 -3
  64. package/dist/plugin/readContextForRequest.js +2 -2
  65. package/dist/plugin/readContextForRequest.js.map +1 -1
  66. package/dist/plugin/refreshEndpoint.js +1 -1
  67. package/dist/plugin/routes.d.ts +5 -0
  68. package/dist/plugin/routes.js +1 -0
  69. package/dist/plugin/routes.js.map +1 -1
  70. package/dist/plugin/runtime.js.map +1 -1
  71. package/dist/providers/ProviderConnection.d.ts +12 -0
  72. package/dist/providers/ProviderConnection.js +105 -0
  73. package/dist/providers/ProviderConnection.js.map +1 -0
  74. package/dist/providers/ProviderConnectionTest.d.ts +12 -0
  75. package/dist/providers/ProviderConnectionTest.js +55 -0
  76. package/dist/providers/ProviderConnectionTest.js.map +1 -0
  77. package/dist/providers/ProvidersListNotice.d.ts +1 -1
  78. package/dist/providers/ProvidersListNotice.js +3 -2
  79. package/dist/providers/ProvidersListNotice.js.map +1 -1
  80. package/dist/providers/collection.d.ts +1 -1
  81. package/dist/providers/collection.js +97 -38
  82. package/dist/providers/collection.js.map +1 -1
  83. package/dist/providers/connectionCheck.d.ts +1 -0
  84. package/dist/providers/connectionCheck.js +80 -0
  85. package/dist/providers/connectionCheck.js.map +1 -0
  86. package/dist/providers/connectionState.js +53 -0
  87. package/dist/providers/connectionState.js.map +1 -0
  88. package/dist/providers/factory.d.ts +1 -3
  89. package/dist/providers/factory.js +18 -21
  90. package/dist/providers/factory.js.map +1 -1
  91. package/dist/providers/hosts.js +20 -6
  92. package/dist/providers/hosts.js.map +1 -1
  93. package/dist/providers/ids.d.ts +6 -0
  94. package/dist/providers/ids.js +32 -0
  95. package/dist/providers/ids.js.map +1 -0
  96. package/dist/providers/providerStatusClient.js +60 -0
  97. package/dist/providers/providerStatusClient.js.map +1 -0
  98. package/dist/providers/registry.js +56 -20
  99. package/dist/providers/registry.js.map +1 -1
  100. package/dist/providers/retarget.js +39 -8
  101. package/dist/providers/retarget.js.map +1 -1
  102. package/dist/providers/secrets.d.ts +1 -1
  103. package/dist/providers/secrets.js.map +1 -1
  104. package/dist/providers/status.d.ts +1 -0
  105. package/dist/providers/status.js +181 -0
  106. package/dist/providers/status.js.map +1 -0
  107. package/dist/surfacing/classifyError.js +37 -5
  108. package/dist/surfacing/classifyError.js.map +1 -1
  109. package/dist/surfacing/engine.js +2 -2
  110. package/dist/surfacing/engine.js.map +1 -1
  111. package/dist/surfacing/lanes.js +29 -22
  112. package/dist/surfacing/lanes.js.map +1 -1
  113. package/dist/surfacing/rebucket.js +1 -1
  114. package/dist/testing/settle.d.ts +2 -1
  115. package/dist/testing/settle.js +6 -2
  116. package/dist/testing/settle.js.map +1 -1
  117. package/dist/tracker/sinks/ga4.js +2 -2
  118. package/dist/translations/ar.js +40 -8
  119. package/dist/translations/ar.js.map +1 -1
  120. package/dist/translations/de.js +40 -8
  121. package/dist/translations/de.js.map +1 -1
  122. package/dist/translations/en.js +40 -8
  123. package/dist/translations/en.js.map +1 -1
  124. package/dist/translations/es.js +40 -8
  125. package/dist/translations/es.js.map +1 -1
  126. package/dist/translations/fr.js +40 -8
  127. package/dist/translations/fr.js.map +1 -1
  128. package/dist/translations/id.js +40 -8
  129. package/dist/translations/id.js.map +1 -1
  130. package/dist/translations/keys.d.ts +32 -0
  131. package/dist/translations/keys.js +32 -0
  132. package/dist/translations/keys.js.map +1 -1
  133. package/dist/translations/ko.js +40 -8
  134. package/dist/translations/ko.js.map +1 -1
  135. package/dist/translations/pt.js +40 -8
  136. package/dist/translations/pt.js.map +1 -1
  137. package/dist/translations/ru.js +40 -8
  138. package/dist/translations/ru.js.map +1 -1
  139. package/dist/translations/uk.js +40 -8
  140. package/dist/translations/uk.js.map +1 -1
  141. package/dist/translations/zh.js +40 -8
  142. package/dist/translations/zh.js.map +1 -1
  143. package/dist/ui/analytics.css +63 -0
  144. package/dist/ui/components/SourcesNoticeBanner.js +4 -3
  145. package/dist/ui/components/SourcesNoticeBanner.js.map +1 -1
  146. package/dist/view/ViewSections.js +9 -2
  147. package/dist/view/ViewSections.js.map +1 -1
  148. package/dist/view/sections/EmptyStates.js +5 -4
  149. package/dist/view/sections/EmptyStates.js.map +1 -1
  150. package/dist/view/sections/OverviewCards.js +6 -2
  151. package/dist/view/sections/OverviewCards.js.map +1 -1
  152. package/dist/view/sections/SourceConnectionNote.js +56 -0
  153. package/dist/view/sections/SourceConnectionNote.js.map +1 -0
  154. package/dist/view/viewProps.d.ts +2 -0
  155. package/dist/view/viewProps.js +2 -1
  156. package/dist/view/viewProps.js.map +1 -1
  157. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sourceErrors.js","names":[],"sources":["../../src/core/sourceErrors.ts"],"sourcesContent":["import type { FilterPair } from './capabilities'\nimport { isDimensionKey, isFilterOperator } from './guards'\n\n/** `Symbol.for`, so an error thrown in one of the package's bundles is recognized in another. */\nconst MISCONFIGURED: unique symbol = Symbol.for('@10x-media/analytics/sourceMisconfigured')\n\nconst HOST_REFUSED: unique symbol = Symbol.for('@10x-media/analytics/hostRefused')\n\nconst UNSUPPORTED_FILTER: unique symbol = Symbol.for('@10x-media/analytics/unsupportedFilter')\n\nconst INVALID_QUERY: unique symbol = Symbol.for('@10x-media/analytics/invalidQuery')\n\n/**\n * A source that cannot work as it is set up. Retrying cannot help, only changing its settings\n * can, so reads answer `source_misconfigured` rather than `unavailable` and are never retried.\n */\nexport class SourceMisconfiguredError extends Error {\n\treadonly [MISCONFIGURED] = true\n\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options)\n\t\tthis.name = 'SourceMisconfiguredError'\n\t}\n}\n\n/** A host a provider document may not reach: unlisted, private, or not https. */\nexport class HostRefusedError extends SourceMisconfiguredError {\n\treadonly [HOST_REFUSED] = true\n\treadonly host: string\n\n\tconstructor(host: string, reason: string) {\n\t\tsuper(`analytics: ${host} is refused: ${reason}`)\n\t\tthis.name = 'HostRefusedError'\n\t\tthis.host = host\n\t}\n}\n\n/** How deep a cause chain is searched; a cyclic or runaway chain ends here. */\nconst MAX_CAUSE_DEPTH = 5\n\n/** The first error in `err`'s cause chain carrying `brand`, or undefined. */\nconst brandedCause = (err: unknown, brand: symbol): object | undefined => {\n\tlet current: unknown = err\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (typeof current !== 'object' || current === null) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (Reflect.get(current, brand) === true) {\n\t\t\treturn current\n\t\t}\n\t\tcurrent = Reflect.get(current, 'cause')\n\t}\n\treturn undefined\n}\n\n/** True for a {@link SourceMisconfiguredError} anywhere in an error's cause chain. */\nexport const isSourceMisconfigured = (err: unknown): boolean =>\n\tbrandedCause(err, MISCONFIGURED) !== undefined\n\n/** True for a {@link HostRefusedError} anywhere in an error's cause chain. */\nexport const isHostRefused = (err: unknown): boolean =>\n\tbrandedCause(err, HOST_REFUSED) !== undefined\n\n/**\n * A read carrying a filter its source does not apply. The source would answer without it, and\n * its numbers would read as filtered when they are not, so the read is refused before it is made.\n */\nexport class UnsupportedFilterError extends Error {\n\treadonly [UNSUPPORTED_FILTER] = true\n\treadonly filter: FilterPair\n\n\tconstructor(source: string, filter: FilterPair) {\n\t\tsuper(`analytics: source \"${source}\" cannot filter ${filter.dimension} with ${filter.operator}`)\n\t\tthis.name = 'UnsupportedFilterError'\n\t\tthis.filter = { dimension: filter.dimension, operator: filter.operator }\n\t}\n}\n\nconst isFilterPair = (value: unknown): value is FilterPair =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\tisDimensionKey(Reflect.get(value, 'dimension')) &&\n\tisFilterOperator(Reflect.get(value, 'operator'))\n\n/**\n * The filter an {@link UnsupportedFilterError} anywhere in an error's cause chain refused, or\n * undefined for any other error.\n */\nexport const refusedFilter = (err: unknown): FilterPair | undefined => {\n\tconst refusal = brandedCause(err, UNSUPPORTED_FILTER)\n\tconst filter: unknown = refusal === undefined ? undefined : Reflect.get(refusal, 'filter')\n\treturn isFilterPair(filter) ? filter : undefined\n}\n\n/**\n * A read its source refuses as asked: a combination it never counts (goal completions broken\n * down by item, say), which no retry or setting changes. Endpoints answer it `invalid_param`.\n */\nexport class InvalidQueryError extends Error {\n\treadonly [INVALID_QUERY] = true\n\t/** The query parameter at fault. */\n\treadonly param: string\n\n\tconstructor(message: string, param: string, options?: ErrorOptions) {\n\t\tsuper(message, options)\n\t\tthis.name = 'InvalidQueryError'\n\t\tthis.param = param\n\t}\n}\n\n/** An error and each cause beneath it, so a log line keeps the driver error a wrapper carries. */\nexport const describeWithCauses = (err: unknown): string => {\n\tconst parts: string[] = []\n\tlet current: unknown = err\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH && current != null; depth++) {\n\t\tconst message = current instanceof Error ? current.message : String(current)\n\t\t// A wrapper that already quotes its cause's message (`ReadFailedError`) is not repeated.\n\t\tif (!parts.some((part) => message !== '' && part.includes(message))) {\n\t\t\tparts.push(String(current))\n\t\t}\n\t\tcurrent = typeof current === 'object' ? Reflect.get(current, 'cause') : undefined\n\t}\n\treturn parts.join(', caused by ')\n}\n\n/** The refusal an {@link InvalidQueryError} anywhere in an error's cause chain carries. */\nexport const invalidQuery = (err: unknown): { message: string; param: string } | undefined => {\n\tconst refusal = brandedCause(err, INVALID_QUERY)\n\tif (refusal === undefined) {\n\t\treturn undefined\n\t}\n\tconst message: unknown = Reflect.get(refusal, 'message')\n\tconst param: unknown = Reflect.get(refusal, 'param')\n\treturn typeof message === 'string' && typeof param === 'string' ? { message, param } : undefined\n}\n"],"mappings":";;;AAIA,MAAM,gBAA+B,OAAO,IAAI,0CAA0C;AAE1F,MAAM,eAA8B,OAAO,IAAI,kCAAkC;AAEjF,MAAM,qBAAoC,OAAO,IAAI,wCAAwC;AAE7F,MAAM,gBAA+B,OAAO,IAAI,mCAAmC;;;;;AAMnF,IAAa,2BAAb,cAA8C,MAAM;CACnD,CAAU,iBAAiB;CAE3B,YAAY,SAAiB,SAAwB;EACpD,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,mBAAb,cAAsC,yBAAyB;CAC9D,CAAU,gBAAgB;CAC1B;CAEA,YAAY,MAAc,QAAgB;EACzC,MAAM,cAAc,KAAK,eAAe,QAAQ;EAChD,KAAK,OAAO;EACZ,KAAK,OAAO;CACb;AACD;;AAGA,MAAM,kBAAkB;;AAGxB,MAAM,gBAAgB,KAAc,UAAsC;CACzE,IAAI,UAAmB;CACvB,KAAK,IAAI,QAAQ,GAAG,QAAQ,iBAAiB,SAAS;EACrD,IAAI,OAAO,YAAY,YAAY,YAAY,MAC9C;EAED,IAAI,QAAQ,IAAI,SAAS,KAAK,MAAM,MACnC,OAAO;EAER,UAAU,QAAQ,IAAI,SAAS,OAAO;CACvC;AAED;;AAGA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IAAI,KAAA;CACzE;CACA,OAAO,MAAM,KAAK,cAAc;AACjC;;AAGA,MAAa,gBAAgB,QAAiE;CAC7F,MAAM,UAAU,aAAa,KAAK,aAAa;CAC/C,IAAI,YAAY,KAAA,GACf;CAED,MAAM,UAAmB,QAAQ,IAAI,SAAS,SAAS;CACvD,MAAM,QAAiB,QAAQ,IAAI,SAAS,OAAO;CACnD,OAAO,OAAO,YAAY,YAAY,OAAO,UAAU,WAAW;EAAE;EAAS;CAAM,IAAI,KAAA;AACxF"}
1
+ {"version":3,"file":"sourceErrors.js","names":[],"sources":["../../src/core/sourceErrors.ts"],"sourcesContent":["import type { FilterPair } from './capabilities'\nimport { isDimensionKey, isFilterOperator } from './guards'\n\n/** `Symbol.for`, so an error thrown in one of the package's bundles is recognized in another. */\nconst MISCONFIGURED: unique symbol = Symbol.for('@10x-media/analytics/sourceMisconfigured')\n\nconst HOST_REFUSED: unique symbol = Symbol.for('@10x-media/analytics/hostRefused')\n\nconst UNKNOWN_SITE: unique symbol = Symbol.for('@10x-media/analytics/unknownSite')\n\nconst UNSUPPORTED_FILTER: unique symbol = Symbol.for('@10x-media/analytics/unsupportedFilter')\n\nconst INVALID_QUERY: unique symbol = Symbol.for('@10x-media/analytics/invalidQuery')\n\n/**\n * A source that cannot work as it is set up. Retrying cannot help, only changing its settings\n * can, so reads answer `source_misconfigured` rather than `unavailable` and are never retried.\n */\nexport class SourceMisconfiguredError extends Error {\n\treadonly [MISCONFIGURED] = true\n\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options)\n\t\tthis.name = 'SourceMisconfiguredError'\n\t}\n}\n\n/** A host a provider document may not reach: unlisted, private, or not https. */\nexport class HostRefusedError extends SourceMisconfiguredError {\n\treadonly [HOST_REFUSED] = true\n\treadonly host: string\n\n\tconstructor(host: string, reason: string) {\n\t\tsuper(`analytics: ${host} is refused: ${reason}`)\n\t\tthis.name = 'HostRefusedError'\n\t\tthis.host = host\n\t}\n}\n\n/** A site ID the vendor answered it does not know, such as self-hosted Umami's Website ID. */\nexport class UnknownSiteError extends SourceMisconfiguredError {\n\treadonly [UNKNOWN_SITE] = true\n\n\tconstructor(message: string) {\n\t\tsuper(message)\n\t\tthis.name = 'UnknownSiteError'\n\t}\n}\n\n/** How deep a cause chain is searched; a cyclic or runaway chain ends here. */\nconst MAX_CAUSE_DEPTH = 5\n\n/** The first error in `err`'s cause chain carrying `brand`, or undefined. */\nconst brandedCause = (err: unknown, brand: symbol): object | undefined => {\n\tlet current: unknown = err\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (typeof current !== 'object' || current === null) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (Reflect.get(current, brand) === true) {\n\t\t\treturn current\n\t\t}\n\t\tcurrent = Reflect.get(current, 'cause')\n\t}\n\treturn undefined\n}\n\n/** True for a {@link SourceMisconfiguredError} anywhere in an error's cause chain. */\nexport const isSourceMisconfigured = (err: unknown): boolean =>\n\tbrandedCause(err, MISCONFIGURED) !== undefined\n\n/** True for a {@link HostRefusedError} anywhere in an error's cause chain. */\nexport const isHostRefused = (err: unknown): boolean =>\n\tbrandedCause(err, HOST_REFUSED) !== undefined\n\n/** True for an {@link UnknownSiteError} anywhere in an error's cause chain. */\nexport const isUnknownSite = (err: unknown): boolean =>\n\tbrandedCause(err, UNKNOWN_SITE) !== undefined\n\n/**\n * A read carrying a filter its source does not apply. The source would answer without it, and\n * its numbers would read as filtered when they are not, so the read is refused before it is made.\n */\nexport class UnsupportedFilterError extends Error {\n\treadonly [UNSUPPORTED_FILTER] = true\n\treadonly filter: FilterPair\n\n\tconstructor(source: string, filter: FilterPair) {\n\t\tsuper(`analytics: source \"${source}\" cannot filter ${filter.dimension} with ${filter.operator}`)\n\t\tthis.name = 'UnsupportedFilterError'\n\t\tthis.filter = { dimension: filter.dimension, operator: filter.operator }\n\t}\n}\n\nconst isFilterPair = (value: unknown): value is FilterPair =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\tisDimensionKey(Reflect.get(value, 'dimension')) &&\n\tisFilterOperator(Reflect.get(value, 'operator'))\n\n/**\n * The filter an {@link UnsupportedFilterError} anywhere in an error's cause chain refused, or\n * undefined for any other error.\n */\nexport const refusedFilter = (err: unknown): FilterPair | undefined => {\n\tconst refusal = brandedCause(err, UNSUPPORTED_FILTER)\n\tconst filter: unknown = refusal === undefined ? undefined : Reflect.get(refusal, 'filter')\n\treturn isFilterPair(filter) ? filter : undefined\n}\n\n/**\n * A read its source refuses as asked: a combination it never counts (goal completions broken\n * down by item, say), which no retry or setting changes. Endpoints answer it `invalid_param`.\n */\nexport class InvalidQueryError extends Error {\n\treadonly [INVALID_QUERY] = true\n\t/** The query parameter at fault. */\n\treadonly param: string\n\n\tconstructor(message: string, param: string, options?: ErrorOptions) {\n\t\tsuper(message, options)\n\t\tthis.name = 'InvalidQueryError'\n\t\tthis.param = param\n\t}\n}\n\n/** An error and each cause beneath it, so a log line keeps the driver error a wrapper carries. */\nexport const describeWithCauses = (err: unknown): string => {\n\tconst parts: string[] = []\n\tlet current: unknown = err\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH && current != null; depth++) {\n\t\tconst message = current instanceof Error ? current.message : String(current)\n\t\t// A wrapper that already quotes its cause's message (`ReadFailedError`) is not repeated.\n\t\tif (!parts.some((part) => message !== '' && part.includes(message))) {\n\t\t\tparts.push(String(current))\n\t\t}\n\t\tcurrent = typeof current === 'object' ? Reflect.get(current, 'cause') : undefined\n\t}\n\treturn parts.join(', caused by ')\n}\n\n/** The refusal an {@link InvalidQueryError} anywhere in an error's cause chain carries. */\nexport const invalidQuery = (err: unknown): { message: string; param: string } | undefined => {\n\tconst refusal = brandedCause(err, INVALID_QUERY)\n\tif (refusal === undefined) {\n\t\treturn undefined\n\t}\n\tconst message: unknown = Reflect.get(refusal, 'message')\n\tconst param: unknown = Reflect.get(refusal, 'param')\n\treturn typeof message === 'string' && typeof param === 'string' ? { message, param } : undefined\n}\n"],"mappings":";;;AAIA,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YAAY,YAAY,OAAO,UAAU,WAAW;EAAE;EAAS;CAAM,IAAI,KAAA;AACxF"}
@@ -1,8 +1,8 @@
1
1
  import { isRecord, kindOf, listOf } from "./values.js";
2
+ import { PROVIDER_IDS } from "../providers/ids.js";
2
3
  import { keysOf, optionalFunction, optionalList, optionsObject } from "./optionChecks.js";
3
4
  import { resolveScopedCollection } from "./collectionOption.js";
4
5
  import { resolveHostPolicy } from "../providers/hosts.js";
5
- import { PROVIDER_IDS } from "../providers/factory.js";
6
6
  import { PROVIDERS_SLUG, connectionFieldAccess, servedProviderTypes } from "../providers/collection.js";
7
7
  //#region src/core/sourceOptions.ts
8
8
  const PROVIDERS_KEYS = keysOf({
@@ -1 +1 @@
1
- {"version":3,"file":"sourceOptions.js","names":[],"sources":["../../src/core/sourceOptions.ts"],"sourcesContent":["import {\n\tconnectionFieldAccess,\n\tPROVIDERS_SLUG,\n\ttype ProviderCollectionFieldOverrides,\n\tservedProviderTypes,\n} from '../providers/collection'\nimport { PROVIDER_IDS, type ProviderId } from '../providers/factory'\nimport { resolveHostPolicy } from '../providers/hosts'\nimport { resolveScopedCollection } from './collectionOption'\nimport { keysOf, optionalFunction, optionalList, optionsObject } from './optionChecks'\nimport type { ProvidersCollectionOptions, ProvidersOptions, ResolvedOptions } from './options'\nimport { isRecord, kindOf, listOf } from './values'\n\nconst PROVIDERS_KEYS = keysOf<ProvidersOptions>({ collection: true, resolve: true, hosts: true })\nconst PROVIDERS_COLLECTION_KEYS = keysOf<ProvidersCollectionOptions>({\n\tslug: true,\n\tscopeField: true,\n\tfields: true,\n\toverrides: true,\n\taccess: true,\n\tencryption: true,\n\tconnectionAccess: true,\n\tdefaultAccess: true,\n\ttypes: true,\n\tsourceAccess: true,\n})\nconst PROVIDER_FIELD_KEYS = keysOf<ProviderCollectionFieldOverrides>({\n\tname: true,\n\tprovider: true,\n\tenabled: true,\n\tisDefault: true,\n\twithoutConsent: true,\n})\nconst ENCRYPTION_KEYS = keysOf<NonNullable<ProvidersCollectionOptions['encryption']>>({\n\tkeys: true,\n})\n\nconst isAdapterShaped = (value: unknown): value is { id: string } =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\tvalue.id !== '' &&\n\ttypeof value.isConfigured === 'function' &&\n\ttypeof value.query === 'function' &&\n\tisRecord(value.capabilities)\n\n/** `adapters`: a list of adapters with an id each, no two sharing one. */\nexport const assertAdapters = (value: unknown): void => {\n\tconst ids = new Set<string>()\n\tfor (const [index, adapter] of optionalList(value, 'adapters', '[native()]').entries()) {\n\t\tif (!isAdapterShaped(adapter)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters[${index}] must be an adapter such as native() or plausible({ siteId, apiKey }), got ${kindOf(adapter)}`\n\t\t\t)\n\t\t}\n\t\tif (ids.has(adapter.id)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters lists two adapters with the id \"${adapter.id}\"; every source is read by its id, so give each its own`\n\t\t\t)\n\t\t}\n\t\tids.add(adapter.id)\n\t}\n}\n\n/** An option naming one of `adapters` by its id. */\nexport const assertNamesAdapter = (\n\tvalue: unknown,\n\tpath: string,\n\tadapters: readonly { id: string }[]\n): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} must be the id of an adapter in adapters, got ${kindOf(value)}`\n\t\t)\n\t}\n\tif (!adapters.some((adapter) => adapter.id === value)) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} \"${value}\" names no adapter in adapters, whose ids are ${listOf(adapters.map((adapter) => `\"${adapter.id}\"`))}`\n\t\t)\n\t}\n}\n\n/** `providers.collection.encryption`: a dedicated key ring, or nothing. */\nconst assertEncryption = (value: unknown): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tconst { keys } = optionsObject(value, {\n\t\tpath: 'providers.collection.encryption',\n\t\tknown: ENCRYPTION_KEYS,\n\t\texample: 'an object such as { keys }',\n\t})\n\tif (\n\t\tkeys !== undefined &&\n\t\t(!isRecord(keys) || typeof keys.active !== 'string' || !isRecord(keys.keys))\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: providers.collection.encryption.keys must be a key set such as { active: 'k1', keys: { k1: process.env.PROVIDER_KEY } }, got ${kindOf(keys)}`\n\t\t)\n\t}\n}\n\n/** A `native` document lends the config native(), so the type is served only beside one. */\nconst availableTypes = (adapters: readonly { id: string }[]): ProviderId[] =>\n\tPROVIDER_IDS.filter((type) => type !== 'native' || adapters.some((a) => a.id === 'native'))\n\n/** `providers.collection` turned on, with what only that collection takes. */\nconst resolveProvidersCollection = (\n\toption: ProvidersOptions['collection'],\n\tavailable: readonly ProviderId[]\n): ResolvedOptions['providers']['collection'] => {\n\tconst collection = resolveScopedCollection(option, {\n\t\tpath: 'providers.collection',\n\t\tfallback: PROVIDERS_SLUG,\n\t\tknown: PROVIDERS_COLLECTION_KEYS,\n\t\tfieldKeys: PROVIDER_FIELD_KEYS,\n\t\texampleSlug: 'providers',\n\t})\n\tif (option === undefined || typeof option === 'boolean') {\n\t\treturn { ...collection, types: available }\n\t}\n\tassertEncryption(option.encryption)\n\tconst connectionAccess = connectionFieldAccess(\n\t\t'providers.collection.connectionAccess',\n\t\toption.connectionAccess\n\t)\n\tconst defaultAccess = connectionFieldAccess(\n\t\t'providers.collection.defaultAccess',\n\t\toption.defaultAccess\n\t)\n\tconst sourceAccess = optionalFunction(option.sourceAccess, 'providers.collection.sourceAccess')\n\treturn {\n\t\t...collection,\n\t\ttypes: servedProviderTypes('providers.collection.types', option.types, available),\n\t\t...(option.encryption ? { encryption: option.encryption } : {}),\n\t\t...(connectionAccess ? { connectionAccess } : {}),\n\t\t...(defaultAccess ? { defaultAccess } : {}),\n\t\t...(sourceAccess ? { sourceAccess } : {}),\n\t}\n}\n\n/** `providers`: the collection or `resolve` (never both), and the hosts either may reach. */\nexport const resolveProviders = (\n\toption: ProvidersOptions | undefined,\n\tadapters: readonly { id: string }[]\n): ResolvedOptions['providers'] => {\n\tif (option !== undefined) {\n\t\toptionsObject(option, {\n\t\t\tpath: 'providers',\n\t\t\tknown: PROVIDERS_KEYS,\n\t\t\texample: 'an object such as { collection: true }',\n\t\t})\n\t}\n\tconst resolve = optionalFunction(option?.resolve, 'providers.resolve')\n\tconst collection = resolveProvidersCollection(option?.collection, availableTypes(adapters))\n\tif (resolve && collection.enabled) {\n\t\tthrow new Error(\n\t\t\t\"analytics: providers.resolve and providers.collection cannot both be set. resolve replaces the collection lookup, so the adapters it returns would be filtered by provider document ids no reader holds, and the collection's sourceAccess and connectionAccess would do nothing. Keep one of them.\"\n\t\t)\n\t}\n\tif (option?.hosts !== undefined && !collection.enabled && !resolve) {\n\t\tthrow new Error(\n\t\t\t'analytics: providers.hosts only applies to provider documents, so it needs providers.collection or providers.resolve. Set one of them, or remove it.'\n\t\t)\n\t}\n\treturn {\n\t\tcollection,\n\t\t...(resolve ? { resolve } : {}),\n\t\thosts: resolveHostPolicy(option?.hosts),\n\t}\n}\n"],"mappings":";;;;;;;AAaA,MAAM,iBAAiB,OAAyB;CAAE,YAAY;CAAM,SAAS;CAAM,OAAO;AAAK,CAAC;AAChG,MAAM,4BAA4B,OAAmC;CACpE,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,YAAY;CACZ,kBAAkB;CAClB,eAAe;CACf,OAAO;CACP,cAAc;AACf,CAAC;AACD,MAAM,sBAAsB,OAAyC;CACpE,MAAM;CACN,UAAU;CACV,SAAS;CACT,WAAW;CACX,gBAAgB;AACjB,CAAC;AACD,MAAM,kBAAkB,OAA8D,EACrF,MAAM,KACP,CAAC;AAED,MAAM,mBAAmB,UACxB,SAAS,KAAK,KACd,OAAO,MAAM,OAAO,YACpB,MAAM,OAAO,MACb,OAAO,MAAM,iBAAiB,cAC9B,OAAO,MAAM,UAAU,cACvB,SAAS,MAAM,YAAY;;AAG5B,MAAa,kBAAkB,UAAyB;CACvD,MAAM,sBAAM,IAAI,IAAY;CAC5B,KA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;CAE1C,iBAAiB,OAAO,UAAU;CAClC,MAAM,mBAAmB,sBACxB,yCACA,OAAO,gBACR;CACA,MAAM,gBAAgB,sBACrB,sCACA,OAAO,aACR;CACA,MAAM,eAAe,iBAAiB,OAAO,cAAc,mCAAmC;CAC9F,OAAO;EACN,GAAG;EACH,OAAO,oBAAoB,8BAA8B,OAAO,OAAO,SAAS;EAChF,GAAI,OAAO,aAAa,EAAE,YAAY,OAAO,WAAW,IAAI,CAAC;EAC7D,GAAI,mBAAmB,EAAE,iBAAiB,IAAI,CAAC;EAC/C,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EACzC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;CACxC;AACD;;AAGA,MAAa,oBACZ,QACA,aACkC;CAClC,IAAI,WAAW,KAAA,GACd,cAAc,QAAQ;EACrB,MAAM;EACN,OAAO;EACP,SAAS;CACV,CAAC;CAEF,MAAM,UAAU,iBAAiB,QAAQ,SAAS,mBAAmB;CACrE,MAAM,aAAa,2BAA2B,QAAQ,YAAY,eAAe,QAAQ,CAAC;CAC1F,IAAI,WAAW,WAAW,SACzB,MAAM,IAAI,MACT,qSACD;CAED,IAAI,QAAQ,UAAU,KAAA,KAAa,CAAC,WAAW,WAAW,CAAC,SAC1D,MAAM,IAAI,MACT,sJACD;CAED,OAAO;EACN;EACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC7B,OAAO,kBAAkB,QAAQ,KAAK;CACvC;AACD"}
1
+ {"version":3,"file":"sourceOptions.js","names":[],"sources":["../../src/core/sourceOptions.ts"],"sourcesContent":["import {\n\tconnectionFieldAccess,\n\tPROVIDERS_SLUG,\n\ttype ProviderCollectionFieldOverrides,\n\tservedProviderTypes,\n} from '../providers/collection'\nimport { resolveHostPolicy } from '../providers/hosts'\nimport { PROVIDER_IDS, type ProviderId } from '../providers/ids'\nimport { resolveScopedCollection } from './collectionOption'\nimport { keysOf, optionalFunction, optionalList, optionsObject } from './optionChecks'\nimport type { ProvidersCollectionOptions, ProvidersOptions, ResolvedOptions } from './options'\nimport { isRecord, kindOf, listOf } from './values'\n\nconst PROVIDERS_KEYS = keysOf<ProvidersOptions>({ collection: true, resolve: true, hosts: true })\nconst PROVIDERS_COLLECTION_KEYS = keysOf<ProvidersCollectionOptions>({\n\tslug: true,\n\tscopeField: true,\n\tfields: true,\n\toverrides: true,\n\taccess: true,\n\tencryption: true,\n\tconnectionAccess: true,\n\tdefaultAccess: true,\n\ttypes: true,\n\tsourceAccess: true,\n})\nconst PROVIDER_FIELD_KEYS = keysOf<ProviderCollectionFieldOverrides>({\n\tname: true,\n\tprovider: true,\n\tenabled: true,\n\tisDefault: true,\n\twithoutConsent: true,\n})\nconst ENCRYPTION_KEYS = keysOf<NonNullable<ProvidersCollectionOptions['encryption']>>({\n\tkeys: true,\n})\n\nconst isAdapterShaped = (value: unknown): value is { id: string } =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\tvalue.id !== '' &&\n\ttypeof value.isConfigured === 'function' &&\n\ttypeof value.query === 'function' &&\n\tisRecord(value.capabilities)\n\n/** `adapters`: a list of adapters with an id each, no two sharing one. */\nexport const assertAdapters = (value: unknown): void => {\n\tconst ids = new Set<string>()\n\tfor (const [index, adapter] of optionalList(value, 'adapters', '[native()]').entries()) {\n\t\tif (!isAdapterShaped(adapter)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters[${index}] must be an adapter such as native() or plausible({ siteId, apiKey }), got ${kindOf(adapter)}`\n\t\t\t)\n\t\t}\n\t\tif (ids.has(adapter.id)) {\n\t\t\tthrow new Error(\n\t\t\t\t`analytics: adapters lists two adapters with the id \"${adapter.id}\"; every source is read by its id, so give each its own`\n\t\t\t)\n\t\t}\n\t\tids.add(adapter.id)\n\t}\n}\n\n/** An option naming one of `adapters` by its id. */\nexport const assertNamesAdapter = (\n\tvalue: unknown,\n\tpath: string,\n\tadapters: readonly { id: string }[]\n): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tif (typeof value !== 'string') {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} must be the id of an adapter in adapters, got ${kindOf(value)}`\n\t\t)\n\t}\n\tif (!adapters.some((adapter) => adapter.id === value)) {\n\t\tthrow new Error(\n\t\t\t`analytics: ${path} \"${value}\" names no adapter in adapters, whose ids are ${listOf(adapters.map((adapter) => `\"${adapter.id}\"`))}`\n\t\t)\n\t}\n}\n\n/** `providers.collection.encryption`: a dedicated key ring, or nothing. */\nconst assertEncryption = (value: unknown): void => {\n\tif (value === undefined) {\n\t\treturn\n\t}\n\tconst { keys } = optionsObject(value, {\n\t\tpath: 'providers.collection.encryption',\n\t\tknown: ENCRYPTION_KEYS,\n\t\texample: 'an object such as { keys }',\n\t})\n\tif (\n\t\tkeys !== undefined &&\n\t\t(!isRecord(keys) || typeof keys.active !== 'string' || !isRecord(keys.keys))\n\t) {\n\t\tthrow new Error(\n\t\t\t`analytics: providers.collection.encryption.keys must be a key set such as { active: 'k1', keys: { k1: process.env.PROVIDER_KEY } }, got ${kindOf(keys)}`\n\t\t)\n\t}\n}\n\n/** A `native` document lends the config native(), so the type is served only beside one. */\nconst availableTypes = (adapters: readonly { id: string }[]): ProviderId[] =>\n\tPROVIDER_IDS.filter((type) => type !== 'native' || adapters.some((a) => a.id === 'native'))\n\n/** `providers.collection` turned on, with what only that collection takes. */\nconst resolveProvidersCollection = (\n\toption: ProvidersOptions['collection'],\n\tavailable: readonly ProviderId[]\n): ResolvedOptions['providers']['collection'] => {\n\tconst collection = resolveScopedCollection(option, {\n\t\tpath: 'providers.collection',\n\t\tfallback: PROVIDERS_SLUG,\n\t\tknown: PROVIDERS_COLLECTION_KEYS,\n\t\tfieldKeys: PROVIDER_FIELD_KEYS,\n\t\texampleSlug: 'providers',\n\t})\n\tif (option === undefined || typeof option === 'boolean') {\n\t\treturn { ...collection, types: available }\n\t}\n\tassertEncryption(option.encryption)\n\tconst connectionAccess = connectionFieldAccess(\n\t\t'providers.collection.connectionAccess',\n\t\toption.connectionAccess\n\t)\n\tconst defaultAccess = connectionFieldAccess(\n\t\t'providers.collection.defaultAccess',\n\t\toption.defaultAccess\n\t)\n\tconst sourceAccess = optionalFunction(option.sourceAccess, 'providers.collection.sourceAccess')\n\treturn {\n\t\t...collection,\n\t\ttypes: servedProviderTypes('providers.collection.types', option.types, available),\n\t\t...(option.encryption ? { encryption: option.encryption } : {}),\n\t\t...(connectionAccess ? { connectionAccess } : {}),\n\t\t...(defaultAccess ? { defaultAccess } : {}),\n\t\t...(sourceAccess ? { sourceAccess } : {}),\n\t}\n}\n\n/** `providers`: the collection or `resolve` (never both), and the hosts either may reach. */\nexport const resolveProviders = (\n\toption: ProvidersOptions | undefined,\n\tadapters: readonly { id: string }[]\n): ResolvedOptions['providers'] => {\n\tif (option !== undefined) {\n\t\toptionsObject(option, {\n\t\t\tpath: 'providers',\n\t\t\tknown: PROVIDERS_KEYS,\n\t\t\texample: 'an object such as { collection: true }',\n\t\t})\n\t}\n\tconst resolve = optionalFunction(option?.resolve, 'providers.resolve')\n\tconst collection = resolveProvidersCollection(option?.collection, availableTypes(adapters))\n\tif (resolve && collection.enabled) {\n\t\tthrow new Error(\n\t\t\t\"analytics: providers.resolve and providers.collection cannot both be set. resolve replaces the collection lookup, so the adapters it returns would be filtered by provider document ids no reader holds, and the collection's sourceAccess and connectionAccess would do nothing. Keep one of them.\"\n\t\t)\n\t}\n\tif (option?.hosts !== undefined && !collection.enabled && !resolve) {\n\t\tthrow new Error(\n\t\t\t'analytics: providers.hosts only applies to provider documents, so it needs providers.collection or providers.resolve. Set one of them, or remove it.'\n\t\t)\n\t}\n\treturn {\n\t\tcollection,\n\t\t...(resolve ? { resolve } : {}),\n\t\thosts: resolveHostPolicy(option?.hosts),\n\t}\n}\n"],"mappings":";;;;;;;AAaA,MAAM,iBAAiB,OAAyB;CAAE,YAAY;CAAM,SAAS;CAAM,OAAO;AAAK,CAAC;AAChG,MAAM,4BAA4B,OAAmC;CACpE,MAAM;CACN,YAAY;CACZ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,WAAW,WAAW,CAAC,SAC1D,MAAM,IAAI,MACT,sJACD;CAED,OAAO;EACN;EACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC7B,OAAO,kBAAkB,QAAQ,KAAK;CACvC;AACD"}
@@ -15,6 +15,12 @@ interface OwnSource {
15
15
  id: string;
16
16
  label: string;
17
17
  docId: string;
18
+ /**
19
+ * Whether the document's connection is failing, as the `fallback` policy reads it: refused, or a
20
+ * vendor that did not answer while its reads rest. The statuses are read on the first call, once
21
+ * per request, so a policy that never asks costs no read.
22
+ */
23
+ failing(): Promise<boolean>;
18
24
  }
19
25
  /**
20
26
  * Decides whether a member of `scope` reads it through the shared adapter `adapterId`. Asked at
@@ -28,7 +34,8 @@ type SourcePolicyFunction = (args: {
28
34
  }) => boolean | Promise<boolean>;
29
35
  /**
30
36
  * Who besides `access.crossScope.unscopedSource` reads a tenant through a shared adapter: `staff`
31
- * nobody else, `tenant` the scope's members, `fallback` its members until they have a source of their own.
37
+ * nobody else, `tenant` the scope's members, `fallback` its members while they have no source of their own
38
+ * that works.
32
39
  */
33
40
  type SourcePolicy = 'staff' | 'tenant' | 'fallback' | SourcePolicyFunction;
34
41
  /** How tenants reach one shared config adapter. */
@@ -1 +1 @@
1
- {"version":3,"file":"sourcePolicy.js","names":[],"sources":["../../src/core/sourcePolicy.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport type { AnalyticsAdapter } from './contract'\nimport { keysOf, optionsObject } from './optionChecks'\nimport { isRecord, kindOf, listOf } from './values'\n\n/** A source one scope reads through, as `defaultSource` is shown it. */\nexport interface SourceRef {\n\tid: string\n\tlabel: string\n\t/** `config` for an adapter every scope shares, `runtime` for one resolved per scope. */\n\tkind: 'config' | 'runtime'\n\t/** The provider document granting it to the scope; absent for a shared adapter none grants. */\n\tdocId?: string\n}\n\n/** A source the reader reads a scope through by one of that scope's own provider documents. */\nexport interface OwnSource {\n\tid: string\n\tlabel: string\n\tdocId: string\n}\n\n/**\n * Decides whether a member of `scope` reads it through the shared adapter `adapterId`. Asked at\n * most once per request, scope and adapter; a throw counts as no.\n */\nexport type SourcePolicyFunction = (args: {\n\treq: PayloadRequest\n\tscope: string\n\tadapterId: string\n\t/** Sources the reader already reads the scope through by its own provider documents. */\n\townSources: OwnSource[]\n}) => boolean | Promise<boolean>\n\n/**\n * Who besides `access.crossScope.unscopedSource` reads a tenant through a shared adapter: `staff`\n * nobody else, `tenant` the scope's members, `fallback` its members until they have a source of their own.\n */\nexport type SourcePolicy = 'staff' | 'tenant' | 'fallback' | SourcePolicyFunction\n\n/** How tenants reach one shared config adapter. */\nexport interface AnalyticsSourceOptions {\n\t/**\n\t * Which of a tenant's own users read it, narrowed to their tenant. Default `staff`. Anything else\n\t * needs an adapter that narrows a query to one scope (`capabilities.scopedQueries`).\n\t */\n\ttenants?: SourcePolicy\n}\n\n/** Picks a tenant scope's default source by id; an id it cannot read leaves the default alone. */\nexport type DefaultSourceFunction = (args: {\n\treq: PayloadRequest\n\tscope: string\n\tsources: SourceRef[]\n}) => string | undefined | Promise<string | undefined>\n\n/**\n * A tenant scope's default source when no provider document of it is flagged the default:\n * `tenantFirst` its own first, `platformFirst` the `platformAdapter`, or a function.\n */\nexport type DefaultSourceRule = 'tenantFirst' | 'platformFirst' | DefaultSourceFunction\n\n/** `sources` and `defaultSource`, checked against the adapters they name. */\nexport interface ResolvedSources {\n\t/** Each config adapter whose tenants read under a policy other than `staff`. */\n\tpolicies: ReadonlyMap<string, Exclude<SourcePolicy, 'staff'>>\n\tdefaultSource?: DefaultSourceRule\n}\n\nconst SOURCE_KEYS = keysOf<AnalyticsSourceOptions>({ tenants: true })\nconst POLICY_NAMES: readonly string[] = ['staff', 'tenant', 'fallback']\nconst DEFAULT_RULES: readonly string[] = ['tenantFirst', 'platformFirst']\n\nconst isPolicy = (value: unknown): value is SourcePolicy =>\n\ttypeof value === 'function' || (typeof value === 'string' && POLICY_NAMES.includes(value))\n\nconst isDefaultRule = (value: unknown): value is DefaultSourceRule =>\n\ttypeof value === 'function' || (typeof value === 'string' && DEFAULT_RULES.includes(value))\n\nconst resolvePolicy = (\n\tid: string,\n\tentry: unknown,\n\tadapter: AnalyticsAdapter\n): Exclude<SourcePolicy, 'staff'> | undefined => {\n\tconst { tenants } = optionsObject(entry, {\n\t\tpath: `sources.${id}`,\n\t\tknown: SOURCE_KEYS,\n\t\texample: \"an object such as { tenants: 'fallback' }\",\n\t})\n\tif (tenants === undefined) {\n\t\treturn undefined\n\t}\n\tif (!isPolicy(tenants)) {\n\t\tthrow new Error(\n\t\t\t`analytics: sources.${id}.tenants must be 'staff', 'tenant', 'fallback' or a function, got ${kindOf(tenants)}`\n\t\t)\n\t}\n\tif (tenants === 'staff') {\n\t\treturn undefined\n\t}\n\tif (adapter.capabilities.scopedQueries !== true) {\n\t\tthrow new Error(\n\t\t\t`analytics: sources.${id}.tenants lets a tenant's own users read through the \"${id}\" adapter, which cannot narrow a query to one scope (it lacks capabilities.scopedQueries), so a tenant would read every tenant's totals. Leave it 'staff', or give it to an adapter that supports scoped queries.`\n\t\t)\n\t}\n\treturn tenants\n}\n\n/**\n * `sources` and `defaultSource`. A switched-off plugin given no adapters has nothing to check\n * the keys against, and reads through nothing anyway.\n */\nexport const resolveSources = (options: {\n\tadapters?: readonly AnalyticsAdapter[]\n\tplatformAdapter?: string\n\tsources?: unknown\n\tdefaultSource?: unknown\n}): ResolvedSources => {\n\tconst { sources, defaultSource } = options\n\tif (defaultSource !== undefined && !isDefaultRule(defaultSource)) {\n\t\tthrow new Error(\n\t\t\t`analytics: defaultSource must be 'tenantFirst', 'platformFirst' or a function, got ${kindOf(defaultSource)}`\n\t\t)\n\t}\n\tif (defaultSource === 'platformFirst' && options.platformAdapter === undefined) {\n\t\tthrow new Error(\n\t\t\t\"analytics: defaultSource 'platformFirst' opens each tenant on the platformAdapter, which is not set; set platformAdapter or pick another rule\"\n\t\t)\n\t}\n\tconst policies = new Map<string, Exclude<SourcePolicy, 'staff'>>()\n\tif (sources !== undefined && (!isRecord(sources) || Array.isArray(sources))) {\n\t\tthrow new Error(\n\t\t\t`analytics: sources must be an object keyed by adapter id, such as { posthog: { tenants: 'fallback' } }, got ${kindOf(sources)}`\n\t\t)\n\t}\n\tconst adapters = options.adapters ?? []\n\tif (adapters.length > 0) {\n\t\tfor (const [id, entry] of Object.entries(sources ?? {})) {\n\t\t\tif (entry === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst adapter = adapters.find((candidate) => candidate.id === id)\n\t\t\tif (!adapter) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`analytics: sources.${id} names no adapter in adapters, whose ids are ${listOf(adapters.map((known) => `\"${known.id}\"`))}; sources is keyed by the id of a config adapter`\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst policy = resolvePolicy(id, entry, adapter)\n\t\t\tif (policy !== undefined) {\n\t\t\t\tpolicies.set(id, policy)\n\t\t\t}\n\t\t}\n\t}\n\treturn { policies, ...(defaultSource === undefined ? {} : { defaultSource }) }\n}\n"],"mappings":";;;AAqEA,MAAM,cAAc,OAA+B,EAAE,SAAS,KAAK,CAAC;AACpE,MAAM,eAAkC;CAAC;CAAS;CAAU;AAAU;AACtE,MAAM,gBAAmC,CAAC,eAAe,eAAe;AAExE,MAAM,YAAY,UACjB,OAAO,UAAU,cAAe,OAAO,UAAU,YAAY,aAAa,SAAS,KAAK;AAEzF,MAAM,iBAAiB,UACtB,OAAO,UAAU,cAAe,OAAO,UAAU,YAAY,cAAc,SAAS,KAAK;AAE1F,MAAM,iBACL,IACA,OACA,YACgD;CAChD,MAAM,EAAE,YAAY,cAAc,OAAO;EACxC,MAAM,WAAW;EACjB,OAAO;EACP,SAAS;CACV,CAAC;CACD,IAAI,YAAY,KAAA,GACf;CAED,IAAI,CAAC,SAAS,OAAO,GACpB,MAAM,IAAI,MACT,sBAAsB,GAAG,oEAAoE,OAAO,OAAO,GAC5G;CAED,IAAI,YAAY,SACf;CAED,IAAI,QAAQ,aAAa,kBAAkB,MAC1C,MAAM,IAAI,MACT,sBAAsB,GAAG,uDAAuD,GAAG,kNACpF;CAED,OAAO;AACR;;;;;AAMA,MAAa,kBAAkB,YAKR;CACtB,MAAM,EAAE,SAAS,kBAAkB;CACnC,IAAI,kBAAkB,KAAA,KAAa,CAAC,cAAc,aAAa,GAC9D,MAAM,IAAI,MACT,sFAAsF,OAAO,aAAa,GAC3G;CAED,IAAI,kBAAkB,mBAAmB,QAAQ,oBAAoB,KAAA,GACpE,MAAM,IAAI,MACT,+IACD;CAED,MAAM,2BAAW,IAAI,IAA4C;CACjE,IAAI,YAAY,KAAA,MAAc,CAAC,SAAS,OAAO,KAAK,MAAM,QAAQ,OAAO,IACxE,MAAM,IAAI,MACT,+GAA+G,OAAO,OAAO,GAC9H;CAED,MAAM,WAAW,QAAQ,YAAY,CAAC;CACtC,IAAI,SAAS,SAAS,GACrB,KAAK,MAAM,CAAC,IAAI,UAAU,OAAO,QAAQ,WAAW,CAAC,CAAC,GAAG;EACxD,IAAI,UAAU,KAAA,GACb;EAED,MAAM,UAAU,SAAS,MAAM,cAAc,UAAU,OAAO,EAAE;EAChE,IAAI,CAAC,SACJ,MAAM,IAAI,MACT,sBAAsB,GAAG,+CAA+C,OAAO,SAAS,KAAK,UAAU,IAAI,MAAM,GAAG,EAAE,CAAC,EAAE,iDAC1H;EAED,MAAM,SAAS,cAAc,IAAI,OAAO,OAAO;EAC/C,IAAI,WAAW,KAAA,GACd,SAAS,IAAI,IAAI,MAAM;CAEzB;CAED,OAAO;EAAE;EAAU,GAAI,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc;CAAG;AAC9E"}
1
+ {"version":3,"file":"sourcePolicy.js","names":[],"sources":["../../src/core/sourcePolicy.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport type { AnalyticsAdapter } from './contract'\nimport { keysOf, optionsObject } from './optionChecks'\nimport { isRecord, kindOf, listOf } from './values'\n\n/** A source one scope reads through, as `defaultSource` is shown it. */\nexport interface SourceRef {\n\tid: string\n\tlabel: string\n\t/** `config` for an adapter every scope shares, `runtime` for one resolved per scope. */\n\tkind: 'config' | 'runtime'\n\t/** The provider document granting it to the scope; absent for a shared adapter none grants. */\n\tdocId?: string\n}\n\n/** A source the reader reads a scope through by one of that scope's own provider documents. */\nexport interface OwnSource {\n\tid: string\n\tlabel: string\n\tdocId: string\n\t/**\n\t * Whether the document's connection is failing, as the `fallback` policy reads it: refused, or a\n\t * vendor that did not answer while its reads rest. The statuses are read on the first call, once\n\t * per request, so a policy that never asks costs no read.\n\t */\n\tfailing(): Promise<boolean>\n}\n\n/**\n * Decides whether a member of `scope` reads it through the shared adapter `adapterId`. Asked at\n * most once per request, scope and adapter; a throw counts as no.\n */\nexport type SourcePolicyFunction = (args: {\n\treq: PayloadRequest\n\tscope: string\n\tadapterId: string\n\t/** Sources the reader already reads the scope through by its own provider documents. */\n\townSources: OwnSource[]\n}) => boolean | Promise<boolean>\n\n/**\n * Who besides `access.crossScope.unscopedSource` reads a tenant through a shared adapter: `staff`\n * nobody else, `tenant` the scope's members, `fallback` its members while they have no source of their own\n * that works.\n */\nexport type SourcePolicy = 'staff' | 'tenant' | 'fallback' | SourcePolicyFunction\n\n/** How tenants reach one shared config adapter. */\nexport interface AnalyticsSourceOptions {\n\t/**\n\t * Which of a tenant's own users read it, narrowed to their tenant. Default `staff`. Anything else\n\t * needs an adapter that narrows a query to one scope (`capabilities.scopedQueries`).\n\t */\n\ttenants?: SourcePolicy\n}\n\n/** Picks a tenant scope's default source by id; an id it cannot read leaves the default alone. */\nexport type DefaultSourceFunction = (args: {\n\treq: PayloadRequest\n\tscope: string\n\tsources: SourceRef[]\n}) => string | undefined | Promise<string | undefined>\n\n/**\n * A tenant scope's default source when no provider document of it is flagged the default:\n * `tenantFirst` its own first, `platformFirst` the `platformAdapter`, or a function.\n */\nexport type DefaultSourceRule = 'tenantFirst' | 'platformFirst' | DefaultSourceFunction\n\n/** `sources` and `defaultSource`, checked against the adapters they name. */\nexport interface ResolvedSources {\n\t/** Each config adapter whose tenants read under a policy other than `staff`. */\n\tpolicies: ReadonlyMap<string, Exclude<SourcePolicy, 'staff'>>\n\tdefaultSource?: DefaultSourceRule\n}\n\nconst SOURCE_KEYS = keysOf<AnalyticsSourceOptions>({ tenants: true })\nconst POLICY_NAMES: readonly string[] = ['staff', 'tenant', 'fallback']\nconst DEFAULT_RULES: readonly string[] = ['tenantFirst', 'platformFirst']\n\nconst isPolicy = (value: unknown): value is SourcePolicy =>\n\ttypeof value === 'function' || (typeof value === 'string' && POLICY_NAMES.includes(value))\n\nconst isDefaultRule = (value: unknown): value is DefaultSourceRule =>\n\ttypeof value === 'function' || (typeof value === 'string' && DEFAULT_RULES.includes(value))\n\nconst resolvePolicy = (\n\tid: string,\n\tentry: unknown,\n\tadapter: AnalyticsAdapter\n): Exclude<SourcePolicy, 'staff'> | undefined => {\n\tconst { tenants } = optionsObject(entry, {\n\t\tpath: `sources.${id}`,\n\t\tknown: SOURCE_KEYS,\n\t\texample: \"an object such as { tenants: 'fallback' }\",\n\t})\n\tif (tenants === undefined) {\n\t\treturn undefined\n\t}\n\tif (!isPolicy(tenants)) {\n\t\tthrow new Error(\n\t\t\t`analytics: sources.${id}.tenants must be 'staff', 'tenant', 'fallback' or a function, got ${kindOf(tenants)}`\n\t\t)\n\t}\n\tif (tenants === 'staff') {\n\t\treturn undefined\n\t}\n\tif (adapter.capabilities.scopedQueries !== true) {\n\t\tthrow new Error(\n\t\t\t`analytics: sources.${id}.tenants lets a tenant's own users read through the \"${id}\" adapter, which cannot narrow a query to one scope (it lacks capabilities.scopedQueries), so a tenant would read every tenant's totals. Leave it 'staff', or give it to an adapter that supports scoped queries.`\n\t\t)\n\t}\n\treturn tenants\n}\n\n/**\n * `sources` and `defaultSource`. A switched-off plugin given no adapters has nothing to check\n * the keys against, and reads through nothing anyway.\n */\nexport const resolveSources = (options: {\n\tadapters?: readonly AnalyticsAdapter[]\n\tplatformAdapter?: string\n\tsources?: unknown\n\tdefaultSource?: unknown\n}): ResolvedSources => {\n\tconst { sources, defaultSource } = options\n\tif (defaultSource !== undefined && !isDefaultRule(defaultSource)) {\n\t\tthrow new Error(\n\t\t\t`analytics: defaultSource must be 'tenantFirst', 'platformFirst' or a function, got ${kindOf(defaultSource)}`\n\t\t)\n\t}\n\tif (defaultSource === 'platformFirst' && options.platformAdapter === undefined) {\n\t\tthrow new Error(\n\t\t\t\"analytics: defaultSource 'platformFirst' opens each tenant on the platformAdapter, which is not set; set platformAdapter or pick another rule\"\n\t\t)\n\t}\n\tconst policies = new Map<string, Exclude<SourcePolicy, 'staff'>>()\n\tif (sources !== undefined && (!isRecord(sources) || Array.isArray(sources))) {\n\t\tthrow new Error(\n\t\t\t`analytics: sources must be an object keyed by adapter id, such as { posthog: { tenants: 'fallback' } }, got ${kindOf(sources)}`\n\t\t)\n\t}\n\tconst adapters = options.adapters ?? []\n\tif (adapters.length > 0) {\n\t\tfor (const [id, entry] of Object.entries(sources ?? {})) {\n\t\t\tif (entry === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst adapter = adapters.find((candidate) => candidate.id === id)\n\t\t\tif (!adapter) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`analytics: sources.${id} names no adapter in adapters, whose ids are ${listOf(adapters.map((known) => `\"${known.id}\"`))}; sources is keyed by the id of a config adapter`\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst policy = resolvePolicy(id, entry, adapter)\n\t\t\tif (policy !== undefined) {\n\t\t\t\tpolicies.set(id, policy)\n\t\t\t}\n\t\t}\n\t}\n\treturn { policies, ...(defaultSource === undefined ? {} : { defaultSource }) }\n}\n"],"mappings":";;;AA4EA,MAAM,cAAc,OAA+B,EAAE,SAAS,KAAK,CAAC;AACpE,MAAM,eAAkC;CAAC;CAAS;CAAU;AAAU;AACtE,MAAM,gBAAmC,CAAC,eAAe,eAAe;AAExE,MAAM,YAAY,UACjB,OAAO,UAAU,cAAe,OAAO,UAAU,YAAY,aAAa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,cAAc,IAAI,OAAO,OAAO;EAC/C,IAAI,WAAW,KAAA,GACd,SAAS,IAAI,IAAI,MAAM;CAEzB;CAED,OAAO;EAAE;EAAU,GAAI,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc;CAAG;AAC9E"}
@@ -1,4 +1,6 @@
1
1
  //#region src/core/throttle.ts
2
+ /** How often a failure that repeats on every read is logged: once a minute. */
3
+ const WARN_EVERY_MS = 6e4;
2
4
  /**
3
5
  * `say` limited to once per `intervalMs` on the `now` clock, so a failure repeating on every read
4
6
  * logs one line per interval rather than one per read.
@@ -13,6 +15,6 @@ const throttled = (say, clock) => {
13
15
  };
14
16
  };
15
17
  //#endregion
16
- export { throttled };
18
+ export { WARN_EVERY_MS, throttled };
17
19
 
18
20
  //# sourceMappingURL=throttle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"throttle.js","names":[],"sources":["../../src/core/throttle.ts"],"sourcesContent":["/**\n * `say` limited to once per `intervalMs` on the `now` clock, so a failure repeating on every read\n * logs one line per interval rather than one per read.\n */\nexport const throttled = (\n\tsay: (message: string) => void,\n\tclock: { now: () => number; intervalMs: number }\n): ((message: string) => void) => {\n\tlet saidAt: number | undefined\n\treturn (message) => {\n\t\tconst at = clock.now()\n\t\tif (saidAt !== undefined && at - saidAt < clock.intervalMs) {\n\t\t\treturn\n\t\t}\n\t\tsaidAt = at\n\t\tsay(message)\n\t}\n}\n"],"mappings":";;;;;AAIA,MAAa,aACZ,KACA,UACiC;CACjC,IAAI;CACJ,QAAQ,YAAY;EACnB,MAAM,KAAK,MAAM,IAAI;EACrB,IAAI,WAAW,KAAA,KAAa,KAAK,SAAS,MAAM,YAC/C;EAED,SAAS;EACT,IAAI,OAAO;CACZ;AACD"}
1
+ {"version":3,"file":"throttle.js","names":[],"sources":["../../src/core/throttle.ts"],"sourcesContent":["/** How often a failure that repeats on every read is logged: once a minute. */\nexport const WARN_EVERY_MS = 60_000\n\n/**\n * `say` limited to once per `intervalMs` on the `now` clock, so a failure repeating on every read\n * logs one line per interval rather than one per read.\n */\nexport const throttled = (\n\tsay: (message: string) => void,\n\tclock: { now: () => number; intervalMs: number }\n): ((message: string) => void) => {\n\tlet saidAt: number | undefined\n\treturn (message) => {\n\t\tconst at = clock.now()\n\t\tif (saidAt !== undefined && at - saidAt < clock.intervalMs) {\n\t\t\treturn\n\t\t}\n\t\tsaidAt = at\n\t\tsay(message)\n\t}\n}\n"],"mappings":";;AACA,MAAa,gBAAgB;;;;;AAM7B,MAAa,aACZ,KACA,UACiC;CACjC,IAAI;CACJ,QAAQ,YAAY;EACnB,MAAM,KAAK,MAAM,IAAI;EACrB,IAAI,WAAW,KAAA,KAAa,KAAK,SAAS,MAAM,YAC/C;EAED,SAAS;EACT,IAAI,OAAO;CACZ;AACD"}
@@ -11,5 +11,5 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
11
11
  import { HitMode, HitType } from "../../native/store/types.js";
12
12
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
14
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
14
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
15
15
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
@@ -12,7 +12,7 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
12
12
  import { HitMode, HitType } from "../../native/store/types.js";
13
13
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
14
14
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
15
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
15
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
16
16
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
17
17
  import { Ga4Config, ga4 } from "../../adapters/ga4/ga4.js";
18
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4Config, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, ga4, ga4EventName };
18
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4Config, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, ga4, ga4EventName };
@@ -16,7 +16,7 @@ import { HitMode, HitType } from "../../native/store/types.js";
16
16
  import { ItemSignatureMode } from "../../native/ingest/itemSignature.js";
17
17
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
18
18
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
19
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
19
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
20
20
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
21
21
  import { AGGREGATES_SLUG, HITS_SLUG } from "../../native/collections/slugs.js";
22
22
  import { RebuildDaysInput, RebuildDaysReport } from "../../native/engine/rebuild.js";
@@ -26,4 +26,4 @@ import { EventHostnameResolver, HostnameOption } from "../../native/ingest/resol
26
26
  import { SqliteThread } from "../../native/store/sql/sqliteThread.js";
27
27
  import { NativeAdapter, NativeCollections, NativeOptions, NativeRetention, NativeSqlite, NativeToday, NativeWithoutConsent, native } from "../../native/nativeAdapter.js";
28
28
  import { MAINTAIN_TASK_SLUG, MaintainTaskInput } from "../../native/tasks/maintainTask.js";
29
- export { AGGREGATES_SLUG, type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsCollectionOptions, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BotFilter, type BrowserAmounts, type CapKey, type CapsOption, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type CardinalityCaps, type CollectionOverrides, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type EventHostnameResolver, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Geo, type GeoResolver, type GeoResolverOptions, type Goal, type GoalMatch, type Granularity, HITS_SLUG, type HeldSlotMode, type HitMode, type HitType, type HostnameOption, type IngestHostnameResolver, type ItemSignatureMode, MAINTAIN_TASK_SLUG, type MaintainTaskInput, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type NativeAdapter, type NativeCollections, type NativeOptions, type NativeRetention, type NativeSqlite, type NativeToday, type NativeWithoutConsent, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RebuildDaysInput, type RebuildDaysReport, type RouteBase, type RoutePaths, SESSION_DIMENSIONS, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SessionDimension, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type SqliteThread, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, type WriteBufferLimits, type WriteBufferOption, isBot, native };
29
+ export { AGGREGATES_SLUG, type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsCollectionOptions, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BotFilter, type BrowserAmounts, type CapKey, type CapsOption, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type CardinalityCaps, type CollectionOverrides, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type EventHostnameResolver, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Geo, type GeoResolver, type GeoResolverOptions, type Goal, type GoalMatch, type Granularity, HITS_SLUG, type HeldSlotMode, type HitMode, type HitType, type HostnameOption, type IngestHostnameResolver, type ItemSignatureMode, MAINTAIN_TASK_SLUG, type MaintainTaskInput, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type NativeAdapter, type NativeCollections, type NativeOptions, type NativeRetention, type NativeSqlite, type NativeToday, type NativeWithoutConsent, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RebuildDaysInput, type RebuildDaysReport, type RouteBase, type RoutePaths, SESSION_DIMENSIONS, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SessionDimension, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type SqliteThread, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, type WriteBufferLimits, type WriteBufferOption, isBot, native };
@@ -11,7 +11,7 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
11
11
  import { HitMode, HitType } from "../../native/store/types.js";
12
12
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
14
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
14
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
15
15
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
16
16
  import { PlausibleConfig, plausible } from "../../adapters/plausible/plausible.js";
17
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type PlausibleConfig, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, plausible };
17
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type PlausibleConfig, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, plausible };
@@ -11,7 +11,7 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
11
11
  import { HitMode, HitType } from "../../native/store/types.js";
12
12
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
14
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
14
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
15
15
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
16
16
  import { PosthogConfig, posthog } from "../../adapters/posthog/posthog.js";
17
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type PosthogConfig, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, posthog };
17
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type PosthogConfig, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, posthog };
@@ -11,7 +11,7 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
11
11
  import { HitMode, HitType } from "../../native/store/types.js";
12
12
  import { RawEventInput } from "../../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../../core/serverEvent.js";
14
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
14
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../../core/contract.js";
15
15
  import { AdapterLabelOption } from "../../core/sourceLabel.js";
16
16
  import { UmamiConfig, umami } from "../../adapters/umami/umami.js";
17
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type UmamiConfig, type VisitorCounting, type WithoutConsentLevel, umami };
17
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type UmamiConfig, type VisitorCounting, type WithoutConsentLevel, umami };
@@ -24,6 +24,8 @@ import { GoalAmountFieldOptions } from "../goals/amountField.js";
24
24
  import { GoalsResponse, WireGoal } from "../goals/fetchGoals.js";
25
25
  import { GoalAmountField, GoalAmountFieldProps } from "../goals/GoalAmountField.js";
26
26
  import { AnalyticsGoals, useAnalyticsGoals } from "../goals/useAnalyticsGoals.js";
27
+ import { ProviderConnection } from "../providers/ProviderConnection.js";
28
+ import { ProviderConnectionTest } from "../providers/ProviderConnectionTest.js";
27
29
  import { ProvidersListNotice } from "../providers/ProvidersListNotice.js";
28
30
  import { QueryFetchError, RequestFailure } from "../ui/data/request.js";
29
31
  import { FetchQueryInit, QueryRequest, RefreshRequest, RefreshResponse, buildQueryUrl, fetchQuery, refreshCache } from "../query/fetchQuery.js";
@@ -46,4 +48,4 @@ import { ReadNotices } from "../widgets/readMeta.js";
46
48
  import { ReadonlyViewGate, ViewAnswers, ViewContextValue, ViewRefresh, useView } from "../view/viewContext.js";
47
49
  import { RealtimePoint } from "../widgets/readForWidgetRealtime.js";
48
50
  import { RealtimeCounter, RealtimeCounterProps } from "../widgets/RealtimeCounter.js";
49
- export { ANALYTICS_ERROR_CODES, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsFilter, type AnalyticsGoals, AnalyticsNavLink, type AnalyticsNavLinkProps, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSources, AnalyticsViewClient, type AnalyticsViewClientProps, type BarDatum, BarList, type BarListHeaders, type BarListProps, type BreakdownTab, type CapabilityRequirement, Card, type CardProps, type ChartDataRow, ChartDataTable, type ChartDataTableProps, type CountryFlagProps, type CountryFlags, DEFAULT_ROUTE_BASE, DIMENSION_KEYS, DataTable, type DataTableColumn, type DataTableProps, type DataTableRow, type DateRange, DateRangeField, type DateRangeFieldComponentProps, type DateRangeFieldOptions, type DateRangePickerAppearance, type DayRange, type DimensionKey, FILTER_OPERATORS, type FetchQueryInit, type FilterCapabilities, FilterDimensionSelectField, type FilterDimensionSelectFieldProps, type FilterOperator, FilterOperatorSelectField, type FilterOperatorSelectFieldProps, type FilterPair, FilterValueField, type FilterValueFieldProps, GoalAmountField, type GoalAmountFieldOptions, type GoalAmountFieldProps, GoalSelectField, type GoalSource, type GoalsResponse, type Granularity, type HostCountryFlag, type ItemLabels, MetricCard, type MetricCardProps, type MetricFormat, type MetricKey, MetricSelectField, type MetricSelectFieldProps, type MetricValue, type MetricValues, ProvidersListNotice, QueryFetchError, type QueryRequest, type QueryResponse, type QuerySourceRef, type QueryState, type ReadNotices, type ReadonlyViewGate, RealtimeCounter, type RealtimeCounterProps, type RealtimePoint, type RefreshRequest, type RefreshResponse, type RequestFailure, type RequestState, type RouteBase, type RoutePaths, type RoutesConfigSource, type SerializedAnalyticsQuery, type SerializedCapabilities, type SortDirection, type SourceErrorKind, SourceSelectField, type SourcesNotice, type SourcesResponse, TIMEFRAME_PRESETS, type TimeframePreset, Toolbar, TrendChart, type TrendChartProps, type TrendPoint, VIEW_LIMITS, type ViewAnswers, ViewBreakdowns, type ViewContextValue, type ViewEndpoints, type ViewGoal, ViewGoals, type ViewLimit, ViewOverview, type ViewQueries, ViewRealtime, type ViewRefresh, ViewRoot, type ViewRootProps, type ViewScopes, type ViewState, ViewTrend, type VisitorCounting, type WireGoal, type WireSource, analyticsRoutes, buildQueryUrl, fetchQuery, formatMetricValue, readErrorCode, readResponseError, refreshCache, routePaths, useAnalyticsGoals, useAnalyticsSources, useFilterCapabilities, useView };
51
+ export { ANALYTICS_ERROR_CODES, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsFilter, type AnalyticsGoals, AnalyticsNavLink, type AnalyticsNavLinkProps, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSources, AnalyticsViewClient, type AnalyticsViewClientProps, type BarDatum, BarList, type BarListHeaders, type BarListProps, type BreakdownTab, type CapabilityRequirement, Card, type CardProps, type ChartDataRow, ChartDataTable, type ChartDataTableProps, type CountryFlagProps, type CountryFlags, DEFAULT_ROUTE_BASE, DIMENSION_KEYS, DataTable, type DataTableColumn, type DataTableProps, type DataTableRow, type DateRange, DateRangeField, type DateRangeFieldComponentProps, type DateRangeFieldOptions, type DateRangePickerAppearance, type DayRange, type DimensionKey, FILTER_OPERATORS, type FetchQueryInit, type FilterCapabilities, FilterDimensionSelectField, type FilterDimensionSelectFieldProps, type FilterOperator, FilterOperatorSelectField, type FilterOperatorSelectFieldProps, type FilterPair, FilterValueField, type FilterValueFieldProps, GoalAmountField, type GoalAmountFieldOptions, type GoalAmountFieldProps, GoalSelectField, type GoalSource, type GoalsResponse, type Granularity, type HostCountryFlag, type ItemLabels, MetricCard, type MetricCardProps, type MetricFormat, type MetricKey, MetricSelectField, type MetricSelectFieldProps, type MetricValue, type MetricValues, ProviderConnection, ProviderConnectionTest, ProvidersListNotice, QueryFetchError, type QueryRequest, type QueryResponse, type QuerySourceRef, type QueryState, type ReadNotices, type ReadonlyViewGate, RealtimeCounter, type RealtimeCounterProps, type RealtimePoint, type RefreshRequest, type RefreshResponse, type RequestFailure, type RequestState, type RouteBase, type RoutePaths, type RoutesConfigSource, type SerializedAnalyticsQuery, type SerializedCapabilities, type SortDirection, type SourceErrorKind, SourceSelectField, type SourcesNotice, type SourcesResponse, TIMEFRAME_PRESETS, type TimeframePreset, Toolbar, TrendChart, type TrendChartProps, type TrendPoint, VIEW_LIMITS, type ViewAnswers, ViewBreakdowns, type ViewContextValue, type ViewEndpoints, type ViewGoal, ViewGoals, type ViewLimit, ViewOverview, type ViewQueries, ViewRealtime, type ViewRefresh, ViewRoot, type ViewRootProps, type ViewScopes, type ViewState, ViewTrend, type VisitorCounting, type WireGoal, type WireSource, analyticsRoutes, buildQueryUrl, fetchQuery, formatMetricValue, readErrorCode, readResponseError, refreshCache, routePaths, useAnalyticsGoals, useAnalyticsSources, useFilterCapabilities, useView };
@@ -17,6 +17,8 @@ import { FilterDimensionSelectField, FilterOperatorSelectField, GoalSelectField,
17
17
  import { DateRangeField } from "../fields/dateRange/ui.js";
18
18
  import { formatMetricValue } from "../fields/format.js";
19
19
  import { GoalAmountField } from "../goals/GoalAmountField.js";
20
+ import { ProviderConnection } from "../providers/ProviderConnection.js";
21
+ import { ProviderConnectionTest } from "../providers/ProviderConnectionTest.js";
20
22
  import { ProvidersListNotice } from "../providers/ProvidersListNotice.js";
21
23
  import { Card } from "../ui/components/Card.js";
22
24
  import { MetricCard } from "../ui/components/MetricCard.js";
@@ -28,4 +30,4 @@ import { ViewRoot } from "../view/ViewRoot.js";
28
30
  import { RealtimeCounter } from "../widgets/RealtimeCounter.js";
29
31
  import { ViewBreakdowns, ViewGoals, ViewOverview, ViewRealtime, ViewTrend } from "../view/ViewSections.js";
30
32
  import { AnalyticsViewClient } from "../view/AnalyticsViewClient.js";
31
- export { ANALYTICS_ERROR_CODES, AnalyticsNavLink, AnalyticsViewClient, BarList, Card, ChartDataTable, DEFAULT_ROUTE_BASE, DIMENSION_KEYS, DataTable, DateRangeField, FILTER_OPERATORS, FilterDimensionSelectField, FilterOperatorSelectField, FilterValueField, GoalAmountField, GoalSelectField, MetricCard, MetricSelectField, ProvidersListNotice, QueryFetchError, RealtimeCounter, SourceSelectField, TIMEFRAME_PRESETS, Toolbar, TrendChart, VIEW_LIMITS, ViewBreakdowns, ViewGoals, ViewOverview, ViewRealtime, ViewRoot, ViewTrend, analyticsRoutes, buildQueryUrl, fetchQuery, formatMetricValue, readErrorCode, readResponseError, refreshCache, routePaths, useAnalyticsGoals, useAnalyticsSources, useFilterCapabilities, useView };
33
+ export { ANALYTICS_ERROR_CODES, AnalyticsNavLink, AnalyticsViewClient, BarList, Card, ChartDataTable, DEFAULT_ROUTE_BASE, DIMENSION_KEYS, DataTable, DateRangeField, FILTER_OPERATORS, FilterDimensionSelectField, FilterOperatorSelectField, FilterValueField, GoalAmountField, GoalSelectField, MetricCard, MetricSelectField, ProviderConnection, ProviderConnectionTest, ProvidersListNotice, QueryFetchError, RealtimeCounter, SourceSelectField, TIMEFRAME_PRESETS, Toolbar, TrendChart, VIEW_LIMITS, ViewBreakdowns, ViewGoals, ViewOverview, ViewRealtime, ViewRoot, ViewTrend, analyticsRoutes, buildQueryUrl, fetchQuery, formatMetricValue, readErrorCode, readResponseError, refreshCache, routePaths, useAnalyticsGoals, useAnalyticsSources, useFilterCapabilities, useView };
@@ -11,11 +11,11 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
11
11
  import { HitMode, HitType } from "../native/store/types.js";
12
12
  import { RawEventInput } from "../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../core/serverEvent.js";
14
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
14
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
15
15
  import { AdapterLabelOption } from "../core/sourceLabel.js";
16
16
  import { CaptureRewrite, CaptureRewriteMount, captureRewrites } from "../next/captureRewrites.js";
17
17
  import { CaptureRouteOptions, captureRoute } from "../next/captureRoute.js";
18
18
  import { IngestRouteOptions } from "../native/ingest/route.js";
19
19
  import { ingestPreflight, ingestRoute } from "../next/ingestRoute.js";
20
20
  import { PosthogProxyRegion, PosthogProxyRewrite, PosthogProxyRewritesOptions, posthogProxyRewrites } from "../next/posthogProxyRewrites.js";
21
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureRewrite, type CaptureRewriteMount, type CaptureRouteOptions, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type IngestRouteOptions, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type PosthogProxyRegion, type PosthogProxyRewrite, type PosthogProxyRewritesOptions, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, captureRewrites, captureRoute, ingestPreflight, ingestRoute, posthogProxyRewrites };
21
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureRewrite, type CaptureRewriteMount, type CaptureRouteOptions, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type IngestRouteOptions, type MaxmindReader, type MaxmindSdk, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type PosthogProxyRegion, type PosthogProxyRewrite, type PosthogProxyRewritesOptions, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, captureRewrites, captureRoute, ingestPreflight, ingestRoute, posthogProxyRewrites };
@@ -11,8 +11,8 @@ import { AnalyticsSdks, Ga4Client, Ga4ClientOptions, Ga4ReportResponse, Ga4Repor
11
11
  import { HitMode, HitType } from "../native/store/types.js";
12
12
  import { RawEventInput } from "../native/ingest/normalizeEvent.js";
13
13
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../core/serverEvent.js";
14
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
14
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
15
15
  import { AdapterLabelOption } from "../core/sourceLabel.js";
16
16
  import { MemoryAnalyticsAdapter, MemoryEvent, memoryAdapter } from "../testing/memoryAdapter.js";
17
17
  import { settleAnalytics } from "../testing/settle.js";
18
- export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MemoryAnalyticsAdapter, type MemoryEvent, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, memoryAdapter, settleAnalytics };
18
+ export { type AdapterContext, type AdapterJobs, type AdapterLabelArgs, type AdapterLabelOption, type AdapterRegisterContext, type AdapterSchemaContext, type AnalyticsAdapter, type AnalyticsCapabilities, type AnalyticsFilter, type AnalyticsQuery, type AnalyticsResult, type AnalyticsRow, type AnalyticsSdks, type AnalyticsTaskName, type BrowserAmounts, type CaptureClientKind, type CaptureSlot, type CaptureSnippet, type CaptureSupport, type ConnectionCheckContext, type ConsentPhase, type CookielessSupport, type CurrencyConverter, type DIMENSION_KEYS, type DateRange, type DimensionKey, type FILTER_OPERATORS, type FetchInit, type FetchLike, type FilterOperator, type FilterOperatorMap, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalMatch, type Granularity, type HeldSlotMode, type HitMode, type HitType, type IngestHostnameResolver, type MaxmindReader, type MaxmindSdk, type MemoryAnalyticsAdapter, type MemoryEvent, type MetricKey, type MetricReach, type MetricSemantics, type MetricValue, type MetricValues, type OrderSignatureMode, type ProxyDescriptor, type ProxyRoute, type ProxyRouteKind, type RateLimitDescriptor, type RawEventInput, type RouteBase, type RoutePaths, type ScheduledTask, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SlotMode, type SlotWithoutConsent, type SnippetArgs, type SnippetMode, type SnippetScript, type SourceErrorKind, type TASK_NAMES, type TrackerGoal, type TrackerSlotConfig, type TrustedPlatform, type VisitorCounting, type WithoutConsentLevel, memoryAdapter, settleAnalytics };
@@ -13,7 +13,7 @@ import { HitMode, HitType } from "../native/store/types.js";
13
13
  import { GOAL_ACTION_TYPE } from "../goals/constants.js";
14
14
  import { RawEventInput } from "../native/ingest/normalizeEvent.js";
15
15
  import { IngestHostnameResolver, ServerEventInput, ServerTrack, ServerTrackIdentity, ServerTrackOptions } from "../core/serverEvent.js";
16
- import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsAdapterFactory, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, PLATFORM_SCOPE, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
16
+ import { AdapterContext, AdapterLabelArgs, AdapterRegisterContext, AdapterSchemaContext, AnalyticsAdapter, AnalyticsAdapterFactory, AnalyticsCapabilities, AnalyticsFilter, AnalyticsQuery, AnalyticsResult, AnalyticsRow, ConnectionCheckContext, DIMENSION_KEYS, DateRange, DimensionKey, FILTER_OPERATORS, FilterOperator, FilterOperatorMap, Granularity, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, PLATFORM_SCOPE, RateLimitDescriptor, SourceErrorKind, VisitorCounting } from "../core/contract.js";
17
17
  import { AnalyticsSourceOptions, DefaultSourceFunction, DefaultSourceRule, OwnSource, SourcePolicy, SourcePolicyFunction, SourceRef } from "../core/sourcePolicy.js";
18
18
  import { AdapterLabelOption } from "../core/sourceLabel.js";
19
19
  import { CapabilityRequirement, FilterPair, SerializedCapabilities } from "../core/capabilities.js";
@@ -26,7 +26,7 @@ import { PluralCategory, PluralName, PluralVariant, SingularKey, TranslationKey,
26
26
  import { TranslationsOption } from "../translations/index.js";
27
27
  import { GoalCollectionFieldOverrides, GoalFieldOverride } from "../goals/collection.js";
28
28
  import { HostPattern, ProviderHostPolicy } from "../providers/hosts.js";
29
- import { ProviderId } from "../providers/factory.js";
29
+ import { ProviderId } from "../providers/ids.js";
30
30
  import { ConnectionAccess, ConnectionFieldAccess, ProviderCollectionFieldOverrides, ProviderFieldOverride } from "../providers/collection.js";
31
31
  import { AfterReadAnswer, AfterReadArgs, AfterReadHook, ReadOrigin } from "../surfacing/afterRead.js";
32
32
  import { TIMEFRAME_PRESETS, TimeframePreset } from "../timeframe/presets.js";
@@ -47,4 +47,4 @@ import { GoalActionDefinition, GoalActionRunArgs, TrackGoalActionOptions } from
47
47
  import { TRAFFIC_CHANNELS, TrafficChannel } from "../native/ingest/source.js";
48
48
  import { ParseResult, ParsedQuery } from "../query/parse.js";
49
49
  import { ExclusionResponse, ExclusionSite } from "../view/exclusionLink.js";
50
- export { ANALYTICS_ERROR_CODES, AdapterContext, type AdapterJobs, AdapterLabelArgs, type AdapterLabelOption, AdapterRegisterContext, AdapterSchemaContext, type AdminDigest, type AfterReadAnswer, type AfterReadArgs, type AfterReadHook, type AnalyticsAccessOptions, AnalyticsAdapter, AnalyticsAdapterFactory, type AnalyticsBinding, type AnalyticsCacheCollectionOptions, type AnalyticsCacheOptions, AnalyticsCapabilities, type AnalyticsCaptureOptions, type AnalyticsCollectionOptions, type AnalyticsComponent, type AnalyticsConcurrencyOptions, type AnalyticsCountryFlags, type AnalyticsCrossScopeOptions, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsExclusionOptions, type AnalyticsFieldsOptions, AnalyticsFilter, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsHooksOptions, type AnalyticsJobsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, AnalyticsQuery, type AnalyticsReadAccess, AnalyticsResult, type AnalyticsRevenueOptions, type AnalyticsRoutesOptions, AnalyticsRow, type AnalyticsScopeOptions, type AnalyticsSdks, type AnalyticsSourceOptions, type AnalyticsStatBaseOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsSyncCollectionOptions, type AnalyticsSyncOptions, type AnalyticsTabOptions, type AnalyticsTaskName, type AnalyticsTaskOptions, type AnalyticsViewAccess, type AnalyticsViewClientProps, type AnalyticsViewOptions, type AnalyticsWarmOptions, type AnalyticsWidgetOverride, type AnalyticsWidgetOverrides, type AnalyticsWidgetsOptions, type AutoCaptureOptions, BUILT_IN_WIDGET_SLUGS, type BindingContext, type BindingDoc, type BrowserAmounts, type BuiltInWidgetSlug, type CacheEntry, type CacheSetOptions, type CacheStore, type CapabilityRequirement, type CaptureClientKind, type CaptureGate, type CaptureGateArgs, type CaptureSlot, type CaptureSlotOption, type CaptureSnippet, CaptureSupport, type CollectionFieldOverride, type CollectionOverrides, type ConnectionAccess, type ConnectionFieldAccess, type ConsentPhase, CookielessSupport, type CountryFlagProps, type CountryFlags, type CrossScopeAccess, type CurrencyConverter, type CurrencyResolver, type CustomWidgetDef, DIMENSION_KEYS, DateRange, type DefaultSourceFunction, type DefaultSourceRule, DimensionKey, type ExclusionResponse, type ExclusionSite, type ExclusionSitesResolver, FILTER_OPERATORS, type FetchInit, type FetchLike, type FetchQueryInit, FilterOperator, FilterOperatorMap, type FilterPair, GOAL_ACTION_TYPE, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalCollectionFieldOverrides, type GoalFieldOptions, type GoalFieldOverride, type GoalMatch, Granularity, type HeldSlotMode, type HitMode, type HitType, type HostCountryFlag, type HostPattern, type HostnameResolver, type IngestHostnameResolver, type ItemCaptureOptions, type ItemLabels, type MaxmindReader, type MaxmindSdk, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, type OrderSignatureMode, type OwnSource, PLATFORM_SCOPE, type ParseResult, type ParsedQuery, type PathResolver, type PluralCategory, type PluralName, type PluralVariant, type ProviderCollectionFieldOverrides, type ProviderFieldOverride, type ProviderHostPolicy, type ProviderHostsOptions, type ProviderId, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ProvidersResolveArgs, ProxyDescriptor, ProxyRoute, ProxyRouteKind, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryRequest, type QueryResponse, type QuerySourceRef, RateLimitDescriptor, type RawEventInput, type ReadOrigin, type ReadRecipe, type RecipeWindow, type RefreshRequest, type RefreshResponse, type ReportMode, type ReportOption, type ResolvedAutoCapture, type ResolvedItemCapture, type RouteBase, type RoutePaths, type ScheduledTask, type ScopeCallSite, type ScopeLabelResolver, type ScopeListResolver, type ScopeMemberAccess, type ScopeResolver, type SerializedAnalyticsQuery, type SerializedCapabilities, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SingularKey, type SlotMode, type SlotWithoutConsent, SnippetArgs, SnippetMode, type SnippetScript, SourceErrorKind, type SourcePolicy, type SourcePolicyFunction, type SourceRef, type SourcesNotice, type SourcesResponse, type TASK_NAMES, TIMEFRAME_PRESETS, TRAFFIC_CHANNELS, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerConfig, type TrackerExclusion, type TrackerGoal, type TrackerSkip, type TrackerSlotConfig, type TrafficChannel, type TranslationKey, type TranslationsOption, type TrustedPlatform, type ViewEndpoints, type ViewGoal, type ViewScopes, VisitorCounting, type WidgetView, type WidgetViewProps, type WireSource, type WithoutConsentArgs, type WithoutConsentFunction, type WithoutConsentLevel, type WithoutConsentOption, keys, pluralKeys, readErrorCode };
50
+ export { ANALYTICS_ERROR_CODES, AdapterContext, type AdapterJobs, AdapterLabelArgs, type AdapterLabelOption, AdapterRegisterContext, AdapterSchemaContext, type AdminDigest, type AfterReadAnswer, type AfterReadArgs, type AfterReadHook, type AnalyticsAccessOptions, AnalyticsAdapter, AnalyticsAdapterFactory, type AnalyticsBinding, type AnalyticsCacheCollectionOptions, type AnalyticsCacheOptions, AnalyticsCapabilities, type AnalyticsCaptureOptions, type AnalyticsCollectionOptions, type AnalyticsComponent, type AnalyticsConcurrencyOptions, type AnalyticsCountryFlags, type AnalyticsCrossScopeOptions, type AnalyticsError, type AnalyticsErrorCode, type AnalyticsExclusionOptions, type AnalyticsFieldsOptions, AnalyticsFilter, type AnalyticsGoalsCollectionOptions, type AnalyticsGoalsOptions, type AnalyticsHooksOptions, type AnalyticsJobsOptions, type AnalyticsMetricLabel, type AnalyticsMetricLabels, type AnalyticsPluginOptions, AnalyticsQuery, type AnalyticsReadAccess, AnalyticsResult, type AnalyticsRevenueOptions, type AnalyticsRoutesOptions, AnalyticsRow, type AnalyticsScopeOptions, type AnalyticsSdks, type AnalyticsSourceOptions, type AnalyticsStatBaseOptions, type AnalyticsStatOptions, type AnalyticsStatRowOptions, type AnalyticsSyncCollectionOptions, type AnalyticsSyncOptions, type AnalyticsTabOptions, type AnalyticsTaskName, type AnalyticsTaskOptions, type AnalyticsViewAccess, type AnalyticsViewClientProps, type AnalyticsViewOptions, type AnalyticsWarmOptions, type AnalyticsWidgetOverride, type AnalyticsWidgetOverrides, type AnalyticsWidgetsOptions, type AutoCaptureOptions, BUILT_IN_WIDGET_SLUGS, type BindingContext, type BindingDoc, type BrowserAmounts, type BuiltInWidgetSlug, type CacheEntry, type CacheSetOptions, type CacheStore, type CapabilityRequirement, type CaptureClientKind, type CaptureGate, type CaptureGateArgs, type CaptureSlot, type CaptureSlotOption, type CaptureSnippet, CaptureSupport, type CollectionFieldOverride, type CollectionOverrides, type ConnectionAccess, ConnectionCheckContext, type ConnectionFieldAccess, type ConsentPhase, CookielessSupport, type CountryFlagProps, type CountryFlags, type CrossScopeAccess, type CurrencyConverter, type CurrencyResolver, type CustomWidgetDef, DIMENSION_KEYS, DateRange, type DefaultSourceFunction, type DefaultSourceRule, DimensionKey, type ExclusionResponse, type ExclusionSite, type ExclusionSitesResolver, FILTER_OPERATORS, type FetchInit, type FetchLike, type FetchQueryInit, FilterOperator, FilterOperatorMap, type FilterPair, GOAL_ACTION_TYPE, type Ga4Client, type Ga4ClientOptions, type Ga4ReportResponse, type Ga4ReportRow, type Ga4Sdk, type Goal, type GoalActionDefinition, type GoalActionRunArgs, type GoalCollectionFieldOverrides, type GoalFieldOptions, type GoalFieldOverride, type GoalMatch, Granularity, type HeldSlotMode, type HitMode, type HitType, type HostCountryFlag, type HostPattern, type HostnameResolver, type IngestHostnameResolver, type ItemCaptureOptions, type ItemLabels, type MaxmindReader, type MaxmindSdk, MetricKey, MetricReach, MetricSemantics, MetricValue, MetricValues, type OrderSignatureMode, type OwnSource, PLATFORM_SCOPE, type ParseResult, type ParsedQuery, type PathResolver, type PluralCategory, type PluralName, type PluralVariant, type ProviderCollectionFieldOverrides, type ProviderFieldOverride, type ProviderHostPolicy, type ProviderHostsOptions, type ProviderId, type ProvidersCollectionOptions, type ProvidersOptions, type ProvidersResolve, type ProvidersResolveArgs, ProxyDescriptor, ProxyRoute, ProxyRouteKind, type QueryError, type QueryErrorCode, type QueryErrorResponse, type QueryRequest, type QueryResponse, type QuerySourceRef, RateLimitDescriptor, type RawEventInput, type ReadOrigin, type ReadRecipe, type RecipeWindow, type RefreshRequest, type RefreshResponse, type ReportMode, type ReportOption, type ResolvedAutoCapture, type ResolvedItemCapture, type RouteBase, type RoutePaths, type ScheduledTask, type ScopeCallSite, type ScopeLabelResolver, type ScopeListResolver, type ScopeMemberAccess, type ScopeResolver, type SerializedAnalyticsQuery, type SerializedCapabilities, type ServerEventInput, type ServerTrack, type ServerTrackIdentity, type ServerTrackOptions, type SingularKey, type SlotMode, type SlotWithoutConsent, SnippetArgs, SnippetMode, type SnippetScript, SourceErrorKind, type SourcePolicy, type SourcePolicyFunction, type SourceRef, type SourcesNotice, type SourcesResponse, type TASK_NAMES, TIMEFRAME_PRESETS, TRAFFIC_CHANNELS, type TimeframePreset, type TimezoneResolver, type TrackGoalActionOptions, type TrackerConfig, type TrackerExclusion, type TrackerGoal, type TrackerSkip, type TrackerSlotConfig, type TrafficChannel, type TranslationKey, type TranslationsOption, type TrustedPlatform, type ViewEndpoints, type ViewGoal, type ViewScopes, VisitorCounting, type WidgetView, type WidgetViewProps, type WireSource, type WithoutConsentArgs, type WithoutConsentFunction, type WithoutConsentLevel, type WithoutConsentOption, keys, pluralKeys, readErrorCode };
@@ -5,7 +5,7 @@ import { requestShaped } from "../../ui/data/request.js";
5
5
  const isStringList = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
6
6
  /** The parts of a source the pickers read: who it is and the lists its capabilities gate on. */
7
7
  const isWireSource = (value) => isRecord(value) && typeof value.id === "string" && typeof value.label === "string" && (value.kind === "config" || value.kind === "runtime") && isRecord(value.capabilities) && isStringList(value.capabilities.metrics) && isStringList(value.capabilities.dimensions) && isRecord(value.capabilities.filters);
8
- const isSourcesResponse = (value) => isRecord(value) && (value.defaultId === null || typeof value.defaultId === "string") && (value.notice === void 0 || value.notice === "platformFallback") && Array.isArray(value.sources) && value.sources.every(isWireSource);
8
+ const isSourcesResponse = (value) => isRecord(value) && (value.defaultId === null || typeof value.defaultId === "string") && (value.notice === void 0 || value.notice === "platformFallback" || value.notice === "ownSourceFailing") && Array.isArray(value.sources) && value.sources.every(isWireSource);
9
9
  /** The listing read fresh, past the shared cache, for a surface that must not show a stale one. */
10
10
  const requestSources = (url, signal) => requestShaped(url, isSourcesResponse, { signal });
11
11
  const cache = createSharedCache();
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSources.js","names":[],"sources":["../../../src/fields/config/fetchSources.ts"],"sourcesContent":["import type { SerializedCapabilities } from '../../core/capabilities'\nimport { isRecord } from '../../core/values'\nimport type { SourcesNotice } from '../../plugin/readContextForRequest'\nimport { requestShaped } from '../../ui/data/request'\nimport { createSharedCache } from '../../ui/data/sharedCache'\n\nexport interface WireSource {\n\tid: string\n\tlabel: string\n\tkind: 'config' | 'runtime'\n\tcapabilities: SerializedCapabilities\n}\n\nexport type { SourcesNotice }\n\nexport interface SourcesResponse {\n\tdefaultId: string | null\n\tsources: WireSource[]\n\t/** What the reader should be told about the listing itself; absent, nothing. */\n\tnotice?: SourcesNotice\n}\n\nconst isStringList = (value: unknown): value is string[] =>\n\tArray.isArray(value) && value.every((entry) => typeof entry === 'string')\n\n/** The parts of a source the pickers read: who it is and the lists its capabilities gate on. */\nconst isWireSource = (value: unknown): value is WireSource =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\ttypeof value.label === 'string' &&\n\t(value.kind === 'config' || value.kind === 'runtime') &&\n\tisRecord(value.capabilities) &&\n\tisStringList(value.capabilities.metrics) &&\n\tisStringList(value.capabilities.dimensions) &&\n\tisRecord(value.capabilities.filters)\n\nconst isSourcesResponse = (value: unknown): value is SourcesResponse =>\n\tisRecord(value) &&\n\t(value.defaultId === null || typeof value.defaultId === 'string') &&\n\t(value.notice === undefined || value.notice === 'platformFallback') &&\n\tArray.isArray(value.sources) &&\n\tvalue.sources.every(isWireSource)\n\n/** The listing read fresh, past the shared cache, for a surface that must not show a stale one. */\nexport const requestSources = (url: string, signal?: AbortSignal): Promise<SourcesResponse> =>\n\trequestShaped(url, isSourcesResponse, { signal })\n\nconst cache = createSharedCache<SourcesResponse>()\n\n/**\n * Source list shared by every picker on the page, keyed by scope so a login or tenant switch reads\n * again. A refusal or misshapen answer rejects and drops the entry, so a later mount retries.\n */\nexport const fetchSources = (url: string, scope: string): Promise<SourcesResponse> =>\n\tcache.read({ route: url, scope }, () => requestSources(url))\n"],"mappings":";;;;AAsBA,MAAM,gBAAgB,UACrB,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,UAAU,OAAO,UAAU,QAAQ;;AAGzE,MAAM,gBAAgB,UACrB,SAAS,KAAK,KACd,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,UAAU,aACtB,MAAM,SAAS,YAAY,MAAM,SAAS,cAC3C,SAAS,MAAM,YAAY,KAC3B,aAAa,MAAM,aAAa,OAAO,KACvC,aAAa,MAAM,aAAa,UAAU,KAC1C,SAAS,MAAM,aAAa,OAAO;AAEpC,MAAM,qBAAqB,UAC1B,SAAS,KAAK,MACb,MAAM,cAAc,QAAQ,OAAO,MAAM,cAAc,cACvD,MAAM,WAAW,KAAA,KAAa,MAAM,WAAW,uBAChD,MAAM,QAAQ,MAAM,OAAO,KAC3B,MAAM,QAAQ,MAAM,YAAY;;AAGjC,MAAa,kBAAkB,KAAa,WAC3C,cAAc,KAAK,mBAAmB,EAAE,OAAO,CAAC;AAEjD,MAAM,QAAQ,kBAAmC;;;;;AAMjD,MAAa,gBAAgB,KAAa,UACzC,MAAM,KAAK;CAAE,OAAO;CAAK;AAAM,SAAS,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"fetchSources.js","names":[],"sources":["../../../src/fields/config/fetchSources.ts"],"sourcesContent":["import type { SerializedCapabilities } from '../../core/capabilities'\nimport { isRecord } from '../../core/values'\nimport type { SourcesNotice } from '../../plugin/readContextForRequest'\nimport { requestShaped } from '../../ui/data/request'\nimport { createSharedCache } from '../../ui/data/sharedCache'\n\nexport interface WireSource {\n\tid: string\n\tlabel: string\n\tkind: 'config' | 'runtime'\n\tcapabilities: SerializedCapabilities\n}\n\nexport type { SourcesNotice }\n\nexport interface SourcesResponse {\n\tdefaultId: string | null\n\tsources: WireSource[]\n\t/** What the reader should be told about the listing itself; absent, nothing. */\n\tnotice?: SourcesNotice\n}\n\nconst isStringList = (value: unknown): value is string[] =>\n\tArray.isArray(value) && value.every((entry) => typeof entry === 'string')\n\n/** The parts of a source the pickers read: who it is and the lists its capabilities gate on. */\nconst isWireSource = (value: unknown): value is WireSource =>\n\tisRecord(value) &&\n\ttypeof value.id === 'string' &&\n\ttypeof value.label === 'string' &&\n\t(value.kind === 'config' || value.kind === 'runtime') &&\n\tisRecord(value.capabilities) &&\n\tisStringList(value.capabilities.metrics) &&\n\tisStringList(value.capabilities.dimensions) &&\n\tisRecord(value.capabilities.filters)\n\nconst isSourcesResponse = (value: unknown): value is SourcesResponse =>\n\tisRecord(value) &&\n\t(value.defaultId === null || typeof value.defaultId === 'string') &&\n\t(value.notice === undefined ||\n\t\tvalue.notice === 'platformFallback' ||\n\t\tvalue.notice === 'ownSourceFailing') &&\n\tArray.isArray(value.sources) &&\n\tvalue.sources.every(isWireSource)\n\n/** The listing read fresh, past the shared cache, for a surface that must not show a stale one. */\nexport const requestSources = (url: string, signal?: AbortSignal): Promise<SourcesResponse> =>\n\trequestShaped(url, isSourcesResponse, { signal })\n\nconst cache = createSharedCache<SourcesResponse>()\n\n/**\n * Source list shared by every picker on the page, keyed by scope so a login or tenant switch reads\n * again. A refusal or misshapen answer rejects and drops the entry, so a later mount retries.\n */\nexport const fetchSources = (url: string, scope: string): Promise<SourcesResponse> =>\n\tcache.read({ route: url, scope }, () => requestSources(url))\n"],"mappings":";;;;AAsBA,MAAM,gBAAgB,UACrB,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,UAAU,OAAO,UAAU,QAAQ;;AAGzE,MAAM,gBAAgB,UACrB,SAAS,KAAK,KACd,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,UAAU,aACtB,MAAM,SAAS,YAAY,MAAM,SAAS,cAC3C,SAAS,MAAM,YAAY,KAC3B,aAAa,MAAM,aAAa,OAAO,KACvC,aAAa,MAAM,aAAa,UAAU,KAC1C,SAAS,MAAM,aAAa,OAAO;AAEpC,MAAM,qBAAqB,UAC1B,SAAS,KAAK,MACb,MAAM,cAAc,QAAQ,OAAO,MAAM,cAAc,cACvD,MAAM,WAAW,KAAA,KACjB,MAAM,WAAW,sBACjB,MAAM,WAAW,uBAClB,MAAM,QAAQ,MAAM,OAAO,KAC3B,MAAM,QAAQ,MAAM,YAAY;;AAGjC,MAAa,kBAAkB,KAAa,WAC3C,cAAc,KAAK,mBAAmB,EAAE,OAAO,CAAC;AAEjD,MAAM,QAAQ,kBAAmC;;;;;AAMjD,MAAa,gBAAgB,KAAa,UACzC,MAAM,KAAK;CAAE,OAAO;CAAK;AAAM,SAAS,eAAe,GAAG,CAAC"}
@@ -27,8 +27,9 @@ const slugError = (collection, req, key) => new ValidationError({
27
27
  label: labelForKey(keys.goalFieldSlug),
28
28
  message: asTranslate(req.t)(key),
29
29
  path: "slug"
30
- }]
31
- });
30
+ }],
31
+ req
32
+ }, req.t);
32
33
  /**
33
34
  * Slug shape and per-scope uniqueness at collection level, so a replaced slug field without its own
34
35
  * `validate` keeps them; the index cannot cover install-wide Postgres rows or host scope fields.
@@ -1 +1 @@
1
- {"version":3,"file":"collection.js","names":[],"sources":["../../src/goals/collection.ts"],"sourcesContent":["import type {\n\tCollectionBeforeValidateHook,\n\tCollectionConfig,\n\tCompoundIndex,\n\tField,\n\tPayloadRequest,\n\tTextFieldSingleValidation,\n} from 'payload'\nimport { ValidationError } from 'payload'\nimport { valueAt } from '../core/values'\nimport {\n\ttype CollectionFieldOverride,\n\thasNamedField,\n\toverrideField,\n\tpairInRow,\n} from '../plugin/collectionFields'\nimport { docScope, type ScopeChange } from '../plugin/scopeChange'\nimport type { ProviderAccessArgs } from '../providers/access'\nimport { providerCreateAccess, providerRowAccess } from '../providers/access'\nimport { takenInScope } from '../providers/scopeUnique'\nimport { stampScope } from '../providers/stampScope'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { asTranslate, labelForKey } from '../translations/server'\nimport { builtInStaticLabel, type StaticLabelFor } from '../translations/staticLabel'\nimport { amountField } from './amountField'\nimport { type AmountOf, amountCurrencyField } from './currency'\nimport { hiddenAdmin } from './moneyFields'\nimport { MAX_PATTERN_GLOBSTARS, MAX_PATTERN_SEGMENTS, patternProblem } from './pathMatch'\nimport { GOAL_SLUG_PATTERN } from './types'\n\nexport const GOALS_SLUG = 'analytics-goals'\n\n/**\n * Replaces one default field, receiving the plugin's own to spread. Any field type may come back, a\n * `row` included, as long as the slug override still holds a field named `slug`.\n */\nexport type GoalFieldOverride = CollectionFieldOverride\n\nexport interface GoalCollectionFieldOverrides {\n\tname?: GoalFieldOverride\n\tslug?: GoalFieldOverride\n\tenabled?: GoalFieldOverride\n\tbrowser?: GoalFieldOverride\n\tmatch?: GoalFieldOverride\n\tvalue?: GoalFieldOverride\n\tcurrency?: GoalFieldOverride\n}\n\nexport interface BuildGoalsCollectionArgs extends ProviderAccessArgs {\n\tslug: string\n\taccess?: Partial<CollectionConfig['access']>\n\t/** Per-field overrides, applied before the whole-collection `overrides`. */\n\tfields?: GoalCollectionFieldOverrides\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t/**\n\t * Whether the install measures money, default on. False hides the amount and currency rather than\n\t * removing them, so existing amounts survive and show again when it is turned back on.\n\t */\n\trevenue?: boolean\n\t/**\n\t * The install's reporting currency when it is one fixed code. The Amount control fills it\n\t * in once an amount is set on a goal that has no currency yet.\n\t */\n\tdefaultCurrency?: string\n\t/**\n\t * Called after any change or delete with the scopes the write touched and the request that\n\t * wrote, so that request's own Payload instance reads those scopes again once the write commits.\n\t */\n\tonChange: (change: ScopeChange, req: PayloadRequest) => void | Promise<void>\n\t/** The install's static labels; the built-in strings alone when absent. */\n\tstaticLabel?: StaticLabelFor\n}\n\nconst validateSlug: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && GOAL_SLUG_PATTERN.test(value)\n\t\t? true\n\t\t: asTranslate(req.t)(keys.goalErrorSlug)\n\n/** The matcher's caps, refused here so an editor hears about them rather than a goal never matching. */\nconst validatePattern: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && patternProblem(value) !== null\n\t\t? asTranslate(req.t)(keys.goalErrorPatternLimits, {\n\t\t\t\tsegments: MAX_PATTERN_SEGMENTS,\n\t\t\t\tglobstars: MAX_PATTERN_GLOBSTARS,\n\t\t\t})\n\t\t: true\n\nconst slugError = (collection: string, req: PayloadRequest, key: TranslationKey) =>\n\tnew ValidationError({\n\t\tcollection,\n\t\terrors: [\n\t\t\t{\n\t\t\t\tlabel: labelForKey(keys.goalFieldSlug),\n\t\t\t\tmessage: asTranslate(req.t)(key),\n\t\t\t\tpath: 'slug',\n\t\t\t},\n\t\t],\n\t})\n\n/**\n * Slug shape and per-scope uniqueness at collection level, so a replaced slug field without its own\n * `validate` keeps them; the index cannot cover install-wide Postgres rows or host scope fields.\n */\nconst checkSlug = (args: BuildGoalsCollectionArgs): CollectionBeforeValidateHook => {\n\treturn async ({ data, originalDoc, req }) => {\n\t\tconst slug = data?.slug\n\t\tif (typeof slug !== 'string' || slug === '') {\n\t\t\treturn data\n\t\t}\n\t\tif (!GOAL_SLUG_PATTERN.test(slug)) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlug)\n\t\t}\n\t\tif (await takenInScope(args, { data, originalDoc, req }, { slug: { equals: slug } })) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlugTaken)\n\t\t}\n\t\treturn data\n\t}\n}\n\n/**\n * Database backstop for the hook, only where the plugin owns the scope field. Postgres treats a NULL\n * scope as distinct, so install-wide rows stay hook-guarded.\n */\nconst uniqueSlugIndex = (args: BuildGoalsCollectionArgs): CompoundIndex | undefined => {\n\tif (!args.scoped) {\n\t\treturn { fields: ['slug'], unique: true }\n\t}\n\treturn args.scopeField === 'scope' ? { fields: ['slug', 'scope'], unique: true } : undefined\n}\n\n/**\n * The plugin's scope field, only while `scopeField` names it: a host-owned field is the host's to\n * register, and a hidden twin would store the scope twice.\n */\nconst scopeField = (args: BuildGoalsCollectionArgs): Field[] =>\n\targs.scopeField === 'scope'\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\t// Written by scoped setups; hidden because single-site installs never touch it.\n\t\t\t\t\tname: 'scope',\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tindex: true,\n\t\t\t\t\tlabel: labelForKey(keys.providerFieldScope),\n\t\t\t\t\tadmin: { hidden: true },\n\t\t\t\t},\n\t\t\t]\n\t\t: []\n\nconst nameField = (): Field => ({\n\tname: 'name',\n\ttype: 'text',\n\trequired: true,\n\tlabel: labelForKey(keys.goalFieldName),\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldNameHelp) },\n})\n\nconst slugField = (indexed: boolean): Field => ({\n\tname: 'slug',\n\ttype: 'text',\n\trequired: true,\n\t// Mongoose refuses a field index and a compound index that share a key spec, and the\n\t// compound one already covers a lookup by slug.\n\tindex: indexed,\n\tlabel: labelForKey(keys.goalFieldSlug),\n\tvalidate: validateSlug,\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldSlugHelp) },\n})\n\nconst enabledField = (): Field => ({\n\tname: 'enabled',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldEnabled),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldEnabledHelp) },\n})\n\n/** Off for a goal only server code completes: a browser's completion of it is then ignored. */\nconst browserField = (): Field => ({\n\tname: 'browser',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldBrowser),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldBrowserHelp) },\n})\n\nconst matchField = (staticLabel: StaticLabelFor): Field => ({\n\tname: 'match',\n\ttype: 'group',\n\tlabel: labelForKey(keys.goalFieldMatch),\n\tfields: [\n\t\t{\n\t\t\tname: 'kind',\n\t\t\ttype: 'select',\n\t\t\trequired: true,\n\t\t\tdefaultValue: 'goal',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchKind),\n\t\t\t// `admin.description` on a select is read where a label function never runs, so the\n\t\t\t// three kinds are explained through the locale map instead.\n\t\t\tadmin: { description: staticLabel(keys.goalFieldMatchKindHelp) },\n\t\t\toptions: [\n\t\t\t\t{ label: labelForKey(keys.goalKindGoal), value: 'goal' },\n\t\t\t\t{ label: labelForKey(keys.goalKindEvent), value: 'event' },\n\t\t\t\t{ label: labelForKey(keys.goalKindPath), value: 'path' },\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: 'name',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchEventName),\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'event',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchEventNameHelp),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'pattern',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchPathPattern),\n\t\t\tvalidate: validatePattern,\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'path',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchPathPatternHelp),\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The amount and where else it may come from, with no heading of their own so they read as\n * part of the goal. The currency is the sibling `currency` field, edited in the Amount control.\n */\nconst valueField = (defaultCurrency: string | undefined): Field => ({\n\tname: 'value',\n\ttype: 'group',\n\tlabel: false,\n\tadmin: { hideGutter: true },\n\tfields: [\n\t\tamountField(\n\t\t\t{\n\t\t\t\tname: 'fixed',\n\t\t\t\ttype: 'number',\n\t\t\t\tmin: 0,\n\t\t\t\tlabel: labelForKey(keys.goalFieldAmount),\n\t\t\t\tadmin: { description: labelForKey(keys.goalFieldAmountHelp) },\n\t\t\t},\n\t\t\t{ currencyPath: '../currency', defaultCurrency }\n\t\t),\n\t\t{\n\t\t\tname: 'prop',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldAmountProp),\n\t\t\tadmin: {\n\t\t\t\tdescription: labelForKey(keys.goalFieldAmountPropHelp),\n\t\t\t\t// Only an action's own details can carry an amount to read.\n\t\t\t\tcondition: (data) => data?.match?.kind === 'event',\n\t\t\t},\n\t\t},\n\t],\n})\n\n/** The amount a goal's currency belongs to: its fixed amount. */\nconst fixedAmount: AmountOf = ({ data }) => valueAt(data, 'value.fixed')\n\n/**\n * Hidden rather than removed while the install measures no money, a replacement included: the\n * field stays in the schema, so a goal that already carries an amount keeps it.\n */\nconst moneyOnly = (field: Field, revenue: boolean | undefined): Field =>\n\trevenue === false ? Object.assign({}, field, { admin: hiddenAdmin(field) }) : field\n\n/**\n * Name and slug share the first row while both are plain named fields; a layout or sidebar\n * replacement cannot live in a row, so it goes top level at its declared position.\n */\nconst layout = (args: BuildGoalsCollectionArgs, indexed: boolean): Field[] => [\n\t...pairInRow(\n\t\toverrideField(nameField(), args.fields?.name),\n\t\toverrideField(slugField(indexed), args.fields?.slug)\n\t),\n\toverrideField(enabledField(), args.fields?.enabled),\n\toverrideField(browserField(), args.fields?.browser),\n\toverrideField(matchField(args.staticLabel ?? builtInStaticLabel), args.fields?.match),\n\tmoneyOnly(overrideField(valueField(args.defaultCurrency), args.fields?.value), args.revenue),\n\tmoneyOnly(overrideField(amountCurrencyField(fixedAmount), args.fields?.currency), args.revenue),\n\t...scopeField(args),\n]\n\n/**\n * The editor-managed goals collection, one document per goal and scope, merged over config goals.\n * Admin-only by default; `access`, `fields` and finally `overrides` reshape it.\n */\nexport const buildGoalsCollection = (args: BuildGoalsCollectionArgs): CollectionConfig => {\n\tconst unique = uniqueSlugIndex(args)\n\tconst fields = layout(args, unique === undefined)\n\tif (!hasNamedField(fields, 'slug')) {\n\t\tthrow new Error(\n\t\t\t`analytics: goals.collection.fields.slug must return a field named \"slug\" (a row or group containing one is fine); the goals collection \"${args.slug}\" keys every report on that value`\n\t\t)\n\t}\n\tconst collection: CollectionConfig = {\n\t\tslug: args.slug,\n\t\t...(unique ? { indexes: [unique] } : {}),\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.goalsCollectionSingular),\n\t\t\tplural: labelForKey(keys.goalsCollectionPlural),\n\t\t},\n\t\t// A duplicate would carry the slug over, which the uniqueness hook refuses anyway.\n\t\tdisableDuplicate: true,\n\t\tadmin: {\n\t\t\tuseAsTitle: 'name',\n\t\t\tdefaultColumns: ['name', 'slug', 'match.kind', 'enabled'],\n\t\t\tgroup: (args.staticLabel ?? builtInStaticLabel)(keys.adminGroup),\n\t\t},\n\t\taccess: {\n\t\t\tread: providerRowAccess(args),\n\t\t\tcreate: providerCreateAccess(args),\n\t\t\tupdate: providerRowAccess(args),\n\t\t\tdelete: providerRowAccess(args),\n\t\t\t...args.access,\n\t\t},\n\t\thooks: {\n\t\t\tbeforeValidate: [checkSlug(args)],\n\t\t\tbeforeChange: [stampScope(args)],\n\t\t\tafterChange: [\n\t\t\t\tasync ({ doc, operation, previousDoc, req }) => {\n\t\t\t\t\tawait args.onChange(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tscope: docScope(doc, args.scopeField),\n\t\t\t\t\t\t\t...(operation === 'update'\n\t\t\t\t\t\t\t\t? { previousScope: docScope(previousDoc, args.scopeField) }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\treq\n\t\t\t\t\t)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t\tafterDelete: [\n\t\t\t\tasync ({ doc, req }) => {\n\t\t\t\t\tawait args.onChange({ scope: docScope(doc, args.scopeField) }, req)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tfields,\n\t}\n\treturn args.overrides ? args.overrides(collection) : collection\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAa,aAAa;AA2C1B,MAAM,gBAA2C,OAAO,EAAE,UACzD,OAAO,UAAU,YAAY,kBAAkB,KAAK,KAAK,IACtD,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,aAAa;;AAGzC,MAAM,mBAA8C,OAAO,EAAE,UAC5D,OAAO,UAAU,YAAY,eAAe,KAAK,MAAM,OACpD,YAAY,IAAI,CAAC,EAAE,KAAK,wBAAwB;CAChD,UAAA;CACA,WAAA;AACD,CAAC,IACA;AAEJ,MAAM,aAAa,YAAoB,KAAqB,QAC3D,IAAI,gBAAgB;CACnB;CACA,QAAQ,CACP;EACC,OAAO,YAAY,KAAK,aAAa;EACrC,SAAS,YAAY,IAAI,CAAC,EAAE,GAAG;EAC/B,MAAM;CACP,CACD;AACD,CAAC;;;;;AAMF,MAAM,aAAa,SAAiE;CACnF,OAAO,OAAO,EAAE,MAAM,aAAa,UAAU;EAC5C,MAAM,OAAO,MAAM;EACnB,IAAI,OAAO,SAAS,YAAY,SAAS,IACxC,OAAO;EAER,IAAI,CAAC,kBAAkB,KAAK,IAAI,GAC/B,MAAM,UAAU,KAAK,MAAM,KAAK,KAAK,aAAa;EAEnD,IAAI,MAAM,aAAa,MAAM;GAAE;GAAM;GAAa;EAAI,GAAG,EAAE,MAAM,EAAE,QAAQ,KAAK,EAAE,CAAC,GAClF,MAAM,UAAU,KAAK,MAAM,KAAK,KAAK,kBAAkB;EAExD,OAAO;CACR;AACD;;;;;AAMA,MAAM,mBAAmB,SAA8D;CACtF,IAAI,CAAC,KAAK,QACT,OAAO;EAAE,QAAQ,CAAC,MAAM;EAAG,QAAQ;CAAK;CAEzC,OAAO,KAAK,eAAe,UAAU;EAAE,QAAQ,CAA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AAE,KAAK,UAAU;IACvB,MAAM,KAAK,SAAS,EAAE,OAAO,SAAS,KAAK,KAAK,UAAU,EAAE,GAAG,GAAG;IAClE,OAAO;GACR,CACD;EACD;EACA;CACD;CACA,OAAO,KAAK,YAAY,KAAK,UAAU,UAAU,IAAI;AACtD"}
1
+ {"version":3,"file":"collection.js","names":[],"sources":["../../src/goals/collection.ts"],"sourcesContent":["import type {\n\tCollectionBeforeValidateHook,\n\tCollectionConfig,\n\tCompoundIndex,\n\tField,\n\tPayloadRequest,\n\tTextFieldSingleValidation,\n} from 'payload'\nimport { ValidationError } from 'payload'\nimport { valueAt } from '../core/values'\nimport {\n\ttype CollectionFieldOverride,\n\thasNamedField,\n\toverrideField,\n\tpairInRow,\n} from '../plugin/collectionFields'\nimport { docScope, type ScopeChange } from '../plugin/scopeChange'\nimport type { ProviderAccessArgs } from '../providers/access'\nimport { providerCreateAccess, providerRowAccess } from '../providers/access'\nimport { takenInScope } from '../providers/scopeUnique'\nimport { stampScope } from '../providers/stampScope'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { asTranslate, labelForKey } from '../translations/server'\nimport { builtInStaticLabel, type StaticLabelFor } from '../translations/staticLabel'\nimport { amountField } from './amountField'\nimport { type AmountOf, amountCurrencyField } from './currency'\nimport { hiddenAdmin } from './moneyFields'\nimport { MAX_PATTERN_GLOBSTARS, MAX_PATTERN_SEGMENTS, patternProblem } from './pathMatch'\nimport { GOAL_SLUG_PATTERN } from './types'\n\nexport const GOALS_SLUG = 'analytics-goals'\n\n/**\n * Replaces one default field, receiving the plugin's own to spread. Any field type may come back, a\n * `row` included, as long as the slug override still holds a field named `slug`.\n */\nexport type GoalFieldOverride = CollectionFieldOverride\n\nexport interface GoalCollectionFieldOverrides {\n\tname?: GoalFieldOverride\n\tslug?: GoalFieldOverride\n\tenabled?: GoalFieldOverride\n\tbrowser?: GoalFieldOverride\n\tmatch?: GoalFieldOverride\n\tvalue?: GoalFieldOverride\n\tcurrency?: GoalFieldOverride\n}\n\nexport interface BuildGoalsCollectionArgs extends ProviderAccessArgs {\n\tslug: string\n\taccess?: Partial<CollectionConfig['access']>\n\t/** Per-field overrides, applied before the whole-collection `overrides`. */\n\tfields?: GoalCollectionFieldOverrides\n\toverrides?: (collection: CollectionConfig) => CollectionConfig\n\t/**\n\t * Whether the install measures money, default on. False hides the amount and currency rather than\n\t * removing them, so existing amounts survive and show again when it is turned back on.\n\t */\n\trevenue?: boolean\n\t/**\n\t * The install's reporting currency when it is one fixed code. The Amount control fills it\n\t * in once an amount is set on a goal that has no currency yet.\n\t */\n\tdefaultCurrency?: string\n\t/**\n\t * Called after any change or delete with the scopes the write touched and the request that\n\t * wrote, so that request's own Payload instance reads those scopes again once the write commits.\n\t */\n\tonChange: (change: ScopeChange, req: PayloadRequest) => void | Promise<void>\n\t/** The install's static labels; the built-in strings alone when absent. */\n\tstaticLabel?: StaticLabelFor\n}\n\nconst validateSlug: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && GOAL_SLUG_PATTERN.test(value)\n\t\t? true\n\t\t: asTranslate(req.t)(keys.goalErrorSlug)\n\n/** The matcher's caps, refused here so an editor hears about them rather than a goal never matching. */\nconst validatePattern: TextFieldSingleValidation = (value, { req }) =>\n\ttypeof value === 'string' && patternProblem(value) !== null\n\t\t? asTranslate(req.t)(keys.goalErrorPatternLimits, {\n\t\t\t\tsegments: MAX_PATTERN_SEGMENTS,\n\t\t\t\tglobstars: MAX_PATTERN_GLOBSTARS,\n\t\t\t})\n\t\t: true\n\nconst slugError = (collection: string, req: PayloadRequest, key: TranslationKey) =>\n\tnew ValidationError(\n\t\t{\n\t\t\tcollection,\n\t\t\terrors: [\n\t\t\t\t{\n\t\t\t\t\tlabel: labelForKey(keys.goalFieldSlug),\n\t\t\t\t\tmessage: asTranslate(req.t)(key),\n\t\t\t\t\tpath: 'slug',\n\t\t\t\t},\n\t\t\t],\n\t\t\treq,\n\t\t},\n\t\treq.t\n\t)\n\n/**\n * Slug shape and per-scope uniqueness at collection level, so a replaced slug field without its own\n * `validate` keeps them; the index cannot cover install-wide Postgres rows or host scope fields.\n */\nconst checkSlug = (args: BuildGoalsCollectionArgs): CollectionBeforeValidateHook => {\n\treturn async ({ data, originalDoc, req }) => {\n\t\tconst slug = data?.slug\n\t\tif (typeof slug !== 'string' || slug === '') {\n\t\t\treturn data\n\t\t}\n\t\tif (!GOAL_SLUG_PATTERN.test(slug)) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlug)\n\t\t}\n\t\tif (await takenInScope(args, { data, originalDoc, req }, { slug: { equals: slug } })) {\n\t\t\tthrow slugError(args.slug, req, keys.goalErrorSlugTaken)\n\t\t}\n\t\treturn data\n\t}\n}\n\n/**\n * Database backstop for the hook, only where the plugin owns the scope field. Postgres treats a NULL\n * scope as distinct, so install-wide rows stay hook-guarded.\n */\nconst uniqueSlugIndex = (args: BuildGoalsCollectionArgs): CompoundIndex | undefined => {\n\tif (!args.scoped) {\n\t\treturn { fields: ['slug'], unique: true }\n\t}\n\treturn args.scopeField === 'scope' ? { fields: ['slug', 'scope'], unique: true } : undefined\n}\n\n/**\n * The plugin's scope field, only while `scopeField` names it: a host-owned field is the host's to\n * register, and a hidden twin would store the scope twice.\n */\nconst scopeField = (args: BuildGoalsCollectionArgs): Field[] =>\n\targs.scopeField === 'scope'\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\t// Written by scoped setups; hidden because single-site installs never touch it.\n\t\t\t\t\tname: 'scope',\n\t\t\t\t\ttype: 'text',\n\t\t\t\t\tindex: true,\n\t\t\t\t\tlabel: labelForKey(keys.providerFieldScope),\n\t\t\t\t\tadmin: { hidden: true },\n\t\t\t\t},\n\t\t\t]\n\t\t: []\n\nconst nameField = (): Field => ({\n\tname: 'name',\n\ttype: 'text',\n\trequired: true,\n\tlabel: labelForKey(keys.goalFieldName),\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldNameHelp) },\n})\n\nconst slugField = (indexed: boolean): Field => ({\n\tname: 'slug',\n\ttype: 'text',\n\trequired: true,\n\t// Mongoose refuses a field index and a compound index that share a key spec, and the\n\t// compound one already covers a lookup by slug.\n\tindex: indexed,\n\tlabel: labelForKey(keys.goalFieldSlug),\n\tvalidate: validateSlug,\n\tadmin: { width: '50%', description: labelForKey(keys.goalFieldSlugHelp) },\n})\n\nconst enabledField = (): Field => ({\n\tname: 'enabled',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldEnabled),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldEnabledHelp) },\n})\n\n/** Off for a goal only server code completes: a browser's completion of it is then ignored. */\nconst browserField = (): Field => ({\n\tname: 'browser',\n\ttype: 'checkbox',\n\tdefaultValue: true,\n\tlabel: labelForKey(keys.goalFieldBrowser),\n\tadmin: { position: 'sidebar', description: labelForKey(keys.goalFieldBrowserHelp) },\n})\n\nconst matchField = (staticLabel: StaticLabelFor): Field => ({\n\tname: 'match',\n\ttype: 'group',\n\tlabel: labelForKey(keys.goalFieldMatch),\n\tfields: [\n\t\t{\n\t\t\tname: 'kind',\n\t\t\ttype: 'select',\n\t\t\trequired: true,\n\t\t\tdefaultValue: 'goal',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchKind),\n\t\t\t// `admin.description` on a select is read where a label function never runs, so the\n\t\t\t// three kinds are explained through the locale map instead.\n\t\t\tadmin: { description: staticLabel(keys.goalFieldMatchKindHelp) },\n\t\t\toptions: [\n\t\t\t\t{ label: labelForKey(keys.goalKindGoal), value: 'goal' },\n\t\t\t\t{ label: labelForKey(keys.goalKindEvent), value: 'event' },\n\t\t\t\t{ label: labelForKey(keys.goalKindPath), value: 'path' },\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\tname: 'name',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchEventName),\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'event',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchEventNameHelp),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: 'pattern',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldMatchPathPattern),\n\t\t\tvalidate: validatePattern,\n\t\t\tadmin: {\n\t\t\t\tcondition: (_data, siblingData) => siblingData?.kind === 'path',\n\t\t\t\tdescription: labelForKey(keys.goalFieldMatchPathPatternHelp),\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The amount and where else it may come from, with no heading of their own so they read as\n * part of the goal. The currency is the sibling `currency` field, edited in the Amount control.\n */\nconst valueField = (defaultCurrency: string | undefined): Field => ({\n\tname: 'value',\n\ttype: 'group',\n\tlabel: false,\n\tadmin: { hideGutter: true },\n\tfields: [\n\t\tamountField(\n\t\t\t{\n\t\t\t\tname: 'fixed',\n\t\t\t\ttype: 'number',\n\t\t\t\tmin: 0,\n\t\t\t\tlabel: labelForKey(keys.goalFieldAmount),\n\t\t\t\tadmin: { description: labelForKey(keys.goalFieldAmountHelp) },\n\t\t\t},\n\t\t\t{ currencyPath: '../currency', defaultCurrency }\n\t\t),\n\t\t{\n\t\t\tname: 'prop',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.goalFieldAmountProp),\n\t\t\tadmin: {\n\t\t\t\tdescription: labelForKey(keys.goalFieldAmountPropHelp),\n\t\t\t\t// Only an action's own details can carry an amount to read.\n\t\t\t\tcondition: (data) => data?.match?.kind === 'event',\n\t\t\t},\n\t\t},\n\t],\n})\n\n/** The amount a goal's currency belongs to: its fixed amount. */\nconst fixedAmount: AmountOf = ({ data }) => valueAt(data, 'value.fixed')\n\n/**\n * Hidden rather than removed while the install measures no money, a replacement included: the\n * field stays in the schema, so a goal that already carries an amount keeps it.\n */\nconst moneyOnly = (field: Field, revenue: boolean | undefined): Field =>\n\trevenue === false ? Object.assign({}, field, { admin: hiddenAdmin(field) }) : field\n\n/**\n * Name and slug share the first row while both are plain named fields; a layout or sidebar\n * replacement cannot live in a row, so it goes top level at its declared position.\n */\nconst layout = (args: BuildGoalsCollectionArgs, indexed: boolean): Field[] => [\n\t...pairInRow(\n\t\toverrideField(nameField(), args.fields?.name),\n\t\toverrideField(slugField(indexed), args.fields?.slug)\n\t),\n\toverrideField(enabledField(), args.fields?.enabled),\n\toverrideField(browserField(), args.fields?.browser),\n\toverrideField(matchField(args.staticLabel ?? builtInStaticLabel), args.fields?.match),\n\tmoneyOnly(overrideField(valueField(args.defaultCurrency), args.fields?.value), args.revenue),\n\tmoneyOnly(overrideField(amountCurrencyField(fixedAmount), args.fields?.currency), args.revenue),\n\t...scopeField(args),\n]\n\n/**\n * The editor-managed goals collection, one document per goal and scope, merged over config goals.\n * Admin-only by default; `access`, `fields` and finally `overrides` reshape it.\n */\nexport const buildGoalsCollection = (args: BuildGoalsCollectionArgs): CollectionConfig => {\n\tconst unique = uniqueSlugIndex(args)\n\tconst fields = layout(args, unique === undefined)\n\tif (!hasNamedField(fields, 'slug')) {\n\t\tthrow new Error(\n\t\t\t`analytics: goals.collection.fields.slug must return a field named \"slug\" (a row or group containing one is fine); the goals collection \"${args.slug}\" keys every report on that value`\n\t\t)\n\t}\n\tconst collection: CollectionConfig = {\n\t\tslug: args.slug,\n\t\t...(unique ? { indexes: [unique] } : {}),\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.goalsCollectionSingular),\n\t\t\tplural: labelForKey(keys.goalsCollectionPlural),\n\t\t},\n\t\t// A duplicate would carry the slug over, which the uniqueness hook refuses anyway.\n\t\tdisableDuplicate: true,\n\t\tadmin: {\n\t\t\tuseAsTitle: 'name',\n\t\t\tdefaultColumns: ['name', 'slug', 'match.kind', 'enabled'],\n\t\t\tgroup: (args.staticLabel ?? builtInStaticLabel)(keys.adminGroup),\n\t\t},\n\t\taccess: {\n\t\t\tread: providerRowAccess(args),\n\t\t\tcreate: providerCreateAccess(args),\n\t\t\tupdate: providerRowAccess(args),\n\t\t\tdelete: providerRowAccess(args),\n\t\t\t...args.access,\n\t\t},\n\t\thooks: {\n\t\t\tbeforeValidate: [checkSlug(args)],\n\t\t\tbeforeChange: [stampScope(args)],\n\t\t\tafterChange: [\n\t\t\t\tasync ({ doc, operation, previousDoc, req }) => {\n\t\t\t\t\tawait args.onChange(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tscope: docScope(doc, args.scopeField),\n\t\t\t\t\t\t\t...(operation === 'update'\n\t\t\t\t\t\t\t\t? { previousScope: docScope(previousDoc, args.scopeField) }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\treq\n\t\t\t\t\t)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t\tafterDelete: [\n\t\t\t\tasync ({ doc, req }) => {\n\t\t\t\t\tawait args.onChange({ scope: docScope(doc, args.scopeField) }, req)\n\t\t\t\t\treturn doc\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tfields,\n\t}\n\treturn args.overrides ? args.overrides(collection) : collection\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAa,aAAa;AA2C1B,MAAM,gBAA2C,OAAO,EAAE,UACzD,OAAO,UAAU,YAAY,kBAAkB,KAAK,KAAK,IACtD,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,aAAa;;AAGzC,MAAM,mBAA8C,OAAO,EAAE,UAC5D,OAAO,UAAU,YAAY,eAAe,KAAK,MAAM,OACpD,YAAY,IAAI,CAAC,EAAE,KAAK,wBAAwB;CAChD,UAAA;CACA,WAAA;AACD,CAAC,IACA;AAEJ,MAAM,aAAa,YAAoB,KAAqB,QAC3D,IAAI,gBACH;CACC;CACA,QAAQ,CACP;EACC,OAAO,YAAY,KAAK,aAAa;EACrC,SAAS,YAAY,IAAI,CAAC,EAAE,GAAG;EAC/B,MAAM;CACP,CACD;CACA;AACD,GACA,IAAI,CACL;;;;;AAMD,MAAM,aAAa,SAAiE;CACnF,OAAO,OAAO,EAAE,MAAM,aAAa,UAAU;EAC5C,MAAM,OAAO,MAAM;E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