Browse Source

minor build fixes after rebase

feat/export-nest-dir-restructure
starbirdtech383 2 years ago
parent
commit
4c64b826b5
  1. 36
      packages/nc-plugin/package-lock.json
  2. 54668
      packages/nocodb/package-lock.json
  3. 29
      packages/nocodb/package.json
  4. 21
      packages/nocodb/src/controllers/export-import.controller.spec.ts
  5. 51
      packages/nocodb/src/controllers/export-import.controller.ts
  6. 6
      packages/nocodb/src/controllers/imports/helpers/NocoSyncDestAdapter.ts
  7. 7
      packages/nocodb/src/controllers/imports/helpers/NocoSyncSourceAdapter.ts
  8. 2480
      packages/nocodb/src/controllers/imports/helpers/job.ts
  9. 4
      packages/nocodb/src/controllers/imports/helpers/readAndProcessData.ts
  10. 21
      packages/nocodb/src/controllers/imports/import.controller.spec.ts
  11. 148
      packages/nocodb/src/controllers/imports/import.controller.ts

36
packages/nc-plugin/package-lock.json generated

@ -472,20 +472,6 @@
"node": ">=v14"
}
},
"node_modules/@commitlint/config-validator": {
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.4.4.tgz",
"integrity": "sha512-bi0+TstqMiqoBAQDvdEP4AFh0GaKyLFlPPEObgI29utoKEYoPQTvF0EYqIwYYLEoJYhj5GfMIhPHJkTJhagfeg==",
"dev": true,
"optional": true,
"dependencies": {
"@commitlint/types": "^17.4.4",
"ajv": "^8.11.0"
},
"engines": {
"node": ">=v14"
}
},
"node_modules/@commitlint/config-validator/node_modules/ajv": {
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
@ -12621,6 +12607,28 @@
"requires": {
"@commitlint/types": "^17.4.4",
"ajv": "^8.11.0"
},
"dependencies": {
"ajv": {
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
"integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
"dev": true,
"optional": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2",
"uri-js": "^4.2.2"
}
},
"json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"optional": true
}
}
},
"@commitlint/execute-rule": {

54668
packages/nocodb/package-lock.json generated

File diff suppressed because it is too large Load Diff

29
packages/nocodb/package.json

@ -111,7 +111,7 @@
"mysql2": "^3.2.0",
"nanoid": "^3.1.20",
"nc-help": "^0.2.87",
"nc-lib-gui": "0.106.0",
"nc-lib-gui": "0.107.0-beta.0",
"nc-plugin": "file:../nc-plugin",
"ncp": "^2.0.0",
"nocodb-sdk": "file:../nocodb-sdk",
@ -147,19 +147,20 @@
"xlsx": "^0.18.5"
},
"devDependencies": {
"@types/chai": "^4.2.12",
"@types/express": "^4.17.7",
"@types/inflection": "^1.5.28",
"@types/lru-cache": "^5.1.0",
"@types/minio": "^7.0.7",
"@types/mkdirp": "^1.0.2",
"@types/mocha": "^8.0.1",
"@types/node": "^18.0.0",
"@types/nodemailer": "^6.4.0",
"@types/supertest": "^2.0.10",
"@types/tinycolor2": "^1.4.3",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@nestjsplus/dyn-schematics": "^1.0.12",
"@types/express": "^4.17.13",
"@types/jest": "^29.5.0",
"@types/mocha": "^10.0.1",
"@types/multer": "^1.4.7",
"@types/node": "18.15.11",
"@types/passport-google-oauth20": "^2.0.11",
"@types/passport-jwt": "^3.0.8",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"chai": "^4.2.0",
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",

21
packages/nocodb/src/controllers/export-import.controller.spec.ts

@ -1,21 +0,0 @@
import { Test } from '@nestjs/testing';
import { ExportImportService } from './../services/export-import.service';
import { ExportImportController } from './export-import.controller';
import type { TestingModule } from '@nestjs/testing';
describe('ExportImportController', () => {
let controller: ExportImportController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ExportImportController],
providers: [ExportImportService],
}).compile();
controller = module.get<ExportImportController>(ExportImportController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

51
packages/nocodb/src/controllers/export-import.controller.ts

@ -1,51 +0,0 @@
import {
Body,
Controller,
HttpCode,
Param,
Patch,
Post,
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,
ExtractProjectIdMiddleware,
} from '../middlewares/extract-project-id/extract-project-id.middleware';
import { ExportImportService } from './../services/export-import.service';
@Controller()
@UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class ExportImportController {
constructor(private readonly exportImportService: ExportImportService) {}
@Post('/api/v1/db/meta/export/:projectId/:baseId')
@HttpCode(200)
@Acl('exportBase')
async exportBase(@Param('baseId') baseId: string, @Body() body: any) {
return await this.exportImportService.exportBase({
baseId,
path: body.path,
});
}
@Post('/api/v1/db/meta/import/:projectId/:baseId')
@HttpCode(200)
@Acl('importBase')
async importBase(
@Request() req,
@Param('projectId') projectId: string,
@Param('baseId') baseId: string,
@Body() body: any,
) {
return await this.exportImportService.importBase({
user: (req as any).user,
projectId: projectId,
baseId: baseId,
src: body.src,
req,
});
}
}

6
packages/nocodb/src/controllers/imports/helpers/NocoSyncDestAdapter.ts

@ -1,6 +0,0 @@
export abstract class NocoSyncSourceAdapter {
public abstract init(): Promise<void>;
public abstract destProjectWrite(): Promise<any>;
public abstract destSchemaWrite(): Promise<any>;
public abstract destDataWrite(): Promise<any>;
}

7
packages/nocodb/src/controllers/imports/helpers/NocoSyncSourceAdapter.ts

@ -1,7 +0,0 @@
export abstract class NocoSyncSourceAdapter {
public abstract init(): Promise<void>;
public abstract srcSchemaGet(): Promise<any>;
public abstract srcDataLoad(): Promise<any>;
public abstract srcDataListen(): Promise<any>;
public abstract srcDataPoll(): Promise<any>;
}

2480
packages/nocodb/src/controllers/imports/helpers/job.ts

File diff suppressed because it is too large Load Diff

4
packages/nocodb/src/controllers/imports/helpers/readAndProcessData.ts

@ -1,8 +1,8 @@
/* eslint-disable no-async-promise-executor */
import { RelationTypes, UITypes } from 'nocodb-sdk';
import EntityMap from './EntityMap';
import type { BulkDataAliasService } from '../../../../services/bulk-data-alias.service';
import type { TablesService } from '../../../../services/tables.service';
import type { BulkDataAliasService } from '../../../services/bulk-data-alias.service';
import type { TablesService } from '../../../services/tables.service';
// @ts-ignore
import type { AirtableBase } from 'airtable/lib/airtable_base';
import type { TableType } from 'nocodb-sdk';

21
packages/nocodb/src/controllers/imports/import.controller.spec.ts

@ -1,21 +0,0 @@
import { Test } from '@nestjs/testing';
import { ImportService } from '../../services/import.service';
import { ImportController } from './import.controller';
import type { TestingModule } from '@nestjs/testing';
describe('ImportController', () => {
let controller: ImportController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ImportController],
providers: [ImportService],
}).compile();
controller = module.get<ImportController>(ImportController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

148
packages/nocodb/src/controllers/imports/import.controller.ts

@ -1,148 +0,0 @@
import { Controller, HttpCode, Post, Request, UseGuards } from '@nestjs/common';
import { forwardRef, Inject } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { SocketGateway } from 'src/services/socket.gateway';
import { GlobalGuard } from '../../guards/global/global.guard';
import { NcError } from '../../helpers/catchError';
import { ExtractProjectIdMiddleware } from '../../middlewares/extract-project-id/extract-project-id.middleware';
import { SyncSource } from '../../models';
import NocoJobs from '../../jobs/NocoJobs';
import airtableSyncJob from './helpers/job';
import type { AirtableSyncConfig } from './helpers/job';
import type { Server } from 'socket.io';
const AIRTABLE_IMPORT_JOB = 'AIRTABLE_IMPORT_JOB';
const AIRTABLE_PROGRESS_JOB = 'AIRTABLE_PROGRESS_JOB';
enum SyncStatus {
PROGRESS = 'PROGRESS',
COMPLETED = 'COMPLETED',
FAILED = 'FAILED',
}
const initJob = (sv: Server, jobs: { [p: string]: { last_message: any } }) => {
// add importer job handler and progress notification job handler
NocoJobs.jobsMgr.addJobWorker(AIRTABLE_IMPORT_JOB, airtableSyncJob);
NocoJobs.jobsMgr.addJobWorker(
AIRTABLE_PROGRESS_JOB,
({ payload, progress }) => {
sv.to(payload?.id).emit('progress', {
msg: progress?.msg,
level: progress?.level,
status: progress?.status,
});
if (payload?.id in jobs) {
jobs[payload?.id].last_message = {
msg: progress?.msg,
level: progress?.level,
status: progress?.status,
};
}
},
);
NocoJobs.jobsMgr.addProgressCbk(AIRTABLE_IMPORT_JOB, (payload, progress) => {
NocoJobs.jobsMgr.add(AIRTABLE_PROGRESS_JOB, {
payload,
progress: {
msg: progress?.msg,
level: progress?.level,
status: progress?.status,
},
});
});
NocoJobs.jobsMgr.addSuccessCbk(AIRTABLE_IMPORT_JOB, (payload) => {
NocoJobs.jobsMgr.add(AIRTABLE_PROGRESS_JOB, {
payload,
progress: {
msg: 'Complete!',
status: SyncStatus.COMPLETED,
},
});
delete jobs[payload?.id];
});
NocoJobs.jobsMgr.addFailureCbk(AIRTABLE_IMPORT_JOB, (payload, error: any) => {
NocoJobs.jobsMgr.add(AIRTABLE_PROGRESS_JOB, {
payload,
progress: {
msg: error?.message || 'Failed due to some internal error',
status: SyncStatus.FAILED,
},
});
delete jobs[payload?.id];
});
};
@Controller()
@UseGuards(ExtractProjectIdMiddleware, GlobalGuard)
export class ImportController {
constructor(
private readonly socketGateway: SocketGateway,
@Inject(forwardRef(() => ModuleRef)) private readonly moduleRef: ModuleRef,
) {}
@Post('/api/v1/db/meta/import/airtable')
@HttpCode(200)
importAirtable(@Request() req) {
NocoJobs.jobsMgr.add(AIRTABLE_IMPORT_JOB, {
id: req.query.id,
...req.body,
});
return {};
}
@Post('/api/v1/db/meta/syncs/:syncId/trigger')
@HttpCode(200)
async triggerSync(@Request() req) {
if (req.params.syncId in this.socketGateway.jobs) {
NcError.badRequest('Sync already in progress');
}
const syncSource = await SyncSource.get(req.params.syncId);
const user = await syncSource.getUser();
// Treat default baseUrl as siteUrl from req object
let baseURL = (req as any).ncSiteUrl;
// if environment value avail use it
// or if it's docker construct using `PORT`
if (process.env.NC_DOCKER) {
baseURL = `http://localhost:${process.env.PORT || 8080}`;
}
setTimeout(() => {
NocoJobs.jobsMgr.add<AirtableSyncConfig>(AIRTABLE_IMPORT_JOB, {
id: req.params.syncId,
...(syncSource?.details || {}),
projectId: syncSource.project_id,
baseId: syncSource.base_id,
authToken: '',
baseURL,
user: user,
moduleRef: this.moduleRef,
});
}, 1000);
this.socketGateway.jobs[req.params.syncId] = {
last_message: {
msg: 'Sync started',
},
};
return {};
}
@Post('/api/v1/db/meta/syncs/:syncId/abort')
@HttpCode(200)
async abortImport(@Request() req) {
if (req.params.syncId in this.socketGateway.jobs) {
delete this.socketGateway.jobs[req.params.syncId];
}
return {};
}
async onModuleInit() {
initJob(this.socketGateway.io, this.socketGateway.jobs);
}
}
Loading…
Cancel
Save