Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Replace relative imports with absolute src/ imports #39

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/trench/src/api-keys/api-keys.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common'
import { ApiKeysService } from './api-keys.service'
import { ClickHouseModule } from '../services/data/click-house/click-house.module'
import { ApiKeysService } from 'src/api-keys/api-keys.service'
import { ClickHouseModule } from 'src/services/data/click-house/click-house.module'
import { CacheModule } from '@nestjs/cache-manager'

@Module({
Expand Down
10 changes: 5 additions & 5 deletions apps/trench/src/api-keys/api-keys.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from '@nestjs/common'
import { ClickHouseService } from '../services/data/click-house/click-house.service'
import { escapeString } from '../services/data/click-house/click-house.util'
import { ClickHouseService } from 'src/services/data/click-house/click-house.service'
import { escapeString } from 'src/services/data/click-house/click-house.util'
import { Cache } from '@nestjs/cache-manager'
import { Inject } from '@nestjs/common'
import { v4 as uuidv4 } from 'uuid'
import { ApiKeyType } from './api-keys.interface'
import { Workspace } from '../workspaces/workspaces.interface'
import { mapRowToWorkspace } from '../workspaces/workspaces.util'
import { ApiKeyType } from 'src/api-keys/api-keys.interface'
import { Workspace } from 'src/workspaces/workspaces.interface'
import { mapRowToWorkspace } from 'src/workspaces/workspaces.util'
const IS_VALID_API_KEY_STRING = 'is-valid'
const IS_INVALID_API_KEY_STRING = 'is-invalid'
@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion apps/trench/src/common/request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request } from '@nestjs/common'
import { Workspace } from '../workspaces/workspaces.interface'
import { Workspace } from 'src/workspaces/workspaces.interface'

export function getWorkspace(req: Request): Workspace {
const workspace = (req as any).workspace
Expand Down
10 changes: 5 additions & 5 deletions apps/trench/src/events/events.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Body, Controller, Get, Post, Query, Request, UseGuards } from '@nestjs/common'
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
import { EventsService } from './events.service'
import { EventsService } from 'src/events/events.service'

import { EventsDTO, EventsQuery, PaginatedEventResponse } from './events.interface'
import { PublicApiGuard } from '../middlewares/public-api.guard'
import { PrivateApiGuard } from '../middlewares/private-api.guard'
import { getWorkspace } from '../common/request'
import { EventsDTO, EventsQuery, PaginatedEventResponse } from 'src/events/events.interface'
import { PublicApiGuard } from 'src/middlewares/public-api.guard'
import { PrivateApiGuard } from 'src/middlewares/private-api.guard'
import { getWorkspace } from 'src/common/request'

@ApiBearerAuth()
@ApiTags('events')
Expand Down
18 changes: 9 additions & 9 deletions apps/trench/src/events/events.dao.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { BadRequestException, Injectable } from '@nestjs/common'
import { ClickHouseService } from '../services/data/click-house/click-house.service'
import { escapeString, formatToClickhouseDate } from '../services/data/click-house/click-house.util'
import { Event, EventDTO, EventsQuery, PaginatedEventResponse } from './events.interface'
import { KafkaService } from '../services/data/kafka/kafka.service'
import { KafkaEventWithUUID } from '../services/data/kafka/kafka.interface'
import { ClickHouseService } from 'src/services/data/click-house/click-house.service'
import { escapeString, formatToClickhouseDate } from 'src/services/data/click-house/click-house.util'
import { Event, EventDTO, EventsQuery, PaginatedEventResponse } from 'src/events/events.interface'
import { KafkaService } from 'src/services/data/kafka/kafka.service'
import { KafkaEventWithUUID } from 'src/services/data/kafka/kafka.interface'
import { v4 as uuidv4 } from 'uuid'
import { mapRowToEvent } from './events.util'
import { Workspace } from '../workspaces/workspaces.interface'
import { getKafkaTopicFromWorkspace } from '../services/data/kafka/kafka.util'
import { isReadOnlyQuery } from '../queries/queries.util'
import { mapRowToEvent } from 'src/events/events.util'
import { Workspace } from 'src/workspaces/workspaces.interface'
import { getKafkaTopicFromWorkspace } from 'src/services/data/kafka/kafka.util'
import { isReadOnlyQuery } from 'src/queries/queries.util'

@Injectable()
export class EventsDao {
Expand Down
2 changes: 1 addition & 1 deletion apps/trench/src/events/events.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger'
import { PaginatedResponse } from '../common/models'
import { PaginatedResponse } from 'src/common/models'

export class EventDTO {
@ApiProperty({
Expand Down
12 changes: 6 additions & 6 deletions apps/trench/src/events/events.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Module } from '@nestjs/common'
import { EventsService } from './events.service'
import { EventsController } from './events.controller'
import { KafkaModule } from '../services/data/kafka/kafka.module'
import { ApiKeysModule } from '../api-keys/api-keys.module'
import { EventsDao } from './events.dao'
import { ClickHouseModule } from '../services/data/click-house/click-house.module'
import { EventsService } from 'src/events/events.service'
import { EventsController } from 'src/events/events.controller'
import { KafkaModule } from 'src/services/data/kafka/kafka.module'
import { ApiKeysModule } from 'src/api-keys/api-keys.module'
import { EventsDao } from 'src/events/events.dao'
import { ClickHouseModule } from 'src/services/data/click-house/click-house.module'

@Module({
imports: [KafkaModule, ApiKeysModule, ClickHouseModule],
Expand Down
8 changes: 4 additions & 4 deletions apps/trench/src/events/events.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common'
import { EventDTO, EventsQuery, PaginatedEventResponse } from './events.interface'
import { EventsDao } from './events.dao'
import { Event } from './events.interface'
import { Workspace } from '../workspaces/workspaces.interface'
import { EventDTO, EventsQuery, PaginatedEventResponse } from 'src/events/events.interface'
import { EventsDao } from 'src/events/events.dao'
import { Event } from 'src/events/events.interface'
import { Workspace } from 'src/workspaces/workspaces.interface'

@Injectable()
export class EventsService {
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/middlewares/admin-api.guard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common'
import { ApiKeysService } from '../api-keys/api-keys.service'
import { ApiGuard } from './api.guard'
import { ApiKeysService } from 'src/api-keys/api-keys.service'
import { ApiGuard } from 'src/middlewares/api.guard'

@Injectable()
export class AdminApiGuard extends ApiGuard {
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/middlewares/api.guard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CanActivate, ExecutionContext, Injectable, UnauthorizedException } from '@nestjs/common'
import { Observable } from 'rxjs'
import { ApiKeysService } from '../api-keys/api-keys.service'
import { ApiKeyType } from '../api-keys/api-keys.interface'
import { ApiKeysService } from 'src/api-keys/api-keys.service'
import { ApiKeyType } from 'src/api-keys/api-keys.interface'

export class ApiGuard implements CanActivate {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/middlewares/private-api.guard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common'
import { ApiKeysService } from '../api-keys/api-keys.service'
import { ApiGuard } from './api.guard'
import { ApiKeysService } from 'src/api-keys/api-keys.service'
import { ApiGuard } from 'src/middlewares/api.guard'

@Injectable()
export class PrivateApiGuard extends ApiGuard {
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/middlewares/public-api.guard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common'
import { ApiKeysService } from '../api-keys/api-keys.service'
import { ApiGuard } from './api.guard'
import { ApiKeysService } from 'src/api-keys/api-keys.service'
import { ApiGuard } from 'src/middlewares/api.guard'

@Injectable()
export class PublicApiGuard extends ApiGuard {
Expand Down
10 changes: 5 additions & 5 deletions apps/trench/src/queries/queries.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Controller, Post, Body, HttpException, HttpStatus, UseGuards, Req } from '@nestjs/common'
import { QueriesService } from './queries.service'
import { PaginatedQueryResponse, QueriesDTO } from './queries.interface'
import { PrivateApiGuard } from '../middlewares/private-api.guard'
import { PaginatedResponse } from '../common/models'
import { QueriesService } from 'src/queries/queries.service'
import { PaginatedQueryResponse, QueriesDTO } from 'src/queries/queries.interface'
import { PrivateApiGuard } from 'src/middlewares/private-api.guard'
import { PaginatedResponse } from 'src/common/models'
import { ApiOperation, ApiResponse } from '@nestjs/swagger'
import { getWorkspace } from '../common/request'
import { getWorkspace } from 'src/common/request'

@Controller('queries')
@UseGuards(PrivateApiGuard)
Expand Down
2 changes: 1 addition & 1 deletion apps/trench/src/queries/queries.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger'
import { PaginatedResponse } from '../common/models'
import { PaginatedResponse } from 'src/common/models'

export class QueriesDTO {
@ApiProperty({
Expand Down
12 changes: 6 additions & 6 deletions apps/trench/src/queries/queries.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Module } from '@nestjs/common'
import { QueriesService } from './queries.service'
import { QueriesController } from './queries.controller'
import { ClickHouseService } from '../services/data/click-house/click-house.service'
import { ClickHouseModule } from '../services/data/click-house/click-house.module'
import { ApiKeysModule } from '../api-keys/api-keys.module'
import { WorkspacesModule } from '../workspaces/workspaces.module'
import { QueriesService } from 'src/queries/queries.service'
import { QueriesController } from 'src/queries/queries.controller'
import { ClickHouseService } from 'src/services/data/click-house/click-house.service'
import { ClickHouseModule } from 'src/services/data/click-house/click-house.module'
import { ApiKeysModule } from 'src/api-keys/api-keys.module'
import { WorkspacesModule } from 'src/workspaces/workspaces.module'

@Module({
imports: [ClickHouseModule, ApiKeysModule, WorkspacesModule],
Expand Down
10 changes: 5 additions & 5 deletions apps/trench/src/queries/queries.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Injectable } from '@nestjs/common'
import { ClickHouseService } from '../services/data/click-house/click-house.service'
import { ClickHouseService } from 'src/services/data/click-house/click-house.service'
import {
convertJsonKeysToCamelCase,
convertObjectToArray,
convertToKebabCase,
isReadOnlyQuery,
parseJsonFields,
} from './queries.util'
import { QueriesDTO } from './queries.interface'
import { WorkspacesService } from '../workspaces/workspaces.service'
import { Workspace } from '../workspaces/workspaces.interface'
} from 'src/queries/queries.util'
import { QueriesDTO } from 'src/queries/queries.interface'
import { WorkspacesService } from 'src/workspaces/workspaces.service'
import { Workspace } from 'src/workspaces/workspaces.interface'

@Injectable()
export class QueriesService {
Expand Down
8 changes: 4 additions & 4 deletions apps/trench/src/services/data/bootstrap/bootstrap.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common'
import { BootstrapService } from './bootstrap.service'
import { KafkaModule } from '../kafka/kafka.module'
import { ClickHouseModule } from '../click-house/click-house.module'
import { WorkspacesModule } from '../../../workspaces/workspaces.module'
import { BootstrapService } from 'src/services/data/bootstrap/bootstrap.service'
import { KafkaModule } from 'src/services/data/kafka/kafka.module'
import { ClickHouseModule } from 'src/services/data/click-house/click-house.module'
import { WorkspacesModule } from 'src/workspaces/workspaces.module'

@Module({
imports: [ClickHouseModule, KafkaModule],
Expand Down
14 changes: 7 additions & 7 deletions apps/trench/src/services/data/bootstrap/bootstrap.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable, Logger } from '@nestjs/common'
import { ClickHouseService } from '../click-house/click-house.service'
import { KafkaService } from '../kafka/kafka.service'
import { DEFAULT_WORKSPACE_ID } from '../../../common/constants'
import { DEFAULT_WORKSPACE_NAME } from '../../../common/constants'
import { getKafkaTopicFromWorkspace } from '../kafka/kafka.util'
import { mapRowToWorkspace } from '../../../workspaces/workspaces.util'
import { Workspace } from '../../../workspaces/workspaces.interface'
import { ClickHouseService } from 'src/services/data/click-house/click-house.service'
import { KafkaService } from 'src/services/data/kafka/kafka.service'
import { DEFAULT_WORKSPACE_ID } from 'src/common/constants'
import { DEFAULT_WORKSPACE_NAME } from 'src/common/constants'
import { getKafkaTopicFromWorkspace } from 'src/services/data/kafka/kafka.util'
import { mapRowToWorkspace } from 'src/workspaces/workspaces.util'
import { Workspace } from 'src/workspaces/workspaces.interface'

@Injectable()
export class BootstrapService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Injectable, Logger } from '@nestjs/common'
import { createClient, ClickHouseClient } from '@clickhouse/client'
import * as fs from 'fs'
import * as path from 'path'
import { Migration } from './click-house.interface'
import { md5 } from '../../../common/crypto'
import { Migration } from 'src/services/data/click-house/click-house.interface'
import { md5 } from 'src/common/crypto'
import {
DEFAULT_KAFKA_BROKERS,
DEFAULT_KAFKA_PARTITIONS,
DEFAULT_KAFKA_TOPIC,
} from '../../../common/constants'
} from 'src/common/constants'

@Injectable()
export class ClickHouseService {
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/services/data/kafka/kafka.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, Logger } from '@nestjs/common'
import { Consumer, Kafka, Producer } from 'kafkajs'
import { KafkaEventWithUUID } from './kafka.interface'
import { DEFAULT_KAFKA_CLIENT_ID, DEFAULT_KAFKA_PARTITIONS } from '../../../common/constants'
import { KafkaEventWithUUID } from 'src/services/data/kafka/kafka.interface'
import { DEFAULT_KAFKA_CLIENT_ID, DEFAULT_KAFKA_PARTITIONS } from 'src/common/constants'

@Injectable()
export class KafkaService {
Expand Down
2 changes: 1 addition & 1 deletion apps/trench/src/services/data/kafka/kafka.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Workspace } from '../../../workspaces/workspaces.interface'
import { Workspace } from 'src/workspaces/workspaces.interface'

export function getKafkaTopicFromWorkspace(workspace: Workspace): string {
if (workspace.isDefault) {
Expand Down
10 changes: 5 additions & 5 deletions apps/trench/src/webhooks/webhooks.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Controller, Get, Post, Delete, Put, Body, Param, UseGuards, Request } from '@nestjs/common'
import { WebhooksService } from './webhooks.service'
import { PaginatedWebhookResponse, Webhook, WebhookDTO } from './webhooks.interface'
import { PrivateApiGuard } from '../middlewares/private-api.guard'
import { WebhooksService } from 'src/webhooks/webhooks.service'
import { PaginatedWebhookResponse, Webhook, WebhookDTO } from 'src/webhooks/webhooks.interface'
import { PrivateApiGuard } from 'src/middlewares/private-api.guard'
import { ApiBearerAuth, ApiOperation, ApiResponse } from '@nestjs/swagger'
import { PaginatedResponse } from '../common/models'
import { getWorkspace } from '../common/request'
import { PaginatedResponse } from 'src/common/models'
import { getWorkspace } from 'src/common/request'

@ApiBearerAuth()
@Controller('webhooks')
Expand Down
6 changes: 3 additions & 3 deletions apps/trench/src/webhooks/webhooks.dao.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BadRequestException, Inject, Injectable } from '@nestjs/common'
import { ClickHouseService } from '../services/data/click-house/click-house.service'
import { Webhook, WebhookDTO } from './webhooks.interface'
import { ClickHouseService } from 'src/services/data/click-house/click-house.service'
import { Webhook, WebhookDTO } from 'src/webhooks/webhooks.interface'
import { CACHE_MANAGER } from '@nestjs/cache-manager'
import { Cache } from 'cache-manager'
import { v4 as uuidv4 } from 'uuid'
import { Workspace } from '../workspaces/workspaces.interface'
import { Workspace } from 'src/workspaces/workspaces.interface'
const CACHE_KEY = 'webhooks'
@Injectable()
export class WebhooksDao {
Expand Down
2 changes: 1 addition & 1 deletion apps/trench/src/webhooks/webhooks.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger'
import { PaginatedResponse } from '../common/models'
import { PaginatedResponse } from 'src/common/models'

export class Webhook {
@ApiProperty({
Expand Down
18 changes: 9 additions & 9 deletions apps/trench/src/webhooks/webhooks.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Module } from '@nestjs/common'
import { WebhooksService } from './webhooks.service'
import { ClickHouseModule } from '../services/data/click-house/click-house.module'
import { KafkaModule } from '../services/data/kafka/kafka.module'
import { EventsModule } from '../events/events.module'
import { WebhooksDao } from './webhooks.dao'
import { WebhooksController } from './webhooks.controller'
import { ApiKeysService } from '../api-keys/api-keys.service'
import { ApiKeysModule } from '../api-keys/api-keys.module'
import { WebhooksService } from 'src/webhooks/webhooks.service'
import { ClickHouseModule } from 'src/services/data/click-house/click-house.module'
import { KafkaModule } from 'src/services/data/kafka/kafka.module'
import { EventsModule } from 'src/events/events.module'
import { WebhooksDao } from 'src/webhooks/webhooks.dao'
import { WebhooksController } from 'src/webhooks/webhooks.controller'
import { ApiKeysService } from 'src/api-keys/api-keys.service'
import { ApiKeysModule } from 'src/api-keys/api-keys.module'
import { CacheModule } from '@nestjs/cache-manager'
import { WorkspacesModule } from '../workspaces/workspaces.module'
import { WorkspacesModule } from 'src/workspaces/workspaces.module'

@Module({
imports: [
Expand Down
26 changes: 13 additions & 13 deletions apps/trench/src/webhooks/webhooks.service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Injectable, Logger, OnModuleInit } from '@nestjs/common'
import { KafkaService } from '../services/data/kafka/kafka.service'
import { WebhooksDao } from './webhooks.dao'
import { DEFAULT_KAFKA_TOPIC } from '../common/constants'
import { KafkaEvent } from '../services/data/kafka/kafka.interface'
import { Webhook, WebhookDTO } from './webhooks.interface'

import { EventsService } from '../events/events.service'
import { Event } from '../events/events.interface'
import { flatten } from '../common/utils'
import { Workspace } from '../workspaces/workspaces.interface'
import { WorkspacesService } from '../workspaces/workspaces.service'
import { getKafkaTopicFromWorkspace } from '../services/data/kafka/kafka.util'
import { shouldProcessEvent } from './webhooks.util'
import { KafkaService } from 'src/services/data/kafka/kafka.service'
import { WebhooksDao } from 'src/webhooks/webhooks.dao'
import { DEFAULT_KAFKA_TOPIC } from 'src/common/constants'
import { KafkaEvent } from 'src/services/data/kafka/kafka.interface'
import { Webhook, WebhookDTO } from 'src/webhooks/webhooks.interface'

import { EventsService } from 'src/events/events.service'
import { Event } from 'src/events/events.interface'
import { flatten } from 'src/common/utils'
import { Workspace } from 'src/workspaces/workspaces.interface'
import { WorkspacesService } from 'src/workspaces/workspaces.service'
import { getKafkaTopicFromWorkspace } from 'src/services/data/kafka/kafka.util'
import { shouldProcessEvent } from 'src/webhooks/webhooks.util'
import { Consumer } from 'kafkajs'
@Injectable()
export class WebhooksService implements OnModuleInit {
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/webhooks/webhooks.util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { KafkaEvent } from '../services/data/kafka/kafka.interface'
import { Webhook } from './webhooks.interface'
import { KafkaEvent } from 'src/services/data/kafka/kafka.interface'
import { Webhook } from 'src/webhooks/webhooks.interface'

export function shouldProcessEvent(event: KafkaEvent, webhook: Webhook): boolean {
const typeMatches = webhook.eventTypes.includes('*') || webhook.eventTypes.includes(event.type)
Expand Down
6 changes: 3 additions & 3 deletions apps/trench/src/workspaces/workspaces.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
Get,
} from '@nestjs/common'

import { AdminApiGuard } from '../middlewares/admin-api.guard'
import { WorkspacesService } from './workspaces.service'
import { CreateWorkspaceDto, Workspace } from './workspaces.interface'
import { AdminApiGuard } from 'src/middlewares/admin-api.guard'
import { WorkspacesService } from 'src/workspaces/workspaces.service'
import { CreateWorkspaceDto, Workspace } from 'src/workspaces/workspaces.interface'
import { ApiOperation, ApiResponse } from '@nestjs/swagger'

@Controller('workspaces')
Expand Down
Loading
Loading