Browse Source

refactor: suggested changes

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5239/head
Pranav C 2 years ago
parent
commit
c0ad5b1d1a
  1. 8
      packages/nocodb/src/lib/controllers/auditController.ts
  2. 5
      packages/nocodb/src/lib/controllers/dataControllers/bulkDataAliasController.ts
  3. 2
      packages/nocodb/src/lib/controllers/dataControllers/dataAliasController.ts
  4. 2
      packages/nocodb/src/lib/controllers/dataControllers/dataAliasExportController.ts
  5. 8
      packages/nocodb/src/lib/meta/api/index.ts
  6. 5
      packages/nocodb/src/lib/services/attachmentService.ts
  7. 14
      packages/nocodb/src/lib/services/auditService.ts
  8. 6
      packages/nocodb/src/lib/services/dataService/export.ts
  9. 5
      packages/nocodb/src/lib/services/projectUserService.ts
  10. 6
      packages/nocodb/src/lib/services/syncService/helpers/job.ts
  11. 3
      packages/nocodb/src/lib/services/tableService.ts

8
packages/nocodb/src/lib/controllers/auditController.ts

@ -9,9 +9,7 @@ export async function commentRow(req: Request<any, any>, res) {
await auditService.commentRow({
rowId: req.params.rowId,
user: (req as any).user,
body: {
...req.body,
},
body: req.body,
})
);
}
@ -20,9 +18,7 @@ export async function auditRowUpdate(req: Request<any, any>, res) {
res.json(
await auditService.auditRowUpdate({
rowId: req.params.rowId,
body: {
...req.body,
},
body: req.body,
})
);
}

5
packages/nocodb/src/lib/controllers/dataControllers/bulkDataAliasController.ts

