Browse Source

revert everything from nocodb-legacy dir (replace with latest from develop)

feat/export-nest-dir-restructure
starbirdtech383 2 years ago
parent
commit
5c611b938c
  1. 1
      packages/nocodb-legacy/.gitignore
  2. 62457
      packages/nocodb-legacy/package-lock.json
  3. 2
      packages/nocodb-legacy/package.json
  4. 2
      packages/nocodb-legacy/src/lib/db/sql-client/lib/sqlite/SqliteClient.ts
  5. 35
      packages/nocodb-legacy/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  6. 3
      packages/nocodb-legacy/src/lib/meta/api/index.ts
  7. 16
      packages/nocodb-legacy/src/lib/plugins/backblaze/Backblaze.ts
  8. 16
      packages/nocodb-legacy/src/lib/plugins/gcs/Gcs.ts
  9. 16
      packages/nocodb-legacy/src/lib/plugins/linode/LinodeObjectStorage.ts
  10. 16
      packages/nocodb-legacy/src/lib/plugins/mino/Minio.ts
  11. 15
      packages/nocodb-legacy/src/lib/plugins/ovhCloud/OvhCloud.ts
  12. 16
      packages/nocodb-legacy/src/lib/plugins/s3/S3.ts
  13. 16
      packages/nocodb-legacy/src/lib/plugins/scaleway/ScalewayObjectStorage.ts
  14. 16
      packages/nocodb-legacy/src/lib/plugins/spaces/Spaces.ts
  15. 16
      packages/nocodb-legacy/src/lib/plugins/upcloud/UpoCloud.ts
  16. 16
      packages/nocodb-legacy/src/lib/plugins/vultr/Vultr.ts
  17. 5
      packages/nocodb-legacy/src/lib/services/dbData/bulkData.ts
  18. 2
      packages/nocodb-legacy/src/lib/services/index.ts
  19. 2
      packages/nocodb-legacy/src/lib/services/metaDiff.svc.ts
  20. 27
      packages/nocodb-legacy/src/lib/v1-legacy/plugins/adapters/storage/Local.ts

1
packages/nocodb-legacy/.gitignore vendored

