Browse Source

refactor: Linting

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/153/head
Pranav C 3 years ago
parent
commit
a8ab70a6d1
  1. 27
      .eslintrc.js
  2. 72
      packages/nocodb/.eslintrc.json
  3. 2
      packages/nocodb/.prettierignore
  4. 1012
      packages/nocodb/package-lock.json
  5. 12
      packages/nocodb/package.json
  6. 86
      packages/nocodb/src/__tests__/graphql.test.ts
  7. 81
      packages/nocodb/src/__tests__/rest.test.ts
  8. 5
      packages/nocodb/src/example/docker.ts
  9. 5
      packages/nocodb/src/example/try.ts
  10. 2
      packages/nocodb/src/interface/XcMetaMgr.ts
  11. 2
      packages/nocodb/src/interface/config.ts
  12. 74
      packages/nocodb/src/lib/dataMapper/lib/BaseModel.ts
  13. 84
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts
  14. 9
      packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts
  15. 2
      packages/nocodb/src/lib/index.ts
  16. 50
      packages/nocodb/src/lib/migrator/SqlMigrator/lib/KnexMigrator.ts
  17. 1
      packages/nocodb/src/lib/migrator/SqlMigrator/lib/SqlMigratorFactory.ts
  18. 3
      packages/nocodb/src/lib/migrator/util/Debug.ts
  19. 4
      packages/nocodb/src/lib/migrator/util/DebugMgr.ts
  20. 3
      packages/nocodb/src/lib/migrator/util/FileCollection.ts
  21. 20
      packages/nocodb/src/lib/noco/NcProjectBuilder.ts
  22. 46
      packages/nocodb/src/lib/noco/Noco.ts
  23. 28
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  24. 8
      packages/nocodb/src/lib/noco/common/BaseModel.ts
  25. 3
      packages/nocodb/src/lib/noco/common/BaseProcedure.ts
  26. 4
      packages/nocodb/src/lib/noco/common/XcCron.ts
  27. 37
      packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts
  28. 22
      packages/nocodb/src/lib/noco/gql/GqlAuthResolver.ts
  29. 5
      packages/nocodb/src/lib/noco/gql/GqlBaseResolver.ts
  30. 5
      packages/nocodb/src/lib/noco/gql/GqlMiddleware.ts
  31. 6
      packages/nocodb/src/lib/noco/gql/GqlProcedureResolver.ts
  32. 8
      packages/nocodb/src/lib/noco/gql/GqlResolver.ts
  33. 13
      packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts
  34. 64
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts
  35. 3
      packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts
  36. 4
      packages/nocodb/src/lib/noco/migrations/nc_001_init.ts
  37. 6
      packages/nocodb/src/lib/noco/nc.try.ts
  38. 29
      packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts
  39. 3
      packages/nocodb/src/lib/noco/plugins/adapters/email/EmailFactory.ts
  40. 3
      packages/nocodb/src/lib/noco/plugins/adapters/email/SMTP.ts
  41. 8
      packages/nocodb/src/lib/noco/plugins/adapters/storage/Local.ts
  42. 50
      packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts
  43. 32
      packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts
  44. 8
      packages/nocodb/src/lib/noco/rest/RestAuthCtrlEE.ts
  45. 3
      packages/nocodb/src/lib/noco/rest/RestBaseCtrl.ts
  46. 5
      packages/nocodb/src/lib/noco/rest/RestCtrl.ts
  47. 7
      packages/nocodb/src/lib/noco/rest/RestCtrlBelongsTo.ts
  48. 7
      packages/nocodb/src/lib/noco/rest/RestCtrlCustom.ts
  49. 7
      packages/nocodb/src/lib/noco/rest/RestCtrlHasMany.ts
  50. 5
      packages/nocodb/src/lib/noco/rest/RestCtrlMin.ts
  51. 6
      packages/nocodb/src/lib/noco/rest/RestCtrlProcedure.ts
  52. 11
      packages/nocodb/src/lib/sqlMgr/SqlMgr.ts
  53. 4
      packages/nocodb/src/lib/sqlMgr/code/gql-schema/xc-ts/BaseGqlXcTsSchema.ts
  54. 2
      packages/nocodb/src/lib/sqlMgr/code/gql-schema/xc-ts/GqlXcSchemaFactory.ts
  55. 1
      packages/nocodb/src/lib/sqlMgr/code/gql-schema/xc-ts/GqlXcTsSchemaMysql.ts
  56. 8
      packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaFactory.ts
  57. 7
      packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaMssql.ts
  58. 4
      packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaMysql.ts
  59. 6
      packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaOracle.ts
  60. 7
      packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaPg.ts
  61. 3
      packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaSqlite.ts
  62. 3
      packages/nocodb/src/lib/sqlMgr/code/policies/xc/ExpressXcPolicy.ts
  63. 7
      packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts
  64. 2
      packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXcBt.ts
  65. 2
      packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXcHm.ts
  66. 1
      packages/nocodb/src/lib/utils/Lang.ts
  67. 9
      packages/nocodb/src/lib/utils/NcConfigFactory.ts
  68. 3
      packages/nocodb/src/plugins/backblaze/Backblaze.ts
  69. 1
      packages/nocodb/src/plugins/backblaze/BackblazePlugin.ts
  70. 3
      packages/nocodb/src/plugins/backblaze/index.ts
  71. 2
      packages/nocodb/src/plugins/discord/Discord.ts
  72. 1
      packages/nocodb/src/plugins/discord/DiscordPlugin.ts
  73. 3
      packages/nocodb/src/plugins/discord/index.ts
  74. 3
      packages/nocodb/src/plugins/gcs/Gcs.ts
  75. 1
      packages/nocodb/src/plugins/gcs/GcsPlugin.ts
  76. 3
      packages/nocodb/src/plugins/gcs/index.ts
  77. 3
      packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts
  78. 1
      packages/nocodb/src/plugins/linode/LinodeObjectStoragePlugin.ts
  79. 3
      packages/nocodb/src/plugins/linode/index.ts
  80. 2
      packages/nocodb/src/plugins/mattermost/Mattermost.ts
  81. 1
      packages/nocodb/src/plugins/mattermost/MattermostPlugin.ts
  82. 3
      packages/nocodb/src/plugins/mattermost/index.ts
  83. 3
      packages/nocodb/src/plugins/mino/Minio.ts
  84. 1
      packages/nocodb/src/plugins/mino/MinioPlugin.ts
  85. 3
      packages/nocodb/src/plugins/mino/index.ts
  86. 3
      packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts
  87. 1
      packages/nocodb/src/plugins/ovhCloud/OvhCloudPlugin.ts
  88. 3
      packages/nocodb/src/plugins/ovhCloud/index.ts
  89. 3
      packages/nocodb/src/plugins/s3/S3.ts
  90. 1
      packages/nocodb/src/plugins/s3/S3Plugin.ts
  91. 3
      packages/nocodb/src/plugins/s3/index.ts
  92. 3
      packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts
  93. 1
      packages/nocodb/src/plugins/scaleway/ScalewayObjectStoragePlugin.ts
  94. 3
      packages/nocodb/src/plugins/scaleway/index.ts
  95. 2
      packages/nocodb/src/plugins/slack/Slack.ts
  96. 1
      packages/nocodb/src/plugins/slack/SlackPlugin.ts
  97. 3
      packages/nocodb/src/plugins/slack/index.ts
  98. 3
      packages/nocodb/src/plugins/smtp/SMTP.ts
  99. 1
      packages/nocodb/src/plugins/smtp/SMTPPlugin.ts
  100. 3
      packages/nocodb/src/plugins/smtp/index.ts
  101. Some files were not shown because too many files have changed in this diff Show More

27
.eslintrc.js

@ -1,27 +0,0 @@
module.exports = {
extends: ["eslint-config-airbnb-base", "eslint-config-prettier"],
plugins: ["eslint-plugin-import", "eslint-plugin-prettier"],
parserOptions: {
ecmaFeatures: {
ecmaVersion: 6
}
},
env: {
es6: true,
node: true
},
rules: {
"prettier/prettier": ["error", {}],
"max-len": ["error", { code: 2000, ignoreUrls: true }],
"linebreak-style": 0,
"no-use-before-define": ["error", { functions: false, classes: false }],
"no-plusplus": ["error", { allowForLoopAfterthoughts: true }],
"no-underscore-dangle": 0,
"import/no-amd": 0,
"import/no-dynamic-require": 0,
"no-console": 0,
"no-param-reassign": 0,
"no-unused-vars": ["error", { argsIgnorePattern: "next" }],
"comma-dangle": 0
}
};

72
packages/nocodb/.eslintrc.json

@ -0,0 +1,72 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"env": {
"es6": true
},
"ignorePatterns": [
"node_modules",
"build",
"coverage",
"dist",
"nc"
],
"plugins": [
"import",
"eslint-comments",
"functional"
],
"extends": [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"prettier",
"prettier/@typescript-eslint"
],
"globals": {
"BigInt": true,
"console": true,
"WebAssembly": true
},
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"eslint-comments/disable-enable-pair": [
"error",
{
"allowWholeFile": true
}
],
"eslint-comments/no-unused-disable": "error",
"import/order": [
"error",
{
"newlines-between": "always",
"alphabetize": {
"order": "asc"
}
}
],
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true,
"ignoreCase": true
}
],
"@typescript-eslint/no-this-alias": "off",
// todo: enable
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
"no-useless-catch": "off",
"no-empty": "off",
"@typescript-eslint/no-empty-function": "off",
"import/order": "off"
}
}

2
packages/nocodb/.prettierignore

@ -0,0 +1,2 @@
# package.json is formatted by package managers, so we ignore it here
package.json

1012
packages/nocodb/package-lock.json generated

File diff suppressed because it is too large Load Diff

12
packages/nocodb/package.json

@ -15,7 +15,7 @@
"obfuscate:build:publish": "npm run build:obfuscate && npm publish .",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"fix:tslint": "tslint --fix --project .",
"lint": "eslint src --ext .ts",
"test": "TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/**/*.test.ts --recursive",
"local:test:graphql": "DATABASE_URL=mysql://root:password@localhost:3306/sakila TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit",
"test:graphql": "TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit",
@ -183,6 +183,8 @@
"@types/mocha": "^8.0.1",
"@types/nodemailer": "^6.4.0",
"@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"@webserverless/fc-express": "^0.1.4",
"autocannon": "^6.5.0",
"ava": "2.2.0",
@ -190,6 +192,11 @@
"codecov": "^3.5.0",
"copyfiles": "^2.3.0",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^7.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^3.0.2",
"eslint-plugin-import": "^2.22.0",
"gh-pages": "^2.0.1",
"mocha": "^8.1.1",
"nodemon": "^2.0.7",
@ -204,9 +211,6 @@
"trash-cli": "^3.0.0",
"ts-loader": "^8.0.5",
"ts-node": "^8.10.2",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0",
"tslint-immutable": "^6.0.1",
"typescript": "^4.0.3",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",

86
packages/nocodb/src/__tests__/graphql.test.ts

