Browse Source

refactor: handler to service-controller - table and column

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5239/head
Pranav C 2 years ago
parent
commit
60507cc433
  1. 6
      packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts
  2. 11
      packages/nocodb-sdk/src/lib/sqlUi/SqlUiFactory.ts
  3. 1778
      packages/nocodb/src/lib/controllers/columnController.ts
  4. 24
      packages/nocodb/src/lib/controllers/filterController.ts
  5. 8
      packages/nocodb/src/lib/meta/api/helpers/columnHelpers.ts
  6. 1778
      packages/nocodb/src/lib/services/columnService.ts
  7. 11
      packages/nocodb/src/lib/services/filterService.ts
  8. 2
      packages/nocodb/src/lib/services/index.ts
  9. 4
      packages/nocodb/src/lib/services/tableService.ts

6
packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts

@ -1,3 +1,4 @@
import { NormalColumnRequestType } from '../Api'
import UITypes from '../UITypes';
import { IDType } from './index';
@ -794,7 +795,10 @@ export class OracleUi {
}
}
static getDataTypeForUiType(col: { uidt: UITypes }, idType?: IDType) {
static getDataTypeForUiType(
col: { uidt: UITypes | NormalColumnRequestType['uidt'] },
idType?: IDType
) {
const colProp: any = {};
switch (col.uidt) {
case 'ID':

11
packages/nocodb-sdk/src/lib/sqlUi/SqlUiFactory.ts

@ -1,3 +1,4 @@
import { BoolType } from '../Api'
import UITypes from '../UITypes';
import { MssqlUi } from './MssqlUi';
@ -56,12 +57,12 @@ export type SqlUIColumn = {
dt?: string;
dtx?: string;
ct?: string;
nrqd?: boolean;
rqd?: boolean;
nrqd?: BoolType;
rqd?: BoolType;
ck?: string;
pk?: boolean;
un?: boolean;
ai?: boolean;
pk?: BoolType;
un?: BoolType;
ai?: BoolType;
cdf?: string | any;
clen?: number | any;
np?: string;

1778
packages/nocodb/src/lib/controllers/columnController.ts

File diff suppressed because it is too large Load Diff

24
packages/nocodb/src/lib/controllers/filterController.ts

@ -16,15 +16,8 @@ import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import { getAjvValidatorMw } from '../meta/api/helpers';
// @ts-ignore
export async function filterGet(req: Request, res: Response, next) {
try {
const filter = await Filter.get(req.params.filterId);
res.json(filter);
} catch (e) {
console.log(e);
next(e);
}
export async function filterGet(req: Request, res: Response) {
res.json(await Filter.get(req.params.filterId));
}
// @ts-ignore
@ -33,14 +26,11 @@ export async function filterList(
res: Response,
next
) {
try {
const filter = await Filter.rootFilterList({ viewId: req.params.viewId });
res.json(filter);
} catch (e) {
console.log(e);
next(e);
}
res.json(
await Filter.rootFilterList({
viewId: req.params.viewId,
})
);
}
// @ts-ignore
export async function filterChildrenRead(

8
packages/nocodb/src/lib/meta/api/helpers/columnHelpers.ts

@ -1,9 +1,9 @@
import { customAlphabet } from 'nanoid';
import {
BoolType,
ColumnReqType,
LinkToAnotherRecordType,
LookupColumnReqType,
BoolType,
RelationTypes,
RollupColumnReqType,
TableType,
@ -77,9 +77,7 @@ export async function createHmAndBtColumn(
}
}
export async function validateRollupPayload(
payload: ColumnReqType & { uidt: UITypes }
) {
export async function validateRollupPayload(payload: ColumnReqType | Column) {
validateParams(
[
'title',
@ -125,7 +123,7 @@ export async function validateRollupPayload(
}
export async function validateLookupPayload(
payload: ColumnReqType & { uidt: UITypes },
payload: ColumnReqType,
columnId?: string
) {
validateParams(

1778
packages/nocodb/src/lib/services/columnService.ts

File diff suppressed because it is too large Load Diff

11
packages/nocodb/src/lib/services/filterService.ts

@ -0,0 +1,11 @@
import Filter from '../models/Filter'
export async function filterGet(param: { filterId: string }) {
const filter = await Filter.get(param.filterId)
return filter
}
export async function filterList(param: { viewId: string }) {
const filter = await Filter.rootFilterList({ viewId: param.viewId })
return filter
}

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

@ -1,2 +1,4 @@
// export * as projectService from './projectService';
export * as tableService from './tableService';
export * as columnService from './columnService';
export * as filterService from './filterService';

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

@ -32,7 +32,7 @@ export function reorderTable(param: { tableId: string; order: any }) {
return Model.updateOrder(param.tableId, param.order);
}
export async function deleteTable(param: { tableId: string; user: User }) {
export async function tableDelete(param: { tableId: string; user: User }) {
const table = await Model.getByIdOrName({ id: param.tableId });
await table.getColumns();
@ -193,7 +193,7 @@ export async function getAccessibleTables(param: {
: (tableList.filter((t) => !t.mm) as Model[]);
}
export async function createTable(args: {
export async function tableCreate(args: {
projectId: string;
baseId?: string;
table: TableReqType;

Loading…
Cancel
Save