@ -1,10 +1,8 @@
import { Request, Response, Router } from 'express';
import { bulkDataService } from '../../services'
import { bulkDataService } from '../../services';
import ncMetaAclMw from '../../meta/helpers/ncMetaAclMw';
import apiMetrics from '../../meta/helpers/apiMetrics';
async function bulkDataInsert(req: Request, res: Response) {
res.json(
await bulkDataService.bulkDataInsert({
@ -63,7 +61,6 @@ async function bulkDataDeleteAll(req: Request, res: Response) {
);
}
const router = Router({ mergeParams: true });
router.post(

2
packages/nocodb/src/lib/controllers/dataControllers/dataAliasController.ts

@ -1,5 +1,5 @@
import { Request, Response, Router } from 'express';
import { dataService } from '../../services'
import { dataService } from '../../services';
import ncMetaAclMw from '../../meta/helpers/ncMetaAclMw';
import apiMetrics from '../../meta/helpers/apiMetrics';
import { parseHrtimeToSeconds } from '../../meta/api/helpers';

2
packages/nocodb/src/lib/controllers/dataControllers/dataAliasExportController.ts

@ -7,7 +7,7 @@ import {
extractCsvData,
extractXlsxData,
} from '../../services/dataService/helpers';
import { getViewAndModelFromRequestByAliasOrId } from './helpers'
import { getViewAndModelFromRequestByAliasOrId } from './helpers';
async function excelDataExport(req: Request, res: Response) {
const { model, view } = await getViewAndModelFromRequestByAliasOrId(req);

8
packages/nocodb/src/lib/meta/api/index.ts

@ -1,4 +1,4 @@
import { Tele } from 'nc-help';
import { T } from 'nc-help';
import orgLicenseController from '../../controllers/orgLicenseController';
import orgTokenController from '../../controllers/orgTokenController';
import orgUserController from '../../controllers/orgUserController';
@ -133,15 +133,15 @@ export default function (router: Router, server) {
}).on('connection', (socket) => {
clients[socket.id] = socket;
const id = getHash(
(process.env.NC_SERVER_UUID || Tele.id) +
(process.env.NC_SERVER_UUID || T.id) +
(socket?.handshake as any)?.user?.id
);
socket.on('page', (args) => {
Tele.page({ ...args, id });
T.page({ ...args, id });
});
socket.on('event', (args) => {
Tele.event({ ...args, id });
T.event({ ...args, id });
});
socket.on('subscribe', (room) => {
if (room in jobs) {

5
packages/nocodb/src/lib/services/attachmentService.ts

@ -1,8 +1,3 @@
// @ts-ignore
import { Request, Response, Router } from 'express';
import { nanoid } from 'nanoid';
import path from 'path';
import slash from 'slash';

14
packages/nocodb/src/lib/services/auditService.ts

@ -1,10 +1,10 @@
import {
AuditRowUpdatePayloadType,
CommentRowPayloadType,
} from 'nocodb-sdk/build/main/lib/CustomAPI';
import { validatePayload } from '../meta/api/helpers';
import Audit from '../models/Audit';
import { AuditOperationSubTypes, AuditOperationTypes } from 'nocodb-sdk';
import {
AuditOperationSubTypes,
AuditOperationTypes,
AuditRowUpdateReqType,
} from 'nocodb-sdk';
import Model from '../models/Model';
import { PagedResponseImpl } from '../meta/helpers/PagedResponse';
@ -12,7 +12,7 @@ import DOMPurify from 'isomorphic-dompurify';
export async function commentRow(param: {
rowId: string;
body: CommentRowPayloadType;
body: AuditRowUpdateReqType;
user: any;
}) {
await validatePayload(
@ -29,7 +29,7 @@ export async function commentRow(param: {
export async function auditRowUpdate(param: {
rowId: string;
body: AuditRowUpdatePayloadType;
body: AuditRowUpdateReqType;
}) {
await validatePayload(
'swagger.json#/components/schemas/AuditRowUpdateReq',

6
packages/nocodb/src/lib/services/dataService/export.ts

@ -1,10 +1,6 @@
import {
getViewAndModelByAliasOrId,
PathParams,
} from './helpers';
import { getViewAndModelByAliasOrId, PathParams } from './helpers';
import { View } from '../../models';
// Todo: bring logic from controller
export async function excelDataExport(
param: PathParams & {

5
packages/nocodb/src/lib/services/projectUserService.ts

@ -292,9 +292,8 @@ export async function sendInviteEmail(
req: any
): Promise<any> {
try {
const template = (
await import('./userService/ui/emailTemplates/invite')
).default;
const template = (await import('./userService/ui/emailTemplates/invite'))
.default;
const emailAdapter = await NcPluginMgrv2.emailAdapter();

6
packages/nocodb/src/lib/services/syncService/helpers/job.ts

@ -679,8 +679,6 @@ export default async (
);
}
// debug
// console.log(JSON.stringify(tables, null, 2));
return tables;
}
@ -1413,7 +1411,7 @@ export default async (
case UITypes.DateTime:
case UITypes.CreateTime:
case UITypes.LastModifiedTime:
rec[key] = dayjs(value).utc().format('YYYY-MM-DD HH:mm');
rec[key] = dayjs(value).format('YYYY-MM-DD HH:mm');
break;
case UITypes.Date:
@ -1422,7 +1420,7 @@ export default async (
rec[key] = null;
logBasic(`:: Invalid date ${value}`);
} else {
rec[key] = dayjs(value).utc().format('YYYY-MM-DD');
rec[key] = dayjs(value).format('YYYY-MM-DD');
}
break;

3
packages/nocodb/src/lib/services/tableService.ts

@ -51,7 +51,7 @@ export async function tableUpdate(param: {
if ('meta' in param.table) {
await Model.updateMeta(param.tableId, param.table.meta);
return { msg: 'success' }
return true;
}
if (!param.table.table_name) {
@ -201,7 +201,6 @@ export async function tableDelete(param: {
return table.delete();
}
export async function getTableWithAccessibleViews(param: {
tableId: string;
user: User;

Loading…
Cancel
Save