Browse Source

chore: move create and restore snapshot to jobs

pull/9879/head
DarkPhoenix2704 3 days ago
parent
commit
2658a9efe6
  1. 14
      packages/nocodb/src/interface/Jobs.ts
  2. 2
      packages/nocodb/src/modules/jobs/jobs.module.ts
  3. 29
      packages/nocodb/src/modules/jobs/jobs/snapshot/snapshot.controller.ts

14
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;
}

2
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,
]
: []),
],

29
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();
}
}
Loading…
Cancel
Save