diff --git a/packages/nocodb/src/interface/Jobs.ts b/packages/nocodb/src/interface/Jobs.ts index 60b720ec5d..106f5dd446 100644 --- a/packages/nocodb/src/interface/Jobs.ts +++ b/packages/nocodb/src/interface/Jobs.ts @@ -29,6 +29,8 @@ export enum JobTypes { AttachmentCleanUp = 'attachment-clean-up', InitMigrationJobs = 'init-migration-jobs', UseWorker = 'use-worker', + CreateSnapshot = 'create-snapshot', + RestoreSnapshot = 'restore-snapshot', } export const SKIP_STORING_JOB_META = [ @@ -167,3 +169,15 @@ export interface ThumbnailGeneratorJobData extends JobData { attachments: AttachmentResType[]; scope?: PublicAttachmentScope; } + +export interface CreateSnapshotJobData extends JobData { + sourceId: string; + dupProjectId: string; + req: NcRequest; +} + +export interface RestoreSnapshotJobData extends JobData { + sourceId: string; + dupProjectId: string; + req: NcRequest; +} diff --git a/packages/nocodb/src/modules/jobs/jobs.module.ts b/packages/nocodb/src/modules/jobs/jobs.module.ts index 81199d1d54..fe3a77ca96 100644 --- a/packages/nocodb/src/modules/jobs/jobs.module.ts +++ b/packages/nocodb/src/modules/jobs/jobs.module.ts @@ -44,6 +44,7 @@ import { QueueService as FallbackQueueService } from '~/modules/jobs/fallback/fa import { JOBS_QUEUE } from '~/interface/Jobs'; import { RecoverLinksMigration } from '~/modules/jobs/migration-jobs/nc_job_003_recover_links'; import { CleanupDuplicateColumnMigration } from '~/modules/jobs/migration-jobs/nc_job_004_cleanup_duplicate_column'; +import { SnapshotController } from '~/modules/jobs/jobs/snapshot/snapshot.controller'; export const JobsModuleMetadata = { imports: [ @@ -73,6 +74,7 @@ export const JobsModuleMetadata = { SourceCreateController, SourceDeleteController, DataExportController, + SnapshotController, ] : []), ], diff --git a/packages/nocodb/src/modules/jobs/jobs/snapshot/snapshot.controller.ts b/packages/nocodb/src/modules/jobs/jobs/snapshot/snapshot.controller.ts new file mode 100644 index 0000000000..68fbce9ad7 --- /dev/null +++ b/packages/nocodb/src/modules/jobs/jobs/snapshot/snapshot.controller.ts @@ -0,0 +1,29 @@ +import { Controller, Inject, Param, Post, UseGuards } from '@nestjs/common'; +import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; +import { GlobalGuard } from '~/guards/global/global.guard'; +import { IJobsService } from '~/modules/jobs/jobs-service.interface'; +import { TenantContext } from '~/decorators/tenant-context.decorator'; +import { NcContext } from '~/interface/config'; + +@Controller() +@UseGuards(MetaApiLimiterGuard, GlobalGuard) +export class SnapshotController { + constructor( + @Inject('JobsService') private readonly jobsService: IJobsService, + ) {} + + // TODO: @DarkPhoenix2704 Add ACL + @Post('/api/v2/meta/bases/:baseId/snapshots/:snapshotId/restore') + async restoreSnapshot( + @TenantContext() context: NcContext, + @Param('snapshotId') snapshotId: string, + ) { + // return await this.snapshotService.restoreSnapshot(context, snapshotId); + } + + // TODO: @DarkPhoenix2704 Add ACL + @Post('/api/v2/meta/bases/:baseId/snapshots') + async createSnapshot(@TenantContext() context: NcContext) { + // return await this.snapshotService.createSnapshot(); + } +}