OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
ralph(M15-002): R5: the 37 hand-written XService interfaces deleted, Services members become ReturnType<typeof createXService>, and the 191 factory members that lose their contextual type get explicit return types
ralph4d7554fb45da
diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 7819f4e72..45ba557aa 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -216,7 +216,6 @@ export { registerDefaultMetrics } from './metrics';// Fastify wrapper does so inside its own already-async route registration)// and keep the reference.export type {- AssistantService,ChatApp,ChatRunContext,FilterCommandResult,@@ -240,7 +239,6 @@ export {// directly, the same way V1 reached every other dissolved service here.export type {AuthProvider,- AuthService,CompleteOAuthCallbackInput,OAuth2Tokens,OAuthUser,@@ -306,7 +304,6 @@ export type {ChartBucketProfilesInput,ChartBucketProfilesRequest,ChartEventOption,- ChartService,ChartSqlInput,CohortMetadata,ConcreteSeries,@@ -402,7 +399,6 @@ export { buildFilterWhere } from './modules/chart/src/table-filter-where';// service here. packages/db/src/services/clients.service.ts stays a// re-export shim.export type {- ClientService,CreatedClient,IServiceClient,IServiceClientWithProject,@@ -414,14 +410,12 @@ export { createClientService } from './modules/client/client.service';// here. Nothing else in the tree reached cohort.service.ts through// @openpanel/db's barrel, so packages/db loses the file entirely rather than// keeping a re-export shim (unlike gsc.ts/gsc.service.ts).-export type { CohortService } from './modules/cohort/cohort.service';// Moved from @openpanel/db's services/conversation.service.ts (M5-006) —// packages/trpc's conversation router, apps/api's live chat route and this// package's own assistant.routes.ts stub call these directly. packages/db// keeps a re-export shim (unlike cohort, M5-003): both non-trpc call sites// still reach it through `@openpanel/db`'s barrel.export type {- ConversationService,IServiceChatMessage,IServiceConversation,IServiceConversationWithMessages,@@ -479,7 +473,6 @@ export {transformMinimalEvent,transformSessionToEvent,} from './modules/event/event.service';-export type { ExportService } from './modules/export/export.service';export { createExportService } from './modules/export/export.service';export type {GetGroupListOptions,@@ -526,7 +519,6 @@ export { zSlackAuthResponse } from './modules/integration/src/slack-contract';export type {McpAuthContext,McpHttpResult,- McpService,} from './modules/mcp/mcp.service';export {createMcpService,@@ -536,7 +528,6 @@ export {export type {INotificationPayload,INotificationRuleCached,- NotificationService,} from './modules/notification/notification.service';export {APP_NOTIFICATION_INTEGRATION_ID,@@ -568,7 +559,6 @@ export { checkNotificationRulesForEvent } from './modules/notification/src/notifexport type {CreateOnboardingProjectResult,OnboardingCronSummary,- OnboardingService,} from './modules/onboarding/onboarding.service';export { createOnboardingService } from './modules/onboarding/onboarding.service';// Dissolved from @openpanel/db's services/organization.service.ts +@@ -586,7 +576,6 @@ export type {IServiceMember,IServiceOrganization,IServiceProjectAccess,- OrganizationService,} from './modules/organization/organization.service';export {createOrganizationService,@@ -610,7 +599,6 @@ export type {IGetUserJourneyInput,ILiveData,ILiveMinuteCount,- OverviewService,SegmentDailyPoint,TrafficColumn,} from './modules/overview/overview.service';@@ -630,7 +618,6 @@ export type {IPageConversionRow,IPageTimeseriesRow,ITopPage,- PagesService,} from './modules/overview/pages.service';export type {AdjustProfilePropertyResult,@@ -655,7 +642,6 @@ export type {IServiceProject,IServiceProjectWithClients,ProjectActivationStatus,- ProjectService,} from './modules/project/project.service';export { createProjectService } from './modules/project/project.service';// The six ClickHouse queries moved from packages/trpc/src/routers/realtime.ts@@ -804,7 +790,6 @@ export { createShareService } from './modules/share/share.service';// map: subscription owns "S"+"C") — packages/trpc's subscription router and// apps/api's webhook controller call these directly, the same way V1 reaches// every other dissolved service here.-export type { SubscriptionService } from './modules/subscription/subscription.service';export {createSubscriptionService,getCurrentSubscriptionProduct,@@ -814,7 +799,6 @@ export {// packages/trpc's auth/onboarding routers call `getUserById`/// `getUserAccount` directly through @openpanel/db's re-export shim, the same// way they reach every other dissolved service here.-export type { UserService } from './modules/user/user.service';export { createUserService } from './modules/user/user.service';import {@@ -839,7 +823,6 @@ export { isShuttingDown, setShuttingDown } from './modules/health/src/shutdown';// else reached it through @openpanel/db's barrel (same as cohort, M5-003).export type {ImportJobProgress,- ImportService,ImportStageResult,ImportSteps,InsertRawEventsResult,@@ -858,7 +841,6 @@ export type {IngestAuthOutcome,IngestBuffers,IngestHeaders,- IngestService,IngestTransport,TrackOutcome,TrackRequest,@@ -990,7 +972,7 @@ export {// `ctx.services.salt` / the v1-compat singleton instead (M10-004, see// salt.service.ts's header — `getSalts` is the one export still bare here,// for the same reason it's bare on the v1-compat seam).-export type { SaltService, Salts } from './modules/salt/salt.service';+export type { Salts } from './modules/salt/salt.service';export {createInitialSalts,createSaltService,diff --git a/packages/core/src/modules/assistant/assistant.service.ts b/packages/core/src/modules/assistant/assistant.service.tsindex f7e1d1e15..738be54ed 100644--- a/packages/core/src/modules/assistant/assistant.service.ts+++ b/packages/core/src/modules/assistant/assistant.service.ts@@ -79,14 +79,6 @@ export async function runFilterCommand(input: RunFilterCommandInput) {return run(input);}-export interface AssistantService {- getChatApp(): ReturnType<typeof getChatApp>;- getChatRunContext(): ReturnType<typeof getChatRunContext>;- runFilterCommand(- input: RunFilterCommandInput- ): ReturnType<typeof runFilterCommand>;-}-/*** Ignores BOTH arguments, and takes them only because ADR-022 R3 keeps the* composition root a flat list: the three members are `@better-agent/core`@@ -97,7 +89,7 @@ export interface AssistantService {export function createAssistantService(_deps: ServiceDeps,_services: () => Services-): AssistantService {+) {return {getChatApp,getChatRunContext,diff --git a/packages/core/src/modules/auth/auth.service.ts b/packages/core/src/modules/auth/auth.service.tsindex 2f89c0edf..411bb50c7 100644--- a/packages/core/src/modules/auth/auth.service.ts+++ b/packages/core/src/modules/auth/auth.service.ts@@ -54,7 +54,7 @@ import {// Re-exported straight from source (not through the imports above, which// exist for `createAuthService` below) — `noExportedImports` would otherwise// flag every one of those imports as "only re-exported", which is false;-// they are also this file's `AuthService` container.+// they are also the members `createAuthService` returns.export { COOKIE_MAX_AGE, COOKIE_OPTIONS } from './src/constants';export {deleteSessionTokenCookie,@@ -81,51 +81,14 @@ export {verifyTotpCode,} from './src/totp';-export interface AuthService extends AccessChecks<IProjectAccess> {- getProjectAccess(args: {- userId: string;- projectId: string;- }): Promise<IProjectAccess | null>;- getOrganizationAccess(- ...args: Parameters<typeof GetOrganizationAccessFn>- ): ReturnType<typeof GetOrganizationAccessFn>;- getClientAccess(- ...args: Parameters<typeof GetClientAccessFn>- ): ReturnType<typeof GetClientAccessFn>;- hashPassword(password: string): Promise<string>;- verifyPasswordHash(hash: string, password: string): Promise<boolean>;- generateSessionToken(): string;- decodeSessionToken(token: string): string | null;- hashSessionToken(token: string): string;- generateTotpSecret(): string;- buildOtpauthUrl(args: { secret: string; accountName: string }): string;- generateQrDataUrl(otpauthUrl: string): Promise<string>;- verifyTotpCode(secret: string, code: string): boolean;- generateRecoveryCodes(count?: number): string[];- hashRecoveryCodes(codes: string[]): Promise<string[]>;- normalizeRecoveryCode(input: string): string;- consumeRecoveryCode(args: {- hashes: string[];- input: string;- }): Promise<{ valid: boolean; remaining: string[] }>;- setSessionTokenCookie(- setCookie: ISetCookie,- token: string,- expiresAt: Date- ): void;- setLastAuthProviderCookie(setCookie: ISetCookie, provider: string): void;- deleteSessionTokenCookie(setCookie: ISetCookie): void;- parseCookieDomain(url: string): {- domain: string | undefined;- secure: boolean;- };-}-function loadAccessLookups() {return import('../../shared/access-lookups');}-let accessChecksPromise: Promise<AccessChecks<IProjectAccess>> | undefined;+/** The ladder contract this module binds and `createAuthService` satisfies. */+type ProjectAccessChecks = AccessChecks<IProjectAccess>;++let accessChecksPromise: Promise<ProjectAccessChecks> | undefined;/*** The single binding of `shared/access.ts`'s ladder to real lookups@@ -143,7 +106,7 @@ let accessChecksPromise: Promise<AccessChecks<IProjectAccess>> | undefined;* `ctx`, so they cannot reach a service. Operator-authorized (docs/TECH_DEBT.md* §5b); the exemption expires when `packages/trpc` dies at P10.*/-export function getAccessChecks(): Promise<AccessChecks<IProjectAccess>> {+export function getAccessChecks(): Promise<ProjectAccessChecks> {if (!accessChecksPromise) {accessChecksPromise = Promise.all([loadAccessLookups(),@@ -191,8 +154,11 @@ export function resetAccessChecksForTests(): void {export function createAuthService(_deps: ServiceDeps,_services: () => Services-): AuthService {- return {+) {+ // Annotated as a whole rather than member by member: one annotation binds+ // the ladder contract and gives all three members the explicit return type+ // `ReturnType<typeof createAuthService>` needs (ADR-022 R5).+ const accessChecks: ProjectAccessChecks = {async requireProjectAccess(args) {return (await getAccessChecks()).requireProjectAccess(args);},@@ -202,14 +168,25 @@ export function createAuthService(async requireProjectAdmin(args) {return (await getAccessChecks()).requireProjectAdmin(args);},- async getProjectAccess(args) {+ };++ return {+ ...accessChecks,+ async getProjectAccess(args: {+ userId: string;+ projectId: string;+ }): Promise<IProjectAccess | null> {return (await loadAccessLookups()).getProjectAccess(args);},- async getOrganizationAccess(args) {- return (await loadAccessLookups()).getOrganizationAccess(args);+ async getOrganizationAccess(+ ...args: Parameters<typeof GetOrganizationAccessFn>+ ): ReturnType<typeof GetOrganizationAccessFn> {+ return (await loadAccessLookups()).getOrganizationAccess(...args);},- async getClientAccess(args) {- return (await loadAccessLookups()).getClientAccess(args);+ async getClientAccess(+ ...args: Parameters<typeof GetClientAccessFn>+ ): ReturnType<typeof GetClientAccessFn> {+ return (await loadAccessLookups()).getClientAccess(...args);},hashPassword,verifyPasswordHash,diff --git a/packages/core/src/modules/chart/chart.service.test.ts b/packages/core/src/modules/chart/chart.service.test.tsindex 8b8099ec1..1a846b937 100644--- a/packages/core/src/modules/chart/chart.service.test.ts+++ b/packages/core/src/modules/chart/chart.service.test.ts@@ -30,7 +30,7 @@ mock.module('@openpanel/redis', () => ({}));let FIXTURE: typeof import('../../../../../test/fixtures').FIXTURE;-let service: import('./chart.service').ChartService;+let service: ReturnType<typeof import('./chart.service').createChartService>;let ch: typeof import('@openpanel/db/src/clickhouse/client').ch;type EventSeriesItem = Extract<IChartEventItem, { type: 'event' }>;diff --git a/packages/core/src/modules/chart/chart.service.ts b/packages/core/src/modules/chart/chart.service.tsindex 776fc481a..565c1230f 100644--- a/packages/core/src/modules/chart/chart.service.ts+++ b/packages/core/src/modules/chart/chart.service.ts@@ -18,7 +18,6 @@// ADR-013's `sql` tag, which ADR-007 keeps in `packages/db` by name: a// compile-time template tag, no client and no request scope.-import type { SqlFragment } from '@openpanel/db/src/clickhouse/sql';import { flatten, map, pipe, prop, sort, uniq } from 'ramda';import type { ServiceDeps, Services } from '../../services';import {@@ -45,32 +44,15 @@ import type { IServiceReport } from '../report/report.service';import { mergeGlobalFilters, onlyReportEvents } from '../report/src/series';import { createConversionService, getConversion } from './conversion.service';import {- type buildFunnelBase,- type buildSessionsCte,createFunnelService,getFunnel,- type getFunnelCore,- type getFunnelGroup,getFunnelProfileIds,- type toSeries as toFunnelSeries,} from './funnel.service';import {createRetentionService,- type getEngagementCore,getRetentionCohort,- type getRetentionCohortCore,- type getRetentionLastSeenSeries,- type getRetentionSeries,- type getRollingActiveUsers,- type getRollingActiveUsersCore,- type getWeeklyRetentionSeriesCore,- type processCohortData,} from './retention.service';-import {- createSankeyService,- getSankey,- type getUserFlowCore,-} from './sankey.service';+import { createSankeyService, getSankey } from './sankey.service';import {chartBucketProfilesQuery,eventFieldValuesQuery,@@ -750,109 +732,16 @@ export async function getFunnelStepProfiles(// The funnel, conversion, sankey and retention services live in this module's// own sibling files, not in modules of their own (ADR-007 gives one service-// per module), so they FOLD INTO `ChartService` rather than becoming four+// per module), so they FOLD INTO `chart` rather than becoming four// more `Services` members: chart.service.ts is already the dispatcher every// caller goes through (`getFunnelChart` / `getConversionChart` /// `getSankeyChart` / `getRetentionChart`), and a `Services` key per file// would name four things that are not modules.-export interface ChartService {- // chart- execute(input: IReportInput): Promise<FinalChart>;- executeAggregate(input: IReportInput): Promise<FinalChart>;- resolveReportInput(- report: NonNullable<IServiceReport> | null,- input: ShareableReportInput- ): IReportInput;- getProjectCard(projectId: string): ReturnType<typeof getProjectCard>;- listChartEvents(projectId: string): Promise<ChartEventOption[]>;- listChartProperties(- input: Parameters<typeof listChartProperties>[1]- ): Promise<string[]>;- getChartPropertyValues(- input: Parameters<typeof getChartPropertyValues>[1]- ): Promise<{ values: string[] }>;- bucketProfiles(input: ChartBucketProfilesRequest): Promise<IServiceProfile[]>;- funnelStepProfiles(- input: FunnelStepProfilesRequest- ): Promise<IServiceProfile[]>;- // funnel- getFunnelGroup(group?: string): ReturnType<typeof getFunnelGroup>;- /** The funnel row -> serie grouping (funnel.service.ts's `toSeries`). */- toFunnelSeries(- ...args: Parameters<typeof toFunnelSeries>- ): ReturnType<typeof toFunnelSeries>;- buildSessionsCte(- input: Parameters<typeof buildSessionsCte>[0]- ): ReturnType<typeof buildSessionsCte>;- getFunnelChart(chartInput: IReportInput): ReturnType<typeof getFunnelChart>;- getFunnel(- input: Parameters<typeof getFunnel>[1]- ): ReturnType<typeof getFunnel>;- getFunnelCore(- input: Parameters<typeof getFunnelCore>[1]- ): ReturnType<typeof getFunnelCore>;- buildFunnelBase(- input: Parameters<typeof buildFunnelBase>[1]- ): ReturnType<typeof buildFunnelBase>;- getFunnelProfileIds(- input: Parameters<typeof getFunnelProfileIds>[1]- ): Promise<string[]>;- // conversion- getConversionChart(- chartInput: IReportInput- ): ReturnType<typeof getConversionChart>;- getConversion(- input: Parameters<typeof getConversion>[1]- ): ReturnType<typeof getConversion>;- // sankey- getRawWhereClause(- type: 'events' | 'sessions',- filters: IChartEventFilter[]- ): SqlFragment | null;- getSankeyChart(input: IReportInput): ReturnType<typeof getSankeyChart>;- getSankey(- input: Parameters<typeof getSankey>[1]- ): ReturnType<typeof getSankey>;- getUserFlowCore(- input: Parameters<typeof getUserFlowCore>[1]- ): ReturnType<typeof getUserFlowCore>;- // retention- processCohortData(- ...args: Parameters<typeof processCohortData>- ): ReturnType<typeof processCohortData>;- getRetentionChart(- report: NonNullable<IServiceReport> | null,- input: RetentionChartInput- ): ReturnType<typeof getRetentionChart>;- getRetentionCohort(- input: Parameters<typeof getRetentionCohort>[1]- ): ReturnType<typeof getRetentionCohort>;- getRetentionCohortCore(- projectId: string- ): ReturnType<typeof getRetentionCohortCore>;- getRetentionSeries(- input: Parameters<typeof getRetentionSeries>[1]- ): ReturnType<typeof getRetentionSeries>;- getRetentionLastSeenSeries(- input: Parameters<typeof getRetentionLastSeenSeries>[1]- ): ReturnType<typeof getRetentionLastSeenSeries>;- getRollingActiveUsers(- input: Parameters<typeof getRollingActiveUsers>[1]- ): ReturnType<typeof getRollingActiveUsers>;- getRollingActiveUsersCore(- input: Parameters<typeof getRollingActiveUsersCore>[1]- ): ReturnType<typeof getRollingActiveUsersCore>;- getWeeklyRetentionSeriesCore(- projectId: string- ): ReturnType<typeof getWeeklyRetentionSeriesCore>;- getEngagementCore(projectId: string): ReturnType<typeof getEngagementCore>;-}-export function createChartService(deps: ServiceDeps,services: () => Services-): ChartService {+) {// The four chart sub-modules each expose their own `create*Service(deps)`// (ADR-007). `services.ts` binds each under its own key; `chart` composes// them as well, so the callers that reach a funnel/retention method through@@ -863,31 +752,58 @@ export function createChartService(const retention = createRetentionService(deps, services);return {- execute: (input) => executeChart(deps, input),- executeAggregate: (input) => executeAggregateChart(deps, input),+ // chart+ execute: (input: IReportInput): Promise<FinalChart> =>+ executeChart(deps, input),+ executeAggregate: (input: IReportInput): Promise<FinalChart> =>+ executeAggregateChart(deps, input),resolveReportInput,- getProjectCard: (projectId) => getProjectCard(deps, projectId),- listChartEvents: (projectId) => listChartEvents(deps, projectId),- listChartProperties: (input) => listChartProperties(deps, input),- getChartPropertyValues: (input) => getChartPropertyValues(deps, input),- bucketProfiles: (input) => getChartBucketProfiles(deps, input),- funnelStepProfiles: (input) => getFunnelStepProfiles(deps, input),+ getProjectCard: (projectId: string): ReturnType<typeof getProjectCard> =>+ getProjectCard(deps, projectId),+ listChartEvents: (projectId: string): Promise<ChartEventOption[]> =>+ listChartEvents(deps, projectId),+ listChartProperties: (+ input: Parameters<typeof listChartProperties>[1]+ ): Promise<string[]> => listChartProperties(deps, input),+ getChartPropertyValues: (+ input: Parameters<typeof getChartPropertyValues>[1]+ ): Promise<{ values: string[] }> => getChartPropertyValues(deps, input),+ bucketProfiles: (+ input: ChartBucketProfilesRequest+ ): Promise<IServiceProfile[]> => getChartBucketProfiles(deps, input),+ funnelStepProfiles: (+ input: FunnelStepProfilesRequest+ ): Promise<IServiceProfile[]> => getFunnelStepProfiles(deps, input),+ // funnelgetFunnelGroup: funnel.getFunnelGroup,+ /** The funnel row -> serie grouping (funnel.service.ts's `toSeries`). */toFunnelSeries: funnel.toSeries,buildSessionsCte: funnel.buildSessionsCte,- getFunnelChart: (chartInput) => getFunnelChart(deps, chartInput),+ getFunnelChart: (+ chartInput: IReportInput+ ): ReturnType<typeof getFunnelChart> => getFunnelChart(deps, chartInput),getFunnel: funnel.getFunnel,getFunnelCore: funnel.getFunnelCore,buildFunnelBase: funnel.buildFunnelBase,getFunnelProfileIds: funnel.getFunnelProfileIds,- getConversionChart: (chartInput) => getConversionChart(deps, chartInput),+ // conversion+ getConversionChart: (+ chartInput: IReportInput+ ): ReturnType<typeof getConversionChart> =>+ getConversionChart(deps, chartInput),getConversion: conversion.getConversion,+ // sankeygetRawWhereClause: sankey.getRawWhereClause,- getSankeyChart: (input) => getSankeyChart(deps, input),+ getSankeyChart: (input: IReportInput): ReturnType<typeof getSankeyChart> =>+ getSankeyChart(deps, input),getSankey: sankey.getSankey,getUserFlowCore: sankey.getUserFlowCore,+ // retentionprocessCohortData: retention.processCohortData,- getRetentionChart: (report, input) =>+ getRetentionChart: (+ report: NonNullable<IServiceReport> | null,+ input: RetentionChartInput+ ): ReturnType<typeof getRetentionChart> =>getRetentionChart(deps, report, input),getRetentionCohort: retention.getRetentionCohort,getRetentionCohortCore: retention.getRetentionCohortCore,diff --git a/packages/core/src/modules/chart/conversion.service.ts b/packages/core/src/modules/chart/conversion.service.tsindex e63de2f07..7b39900ee 100644--- a/packages/core/src/modules/chart/conversion.service.ts+++ b/packages/core/src/modules/chart/conversion.service.ts@@ -267,17 +267,13 @@ function toSeries(/** See funnel.service.ts's `createFunnelService` for why each chart* sub-module carries its own factory (M10-009, ADR-007). */-export interface ConversionService {- getConversion(- input: Parameters<typeof getConversion>[1]- ): ReturnType<typeof getConversion>;-}-export function createConversionService(deps: ServiceDeps,_services: () => Services-): ConversionService {+) {return {- getConversion: (input) => getConversion(deps, input),+ getConversion: (+ input: Parameters<typeof getConversion>[1]+ ): ReturnType<typeof getConversion> => getConversion(deps, input),};}diff --git a/packages/core/src/modules/chart/funnel.service.ts b/packages/core/src/modules/chart/funnel.service.tsindex f46aca296..cebba69d3 100644--- a/packages/core/src/modules/chart/funnel.service.ts+++ b/packages/core/src/modules/chart/funnel.service.ts@@ -433,40 +433,31 @@ export async function getFunnelProfileIds(/*** `ctx.services.chart`'s funnel half, as its own module factory (ADR-007:- * "each service is `createXService(deps): XService`"). `createChartService`- * composes this rather than re-binding these functions itself, so the chart- * module keeps one registry key while every `*.service.ts` file exposes its- * own factory (M10-009).+ * "each service is `createXService(deps)`"). `createChartService` composes+ * this rather than re-binding these functions itself, so the chart module+ * keeps one registry key while every `*.service.ts` file exposes its own+ * factory (M10-009).*/-export interface FunnelService {- getFunnelGroup: typeof getFunnelGroup;- toSeries: typeof toSeries;- buildSessionsCte: typeof buildSessionsCte;- getFunnel(- input: Parameters<typeof getFunnel>[1]- ): ReturnType<typeof getFunnel>;- getFunnelCore(- input: Parameters<typeof getFunnelCore>[1]- ): ReturnType<typeof getFunnelCore>;- buildFunnelBase(- input: Parameters<typeof buildFunnelBase>[1]- ): ReturnType<typeof buildFunnelBase>;- getFunnelProfileIds(- input: Parameters<typeof getFunnelProfileIds>[1]- ): ReturnType<typeof getFunnelProfileIds>;-}-export function createFunnelService(deps: ServiceDeps,_services: () => Services-): FunnelService {+) {return {getFunnelGroup,toSeries,buildSessionsCte,- getFunnel: (input) => getFunnel(deps, input),- getFunnelCore: (input) => getFunnelCore(deps, input),- buildFunnelBase: (input) => buildFunnelBase(deps, input),- getFunnelProfileIds: (input) => getFunnelProfileIds(deps, input),+ getFunnel: (+ input: Parameters<typeof getFunnel>[1]+ ): ReturnType<typeof getFunnel> => getFunnel(deps, input),+ getFunnelCore: (+ input: Parameters<typeof getFunnelCore>[1]+ ): ReturnType<typeof getFunnelCore> => getFunnelCore(deps, input),+ buildFunnelBase: (+ input: Parameters<typeof buildFunnelBase>[1]+ ): ReturnType<typeof buildFunnelBase> => buildFunnelBase(deps, input),+ getFunnelProfileIds: (+ input: Parameters<typeof getFunnelProfileIds>[1]+ ): ReturnType<typeof getFunnelProfileIds> =>+ getFunnelProfileIds(deps, input),};}diff --git a/packages/core/src/modules/chart/retention.service.ts b/packages/core/src/modules/chart/retention.service.tsindex 56232bf23..14c72053c 100644--- a/packages/core/src/modules/chart/retention.service.ts+++ b/packages/core/src/modules/chart/retention.service.ts@@ -393,49 +393,41 @@ export function processCohortData(/** See funnel.service.ts's `createFunnelService` for why each chart* sub-module carries its own factory (M10-009, ADR-007). */-export interface RetentionService {- processCohortData: typeof processCohortData;- getRetentionCohort(- input: Parameters<typeof getRetentionCohort>[1]- ): ReturnType<typeof getRetentionCohort>;- getRetentionCohortCore(- projectId: string- ): ReturnType<typeof getRetentionCohortCore>;- getRetentionSeries(- input: Parameters<typeof getRetentionSeries>[1]- ): ReturnType<typeof getRetentionSeries>;- getRetentionLastSeenSeries(- input: Parameters<typeof getRetentionLastSeenSeries>[1]- ): ReturnType<typeof getRetentionLastSeenSeries>;- getRollingActiveUsers(- input: Parameters<typeof getRollingActiveUsers>[1]- ): ReturnType<typeof getRollingActiveUsers>;- getRollingActiveUsersCore(- input: Parameters<typeof getRollingActiveUsersCore>[1]- ): ReturnType<typeof getRollingActiveUsersCore>;- getWeeklyRetentionSeriesCore(- projectId: string- ): ReturnType<typeof getWeeklyRetentionSeriesCore>;- getEngagementCore(projectId: string): ReturnType<typeof getEngagementCore>;-}-export function createRetentionService(deps: ServiceDeps,_services: () => Services-): RetentionService {+) {return {processCohortData,- getRetentionCohort: (input) => getRetentionCohort(deps, input),- getRetentionCohortCore: (projectId) =>+ getRetentionCohort: (+ input: Parameters<typeof getRetentionCohort>[1]+ ): ReturnType<typeof getRetentionCohort> => getRetentionCohort(deps, input),+ getRetentionCohortCore: (+ projectId: string+ ): ReturnType<typeof getRetentionCohortCore> =>getRetentionCohortCore(deps, projectId),- getRetentionSeries: (input) => getRetentionSeries(deps, input),- getRetentionLastSeenSeries: (input) =>+ getRetentionSeries: (+ input: Parameters<typeof getRetentionSeries>[1]+ ): ReturnType<typeof getRetentionSeries> => getRetentionSeries(deps, input),+ getRetentionLastSeenSeries: (+ input: Parameters<typeof getRetentionLastSeenSeries>[1]+ ): ReturnType<typeof getRetentionLastSeenSeries> =>getRetentionLastSeenSeries(deps, input),- getRollingActiveUsers: (input) => getRollingActiveUsers(deps, input),- getRollingActiveUsersCore: (input) =>+ getRollingActiveUsers: (+ input: Parameters<typeof getRollingActiveUsers>[1]+ ): ReturnType<typeof getRollingActiveUsers> =>+ getRollingActiveUsers(deps, input),+ getRollingActiveUsersCore: (+ input: Parameters<typeof getRollingActiveUsersCore>[1]+ ): ReturnType<typeof getRollingActiveUsersCore> =>getRollingActiveUsersCore(deps, input),- getWeeklyRetentionSeriesCore: (projectId) =>+ getWeeklyRetentionSeriesCore: (+ projectId: string+ ): ReturnType<typeof getWeeklyRetentionSeriesCore> =>getWeeklyRetentionSeriesCore(deps, projectId),- getEngagementCore: (projectId) => getEngagementCore(deps, projectId),+ getEngagementCore: (+ projectId: string+ ): ReturnType<typeof getEngagementCore> =>+ getEngagementCore(deps, projectId),};}diff --git a/packages/core/src/modules/chart/sankey.service.ts b/packages/core/src/modules/chart/sankey.service.tsindex 107fae23e..9f46aae6c 100644--- a/packages/core/src/modules/chart/sankey.service.ts+++ b/packages/core/src/modules/chart/sankey.service.ts@@ -521,23 +521,17 @@ export async function getUserFlowCore(/** See funnel.service.ts's `createFunnelService` for why each chart* sub-module carries its own factory (M10-009, ADR-007). */-export interface SankeyService {- getRawWhereClause: typeof getRawWhereClause;- getSankey(- input: Parameters<typeof getSankey>[1]- ): ReturnType<typeof getSankey>;- getUserFlowCore(- input: Parameters<typeof getUserFlowCore>[1]- ): ReturnType<typeof getUserFlowCore>;-}-export function createSankeyService(deps: ServiceDeps,_services: () => Services-): SankeyService {+) {return {getRawWhereClause,- getSankey: (input) => getSankey(deps, input),- getUserFlowCore: (input) => getUserFlowCore(deps, input),+ getSankey: (+ input: Parameters<typeof getSankey>[1]+ ): ReturnType<typeof getSankey> => getSankey(deps, input),+ getUserFlowCore: (+ input: Parameters<typeof getUserFlowCore>[1]+ ): ReturnType<typeof getUserFlowCore> => getUserFlowCore(deps, input),};}diff --git a/packages/core/src/modules/client/client.service.test.ts b/packages/core/src/modules/client/client.service.test.tsindex 2ca7ddc9d..912621607 100644--- a/packages/core/src/modules/client/client.service.test.ts+++ b/packages/core/src/modules/client/client.service.test.ts@@ -138,7 +138,7 @@ mock.module('@openpanel/redis', () => ({}),}));-let subject: import('./client.service').ClientService;+let subject: ReturnType<typeof import('./client.service').createClientService>;beforeAll(async () => {const { createClientService } = await import('./client.service');subject = createClientService(diff --git a/packages/core/src/modules/client/client.service.ts b/packages/core/src/modules/client/client.service.tsindex 8768c8e68..d3ada79d4 100644--- a/packages/core/src/modules/client/client.service.ts+++ b/packages/core/src/modules/client/client.service.ts@@ -127,51 +127,10 @@ export interface CreatedClient {secret: string;}-export interface ClientService {- getClientsByOrganizationId(- organizationId: string- ): ReturnType<typeof getClientsByOrganizationId>;- getClientsByProjectId(- projectId: string- ): ReturnType<typeof getClientsByProjectId>;- getClientById(id: string): ReturnType<typeof getClientById>;- getClientByIdCached(id: string): Promise<IServiceClientWithProject | null>;- /** Invalidates a single id in `getClientByIdCached`'s L1 LRU + Redis. Its- * own create/update/delete already call this; `project.service.ts`- * reaches it too, through the v1-compat singleton, to invalidate a- * project's clients on a project mutation — see that file's header. */- clearClientByIdCache(id: string): Promise<number>;- listClientsForOrganization(- organizationId: string,- projectId?: string- ): ReturnType<typeof listClientsForOrganization>;- getClientForOrganization(- id: string,- organizationId: string- ): ReturnType<typeof getClientForOrganization>;- createClientForOrganization(- organizationId: string,- input: {- name: string;- projectId?: string | null;- type?: 'read' | 'write' | 'root';- }- ): Promise<CreatedClient | null>;- updateClientForOrganization(- id: string,- organizationId: string,- input: { name?: string }- ): Promise<IServiceClient | null>;- deleteClientForOrganization(- id: string,- organizationId: string- ): Promise<boolean>;-}-export function createClientService(deps: ServiceDeps,_services: () => Services-): ClientService {+) {/** L1 LRU (60s) + L2 Redis. clear() invalidates Redis + local LRU; other nodes may serve stale from LRU for up to 60s. */const getClientByIdCached = cacheable((id: string) => getClientById(deps, id),@@ -258,16 +217,34 @@ export function createClientService(}return {- getClientsByOrganizationId: (organizationId) =>+ getClientsByOrganizationId: (+ organizationId: string+ ): ReturnType<typeof getClientsByOrganizationId> =>getClientsByOrganizationId(deps, organizationId),- getClientsByProjectId: (projectId) =>+ getClientsByProjectId: (+ projectId: string+ ): ReturnType<typeof getClientsByProjectId> =>getClientsByProjectId(deps, projectId),- getClientById: (id) => getClientById(deps, id),- getClientByIdCached: (id) => getClientByIdCached(id),- clearClientByIdCache: (id) => getClientByIdCached.clear(id),- listClientsForOrganization: (organizationId, projectId) =>+ getClientById: (id: string): ReturnType<typeof getClientById> =>+ getClientById(deps, id),+ getClientByIdCached: (+ id: string+ ): Promise<IServiceClientWithProject | null> => getClientByIdCached(id),+ /** Invalidates a single id in `getClientByIdCached`'s L1 LRU + Redis. Its+ * own create/update/delete already call this; `project.service.ts`+ * reaches it too, through the v1-compat singleton, to invalidate a+ * project's clients on a project mutation — see that file's header. */+ clearClientByIdCache: (id: string): Promise<number> =>+ getClientByIdCached.clear(id),+ listClientsForOrganization: (+ organizationId: string,+ projectId?: string+ ): ReturnType<typeof listClientsForOrganization> =>listClientsForOrganization(deps, organizationId, projectId),- getClientForOrganization: (id, organizationId) =>+ getClientForOrganization: (+ id: string,+ organizationId: string+ ): ReturnType<typeof getClientForOrganization> =>getClientForOrganization(deps, id, organizationId),createClientForOrganization,updateClientForOrganization,diff --git a/packages/core/src/modules/cohort/cohort.jobs.test.ts b/packages/core/src/modules/cohort/cohort.jobs.test.tsindex c1a74e3e0..8d72967d6 100644--- a/packages/core/src/modules/cohort/cohort.jobs.test.ts+++ b/packages/core/src/modules/cohort/cohort.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { cohortCronJobs, cohortQueueJobs } from './cohort.jobs';-import type { CohortService } from './cohort.service';+import type { createCohortService } from './cohort.service';function stubLogger(): Logger {const noop = () => undefined;@@ -24,7 +24,10 @@ function stubLogger(): Logger {return logger;}-function stubJobCtx(cohort: Partial<CohortService>, jobName = 'test'): JobCtx {+function stubJobCtx(+ cohort: Partial<ReturnType<typeof createCohortService>>,+ jobName = 'test'+): JobCtx {const services: Services = {auth: {} as Services['auth'],notification: {} as Services['notification'],@@ -33,7 +36,7 @@ function stubJobCtx(cohort: Partial<CohortService>, jobName = 'test'): JobCtx {gsc: {} as Services['gsc'],import: {} as Services['import'],ingest: {} as Services['ingest'],- cohort: cohort as CohortService,+ cohort: cohort as ReturnType<typeof createCohortService>,organization: {} as Services['organization'],onboarding: {} as Services['onboarding'],session: {} as Services['session'],diff --git a/packages/core/src/modules/cohort/cohort.service.ts b/packages/core/src/modules/cohort/cohort.service.tsindex 1796d9689..065b50834 100644--- a/packages/core/src/modules/cohort/cohort.service.ts+++ b/packages/core/src/modules/cohort/cohort.service.ts@@ -1019,33 +1019,29 @@ export async function getCohortMemberRoutes();}-export interface CohortService {- updateMembership(cohortId: string): Promise<void>;- listRefreshableCohortIds(): Promise<string[]>;- /**- * Enqueue a recompute for a cohort.- *- * Uses `deduplicationId` rather than `jobId`. A fixed jobId makes BullMQ- * short-circuit `add` for as long as *any* record for that id exists in- * Redis — and `removeOnComplete: { age }` is not a TTL, it only trims on- * some other job in the queue finishing. That deadlocks: nothing can be- * added because the completed record is still there, and the record is- * never collected because nothing gets added. `deduplicationId`, in- * contrast, is released by `moveToFinished` on both completion and- * terminal failure, so it only collapses a compute that is genuinely still- * in flight (ADR-005: "cohort must NOT be normalised onto jobId").- */- enqueueCompute(cohortId: string): Promise<void>;-}-export function createCohortService(deps: ServiceDeps,_services: () => Services-): CohortService {+) {return {- updateMembership: (cohortId) => updateCohortMembership(deps, cohortId),- listRefreshableCohortIds: () => listRefreshableCohortIds(deps),- enqueueCompute: async (cohortId) => {+ updateMembership: (cohortId: string): Promise<void> =>+ updateCohortMembership(deps, cohortId),+ listRefreshableCohortIds: (): Promise<string[]> =>+ listRefreshableCohortIds(deps),+ /**+ * Enqueue a recompute for a cohort.+ *+ * Uses `deduplicationId` rather than `jobId`. A fixed jobId makes BullMQ+ * short-circuit `add` for as long as *any* record for that id exists in+ * Redis — and `removeOnComplete: { age }` is not a TTL, it only trims on+ * some other job in the queue finishing. That deadlocks: nothing can be+ * added because the completed record is still there, and the record is+ * never collected because nothing gets added. `deduplicationId`, in+ * contrast, is released by `moveToFinished` on both completion and+ * terminal failure, so it only collapses a compute that is genuinely still+ * in flight (ADR-005: "cohort must NOT be normalised onto jobId").+ */+ enqueueCompute: async (cohortId: string): Promise<void> => {await deps.queues.cohortCompute.cohortCompute.add({ cohortId },{ deduplicationId: `cohort-${cohortId}` }diff --git a/packages/core/src/modules/conversation/conversation.service.ts b/packages/core/src/modules/conversation/conversation.service.tsindex 9989ceb79..06dc6d9f3 100644--- a/packages/core/src/modules/conversation/conversation.service.ts+++ b/packages/core/src/modules/conversation/conversation.service.ts@@ -93,29 +93,23 @@ export async function deleteConversation(await deps.db.conversation.delete({ where: { id } });}-export interface ConversationService {- getConversationById(- id: string,- options?: { withMessages?: boolean }- ): ReturnType<typeof getConversationById>;- listConversations(- input: Parameters<typeof listConversations>[1]- ): Promise<IServiceConversation[]>;- upsertConversationTitle(- input: Parameters<typeof upsertConversationTitle>[1]- ): Promise<IServiceConversation>;- deleteConversation(id: string): Promise<void>;-}-export function createConversationService(deps: ServiceDeps,_services: () => Services-): ConversationService {+) {return {- getConversationById: (id, options) =>+ getConversationById: (+ id: string,+ options?: { withMessages?: boolean }+ ): ReturnType<typeof getConversationById> =>getConversationById(deps, id, options),- listConversations: (input) => listConversations(deps, input),- upsertConversationTitle: (input) => upsertConversationTitle(deps, input),- deleteConversation: (id) => deleteConversation(deps, id),+ listConversations: (+ input: Parameters<typeof listConversations>[1]+ ): Promise<IServiceConversation[]> => listConversations(deps, input),+ upsertConversationTitle: (+ input: Parameters<typeof upsertConversationTitle>[1]+ ): Promise<IServiceConversation> => upsertConversationTitle(deps, input),+ deleteConversation: (id: string): Promise<void> =>+ deleteConversation(deps, id),};}diff --git a/packages/core/src/modules/dashboard/dashboard.service.ts b/packages/core/src/modules/dashboard/dashboard.service.tsindex 570c58fbe..7160153a7 100644--- a/packages/core/src/modules/dashboard/dashboard.service.ts+++ b/packages/core/src/modules/dashboard/dashboard.service.ts@@ -160,37 +160,36 @@ export async function deleteDashboard(}}-export interface DashboardService {- getDashboardById(- id: string,- projectId: string- ): Promise<DashboardWithProject | null>;- getDashboardByIdOrThrow(id: string): Promise<Dashboard>;- getDashboardsByProjectId(projectId: string): Promise<IServiceDashboards>;- listDashboardsCore(input: {- projectId: string;- organizationId: string;- }): Promise<DashboardListItem[]>;- createDashboard(input: {- name: string;- projectId: string;- }): Promise<Dashboard>;- updateDashboard(input: { id: string; name: string }): Promise<Dashboard>;- deleteDashboard(input: { id: string; forceDelete?: boolean }): Promise<void>;-}-export function createDashboardService(deps: ServiceDeps,_services: () => Services-): DashboardService {+) {return {- getDashboardById: (id, projectId) => getDashboardById(deps, id, projectId),- getDashboardByIdOrThrow: (id) => getDashboardByIdOrThrow(deps, id),- getDashboardsByProjectId: (projectId) =>- getDashboardsByProjectId(deps, projectId),- listDashboardsCore: (input) => listDashboardsCore(deps, input),- createDashboard: (input) => createDashboard(deps, input),- updateDashboard: (input) => updateDashboard(deps, input),- deleteDashboard: (input) => deleteDashboard(deps, input),+ getDashboardById: (+ id: string,+ projectId: string+ ): Promise<DashboardWithProject | null> =>+ getDashboardById(deps, id, projectId),+ getDashboardByIdOrThrow: (id: string): Promise<Dashboard> =>+ getDashboardByIdOrThrow(deps, id),+ getDashboardsByProjectId: (+ projectId: string+ ): Promise<IServiceDashboards> => getDashboardsByProjectId(deps, projectId),+ listDashboardsCore: (input: {+ projectId: string;+ organizationId: string;+ }): Promise<DashboardListItem[]> => listDashboardsCore(deps, input),+ createDashboard: (input: {+ name: string;+ projectId: string;+ }): Promise<Dashboard> => createDashboard(deps, input),+ updateDashboard: (input: {+ id: string;+ name: string;+ }): Promise<Dashboard> => updateDashboard(deps, input),+ deleteDashboard: (input: {+ id: string;+ forceDelete?: boolean;+ }): Promise<void> => deleteDashboard(deps, input),};}diff --git a/packages/core/src/modules/event/event.service.ts b/packages/core/src/modules/event/event.service.tsindex be265e21d..b8b9b6660 100644--- a/packages/core/src/modules/event/event.service.ts+++ b/packages/core/src/modules/event/event.service.ts@@ -1322,23 +1322,18 @@ export async function getTopOrigins(deps: ServiceDeps, projectId: string) {);}-export interface EventService {- getById(input: {- projectId: string;- id: string;- createdAt?: Date;- }): Promise<IServiceEvent | null>;- create(- payload: IServiceCreateEventPayloadWithId- ): Promise<{ document: IClickhouseEvent }>;-}-export function createEventService(deps: ServiceDeps,_services: () => Services-): EventService {+) {return {- getById: (input) => getEventById(deps, input),- create: (payload) => createEvent(deps, payload),+ getById: (input: {+ projectId: string;+ id: string;+ createdAt?: Date;+ }): Promise<IServiceEvent | null> => getEventById(deps, input),+ create: (+ payload: IServiceCreateEventPayloadWithId+ ): Promise<{ document: IClickhouseEvent }> => createEvent(deps, payload),};}diff --git a/packages/core/src/modules/export/export.service.ts b/packages/core/src/modules/export/export.service.tsindex d325f13b4..6fe81ee6b 100644--- a/packages/core/src/modules/export/export.service.ts+++ b/packages/core/src/modules/export/export.service.ts@@ -118,30 +118,21 @@ export async function resolveInsightsDateRange(// --- service -------------------------------------------------------------export interface ExportService {- resolveExportProjectId(- client: AuthenticatedClient,- query: { project_id?: string; projectId?: string }- ): Promise<ProjectIdResolution>;- resolveInsightsProjectId(- client: AuthenticatedClient,- params: { projectId?: string }- ): Promise<string>;- resolveInsightsDateRange(- projectId: string,- data: { startDate?: string; endDate?: string; range?: IChartRange }- ): Promise<{ startDate: string; endDate: string }>;-}-export function createExportService(deps: ServiceDeps,_services: () => Services-): ExportService {+) {return {- resolveExportProjectId: (client, query) =>+ resolveExportProjectId: (+ client: AuthenticatedClient,+ query: { project_id?: string; projectId?: string }+ ): Promise<ProjectIdResolution> =>resolveExportProjectId(deps, client, query),resolveInsightsProjectId,- resolveInsightsDateRange: (projectId, data) =>+ resolveInsightsDateRange: (+ projectId: string,+ data: { startDate?: string; endDate?: string; range?: IChartRange }+ ): Promise<{ startDate: string; endDate: string }> =>resolveInsightsDateRange(deps, projectId, data),};}diff --git a/packages/core/src/modules/group/group.service.ts b/packages/core/src/modules/group/group.service.tsindex 31a906f73..640d646b8 100644--- a/packages/core/src/modules/group/group.service.ts+++ b/packages/core/src/modules/group/group.service.ts@@ -516,17 +516,14 @@ export async function getGroupCore(};}-export interface GroupService {- byId(id: string, projectId: string): Promise<IServiceGroup | null>;- upsert(input: IServiceUpsertGroup): Promise<void>;-}-export function createGroupService(deps: ServiceDeps,_services: () => Services-): GroupService {+) {return {- byId: (id, projectId) => getGroupById(deps, id, projectId),- upsert: (input) => upsertGroup(deps, input),+ byId: (id: string, projectId: string): Promise<IServiceGroup | null> =>+ getGroupById(deps, id, projectId),+ upsert: (input: IServiceUpsertGroup): Promise<void> =>+ upsertGroup(deps, input),};}diff --git a/packages/core/src/modules/gsc/gsc.jobs.test.ts b/packages/core/src/modules/gsc/gsc.jobs.test.tsindex 67974017e..bc58476de 100644--- a/packages/core/src/modules/gsc/gsc.jobs.test.ts+++ b/packages/core/src/modules/gsc/gsc.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { gscCronJobs, gscQueueJobs } from './gsc.jobs';-import type { GscService } from './gsc.service';+import type { createGscService } from './gsc.service';function stubLogger(): Logger {const noop = () => undefined;@@ -24,7 +24,10 @@ function stubLogger(): Logger {return logger;}-function stubJobCtx(gsc: Partial<GscService>, jobName = 'test'): JobCtx {+function stubJobCtx(+ gsc: Partial<ReturnType<typeof createGscService>>,+ jobName = 'test'+): JobCtx {const services: Services = {auth: {} as Services['auth'],notification: {} as Services['notification'],@@ -33,7 +36,7 @@ function stubJobCtx(gsc: Partial<GscService>, jobName = 'test'): JobCtx {cohort: {} as Services['cohort'],import: {} as Services['import'],ingest: {} as Services['ingest'],- gsc: gsc as GscService,+ gsc: gsc as ReturnType<typeof createGscService>,organization: {} as Services['organization'],onboarding: {} as Services['onboarding'],session: {} as Services['session'],@@ -161,7 +164,7 @@ test('gscSync fans out one gscProjectSync enqueue per connected project', async{ projectId: 'p1' },{ projectId: 'p2' },],- } as GscService,+ } as ReturnType<typeof createGscService>,organization: {} as Services['organization'],onboarding: {} as Services['onboarding'],session: {} as Services['session'],diff --git a/packages/core/src/modules/gsc/gsc.service.ts b/packages/core/src/modules/gsc/gsc.service.tsindex 7caa0612c..46442d4a5 100644--- a/packages/core/src/modules/gsc/gsc.service.ts+++ b/packages/core/src/modules/gsc/gsc.service.ts@@ -1475,59 +1475,59 @@ type WithoutDeps<T extends (deps: ServiceDeps, ...args: never[]) => unknown> =? (...args: A) => R: never;-export interface GscService {- getConnection(projectId: string): Promise<GscConnectionSummary | null>;- listSites(projectId: string): Promise<GscSite[]>;- /** Also enqueues the `gscProjectBackfill` job — same as V1's router. */- selectSite(projectId: string, siteUrl: string): Promise<void>;- disconnect(projectId: string): Promise<void>;- resolveDateRange(- projectId: string,- input: GscDateRangeInput- ): ReturnType<typeof resolveGscDateRange>;- getOverview: WithoutDeps<typeof getGscOverview>;- getPreviousOverview: WithoutDeps<typeof getGscPreviousOverview>;- getPages: WithoutDeps<typeof getGscPages>;- getPageDetails: WithoutDeps<typeof getGscPageDetails>;- getQueryDetails: WithoutDeps<typeof getGscQueryDetails>;- getQueries: WithoutDeps<typeof getGscQueries>;- getSearchEngines: WithoutDeps<typeof getGscSearchEngines>;- getAiEngines: WithoutDeps<typeof getGscAiEngines>;- getCannibalization: typeof getGscCannibalization;- listConnectionsForSync(): Promise<{ projectId: string }[]>;- runProjectSync(projectId: string): Promise<void>;- runProjectBackfill(projectId: string): Promise<void>;-}-/** `ctx.services.gsc` — a thin binding of the functions above to a Ctx's logger/queues. */-export function createGscService(- deps: ServiceDeps,- _services: () => Services-): GscService {+export function createGscService(deps: ServiceDeps, _services: () => Services) {const logger = deps.logger.child({ module: 'gsc' });+ const getOverview: WithoutDeps<typeof getGscOverview> = (...args) =>+ getGscOverview(deps, ...args);+ const getPreviousOverview: WithoutDeps<typeof getGscPreviousOverview> = (+ ...args+ ) => getGscPreviousOverview(deps, ...args);+ const getPages: WithoutDeps<typeof getGscPages> = (...args) =>+ getGscPages(deps, ...args);+ const getPageDetails: WithoutDeps<typeof getGscPageDetails> = (...args) =>+ getGscPageDetails(deps, ...args);+ const getQueryDetails: WithoutDeps<typeof getGscQueryDetails> = (...args) =>+ getGscQueryDetails(deps, ...args);+ const getQueries: WithoutDeps<typeof getGscQueries> = (...args) =>+ getGscQueries(deps, ...args);+ const getSearchEngines: WithoutDeps<typeof getGscSearchEngines> = (...args) =>+ getGscSearchEngines(deps, ...args);+ const getAiEngines: WithoutDeps<typeof getGscAiEngines> = (...args) =>+ getGscAiEngines(deps, ...args);+return {- getConnection: (projectId) => getGscConnection(deps, projectId),- listSites: (projectId) => listGscSites(deps, projectId),- selectSite: async (projectId, siteUrl) => {+ getConnection: (projectId: string): Promise<GscConnectionSummary | null> =>+ getGscConnection(deps, projectId),+ listSites: (projectId: string): Promise<GscSite[]> =>+ listGscSites(deps, projectId),+ /** Also enqueues the `gscProjectBackfill` job — same as V1's router. */+ selectSite: async (projectId: string, siteUrl: string): Promise<void> => {await selectGscSite(deps, projectId, siteUrl);await deps.queues.gsc.gscProjectBackfill.add({ projectId });},- disconnect: (projectId) => disconnectGscConnection(deps, projectId),- resolveDateRange: (projectId, input) =>+ disconnect: (projectId: string): Promise<void> =>+ disconnectGscConnection(deps, projectId),+ resolveDateRange: (+ projectId: string,+ input: GscDateRangeInput+ ): ReturnType<typeof resolveGscDateRange> =>resolveGscDateRange(deps, projectId, input),- getOverview: (...args) => getGscOverview(deps, ...args),- getPreviousOverview: (...args) => getGscPreviousOverview(deps, ...args),- getPages: (...args) => getGscPages(deps, ...args),- getPageDetails: (...args) => getGscPageDetails(deps, ...args),- getQueryDetails: (...args) => getGscQueryDetails(deps, ...args),- getQueries: (...args) => getGscQueries(deps, ...args),- getSearchEngines: (...args) => getGscSearchEngines(deps, ...args),- getAiEngines: (...args) => getGscAiEngines(deps, ...args),+ getOverview,+ getPreviousOverview,+ getPages,+ getPageDetails,+ getQueryDetails,+ getQueries,+ getSearchEngines,+ getAiEngines,getCannibalization: getGscCannibalization,- listConnectionsForSync: () => listGscConnectionsForSync(deps),- runProjectSync: (projectId) => runGscProjectSync(deps, projectId, logger),- runProjectBackfill: (projectId) =>+ listConnectionsForSync: (): Promise<{ projectId: string }[]> =>+ listGscConnectionsForSync(deps),+ runProjectSync: (projectId: string): Promise<void> =>+ runGscProjectSync(deps, projectId, logger),+ runProjectBackfill: (projectId: string): Promise<void> =>runGscProjectBackfill(deps, projectId, logger),};}diff --git a/packages/core/src/modules/import/import.jobs.test.ts b/packages/core/src/modules/import/import.jobs.test.tsindex 52219c4d6..0ecbd9236 100644--- a/packages/core/src/modules/import/import.jobs.test.ts+++ b/packages/core/src/modules/import/import.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { importQueueJobs } from './import.jobs';-import type { ImportService } from './import.service';+import type { createImportService } from './import.service';function stubLogger(): Logger {const noop = () => undefined;@@ -24,7 +24,9 @@ function stubLogger(): Logger {return logger;}-function stubJobCtx(importService: Partial<ImportService>): JobCtx {+function stubJobCtx(+ importService: Partial<ReturnType<typeof createImportService>>+): JobCtx {const services: Services = {auth: {} as Services['auth'],notification: {} as Services['notification'],@@ -33,7 +35,7 @@ function stubJobCtx(importService: Partial<ImportService>): JobCtx {cohort: {} as Services['cohort'],ingest: {} as Services['ingest'],gsc: {} as Services['gsc'],- import: importService as ImportService,+ import: importService as ReturnType<typeof createImportService>,organization: {} as Services['organization'],onboarding: {} as Services['onboarding'],session: {} as Services['session'],diff --git a/packages/core/src/modules/import/import.service.ts b/packages/core/src/modules/import/import.service.tsindex 175b040c3..f31eba621 100644--- a/packages/core/src/modules/import/import.service.ts+++ b/packages/core/src/modules/import/import.service.ts@@ -1232,24 +1232,21 @@ export async function insertRawEventsBatch(// `ctx.services.import` binding.// ----------------------------------------------------------------------------export interface ImportService {- run(- importId: string,- progress?: ImportJobProgress- ): Promise<{ success: true }>;- /** Enqueues the `import` job and returns its BullMQ job id, for `Import.jobId`. */- enqueue(importId: string): Promise<string>;-}-/** `ctx.services.import` — a thin binding of the job body above to a Ctx's queues. */export function createImportService(deps: ServiceDeps,_services: () => Services-): ImportService {+) {const logger = deps.logger.child({ module: 'import' });return {- run: (importId, progress) => runImportJob(deps, importId, progress, logger),- enqueue: (importId) => deps.queues.import.import.add({ importId }),+ run: (+ importId: string,+ progress?: ImportJobProgress+ ): Promise<{ success: true }> =>+ runImportJob(deps, importId, progress, logger),+ /** Enqueues the `import` job and returns its BullMQ job id, for `Import.jobId`. */+ enqueue: (importId: string): Promise<string> =>+ deps.queues.import.import.add({ importId }),};}diff --git a/packages/core/src/modules/ingest/ingest.service.ts b/packages/core/src/modules/ingest/ingest.service.tsindex acee2ca53..c2863e339 100644--- a/packages/core/src/modules/ingest/ingest.service.ts+++ b/packages/core/src/modules/ingest/ingest.service.ts@@ -903,27 +903,23 @@ function isLiveSession(session: { ended_at: string }, now: number): boolean {);}-export interface IngestService {- track(- request: TrackRequest,- produceIncomingEvent: IncomingEventProducer- ): Promise<TrackOutcome>;- checkBot(request: Parameters<typeof checkIngestBot>[1]): Promise<BotVerdict>;- isDuplicate: typeof isDuplicateIngestRequest;-}-export function createIngestService(deps: ServiceDeps,_services: () => Services-): IngestService {+) {return {- track: (request, produceIncomingEvent) =>+ track: (+ request: TrackRequest,+ produceIncomingEvent: IncomingEventProducer+ ): Promise<TrackOutcome> =>ingestTrack(request, {buffers: deps.buffers,produceIncomingEvent,deps,}),- checkBot: (request) => checkIngestBot(deps, request),+ checkBot: (+ request: Parameters<typeof checkIngestBot>[1]+ ): Promise<BotVerdict> => checkIngestBot(deps, request),isDuplicate: isDuplicateIngestRequest,};}diff --git a/packages/core/src/modules/insight/insight.jobs.test.ts b/packages/core/src/modules/insight/insight.jobs.test.tsindex 5427be2e0..abb224a23 100644--- a/packages/core/src/modules/insight/insight.jobs.test.ts+++ b/packages/core/src/modules/insight/insight.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { insightCronJobs, insightQueueJobs } from './insight.jobs';-import type { InsightService } from './insight.service';+import type { createInsightService } from './insight.service';function stubLogger(): Logger {const noop = () => undefined;@@ -29,13 +29,13 @@ function stubLogger(): Logger {// makes it unassignable afterwards — exactly what a fake `services.insight`// needs to be for a handler test.function stubJobCtx(- insight: Partial<InsightService>,+ insight: Partial<ReturnType<typeof createInsightService>>,jobName = 'test'): JobCtx {const services: Services = {auth: {} as Services['auth'],notification: {} as Services['notification'],- insight: insight as InsightService,+ insight: insight as ReturnType<typeof createInsightService>,gsc: {} as Services['gsc'],integration: {} as Services['integration'],cohort: {} as Services['cohort'],@@ -146,7 +146,7 @@ test('insightsDaily fans out one insightsProject enqueue per candidate, jobId de{ projectId: 'p1', date },{ projectId: 'p2', date },],- } as InsightService,+ } as ReturnType<typeof createInsightService>,gsc: {} as Services['gsc'],integration: {} as Services['integration'],cohort: {} as Services['cohort'],diff --git a/packages/core/src/modules/insight/insight.service.ts b/packages/core/src/modules/insight/insight.service.tsindex 2822a813d..553384641 100644--- a/packages/core/src/modules/insight/insight.service.ts+++ b/packages/core/src/modules/insight/insight.service.ts@@ -702,52 +702,44 @@ export type {ReferrerSpikeCluster,} from './src/referrer-spikes';-export interface InsightService {- listDailyInsightCandidates(date: string): Promise<DailyInsightCandidate[]>;- runProjectInsights(args: { projectId: string; date: string }): Promise<void>;- cleanupStaleInsights(): Promise<{ insights: number; events: number }>;- sendWeeklyDigests(): Promise<WeeklyDigestResult>;- previewWeeklyDigest(- projectId: string,- opts?: { to?: string; force?: boolean }- ): Promise<WeeklyDigestPreview>;- listInsights(args: {- projectId: string;- limit: number;- }): ReturnType<typeof listInsights>;- listAllInsights(args: {- projectId: string;- limit: number;- }): ReturnType<typeof listAllInsights>;- explainInsight(- input: ExplainInsightInput,- cacheKey: string- ): Promise<InsightExplanation | null>;- getReferrerSpikes(- input: GetReferrerSpikesInput- ): Promise<ReferrerSpikeCluster[]>;- scanLegacyInsights(projectId: string): Promise<LegacyInsight[]>;-}-/** `ctx.services.insight` — a thin binding of the functions above to a Ctx's logger. */export function createInsightService(deps: ServiceDeps,_services: () => Services-): InsightService {+) {const logger = deps.logger.child({ module: 'insight' });return {- listDailyInsightCandidates: (date) =>+ listDailyInsightCandidates: (+ date: string+ ): Promise<DailyInsightCandidate[]> =>listDailyInsightCandidates(deps, date),- runProjectInsights: (args) => runProjectInsights(deps, { ...args, logger }),- cleanupStaleInsights: () => cleanupStaleInsights(deps, logger),- sendWeeklyDigests: () => sendWeeklyDigests(deps, logger),- previewWeeklyDigest: (projectId, opts) =>+ runProjectInsights: (args: {+ projectId: string;+ date: string;+ }): Promise<void> => runProjectInsights(deps, { ...args, logger }),+ cleanupStaleInsights: (): Promise<{ insights: number; events: number }> =>+ cleanupStaleInsights(deps, logger),+ sendWeeklyDigests: (): Promise<WeeklyDigestResult> =>+ sendWeeklyDigests(deps, logger),+ previewWeeklyDigest: (+ projectId: string,+ opts?: { to?: string; force?: boolean }+ ): Promise<WeeklyDigestPreview> =>previewWeeklyDigest(deps, projectId, opts),- listInsights: (args) => listInsights(deps, args),- listAllInsights: (args) => listAllInsights(deps, args),+ listInsights: (args: {+ projectId: string;+ limit: number;+ }): ReturnType<typeof listInsights> => listInsights(deps, args),+ listAllInsights: (args: {+ projectId: string;+ limit: number;+ }): ReturnType<typeof listAllInsights> => listAllInsights(deps, args),explainInsight,- getReferrerSpikes: (input) => getReferrerSpikes(deps, input),- scanLegacyInsights: (projectId) => scanLegacyInsights(deps, projectId),+ getReferrerSpikes: (+ input: GetReferrerSpikesInput+ ): Promise<ReferrerSpikeCluster[]> => getReferrerSpikes(deps, input),+ scanLegacyInsights: (projectId: string): Promise<LegacyInsight[]> =>+ scanLegacyInsights(deps, projectId),};}diff --git a/packages/core/src/modules/insight/src/legacy-scan.ts b/packages/core/src/modules/insight/src/legacy-scan.tsindex 3304b9fd3..28e89e9aa 100644--- a/packages/core/src/modules/insight/src/legacy-scan.ts+++ b/packages/core/src/modules/insight/src/legacy-scan.ts@@ -316,15 +316,10 @@ class LegacyInsightsScanner {}}-export interface LegacyInsightsScannerService {- generateInsights(projectId: string): Promise<Insight[]>;-}--export function createLegacyInsightsScanner(- deps: ChScope-): LegacyInsightsScannerService {+export function createLegacyInsightsScanner(deps: ChScope) {const scanner = new LegacyInsightsScanner(deps);return {- generateInsights: (projectId) => scanner.generateInsights(projectId),+ generateInsights: (projectId: string): Promise<Insight[]> =>+ scanner.generateInsights(projectId),};}diff --git a/packages/core/src/modules/integration/integration.service.ts b/packages/core/src/modules/integration/integration.service.tsindex eb7bbfc82..67bd719c7 100644--- a/packages/core/src/modules/integration/integration.service.ts+++ b/packages/core/src/modules/integration/integration.service.ts@@ -482,34 +482,42 @@ type WithoutDeps<T extends (deps: ServiceDeps, ...args: never[]) => unknown> =? (...args: A) => R: never;-export interface IntegrationService {- getById: WithoutDeps<typeof getIntegrationById>;- listForProject: WithoutDeps<typeof listIntegrationsForProject>;- upsert: WithoutDeps<typeof upsertIntegration>;- createOrUpdateSlack: WithoutDeps<typeof createOrUpdateSlackIntegration>;- testConnection: WithoutDeps<typeof testIntegrationConnection>;- testExportConnection: WithoutDeps<typeof testExportIntegrationConnection>;- delete: WithoutDeps<typeof deleteIntegration>;- completeSlackOAuthCallback: WithoutDeps<typeof completeSlackOAuthCallback>;-}-/** M10-009: this module had no factory at all — the one `*.service.ts` file* `services.ts` did not register (docs/TECH_DEBT.md §5a). */export function createIntegrationService(deps: ServiceDeps,_services: () => Services-): IntegrationService {+) {+ const getById: WithoutDeps<typeof getIntegrationById> = (...args) =>+ getIntegrationById(deps, ...args);+ const listForProject: WithoutDeps<typeof listIntegrationsForProject> = (+ ...args+ ) => listIntegrationsForProject(deps, ...args);+ const upsert: WithoutDeps<typeof upsertIntegration> = (...args) =>+ upsertIntegration(deps, ...args);+ const createOrUpdateSlack: WithoutDeps<+ typeof createOrUpdateSlackIntegration+ > = (...args) => createOrUpdateSlackIntegration(deps, ...args);+ const testConnection: WithoutDeps<typeof testIntegrationConnection> = (+ ...args+ ) => testIntegrationConnection(deps, ...args);+ const testExportConnection: WithoutDeps<+ typeof testExportIntegrationConnection+ > = (...args) => testExportIntegrationConnection(deps, ...args);+ const deleteBound: WithoutDeps<typeof deleteIntegration> = (...args) =>+ deleteIntegration(deps, ...args);+ const completeSlackOAuthCallbackBound: WithoutDeps<+ typeof completeSlackOAuthCallback+ > = (...args) => completeSlackOAuthCallback(deps, ...args);+return {- getById: (...args) => getIntegrationById(deps, ...args),- listForProject: (...args) => listIntegrationsForProject(deps, ...args),- upsert: (...args) => upsertIntegration(deps, ...args),- createOrUpdateSlack: (...args) =>- createOrUpdateSlackIntegration(deps, ...args),- testConnection: (...args) => testIntegrationConnection(deps, ...args),- testExportConnection: (...args) =>- testExportIntegrationConnection(deps, ...args),- delete: (...args) => deleteIntegration(deps, ...args),- completeSlackOAuthCallback: (...args) =>- completeSlackOAuthCallback(deps, ...args),+ getById,+ listForProject,+ upsert,+ createOrUpdateSlack,+ testConnection,+ testExportConnection,+ delete: deleteBound,+ completeSlackOAuthCallback: completeSlackOAuthCallbackBound,};}diff --git a/packages/core/src/modules/mcp/mcp.service.ts b/packages/core/src/modules/mcp/mcp.service.tsindex 1c1155f22..d45a9487c 100644--- a/packages/core/src/modules/mcp/mcp.service.ts+++ b/packages/core/src/modules/mcp/mcp.service.ts@@ -196,17 +196,6 @@ function logToolResult();}-export interface McpService {- extractToken(- query: Record<string, unknown>,- authHeader: string | undefined- ): ReturnType<typeof extractToken>;- handleStatelessMcpRequest(- token: string | undefined,- body: unknown- ): Promise<McpHttpResult>;-}-/*** Ignores BOTH arguments, and takes them only because ADR-022 R3 keeps the* composition root a flat list: `extractToken` is pure and@@ -218,7 +207,7 @@ export interface McpService {export function createMcpService(_deps: ServiceDeps,_services: () => Services-): McpService {+) {return {extractToken,handleStatelessMcpRequest,diff --git a/packages/core/src/modules/misc/misc.service.ts b/packages/core/src/modules/misc/misc.service.tsindex 4b6aefb63..b6eb63f24 100644--- a/packages/core/src/modules/misc/misc.service.ts+++ b/packages/core/src/modules/misc/misc.service.ts@@ -493,13 +493,9 @@ export async function runPingCron(deps: ServiceDeps): Promise<unknown> {throw new Error('Failed to ping the server');}-export interface MiscService {- runPingCron(): Promise<unknown>;-}-export function createMiscService(deps: ServiceDeps,_services: () => Services-): MiscService {- return { runPingCron: () => runPingCron(deps) };+) {+ return { runPingCron: (): Promise<unknown> => runPingCron(deps) };}diff --git a/packages/core/src/modules/notification/notification.jobs.test.ts b/packages/core/src/modules/notification/notification.jobs.test.tsindex aa033b690..ad4f130ff 100644--- a/packages/core/src/modules/notification/notification.jobs.test.ts+++ b/packages/core/src/modules/notification/notification.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { notificationQueueJobs } from './notification.jobs';-import type { NotificationService } from './notification.service';+import type { createNotificationService } from './notification.service';function stubLogger(): Logger {const noop = () => undefined;@@ -24,10 +24,12 @@ function stubLogger(): Logger {return logger;}-function stubJobCtx(notification: Partial<NotificationService>): JobCtx {+function stubJobCtx(+ notification: Partial<ReturnType<typeof createNotificationService>>+): JobCtx {const services: Services = {auth: {} as Services['auth'],- notification: notification as NotificationService,+ notification: notification as ReturnType<typeof createNotificationService>,insight: {} as Services['insight'],integration: {} as Services['integration'],cohort: {} as Services['cohort'],diff --git a/packages/core/src/modules/notification/notification.service.ts b/packages/core/src/modules/notification/notification.service.tsindex 1227aa7c4..cd0e6c66a 100644--- a/packages/core/src/modules/notification/notification.service.ts+++ b/packages/core/src/modules/notification/notification.service.ts@@ -518,17 +518,13 @@ export async function deleteNotificationRule(deps: ServiceDeps, id: string) {// -- Services surface ---------------------------------------------------export interface NotificationService {- dispatch(- notification: Prisma.NotificationUncheckedCreateInput- ): Promise<unknown>;-}-export function createNotificationService(deps: ServiceDeps,_services: () => Services-): NotificationService {+) {return {- dispatch: (notification) => deliverNotification(deps, notification),+ dispatch: (+ notification: Prisma.NotificationUncheckedCreateInput+ ): Promise<unknown> => deliverNotification(deps, notification),};}diff --git a/packages/core/src/modules/onboarding/onboarding.jobs.test.ts b/packages/core/src/modules/onboarding/onboarding.jobs.test.tsindex d22c339fe..5fed26160 100644--- a/packages/core/src/modules/onboarding/onboarding.jobs.test.ts+++ b/packages/core/src/modules/onboarding/onboarding.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { onboardingCronJobs } from './onboarding.jobs';-import type { OnboardingService } from './onboarding.service';+import type { createOnboardingService } from './onboarding.service';function stubLogger(): Logger {const noop = () => undefined;@@ -25,7 +25,7 @@ function stubLogger(): Logger {}function stubJobCtx(- onboarding: Partial<OnboardingService>,+ onboarding: Partial<ReturnType<typeof createOnboardingService>>,jobName = 'test'): JobCtx {const services: Services = {@@ -38,7 +38,7 @@ function stubJobCtx(ingest: {} as Services['ingest'],cohort: {} as Services['cohort'],organization: {} as Services['organization'],- onboarding: onboarding as OnboardingService,+ onboarding: onboarding as ReturnType<typeof createOnboardingService>,session: {} as Services['session'],event: {} as Services['event'],profile: {} as Services['profile'],diff --git a/packages/core/src/modules/onboarding/onboarding.service.ts b/packages/core/src/modules/onboarding/onboarding.service.tsindex c72f5668b..65909ab1c 100644--- a/packages/core/src/modules/onboarding/onboarding.service.ts+++ b/packages/core/src/modules/onboarding/onboarding.service.ts@@ -415,10 +415,6 @@ export async function runOnboardingCron(return summary;}-export interface OnboardingService {- runOnboardingCron(): Promise<OnboardingCronSummary | null>;-}-/** Registered in `services.ts`. Closes over `deps.logger`, the same value* `ctx.logger` is, so `ctx.services.onboarding.runOnboardingCron()` takes no* arguments — same shape as organization's `runDeleteCron`, which needs no@@ -426,8 +422,9 @@ export interface OnboardingService {export function createOnboardingService(deps: ServiceDeps,_services: () => Services-): OnboardingService {+) {return {- runOnboardingCron: () => runOnboardingCron(deps, deps.logger),+ runOnboardingCron: (): Promise<OnboardingCronSummary | null> =>+ runOnboardingCron(deps, deps.logger),};}diff --git a/packages/core/src/modules/organization/organization.jobs.test.ts b/packages/core/src/modules/organization/organization.jobs.test.tsindex ca9ab04e0..7a6167a89 100644--- a/packages/core/src/modules/organization/organization.jobs.test.ts+++ b/packages/core/src/modules/organization/organization.jobs.test.ts@@ -8,7 +8,7 @@ import { queues } from '../../jobs.registry';import type { Logger } from '../../logger';import type { Services } from '../../services';import { organizationCronJobs } from './organization.jobs';-import type { OrganizationService } from './organization.service';+import type { createOrganizationService } from './organization.service';function stubLogger(): Logger {const noop = () => undefined;@@ -25,7 +25,7 @@ function stubLogger(): Logger {}function stubJobCtx(- organization: Partial<OrganizationService>,+ organization: Partial<ReturnType<typeof createOrganizationService>>,jobName = 'test'): JobCtx {const services: Services = {@@ -37,7 +37,7 @@ function stubJobCtx(import: {} as Services['import'],ingest: {} as Services['ingest'],cohort: {} as Services['cohort'],- organization: organization as OrganizationService,+ organization: organization as ReturnType<typeof createOrganizationService>,onboarding: {} as Services['onboarding'],session: {} as Services['session'],event: {} as Services['event'],diff --git a/packages/core/src/modules/organization/organization.service.ts b/packages/core/src/modules/organization/organization.service.tsindex e69e0f281..18e996046 100644--- a/packages/core/src/modules/organization/organization.service.ts+++ b/packages/core/src/modules/organization/organization.service.ts@@ -939,53 +939,45 @@ export async function updateOrganizationMemberAccess(]);}-export interface OrganizationService {- get(organizationId: string): ReturnType<typeof getOrganizationById>;- list(userId: string | null): ReturnType<typeof getOrganizations>;- update(input: {- id: string;- name: string;- timezone: string;- }): ReturnType<typeof updateOrganization>;- scheduleDeletion(organizationId: string): Promise<void>;- cancelDeletion(organizationId: string): Promise<void>;- inviteUser(- input: Parameters<typeof inviteUserToOrganization>[1]- ): Promise<InviteUserResult>;- getInviteOrThrow(inviteId: string): Promise<Invite>;- revokeInvite(inviteId: string): Promise<Invite>;- removeMember(- input: Parameters<typeof removeOrganizationMember>[1]- ): Promise<void>;- updateMemberAccess(- input: Parameters<typeof updateOrganizationMemberAccess>[1]- ): ReturnType<typeof updateOrganizationMemberAccess>;- members(organizationId: string): Promise<IServiceMember[]>;- invitations(organizationId: string): Promise<Invite[]>;- getInvite(inviteId: string): ReturnType<typeof getInviteById>;- runDeleteCron(): Promise<DeleteCronResult>;-}-export function createOrganizationService(deps: ServiceDeps,_services: () => Services-): OrganizationService {+) {return {- get: (organizationId) => getOrganizationById(deps, organizationId),- list: (userId) => getOrganizations(deps, userId),- update: (input) => updateOrganization(deps, input),- scheduleDeletion: (organizationId) =>+ get: (organizationId: string): ReturnType<typeof getOrganizationById> =>+ getOrganizationById(deps, organizationId),+ list: (userId: string | null): ReturnType<typeof getOrganizations> =>+ getOrganizations(deps, userId),+ update: (input: {+ id: string;+ name: string;+ timezone: string;+ }): ReturnType<typeof updateOrganization> =>+ updateOrganization(deps, input),+ scheduleDeletion: (organizationId: string): Promise<void> =>scheduleOrganizationDeletion(deps, organizationId),- cancelDeletion: (organizationId) =>+ cancelDeletion: (organizationId: string): Promise<void> =>cancelOrganizationDeletion(deps, organizationId),- inviteUser: (input) => inviteUserToOrganization(deps, input),- getInviteOrThrow: (inviteId) => getInviteOrThrow(deps, inviteId),- revokeInvite: (inviteId) => revokeInvite(deps, inviteId),- removeMember: (input) => removeOrganizationMember(deps, input),- updateMemberAccess: (input) => updateOrganizationMemberAccess(deps, input),- members: (organizationId) => getMembers(deps, organizationId),- invitations: (organizationId) => getInvites(deps, organizationId),- getInvite: (inviteId) => getInviteById(deps, inviteId),- runDeleteCron: () => runDeleteCron(deps),+ inviteUser: (+ input: Parameters<typeof inviteUserToOrganization>[1]+ ): Promise<InviteUserResult> => inviteUserToOrganization(deps, input),+ getInviteOrThrow: (inviteId: string): Promise<Invite> =>+ getInviteOrThrow(deps, inviteId),+ revokeInvite: (inviteId: string): Promise<Invite> =>+ revokeInvite(deps, inviteId),+ removeMember: (+ input: Parameters<typeof removeOrganizationMember>[1]+ ): Promise<void> => removeOrganizationMember(deps, input),+ updateMemberAccess: (+ input: Parameters<typeof updateOrganizationMemberAccess>[1]+ ): ReturnType<typeof updateOrganizationMemberAccess> =>+ updateOrganizationMemberAccess(deps, input),+ members: (organizationId: string): Promise<IServiceMember[]> =>+ getMembers(deps, organizationId),+ invitations: (organizationId: string): Promise<Invite[]> =>+ getInvites(deps, organizationId),+ getInvite: (inviteId: string): ReturnType<typeof getInviteById> =>+ getInviteById(deps, inviteId),+ runDeleteCron: (): Promise<DeleteCronResult> => runDeleteCron(deps),};}diff --git a/packages/core/src/modules/overview/overview.service.ts b/packages/core/src/modules/overview/overview.service.tsindex dd4e6cfe0..b01740c8b 100644--- a/packages/core/src/modules/overview/overview.service.ts+++ b/packages/core/src/modules/overview/overview.service.ts@@ -1369,65 +1369,51 @@ export async function getAnalyticsOverviewCore(};}-export interface OverviewService {- isPageFilter(filters: IChartEventFilter[]): boolean;- getRawWhereClause(- type: 'events' | 'sessions',- filters: IChartEventFilter[]- ): SqlFragment | null;- getMetrics(input: IGetMetricsInput): ReturnType<typeof getMetrics>;- getTopPages(input: IGetTopPagesInput): ReturnType<typeof getTopPages>;- getTopEntryExit(- input: IGetTopEntryExitInput- ): ReturnType<typeof getTopEntryExit>;- getTopGeneric(input: IGetTopGenericInput): ReturnType<typeof getTopGeneric>;- getTopGenericSeries(- input: IGetTopGenericSeriesInput- ): ReturnType<typeof getTopGenericSeries>;- getUserJourney(- input: IGetUserJourneyInput- ): ReturnType<typeof getUserJourney>;- getTopEvents(- input: Parameters<typeof getTopEvents>[1]- ): ReturnType<typeof getTopEvents>;- getTopLinkOut(- input: Parameters<typeof getTopLinkOut>[1]- ): ReturnType<typeof getTopLinkOut>;- getMapData(- input: Parameters<typeof getMapData>[1]- ): ReturnType<typeof getMapData>;- getLiveData(projectId: string): Promise<ILiveData>;- getTrafficBreakdownCore(- input: Parameters<typeof getTrafficBreakdownCore>[1]- ): ReturnType<typeof getTrafficBreakdownCore>;- getSegmentDailySeriesCore(- input: Parameters<typeof getSegmentDailySeriesCore>[1]- ): Promise<SegmentDailyPoint[]>;- getAnalyticsOverviewCore(- input: GetAnalyticsOverviewInput- ): ReturnType<typeof getAnalyticsOverviewCore>;-}-export function createOverviewService(deps: ServiceDeps,_services: () => Services-): OverviewService {+) {return {isPageFilter,getRawWhereClause,- getMetrics: (input) => getMetrics(deps, input),- getTopPages: (input) => getTopPages(deps, input),- getTopEntryExit: (input) => getTopEntryExit(deps, input),- getTopGeneric: (input) => getTopGeneric(deps, input),- getTopGenericSeries: (input) => getTopGenericSeries(deps, input),- getUserJourney: (input) => getUserJourney(deps, input),- getTopEvents: (input) => getTopEvents(deps, input),- getTopLinkOut: (input) => getTopLinkOut(deps, input),- getMapData: (input) => getMapData(deps, input),- getLiveData: (projectId) => getLiveData(deps, projectId),- getTrafficBreakdownCore: (input) => getTrafficBreakdownCore(deps, input),- getSegmentDailySeriesCore: (input) =>- getSegmentDailySeriesCore(deps, input),- getAnalyticsOverviewCore: (input) => getAnalyticsOverviewCore(deps, input),+ getMetrics: (input: IGetMetricsInput): ReturnType<typeof getMetrics> =>+ getMetrics(deps, input),+ getTopPages: (input: IGetTopPagesInput): ReturnType<typeof getTopPages> =>+ getTopPages(deps, input),+ getTopEntryExit: (+ input: IGetTopEntryExitInput+ ): ReturnType<typeof getTopEntryExit> => getTopEntryExit(deps, input),+ getTopGeneric: (+ input: IGetTopGenericInput+ ): ReturnType<typeof getTopGeneric> => getTopGeneric(deps, input),+ getTopGenericSeries: (+ input: IGetTopGenericSeriesInput+ ): ReturnType<typeof getTopGenericSeries> =>+ getTopGenericSeries(deps, input),+ getUserJourney: (+ input: IGetUserJourneyInput+ ): ReturnType<typeof getUserJourney> => getUserJourney(deps, input),+ getTopEvents: (+ input: Parameters<typeof getTopEvents>[1]+ ): ReturnType<typeof getTopEvents> => getTopEvents(deps, input),+ getTopLinkOut: (+ input: Parameters<typeof getTopLinkOut>[1]+ ): ReturnType<typeof getTopLinkOut> => getTopLinkOut(deps, input),+ getMapData: (+ input: Parameters<typeof getMapData>[1]+ ): ReturnType<typeof getMapData> => getMapData(deps, input),+ getLiveData: (projectId: string): Promise<ILiveData> =>+ getLiveData(deps, projectId),+ getTrafficBreakdownCore: (+ input: Parameters<typeof getTrafficBreakdownCore>[1]+ ): ReturnType<typeof getTrafficBreakdownCore> =>+ getTrafficBreakdownCore(deps, input),+ getSegmentDailySeriesCore: (+ input: Parameters<typeof getSegmentDailySeriesCore>[1]+ ): Promise<SegmentDailyPoint[]> => getSegmentDailySeriesCore(deps, input),+ getAnalyticsOverviewCore: (+ input: GetAnalyticsOverviewInput+ ): ReturnType<typeof getAnalyticsOverviewCore> =>+ getAnalyticsOverviewCore(deps, input),};}diff --git a/packages/core/src/modules/overview/pages.service.ts b/packages/core/src/modules/overview/pages.service.tsindex 202698d25..2b8e3b099 100644--- a/packages/core/src/modules/overview/pages.service.ts+++ b/packages/core/src/modules/overview/pages.service.ts@@ -219,39 +219,33 @@ export async function getPageConversionsCore();}-export interface PagesService {- getTopPages(input: IGetPagesInput): Promise<ITopPage[]>;- getPageTimeseries(- input: IGetPagesInput & {- interval: IInterval;- filterOrigin?: string;- filterPath?: string;- }- ): Promise<IPageTimeseriesRow[]>;- getTopPagesCore(- input: Parameters<typeof getTopPagesCore>[1]- ): ReturnType<typeof getTopPagesCore>;- getEntryExitPagesCore(- input: Parameters<typeof getEntryExitPagesCore>[1]- ): ReturnType<typeof getEntryExitPagesCore>;- getPagePerformanceCore(- input: Parameters<typeof getPagePerformanceCore>[1]- ): ReturnType<typeof getPagePerformanceCore>;- getPageConversionsCore(- input: Parameters<typeof getPageConversionsCore>[1]- ): Promise<IPageConversionRow[]>;-}-export function createPagesService(deps: ServiceDeps,_services: () => Services-): PagesService {+) {return {- getTopPages: (input) => getTopPages(deps, input),- getPageTimeseries: (input) => getPageTimeseries(deps, input),- getTopPagesCore: (input) => getTopPagesCore(deps, input),- getEntryExitPagesCore: (input) => getEntryExitPagesCore(deps, input),- getPagePerformanceCore: (input) => getPagePerformanceCore(deps, input),- getPageConversionsCore: (input) => getPageConversionsCore(deps, input),+ getTopPages: (input: IGetPagesInput): Promise<ITopPage[]> =>+ getTopPages(deps, input),+ getPageTimeseries: (+ input: IGetPagesInput & {+ interval: IInterval;+ filterOrigin?: string;+ filterPath?: string;+ }+ ): Promise<IPageTimeseriesRow[]> => getPageTimeseries(deps, input),+ getTopPagesCore: (+ input: Parameters<typeof getTopPagesCore>[1]+ ): ReturnType<typeof getTopPagesCore> => getTopPagesCore(deps, input),+ getEntryExitPagesCore: (+ input: Parameters<typeof getEntryExitPagesCore>[1]+ ): ReturnType<typeof getEntryExitPagesCore> =>+ getEntryExitPagesCore(deps, input),+ getPagePerformanceCore: (+ input: Parameters<typeof getPagePerformanceCore>[1]+ ): ReturnType<typeof getPagePerformanceCore> =>+ getPagePerformanceCore(deps, input),+ getPageConversionsCore: (+ input: Parameters<typeof getPageConversionsCore>[1]+ ): Promise<IPageConversionRow[]> => getPageConversionsCore(deps, input),};}diff --git a/packages/core/src/modules/profile/profile.service.ts b/packages/core/src/modules/profile/profile.service.tsindex 498a4d90b..d5b4d5c0f 100644--- a/packages/core/src/modules/profile/profile.service.ts+++ b/packages/core/src/modules/profile/profile.service.ts@@ -711,17 +711,16 @@ export async function adjustProfileProperty(return { status: 'ok', profileId: profile.id };}-export interface ProfileService {- byId(id: string, projectId: string): Promise<IServiceProfile | null>;- upsert(input: IServiceUpsertProfile, isFromEvent?: boolean): Promise<void>;-}-export function createProfileService(deps: ServiceDeps,_services: () => Services-): ProfileService {+) {return {- byId: (id, projectId) => getProfileById(deps, id, projectId),- upsert: (input, isFromEvent) => upsertProfile(deps, input, isFromEvent),+ byId: (id: string, projectId: string): Promise<IServiceProfile | null> =>+ getProfileById(deps, id, projectId),+ upsert: (+ input: IServiceUpsertProfile,+ isFromEvent?: boolean+ ): Promise<void> => upsertProfile(deps, input, isFromEvent),};}diff --git a/packages/core/src/modules/project/project.service.test.ts b/packages/core/src/modules/project/project.service.test.tsindex 82e2ec98c..e09ecf210 100644--- a/packages/core/src/modules/project/project.service.test.ts+++ b/packages/core/src/modules/project/project.service.test.ts@@ -199,7 +199,9 @@ afterAll(() => {mock.module('../../v1-compat', () => realV1Compat);});-let subject: import('./project.service').ProjectService;+let subject: ReturnType<+ typeof import('./project.service').createProjectService+>;beforeAll(async () => {const { createProjectService } = await import('./project.service');subject = createProjectService(diff --git a/packages/core/src/modules/project/project.service.ts b/packages/core/src/modules/project/project.service.tsindex 1f789ff94..6f983eb1c 100644--- a/packages/core/src/modules/project/project.service.ts+++ b/packages/core/src/modules/project/project.service.ts@@ -387,70 +387,10 @@ export async function getProjectForOrganization(// controller's `Date.now() + 24 * 60 * 60 * 1000` (REST), same duration.const DELETE_GRACE_PERIOD_MS = 24 * 60 * 60 * 1000;-export interface ProjectService {- getProjectById(id: string): ReturnType<typeof getProjectById>;- getProjectByIdCached(id: string): ReturnType<typeof getProjectById>;- /** Invalidates a single id in `getProjectByIdCached`'s L1 LRU + Redis —- * `ingest/src/incoming-event-handler.ts` reaches it, through the- * v1-compat singleton, right after marking a project's first event. */- clearProjectByIdCache(id: string): Promise<number>;- getProjectWithClients(id: string): ReturnType<typeof getProjectWithClients>;- getProjects(- input: Parameters<typeof getProjects>[1]- ): ReturnType<typeof getProjects>;- getProjectEventsCount(- projectId: string- ): ReturnType<typeof getProjectEventsCount>;- getLastEventPerProject(): ReturnType<typeof getLastEventPerProject>;- resolveClientProjectId(- input: Parameters<typeof resolveClientProjectId>[1]- ): ReturnType<typeof resolveClientProjectId>;- getProjectActivationStatus(- projectId: string- ): ReturnType<typeof getProjectActivationStatus>;- listProjectsCore(- input: Parameters<typeof listProjectsCore>[1]- ): ReturnType<typeof listProjectsCore>;- listProjectsForOrganization(- organizationId: string- ): ReturnType<typeof listProjectsForOrganization>;- getProjectForOrganization(- id: string,- organizationId: string- ): ReturnType<typeof getProjectForOrganization>;- createProjectForOrganization(- organizationId: string,- input: {- name: string;- domain?: string | null;- cors: string[];- crossDomain: boolean;- types: ProjectType[];- }- ): Promise<{ project: IServiceProject; client: CreatedProjectClient | null }>;- updateProjectForOrganization(- id: string,- organizationId: string,- input: {- name?: string;- domain?: string | null;- cors?: string[];- crossDomain?: boolean;- allowUnsafeRevenueTracking?: boolean;- }- ): Promise<IServiceProject | null>;- deleteProjectForOrganization(- id: string,- organizationId: string- ): Promise<boolean>;- scheduleProjectDeletion(id: string): Promise<void>;- cancelProjectDeletion(id: string): Promise<void>;-}-export function createProjectService(deps: ServiceDeps,_services: () => Services-): ProjectService {+) {/** L1 LRU (60s) + L2 Redis. clear() invalidates Redis + local LRU; other nodes may serve stale from LRU for up to 60s. */const getProjectByIdCached = cacheable((id: string) => getProjectById(deps, id),@@ -631,21 +571,47 @@ export function createProjectService(}return {- getProjectById: (id) => getProjectById(deps, id),- getProjectByIdCached: (id) => getProjectByIdCached(id),- clearProjectByIdCache: (id) => getProjectByIdCached.clear(id),- getProjectWithClients: (id) => getProjectWithClients(deps, id),- getProjects: (input) => getProjects(deps, input),- getProjectEventsCount: (projectId) =>+ getProjectById: (id: string): ReturnType<typeof getProjectById> =>+ getProjectById(deps, id),+ getProjectByIdCached: (id: string): ReturnType<typeof getProjectById> =>+ getProjectByIdCached(id),+ /** Invalidates a single id in `getProjectByIdCached`'s L1 LRU + Redis —+ * `ingest/src/incoming-event-handler.ts` reaches it, through the+ * v1-compat singleton, right after marking a project's first event. */+ clearProjectByIdCache: (id: string): Promise<number> =>+ getProjectByIdCached.clear(id),+ getProjectWithClients: (+ id: string+ ): ReturnType<typeof getProjectWithClients> =>+ getProjectWithClients(deps, id),+ getProjects: (+ input: Parameters<typeof getProjects>[1]+ ): ReturnType<typeof getProjects> => getProjects(deps, input),+ getProjectEventsCount: (+ projectId: string+ ): ReturnType<typeof getProjectEventsCount> =>getProjectEventsCount(deps, projectId),- getLastEventPerProject: () => getLastEventPerProject(deps),- resolveClientProjectId: (input) => resolveClientProjectId(deps, input),- getProjectActivationStatus: (projectId) =>+ getLastEventPerProject: (): ReturnType<typeof getLastEventPerProject> =>+ getLastEventPerProject(deps),+ resolveClientProjectId: (+ input: Parameters<typeof resolveClientProjectId>[1]+ ): ReturnType<typeof resolveClientProjectId> =>+ resolveClientProjectId(deps, input),+ getProjectActivationStatus: (+ projectId: string+ ): ReturnType<typeof getProjectActivationStatus> =>getProjectActivationStatus(deps, projectId),- listProjectsCore: (input) => listProjectsCore(deps, input),- listProjectsForOrganization: (organizationId) =>+ listProjectsCore: (+ input: Parameters<typeof listProjectsCore>[1]+ ): ReturnType<typeof listProjectsCore> => listProjectsCore(deps, input),+ listProjectsForOrganization: (+ organizationId: string+ ): ReturnType<typeof listProjectsForOrganization> =>listProjectsForOrganization(deps, organizationId),- getProjectForOrganization: (id, organizationId) =>+ getProjectForOrganization: (+ id: string,+ organizationId: string+ ): ReturnType<typeof getProjectForOrganization> =>getProjectForOrganization(deps, id, organizationId),createProjectForOrganization,updateProjectForOrganization,diff --git a/packages/core/src/modules/realtime/realtime.service.ts b/packages/core/src/modules/realtime/realtime.service.tsindex d0024dc06..8fda935b2 100644--- a/packages/core/src/modules/realtime/realtime.service.ts+++ b/packages/core/src/modules/realtime/realtime.service.ts@@ -549,33 +549,32 @@ export async function subscribeToOrganizationSubscriptionUpdates();}-export interface RealtimeService {- getCoordinates(projectId: string): ReturnType<typeof getRealtimeCoordinates>;- getMapBadgeDetails(- input: Parameters<typeof getRealtimeMapBadgeDetails>[1]- ): ReturnType<typeof getRealtimeMapBadgeDetails>;- getActiveSessions(- projectId: string- ): ReturnType<typeof getRealtimeActiveSessions>;- getPaths(projectId: string): ReturnType<typeof getRealtimePaths>;- getReferrals(projectId: string): ReturnType<typeof getRealtimeReferrals>;- getGeo(projectId: string): ReturnType<typeof getRealtimeGeo>;- getActiveVisitorCount(projectId: string): Promise<number>;-}-export function createRealtimeService(deps: ServiceDeps,_services: () => Services-): RealtimeService {+) {return {- getCoordinates: (projectId) => getRealtimeCoordinates(deps, projectId),- getMapBadgeDetails: (input) => getRealtimeMapBadgeDetails(deps, input),- getActiveSessions: (projectId) =>+ getCoordinates: (+ projectId: string+ ): ReturnType<typeof getRealtimeCoordinates> =>+ getRealtimeCoordinates(deps, projectId),+ getMapBadgeDetails: (+ input: Parameters<typeof getRealtimeMapBadgeDetails>[1]+ ): ReturnType<typeof getRealtimeMapBadgeDetails> =>+ getRealtimeMapBadgeDetails(deps, input),+ getActiveSessions: (+ projectId: string+ ): ReturnType<typeof getRealtimeActiveSessions> =>getRealtimeActiveSessions(deps, projectId),- getPaths: (projectId) => getRealtimePaths(deps, projectId),- getReferrals: (projectId) => getRealtimeReferrals(deps, projectId),- getGeo: (projectId) => getRealtimeGeo(deps, projectId),- getActiveVisitorCount: (projectId) =>+ getPaths: (projectId: string): ReturnType<typeof getRealtimePaths> =>+ getRealtimePaths(deps, projectId),+ getReferrals: (+ projectId: string+ ): ReturnType<typeof getRealtimeReferrals> =>+ getRealtimeReferrals(deps, projectId),+ getGeo: (projectId: string): ReturnType<typeof getRealtimeGeo> =>+ getRealtimeGeo(deps, projectId),+ getActiveVisitorCount: (projectId: string): Promise<number> =>getActiveVisitorCount(deps, projectId),};}diff --git a/packages/core/src/modules/reference/reference.service.test.ts b/packages/core/src/modules/reference/reference.service.test.tsindex 9433ec94b..885ef292a 100644--- a/packages/core/src/modules/reference/reference.service.test.ts+++ b/packages/core/src/modules/reference/reference.service.test.ts@@ -128,7 +128,9 @@ afterAll(() => {mock.module('../../shared/date', () => realDate);});-let subject: import('./reference.service').ReferenceService;+let subject: ReturnType<+ typeof import('./reference.service').createReferenceService+>;beforeAll(async () => {const { createReferenceService } = await import('./reference.service');subject = createReferenceService(diff --git a/packages/core/src/modules/reference/reference.service.ts b/packages/core/src/modules/reference/reference.service.tsindex 1fe442152..f74c19d87 100644--- a/packages/core/src/modules/reference/reference.service.ts+++ b/packages/core/src/modules/reference/reference.service.ts@@ -135,27 +135,24 @@ export async function getChartReferences(});}-export interface ReferenceService {- getReferenceById(id: string): Promise<Reference | null>;- getReferenceByIdOrThrow(id: string): Promise<Reference>;- listReferences(input: ListReferencesInput): Promise<Reference[]>;- createReference(input: CreateReferenceInput): Promise<Reference>;- updateReference(input: UpdateReferenceInput): Promise<Reference>;- deleteReference(id: string): Promise<Reference>;- getChartReferences(input: ChartReferencesInput): Promise<Reference[]>;-}-export function createReferenceService(deps: ServiceDeps,_services: () => Services-): ReferenceService {+) {return {- getReferenceById: (id) => getReferenceById(deps, id),- getReferenceByIdOrThrow: (id) => getReferenceByIdOrThrow(deps, id),- listReferences: (input) => listReferences(deps, input),- createReference: (input) => createReference(deps, input),- updateReference: (input) => updateReference(deps, input),- deleteReference: (id) => deleteReference(deps, id),- getChartReferences: (input) => getChartReferences(deps, input),+ getReferenceById: (id: string): Promise<Reference | null> =>+ getReferenceById(deps, id),+ getReferenceByIdOrThrow: (id: string): Promise<Reference> =>+ getReferenceByIdOrThrow(deps, id),+ listReferences: (input: ListReferencesInput): Promise<Reference[]> =>+ listReferences(deps, input),+ createReference: (input: CreateReferenceInput): Promise<Reference> =>+ createReference(deps, input),+ updateReference: (input: UpdateReferenceInput): Promise<Reference> =>+ updateReference(deps, input),+ deleteReference: (id: string): Promise<Reference> =>+ deleteReference(deps, id),+ getChartReferences: (input: ChartReferencesInput): Promise<Reference[]> =>+ getChartReferences(deps, input),};}diff --git a/packages/core/src/modules/report/report.service.ts b/packages/core/src/modules/report/report.service.tsindex 47b25500f..0f9baeef6 100644--- a/packages/core/src/modules/report/report.service.ts+++ b/packages/core/src/modules/report/report.service.ts@@ -462,79 +462,53 @@ export async function resetReportLayouts(// --- service -------------------------------------------------------------export interface ReportService {- transformFilter(- filter: Partial<IChartEventFilter>,- index: number- ): IChartEventFilter;- transformReportEventItem(- item: IChartEventItem,- index: number- ): IChartEventItem;- transformReport(- report: DbReport & { layout?: ReportLayout | null }- ): ReturnType<typeof transformReport>;- mergeGlobalFilters(- series: IChartEventItem[],- globalFilters?: IChartEventFilter[]- ): IChartEventItem[];- onlyReportEvents(series: IChartEventItem[]): IChartEventItem[];- getReportsByDashboardId(- dashboardId: string- ): ReturnType<typeof getReportsByDashboardId>;- getReportById(id: string): ReturnType<typeof getReportById>;- getReportByIdOrThrow(id: string): ReturnType<typeof getReportByIdOrThrow>;- listReportsCore(- input: Parameters<typeof listReportsCore>[1]- ): ReturnType<typeof listReportsCore>;- getReportDataCore(- input: Parameters<typeof getReportDataCore>[1]- ): ReturnType<typeof getReportDataCore>;- createReport(- input: Parameters<typeof createReport>[1]- ): ReturnType<typeof createReport>;- updateReport(- input: Parameters<typeof updateReport>[1]- ): ReturnType<typeof updateReport>;- moveReport(- input: Parameters<typeof moveReport>[1]- ): ReturnType<typeof moveReport>;- deleteReport(reportId: string): ReturnType<typeof deleteReport>;- duplicateReport(report: DbReport): ReturnType<typeof duplicateReport>;- updateReportLayout(- input: Parameters<typeof updateReportLayout>[1]- ): ReturnType<typeof updateReportLayout>;- getReportLayouts(- input: Parameters<typeof getReportLayouts>[1]- ): ReturnType<typeof getReportLayouts>;- resetReportLayouts(- input: Parameters<typeof resetReportLayouts>[1]- ): ReturnType<typeof resetReportLayouts>;-}-export function createReportService(deps: ServiceDeps,_services: () => Services-): ReportService {+) {return {transformFilter,transformReportEventItem,transformReport,mergeGlobalFilters,onlyReportEvents,- getReportsByDashboardId: (dashboardId) =>+ getReportsByDashboardId: (+ dashboardId: string+ ): ReturnType<typeof getReportsByDashboardId> =>getReportsByDashboardId(deps, dashboardId),- getReportById: (id) => getReportById(deps, id),- getReportByIdOrThrow: (id) => getReportByIdOrThrow(deps, id),- listReportsCore: (input) => listReportsCore(deps, input),- getReportDataCore: (input) => getReportDataCore(deps, input),- createReport: (input) => createReport(deps, input),- updateReport: (input) => updateReport(deps, input),- moveReport: (input) => moveReport(deps, input),- deleteReport: (reportId) => deleteReport(deps, reportId),- duplicateReport: (report) => duplicateReport(deps, report),- updateReportLayout: (input) => updateReportLayout(deps, input),- getReportLayouts: (input) => getReportLayouts(deps, input),- resetReportLayouts: (input) => resetReportLayouts(deps, input),+ getReportById: (id: string): ReturnType<typeof getReportById> =>+ getReportById(deps, id),+ getReportByIdOrThrow: (+ id: string+ ): ReturnType<typeof getReportByIdOrThrow> =>+ getReportByIdOrThrow(deps, id),+ listReportsCore: (+ input: Parameters<typeof listReportsCore>[1]+ ): ReturnType<typeof listReportsCore> => listReportsCore(deps, input),+ getReportDataCore: (+ input: Parameters<typeof getReportDataCore>[1]+ ): ReturnType<typeof getReportDataCore> => getReportDataCore(deps, input),+ createReport: (+ input: Parameters<typeof createReport>[1]+ ): ReturnType<typeof createReport> => createReport(deps, input),+ updateReport: (+ input: Parameters<typeof updateReport>[1]+ ): ReturnType<typeof updateReport> => updateReport(deps, input),+ moveReport: (+ input: Parameters<typeof moveReport>[1]+ ): ReturnType<typeof moveReport> => moveReport(deps, input),+ deleteReport: (reportId: string): ReturnType<typeof deleteReport> =>+ deleteReport(deps, reportId),+ duplicateReport: (report: DbReport): ReturnType<typeof duplicateReport> =>+ duplicateReport(deps, report),+ updateReportLayout: (+ input: Parameters<typeof updateReportLayout>[1]+ ): ReturnType<typeof updateReportLayout> => updateReportLayout(deps, input),+ getReportLayouts: (+ input: Parameters<typeof getReportLayouts>[1]+ ): ReturnType<typeof getReportLayouts> => getReportLayouts(deps, input),+ resetReportLayouts: (+ input: Parameters<typeof resetReportLayouts>[1]+ ): ReturnType<typeof resetReportLayouts> => resetReportLayouts(deps, input),};}diff --git a/packages/core/src/modules/salt/salt.service.test.ts b/packages/core/src/modules/salt/salt.service.test.tsindex 4f2cc6aea..0a374bc70 100644--- a/packages/core/src/modules/salt/salt.service.test.ts+++ b/packages/core/src/modules/salt/salt.service.test.ts@@ -92,7 +92,7 @@ afterAll(() => {mock.module('@openpanel/redis', () => realRedis);});-let subject: import('./salt.service').SaltService;+let subject: ReturnType<typeof import('./salt.service').createSaltService>;let fetchSalts: typeof import('./salt.service').fetchSalts;beforeAll(async () => {const mod = await import('./salt.service');diff --git a/packages/core/src/modules/salt/salt.service.ts b/packages/core/src/modules/salt/salt.service.tsindex dce0caf7f..c2bd481a3 100644--- a/packages/core/src/modules/salt/salt.service.ts+++ b/packages/core/src/modules/salt/salt.service.ts@@ -88,16 +88,10 @@ export async function createInitialSalts(}}-export interface SaltService {- getSalts(): Promise<Salts>;- createInitialSalts(): Promise<void>;- rotateSalt(): Promise<{ salt: string; createdAt: Date }>;-}-export function createSaltService(deps: ServiceDeps,_services: () => Services-): SaltService {+) {const getSalts = cacheable(SALT_CACHE_NAME,() => fetchSalts(deps),@@ -145,8 +139,8 @@ export function createSaltService(}return {- getSalts: () => getSalts(),- createInitialSalts: () => createInitialSalts(deps),- rotateSalt: () => rotateSalt(),+ getSalts: (): Promise<Salts> => getSalts(),+ createInitialSalts: (): Promise<void> => createInitialSalts(deps),+ rotateSalt: (): Promise<{ salt: string; createdAt: Date }> => rotateSalt(),};}diff --git a/packages/core/src/modules/session/session.service.ts b/packages/core/src/modules/session/session.service.tsindex 942153683..6157284fa 100644--- a/packages/core/src/modules/session/session.service.ts+++ b/packages/core/src/modules/session/session.service.ts@@ -497,27 +497,23 @@ export async function querySessionsCore();}-export interface SessionService {- byId(- sessionId: string,- projectId: string- ): Promise<IServiceSession & { hasReplay: boolean }>;- /**- * Enqueue one `session_end` job, idempotent on the closed session's id.- * The ctx.queues-based producer; V1's now-deleted apps/worker kept its own- * @openpanel/queue producer (utils/session-handler.ts) because core could- * not import @openpanel/queue back (see cohort.service.ts's header).- */- enqueueSessionEnd(input: EnqueueSessionEndInput): Promise<void>;-}-export function createSessionService(deps: ServiceDeps,_services: () => Services-): SessionService {+) {return {- byId: (sessionId, projectId) => getSessionById(deps, sessionId, projectId),- enqueueSessionEnd: async (input) => {+ byId: (+ sessionId: string,+ projectId: string+ ): Promise<IServiceSession & { hasReplay: boolean }> =>+ getSessionById(deps, sessionId, projectId),+ /**+ * Enqueue one `session_end` job, idempotent on the closed session's id.+ * The ctx.queues-based producer; V1's now-deleted apps/worker kept its own+ * @openpanel/queue producer (utils/session-handler.ts) because core could+ * not import @openpanel/queue back (see cohort.service.ts's header).+ */+ enqueueSessionEnd: async (input: EnqueueSessionEndInput): Promise<void> => {await deps.queues.sessions.session.add(sessionEndJobPayload(input),sessionEndEnqueueOptions(input.closedSession.id)diff --git a/packages/core/src/modules/share/share.service.test.ts b/packages/core/src/modules/share/share.service.test.tsindex be23d98a2..5e51d96e1 100644--- a/packages/core/src/modules/share/share.service.test.ts+++ b/packages/core/src/modules/share/share.service.test.ts@@ -218,7 +218,7 @@ afterAll(() => {mock.module('../../shared/access-lookups', () => realAccessLookups);});-let subject: import('./share.service').ShareService;+let subject: ReturnType<typeof import('./share.service').createShareService>;beforeAll(async () => {const { createShareService } = await import('./share.service');subject = createShareService(diff --git a/packages/core/src/modules/share/share.service.ts b/packages/core/src/modules/share/share.service.tsindex 003a03868..186eaf46c 100644--- a/packages/core/src/modules/share/share.service.ts+++ b/packages/core/src/modules/share/share.service.ts@@ -593,107 +593,95 @@ export interface ShareAccessContext {session?: { userId?: string | null };}-export interface ShareService {- getShareOverviewById(id: string): ReturnType<typeof getShareOverviewById>;- getShareByProjectId(- projectId: string- ): ReturnType<typeof getShareByProjectId>;- getShareDashboardById(id: string): ReturnType<typeof getShareDashboardById>;- getShareDashboardByDashboardId(- dashboardId: string- ): ReturnType<typeof getShareDashboardByDashboardId>;- getShareReportById(id: string): ReturnType<typeof getShareReportById>;- getShareReportByReportId(- reportId: string- ): ReturnType<typeof getShareReportByReportId>;- validateReportAccess(- reportId: string,- shareId: string,- shareType: 'dashboard' | 'report'- ): ReturnType<typeof validateReportAccess>;- validateShareAccess(- shareId: string,- reportId: string,- accessContext: ShareAccessContext- ): Promise<{ projectId: string; isValid: boolean }>;- validateOverviewShareAccess(- shareId: string | undefined,- projectId: string,- accessContext: ShareAccessContext- ): Promise<{ isValid: boolean }>;- getShareOverview(- shareId: string,- cookies: CookieReader- ): ReturnType<typeof getShareOverview>;- getShareOverviewSettings(- projectId: string- ): ReturnType<typeof getShareOverviewSettings>;- createShareOverview(- input: CreateShareOverviewInput- ): ReturnType<typeof createShareOverview>;- getShareDashboard(- shareId: string,- cookies: CookieReader- ): ReturnType<typeof getShareDashboard>;- getShareDashboardSettings(- projectId: string,- dashboardId: string- ): ReturnType<typeof getShareDashboardSettings>;- createShareDashboard(- input: CreateShareDashboardInput- ): ReturnType<typeof createShareDashboard>;- getShareDashboardReports(- shareId: string,- cookies: CookieReader- ): ReturnType<typeof getShareDashboardReports>;- getShareReport(- shareId: string,- cookies: CookieReader- ): ReturnType<typeof getShareReport>;- getShareReportSettings(- projectId: string,- reportId: string- ): ReturnType<typeof getShareReportSettings>;- createShareReport(- input: CreateShareReportInput- ): ReturnType<typeof createShareReport>;-}-export function createShareService(deps: ServiceDeps,_services: () => Services-): ShareService {+) {return {- getShareOverviewById: (id) => getShareOverviewById(deps, id),- getShareByProjectId: (projectId) => getShareByProjectId(deps, projectId),- getShareDashboardById: (id) => getShareDashboardById(deps, id),- getShareDashboardByDashboardId: (dashboardId) =>+ getShareOverviewById: (+ id: string+ ): ReturnType<typeof getShareOverviewById> =>+ getShareOverviewById(deps, id),+ getShareByProjectId: (+ projectId: string+ ): ReturnType<typeof getShareByProjectId> =>+ getShareByProjectId(deps, projectId),+ getShareDashboardById: (+ id: string+ ): ReturnType<typeof getShareDashboardById> =>+ getShareDashboardById(deps, id),+ getShareDashboardByDashboardId: (+ dashboardId: string+ ): ReturnType<typeof getShareDashboardByDashboardId> =>getShareDashboardByDashboardId(deps, dashboardId),- getShareReportById: (id) => getShareReportById(deps, id),- getShareReportByReportId: (reportId) =>+ getShareReportById: (id: string): ReturnType<typeof getShareReportById> =>+ getShareReportById(deps, id),+ getShareReportByReportId: (+ reportId: string+ ): ReturnType<typeof getShareReportByReportId> =>getShareReportByReportId(deps, reportId),- validateReportAccess: (reportId, shareId, shareType) =>+ validateReportAccess: (+ reportId: string,+ shareId: string,+ shareType: 'dashboard' | 'report'+ ): ReturnType<typeof validateReportAccess> =>validateReportAccess(deps, reportId, shareId, shareType),- validateShareAccess: (shareId, reportId, accessContext) =>+ validateShareAccess: (+ shareId: string,+ reportId: string,+ accessContext: ShareAccessContext+ ): Promise<{ projectId: string; isValid: boolean }> =>validateShareAccess(deps, shareId, reportId, accessContext),- validateOverviewShareAccess: (shareId, projectId, accessContext) =>+ validateOverviewShareAccess: (+ shareId: string | undefined,+ projectId: string,+ accessContext: ShareAccessContext+ ): Promise<{ isValid: boolean }> =>validateOverviewShareAccess(deps, shareId, projectId, accessContext),- getShareOverview: (shareId, cookies) =>+ getShareOverview: (+ shareId: string,+ cookies: CookieReader+ ): ReturnType<typeof getShareOverview> =>getShareOverview(deps, shareId, cookies),- getShareOverviewSettings: (projectId) =>+ getShareOverviewSettings: (+ projectId: string+ ): ReturnType<typeof getShareOverviewSettings> =>getShareOverviewSettings(deps, projectId),- createShareOverview: (input) => createShareOverview(deps, input),- getShareDashboard: (shareId, cookies) =>+ createShareOverview: (+ input: CreateShareOverviewInput+ ): ReturnType<typeof createShareOverview> =>+ createShareOverview(deps, input),+ getShareDashboard: (+ shareId: string,+ cookies: CookieReader+ ): ReturnType<typeof getShareDashboard> =>getShareDashboard(deps, shareId, cookies),- getShareDashboardSettings: (projectId, dashboardId) =>+ getShareDashboardSettings: (+ projectId: string,+ dashboardId: string+ ): ReturnType<typeof getShareDashboardSettings> =>getShareDashboardSettings(deps, projectId, dashboardId),- createShareDashboard: (input) => createShareDashboard(deps, input),- getShareDashboardReports: (shareId, cookies) =>+ createShareDashboard: (+ input: CreateShareDashboardInput+ ): ReturnType<typeof createShareDashboard> =>+ createShareDashboard(deps, input),+ getShareDashboardReports: (+ shareId: string,+ cookies: CookieReader+ ): ReturnType<typeof getShareDashboardReports> =>getShareDashboardReports(deps, shareId, cookies),- getShareReport: (shareId, cookies) =>+ getShareReport: (+ shareId: string,+ cookies: CookieReader+ ): ReturnType<typeof getShareReport> =>getShareReport(deps, shareId, cookies),- getShareReportSettings: (projectId, reportId) =>+ getShareReportSettings: (+ projectId: string,+ reportId: string+ ): ReturnType<typeof getShareReportSettings> =>getShareReportSettings(deps, projectId, reportId),- createShareReport: (input) => createShareReport(deps, input),+ createShareReport: (+ input: CreateShareReportInput+ ): ReturnType<typeof createShareReport> => createShareReport(deps, input),};}diff --git a/packages/core/src/modules/subscription/subscription.service.ts b/packages/core/src/modules/subscription/subscription.service.tsindex b8f733956..fbd6b127f 100644--- a/packages/core/src/modules/subscription/subscription.service.ts+++ b/packages/core/src/modules/subscription/subscription.service.ts@@ -802,61 +802,46 @@ async function dispatchPolarWebhookEvent(}}-export interface SubscriptionService {- getCurrentSubscriptionProduct(- organizationId: string- ): ReturnType<typeof getCurrentSubscriptionProduct>;- checkout(- userId: string,- input: ICheckout,- ipAddress: string | undefined- ): ReturnType<typeof checkout>;- listProducts(organizationId: string): ReturnType<typeof listProducts>;- getUsage(organizationId: string): ReturnType<typeof getUsage>;- cancelSubscription(- userId: string,- input: ICancelSubscription- ): ReturnType<typeof cancelSubscription>;- pauseSubscription(- userId: string,- input: IPauseSubscription- ): ReturnType<typeof pauseSubscription>;- resumeSubscription(- userId: string,- organizationId: string- ): ReturnType<typeof resumeSubscription>;- applySaveDiscount(- userId: string,- organizationId: string- ): ReturnType<typeof applySaveDiscount>;- portal(userId: string, organizationId: string): ReturnType<typeof portal>;- handlePolarWebhookEvent(- rawBody: string | Buffer,- headers: Record<string, string>,- logger: Logger- ): Promise<void>;-}-export function createSubscriptionService(deps: ServiceDeps,_services: () => Services-): SubscriptionService {+) {return {getCurrentSubscriptionProduct,- checkout: (userId, input, ipAddress) =>- checkout(deps, userId, input, ipAddress),- listProducts: (organizationId) => listProducts(deps, organizationId),- getUsage: (organizationId) => getUsage(deps, organizationId),- cancelSubscription: (userId, input) =>+ checkout: (+ userId: string,+ input: ICheckout,+ ipAddress: string | undefined+ ): ReturnType<typeof checkout> => checkout(deps, userId, input, ipAddress),+ listProducts: (organizationId: string): ReturnType<typeof listProducts> =>+ listProducts(deps, organizationId),+ getUsage: (organizationId: string): ReturnType<typeof getUsage> =>+ getUsage(deps, organizationId),+ cancelSubscription: (+ userId: string,+ input: ICancelSubscription+ ): ReturnType<typeof cancelSubscription> =>cancelSubscription(deps, userId, input),- pauseSubscription: (userId, input) =>+ pauseSubscription: (+ userId: string,+ input: IPauseSubscription+ ): ReturnType<typeof pauseSubscription> =>pauseSubscription(deps, userId, input),- resumeSubscription: (userId, organizationId) =>+ resumeSubscription: (+ userId: string,+ organizationId: string+ ): ReturnType<typeof resumeSubscription> =>resumeSubscription(deps, userId, organizationId),- applySaveDiscount: (userId, organizationId) =>+ applySaveDiscount: (+ userId: string,+ organizationId: string+ ): ReturnType<typeof applySaveDiscount> =>applySaveDiscount(deps, userId, organizationId),portal,- handlePolarWebhookEvent: (rawBody, headers, logger) =>- handlePolarWebhookEvent(deps, rawBody, headers, logger),+ handlePolarWebhookEvent: (+ rawBody: string | Buffer,+ headers: Record<string, string>,+ logger: Logger+ ): Promise<void> => handlePolarWebhookEvent(deps, rawBody, headers, logger),};}diff --git a/packages/core/src/modules/user/user.service.ts b/packages/core/src/modules/user/user.service.tsindex 0252c399a..5a0d58b2d 100644--- a/packages/core/src/modules/user/user.service.ts+++ b/packages/core/src/modules/user/user.service.ts@@ -20,7 +20,7 @@ export type IServiceUser = Awaited<ReturnType<typeof getUserById>>;// `findUniqueOrThrow` returns a chainable "fluent" client (PromiseLike, plus// relation-loading methods), which trips up `Services['user']['getUserById']`// in v1-compat.ts — a `.then(...)` wrapping a bare fluent type there can't-// unify with the plain `Promise<User>` the interface declares.+// unify with the plain `Promise<User>` the service member declares.export function getUserById(deps: ServiceDeps, id: string): Promise<User> {return deps.db.user.findUniqueOrThrow({where: {@@ -140,28 +140,23 @@ export async function updateUserProfile(});}-export interface UserService {- getUserById(id: string): ReturnType<typeof getUserById>;- getUserAccount(- args: Parameters<typeof getUserAccount>[1]- ): ReturnType<typeof getUserAccount>;- listUserDeletionBlockers(userId: string): Promise<UserDeletionBlocker[]>;- deleteUserAccount(userId: string): Promise<void>;- updateUserProfile(- input: Parameters<typeof updateUserProfile>[1]- ): ReturnType<typeof updateUserProfile>;-}-export function createUserService(deps: ServiceDeps,_services: () => Services-): UserService {+) {return {- getUserById: (id) => getUserById(deps, id),- getUserAccount: (args) => getUserAccount(deps, args),- listUserDeletionBlockers: (userId) =>- listUserDeletionBlockers(deps, userId),- deleteUserAccount: (userId) => deleteUserAccount(deps, userId),- updateUserProfile: (input) => updateUserProfile(deps, input),+ getUserById: (id: string): ReturnType<typeof getUserById> =>+ getUserById(deps, id),+ getUserAccount: (+ args: Parameters<typeof getUserAccount>[1]+ ): ReturnType<typeof getUserAccount> => getUserAccount(deps, args),+ listUserDeletionBlockers: (+ userId: string+ ): Promise<UserDeletionBlocker[]> => listUserDeletionBlockers(deps, userId),+ deleteUserAccount: (userId: string): Promise<void> =>+ deleteUserAccount(deps, userId),+ updateUserProfile: (+ input: Parameters<typeof updateUserProfile>[1]+ ): ReturnType<typeof updateUserProfile> => updateUserProfile(deps, input),};}diff --git a/packages/core/src/services.ts b/packages/core/src/services.tsindex eade1024b..61efe3f4d 100644--- a/packages/core/src/services.ts+++ b/packages/core/src/services.ts@@ -3,144 +3,42 @@// before it with an empty interface.import type { Ctx } from './context';-import {- type AssistantService,- createAssistantService,-} from './modules/assistant/assistant.service';-import {- type AuthService,- createAuthService,-} from './modules/auth/auth.service';-import {- type ChartService,- createChartService,-} from './modules/chart/chart.service';-import {- type ConversionService,- createConversionService,-} from './modules/chart/conversion.service';-import {- createFunnelService,- type FunnelService,-} from './modules/chart/funnel.service';-import {- createRetentionService,- type RetentionService,-} from './modules/chart/retention.service';-import {- createSankeyService,- type SankeyService,-} from './modules/chart/sankey.service';-import {- type ClientService,- createClientService,-} from './modules/client/client.service';-import {- type CohortService,- createCohortService,-} from './modules/cohort/cohort.service';-import {- type ConversationService,- createConversationService,-} from './modules/conversation/conversation.service';-import {- createDashboardService,- type DashboardService,-} from './modules/dashboard/dashboard.service';-import {- createEventService,- type EventService,-} from './modules/event/event.service';-import {- createExportService,- type ExportService,-} from './modules/export/export.service';-import {- createGroupService,- type GroupService,-} from './modules/group/group.service';-import { createGscService, type GscService } from './modules/gsc/gsc.service';-import {- createImportService,- type ImportService,-} from './modules/import/import.service';-import {- createIngestService,- type IngestService,-} from './modules/ingest/ingest.service';-import {- createInsightService,- type InsightService,-} from './modules/insight/insight.service';-import {- createIntegrationService,- type IntegrationService,-} from './modules/integration/integration.service';-import { createMcpService, type McpService } from './modules/mcp/mcp.service';-import {- createMiscService,- type MiscService,-} from './modules/misc/misc.service';-import {- createNotificationService,- type NotificationService,-} from './modules/notification/notification.service';-import {- createOnboardingService,- type OnboardingService,-} from './modules/onboarding/onboarding.service';-import {- createOrganizationService,- type OrganizationService,-} from './modules/organization/organization.service';-import {- createOverviewService,- type OverviewService,-} from './modules/overview/overview.service';-import {- createPagesService,- type PagesService,-} from './modules/overview/pages.service';-import {- createProfileService,- type ProfileService,-} from './modules/profile/profile.service';-import {- createProjectService,- type ProjectService,-} from './modules/project/project.service';-import {- createRealtimeService,- type RealtimeService,-} from './modules/realtime/realtime.service';-import {- createReferenceService,- type ReferenceService,-} from './modules/reference/reference.service';-import {- createReportService,- type ReportService,-} from './modules/report/report.service';-import {- createSaltService,- type SaltService,-} from './modules/salt/salt.service';-import {- createSessionService,- type SessionService,-} from './modules/session/session.service';-import {- createShareService,- type ShareService,-} from './modules/share/share.service';-import {- createSubscriptionService,- type SubscriptionService,-} from './modules/subscription/subscription.service';-import {- createUserService,- type UserService,-} from './modules/user/user.service';+import { createAssistantService } from './modules/assistant/assistant.service';+import { createAuthService } from './modules/auth/auth.service';+import { createChartService } from './modules/chart/chart.service';+import { createConversionService } from './modules/chart/conversion.service';+import { createFunnelService } from './modules/chart/funnel.service';+import { createRetentionService } from './modules/chart/retention.service';+import { createSankeyService } from './modules/chart/sankey.service';+import { createClientService } from './modules/client/client.service';+import { createCohortService } from './modules/cohort/cohort.service';+import { createConversationService } from './modules/conversation/conversation.service';+import { createDashboardService } from './modules/dashboard/dashboard.service';+import { createEventService } from './modules/event/event.service';+import { createExportService } from './modules/export/export.service';+import { createGroupService } from './modules/group/group.service';+import { createGscService } from './modules/gsc/gsc.service';+import { createImportService } from './modules/import/import.service';+import { createIngestService } from './modules/ingest/ingest.service';+import { createInsightService } from './modules/insight/insight.service';+import { createIntegrationService } from './modules/integration/integration.service';+import { createMcpService } from './modules/mcp/mcp.service';+import { createMiscService } from './modules/misc/misc.service';+import { createNotificationService } from './modules/notification/notification.service';+import { createOnboardingService } from './modules/onboarding/onboarding.service';+import { createOrganizationService } from './modules/organization/organization.service';+import { createOverviewService } from './modules/overview/overview.service';+import { createPagesService } from './modules/overview/pages.service';+import { createProfileService } from './modules/profile/profile.service';+import { createProjectService } from './modules/project/project.service';+import { createRealtimeService } from './modules/realtime/realtime.service';+import { createReferenceService } from './modules/reference/reference.service';+import { createReportService } from './modules/report/report.service';+import { createSaltService } from './modules/salt/salt.service';+import { createSessionService } from './modules/session/session.service';+import { createShareService } from './modules/share/share.service';+import { createSubscriptionService } from './modules/subscription/subscription.service';+import { createUserService } from './modules/user/user.service';/** What every service factory receives — derived from Ctx, so it cannot drift. */export type ServiceDeps = Pick<@@ -158,47 +56,47 @@ export type ServiceDeps = Pick<// return type cannot be computed from signatures alone. Omit one and// typecheck fails with ts7022/ts7023 naming the method.export interface Services {- auth: AuthService;- insight: InsightService;- gsc: GscService;- cohort: CohortService;- import: ImportService;- ingest: IngestService;- organization: OrganizationService;- integration: IntegrationService;- onboarding: OnboardingService;- notification: NotificationService;- session: SessionService;- event: EventService;- profile: ProfileService;- group: GroupService;- chart: ChartService;+ auth: ReturnType<typeof createAuthService>;+ insight: ReturnType<typeof createInsightService>;+ gsc: ReturnType<typeof createGscService>;+ cohort: ReturnType<typeof createCohortService>;+ import: ReturnType<typeof createImportService>;+ ingest: ReturnType<typeof createIngestService>;+ organization: ReturnType<typeof createOrganizationService>;+ integration: ReturnType<typeof createIntegrationService>;+ onboarding: ReturnType<typeof createOnboardingService>;+ notification: ReturnType<typeof createNotificationService>;+ session: ReturnType<typeof createSessionService>;+ event: ReturnType<typeof createEventService>;+ profile: ReturnType<typeof createProfileService>;+ group: ReturnType<typeof createGroupService>;+ chart: ReturnType<typeof createChartService>;// One key per `*.service.ts` (M10-009): the chart module is four files// besides `chart.service.ts`, so each is bound here too. `chart` keeps the// composed facade its own callers already use — the factories build stateless// closures over `deps`, so binding a sub-module twice binds the same// functions, not a second piece of state.- funnel: FunnelService;- conversion: ConversionService;- sankey: SankeyService;- retention: RetentionService;- overview: OverviewService;- pages: PagesService;- realtime: RealtimeService;- misc: MiscService;- report: ReportService;- dashboard: DashboardService;- export: ExportService;- share: ShareService;- reference: ReferenceService;- client: ClientService;- project: ProjectService;- user: UserService;- subscription: SubscriptionService;- salt: SaltService;- conversation: ConversationService;- assistant: AssistantService;- mcp: McpService;+ funnel: ReturnType<typeof createFunnelService>;+ conversion: ReturnType<typeof createConversionService>;+ sankey: ReturnType<typeof createSankeyService>;+ retention: ReturnType<typeof createRetentionService>;+ overview: ReturnType<typeof createOverviewService>;+ pages: ReturnType<typeof createPagesService>;+ realtime: ReturnType<typeof createRealtimeService>;+ misc: ReturnType<typeof createMiscService>;+ report: ReturnType<typeof createReportService>;+ dashboard: ReturnType<typeof createDashboardService>;+ export: ReturnType<typeof createExportService>;+ share: ReturnType<typeof createShareService>;+ reference: ReturnType<typeof createReferenceService>;+ client: ReturnType<typeof createClientService>;+ project: ReturnType<typeof createProjectService>;+ user: ReturnType<typeof createUserService>;+ subscription: ReturnType<typeof createSubscriptionService>;+ salt: ReturnType<typeof createSaltService>;+ conversation: ReturnType<typeof createConversationService>;+ assistant: ReturnType<typeof createAssistantService>;+ mcp: ReturnType<typeof createMcpService>;}// MUST stay a hoisted `function` declaration, not a `const` arrow: one static