mirror of
https://github.com/docmost/docmost.git
synced 2026-08-23 07:52:12 +10:00
fix naming conflicts
This commit is contained in:
@@ -26,7 +26,7 @@ import KeyvRedis from '@keyv/redis';
|
||||
import { LoggerModule } from './common/logger/logger.module';
|
||||
import { ClsModule } from 'nestjs-cls';
|
||||
import { NoopAuditModule } from './integrations/audit/audit.module';
|
||||
import { NoopPageViewModule } from './integrations/page-view/page-view.module';
|
||||
import { NoopPageAnalyticsModule } from './integrations/page-analytics/page-analytics.module';
|
||||
import { ThrottleModule } from './integrations/throttle/throttle.module';
|
||||
|
||||
const enterpriseModules = [];
|
||||
@@ -51,7 +51,7 @@ try {
|
||||
}),
|
||||
LoggerModule,
|
||||
NoopAuditModule,
|
||||
NoopPageViewModule,
|
||||
NoopPageAnalyticsModule,
|
||||
CoreModule,
|
||||
DatabaseModule,
|
||||
EnvironmentModule,
|
||||
|
||||
@@ -15,7 +15,7 @@ export const Feature = {
|
||||
SCIM: 'scim',
|
||||
PAGE_VERIFICATION: 'page:verification',
|
||||
AUDIT_LOGS: 'audit:logs',
|
||||
PAGE_ANALYTICS: 'analytics:page-views',
|
||||
PAGE_ANALYTICS: 'analytics:page-analytics',
|
||||
RETENTION: 'retention',
|
||||
SHARING_CONTROLS: 'sharing:controls',
|
||||
VIEWER_COMMENTS: 'comment:viewer',
|
||||
|
||||
@@ -52,9 +52,9 @@ import {
|
||||
IAuditService,
|
||||
} from '../../integrations/audit/audit.service';
|
||||
import {
|
||||
PAGE_VIEW_SERVICE,
|
||||
IPageViewService,
|
||||
} from '../../integrations/page-view/page-view.service';
|
||||
PAGE_ANALYTICS_SERVICE,
|
||||
IPageAnalyticsService,
|
||||
} from '../../integrations/page-analytics/page-analytics.service';
|
||||
import { getPageTitle } from '../../common/helpers';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@@ -69,7 +69,7 @@ export class PageController {
|
||||
private readonly backlinkService: BacklinkService,
|
||||
private readonly labelService: LabelService,
|
||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||
@Inject(PAGE_VIEW_SERVICE) private readonly pageViewService: IPageViewService,
|
||||
@Inject(PAGE_ANALYTICS_SERVICE) private readonly pageAnalyticsService: IPageAnalyticsService,
|
||||
) {}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@@ -93,7 +93,7 @@ export class PageController {
|
||||
|
||||
const permissions = { canEdit, hasRestriction };
|
||||
|
||||
void this.pageViewService.track({
|
||||
void this.pageAnalyticsService.track({
|
||||
pageId: page.id,
|
||||
workspaceId: page.workspaceId,
|
||||
spaceId: page.spaceId,
|
||||
|
||||
@@ -36,9 +36,9 @@ import {
|
||||
IAuditService,
|
||||
} from '../../integrations/audit/audit.service';
|
||||
import {
|
||||
PAGE_VIEW_SERVICE,
|
||||
IPageViewService,
|
||||
} from '../../integrations/page-view/page-view.service';
|
||||
PAGE_ANALYTICS_SERVICE,
|
||||
IPageAnalyticsService,
|
||||
} from '../../integrations/page-analytics/page-analytics.service';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('shares')
|
||||
@@ -51,8 +51,8 @@ export class ShareController {
|
||||
private readonly pageAccessService: PageAccessService,
|
||||
private readonly licenseCheckService: LicenseCheckService,
|
||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||
@Inject(PAGE_VIEW_SERVICE)
|
||||
private readonly pageViewService: IPageViewService,
|
||||
@Inject(PAGE_ANALYTICS_SERVICE)
|
||||
private readonly pageAnalyticsService: IPageAnalyticsService,
|
||||
) {}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@@ -85,7 +85,7 @@ export class ShareController {
|
||||
throw new NotFoundException('Shared page not found');
|
||||
}
|
||||
|
||||
void this.pageViewService.track({
|
||||
void this.pageAnalyticsService.track({
|
||||
pageId: shareData.page.id,
|
||||
workspaceId: workspace.id,
|
||||
spaceId: shareData.page.spaceId,
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@ import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('page_views')
|
||||
.createTable('page_analytics')
|
||||
.ifNotExists()
|
||||
.addColumn('id', 'uuid', (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
||||
@@ -32,16 +32,16 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex('idx_page_views_workspace_page_date')
|
||||
.createIndex('idx_page_analytics_workspace_page_date')
|
||||
.ifNotExists()
|
||||
.on('page_views')
|
||||
.on('page_analytics')
|
||||
.columns(['workspace_id', 'page_id', 'view_date'])
|
||||
.execute();
|
||||
|
||||
await sql`
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS
|
||||
uq_page_views_workspace_page_identity
|
||||
ON page_views (
|
||||
uq_page_analytics_workspace_page_identity
|
||||
ON page_analytics (
|
||||
workspace_id,
|
||||
page_id,
|
||||
COALESCE(user_id::text, visitor_id)
|
||||
@@ -50,5 +50,5 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable('page_views').ifExists().execute();
|
||||
await db.schema.dropTable('page_analytics').ifExists().execute();
|
||||
}
|
||||
+2
-2
@@ -544,7 +544,7 @@ export interface PagePermissions {
|
||||
updatedAt: Generated<Timestamp>;
|
||||
}
|
||||
|
||||
export interface PageViews {
|
||||
export interface PageAnalytics {
|
||||
id: Generated<string>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
@@ -676,7 +676,7 @@ export interface DB {
|
||||
pagePermissions: PagePermissions;
|
||||
pageHistory: PageHistory;
|
||||
pageLabels: PageLabels;
|
||||
pageViews: PageViews;
|
||||
pageAnalytics: PageAnalytics;
|
||||
pageVerifications: PageVerifications;
|
||||
pageVerifiers: PageVerifiers;
|
||||
pages: Pages;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Insertable, Selectable, Updateable } from 'kysely';
|
||||
import {
|
||||
AiChats,
|
||||
PageViews,
|
||||
PageAnalytics as _PageAnalytics,
|
||||
AiChatMessages,
|
||||
Attachments,
|
||||
BaseProperties,
|
||||
@@ -108,9 +108,9 @@ export type PageHistory = Selectable<History>;
|
||||
export type InsertablePageHistory = Insertable<History>;
|
||||
export type UpdatablePageHistory = Updateable<Omit<History, 'id'>>;
|
||||
|
||||
export type PageView = Selectable<PageViews>;
|
||||
export type InsertablePageView = Insertable<PageViews>;
|
||||
export type UpdatablePageView = Updateable<Omit<PageViews, 'id'>>;
|
||||
export type PageAnalytics = Selectable<_PageAnalytics>;
|
||||
export type InsertablePageAnalytics = Insertable<_PageAnalytics>;
|
||||
export type UpdatablePageAnalytics = Updateable<Omit<_PageAnalytics, 'id'>>;
|
||||
|
||||
// Comment
|
||||
export type Comment = Selectable<Comments>;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { PAGE_ANALYTICS_SERVICE, NoopPageAnalyticsService } from './page-analytics.service';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [
|
||||
{
|
||||
provide: PAGE_ANALYTICS_SERVICE,
|
||||
useClass: NoopPageAnalyticsService,
|
||||
},
|
||||
],
|
||||
exports: [PAGE_ANALYTICS_SERVICE],
|
||||
})
|
||||
export class NoopPageAnalyticsModule {}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
export type PageAnalyticsPayload = {
|
||||
pageId: string;
|
||||
workspaceId?: string;
|
||||
spaceId?: string;
|
||||
shareId?: string;
|
||||
userId?: string | null;
|
||||
visitorId?: string;
|
||||
};
|
||||
|
||||
export const PAGE_ANALYTICS_SERVICE = Symbol('PAGE_ANALYTICS_SERVICE');
|
||||
|
||||
export interface IPageAnalyticsService {
|
||||
track(payload: PageAnalyticsPayload): void | Promise<void>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoopPageAnalyticsService implements IPageAnalyticsService {
|
||||
track(_payload: PageAnalyticsPayload): void {}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { PAGE_VIEW_SERVICE, NoopPageViewService } from './page-view.service';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [
|
||||
{
|
||||
provide: PAGE_VIEW_SERVICE,
|
||||
useClass: NoopPageViewService,
|
||||
},
|
||||
],
|
||||
exports: [PAGE_VIEW_SERVICE],
|
||||
})
|
||||
export class NoopPageViewModule {}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
export type PageViewPayload = {
|
||||
pageId: string;
|
||||
workspaceId?: string;
|
||||
spaceId?: string;
|
||||
shareId?: string;
|
||||
userId?: string | null;
|
||||
visitorId?: string;
|
||||
};
|
||||
|
||||
export const PAGE_VIEW_SERVICE = Symbol('PAGE_VIEW_SERVICE');
|
||||
|
||||
export interface IPageViewService {
|
||||
track(payload: PageViewPayload): void | Promise<void>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoopPageViewService implements IPageViewService {
|
||||
track(_payload: PageViewPayload): void {}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export enum QueueName {
|
||||
HISTORY_QUEUE = '{history-queue}',
|
||||
NOTIFICATION_QUEUE = '{notification-queue}',
|
||||
AUDIT_QUEUE = '{audit-queue}',
|
||||
PAGE_VIEW_QUEUE = '{page-view-queue}',
|
||||
PAGE_ANALYTICS_QUEUE = '{page-analytics-queue}',
|
||||
BASE_QUEUE = '{base-queue}',
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ export enum QueueJob {
|
||||
|
||||
AUDIT_LOG = 'audit-log',
|
||||
AUDIT_CLEANUP = 'audit-cleanup',
|
||||
PAGE_VIEW_TRACK = 'page-view-track',
|
||||
PAGE_VIEW_CLEANUP = 'page-view-cleanup',
|
||||
PAGE_ANALYTICS_TRACK = 'page-analytics-track',
|
||||
PAGE_ANALYTICS_CLEANUP = 'page-analytics-cleanup',
|
||||
|
||||
PDF_EXPORT_TASK = 'pdf-export-task',
|
||||
PDF_EXPORT_CLEANUP = 'pdf-export-cleanup',
|
||||
|
||||
@@ -93,7 +93,7 @@ import { GeneralQueueProcessor } from './processors/general-queue.processor';
|
||||
},
|
||||
}),
|
||||
BullModule.registerQueue({
|
||||
name: QueueName.PAGE_VIEW_QUEUE,
|
||||
name: QueueName.PAGE_ANALYTICS_QUEUE,
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
|
||||
Reference in New Issue
Block a user