@10x-media/analytics 1.0.0-beta.15 → 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.
- package/CHANGELOG.md +56 -0
- package/README.md +1 -1
- package/dist/adapters/ga4/ga4.js +33 -2
- package/dist/adapters/ga4/ga4.js.map +1 -1
- package/dist/adapters/ga4/measurementId.js +4 -1
- package/dist/adapters/ga4/measurementId.js.map +1 -1
- package/dist/adapters/ga4/propertyId.js +17 -0
- package/dist/adapters/ga4/propertyId.js.map +1 -0
- package/dist/adapters/http/fetchJson.js +24 -1
- package/dist/adapters/http/fetchJson.js.map +1 -1
- package/dist/adapters/plausible/plausible.js +16 -1
- package/dist/adapters/plausible/plausible.js.map +1 -1
- package/dist/adapters/plausible/siteId.js +31 -0
- package/dist/adapters/plausible/siteId.js.map +1 -0
- package/dist/adapters/posthog/cloud.js +20 -0
- package/dist/adapters/posthog/cloud.js.map +1 -0
- package/dist/adapters/posthog/credentials.js +20 -0
- package/dist/adapters/posthog/credentials.js.map +1 -0
- package/dist/adapters/posthog/posthog.d.ts +3 -3
- package/dist/adapters/posthog/posthog.js +24 -10
- package/dist/adapters/posthog/posthog.js.map +1 -1
- package/dist/adapters/umami/umami.js +34 -7
- package/dist/adapters/umami/umami.js.map +1 -1
- package/dist/charts/series.js +1 -1
- package/dist/core/contract.d.ts +16 -1
- package/dist/core/contract.js.map +1 -1
- package/dist/core/options.d.ts +1 -1
- package/dist/core/options.js +1 -1
- package/dist/core/options.js.map +1 -1
- package/dist/core/scopedRead.js +62 -14
- package/dist/core/scopedRead.js.map +1 -1
- package/dist/core/sourceErrors.js +12 -1
- package/dist/core/sourceErrors.js.map +1 -1
- package/dist/core/sourceOptions.js +1 -1
- package/dist/core/sourceOptions.js.map +1 -1
- package/dist/core/sourcePolicy.d.ts +8 -1
- package/dist/core/sourcePolicy.js.map +1 -1
- package/dist/core/throttle.js +3 -1
- package/dist/core/throttle.js.map +1 -1
- package/dist/exports/adapters/contract.d.ts +1 -1
- package/dist/exports/adapters/ga4.d.ts +2 -2
- package/dist/exports/adapters/native.d.ts +2 -2
- package/dist/exports/adapters/plausible.d.ts +2 -2
- package/dist/exports/adapters/posthog.d.ts +2 -2
- package/dist/exports/adapters/umami.d.ts +2 -2
- package/dist/exports/client.d.ts +3 -1
- package/dist/exports/client.js +3 -1
- package/dist/exports/next.d.ts +2 -2
- package/dist/exports/testing.d.ts +2 -2
- package/dist/exports/types.d.ts +3 -3
- package/dist/fields/config/fetchSources.js +1 -1
- package/dist/fields/config/fetchSources.js.map +1 -1
- package/dist/goals/collection.js +3 -2
- package/dist/goals/collection.js.map +1 -1
- package/dist/goals/resolver.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/dist/native/geo/maxmindResolver.js +1 -1
- package/dist/native/nativeAdapter.js +1 -1
- package/dist/plugin/createRuntime.js +57 -13
- package/dist/plugin/createRuntime.js.map +1 -1
- package/dist/plugin/pluginCollections.js +4 -1
- package/dist/plugin/pluginCollections.js.map +1 -1
- package/dist/plugin/providerStatusEndpoint.js +80 -0
- package/dist/plugin/providerStatusEndpoint.js.map +1 -0
- package/dist/plugin/queryEndpoint.js +1 -1
- package/dist/plugin/queryEndpoint.js.map +1 -1
- package/dist/plugin/readContextForRequest.d.ts +4 -3
- package/dist/plugin/readContextForRequest.js +2 -2
- package/dist/plugin/readContextForRequest.js.map +1 -1
- package/dist/plugin/refreshEndpoint.js +1 -1
- package/dist/plugin/routes.d.ts +5 -0
- package/dist/plugin/routes.js +1 -0
- package/dist/plugin/routes.js.map +1 -1
- package/dist/plugin/runtime.js.map +1 -1
- package/dist/providers/ProviderConnection.d.ts +12 -0
- package/dist/providers/ProviderConnection.js +105 -0
- package/dist/providers/ProviderConnection.js.map +1 -0
- package/dist/providers/ProviderConnectionTest.d.ts +12 -0
- package/dist/providers/ProviderConnectionTest.js +55 -0
- package/dist/providers/ProviderConnectionTest.js.map +1 -0
- package/dist/providers/ProvidersListNotice.d.ts +1 -1
- package/dist/providers/ProvidersListNotice.js +3 -2
- package/dist/providers/ProvidersListNotice.js.map +1 -1
- package/dist/providers/collection.d.ts +1 -1
- package/dist/providers/collection.js +106 -41
- package/dist/providers/collection.js.map +1 -1
- package/dist/providers/connectionCheck.d.ts +1 -0
- package/dist/providers/connectionCheck.js +80 -0
- package/dist/providers/connectionCheck.js.map +1 -0
- package/dist/providers/connectionState.js +53 -0
- package/dist/providers/connectionState.js.map +1 -0
- package/dist/providers/factory.d.ts +1 -3
- package/dist/providers/factory.js +18 -21
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/hosts.js +31 -9
- package/dist/providers/hosts.js.map +1 -1
- package/dist/providers/ids.d.ts +6 -0
- package/dist/providers/ids.js +32 -0
- package/dist/providers/ids.js.map +1 -0
- package/dist/providers/providerStatusClient.js +60 -0
- package/dist/providers/providerStatusClient.js.map +1 -0
- package/dist/providers/registry.js +56 -20
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/retarget.js +39 -8
- package/dist/providers/retarget.js.map +1 -1
- package/dist/providers/secrets.d.ts +1 -1
- package/dist/providers/secrets.js.map +1 -1
- package/dist/providers/status.d.ts +1 -0
- package/dist/providers/status.js +181 -0
- package/dist/providers/status.js.map +1 -0
- package/dist/surfacing/classifyError.js +37 -5
- package/dist/surfacing/classifyError.js.map +1 -1
- package/dist/surfacing/engine.js +2 -2
- package/dist/surfacing/engine.js.map +1 -1
- package/dist/surfacing/lanes.js +29 -22
- package/dist/surfacing/lanes.js.map +1 -1
- package/dist/surfacing/rebucket.js +1 -1
- package/dist/testing/settle.d.ts +2 -1
- package/dist/testing/settle.js +6 -2
- package/dist/testing/settle.js.map +1 -1
- package/dist/tracker/sinks/ga4.js +2 -2
- package/dist/translations/ar.js +43 -8
- package/dist/translations/ar.js.map +1 -1
- package/dist/translations/de.js +43 -8
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +43 -8
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.js +43 -8
- package/dist/translations/es.js.map +1 -1
- package/dist/translations/fr.js +43 -8
- package/dist/translations/fr.js.map +1 -1
- package/dist/translations/id.js +43 -8
- package/dist/translations/id.js.map +1 -1
- package/dist/translations/keys.d.ts +35 -0
- package/dist/translations/keys.js +35 -0
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.js +43 -8
- package/dist/translations/ko.js.map +1 -1
- package/dist/translations/pt.js +43 -8
- package/dist/translations/pt.js.map +1 -1
- package/dist/translations/ru.js +43 -8
- package/dist/translations/ru.js.map +1 -1
- package/dist/translations/uk.js +43 -8
- package/dist/translations/uk.js.map +1 -1
- package/dist/translations/zh.js +43 -8
- package/dist/translations/zh.js.map +1 -1
- package/dist/ui/analytics.css +63 -0
- package/dist/ui/components/SourcesNoticeBanner.js +4 -3
- package/dist/ui/components/SourcesNoticeBanner.js.map +1 -1
- package/dist/view/ViewSections.js +9 -2
- package/dist/view/ViewSections.js.map +1 -1
- package/dist/view/sections/EmptyStates.js +5 -4
- package/dist/view/sections/EmptyStates.js.map +1 -1
- package/dist/view/sections/OverviewCards.js +6 -2
- package/dist/view/sections/OverviewCards.js.map +1 -1
- package/dist/view/sections/SourceConnectionNote.js +56 -0
- package/dist/view/sections/SourceConnectionNote.js.map +1 -0
- package/dist/view/viewProps.d.ts +2 -0
- package/dist/view/viewProps.js +2 -1
- package/dist/view/viewProps.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopedRead.js","names":[],"sources":["../../src/core/scopedRead.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { decideOnce } from '../access/decideOnce'\nimport { isScopeMember } from '../access/membership'\nimport {\n\ttype GatedScope,\n\tisGatedScope,\n\tmintGatedScope,\n\ttype ReadPrincipal,\n\tSYSTEM,\n} from '../access/principal'\nimport { readGate } from '../access/readGate'\nimport { readableProviderDocIds } from '../plugin/readableProviders'\nimport { requestMemo } from '../plugin/requestMemo'\nimport {\n\ttype AnalyticsRuntime,\n\tresolvableScope,\n\tresolveRegistryFor,\n\tresolveScopeFor,\n\ttype ScopeGates,\n\tscopeGates,\n} from '../plugin/runtime'\nimport { MAX_SCOPE_LENGTH } from '../query/limits'\nimport { type AnalyticsAdapter, PLATFORM_SCOPE } from './contract'\nimport {\n\ttype AdapterRegistry,\n\tcreateRegistry,\n\tfilterRegistry,\n\ttype ScopeRegistry,\n} from './registry'\nimport { sourceLabelFor, sourceRefFor } from './sourceLabel'\nimport type { DefaultSourceFunction, SourceRef } from './sourcePolicy'\n\nexport type ReadContext =\n\t| {\n\t\t\tok: true\n\t\t\tadapter: AnalyticsAdapter\n\t\t\tscope: string | null\n\t\t\t/** The scope to stamp on the adapter query; undefined for install-wide reads. */\n\t\t\tqueryScope?: string\n\t\t\t/**\n\t\t\t * The read's principal and scope, for the reads it makes on its behalf: handing this on\n\t\t\t * keeps every one of them on exactly this scope without deciding it again.\n\t\t\t */\n\t\t\tpin: ReadPrincipal\n\t\t\t/** The source asked for, which this reader cannot read, when the scope default read instead. */\n\t\t\tsubstitutedFrom?: string\n\t }\n\t| {\n\t\t\tok: false\n\t\t\t/**\n\t\t\t * Why the read was refused: `no-sources` (nothing this reader may read), `no-access`,\n\t\t\t * `not-member`, or `no-scope` (no single scope resolved, no cross-scope read).\n\t\t\t */\n\t\t\treason?: 'no-sources' | 'no-access' | 'not-member' | 'no-scope'\n\t }\n\ntype ResolveReadContextArgs = {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tadapterId?: string\n\t/**\n\t * Without an `adapterId`, the source to read through is the scope's default when this accepts\n\t * it, else the first visible source it accepts, else the default all the same.\n\t */\n\tprefer?: (adapter: AnalyticsAdapter) => boolean\n\t/**\n\t * An `adapterId` this reader cannot read is read as if none were named, the substitution\n\t * reported as `substitutedFrom`: for a stored choice, never a caller's explicit one.\n\t */\n\tfallbackWhenUnreadable?: boolean\n} & ReadPrincipal\n\ninterface QueryScopeArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\t/** The read's resolved scope; `'*'` is the explicit cross-scope marker. */\n\tscope: string | null\n\tadapter: AnalyticsAdapter\n\t/** Shared cross-scope decisions; one set is created per call when omitted. */\n\tgates?: ScopeGates\n}\n\n/**\n * A scope a request may act on, or why not: `named` and `unresolved` are denied cross-scope gates,\n * `failed` a throwing `scope.resolve`, `not-member` a scope its user does not belong to.\n */\nexport type RequestedScope =\n\t| {\n\t\t\tok: true\n\t\t\tscope: string | null\n\t\t\t/** The same scope as a token the reads below accept without deciding it again. */\n\t\t\tgated: GatedScope\n\t }\n\t| { ok: false; reason: 'named' | 'unresolved' | 'failed' | 'not-member' }\n\ninterface RequestedScopeArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\t/** The `scope` the request carried, untrimmed; null or undefined when it carried none. */\n\traw?: string | null\n\t/** Shared cross-scope decisions; one set is created per call when omitted. */\n\tgates?: ScopeGates\n}\n\nconst cleared = (scope: string | null): RequestedScope => ({\n\tok: true,\n\tscope,\n\tgated: mintGatedScope(scope),\n})\n\n/**\n * The scope one request may act on, for every endpoint taking a caller's `scope`, and the only\n * place a {@link GatedScope} is minted. A scoped install's null, no tenant selected, fails closed.\n */\nexport const resolveRequestedScope = async (args: RequestedScopeArgs): Promise<RequestedScope> => {\n\tconst { runtime, req } = args\n\tconst gates = args.gates ?? scopeGates(runtime, req)\n\tconst named = typeof args.raw === 'string' ? args.raw.trim() : ''\n\tif (named !== '') {\n\t\t// The wildcard is never the request's own scope in this sense: it names every scope,\n\t\t// whatever the resolver answered, and stays behind the aggregate gate.\n\t\tif (named === PLATFORM_SCOPE) {\n\t\t\treturn (await gates.aggregate({ scope: PLATFORM_SCOPE }))\n\t\t\t\t? cleared(named)\n\t\t\t\t: { ok: false, reason: 'named' }\n\t\t}\n\t\t// An install without tenants has no scope to name, and no tenant id runs this long.\n\t\tif (runtime.scoped !== true || named.length > MAX_SCOPE_LENGTH) {\n\t\t\treturn { ok: false, reason: 'named' }\n\t\t}\n\t\tif (await gates.named({ scope: named })) {\n\t\t\treturn cleared(named)\n\t\t}\n\t\t// Only after the gate has said no, so a platform reader still costs one resolution.\n\t\tconst own = await resolveScopeFor(runtime, req).catch(() => null)\n\t\tif (own === null || own === PLATFORM_SCOPE || own !== named) {\n\t\t\treturn { ok: false, reason: 'named' }\n\t\t}\n\t\treturn (await isScopeMember(runtime.member, req, own))\n\t\t\t? cleared(own)\n\t\t\t: { ok: false, reason: 'not-member' }\n\t}\n\tlet scope: string | null\n\ttry {\n\t\tscope = await resolveScopeFor(runtime, req)\n\t} catch {\n\t\treturn { ok: false, reason: 'failed' }\n\t}\n\tif (scope === PLATFORM_SCOPE || scope === null) {\n\t\tconst crossScope = scope === PLATFORM_SCOPE || runtime.scoped === true\n\t\treturn crossScope && !(await gates.aggregate({ scope }))\n\t\t\t? { ok: false, reason: 'unresolved' }\n\t\t\t: cleared(scope)\n\t}\n\tif ((await isScopeMember(runtime.member, req, scope)) || (await gates.named({ scope }))) {\n\t\treturn cleared(scope)\n\t}\n\treturn { ok: false, reason: 'not-member' }\n}\n\n/**\n * True for a shared config adapter that cannot narrow its query, read under a tenant scope: it\n * would answer with every scope's data, so reading or listing it takes `unscopedSource`.\n */\nexport const needsUnscopedSourceAccess = (\n\truntime: AnalyticsRuntime,\n\tadapter: AnalyticsAdapter,\n\tscope: string | null\n): boolean =>\n\tscope !== null &&\n\tscope !== PLATFORM_SCOPE &&\n\truntime.configAdapterIds.has(adapter.id) &&\n\t!adapter.capabilities.scopedQueries\n\n/**\n * {@link SYSTEM} reads any scope, but never a tenant through a shared adapter that cannot narrow\n * to it: a job would store that adapter's install-wide numbers as the tenant's own.\n */\nconst SYSTEM_GATES: ScopeGates = {\n\tnamed: () => Promise.resolve(true),\n\taggregate: () => Promise.resolve(true),\n\tunscopedSource: () => Promise.resolve(false),\n}\n\ninterface VisibleArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tresolved: ScopeRegistry\n\tscope: string | null\n\tgates?: ScopeGates\n\tprincipal?: typeof SYSTEM\n}\n\n/** The adapters one reader sees in a scope, and which of them a `fallback` policy alone admitted. */\nexport interface VisibleSources {\n\tregistry: AdapterRegistry | null\n\t/** Shared adapters listed only because a `fallback` policy let a member of the scope in. */\n\tfallbackAdmitted: ReadonlySet<string>\n}\n\nconst NONE_ADMITTED: ReadonlySet<string> = new Set()\n\n/** A source the reader reads a scope through by one of the scope's own provider documents. */\ninterface Granted {\n\tadapter: AnalyticsAdapter\n\tdocId: string\n}\n\n/**\n * Whether `sources.<id>.tenants` lets this member of `scope` read through a shared adapter none\n * of its documents grants; asked once per request, scope and adapter. A policy that throws denies.\n */\nconst policyAdmits = async (args: {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tscope: string\n\tadapter: AnalyticsAdapter\n\town: readonly Granted[]\n}): Promise<boolean> => {\n\tconst { runtime, req, scope, adapter, own } = args\n\tconst policy = runtime.sourcePolicies?.get(adapter.id)\n\t// The boot refuses a policy on an adapter that cannot narrow; a tenant must never read totals\n\t// spanning every tenant, so a runtime built any other way is held to it too.\n\tif (\n\t\tpolicy === undefined ||\n\t\t!runtime.configAdapterIds.has(adapter.id) ||\n\t\tadapter.capabilities.scopedQueries !== true ||\n\t\t!(await isScopeMember(runtime.member, req, scope))\n\t) {\n\t\treturn false\n\t}\n\treturn decideOnce(req, {\n\t\towner: runtime,\n\t\tkey: `sourcePolicy:${JSON.stringify(scope)}:${adapter.id}`,\n\t\tdecide: async () => {\n\t\t\tif (policy === 'tenant') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (policy === 'fallback') {\n\t\t\t\treturn own.length === 0\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst ownSources = await Promise.all(\n\t\t\t\t\town.map(async (granted) => ({\n\t\t\t\t\t\tid: granted.adapter.id,\n\t\t\t\t\t\tlabel: await sourceLabelFor(granted.adapter, { req, scope }),\n\t\t\t\t\t\tdocId: granted.docId,\n\t\t\t\t\t}))\n\t\t\t\t)\n\t\t\t\treturn (await policy({ req, scope, adapterId: adapter.id, ownSources })) === true\n\t\t\t} catch (err) {\n\t\t\t\treq.payload.logger?.warn(\n\t\t\t\t\t`analytics: sources.${adapter.id}.tenants threw for scope \"${scope}\", which counts as no: ${String(err)}`\n\t\t\t\t)\n\t\t\t\treturn false\n\t\t\t}\n\t\t},\n\t})\n}\n\nconst pickedDefaults = requestMemo<string | undefined>('defaultSources')\n\n/** The `defaultSource` function's pick, asked once per request, scope and set of sources. */\nconst pickDefault = (args: {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tresolved: ScopeRegistry\n\tscope: string\n\tvisible: AdapterRegistry\n\tpick: DefaultSourceFunction\n}): Promise<string | undefined> => {\n\tconst { runtime, req, resolved, scope, visible, pick } = args\n\tconst listed = visible.all()\n\treturn pickedDefaults(req, {\n\t\towner: pick,\n\t\tkey: `${JSON.stringify(scope)}:${listed.map((adapter) => adapter.id).join(',')}`,\n\t\tcompute: async () => {\n\t\t\ttry {\n\t\t\t\tconst sources: SourceRef[] = await Promise.all(\n\t\t\t\t\tlisted.map((adapter) =>\n\t\t\t\t\t\tsourceRefFor(adapter, {\n\t\t\t\t\t\t\treq,\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tconfigIds: runtime.configAdapterIds,\n\t\t\t\t\t\t\tdocId: resolved.grants.get(adapter.id),\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\treturn await pick({ req, scope, sources })\n\t\t\t} catch (err) {\n\t\t\t\treq.payload.logger?.warn(\n\t\t\t\t\t`analytics: defaultSource threw for scope \"${scope}\", which keeps the default: ${String(err)}`\n\t\t\t\t)\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t},\n\t})\n}\n\ninterface ScopeDefaultArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tresolved: ScopeRegistry\n\tscope: string\n\tvisible: AdapterRegistry\n}\n\n/**\n * A tenant scope's default among the sources a reader sees: its document flagged the default, else\n * the `defaultSource` rule's pick, else undefined for the registry's own.\n */\nconst scopeDefaultId = async (args: ScopeDefaultArgs): Promise<string | undefined> => {\n\tconst { runtime, resolved, visible } = args\n\tconst all = visible.all()\n\tconst sees = (id: string | undefined): id is string =>\n\t\tid !== undefined && all.some((adapter) => adapter.id === id)\n\tif (sees(resolved.defaultGrant)) {\n\t\treturn resolved.defaultGrant\n\t}\n\tconst rule = runtime.defaultSource\n\tif (rule === undefined) {\n\t\treturn undefined\n\t}\n\tif (rule === 'tenantFirst') {\n\t\treturn all.find((adapter) => resolved.grants.has(adapter.id))?.id\n\t}\n\tif (rule === 'platformFirst') {\n\t\treturn sees(runtime.platformAdapterId) ? runtime.platformAdapterId : undefined\n\t}\n\tconst picked = await pickDefault({ ...args, pick: rule })\n\treturn sees(picked) ? picked : undefined\n}\n\n/** `visible` reading through the scope's chosen default; the very registry when it already does. */\nconst withScopeDefault = async (\n\targs: Omit<ScopeDefaultArgs, 'visible'> & { visible: AdapterRegistry | null }\n): Promise<AdapterRegistry | null> => {\n\tconst { visible } = args\n\tif (!visible) {\n\t\treturn null\n\t}\n\tconst chosen = await scopeDefaultId({ ...args, visible })\n\treturn chosen === undefined || chosen === visible.default().id\n\t\t? visible\n\t\t: createRegistry(visible.all(), chosen)\n}\n\n/**\n * {@link visibleRegistryFor}, also naming the shared adapters only a `fallback` policy admitted,\n * which a listing says so about.\n */\nexport const visibleSourcesFor = async (args: VisibleArgs): Promise<VisibleSources> => {\n\tconst { runtime, req, resolved, scope } = args\n\tconst { registry, grants } = resolved\n\tif (runtime.scoped !== true || scope === null || scope === PLATFORM_SCOPE) {\n\t\treturn { registry, fallbackAdmitted: NONE_ADMITTED }\n\t}\n\tif (args.principal === SYSTEM) {\n\t\tconst visible = filterRegistry(\n\t\t\tregistry,\n\t\t\t(adapter) => grants.has(adapter.id) || !needsUnscopedSourceAccess(runtime, adapter, scope)\n\t\t)\n\t\treturn {\n\t\t\tregistry: await withScopeDefault({ runtime, req, resolved, scope, visible }),\n\t\t\tfallbackAdmitted: NONE_ADMITTED,\n\t\t}\n\t}\n\tconst gates = args.gates ?? scopeGates(runtime, req)\n\tconst readable = await readableProviderDocIds(runtime, req, scope)\n\tconst own: Granted[] = []\n\tfor (const adapter of registry.all()) {\n\t\tconst docId = grants.get(adapter.id)\n\t\tif (docId !== undefined && (readable === null || readable.has(docId))) {\n\t\t\town.push({ adapter, docId })\n\t\t}\n\t}\n\tconst keep = new Set(own.map((granted) => granted.adapter.id))\n\tconst fallbackAdmitted = new Set<string>()\n\tfor (const adapter of registry.all()) {\n\t\tif (grants.has(adapter.id)) {\n\t\t\tcontinue\n\t\t}\n\t\tif (!runtime.providersCollection && adapter.capabilities.scopedQueries) {\n\t\t\tkeep.add(adapter.id)\n\t\t\tcontinue\n\t\t}\n\t\tif (await gates.unscopedSource({ scope, adapterId: adapter.id })) {\n\t\t\tkeep.add(adapter.id)\n\t\t\tcontinue\n\t\t}\n\t\tif (await policyAdmits({ runtime, req, scope, adapter, own })) {\n\t\t\tkeep.add(adapter.id)\n\t\t\tif (runtime.sourcePolicies?.get(adapter.id) === 'fallback') {\n\t\t\t\tfallbackAdmitted.add(adapter.id)\n\t\t\t}\n\t\t}\n\t}\n\tconst visible = filterRegistry(registry, (adapter) => keep.has(adapter.id))\n\treturn {\n\t\tregistry: await withScopeDefault({ runtime, req, resolved, scope, visible }),\n\t\tfallbackAdmitted,\n\t}\n}\n\n/**\n * The adapters a request may read through in one tenant scope, or null for none: the scope's own\n * sources follow the providers' read access (`sourceAccess`), a config adapter `unscopedSource` or\n * its `sources` policy. A tenant scope reads through its chosen default (see `defaultSource`).\n */\nexport const visibleRegistryFor = async (args: VisibleArgs): Promise<AdapterRegistry | null> =>\n\t(await visibleSourcesFor(args)).registry\n\n/**\n * The sources a job reads one scope through as {@link SYSTEM}, or null when the scope holds\n * none: exactly what `resolveReadContext` lets a system read choose from.\n */\nexport const systemRegistryFor = async (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope: string | null\n): Promise<AdapterRegistry | null> => {\n\tconst resolved = await resolveRegistryFor(runtime, {\n\t\tpayload: req.payload,\n\t\treq,\n\t\tscope: resolvableScope(scope),\n\t})\n\treturn visibleRegistryFor({ runtime, req, resolved, scope, principal: SYSTEM })\n}\n\n/**\n * The scope to stamp on one adapter query, or a refusal. Every read path decides it here, so\n * widgets and the query endpoint cannot drift on what counts as cross-scope.\n */\nexport const resolveQueryScope = async (\n\targs: QueryScopeArgs\n): Promise<{ ok: true; queryScope?: string } | { ok: false }> => {\n\tconst { runtime, req, scope, adapter } = args\n\tconst gates = args.gates ?? scopeGates(runtime, req)\n\tif (scope === PLATFORM_SCOPE) {\n\t\treturn (await gates.aggregate({ scope })) ? { ok: true } : { ok: false }\n\t}\n\tif (scope === null) {\n\t\treturn { ok: true }\n\t}\n\tif (needsUnscopedSourceAccess(runtime, adapter, scope)) {\n\t\treturn (await gates.unscopedSource({ scope, adapterId: adapter.id }))\n\t\t\t? { ok: true }\n\t\t\t: { ok: false }\n\t}\n\treturn { ok: true, queryScope: scope }\n}\n\ntype PrincipalScope =\n\t| { ok: true; scope: string | null; pin: ReadPrincipal }\n\t| Extract<ReadContext, { ok: false }>\n\n/**\n * The read's scope: the system's own, one already cleared, or the one the request asks for. Checked\n * at runtime, since a JavaScript caller or a cast can pass anything; anything else is refused.\n */\nconst principalScope = async (\n\targs: ResolveReadContextArgs,\n\tgates: ScopeGates\n): Promise<PrincipalScope> => {\n\tconst { scope } = args\n\tif (args.principal === SYSTEM) {\n\t\treturn typeof scope === 'string' || scope === null\n\t\t\t? { ok: true, scope, pin: { principal: SYSTEM, scope } }\n\t\t\t: { ok: false }\n\t}\n\tif (isGatedScope(scope)) {\n\t\treturn { ok: true, scope: scope.value, pin: { scope } }\n\t}\n\tif (scope !== undefined && scope !== null && typeof scope !== 'string') {\n\t\treturn { ok: false }\n\t}\n\tconst requested = await resolveRequestedScope({\n\t\truntime: args.runtime,\n\t\treq: args.req,\n\t\tgates,\n\t\traw: scope,\n\t})\n\tif (!requested.ok) {\n\t\tswitch (requested.reason) {\n\t\t\tcase 'not-member':\n\t\t\t\treturn { ok: false, reason: 'not-member' }\n\t\t\tcase 'named':\n\t\t\t\treturn { ok: false, reason: 'no-access' }\n\t\t\tcase 'unresolved':\n\t\t\t\treturn { ok: false, reason: 'no-scope' }\n\t\t\tcase 'failed':\n\t\t\t\treturn { ok: false }\n\t\t}\n\t}\n\treturn { ok: true, scope: requested.scope, pin: { scope: requested.gated } }\n}\n\n/**\n * One read's scope and adapter, behind `access.read` and `resolveRequestedScope` unless the\n * principal is {@link SYSTEM}. Any failure answers `{ ok: false }`, so a surface never throws.\n */\nexport const resolveReadContext = async (args: ResolveReadContextArgs): Promise<ReadContext> => {\n\tconst { runtime, req, adapterId } = args\n\tconst system = args.principal === SYSTEM\n\tconst gates = system ? SYSTEM_GATES : scopeGates(runtime, req)\n\ttry {\n\t\tif (!system && !(await readGate(runtime, req))) {\n\t\t\treturn { ok: false, reason: 'no-access' }\n\t\t}\n\t\tconst decided = await principalScope(args, gates)\n\t\tif (!decided.ok) {\n\t\t\treturn decided\n\t\t}\n\t\tconst { scope, pin } = decided\n\t\tconst registryScope = resolvableScope(scope)\n\t\tconst resolved = await resolveRegistryFor(runtime, {\n\t\t\tpayload: req.payload,\n\t\t\treq,\n\t\t\tscope: registryScope,\n\t\t})\n\t\t// The default is picked out of what this reader may actually read, so a scope whose\n\t\t// leading source is the platform's own shared one still serves a tenant admin.\n\t\tconst registry = await visibleRegistryFor({\n\t\t\truntime,\n\t\t\treq,\n\t\t\tresolved,\n\t\t\tscope,\n\t\t\tgates,\n\t\t\t...(system ? { principal: SYSTEM } : {}),\n\t\t})\n\t\tif (!registry) {\n\t\t\treturn { ok: false, reason: 'no-sources' }\n\t\t}\n\t\tconst fallback = registry.default()\n\t\tconst preferred =\n\t\t\targs.prefer && !args.prefer(fallback) ? registry.all().find(args.prefer) : undefined\n\t\tconst substitutedFrom =\n\t\t\tadapterId && args.fallbackWhenUnreadable && !registry.all().some((a) => a.id === adapterId)\n\t\t\t\t? adapterId\n\t\t\t\t: undefined\n\t\tconst adapter =\n\t\t\tadapterId && substitutedFrom === undefined ? registry.get(adapterId) : (preferred ?? fallback)\n\t\tconst decision = await resolveQueryScope({\n\t\t\truntime,\n\t\t\treq,\n\t\t\tscope,\n\t\t\tadapter,\n\t\t\tgates,\n\t\t})\n\t\tif (!decision.ok) {\n\t\t\treturn { ok: false }\n\t\t}\n\t\treturn {\n\t\t\tok: true,\n\t\t\tadapter,\n\t\t\tscope: registryScope,\n\t\t\tqueryScope: decision.queryScope,\n\t\t\tpin,\n\t\t\t...(substitutedFrom === undefined ? {} : { substitutedFrom }),\n\t\t}\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: read context resolution failed: ${String(err)}`)\n\t\treturn { ok: false }\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAwGA,MAAM,WAAW,WAA0C;CAC1D,IAAI;CACJ;CACA,OAAO,eAAe,KAAK;AAC5B;;;;;AAMA,MAAa,wBAAwB,OAAO,SAAsD;CACjG,MAAM,EAAE,SAAS,QAAQ;CACzB,MAAM,QAAQ,KAAK,SAAS,WAAW,SAAS,GAAG;CACnD,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI;CAC/D,IAAI,UAAU,IAAI;EAGjB,IAAI,UAAA,KACH,OAAQ,MAAM,MAAM,UAAU,EAAE,OAAA,IAAsB,CAAC,IACpD,QAAQ,KAAK,IACb;GAAE,IAAI;GAAO,QAAQ;EAAQ;EAGjC,IAAI,QAAQ,WAAW,QAAQ,MAAM,SAAA,KACpC,OAAO;GAAE,IAAI;GAAO,QAAQ;EAAQ;EAErC,IAAI,MAAM,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC,GACrC,OAAO,QAAQ,KAAK;EAGrB,MAAM,MAAM,MAAM,gBAAgB,SAAS,GAAG,EA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vF,YACA,KAAA;EACJ,MAAM,UACL,aAAa,oBAAoB,KAAA,IAAY,SAAS,IAAI,SAAS,IAAK,aAAa;EACtF,MAAM,WAAW,MAAM,kBAAkB;GACxC;GACA;GACA;GACA;GACA;EACD,CAAC;EACD,IAAI,CAAC,SAAS,IACb,OAAO,EAAE,IAAI,MAAM;EAEpB,OAAO;GACN,IAAI;GACJ;GACA,OAAO;GACP,YAAY,SAAS;GACrB;GACA,GAAI,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB;EAC5D;CACD,SAAS,KAAK;EACb,IAAI,QAAQ,QAAQ,KAAK,8CAA8C,OAAO,GAAG,GAAG;EACpF,OAAO,EAAE,IAAI,MAAM;CACpB;AACD"}
|
|
1
|
+
{"version":3,"file":"scopedRead.js","names":[],"sources":["../../src/core/scopedRead.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { decideOnce } from '../access/decideOnce'\nimport { isScopeMember } from '../access/membership'\nimport {\n\ttype GatedScope,\n\tisGatedScope,\n\tmintGatedScope,\n\ttype ReadPrincipal,\n\tSYSTEM,\n} from '../access/principal'\nimport { readGate } from '../access/readGate'\nimport { readableProviderDocIds } from '../plugin/readableProviders'\nimport { requestMemo } from '../plugin/requestMemo'\nimport {\n\ttype AnalyticsRuntime,\n\tresolvableScope,\n\tresolveRegistryFor,\n\tresolveScopeFor,\n\ttype ScopeGates,\n\tscopeGates,\n} from '../plugin/runtime'\nimport { isFailingConnection, type ProviderStatus } from '../providers/connectionState'\nimport { MAX_SCOPE_LENGTH } from '../query/limits'\nimport { BREAKER_MAX_MS } from '../surfacing/breaker'\nimport { currentDate } from './clock'\nimport { type AnalyticsAdapter, PLATFORM_SCOPE } from './contract'\nimport {\n\ttype AdapterRegistry,\n\tcreateRegistry,\n\tfilterRegistry,\n\ttype ScopeRegistry,\n} from './registry'\nimport { sourceLabelFor, sourceRefFor } from './sourceLabel'\nimport type { DefaultSourceFunction, SourceRef } from './sourcePolicy'\n\nexport type ReadContext =\n\t| {\n\t\t\tok: true\n\t\t\tadapter: AnalyticsAdapter\n\t\t\tscope: string | null\n\t\t\t/** The scope to stamp on the adapter query; undefined for install-wide reads. */\n\t\t\tqueryScope?: string\n\t\t\t/**\n\t\t\t * The read's principal and scope, for the reads it makes on its behalf: handing this on\n\t\t\t * keeps every one of them on exactly this scope without deciding it again.\n\t\t\t */\n\t\t\tpin: ReadPrincipal\n\t\t\t/** The source asked for, which this reader cannot read, when the scope default read instead. */\n\t\t\tsubstitutedFrom?: string\n\t }\n\t| {\n\t\t\tok: false\n\t\t\t/**\n\t\t\t * Why the read was refused: `no-sources` (nothing this reader may read), `no-access`,\n\t\t\t * `not-member`, or `no-scope` (no single scope resolved, no cross-scope read).\n\t\t\t */\n\t\t\treason?: 'no-sources' | 'no-access' | 'not-member' | 'no-scope'\n\t }\n\ntype ResolveReadContextArgs = {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tadapterId?: string\n\t/**\n\t * Without an `adapterId`, the source to read through is the scope's default when this accepts\n\t * it, else the first visible source it accepts, else the default all the same.\n\t */\n\tprefer?: (adapter: AnalyticsAdapter) => boolean\n\t/**\n\t * An `adapterId` this reader cannot read is read as if none were named, the substitution\n\t * reported as `substitutedFrom`: for a stored choice, never a caller's explicit one.\n\t */\n\tfallbackWhenUnreadable?: boolean\n} & ReadPrincipal\n\ninterface QueryScopeArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\t/** The read's resolved scope; `'*'` is the explicit cross-scope marker. */\n\tscope: string | null\n\tadapter: AnalyticsAdapter\n\t/** Shared cross-scope decisions; one set is created per call when omitted. */\n\tgates?: ScopeGates\n}\n\n/**\n * A scope a request may act on, or why not: `named` and `unresolved` are denied cross-scope gates,\n * `failed` a throwing `scope.resolve`, `not-member` a scope its user does not belong to.\n */\nexport type RequestedScope =\n\t| {\n\t\t\tok: true\n\t\t\tscope: string | null\n\t\t\t/** The same scope as a token the reads below accept without deciding it again. */\n\t\t\tgated: GatedScope\n\t }\n\t| { ok: false; reason: 'named' | 'unresolved' | 'failed' | 'not-member' }\n\ninterface RequestedScopeArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\t/** The `scope` the request carried, untrimmed; null or undefined when it carried none. */\n\traw?: string | null\n\t/** Shared cross-scope decisions; one set is created per call when omitted. */\n\tgates?: ScopeGates\n}\n\nconst cleared = (scope: string | null): RequestedScope => ({\n\tok: true,\n\tscope,\n\tgated: mintGatedScope(scope),\n})\n\n/**\n * The scope one request may act on, for every endpoint taking a caller's `scope`, and the only\n * place a {@link GatedScope} is minted. A scoped install's null, no tenant selected, fails closed.\n */\nexport const resolveRequestedScope = async (args: RequestedScopeArgs): Promise<RequestedScope> => {\n\tconst { runtime, req } = args\n\tconst gates = args.gates ?? scopeGates(runtime, req)\n\tconst named = typeof args.raw === 'string' ? args.raw.trim() : ''\n\tif (named !== '') {\n\t\t// The wildcard is never the request's own scope in this sense: it names every scope,\n\t\t// whatever the resolver answered, and stays behind the aggregate gate.\n\t\tif (named === PLATFORM_SCOPE) {\n\t\t\treturn (await gates.aggregate({ scope: PLATFORM_SCOPE }))\n\t\t\t\t? cleared(named)\n\t\t\t\t: { ok: false, reason: 'named' }\n\t\t}\n\t\t// An install without tenants has no scope to name, and no tenant id runs this long.\n\t\tif (runtime.scoped !== true || named.length > MAX_SCOPE_LENGTH) {\n\t\t\treturn { ok: false, reason: 'named' }\n\t\t}\n\t\tif (await gates.named({ scope: named })) {\n\t\t\treturn cleared(named)\n\t\t}\n\t\t// Only after the gate has said no, so a platform reader still costs one resolution.\n\t\tconst own = await resolveScopeFor(runtime, req).catch(() => null)\n\t\tif (own === null || own === PLATFORM_SCOPE || own !== named) {\n\t\t\treturn { ok: false, reason: 'named' }\n\t\t}\n\t\treturn (await isScopeMember(runtime.member, req, own))\n\t\t\t? cleared(own)\n\t\t\t: { ok: false, reason: 'not-member' }\n\t}\n\tlet scope: string | null\n\ttry {\n\t\tscope = await resolveScopeFor(runtime, req)\n\t} catch {\n\t\treturn { ok: false, reason: 'failed' }\n\t}\n\tif (scope === PLATFORM_SCOPE || scope === null) {\n\t\tconst crossScope = scope === PLATFORM_SCOPE || runtime.scoped === true\n\t\treturn crossScope && !(await gates.aggregate({ scope }))\n\t\t\t? { ok: false, reason: 'unresolved' }\n\t\t\t: cleared(scope)\n\t}\n\tif ((await isScopeMember(runtime.member, req, scope)) || (await gates.named({ scope }))) {\n\t\treturn cleared(scope)\n\t}\n\treturn { ok: false, reason: 'not-member' }\n}\n\n/**\n * True for a shared config adapter that cannot narrow its query, read under a tenant scope: it\n * would answer with every scope's data, so reading or listing it takes `unscopedSource`.\n */\nexport const needsUnscopedSourceAccess = (\n\truntime: AnalyticsRuntime,\n\tadapter: AnalyticsAdapter,\n\tscope: string | null\n): boolean =>\n\tscope !== null &&\n\tscope !== PLATFORM_SCOPE &&\n\truntime.configAdapterIds.has(adapter.id) &&\n\t!adapter.capabilities.scopedQueries\n\n/**\n * {@link SYSTEM} reads any scope, but never a tenant through a shared adapter that cannot narrow\n * to it: a job would store that adapter's install-wide numbers as the tenant's own.\n */\nconst SYSTEM_GATES: ScopeGates = {\n\tnamed: () => Promise.resolve(true),\n\taggregate: () => Promise.resolve(true),\n\tunscopedSource: () => Promise.resolve(false),\n}\n\ninterface VisibleArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tresolved: ScopeRegistry\n\tscope: string | null\n\tgates?: ScopeGates\n\tprincipal?: typeof SYSTEM\n}\n\n/** The adapters one reader sees in a scope, and which of them a `fallback` policy alone admitted. */\nexport interface VisibleSources {\n\tregistry: AdapterRegistry | null\n\t/** Shared adapters listed only because a `fallback` policy let a member of the scope in. */\n\tfallbackAdmitted: ReadonlySet<string>\n\t/** True when the scope has sources of its own, all failing, so a `fallback` policy stands in for them. */\n\townFailing: boolean\n}\n\nconst NONE_ADMITTED: ReadonlySet<string> = new Set()\n\n/** A source the reader reads a scope through by one of the scope's own provider documents. */\ninterface Granted {\n\tadapter: AnalyticsAdapter\n\tdocId: string\n}\n\n/**\n * The scope's own documents whose source is failing (`isFailingConnection`), which a `fallback`\n * policy stands in for and a policy function reads as `failing`; empty unless the install has\n * either. A document failing for longer than the breaker's longest rest is checked again in the\n * background, since nothing else reads a source its scope no longer opens on. Rows that cannot be\n * read count as no failure, so the reads go on.\n */\nconst failingOwnDocs = async (\n\truntime: AnalyticsRuntime,\n\town: readonly Granted[]\n): Promise<ReadonlySet<string>> => {\n\tconst store = runtime.providerStatus\n\tif (\n\t\t!store ||\n\t\town.length === 0 ||\n\t\t![...(runtime.sourcePolicies?.values() ?? [])].some(\n\t\t\t(policy) => policy === 'fallback' || typeof policy === 'function'\n\t\t)\n\t) {\n\t\treturn NONE_ADMITTED\n\t}\n\tlet statuses: Map<string, ProviderStatus>\n\ttry {\n\t\t// A config adapter lent to a document (native) writes no status: any row it has is stale.\n\t\tconst checked = own.filter((granted) => !runtime.configAdapterIds.has(granted.adapter.id))\n\t\tconst versions = new Map(\n\t\t\tchecked.map((granted) => [granted.docId, runtime.providerVersionOf?.(granted.adapter)])\n\t\t)\n\t\tstatuses = await store.readMany(\n\t\t\tchecked.map((granted) => granted.docId),\n\t\t\t(docId) => versions.get(docId)\n\t\t)\n\t} catch (err) {\n\t\truntime.providerStatusWarning?.(\n\t\t\t`analytics: provider connection statuses could not be read, so no source counts as failing: ${String(err)}`\n\t\t)\n\t\treturn NONE_ADMITTED\n\t}\n\tconst at = currentDate().getTime()\n\tconst failing = new Set<string>()\n\tfor (const [docId, status] of statuses) {\n\t\tif (!isFailingConnection(status, at)) {\n\t\t\tcontinue\n\t\t}\n\t\tfailing.add(docId)\n\t\tif (at - Date.parse(status.lastErrorAt ?? '') >= BREAKER_MAX_MS) {\n\t\t\truntime.providerRecheck?.request(docId)\n\t\t}\n\t}\n\treturn failing\n}\n\n/**\n * Whether `sources.<id>.tenants` lets this member of `scope` read through a shared adapter none\n * of its documents grants; asked once per request, scope and adapter. A policy that throws denies.\n */\nconst policyAdmits = async (args: {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tscope: string\n\tadapter: AnalyticsAdapter\n\town: readonly Granted[]\n\t/** The ids of `own`'s documents whose connection is failing, read when a policy asks. */\n\tfailing: () => Promise<ReadonlySet<string>>\n}): Promise<boolean> => {\n\tconst { runtime, req, scope, adapter, own, failing } = args\n\tconst policy = runtime.sourcePolicies?.get(adapter.id)\n\t// The boot refuses a policy on an adapter that cannot narrow; a tenant must never read totals\n\t// spanning every tenant, so a runtime built any other way is held to it too.\n\tif (\n\t\tpolicy === undefined ||\n\t\t!runtime.configAdapterIds.has(adapter.id) ||\n\t\tadapter.capabilities.scopedQueries !== true ||\n\t\t!(await isScopeMember(runtime.member, req, scope))\n\t) {\n\t\treturn false\n\t}\n\treturn decideOnce(req, {\n\t\towner: runtime,\n\t\tkey: `sourcePolicy:${JSON.stringify(scope)}:${adapter.id}`,\n\t\tdecide: async () => {\n\t\t\tif (policy === 'tenant') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (policy === 'fallback') {\n\t\t\t\tconst failed = await failing()\n\t\t\t\treturn own.every((granted) => failed.has(granted.docId))\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst ownSources = await Promise.all(\n\t\t\t\t\town.map(async (granted) => ({\n\t\t\t\t\t\tid: granted.adapter.id,\n\t\t\t\t\t\tlabel: await sourceLabelFor(granted.adapter, { req, scope }),\n\t\t\t\t\t\tdocId: granted.docId,\n\t\t\t\t\t\tfailing: async () => (await failing()).has(granted.docId),\n\t\t\t\t\t}))\n\t\t\t\t)\n\t\t\t\treturn (await policy({ req, scope, adapterId: adapter.id, ownSources })) === true\n\t\t\t} catch (err) {\n\t\t\t\treq.payload.logger?.warn(\n\t\t\t\t\t`analytics: sources.${adapter.id}.tenants threw for scope \"${scope}\", which counts as no: ${String(err)}`\n\t\t\t\t)\n\t\t\t\treturn false\n\t\t\t}\n\t\t},\n\t})\n}\n\nconst pickedDefaults = requestMemo<string | undefined>('defaultSources')\n\n/** The `defaultSource` function's pick, asked once per request, scope and set of sources. */\nconst pickDefault = (args: {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tresolved: ScopeRegistry\n\tscope: string\n\tvisible: AdapterRegistry\n\tpick: DefaultSourceFunction\n}): Promise<string | undefined> => {\n\tconst { runtime, req, resolved, scope, visible, pick } = args\n\tconst listed = visible.all()\n\treturn pickedDefaults(req, {\n\t\towner: pick,\n\t\tkey: `${JSON.stringify(scope)}:${listed.map((adapter) => adapter.id).join(',')}`,\n\t\tcompute: async () => {\n\t\t\ttry {\n\t\t\t\tconst sources: SourceRef[] = await Promise.all(\n\t\t\t\t\tlisted.map((adapter) =>\n\t\t\t\t\t\tsourceRefFor(adapter, {\n\t\t\t\t\t\t\treq,\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tconfigIds: runtime.configAdapterIds,\n\t\t\t\t\t\t\tdocId: resolved.grants.get(adapter.id),\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\treturn await pick({ req, scope, sources })\n\t\t\t} catch (err) {\n\t\t\t\treq.payload.logger?.warn(\n\t\t\t\t\t`analytics: defaultSource threw for scope \"${scope}\", which keeps the default: ${String(err)}`\n\t\t\t\t)\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t},\n\t})\n}\n\ninterface ScopeDefaultArgs {\n\truntime: AnalyticsRuntime\n\treq: PayloadRequest\n\tresolved: ScopeRegistry\n\tscope: string\n\tvisible: AdapterRegistry\n}\n\n/**\n * A tenant scope's default among the sources a reader sees: its document flagged the default, else\n * the `defaultSource` rule's pick, else undefined for the registry's own.\n */\nconst scopeDefaultId = async (args: ScopeDefaultArgs): Promise<string | undefined> => {\n\tconst { runtime, resolved, visible } = args\n\tconst all = visible.all()\n\tconst sees = (id: string | undefined): id is string =>\n\t\tid !== undefined && all.some((adapter) => adapter.id === id)\n\tif (sees(resolved.defaultGrant)) {\n\t\treturn resolved.defaultGrant\n\t}\n\tconst rule = runtime.defaultSource\n\tif (rule === undefined) {\n\t\treturn undefined\n\t}\n\tif (rule === 'tenantFirst') {\n\t\treturn all.find((adapter) => resolved.grants.has(adapter.id))?.id\n\t}\n\tif (rule === 'platformFirst') {\n\t\treturn sees(runtime.platformAdapterId) ? runtime.platformAdapterId : undefined\n\t}\n\tconst picked = await pickDefault({ ...args, pick: rule })\n\treturn sees(picked) ? picked : undefined\n}\n\n/** `visible` reading through the scope's chosen default; the very registry when it already does. */\nconst withScopeDefault = async (\n\targs: Omit<ScopeDefaultArgs, 'visible'> & { visible: AdapterRegistry | null }\n): Promise<AdapterRegistry | null> => {\n\tconst { visible } = args\n\tif (!visible) {\n\t\treturn null\n\t}\n\tconst chosen = await scopeDefaultId({ ...args, visible })\n\treturn chosen === undefined || chosen === visible.default().id\n\t\t? visible\n\t\t: createRegistry(visible.all(), chosen)\n}\n\n/**\n * {@link visibleRegistryFor}, also naming the shared adapters only a `fallback` policy admitted,\n * which a listing says so about.\n */\nexport const visibleSourcesFor = async (args: VisibleArgs): Promise<VisibleSources> => {\n\tconst { runtime, req, resolved, scope } = args\n\tconst { registry, grants } = resolved\n\tif (runtime.scoped !== true || scope === null || scope === PLATFORM_SCOPE) {\n\t\treturn { registry, fallbackAdmitted: NONE_ADMITTED, ownFailing: false }\n\t}\n\tif (args.principal === SYSTEM) {\n\t\tconst visible = filterRegistry(\n\t\t\tregistry,\n\t\t\t(adapter) => grants.has(adapter.id) || !needsUnscopedSourceAccess(runtime, adapter, scope)\n\t\t)\n\t\treturn {\n\t\t\tregistry: await withScopeDefault({ runtime, req, resolved, scope, visible }),\n\t\t\tfallbackAdmitted: NONE_ADMITTED,\n\t\t\townFailing: false,\n\t\t}\n\t}\n\tconst gates = args.gates ?? scopeGates(runtime, req)\n\tconst readable = await readableProviderDocIds(runtime, req, scope)\n\tconst own: Granted[] = []\n\tfor (const adapter of registry.all()) {\n\t\tconst docId = grants.get(adapter.id)\n\t\tif (docId !== undefined && (readable === null || readable.has(docId))) {\n\t\t\town.push({ adapter, docId })\n\t\t}\n\t}\n\tconst keep = new Set(own.map((granted) => granted.adapter.id))\n\tlet failingRead: Promise<ReadonlySet<string>> | undefined\n\tconst failing = () => {\n\t\tfailingRead ??= failingOwnDocs(runtime, own)\n\t\treturn failingRead\n\t}\n\tconst fallbackAdmitted = new Set<string>()\n\tfor (const adapter of registry.all()) {\n\t\tif (grants.has(adapter.id)) {\n\t\t\tcontinue\n\t\t}\n\t\tif (!runtime.providersCollection && adapter.capabilities.scopedQueries) {\n\t\t\tkeep.add(adapter.id)\n\t\t\tcontinue\n\t\t}\n\t\tif (await gates.unscopedSource({ scope, adapterId: adapter.id })) {\n\t\t\tkeep.add(adapter.id)\n\t\t\tcontinue\n\t\t}\n\t\tif (await policyAdmits({ runtime, req, scope, adapter, own, failing })) {\n\t\t\tkeep.add(adapter.id)\n\t\t\tif (runtime.sourcePolicies?.get(adapter.id) === 'fallback') {\n\t\t\t\tfallbackAdmitted.add(adapter.id)\n\t\t\t}\n\t\t}\n\t}\n\tconst visible = filterRegistry(registry, (adapter) => keep.has(adapter.id))\n\tconst scoped = await withScopeDefault({ runtime, req, resolved, scope, visible })\n\tconst ownFailing = own.length > 0 && fallbackAdmitted.size > 0\n\tconst defaultDoc = scoped ? resolved.grants.get(scoped.default().id) : undefined\n\tconst standIn =\n\t\townFailing && defaultDoc !== undefined && (await failing()).has(defaultDoc)\n\t\t\t? [...fallbackAdmitted][0]\n\t\t\t: undefined\n\treturn {\n\t\tregistry: scoped && standIn !== undefined ? createRegistry(scoped.all(), standIn) : scoped,\n\t\tfallbackAdmitted,\n\t\townFailing,\n\t}\n}\n\n/**\n * The adapters a request may read through in one tenant scope, or null for none: the scope's own\n * sources follow the providers' read access (`sourceAccess`), a config adapter `unscopedSource` or\n * its `sources` policy. A tenant scope reads through its chosen default (see `defaultSource`).\n */\nexport const visibleRegistryFor = async (args: VisibleArgs): Promise<AdapterRegistry | null> =>\n\t(await visibleSourcesFor(args)).registry\n\n/**\n * The sources a job reads one scope through as {@link SYSTEM}, or null when the scope holds\n * none: exactly what `resolveReadContext` lets a system read choose from.\n */\nexport const systemRegistryFor = async (\n\truntime: AnalyticsRuntime,\n\treq: PayloadRequest,\n\tscope: string | null\n): Promise<AdapterRegistry | null> => {\n\tconst resolved = await resolveRegistryFor(runtime, {\n\t\tpayload: req.payload,\n\t\treq,\n\t\tscope: resolvableScope(scope),\n\t})\n\treturn visibleRegistryFor({ runtime, req, resolved, scope, principal: SYSTEM })\n}\n\n/**\n * The scope to stamp on one adapter query, or a refusal. Every read path decides it here, so\n * widgets and the query endpoint cannot drift on what counts as cross-scope.\n */\nexport const resolveQueryScope = async (\n\targs: QueryScopeArgs\n): Promise<{ ok: true; queryScope?: string } | { ok: false }> => {\n\tconst { runtime, req, scope, adapter } = args\n\tconst gates = args.gates ?? scopeGates(runtime, req)\n\tif (scope === PLATFORM_SCOPE) {\n\t\treturn (await gates.aggregate({ scope })) ? { ok: true } : { ok: false }\n\t}\n\tif (scope === null) {\n\t\treturn { ok: true }\n\t}\n\tif (needsUnscopedSourceAccess(runtime, adapter, scope)) {\n\t\treturn (await gates.unscopedSource({ scope, adapterId: adapter.id }))\n\t\t\t? { ok: true }\n\t\t\t: { ok: false }\n\t}\n\treturn { ok: true, queryScope: scope }\n}\n\ntype PrincipalScope =\n\t| { ok: true; scope: string | null; pin: ReadPrincipal }\n\t| Extract<ReadContext, { ok: false }>\n\n/**\n * The read's scope: the system's own, one already cleared, or the one the request asks for. Checked\n * at runtime, since a JavaScript caller or a cast can pass anything; anything else is refused.\n */\nconst principalScope = async (\n\targs: ResolveReadContextArgs,\n\tgates: ScopeGates\n): Promise<PrincipalScope> => {\n\tconst { scope } = args\n\tif (args.principal === SYSTEM) {\n\t\treturn typeof scope === 'string' || scope === null\n\t\t\t? { ok: true, scope, pin: { principal: SYSTEM, scope } }\n\t\t\t: { ok: false }\n\t}\n\tif (isGatedScope(scope)) {\n\t\treturn { ok: true, scope: scope.value, pin: { scope } }\n\t}\n\tif (scope !== undefined && scope !== null && typeof scope !== 'string') {\n\t\treturn { ok: false }\n\t}\n\tconst requested = await resolveRequestedScope({\n\t\truntime: args.runtime,\n\t\treq: args.req,\n\t\tgates,\n\t\traw: scope,\n\t})\n\tif (!requested.ok) {\n\t\tswitch (requested.reason) {\n\t\t\tcase 'not-member':\n\t\t\t\treturn { ok: false, reason: 'not-member' }\n\t\t\tcase 'named':\n\t\t\t\treturn { ok: false, reason: 'no-access' }\n\t\t\tcase 'unresolved':\n\t\t\t\treturn { ok: false, reason: 'no-scope' }\n\t\t\tcase 'failed':\n\t\t\t\treturn { ok: false }\n\t\t}\n\t}\n\treturn { ok: true, scope: requested.scope, pin: { scope: requested.gated } }\n}\n\n/**\n * One read's scope and adapter, behind `access.read` and `resolveRequestedScope` unless the\n * principal is {@link SYSTEM}. Any failure answers `{ ok: false }`, so a surface never throws.\n */\nexport const resolveReadContext = async (args: ResolveReadContextArgs): Promise<ReadContext> => {\n\tconst { runtime, req, adapterId } = args\n\tconst system = args.principal === SYSTEM\n\tconst gates = system ? SYSTEM_GATES : scopeGates(runtime, req)\n\ttry {\n\t\tif (!system && !(await readGate(runtime, req))) {\n\t\t\treturn { ok: false, reason: 'no-access' }\n\t\t}\n\t\tconst decided = await principalScope(args, gates)\n\t\tif (!decided.ok) {\n\t\t\treturn decided\n\t\t}\n\t\tconst { scope, pin } = decided\n\t\tconst registryScope = resolvableScope(scope)\n\t\tconst resolved = await resolveRegistryFor(runtime, {\n\t\t\tpayload: req.payload,\n\t\t\treq,\n\t\t\tscope: registryScope,\n\t\t})\n\t\t// The default is picked out of what this reader may actually read, so a scope whose\n\t\t// leading source is the platform's own shared one still serves a tenant admin.\n\t\tconst registry = await visibleRegistryFor({\n\t\t\truntime,\n\t\t\treq,\n\t\t\tresolved,\n\t\t\tscope,\n\t\t\tgates,\n\t\t\t...(system ? { principal: SYSTEM } : {}),\n\t\t})\n\t\tif (!registry) {\n\t\t\treturn { ok: false, reason: 'no-sources' }\n\t\t}\n\t\tconst fallback = registry.default()\n\t\tconst preferred =\n\t\t\targs.prefer && !args.prefer(fallback) ? registry.all().find(args.prefer) : undefined\n\t\tconst substitutedFrom =\n\t\t\tadapterId && args.fallbackWhenUnreadable && !registry.all().some((a) => a.id === adapterId)\n\t\t\t\t? adapterId\n\t\t\t\t: undefined\n\t\tconst adapter =\n\t\t\tadapterId && substitutedFrom === undefined ? registry.get(adapterId) : (preferred ?? fallback)\n\t\tconst decision = await resolveQueryScope({\n\t\t\truntime,\n\t\t\treq,\n\t\t\tscope,\n\t\t\tadapter,\n\t\t\tgates,\n\t\t})\n\t\tif (!decision.ok) {\n\t\t\treturn { ok: false }\n\t\t}\n\t\treturn {\n\t\t\tok: true,\n\t\t\tadapter,\n\t\t\tscope: registryScope,\n\t\t\tqueryScope: decision.queryScope,\n\t\t\tpin,\n\t\t\t...(substitutedFrom === undefined ? {} : { substitutedFrom }),\n\t\t}\n\t} catch (err) {\n\t\treq.payload.logger?.warn(`analytics: read context resolution failed: ${String(err)}`)\n\t\treturn { ok: false }\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA2GA,MAAM,WAAW,WAA0C;CAC1D,IAAI;CACJ;CACA,OAAO,eAAe,KAAK;AAC5B;;;;;AAMA,MAAa,wBAAwB,OAAO,SAAsD;CACjG,MAAM,EAAE,SAAS,QAAQ;CACzB,MAAM,QAAQ,KAAK,SAAS,WAAW,SAAS,GAAG;CACnD,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI;CAC/D,IAAI,UAAU,IAAI;EAGjB,IAAI,UAAA,KACH,OAAQ,MAAM,MAAM,UAAU,EAAE,OAAA,IAAsB,CAAC,IACpD,QAAQ,KAAK,IACb;GAAE,IAAI;GAAO,QAAQ;EAAQ;EAGjC,IAAI,QAAQ,WAAW,QAAQ,MAAM,SAAA,KACpC,OAAO;GAAE,IAAI;GAAO,QAAQ;EAAQ;EAErC,IAAI,MAAM,MAAM,MAAM,EAAE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OA;GACA;GACA,GAAI,SAAS,EAAE,WAAW,OAAO,IAAI,CAAC;EACvC,CAAC;EACD,IAAI,CAAC,UACJ,OAAO;GAAE,IAAI;GAAO,QAAQ;EAAa;EAE1C,MAAM,WAAW,SAAS,QAAQ;EAClC,MAAM,YACL,KAAK,UAAU,CAAC,KAAK,OAAO,QAAQ,IAAI,SAAS,IAAI,EAAE,KAAK,KAAK,MAAM,IAAI,KAAA;EAC5E,MAAM,kBACL,aAAa,KAAK,0BAA0B,CAAC,SAAS,IAAI,EAAE,MAAM,MAAM,EAAE,OAAO,SAAS,IACvF,YACA,KAAA;EACJ,MAAM,UACL,aAAa,oBAAoB,KAAA,IAAY,SAAS,IAAI,SAAS,IAAK,aAAa;EACtF,MAAM,WAAW,MAAM,kBAAkB;GACxC;GACA;GACA;GACA;GACA;EACD,CAAC;EACD,IAAI,CAAC,SAAS,IACb,OAAO,EAAE,IAAI,MAAM;EAEpB,OAAO;GACN,IAAI;GACJ;GACA,OAAO;GACP,YAAY,SAAS;GACrB;GACA,GAAI,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB;EAC5D;CACD,SAAS,KAAK;EACb,IAAI,QAAQ,QAAQ,KAAK,8CAA8C,OAAO,GAAG,GAAG;EACpF,OAAO,EAAE,IAAI,MAAM;CACpB;AACD"}
|
|
@@ -3,6 +3,7 @@ import { isDimensionKey, isFilterOperator } from "./guards.js";
|
|
|
3
3
|
/** `Symbol.for`, so an error thrown in one of the package's bundles is recognized in another. */
|
|
4
4
|
const MISCONFIGURED = Symbol.for("@10x-media/analytics/sourceMisconfigured");
|
|
5
5
|
const HOST_REFUSED = Symbol.for("@10x-media/analytics/hostRefused");
|
|
6
|
+
const UNKNOWN_SITE = Symbol.for("@10x-media/analytics/unknownSite");
|
|
6
7
|
const UNSUPPORTED_FILTER = Symbol.for("@10x-media/analytics/unsupportedFilter");
|
|
7
8
|
const INVALID_QUERY = Symbol.for("@10x-media/analytics/invalidQuery");
|
|
8
9
|
/**
|
|
@@ -26,6 +27,14 @@ var HostRefusedError = class extends SourceMisconfiguredError {
|
|
|
26
27
|
this.host = host;
|
|
27
28
|
}
|
|
28
29
|
};
|
|
30
|
+
/** A site ID the vendor answered it does not know, such as self-hosted Umami's Website ID. */
|
|
31
|
+
var UnknownSiteError = class extends SourceMisconfiguredError {
|
|
32
|
+
[UNKNOWN_SITE] = true;
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "UnknownSiteError";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
29
38
|
/** How deep a cause chain is searched; a cyclic or runaway chain ends here. */
|
|
30
39
|
const MAX_CAUSE_DEPTH = 5;
|
|
31
40
|
/** The first error in `err`'s cause chain carrying `brand`, or undefined. */
|
|
@@ -41,6 +50,8 @@ const brandedCause = (err, brand) => {
|
|
|
41
50
|
const isSourceMisconfigured = (err) => brandedCause(err, MISCONFIGURED) !== void 0;
|
|
42
51
|
/** True for a {@link HostRefusedError} anywhere in an error's cause chain. */
|
|
43
52
|
const isHostRefused = (err) => brandedCause(err, HOST_REFUSED) !== void 0;
|
|
53
|
+
/** True for an {@link UnknownSiteError} anywhere in an error's cause chain. */
|
|
54
|
+
const isUnknownSite = (err) => brandedCause(err, UNKNOWN_SITE) !== void 0;
|
|
44
55
|
/**
|
|
45
56
|
* A read carrying a filter its source does not apply. The source would answer without it, and
|
|
46
57
|
* its numbers would read as filtered when they are not, so the read is refused before it is made.
|
|
@@ -104,6 +115,6 @@ const invalidQuery = (err) => {
|
|
|
104
115
|
} : void 0;
|
|
105
116
|
};
|
|
106
117
|
//#endregion
|
|
107
|
-
export { HostRefusedError, InvalidQueryError, SourceMisconfiguredError, UnsupportedFilterError, describeWithCauses, invalidQuery, isHostRefused, isSourceMisconfigured, refusedFilter };
|
|
118
|
+
export { HostRefusedError, InvalidQueryError, SourceMisconfiguredError, UnknownSiteError, UnsupportedFilterError, describeWithCauses, invalidQuery, isHostRefused, isSourceMisconfigured, isUnknownSite, refusedFilter };
|
|
108
119
|
|
|
109
120
|
//# sourceMappingURL=sourceErrors.js.map
|
|
@@ -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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U,OAAO,OAAO;EAE3E,IAAI,CAAC,MAAM,MAAM,SAAS,YAAY,MAAM,KAAK,SAAS,OAAO,CAAC,GACjE,MAAM,KAAK,OAAO,OAAO,CAAC;EAE3B,UAAU,OAAO,YAAY,WAAW,QAAQ,IAAI,SAAS,OAAO,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,MAAM,gBAA+B,OAAO,IAAI,0CAA0C;AAE1F,MAAM,eAA8B,OAAO,IAAI,kCAAkC;AAEjF,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,IAAa,mBAAb,cAAsC,yBAAyB;CAC9D,CAAU,gBAAgB;CAE1B,YAAY,SAAiB;EAC5B,MAAM,OAAO;EACb,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,MAAa,yBAAyB,QACrC,aAAa,KAAK,aAAa,MAAM,KAAA;;AAGtC,MAAa,iBAAiB,QAC7B,aAAa,KAAK,YAAY,MAAM,KAAA;;AAGrC,MAAa,i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BAAgB,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,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 {
|
|
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,QAAQ;CACR,WAAW;C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C1D,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
|
|
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
|
|
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,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"}
|
package/dist/core/throttle.js
CHANGED
|
@@ -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":";;;;;
|
|
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 };
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -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 };
|
package/dist/exports/client.js
CHANGED
|
@@ -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 };
|
package/dist/exports/next.d.ts
CHANGED
|
@@ -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 };
|