@ -20,4 +20,3 @@ test_meta.db
test_sakila.db
test_sakila_*.db
.env
export/**

62457
packages/nocodb-legacy/package-lock.json generated

File diff suppressed because it is too large Load Diff

2
packages/nocodb-legacy/package.json

@ -110,7 +110,7 @@
"nanoid": "^3.1.20",
"nc-help": "0.2.87",
"nc-lib-gui": "0.106.1",
"nc-plugin": "file:../nc-plugin",
"nc-plugin": "0.1.2",
"ncp": "^2.0.0",
"nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10",

2
packages/nocodb-legacy/src/lib/db/sql-client/lib/sqlite/SqliteClient.ts

@ -409,7 +409,7 @@ class SqliteClient extends KnexClient {
response[i].not_nullable = response[i].notnull === 1;
response[i].rqd = response[i].notnull === 1;
response[i].cdf = response[i].dflt_value;
response[i].pk = response[i].pk > 0;
response[i].pk = response[i].pk === 1;
response[i].cop = response[i].cid;
// https://stackoverflow.com/a/7906029

35
packages/nocodb-legacy/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -2066,18 +2066,13 @@ class BaseModelSqlv2 {
{
chunkSize: _chunkSize = 100,
cookie,
foreign_key_checks = true,
raw = false,
}: {
chunkSize?: number;
cookie?: any;
foreign_key_checks?: boolean;
raw?: boolean;
} = {}
) {
try {
// TODO: ag column handling for raw bulk insert
const insertDatas = raw ? datas : await Promise.all(
const insertDatas = await Promise.all(
datas.map(async (d) => {
await populatePk(this.model, d);
return this.model.mapAliasToColumn(d);
@ -2086,49 +2081,27 @@ class BaseModelSqlv2 {
// await this.beforeInsertb(insertDatas, null);
if (!raw) {
for (const data of datas) {
await this.validate(data);
}
}
// fallbacks to `10` if database client is sqlite
// to avoid `too many SQL variables` error
// refer : https://www.sqlite.org/limits.html
const chunkSize = this.isSqlite ? 10 : _chunkSize;
const trx = await this.dbDriver.transaction();
if (!foreign_key_checks) {
if (this.isPg) {
await trx.raw('set session_replication_role to replica;');
} else if (this.isMySQL) {
await trx.raw('SET foreign_key_checks = 0;');
}
}
const response =
this.isPg || this.isMssql
? await trx
? await this.dbDriver
.batchInsert(this.tnPath, insertDatas, chunkSize)
.returning(this.model.primaryKey?.column_name)
: await trx.batchInsert(
: await this.dbDriver.batchInsert(
this.tnPath,
insertDatas,
chunkSize
);
if (!foreign_key_checks) {
if (this.isPg) {
await trx.raw('set session_replication_role to origin;');
} else if (this.isMySQL) {
await trx.raw('SET foreign_key_checks = 1;');
}
}
await trx.commit();
if (!raw) await this.afterBulkInsert(insertDatas, this.dbDriver, cookie);
await this.afterBulkInsert(insertDatas, this.dbDriver, cookie);
return response;
} catch (e) {

3
packages/nocodb-legacy/src/lib/meta/api/index.ts

@ -50,7 +50,6 @@ import {
import swaggerController from '../../controllers/apiDocs';
import { importController, syncSourceController } from '../../controllers/sync';
import mapViewController from '../../controllers/views/mapView.ctl';
import exportImportController from '../../controllers/exportImport'
import type { Socket } from 'socket.io';
import type { Router } from 'express';
@ -104,8 +103,6 @@ export default function (router: Router, server) {
router.use(syncSourceController);
router.use(kanbanViewController);
router.use(mapViewController);
router.use(exportImportController.exportController);
router.use(exportImportController.importController);
userController(router);

16
packages/nocodb-legacy/src/lib/plugins/backblaze/Backblaze.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class Backblaze implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -79,21 +78,6 @@ export default class Backblaze implements IStorageAdapterV2 {
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
patchRegion(region: string): string {
// in v0.0.1, we constructed the endpoint with `region = s3.us-west-001`
// in v0.0.2, `region` would be `us-west-001`

16
packages/nocodb-legacy/src/lib/plugins/gcs/Gcs.ts

@ -8,7 +8,6 @@ import {
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import type { StorageOptions } from '@google-cloud/storage';
import { Readable } from 'stream';
export default class Gcs implements IStorageAdapterV2 {
private storageClient: Storage;
@ -127,19 +126,4 @@ export default class Gcs implements IStorageAdapterV2 {
);
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
}

16
packages/nocodb-legacy/src/lib/plugins/linode/LinodeObjectStorage.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class LinodeObjectStorage implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -79,21 +78,6 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 {
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
public async fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);
}

16
packages/nocodb-legacy/src/lib/plugins/mino/Minio.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class Minio implements IStorageAdapterV2 {
private minioClient: MinioClient;
@ -132,19 +131,4 @@ export default class Minio implements IStorageAdapterV2 {
);
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
}

15
packages/nocodb-legacy/src/lib/plugins/ovhCloud/OvhCloud.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class OvhCloud implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -79,20 +78,6 @@ export default class OvhCloud implements IStorageAdapterV2 {
});
}
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
public async fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);
}

16
packages/nocodb-legacy/src/lib/plugins/s3/S3.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class S3 implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -78,21 +77,6 @@ export default class S3 implements IStorageAdapterV2 {
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
public async fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);
}

16
packages/nocodb-legacy/src/lib/plugins/scaleway/ScalewayObjectStorage.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class ScalewayObjectStorage implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -128,19 +127,4 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 {
);
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
}

16
packages/nocodb-legacy/src/lib/plugins/spaces/Spaces.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class Spaces implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -79,21 +78,6 @@ export default class Spaces implements IStorageAdapterV2 {
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
public async fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);
}

16
packages/nocodb-legacy/src/lib/plugins/upcloud/UpoCloud.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class UpoCloud implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -79,21 +78,6 @@ export default class UpoCloud implements IStorageAdapterV2 {
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
public async fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);
}

16
packages/nocodb-legacy/src/lib/plugins/vultr/Vultr.ts

@ -7,7 +7,6 @@ import {
waitForStreamClose,
} from '../../utils/pluginUtils';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
import { Readable } from 'stream';
export default class Vultr implements IStorageAdapterV2 {
private s3Client: AWS.S3;
@ -79,21 +78,6 @@ export default class Vultr implements IStorageAdapterV2 {
});
}
// TODO - implement
fileCreateByStream(_key: string, _stream: Readable): Promise<void> {
return Promise.resolve(undefined);
}
// TODO - implement
fileReadByStream(_key: string): Promise<Readable> {
return Promise.resolve(undefined);
}
// TODO - implement
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}
public async fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);
}

5
packages/nocodb-legacy/src/lib/services/dbData/bulkData.ts

@ -38,15 +38,12 @@ export async function bulkDataInsert(
param: PathParams & {
body: any;
cookie: any;
chunkSize?: number;
foreign_key_checks?: boolean;
raw?: boolean;
}
) {
return await executeBulkOperation({
...param,
operation: 'bulkInsert',
options: [param.body, { cookie: param.cookie, foreign_key_checks: param.foreign_key_checks, chunkSize: param.chunkSize, raw: param.raw }],
options: [param.body, { cookie: param.cookie }],
});
}

2
packages/nocodb-legacy/src/lib/services/index.ts

@ -36,5 +36,3 @@ export * as syncService from './sync';
export * from './public';
export * as orgTokenService from './orgToken.svc';
export * as orgTokenServiceEE from './ee/orgToken.svc';
export * as exportService from './exportImport/export.svc';
export * as importService from './exportImport/import.svc';

2
packages/nocodb-legacy/src/lib/services/metaDiff.svc.ts

@ -1010,7 +1010,7 @@ export async function extractAndGenerateManyToManyRelations(
}
// todo: impl better method to identify m2m relation
if (belongsToCols?.length === 2 && normalColumns.length < 5 && assocModel.primaryKeys.length === 2) {
if (belongsToCols?.length === 2 && normalColumns.length < 5) {
const modelA = await belongsToCols[0].colOptions.getRelatedTable();
const modelB = await belongsToCols[1].colOptions.getRelatedTable();

27
packages/nocodb-legacy/src/lib/v1-legacy/plugins/adapters/storage/Local.ts

@ -4,7 +4,6 @@ import { promisify } from 'util';
import mkdirp from 'mkdirp';
import axios from 'axios';
import NcConfigFactory from '../../../../utils/NcConfigFactory';
import type { Readable } from 'stream';
import type { IStorageAdapterV2, XcFile } from 'nc-plugin';
export default class Local implements IStorageAdapterV2 {
@ -66,32 +65,6 @@ export default class Local implements IStorageAdapterV2 {
});
}
public async fileCreateByStream(key: string, stream: Readable): Promise<void> {
return new Promise(async (resolve, reject) => {
const destPath = path.join(NcConfigFactory.getToolDir(), ...key.split('/'));
try {
await mkdirp(path.dirname(destPath));
const writableStream = fs.createWriteStream(destPath);
writableStream.on('finish', () => resolve());
writableStream.on('error', (err) => reject(err));
stream.pipe(writableStream);
} catch (e) {
throw e;
}
});
}
public async fileReadByStream(key: string): Promise<Readable> {
const srcPath = path.join(NcConfigFactory.getToolDir(), ...key.split('/'));
return fs.createReadStream(srcPath, { encoding: 'utf8' });
}
public async getDirectoryList(key: string): Promise<string[]> {
const destDir = path.join(NcConfigFactory.getToolDir(), ...key.split('/'));
return fs.promises.readdir(destDir);
}
// todo: implement
fileDelete(_path: string): Promise<any> {
return Promise.resolve(undefined);

Loading…
Cancel
Save