@ -1,78 +1,15 @@
/* tslint:disable */
import {expect} from 'chai';
import 'mocha';
import {Noco} from "../lib";
import request from 'supertest';
import express from 'express';
import request from 'supertest';
import {Noco} from "../lib";
import NcConfigFactory from "../lib/utils/NcConfigFactory";
process.env.TEST = 'test';
// import knex from 'knex';
// import {XcConfig} from "../interface/config";
// import JWT from "../lib/xgene/grpc/helpers/jwt";
// import JWT from "../lib/instant/grpc/helpers/jwt";
// const config: XcConfig = {
// auth: {
// jwt: {
// secret: "shgdhsgdhgsgdgswyeyey28378732qgwhqg233232hjhasha",
// dbAlias:'db'
// }
// },
// envs: {
// dev: {
// db: [
// {
// "client": "mysql",
// "connection": {
// "host": "localhost",
// "port": 3306,
// "user": "root",
// "password": "password",
// database: "sakila"
// },
// meta: {
// "dbAlias": "db",
// api: {
// type: "graphql",
// prefix: ""
// },
// metaTables: "db"
// }
// },
// ],
// }, test: {
// db: [
// {
// "client": "mysql",
// "connection": {
// "host": "localhost",
// "port": 3306,
// "user": "root",
// "password": "",
// database: "sakila"
// },
// meta: {
// "dbAlias": "db",
// api: {
// type: "graphql",
// prefix: ""
// },
// metaTables: "db"
// }
// },
// ],
// },
// },
// toolDir: process.cwd()
// };
// process.env[`DATABASE_URL`] = 'mysql://root:password@localhost:3306/sakila';
const dbConfig = NcConfigFactory.urlToDbConfig(NcConfigFactory.extractXcUrlFromJdbc(process.env[`DATABASE_URL`]), null, null, 'graphql');
// @ts-ignore
const projectCreateReqBody = {
"api": "projectCreateByWeb",
"query": {"skipProjectHasDb": 1},
@ -85,23 +22,6 @@ const projectCreateReqBody = {
"dev": {
"db": [
dbConfig
// {
// "client": "mysql2",
// "connection": {
// "host": "localhost",
// "port": "3306",
// "user": "root",
// "password": "password",
// "database": "sakila",
// "multipleStatements": true
// },
// "meta": {
// "tn": "nc_evolutions",
// "dbAlias": "db",
// "api": {"type": "graphql", "prefix": "", "graphqlDepthLimit": 10},
// "inflection": {"tn": "none", "cn": "none"}
// }
// }
], "apiClient": {"data": []}
}
},

81
packages/nocodb/src/__tests__/rest.test.ts

@ -1,89 +1,14 @@
/* tslint:disable */
import {expect} from 'chai';
import 'mocha';
import {Noco} from "../lib";
import request from 'supertest';
import express from 'express';
import request from 'supertest';
import {Noco} from "../lib";
import NcConfigFactory from "../lib/utils/NcConfigFactory";
// import knex from 'knex';
// import {XcConfig} from "../interface/config";
// import JWT from "../lib/xgene/grpc/helpers/jwt";
process.env.TEST = 'test';
// process.env[`DATABASE_URL`] = 'mysql://root:password@localhost:3306/sakila';
let projectId;
let token;
/*
const config: XcConfig = {
// mailer: {
// "from": "From",
// "options": {
// "host": "host",
// "port": 465,
// "secure": true,
// "auth": {
// "user": "user",
// "pass": "pass"
// }
// }
// },
auth: {
jwt: {
secret: "shgdhsgdhgsgdgswyeyey28378732qgwhqg233232hjhasha",
dbAlias: 'db'
}
},
envs: {
dev: {
db: [
{
"client": "mysql",
"connection": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "password",
database: "sakila"
},
meta: {
"dbAlias": "db",
api: {
type: "rest",
prefix: ""
},
metaTables: "db"
}
},
],
},
test: {
db: [
{
"client": "mysql",
"connection": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "",
database: "sakila"
},
meta: {
"dbAlias": "db",
api: {
type: "rest",
prefix: ""
},
metaTables: "db"
}
},
],
},
},
toolDir: process.cwd()
};
*/
const dbConfig = NcConfigFactory.urlToDbConfig(NcConfigFactory.extractXcUrlFromJdbc(process.env[`DATABASE_URL`]));
const projectCreateReqBody = {
"api": "projectCreateByWeb",

5
packages/nocodb/src/example/docker.ts

@ -1,7 +1,8 @@
import cors from 'cors';
import express from 'express';
import Noco from "../lib/noco/Noco";
process.env.NC_VERSION = '0009044';
import express from 'express';
import cors from 'cors';
const server = express();
server.use(cors({

5
packages/nocodb/src/example/try.ts

@ -1,6 +1,7 @@
import {NcConfigFactory, Noco} from "../lib";
import express from 'express';
import cors from 'cors';
import express from 'express';
import {NcConfigFactory, Noco} from "../lib";
process.env.DATABASE_URL = 'mysql://root:password@localhost:3306/sakila'

2
packages/nocodb/src/interface/XcMetaMgr.ts

@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export default interface XcMetaMgr {

2
packages/nocodb/src/interface/config.ts

@ -1,4 +1,5 @@
import {Handler} from "express";
import * as e from 'express';
import Knex from "knex";
export interface Route {
@ -278,7 +279,6 @@ export class Result {
}
import * as e from 'express';
enum HTTPType {

74
packages/nocodb/src/lib/dataMapper/lib/BaseModel.ts

@ -1,8 +1,9 @@
/* eslint-disable @typescript-eslint/ban-types,prefer-const */
import Knex from "knex";
const Validator = require('validator');
const _ = require('lodash');
const autoBind = require('auto-bind');
const _ = require('lodash');
const Validator = require('validator');
// interface BaseModel {
@ -129,7 +130,7 @@ abstract class BaseModel {
async validate(columns) {
// let cols = Object.keys(this.columns);
for (let i = 0; i < this.columns.length; ++i) {
let {validate: {func, msg}, cn} = this.columns[i];
const {validate: {func, msg}, cn} = this.columns[i];
for (let j = 0; j < func.length; ++j) {
const fn = typeof func[j] === 'string' ? Validator[func[j]] : func[j];
const arg = typeof func[j] === 'string' ? columns[cn] + "" : columns[cn];
@ -156,8 +157,8 @@ abstract class BaseModel {
* @private
*/
_wherePk(id) {
let ids = (id + '').split('___');
let where = {};
const ids = (id + '').split('___');
const where = {};
for (let i = 0; i < this.pks.length; ++i) {
where[this.pks[i].cn] = ids[i];
}
@ -174,8 +175,8 @@ abstract class BaseModel {
* @private
*/
_whereFk({tnp, parentId}) {
let {rcn} = this.belongsToRelations.find(({rtn}) => rtn === tnp)
let where = {[rcn]: parentId};
const {rcn} = this.belongsToRelations.find(({rtn}) => rtn === tnp)
const where = {[rcn]: parentId};
return where;
}
@ -186,8 +187,8 @@ abstract class BaseModel {
* @private
*/
_extractPks(obj) {
let objCopy = JSON.parse(JSON.stringify(obj));
for (let key in obj) {
const objCopy = JSON.parse(JSON.stringify(obj));
for (const key in obj) {
if (this.pks.filter(pk => pk.cn === key).length === 0) {
delete objCopy[key];
}
@ -295,13 +296,12 @@ abstract class BaseModel {
await this.beforeInsertb(data)
let response;
for (let d of data) {
for (const d of data) {
await this.validate(d);
}
response = await this.dbDriver.batchInsert(this.tn, data, 50)
const response = await this.dbDriver.batchInsert(this.tn, data, 50)
.returning(this.pks[0].cn);
await this.afterInsertb(data);
@ -372,7 +372,7 @@ abstract class BaseModel {
const {fields, where, limit, offset, sort, condition} = this._getListArgs(args);
let query = this.$db.select(...fields.split(','))
const query = this.$db.select(...fields.split(','))
.xwhere(where)
.condition(condition);
@ -402,7 +402,7 @@ abstract class BaseModel {
async findOne(args) {
try {
const {fields, where, condition} = this._getListArgs(args);
let query = this.$db.select(fields)
const query = this.$db.select(fields)
.xwhere(where).condition(condition).first();
this._paginateAndSort(query, args)
return await this._run(query);
@ -430,7 +430,7 @@ abstract class BaseModel {
async findOneByFk({parentId, tnp, ...args}) {
try {
const {fields, where, condition} = this._getListArgs(args);
let query = this.$db.select(fields)
const query = this.$db.select(fields)
.where(this._whereFk({parentId, tnp}))
.xwhere(where).condition(condition).first();
this._paginateAndSort(query, args)
@ -617,10 +617,10 @@ abstract class BaseModel {
trx = await this.dbDriver.transaction();
let res = [];
for (let d of data) {
const res = [];
for (const d of data) {
// this.validate(d);
let response = await this._run(trx(this.tn).update(d).where(this._extractPks(d)));
const response = await this._run(trx(this.tn).update(d).where(this._extractPks(d)));
res.push(response);
}
@ -651,9 +651,9 @@ abstract class BaseModel {
await this.beforeDeleteb(ids);
trx = await this.dbDriver.transaction();
let res = [];
for (let d of ids) {
let response = await this._run(trx(this.tn).del().where(this._extractPks(d)));
const res = [];
for (const d of ids) {
const response = await this._run(trx(this.tn).del().where(this._extractPks(d)));
res.push(response);
}
trx.commit();
@ -678,7 +678,7 @@ abstract class BaseModel {
* @param {String} id - ___ separated primary key string
* @returns {Promise<boolean>} - true for exits and false for none
*/
async exists(id, {}) {
async exists(id, _) {
try {
return Object.keys((await this.readByPk(id, {conditionGraph: null}))).length !== 0;
} catch (e) {
@ -719,7 +719,7 @@ abstract class BaseModel {
async groupBy({having, fields = '', column_name, limit, offset, sort}) {
try {
const columns = [...(column_name ? [column_name] : []), ...fields.split(',').filter(Boolean)];
let query = this.$db
const query = this.$db
.groupBy(columns)
.count(`${(this.pks[0] || this.columns[0]).cn} as count`)
.select(columns)
@ -750,9 +750,9 @@ abstract class BaseModel {
* @memberof BaseModel
* @throws {Error}
*/
async aggregate({having, fields = '', func, column_name, limit, offset, sort}) {
async aggregate({having, fields = '', func, column_name, limit, offset, sort}) {
try {
let query = this.$db
const query = this.$db
.select(...fields.split(','))
.xhaving(having);
@ -871,7 +871,7 @@ abstract class BaseModel {
*/
async distinct({cn, fields = '', where, limit, offset, sort, condition}) {
try {
let query = this.$db;
const query = this.$db;
query.distinct(cn, ...fields.split(',').filter(Boolean));
query.xwhere(where).condition(condition);
this._paginateAndSort(query, {limit, offset, sort});
@ -891,7 +891,7 @@ abstract class BaseModel {
*/
async raw(queryString, params = []) {
try {
let query = this.dbDriver.raw(queryString, params);
const query = this.dbDriver.raw(queryString, params);
return await this._run(query);
} catch (e) {
console.log(e);
@ -919,7 +919,7 @@ abstract class BaseModel {
}
let childs = await this._run(this.dbDriver.union(
const childs = await this._run(this.dbDriver.union(
parent.map(p => {
const query = this
.dbDriver(child)
@ -932,7 +932,7 @@ abstract class BaseModel {
}), !this.isSqlite()
));
let gs = _.groupBy(childs, cn);
const gs = _.groupBy(childs, cn);
parent.forEach(row => {
row[child] = gs[row[this.pks[0].cn]] || [];
})
@ -956,7 +956,7 @@ abstract class BaseModel {
const {fields, where, limit, offset, sort, condition} = this._getListArgs(args);
const {rcn} = this.hasManyRelations.find(({tn}) => tn === child) || {};
let query = this.dbDriver(child).select(...fields.split(','))
const query = this.dbDriver(child).select(...fields.split(','))
.where(rcn, parentId)
.xwhere(where).condition(condition);
@ -1023,7 +1023,7 @@ abstract class BaseModel {
fields = fields || f || '*';
try {
for (let parent of parents.split('~')) {
for (const parent of parents.split('~')) {
const {cn} = this.belongsToRelations.find(({rtn}) => rtn === parent) || {};
if (fields !== '*' && fields.split(',').indexOf(cn) === -1) {
fields += ',' + cn;
@ -1066,7 +1066,7 @@ abstract class BaseModel {
const parents = await this._run(this.dbDriver(parent).select(...fields.split(',')).whereIn(rcn, parentIds));
let gs = _.groupBy(parents, rcn);
const gs = _.groupBy(parents, rcn);
childs.forEach(row => {
row[parent] = gs[row[cn]] && gs[row[cn]][0];
@ -1095,7 +1095,7 @@ abstract class BaseModel {
fields += ',' + cn;
}
let childs = await this._run(this.dbDriver.union(
const childs = await this._run(this.dbDriver.union(
ids.map(p => {
const query = this
.dbDriver(child)
@ -1135,11 +1135,11 @@ abstract class BaseModel {
*/
async hasManyListCount({child, ids, ...rest}) {
try {
let {where, condition} = this._getChildListArgs(rest);
const {where, condition} = this._getChildListArgs(rest);
const {cn} = this.hasManyRelations.find(({tn}) => tn === child) || {};
let childs = await this._run(this.dbDriver.unionAll(
const childs = await this._run(this.dbDriver.unionAll(
ids.map(p => {
const query = this
.dbDriver(child)
@ -1219,7 +1219,7 @@ abstract class BaseModel {
* @private
*/
_getListArgs(args) {
let obj: XcFilter = {};
const obj: XcFilter = {};
obj.where = args.where || args.w || '';
obj.limit = Math.max(Math.min(args.limit || args.l || this.config.limitDefault, this.config.limitMax), this.config.limitMin);
obj.offset = args.offset || args.o || 0;
@ -1238,7 +1238,7 @@ abstract class BaseModel {
*/
_getChildListArgs(args: any, index?: number) {
index++;
let obj: XcFilter = {};
const obj: XcFilter = {};
obj.where = args[`where${index}`] || args[`w${index}`] || '';
obj.limit = Math.max(Math.min(args[`limit${index}`] || args[`l${index}`] || this.config.limitDefault, this.config.limitMax), this.config.limitMin);
obj.offset = args[`offset${index}`] || args[`o${index}`] || 0;

84
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts

@ -1,6 +1,7 @@
import Validator from 'validator';
import _ from 'lodash';
import autoBind from 'auto-bind';
import _ from 'lodash';
import Validator from 'validator';
import BaseModel, {XcFilter, XcFilterWithAlias} from '../BaseModel';
@ -98,7 +99,7 @@ class BaseModelSql extends BaseModel {
async validate(columns) {
// let cols = Object.keys(this.columns);
for (let i = 0; i < this.columns.length; ++i) {
let {validate: {func, msg}, cn} = this.columns[i];
const {validate: {func, msg}, cn} = this.columns[i];
for (let j = 0; j < func.length; ++j) {
const fn = typeof func[j] === 'string' ? Validator[func[j]] : func[j];
const arg = typeof func[j] === 'string' ? columns[cn] + "" : columns[cn];
@ -127,8 +128,8 @@ class BaseModelSql extends BaseModel {
* @private
*/
_wherePk(id) {
let ids = (id + '').split('___');
let where = {};
const ids = (id + '').split('___');
const where = {};
for (let i = 0; i < this.pks.length; ++i) {
where[this.pks[i].cn] = ids[i];
}
@ -309,11 +310,10 @@ class BaseModelSql extends BaseModel {
await this.beforeUpdate(data, trx, cookie);
let response;
const driver = trx ? trx : this.dbDriver
// this.validate(data);
response = await this._run(driver(this.tn).update(mappedData).where(this._wherePk(id)));
const response = await this._run(driver(this.tn).update(mappedData).where(this._wherePk(id)));
await this.afterUpdate(data, trx, cookie);
return response;
} catch (e) {
@ -335,10 +335,9 @@ class BaseModelSql extends BaseModel {
try {
await this.beforeDelete({id}, trx, cookie);
let response;
let dbDriver = trx ? trx : this.dbDriver;
const dbDriver = trx ? trx : this.dbDriver;
response = await this._run(dbDriver(this.tn).del().where(this._wherePk(id)));
const response = await this._run(dbDriver(this.tn).del().where(this._wherePk(id)));
await this.afterDelete({id}, trx, cookie);
return response;
} catch (e) {
@ -429,10 +428,9 @@ class BaseModelSql extends BaseModel {
await this.validate(data);
await this.beforeUpdate(data, trx, cookie);
let response;
const dbDriver = trx ? trx : this.dbDriver;
// this.validate(data);
response = await this._run(dbDriver(this.tn).update(data).where(this._wherePk(id)).andWhere(this._whereFk({
const response = await this._run(dbDriver(this.tn).update(data).where(this._wherePk(id)).andWhere(this._whereFk({
tnp,
parentId
})));
@ -461,10 +459,9 @@ class BaseModelSql extends BaseModel {
// await this.beforeUpdate(data);
await this.validate(data);
let response;
const driver = trx ? trx : this.dbDriver
response = await this._run(driver(this.tn).update(data).xwhere(where, this.selectQuery('')).condition(condition, this.selectQuery('')));
const response = await this._run(driver(this.tn).update(data).xwhere(where, this.selectQuery('')).condition(condition, this.selectQuery('')));
// await this.afterUpdate(data);
return response;
@ -491,9 +488,8 @@ class BaseModelSql extends BaseModel {
try {
await this.beforeDelete({id, parentId, tnp}, trx, cookie);
let response;
const dbDriver = trx ? trx : this.dbDriver;
response = await this._run(dbDriver(this.tn).del().where(this._wherePk(id)).andWhere(this._whereFk({
const response = await this._run(dbDriver(this.tn).del().where(this._wherePk(id)).andWhere(this._whereFk({
tnp,
parentId
})));
@ -519,10 +515,9 @@ class BaseModelSql extends BaseModel {
try {
// await this.beforeUpdate(data);
let response;
const driver = trx ? trx : this.dbDriver
response = await this._run(driver(this.tn).del().xwhere(where, this.selectQuery('')).condition(condition, this.selectQuery('')));
const response = await this._run(driver(this.tn).del().xwhere(where, this.selectQuery('')).condition(condition, this.selectQuery('')));
// await this.afterUpdate(data);
return response;
@ -549,14 +544,11 @@ class BaseModelSql extends BaseModel {
await this.beforeInsertb(insertDatas, null)
let response;
for (const d1 of insertDatas) {
await this.validate(d1);
}
response = await this.dbDriver.batchInsert(this.tn, insertDatas, 50)
const response = await this.dbDriver.batchInsert(this.tn, insertDatas, 50)
.returning(this.pks[0].cn);
await this.afterInsertb(insertDatas, null);
@ -587,12 +579,12 @@ class BaseModelSql extends BaseModel {
transaction = await this.dbDriver.transaction();
await this.beforeUpdateb(insertDatas, transaction);
let res = [];
const res = [];
for (const d of insertDatas) {
await this.validate(d);
// this.validate(d);
let response = await this._run(transaction(this.tn).update(d).where(this._extractPks(d)));
const response = await this._run(transaction(this.tn).update(d).where(this._extractPks(d)));
res.push(response);
}
@ -623,9 +615,9 @@ class BaseModelSql extends BaseModel {
transaction = await this.dbDriver.transaction();
await this.beforeDeleteb(ids, transaction);
let res = [];
for (let d of ids) {
let response = await this._run(transaction(this.tn).del().where(this._extractPks(d)));
const res = [];
for (const d of ids) {
const response = await this._run(transaction(this.tn).del().where(this._extractPks(d)));
res.push(response);
}
await this.afterDeleteb(res, transaction);
@ -707,7 +699,7 @@ class BaseModelSql extends BaseModel {
try {
let {fields, where, limit, offset, sort, condition, conditionGraph = null} = this._getListArgs(args);
const {fields, where, limit, offset, sort, condition, conditionGraph = null} = this._getListArgs(args);
// if (fields === '*') {
// fields = `${this.tn}.*`;
@ -745,11 +737,12 @@ class BaseModelSql extends BaseModel {
*/
async findOne(args: XcFilterWithAlias = {}) {
try {
let {fields, where, condition, conditionGraph} = this._getListArgs(args);
const {where, condition, conditionGraph, ...rest} = this._getListArgs(args);
let {fields} = rest;
if (fields === '*') {
fields = `${this.tn}.*`;
}
let query = this.$db
const query = this.$db
// .select(fields)
.select(this.selectQuery(fields))
.xwhere(where, this.selectQuery('')).condition(condition, this.selectQuery(''))
@ -779,11 +772,12 @@ class BaseModelSql extends BaseModel {
*/
async findOneByFk({parentId, tnp, ...args}) {
try {
let {fields, where, condition, conditionGraph} = this._getListArgs(args);
const {where, condition, conditionGraph, ...restArgs} = this._getListArgs(args);
let {fields} = restArgs;
if (fields === '*') {
fields = `${this.tn}.*`;
}
let query = this.$db
const query = this.$db
// .select(fields)
.select(this.selectQuery(fields))
.where(this._whereFk({parentId, tnp}))
@ -908,7 +902,7 @@ class BaseModelSql extends BaseModel {
async groupBy({having, fields = '', column_name, limit, offset, sort}) {
try {
const columns = [...(column_name ? [column_name] : []), ...fields.split(',').filter(Boolean)];
let query = this.$db
const query = this.$db
.groupBy(columns)
.count(`${(this.pks[0] || this.columns[0]).cn} as count`)
// .select(columns)
@ -1107,7 +1101,8 @@ class BaseModelSql extends BaseModel {
* @private
*/
async _getChildListInParent({parent, child}, rest = {}, index) {
let {fields, where, limit, offset, sort} = this._getChildListArgs(rest, index, child);
const {where, limit, offset, sort, ...restArgs} = this._getChildListArgs(rest, index, child);
let {fields} = restArgs;
const {cn} = this.hasManyRelations.find(({tn}) => tn === child) || {};
const _cn = this.dbModels[child].columnToAlias?.[cn];
@ -1160,7 +1155,8 @@ class BaseModelSql extends BaseModel {
}
public async _getGroupedManyToManyList({rest = {}, index = 0, child, parentIds}) {
let {fields, where, limit, offset, sort} = this._getChildListArgs(rest, index, child);
const {where, limit, offset, sort, ...restArgs} = this._getChildListArgs(rest, index, child);
let {fields} = restArgs;
const {tn, cn, vtn, vcn, vrcn, rtn, rcn} = this.manyToManyRelations.find(({rtn}) => rtn === child) || {};
// @ts-ignore
// const _cn = this.dbModels[tn].columnToAlias?.[cn];
@ -1204,14 +1200,15 @@ class BaseModelSql extends BaseModel {
*/
async hasManyChildren({child, parentId, conditionGraph = null, ...args}: XcFilterWithAlias & { child: string, parentId: any }) {
try {
let {fields, where, limit, offset, sort} = this._getListArgs(args);
const {where, limit, offset, sort, ...restArgs} = this._getListArgs(args);
let {fields} = restArgs;
const {cn} = this.hasManyRelations.find(({tn}) => tn === child) || {};
if (fields === '*') {
fields = `${child}.*`
}
let query = this.dbDriver(child)
const query = this.dbDriver(child)
// .select(...fields.split(','))
.select(this.dbModels?.[child]?.selectQuery(fields) || fields)
.where(cn, parentId)
@ -1412,7 +1409,7 @@ class BaseModelSql extends BaseModel {
fields = fields || f || '*';
try {
for (let parent of parents.split('~')) {
for (const parent of parents.split('~')) {
const {cn} = this.belongsToRelations.find(({rtn}) => rtn === parent) || {};
if (fields !== '*' && fields.split(',').indexOf(cn) === -1) {
fields += ',' + cn;
@ -1481,7 +1478,8 @@ class BaseModelSql extends BaseModel {
*/
async hasManyListGQL({child, ids, ...rest}) {
try {
let {fields, where, limit, offset, conditionGraph, sort} = this._getChildListArgs(rest);
const {where, limit, offset, conditionGraph, sort, ...restArgs} = this._getChildListArgs(rest);
let {fields} = restArgs;
const {cn} = this.hasManyRelations.find(({tn}) => tn === child) || {};
@ -1491,7 +1489,7 @@ class BaseModelSql extends BaseModel {
fields = fields.split(',').map(c => `${child}.${c}`).join(',')
let childs = await this._run(this._paginateAndSort(this.dbDriver.union(
const childs = await this._run(this._paginateAndSort(this.dbDriver.union(
ids.map(p => {
const query = this
.dbDriver(child)
@ -1538,7 +1536,7 @@ class BaseModelSql extends BaseModel {
const {cn} = this.hasManyRelations.find(({tn}) => tn === child) || {};
let childs = await this._run(this.dbDriver.unionAll(
const childs = await this._run(this.dbDriver.unionAll(
ids.map(p => {
const query = this
.dbDriver(child)
@ -1625,7 +1623,7 @@ class BaseModelSql extends BaseModel {
* @private
*/
_getListArgs(args: XcFilterWithAlias): XcFilter {
let obj: XcFilter = {};
const obj: XcFilter = {};
obj.where = args.where || args.w || '';
obj.condition = args.condition || args.c || {};
obj.conditionGraph = args.conditionGraph || {};
@ -1646,7 +1644,7 @@ class BaseModelSql extends BaseModel {
*/
_getChildListArgs(args: any, index?: number, child?: string) {
index++;
let obj: XcFilter = {};
const obj: XcFilter = {};
obj.where = args[`where${index}`] || args[`w${index}`] || '';
obj.limit = Math.max(Math.min(args[`limit${index}`] || args[`l${index}`] || this.config.limitDefault, this.config.limitMax), this.config.limitMin);
obj.offset = args[`offset${index}`] || args[`o${index}`] || 0;

9
packages/nocodb/src/lib/dataMapper/lib/sql/CustomKnex.ts

@ -1,4 +1,5 @@
import Knex from 'knex';
import {BaseModelSql} from "./BaseModelSql";
const opMapping = {
@ -47,9 +48,9 @@ function toArrayOfConditions(str) {
throw new Error(`${str.substring(0, openIndex + 1).slice(-10)} : Closing bracket not found`)
// getting operand starting index
let operandStartIndex = str.lastIndexOf('~', openIndex);
let operator = operandStartIndex != -1 ? str.substring(operandStartIndex + 1, openIndex) : '';
let lhsOfNestedQuery = str.substring(0, openIndex);
const operandStartIndex = str.lastIndexOf('~', openIndex);
const operator = operandStartIndex != -1 ? str.substring(operandStartIndex + 1, openIndex) : '';
const lhsOfNestedQuery = str.substring(0, openIndex);
nestedArrayConditions.push(
...toArrayOfConditions(lhsOfNestedQuery),
@ -108,7 +109,7 @@ const appendWhereCondition = function (conditions, columnAliases: {
break;
}
} else if (typeof condition === 'string') {
let matches = condition.match(/^(?:~(\w+))?\((\w+),(\w+),(.*?)\)(?:~(?:or|and|not))?$/)
const matches = condition.match(/^(?:~(\w+))?\((\w+),(\w+),(.*?)\)(?:~(?:or|and|not))?$/)
if (!matches) throw new Error(`${condition} : not a valid syntax`)
switch (matches[3]) {

2
packages/nocodb/src/lib/index.ts

@ -1,6 +1,6 @@
import Noco from './noco/Noco'
import NcConfigFactory from './utils/NcConfigFactory';
import XcTry from './noco/nc.try';
import NcConfigFactory from './utils/NcConfigFactory';
export default Noco;

50
packages/nocodb/src/lib/migrator/SqlMigrator/lib/KnexMigrator.ts

@ -1,20 +1,22 @@
import fs from "fs";
import mkdirp from "mkdirp";
import path from "path";
import {promisify} from "util";
import glob from "glob";
import Handlebars from "handlebars";
import mkdirp from "mkdirp";
import {SqlClientFactory} from 'nc-help';
import rmdir from "rmdir";
import path from "path";
import SqlMigrator from "./SqlMigrator";
import {SqlClientFactory} from 'nc-help';
import * as fileHelp from "../../util/file.help";
import Debug from "../../util/Debug";
import Result from "../../util/Result";
import Emit from "../../util/emit";
import * as fileHelp from "../../util/file.help";
import Handlebars from "handlebars";
import NcConfigFactory from './NcConfigFactory';
import SqlMigrator from "./SqlMigrator";
const evt = new Emit();
const log = new Debug("KnexMigrator");
@ -502,7 +504,7 @@ export default class KnexMigrator extends SqlMigrator {
if (files.length === migrations.length) {
this.emit(`Evolutions are upto date for ' ${args.env} : ${args.dbAlias} '`);
for (var i = 0; i < migrations.length; ++i) {
for (let i = 0; i < migrations.length; ++i) {
result.data.object.list.push({
title: migrations[i].title,
titleDown: migrations[i].titleDown,
@ -523,9 +525,9 @@ export default class KnexMigrator extends SqlMigrator {
if (migrations.length !== 0) {
// get last evolution that was made
const lastEvolution = migrations[migrations.length - 1];
let i = 0
// find the index of the last evolution in evolution list of files
for (var i = 0; i < files.length; ++i) {
for (; i < files.length; ++i) {
if (this.metaDb) {
if (files[i].title.indexOf(lastEvolution.title) !== -1) {
i++;
@ -548,7 +550,7 @@ export default class KnexMigrator extends SqlMigrator {
/** ************** START : calculate migration steps from filename *************** */
if (!migrationSteps) {
let fileFound = 0;
for (var i = fileIndex; i < files.length; ++i) {
for (let i = fileIndex; i < files.length; ++i) {
migrationSteps++;
if (this.metaDb) {
if (files[i].title.includes(args.file)) {
@ -573,7 +575,7 @@ export default class KnexMigrator extends SqlMigrator {
if (onlyList) {
if (this.metaDb) {
for (var i = 0; i < fileIndex; ++i) {
for (let i = 0; i < fileIndex; ++i) {
result.data.object.list.push({
title: files[i].title,
titleDown: filesDown[i].title_down,
@ -581,7 +583,7 @@ export default class KnexMigrator extends SqlMigrator {
});
}
} else {
for (var i = 0; i < fileIndex; ++i) {
for (let i = 0; i < fileIndex; ++i) {
const fileParts = files[i].split("/");
const downFileParts = filesDown[i].split("/");
result.data.object.list.push({
@ -598,7 +600,7 @@ export default class KnexMigrator extends SqlMigrator {
/** ************** START : Apply migrations *************** */
for (
var i = fileIndex;
let i = fileIndex;
i < files.length && i < fileIndex + migrationSteps;
++i
) {
@ -658,11 +660,11 @@ export default class KnexMigrator extends SqlMigrator {
const trx = await sqlClient.knex.transaction();
try {
for (let query of upStatements) {
for (const query of upStatements) {
await trx.raw(query);
vm.emit(`'${query}' : Executed SQL query`);
}
for (let data of metaTableInserts) {
for (const data of metaTableInserts) {
await trx(connection.meta.tn).insert(data);
vm.emit(`'${data.title}' : Updating bookkeeping of SQL UP migration - done`);
}
@ -746,7 +748,7 @@ export default class KnexMigrator extends SqlMigrator {
if (!migrationSteps) {
let fileFound = 0;
for (var i = migrations.length - 1; i >= 0; --i) {
for (let i = migrations.length - 1; i >= 0; --i) {
migrationSteps++;
if (this.metaDb) {
if (files[i].title_down.includes(args.file)) {
@ -771,7 +773,7 @@ export default class KnexMigrator extends SqlMigrator {
const downStatements = [];
const metaDownDeletes = [];
for (
var i = migrations.length - 1, j = 0;
let i = migrations.length - 1, j = 0;
i >= 0 && j < migrationSteps;
--i, ++j
) {
@ -810,11 +812,11 @@ export default class KnexMigrator extends SqlMigrator {
const trx = await sqlClient.knex.transaction();
try {
for (let query of downStatements) {
for (const query of downStatements) {
await trx.raw(query).transacting(trx);
vm.emit(`'${query}' : Executed SQL query`);
}
for (let condition of metaDownDeletes) {
for (const condition of metaDownDeletes) {
vm.emit(`'${condition.titleDown}' : Updating bookkeeping of SQL DOWN migration - done`);
await trx(connection.meta.tn).where(condition).del();
}
@ -1530,8 +1532,8 @@ export default class KnexMigrator extends SqlMigrator {
if (args.env in this.project.envs) {
let found = 0;
// find if dbAlias exists in sent environment
for (var i = 0; i < this.project.envs[args.env].db.length; ++i) {
let db = this.project.envs[args.env].db[i];
for (let i = 0; i < this.project.envs[args.env].db.length; ++i) {
const db = this.project.envs[args.env].db[i];
if (db.meta.dbAlas === args.db.meta.dbAlias) {
found = 1;
@ -1548,10 +1550,10 @@ export default class KnexMigrator extends SqlMigrator {
} else {
let foundInWorkingEnv = 0;
let i = 0
for (; i < this.project.envs[this.project.workingEnv].db.length; ++i) {
for (var i = 0; i < this.project.envs[this.project.workingEnv].db.length; ++i) {
let db = this.project.envs[this.project.workingEnv].db[i];
const db = this.project.envs[this.project.workingEnv].db[i];
if (db.meta.alias === args.db.meta.alias) {
foundInWorkingEnv = 1;

1
packages/nocodb/src/lib/migrator/SqlMigrator/lib/SqlMigratorFactory.ts

@ -1,4 +1,3 @@
/* eslint-disable no-unreachable */
import KnexMigrator from "./KnexMigrator";
export default class SqlMigratorFactory {

3
packages/nocodb/src/lib/migrator/util/Debug.ts

@ -1,5 +1,6 @@
import debug from "debug";
import boxen from "boxen";
import debug from "debug";
import("colors");
import DebugMgr from "./DebugMgr";

4
packages/nocodb/src/lib/migrator/util/DebugMgr.ts

@ -1,7 +1,3 @@
/* eslint-disable guard-for-in */
/* eslint-disable no-undef */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-unused-vars */
import debug from "debug";
const namespaces = {};

3
packages/nocodb/src/lib/migrator/util/FileCollection.ts

@ -1,6 +1,7 @@
import fs from 'fs';
import { promisify } from "util";
import jsonfile from 'jsonfile';
import fs from 'fs';
export default class FileCollection {
public args;

20
packages/nocodb/src/lib/noco/NcProjectBuilder.ts

@ -1,15 +1,17 @@
import {NcConfig} from "../../interface/config";
import Noco from "./Noco";
import {Router} from "express";
import {RestApiBuilder} from "./rest/RestApiBuilder";
import {GqlApiBuilder} from "./gql/GqlApiBuilder";
import fs from "fs";
import path from "path";
import axios from "axios";
import {Router} from "express";
import {SqlClientFactory, Tele} from 'nc-help';
import path from "path";
import fs from "fs";
import {NcConfig} from "../../interface/config";
import Migrator from '../migrator/SqlMigrator/lib/KnexMigrator';
import axios from "axios";
import Noco from "./Noco";
import {GqlApiBuilder} from "./gql/GqlApiBuilder";
import {XCEeError} from "./meta/NcMetaMgr";
import {RestApiBuilder} from "./rest/RestApiBuilder";
export default class NcProjectBuilder {
@ -764,7 +766,7 @@ export default class NcProjectBuilder {
}
public get prefix(): String {
public get prefix(): string {
return this.config?.prefix;
}

46
packages/nocodb/src/lib/noco/Noco.ts

@ -1,41 +1,36 @@
import * as express from 'express'
/* eslint-disable @typescript-eslint/ban-types */
import fs from "fs";
import path from 'path';
import * as Sentry from '@sentry/node';
import bodyParser from "body-parser";
import morgan from "morgan";
// import Table from "cli-table3";
import cookieParser from 'cookie-parser';
import clear from 'clear';
// const colors = require("colors/safe");
import cookieParser from 'cookie-parser';
import debug from 'debug';
import {v4 as uuidv4} from 'uuid';
import path from 'path';
import fs from "fs";
import * as express from 'express'
import {Router} from "express";
import importFresh from "import-fresh";
import morgan from "morgan";
import {Tele} from "nc-help";
import {NcConfig} from "../../interface/config";
import {RestApiBuilder} from "./rest/RestApiBuilder";
import {GqlApiBuilder} from "./gql/GqlApiBuilder";
import Migrator from '../migrator/SqlMigrator/lib/KnexMigrator';
import NcToolGui from "nc-lib-gui";
import requestIp from 'request-ip';
import {v4 as uuidv4} from 'uuid';
import {NcConfig} from "../../interface/config";
import Migrator from '../migrator/SqlMigrator/lib/KnexMigrator';
import NcConfigFactory from "../utils/NcConfigFactory";
import NcMetaIO from "./meta/NcMetaIO";
import NcProjectBuilderCE from "./NcProjectBuilder";
import NcProjectBuilderEE from "./NcProjectBuilderEE";
import {Router} from "express";
import requestIp from 'request-ip';
import {GqlApiBuilder} from "./gql/GqlApiBuilder";
import NcMetaIO from "./meta/NcMetaIO";
import NcMetaImplCE from "./meta/NcMetaIOImpl";
import RestAuthCtrlCE from "./rest/RestAuthCtrl";
import NcMetaMgrCE from "./meta/NcMetaMgr";
import NcMetaImplEE from "./meta/NcMetaIOImplEE";
import RestAuthCtrlEE from "./rest/RestAuthCtrlEE";
import NcMetaMgrCE from "./meta/NcMetaMgr";
import NcMetaMgrEE from "./meta/NcMetaMgrEE";
import * as Sentry from '@sentry/node';
import {RestApiBuilder} from "./rest/RestApiBuilder";
import RestAuthCtrlCE from "./rest/RestAuthCtrl";
import RestAuthCtrlEE from "./rest/RestAuthCtrlEE";
const log = debug('nc:app');
require('dotenv').config();
@ -326,9 +321,10 @@ export default class Noco {
}
break;
default:
default: {
const projectBuilder = this.projectBuilders.find(pb => pb.id == data.req?.project_id);
return projectBuilder?.handleRunTimeChanges(data);
}
}
};

28
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -1,27 +1,29 @@
import * as fs from "fs";
import debug from 'debug';
import {Router} from "express";
import inflection from "inflection";
import Knex from "knex";
import {
// ModelXcMetaFactory,
MysqlClient, PgClient, SqlClient,
// ExpressXcPolicy,
SqlClientFactory
} from 'nc-help';
import Noco from "../Noco";
import {Acls, DbConfig, NcConfig} from "../../../interface/config";
import XcDynamicChanges from "../../../interface/XcDynamicChanges";
import {Acls, DbConfig, NcConfig} from "../../../interface/config";
import {BaseModelSql, XKnex} from "../../dataMapper";
import inflection from "inflection";
import BaseModel from "./BaseModel";
import {XcCron} from "./XcCron";
import {Router} from "express";
import NcMetaIO from "../meta/NcMetaIO";
import debug from 'debug';
import Knex from "knex";
import ModelXcMetaFactory from "../../sqlMgr/code/models/xc/ModelXcMetaFactory";
import ExpressXcPolicy from '../../sqlMgr/code/policies/xc/ExpressXcPolicy';
import NcHelp from "../../utils/NcHelp";
import * as fs from "fs";
import NcProjectBuilder from "../NcProjectBuilder";
import Noco from "../Noco";
import NcMetaIO from "../meta/NcMetaIO";
import XcCache from "../plugins/adapters/cache/XcCache";
import ModelXcMetaFactory from "../../sqlMgr/code/models/xc/ModelXcMetaFactory";
import ExpressXcPolicy from '../../sqlMgr/code/policies/xc/ExpressXcPolicy';
import BaseModel from "./BaseModel";
import {XcCron} from "./XcCron";
const log = debug('nc:api:base');

8
packages/nocodb/src/lib/noco/common/BaseModel.ts

@ -1,9 +1,11 @@
import Handlebars from "handlebars";
import {IWebhookNotificationAdapter} from "nc-plugin";
import IEmailAdapter from "../../../interface/IEmailAdapter";
import {BaseModelSql} from "../../dataMapper";
// import axios from "axios";
import BaseApiBuilder from "./BaseApiBuilder";
import IEmailAdapter from "../../../interface/IEmailAdapter";
import Handlebars from "handlebars";
import {IWebhookNotificationAdapter} from "nc-plugin";
class BaseModel<T extends BaseApiBuilder<any>> extends BaseModelSql {

3
packages/nocodb/src/lib/noco/common/BaseProcedure.ts

@ -1,7 +1,8 @@
import {GqlApiBuilder} from "../gql/GqlApiBuilder";
import XcProcedure from "./XcProcedure";
import {RestApiBuilder} from "../rest/RestApiBuilder";
import XcProcedure from "./XcProcedure";
export default class BaseProcedure {
protected builder: GqlApiBuilder | RestApiBuilder;

4
packages/nocodb/src/lib/noco/common/XcCron.ts

@ -1,6 +1,8 @@
import {CronJob} from 'cron';
import Noco from "../Noco";
import {NcConfig} from "../../../interface/config";
import Noco from "../Noco";
import BaseApiBuilder from "./BaseApiBuilder";
// import * as tsc from "typescript";

37
packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

@ -1,29 +1,30 @@
import GqlResolver from "./GqlResolver";
import {BaseType} from 'xc-core-ts';
import {DbConfig, NcConfig} from "../../../interface/config";
import Noco from "../Noco";
import GqlMiddleware from "./GqlMiddleware";
import DataLoader from "dataloader";
import _ from 'lodash';
import NcHelp from "../../utils/NcHelp";
import debug from 'debug';
import {Router} from "express";
import XcMetaMgr from "../../../interface/XcMetaMgr";
import BaseApiBuilder from "../common/BaseApiBuilder";
import {execute} from "graphql";
import commonSchema from './common.schema';
import {GqlProcedureResolver} from "./GqlProcedureResolver";
import NcMetaIO from "../meta/NcMetaIO";
import {GraphQLJSON} from 'graphql-type-json';
import _ from 'lodash';
import {BaseType} from 'xc-core-ts';
import debug from 'debug';
import NcProjectBuilder from "../NcProjectBuilder";
import XcMetaMgr from "../../../interface/XcMetaMgr";
import {DbConfig, NcConfig} from "../../../interface/config";
import ExpressXcTsPolicyGql from "../../sqlMgr/code/gql-policies/xc-ts/ExpressXcTsPolicyGql";
import GqlXcSchemaFactory from "../../sqlMgr/code/gql-schema/xc-ts/GqlXcSchemaFactory";
import ModelXcMetaFactory from "../../sqlMgr/code/models/xc/ModelXcMetaFactory";
import ExpressXcTsPolicyGql from "../../sqlMgr/code/gql-policies/xc-ts/ExpressXcTsPolicyGql";
import NcHelp from "../../utils/NcHelp";
import NcProjectBuilder from "../NcProjectBuilder";
import Noco from "../Noco";
import BaseApiBuilder from "../common/BaseApiBuilder";
import NcMetaIO from "../meta/NcMetaIO";
import {GraphQLJSON} from 'graphql-type-json';
import {m2mNotChildren, m2mNotChildrenCount} from "./GqlCommonResolvers";
import GqlMiddleware from "./GqlMiddleware";
import {GqlProcedureResolver} from "./GqlProcedureResolver";
import GqlResolver from "./GqlResolver";
import commonSchema from './common.schema';
const log = debug('nc:api:gql');

22
packages/nocodb/src/lib/noco/gql/GqlAuthResolver.ts

@ -1,19 +1,21 @@
import passport from 'passport';
import {Strategy, ExtractJwt} from 'passport-jwt';
import * as jwt from 'jsonwebtoken';
import {promisify} from 'util';
import bcrypt from 'bcryptjs';
import * as ejs from 'ejs';
import * as jwt from 'jsonwebtoken';
import passport from 'passport';
import {ExtractJwt, Strategy} from 'passport-jwt';
import IEmailAdapter from "../../../interface/IEmailAdapter";
import {DbConfig, NcConfig} from "../../../interface/config";
import {Knex, XKnex} from "../../dataMapper";
import Noco from "../Noco";
import authSchema from './auth/schema';
const {v4: uuidv4} = require('uuid');
const PassportLocalStrategy = require('passport-local').Strategy;
const autoBind = require('auto-bind');
import * as ejs from 'ejs';
import {Knex, XKnex} from "../../dataMapper";
import Noco from "../Noco";
import IEmailAdapter from "../../../interface/IEmailAdapter";
const {isEmail} = require('validator');
// import swaggerUi from 'swagger-ui-express';
@ -225,7 +227,8 @@ export default class GqlAuthResolver {
public async signup(args, {req}) {
let {email, password, firstname, lastname} = args.data;
const {email, firstname, lastname} = args.data;
let {password} = args.data;
if (!isEmail(email)) {
throw new Error(`Not a valid email`);
@ -450,6 +453,7 @@ export default class GqlAuthResolver {
})
}
}
private get emailClient(): IEmailAdapter {
return this.app?.metaMgr?.emailAdapter;
}

5
packages/nocodb/src/lib/noco/gql/GqlBaseResolver.ts

@ -2,7 +2,8 @@ export default class GqlBaseResolver {
constructor() {
}
public static applyMiddlewares(handlers: Function[] = [], resolvers = {}, postHandlers: Function[] = []): any {
// todo: type correction
public static applyMiddlewares(handlers: any[] = [], resolvers = {}, postHandlers: any[] = []): any {
if (!handlers) {
return resolvers;
}
@ -12,7 +13,7 @@ export default class GqlBaseResolver {
for (const handler of handlers) {
await handler(...args)
}
const result = await (resolver as Function)(...args);
const result = await (resolver as any)(...args);
if (postHandlers) {
for (const handler of postHandlers) {
await handler(result, ...args)

5
packages/nocodb/src/lib/noco/gql/GqlMiddleware.ts

@ -1,8 +1,7 @@
import autoBind from 'auto-bind';
// import * as tsc from "typescript";
import {Acls} from "../../../interface/config";
import Handlebars from "handlebars";
// import {NextFunction, Request, Response} from "express";
import {Acls} from "../../../interface/config";
export default class GqlMiddleware {
private tn: any;

6
packages/nocodb/src/lib/noco/gql/GqlProcedureResolver.ts

@ -1,7 +1,9 @@
import autoBind from 'auto-bind';
import {GqlApiBuilder} from "./GqlApiBuilder";
import XcProcedure from "../common/XcProcedure";
import BaseProcedure from "../common/BaseProcedure";
import XcProcedure from "../common/XcProcedure";
import {GqlApiBuilder} from "./GqlApiBuilder";
import GqlBaseResolver from "./GqlBaseResolver";
export class GqlProcedureResolver

8
packages/nocodb/src/lib/noco/gql/GqlResolver.ts

@ -1,10 +1,12 @@
import {BaseModelSql} from "../../dataMapper";
import autoBind from 'auto-bind';
import GqlMiddleware from "./GqlMiddleware";
import {Acls} from "../../../interface/config";
import GqlBaseResolver from "./GqlBaseResolver";
import {BaseModelSql} from "../../dataMapper";
import Noco from "../Noco";
import GqlBaseResolver from "./GqlBaseResolver";
import GqlMiddleware from "./GqlMiddleware";
function parseHrtimeToSeconds(hrtime) {
const seconds = (hrtime[0] + (hrtime[1] / 1e6)).toFixed(3);
return seconds;

13
packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts

@ -1,11 +1,14 @@
import NcMetaIO, {META_TABLES} from "./NcMetaIO";
import Noco from "../Noco";
import CryptoJS from 'crypto-js';
import {nanoid} from 'nanoid';
import {NcConfig} from "../../../interface/config";
import {XKnex, Knex} from "../../dataMapper";
import {Knex, XKnex} from "../../dataMapper";
import NcHelp from "../../utils/NcHelp";
import {nanoid} from 'nanoid';
import Noco from "../Noco";
import XcMigrationSource from "../common/XcMigrationSource";
import CryptoJS from 'crypto-js';
import NcMetaIO, {META_TABLES} from "./NcMetaIO";
export default class NcMetaIOImpl extends NcMetaIO {

64
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -1,41 +1,41 @@
import Noco from "../Noco";
import {Result, NcConfig} from "../../../interface/config";
import {RestApiBuilder} from "../rest/RestApiBuilder";
import {GqlApiBuilder} from "../gql/GqlApiBuilder";
import {Handler, Router} from "express";
import fs from 'fs';
import path from 'path';
import extract from 'extract-zip';
import archiver from 'archiver';
import axios from 'axios';
import bodyParser from "body-parser";
import {Handler, Router} from "express";
import extract from 'extract-zip';
import isDocker from 'is-docker';
import multer from 'multer';
import NcMetaIO, {META_TABLES} from "./NcMetaIO";
import {nanoid} from 'nanoid';
import {
SqlClientFactory, Tele
} from 'nc-help'
import NcHelp from "../../utils/NcHelp";
import bodyParser from "body-parser";
import projectAcl from "../../utils/projectAcl";
import slash from 'slash';
import {v4 as uuidv4} from 'uuid';
import ProjectMgr from '../../sqlMgr/ProjectMgr';
import {nanoid} from 'nanoid';
import mimetypes, {mimeIcons} from "../../utils/mimeTypes";
import IStorageAdapter from "../../../interface/IStorageAdapter";
import IEmailAdapter from "../../../interface/IEmailAdapter";
import EmailFactory from "../plugins/adapters/email/EmailFactory";
import Twilio from "../plugins/adapters/twilio/Twilio";
import IStorageAdapter from "../../../interface/IStorageAdapter";
import {NcConfig, Result} from "../../../interface/config";
import {NcConfigFactory} from "../../index";
import XcCache from "../plugins/adapters/cache/XcCache";
import axios from 'axios';
import isDocker from 'is-docker';
import slash from 'slash';
import RestAuthCtrl from "../rest/RestAuthCtrlEE";
import ExpressXcTsRoutesHm from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesHm";
import ExpressXcTsRoutesBt from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesBt";
import ProjectMgr from '../../sqlMgr/ProjectMgr';
import ExpressXcTsRoutes from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutes";
import ExpressXcTsRoutesBt from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesBt";
import ExpressXcTsRoutesHm from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesHm";
import NcHelp from "../../utils/NcHelp";
import mimetypes, {mimeIcons} from "../../utils/mimeTypes";
import projectAcl from "../../utils/projectAcl";
import Noco from "../Noco";
import {GqlApiBuilder} from "../gql/GqlApiBuilder";
import NcPluginMgr from "../plugins/NcPluginMgr";
import XcCache from "../plugins/adapters/cache/XcCache";
import EmailFactory from "../plugins/adapters/email/EmailFactory";
import Twilio from "../plugins/adapters/twilio/Twilio";
import {RestApiBuilder} from "../rest/RestApiBuilder";
import RestAuthCtrl from "../rest/RestAuthCtrlEE";
import NcMetaIO, {META_TABLES} from "./NcMetaIO";
const XC_PLUGIN_DET = 'XC_PLUGIN_DET';
@ -59,7 +59,7 @@ export default class NcMetaMgr {
protected xcMeta: NcMetaIO;
protected projectMgr: any;
// @ts-ignore
protected isEe: boolean = false;
protected isEe = false;
constructor(app: Noco, config: NcConfig, xcMeta: NcMetaIO) {
@ -207,8 +207,7 @@ export default class NcMetaMgr {
if (this.config.auth) {
if (this.config.auth.jwt) {
let knex;
knex = this.xcMeta.knex;
const knex = this.xcMeta.knex;
let projectHasAdmin = false;
projectHasAdmin = !!(await knex('xc_users').first())
@ -2513,7 +2512,7 @@ export default class NcMetaMgr {
// todo: compare column
switch (args.args.type) {
case 'bt':
case 'hm':
case 'hm': {
const child = await this.xcMeta.metaGet(projectId, dbAlias, 'nc_models', {
title: args.args.childTable
});
@ -2578,6 +2577,7 @@ export default class NcMetaMgr {
});
}
}
}
break;
case 'mm': {
const assoc = await this.xcMeta.metaGet(projectId, dbAlias, 'nc_models', {
@ -3079,7 +3079,7 @@ export default class NcMetaMgr {
return Object.values(result);
}
break;
case 'relation':
case 'relation': {
const relations = await this.xcRelationsGet(args);
@ -3116,6 +3116,7 @@ export default class NcMetaMgr {
}
}
return Object.values(result);
}
break;
}
} catch (e) {
@ -3215,10 +3216,11 @@ export default class NcMetaMgr {
protected async xcPluginTest(req, args): Promise<any> {
try {
switch (args.args.category) {
case 'Email':
case 'Email': {
const emailIns = EmailFactory.createNewInstance(args.args, args.args.input)
await emailIns.init();
await emailIns?.test(req.user?.email)
}
break;
default:
return this.pluginMgr.test(args.args)

3
packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

@ -1,7 +1,8 @@
import NcMetaMgr from "./NcMetaMgr";
import {Tele} from 'nc-help';
import {v4 as uuidv4} from 'uuid';
import NcMetaMgr from "./NcMetaMgr";
export default class NcMetaMgrEE extends NcMetaMgr {
/* protected async handlePublicRequest(req, res, next) {

4
packages/nocodb/src/lib/noco/migrations/nc_001_init.ts

@ -1,15 +1,15 @@
// import s3 from "../plugins/s3";
// import gcs from "../plugins/gcs";
// import smtp from "../plugins/smtp";
import cache from "../plugins/cache";
import googleAuth from "../plugins/googleAuth";
import ses from "../plugins/ses";
// import azure from "../plugins/azure";
// import brand from "../plugins/brand";
// import discord from "../plugins/discord";
// import slack from "../plugins/slack";
// import mattermost from "../plugins/mattermost";
import googleAuth from "../plugins/googleAuth";
// import ee from "../plugins/ee";
import cache from "../plugins/cache";
// import miniio from "../plugins/miniio";
// import spaces from "../plugins/spaces";
// import githubAuth from "../instant/common/plugins/githubAuth";

6
packages/nocodb/src/lib/noco/nc.try.ts

@ -1,9 +1,11 @@
import Noco from "./Noco";
import express from 'express';
import cors from 'cors';
import express from 'express';
import NcConfigFactory from "../utils/NcConfigFactory";
import Noco from "./Noco";
export default async function (dbUrl): Promise<void> {
const server = express();

29
packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts

@ -1,4 +1,3 @@
import NcMetaIO from "../meta/NcMetaIO";
import {
IEmailAdapter,
IStorageAdapter,
@ -8,25 +7,26 @@ import {
XcStoragePlugin, XcWebhookNotificationPlugin
} from "nc-plugin";
import S3PluginConfig from "../../../plugins/s3";
import BackblazePluginConfig from "../../../plugins/backblaze";
import DiscordPluginConfig from "../../../plugins/discord";
import GcsPluginConfig from "../../../plugins/gcs";
import LinodePluginConfig from "../../../plugins/linode";
import BackblazePluginConfig from "../../../plugins/backblaze";
import VultrPluginConfig from "../../../plugins/vultr";
import OvhCloudPluginConfig from "../../../plugins/ovhCloud";
import MattermostPluginConfig from "../../../plugins/mattermost";
import MinioPluginConfig from "../../../plugins/mino";
import SpacesPluginConfig from "../../../plugins/spaces";
import UpcloudPluginConfig from "../../../plugins/upcloud";
import SMTPPluginConfig from "../../../plugins/smtp";
import OvhCloudPluginConfig from "../../../plugins/ovhCloud";
import S3PluginConfig from "../../../plugins/s3";
import ScalewayPluginConfig from "../../../plugins/scaleway";
import SlackPluginConfig from "../../../plugins/slack";
import SMTPPluginConfig from "../../../plugins/smtp";
import SpacesPluginConfig from "../../../plugins/spaces";
import TeamsPluginConfig from "../../../plugins/teams";
import MattermostPluginConfig from "../../../plugins/mattermost";
import DiscordPluginConfig from "../../../plugins/discord";
import TwilioWhatsappPluginConfig from "../../../plugins/twilioWhatsapp";
import TwilioPluginConfig from "../../../plugins/twilio";
import ScalewayPluginConfig from "../../../plugins/scaleway";
import TwilioWhatsappPluginConfig from "../../../plugins/twilioWhatsapp";
import UpcloudPluginConfig from "../../../plugins/upcloud";
import VultrPluginConfig from "../../../plugins/vultr";
import Noco from "../Noco";
import NcMetaIO from "../meta/NcMetaIO";
import Local from "./adapters/storage/Local";
const defaultPlugins = [
@ -134,11 +134,12 @@ class NcPluginMgr {
public async test(args: any): Promise<boolean> {
switch (args.category) {
case 'Storage':
case 'Storage': {
const plugin = defaultPlugins.find(pluginConfig => pluginConfig?.title === args.title);
const tempPlugin = new plugin.builder(this.app, plugin);
await tempPlugin.init(args?.input);
return tempPlugin?.getAdapter()?.test?.();
}
break;
default:
throw new Error('Not implemented');

3
packages/nocodb/src/lib/noco/plugins/adapters/email/EmailFactory.ts

@ -1,6 +1,7 @@
import IEmailAdapter from "../../../../../interface/IEmailAdapter";
import SES from "./SES";
import SMTP from "./SMTP";
import IEmailAdapter from "../../../../../interface/IEmailAdapter";
export default class EmailFactory {

3
packages/nocodb/src/lib/noco/plugins/adapters/email/SMTP.ts

@ -1,8 +1,9 @@
// @ts-ignore
import IEmailAdapter, {XcEmail} from "../../../../../interface/IEmailAdapter";
import nodemailer from 'nodemailer';
import Mail from "nodemailer/lib/mailer";
import IEmailAdapter, {XcEmail} from "../../../../../interface/IEmailAdapter";
export default // @ts-ignore
class SMTP implements IEmailAdapter {

8
packages/nocodb/src/lib/noco/plugins/adapters/storage/Local.ts

@ -1,7 +1,9 @@
import IStorageAdapter, {XcFile} from "../../../../../interface/IStorageAdapter";
import mkdirp from "mkdirp";
import path from "path";
import fs from "fs";
import path from "path";
import mkdirp from "mkdirp";
import IStorageAdapter, {XcFile} from "../../../../../interface/IStorageAdapter";
export default class Local implements IStorageAdapter {

50
packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

@ -1,31 +1,33 @@
import {RestCtrl} from "./RestCtrl";
import {RestCtrlBelongsTo} from "./RestCtrlBelongsTo";
import {RestCtrlHasMany} from "./RestCtrlHasMany";
import {DbConfig, NcConfig} from "../../../interface/config";
import Noco from "../Noco";
import NcHelp from "../../utils/NcHelp";
import {Router} from "express";
import autoBind from "auto-bind";
import fs from 'fs';
import path from 'path';
import mkdirp from 'mkdirp';
import * as ejs from 'ejs';
import debug from 'debug';
import BaseApiBuilder, {IGNORE_TABLES} from "../common/BaseApiBuilder";
import autoBind from "auto-bind";
import debug from 'debug';
import * as ejs from 'ejs';
import {Router} from "express";
import {glob} from "glob";
import {RestCtrlProcedure} from "./RestCtrlProcedure";
import NcMetaIO from "../meta/NcMetaIO";
import {RestCtrlCustom} from "./RestCtrlCustom";
import NcProjectBuilder from "../NcProjectBuilder";
import mkdirp from 'mkdirp';
import {DbConfig, NcConfig} from "../../../interface/config";
import ModelXcMetaFactory from "../../sqlMgr/code/models/xc/ModelXcMetaFactory";
import ExpressXcTsRoutes from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutes";
import SwaggerXc from "../../sqlMgr/code/routers/xc-ts/SwaggerXc";
import ExpressXcTsRoutesHm from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesHm";
import ExpressXcTsRoutesBt from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesBt";
import SwaggerXcHm from "../../sqlMgr/code/routers/xc-ts/SwaggerXcHm";
import SwaggerXcBt from "../../sqlMgr/code/routers/xc-ts/SwaggerXcBt";
import SwaggerXcHm from "../../sqlMgr/code/routers/xc-ts/SwaggerXcHm";
import ExpressXcTsRoutes from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutes";
import ExpressXcTsRoutesBt from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesBt";
import ExpressXcTsRoutesHm from "../../sqlMgr/code/routes/xc-ts/ExpressXcTsRoutesHm";
import NcHelp from "../../utils/NcHelp";
import NcProjectBuilder from "../NcProjectBuilder";
import Noco from "../Noco";
import BaseApiBuilder, {IGNORE_TABLES} from "../common/BaseApiBuilder";
import NcMetaIO from "../meta/NcMetaIO";
import {RestCtrl} from "./RestCtrl";
import {RestCtrlBelongsTo} from "./RestCtrlBelongsTo";
import {RestCtrlCustom} from "./RestCtrlCustom";
import {RestCtrlHasMany} from "./RestCtrlHasMany";
import {RestCtrlProcedure} from "./RestCtrlProcedure";
const log = debug('nc:api:rest');
@ -922,7 +924,7 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
for (const [i, newHmRoute] of Object.entries(hmRoutes)) {
const oldHmRoute: any = oldHmRoutes[i];
this.log(`xcTableRename : Updating routes for ${relationTable}Hm${newTablename} on behalf of '%table rename' - \'%s\' => \'%s\' (HasMany relation)`, relationTable, oldTablename, newTablename)
this.log(`xcTableRename : Updating routes for ${relationTable}Hm${newTablename} on behalf of '%table rename' - '%s' => '%s' (HasMany relation)`, relationTable, oldTablename, newTablename)
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_routes', {
@ -952,7 +954,7 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
for (const [i, newBtRoute] of Object.entries(newBtRoutes)) {
const oldBtRoute: any = oldBtRoutes[i];
this.log(`xcTableRename : Updating routes for ${relationTable}Bt${oldTablename} on behalf of '%table rename' - \'%s\' => \'%s\' (BelongsTo relation)`, relationTable, oldTablename, newTablename)
this.log(`xcTableRename : Updating routes for ${relationTable}Bt${oldTablename} on behalf of '%table rename' - '%s' => '%s' (BelongsTo relation)`, relationTable, oldTablename, newTablename)
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_routes', {
title: `${relationTable}Bt${newTablename}`,
path: newBtRoute.path,
@ -1482,8 +1484,8 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
this.log('populteProcedureAndFunctionRoutes');
const router = this.routers.___procedure = Router();
let functions = [];
let procedures = [];
const functions = [];
const procedures = [];
// enable extra
// try {
// functions = (await this.sqlClient.functionList())?.data?.list;

32
packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts

@ -1,34 +1,34 @@
import passport from 'passport';
import {Strategy, ExtractJwt} from 'passport-jwt';
import * as jwt from 'jsonwebtoken';
import {Knex} from '../../dataMapper';
import {promisify} from 'util';
import bcrypt from 'bcryptjs';
import {DbConfig, NcConfig} from "../../../interface/config";
import validator from "validator";
import * as ejs from 'ejs';
import * as jwt from 'jsonwebtoken';
import {Tele} from 'nc-help';
import passport from 'passport';
import {Strategy as AuthTokenStrategy} from 'passport-auth-token';
import {Strategy as GithubStrategy} from 'passport-github'
import {Strategy as GoogleStrategy} from 'passport-google-oauth20';
import {ExtractJwt, Strategy} from 'passport-jwt';
import validator from "validator";
import {DbConfig, NcConfig} from "../../../interface/config";
import {Knex} from '../../dataMapper';
import Noco from "../Noco";
const {v4: uuidv4} = require('uuid');
const PassportLocalStrategy = require('passport-local').Strategy;
const autoBind = require('auto-bind');
const PassportLocalStrategy = require('passport-local').Strategy;
const {v4: uuidv4} = require('uuid');
import * as crypto from "crypto";
import * as ejs from 'ejs';
import Noco from "../Noco";
import NcMetaIO from "../meta/NcMetaIO";
const {isEmail} = require('validator');
import axios from 'axios';
import axios from 'axios';
import {Strategy as GoogleStrategy} from 'passport-google-oauth20';
import {Strategy as GithubStrategy} from 'passport-github'
import {Strategy as AuthTokenStrategy} from 'passport-auth-token';
// import {Strategy as AzureAdOAuth2Strategy} from 'passport-azure-ad-oauth2';
import IEmailAdapter from "../../../interface/IEmailAdapter";
import XcCache from "../plugins/adapters/cache/XcCache";
// import {Router} from "express";
passport.serializeUser(function ({id, email, email_verified, roles, provider, firstname, lastname, isAuthorized}, done) {
done(null, {

8
packages/nocodb/src/lib/noco/rest/RestAuthCtrlEE.ts

@ -1,11 +1,13 @@
import RestAuthCtrl from "./RestAuthCtrl";
import validator from "validator";
import {Tele} from 'nc-help';
import {v4 as uuidv4} from 'uuid';
import passport from 'passport';
import {Strategy} from 'passport-jwt';
import {v4 as uuidv4} from 'uuid';
import validator from "validator";
import XcCache from "../plugins/adapters/cache/XcCache";
import RestAuthCtrl from "./RestAuthCtrl";
export default class RestAuthCtrlEE extends RestAuthCtrl {

3
packages/nocodb/src/lib/noco/rest/RestBaseCtrl.ts

@ -1,7 +1,8 @@
import {Handler, NextFunction, Request, Response, Router} from "express";
import {Route} from "../../../interface/config";
import Handlebars from "handlebars";
import {Route} from "../../../interface/config";
export abstract class RestBaseCtrl {
public router: Router;

5
packages/nocodb/src/lib/noco/rest/RestCtrl.ts

@ -1,7 +1,8 @@
import autoBind from 'auto-bind';
import {NextFunction, Request, Response, Router} from "express";
import {BaseModelSql} from "../../dataMapper";
import {Acl, Acls, Route} from "../../../interface/config";
import autoBind from 'auto-bind';
import {BaseModelSql} from "../../dataMapper";
import {RestBaseCtrl} from "./RestBaseCtrl";

7
packages/nocodb/src/lib/noco/rest/RestCtrlBelongsTo.ts

@ -1,7 +1,10 @@
import {BaseModelSql} from "../../dataMapper";
import autoBind from 'auto-bind';
import {NextFunction, Request, Response} from "express";
import {Acl, Acls, Route} from "../../../interface/config";
import autoBind from 'auto-bind';
import {BaseModelSql} from "../../dataMapper";
import {RestBaseCtrl} from "./RestBaseCtrl";
export class RestCtrlBelongsTo extends RestBaseCtrl {

7
packages/nocodb/src/lib/noco/rest/RestCtrlCustom.ts

@ -1,7 +1,8 @@
import {NextFunction, Router, Request, Response} from "express";
import {BaseModelSql} from "../../dataMapper";
import {Route} from "../../../interface/config";
import autoBind from 'auto-bind';
import {NextFunction, Request, Response, Router} from "express";
import {Route} from "../../../interface/config";
import {BaseModelSql} from "../../dataMapper";
import {RestBaseCtrl} from "./RestBaseCtrl";

7
packages/nocodb/src/lib/noco/rest/RestCtrlHasMany.ts

@ -1,7 +1,10 @@
import {BaseModelSql} from "../../dataMapper";
import autoBind from 'auto-bind';
import {NextFunction, Request, Response} from "express";
import {Acl, Acls, Route} from "../../../interface/config";
import autoBind from 'auto-bind';
import {BaseModelSql} from "../../dataMapper";
import {RestBaseCtrl} from "./RestBaseCtrl";
export class RestCtrlHasMany extends RestBaseCtrl {

5
packages/nocodb/src/lib/noco/rest/RestCtrlMin.ts

@ -1,7 +1,8 @@
import autoBind from 'auto-bind';
import {Request, Response, Router} from "express";
import {BaseModelSql} from "../../dataMapper";
import {Acls} from "../../../interface/config";
import autoBind from 'auto-bind';
import {BaseModelSql} from "../../dataMapper";
function parseHrtimeToSeconds(hrtime) {

6
packages/nocodb/src/lib/noco/rest/RestCtrlProcedure.ts

@ -1,8 +1,10 @@
import autoBind from 'auto-bind';
import {RestApiBuilder} from "./RestApiBuilder";
import {Handler, NextFunction, Request, Response, Router} from "express";
import XcProcedure from "../common/XcProcedure";
import BaseProcedure from "../common/BaseProcedure";
import XcProcedure from "../common/XcProcedure";
import {RestApiBuilder} from "./RestApiBuilder";
export class RestCtrlProcedure
extends BaseProcedure {

11
packages/nocodb/src/lib/sqlMgr/SqlMgr.ts

@ -1,13 +1,12 @@
import fs from "fs";
import fsExtra from 'fs-extra';
import path from "path";
import {Debug, SqlClientFactory, Result} from "nc-help";
import inflection from 'inflection';
import url from 'url'
import slash from 'slash';
import fsExtra from 'fs-extra';
import importFresh from 'import-fresh';
import inflection from 'inflection';
import {Debug, Result, SqlClientFactory} from "nc-help";
import slash from 'slash';
// import debug from 'debug';
const log = new Debug("SqlMgr");
@ -399,7 +398,7 @@ export default class SqlMgr {
args.type = args.type || args.project.type;
if (this.isDbConnectionProject(args.projectJson)) {
// ignore
} else {
await this.migrator().init(args);
await this.migrator().sync(args);

4
packages/nocodb/src/lib/sqlMgr/code/gql-schema/xc-ts/BaseGqlXcTsSchema.ts

@ -1,6 +1,8 @@
import lodash from "lodash";
import BaseRender from "../../BaseRender";
import {AGG_DEFAULT_COLS, GROUPBY_DEFAULT_COLS} from "./schemaHelp";
import lodash from "lodash";
abstract class BaseGqlXcTsSchema extends BaseRender {

2
packages/nocodb/src/lib/sqlMgr/code/gql-schema/xc-ts/GqlXcSchemaFactory.ts

@ -1,7 +1,7 @@
import GqlXcSchemaMssql from "./GqlXcTsSchemaMssql";
import GqlXcTsSchemaMysql from "./GqlXcTsSchemaMysql";
import GqlXcSchemaOracle from "./GqlXcTsSchemaOracle";
import GqlXcSchemaPg from "./GqlXcTsSchemaPg";
import GqlXcSchemaMssql from "./GqlXcTsSchemaMssql";
import GqlXcSchemaSqlite from "./GqlXcTsSchemaSqlite";
class GqlXcSchemaFactory {

1
packages/nocodb/src/lib/sqlMgr/code/gql-schema/xc-ts/GqlXcTsSchemaMysql.ts

@ -228,7 +228,6 @@ class GqlXcTsSchemaMysql extends BaseGqlXcTsSchema {
case "mediumblob":
case "longblob":
case "enum":
case "time":
return "String"
break;

8
packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaFactory.ts

@ -1,9 +1,9 @@
import ModelXcMetaMysql from "./ModelXcMetaMysql";
import ModelXcMetaSqlite from "./ModelXcMetaSqlite";
import ModelXcMetaPg from "./ModelXcMetaPg";
import BaseModelXcMeta from "./BaseModelXcMeta";
import ModelXcMetaMssql from "./ModelXcMetaMssql";
import ModelXcMetaMysql from "./ModelXcMetaMysql";
import ModelXcMetaOracle from "./ModelXcMetaOracle";
import BaseModelXcMeta from "./BaseModelXcMeta";
import ModelXcMetaPg from "./ModelXcMetaPg";
import ModelXcMetaSqlite from "./ModelXcMetaSqlite";
class ModelXcMetaFactory {
public static create(connectionConfig, args):BaseModelXcMeta {

7
packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaMssql.ts

@ -357,9 +357,6 @@ class ModelXcMetaMssql extends BaseModelXcMeta{
case "set":
str += `"SET(${column.dtxp})"`;
break;
case "time":
str += `DataTypes.TIME`;
break;
case "geometry":
str += `DataTypes.GEOMETRY`;
break;
@ -520,9 +517,9 @@ class ModelXcMetaMssql extends BaseModelXcMeta{
getXcColumnsObject(args) {
let columnsArr = [];
const columnsArr = [];
for (let column of args.columns) {
for (const column of args.columns) {
const columnObj = {
validate: {
func: [],

4
packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaMysql.ts

@ -129,9 +129,9 @@ class ModelXcMetaMysql extends BaseModelXcMeta {
getXcColumnsObject(args) {
let columnsArr = [];
const columnsArr = [];
for (let column of args.columns) {
for (const column of args.columns) {
const columnObj = {
validate: {
func: [],

6
packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaOracle.ts

@ -130,9 +130,9 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
getXcColumnsObject(args) {
let columnsArr = [];
const columnsArr = [];
for (let column of args.columns) {
for (const column of args.columns) {
const columnObj = {
validate: {
func: [],
@ -330,8 +330,6 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
case 'nclob':
return 'string'
case 'nvarchar2':
case 'octet':
case 'oid':
case 'pointer':
case 'raw':

7
packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaPg.ts

@ -770,9 +770,6 @@ class ModelXcMetaPg extends BaseModelXcMeta {
case "set":
str += `"SET(${column.dtxp})"`;
break;
case "time":
str += `DataTypes.TIME`;
break;
case "geometry":
str += `DataTypes.GEOMETRY`;
break;
@ -934,9 +931,9 @@ class ModelXcMetaPg extends BaseModelXcMeta {
getXcColumnsObject(args) {
let columnsArr = [];
const columnsArr = [];
for (let column of args.columns) {
for (const column of args.columns) {
const columnObj = {
validate: {
func: [],

3
packages/nocodb/src/lib/sqlMgr/code/models/xc/ModelXcMetaSqlite.ts

@ -316,9 +316,6 @@ class ModelXcMetaSqlite extends BaseModelXcMeta {
case "set":
str += `"SET(${column.dtxp})"`;
break;
case "time":
str += `DataTypes.TIME`;
break;
case "geometry":
str += `DataTypes.GEOMETRY`;
break;

3
packages/nocodb/src/lib/sqlMgr/code/policies/xc/ExpressXcPolicy.ts

@ -1,6 +1,7 @@
import BaseRender from "../../BaseRender";
import lodash from "lodash";
import {Acl} from "../../../../../interface/config";
import BaseRender from "../../BaseRender";
class ExpressXcMiddleware extends BaseRender {

7
packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXc.ts

@ -1,4 +1,5 @@
import BaseRender from "../../BaseRender";
import SwaggerTypes from "./SwaggerTypes";
class SwaggerXc extends BaseRender {
@ -51,14 +52,14 @@ class SwaggerXc extends BaseRender {
* @private
*/
_renderDefinitions(args) {
let obj = this.getDefenitions(args);
const obj = this.getDefenitions(args);
return JSON.stringify(obj);
}
getDefenitions(args) {
let obj = {
const obj = {
[args._tn]: {
type: 'object',
properties: {}
@ -68,7 +69,7 @@ class SwaggerXc extends BaseRender {
const properties = obj[args._tn].properties;
for (let column of args.columns) {
for (const column of args.columns) {
const field: any = {};
SwaggerTypes.setSwaggerType(column, field, args.dbType)

2
packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXcBt.ts

@ -49,7 +49,7 @@ class SwaggerXcBt extends BaseRender {
*/
_renderDefinitions(_args) {
let obj = {};
const obj = {};
return JSON.stringify(obj);

2
packages/nocodb/src/lib/sqlMgr/code/routers/xc-ts/SwaggerXcHm.ts

@ -49,7 +49,7 @@ class SwaggerXcHm extends BaseRender {
*/
_renderDefinitions(_args) {
let obj = {};
const obj = {};
return JSON.stringify(obj);

1
packages/nocodb/src/lib/utils/Lang.ts

@ -1,4 +1,5 @@
import osLocale from 'os-locale';
import english from './english.json';
import translated from './translated.json';

9
packages/nocodb/src/lib/utils/NcConfigFactory.ts

@ -1,11 +1,8 @@
import {AuthConfig, DbConfig, MailerConfig, NcConfig} from "../../interface/config";
import {SqlClientFactory} from 'nc-help';
// import {v4 as uuidv4} from 'uuid';
// import fs from 'fs';
// import path from 'path';
import parseDbUrl from "parse-database-url";
import {AuthConfig, DbConfig, MailerConfig, NcConfig} from "../../interface/config";
const {uniqueNamesGenerator, starWars, adjectives, animals} = require('unique-names-generator');
const driverClientMapping = {
@ -537,7 +534,7 @@ export default class NcConfigFactory implements NcConfig {
}*/
}
public version: string = '0.6';
public version = '0.6';
public port: number;
public auth?: AuthConfig;
public env: "production" | "dev" | "test" | string;

3
packages/nocodb/src/plugins/backblaze/Backblaze.ts

@ -1,6 +1,7 @@
import AWS from "aws-sdk";
import fs from "fs";
import path from "path";
import AWS from "aws-sdk";
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class Backblaze implements IStorageAdapter {

1
packages/nocodb/src/plugins/backblaze/BackblazePlugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import Backblaze from "./Backblaze";

3
packages/nocodb/src/plugins/backblaze/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import BackblazePlugin from "./BackblazePlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: BackblazePlugin,

2
packages/nocodb/src/plugins/discord/Discord.ts

@ -1,5 +1,5 @@
import {IWebhookNotificationAdapter} from "nc-plugin";
import axios from "axios";
import {IWebhookNotificationAdapter} from "nc-plugin";
export default class Discord implements IWebhookNotificationAdapter {

1
packages/nocodb/src/plugins/discord/DiscordPlugin.ts

@ -1,4 +1,5 @@
import {IWebhookNotificationAdapter, XcWebhookNotificationPlugin} from "nc-plugin";
import Discord from "./Discord";

3
packages/nocodb/src/plugins/discord/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import DiscordPlugin from "./DiscordPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: DiscordPlugin,

3
packages/nocodb/src/plugins/gcs/Gcs.ts

@ -1,7 +1,8 @@
import fs from "fs";
import path from "path";
import {IStorageAdapter, XcFile} from "nc-plugin";
import {Storage, StorageOptions} from '@google-cloud/storage';
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class Gcs implements IStorageAdapter {

1
packages/nocodb/src/plugins/gcs/GcsPlugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import Gcs from "./Gcs";

3
packages/nocodb/src/plugins/gcs/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import GcsPlugin from "./GcsPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: GcsPlugin,

3
packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts

@ -1,6 +1,7 @@
import AWS from "aws-sdk";
import fs from "fs";
import path from "path";
import AWS from "aws-sdk";
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class LinodeObjectStorage implements IStorageAdapter {

1
packages/nocodb/src/plugins/linode/LinodeObjectStoragePlugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import LinodeObjectStorage from "./LinodeObjectStorage";

3
packages/nocodb/src/plugins/linode/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import LinodeObjectStoragePlugin from "./LinodeObjectStoragePlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig = {
builder: LinodeObjectStoragePlugin,

2
packages/nocodb/src/plugins/mattermost/Mattermost.ts

@ -1,5 +1,5 @@
import {IWebhookNotificationAdapter} from "nc-plugin";
import axios from "axios";
import {IWebhookNotificationAdapter} from "nc-plugin";
export default class Mattermost implements IWebhookNotificationAdapter {

1
packages/nocodb/src/plugins/mattermost/MattermostPlugin.ts

@ -1,4 +1,5 @@
import {IWebhookNotificationAdapter, XcWebhookNotificationPlugin} from "nc-plugin";
import Mattermost from "./Mattermost";

3
packages/nocodb/src/plugins/mattermost/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import MattermostPlugin from "./MattermostPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: MattermostPlugin,

3
packages/nocodb/src/plugins/mino/Minio.ts

@ -1,7 +1,8 @@
import fs from "fs";
import path from "path";
import {IStorageAdapter, XcFile} from "nc-plugin";
import {Client as MinioClient} from "minio";
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class Minio implements IStorageAdapter {

1
packages/nocodb/src/plugins/mino/MinioPlugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import Minio from "./Minio";

3
packages/nocodb/src/plugins/mino/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import S3Plugin from "./MinioPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: S3Plugin,

3
packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts

@ -1,6 +1,7 @@
import AWS from "aws-sdk";
import fs from "fs";
import path from "path";
import AWS from "aws-sdk";
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class OvhCloud implements IStorageAdapter {

1
packages/nocodb/src/plugins/ovhCloud/OvhCloudPlugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import OvhCloud from "./OvhCloud";

3
packages/nocodb/src/plugins/ovhCloud/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import OvhCloud from "./OvhCloudPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig = {
builder: OvhCloud,

3
packages/nocodb/src/plugins/s3/S3.ts

@ -1,6 +1,7 @@
import AWS from "aws-sdk";
import fs from "fs";
import path from "path";
import AWS from "aws-sdk";
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class S3 implements IStorageAdapter {

1
packages/nocodb/src/plugins/s3/S3Plugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import S3 from "./S3";

3
packages/nocodb/src/plugins/s3/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import S3Plugin from "./S3Plugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig = {
builder: S3Plugin,

3
packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts

@ -1,6 +1,7 @@
import AWS from "aws-sdk";
import fs from "fs";
import path from "path";
import AWS from "aws-sdk";
import {IStorageAdapter, XcFile} from "nc-plugin";
export default class ScalewayObjectStorage implements IStorageAdapter {

1
packages/nocodb/src/plugins/scaleway/ScalewayObjectStoragePlugin.ts

@ -1,4 +1,5 @@
import {IStorageAdapter, XcStoragePlugin} from "nc-plugin";
import ScalewayObjectStorage from "./ScalewayObjectStorage";

3
packages/nocodb/src/plugins/scaleway/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import ScalewayObjectStoragePlugin from "./ScalewayObjectStoragePlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig = {
builder: ScalewayObjectStoragePlugin,

2
packages/nocodb/src/plugins/slack/Slack.ts

@ -1,5 +1,5 @@
import {IWebhookNotificationAdapter} from "nc-plugin";
import axios from "axios";
import {IWebhookNotificationAdapter} from "nc-plugin";
export default class Slack implements IWebhookNotificationAdapter {

1
packages/nocodb/src/plugins/slack/SlackPlugin.ts

@ -1,4 +1,5 @@
import {IWebhookNotificationAdapter, XcWebhookNotificationPlugin} from "nc-plugin";
import Slack from "./Slack";

3
packages/nocodb/src/plugins/slack/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import SlackPlugin from "./SlackPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: SlackPlugin,

3
packages/nocodb/src/plugins/smtp/SMTP.ts

@ -1,6 +1,7 @@
import {IEmailAdapter} from "nc-plugin";
import Mail from "nodemailer/lib/mailer";
import nodemailer from "nodemailer";
import Mail from "nodemailer/lib/mailer";
import {XcEmail} from "../../interface/IEmailAdapter";
export default class SMTP implements IEmailAdapter {

1
packages/nocodb/src/plugins/smtp/SMTPPlugin.ts

@ -1,4 +1,5 @@
import {IEmailAdapter, XcEmailPlugin} from "nc-plugin";
import SMTP from "./SMTP";

3
packages/nocodb/src/plugins/smtp/index.ts

@ -1,6 +1,7 @@
import {XcActionType, XcType} from "nc-common";
import {XcPluginConfig} from "nc-plugin";
import SMTPPlugin from "./SMTPPlugin";
import {XcActionType, XcType} from "nc-common";
const config: XcPluginConfig ={
builder: SMTPPlugin,

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save