Browse Source

chore(nocodb): lint

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
e4f5500d31
  1. 4
      packages/nocodb/src/models/Audit.ts
  2. 2
      packages/nocodb/src/models/Base.ts
  3. 4
      packages/nocodb/src/models/Filter.ts
  4. 2
      packages/nocodb/src/models/Project.ts
  5. 2
      packages/nocodb/src/models/RollupColumn.ts
  6. 2
      packages/nocodb/src/services/bulk-data-alias.service.ts
  7. 5
      packages/nocodb/src/services/users/users.service.ts
  8. 2
      packages/nocodb/src/version-upgrader/ncProjectUpgraderV2_0090000.ts
  9. 20
      packages/nocodb/tests/unit/factory/view.ts

4
packages/nocodb/src/models/Audit.ts

@ -54,8 +54,8 @@ export default class Audit implements AuditType {
project_id?: string; project_id?: string;
fk_model_id?: string; fk_model_id?: string;
row_id?: string; row_id?: string;
op_type?: (typeof opTypes)[number]; op_type?: typeof opTypes[number];
op_sub_type?: (typeof opSubTypes)[number]; op_sub_type?: typeof opSubTypes[number];
status?: string; status?: string;
description?: string; description?: string;
details?: string; details?: string;

2
packages/nocodb/src/models/Base.ts

@ -30,7 +30,7 @@ export default class Base implements BaseType {
id?: string; id?: string;
project_id?: string; project_id?: string;
alias?: string; alias?: string;
type?: (typeof DB_TYPES)[number]; type?: typeof DB_TYPES[number];
is_meta?: BoolType; is_meta?: BoolType;
config?: string; config?: string;
inflection_column?: string; inflection_column?: string;

4
packages/nocodb/src/models/Filter.ts

@ -81,8 +81,8 @@ export default class Filter implements FilterType {
fk_column_id?: string; fk_column_id?: string;
fk_parent_id?: string; fk_parent_id?: string;
comparison_op?: (typeof COMPARISON_OPS)[number]; comparison_op?: typeof COMPARISON_OPS[number];
comparison_sub_op?: (typeof COMPARISON_SUB_OPS)[number]; comparison_sub_op?: typeof COMPARISON_SUB_OPS[number];
value?: string; value?: string;

2
packages/nocodb/src/models/Project.ts

@ -63,7 +63,7 @@ export default class Project implements ProjectType {
for (const base of project.bases) { for (const base of project.bases) {
await Base.createBase( await Base.createBase(
{ {
type: base.config?.client as (typeof DB_TYPES)[number], type: base.config?.client as typeof DB_TYPES[number],
...base, ...base,
projectId, projectId,
}, },

2
packages/nocodb/src/models/RollupColumn.ts

@ -20,7 +20,7 @@ export default class RollupColumn implements RollupType {
fk_column_id; fk_column_id;
fk_relation_column_id; fk_relation_column_id;
fk_rollup_column_id; fk_rollup_column_id;
rollup_function: (typeof ROLLUP_FUNCTIONS)[number]; rollup_function: typeof ROLLUP_FUNCTIONS[number];
constructor(data: Partial<RollupColumn>) { constructor(data: Partial<RollupColumn>) {
Object.assign(this, data); Object.assign(this, data);

2
packages/nocodb/src/services/bulk-data-alias.service.ts

@ -24,7 +24,7 @@ export class BulkDataAliasService {
async executeBulkOperation<T extends BulkOperation>( async executeBulkOperation<T extends BulkOperation>(
param: PathParams & { param: PathParams & {
operation: T; operation: T;
options: Parameters<(typeof BaseModelSqlv2.prototype)[T]>; options: Parameters<typeof BaseModelSqlv2.prototype[T]>;
}, },
) { ) {
const { model, view, base } = await this.getModelViewBase(param); const { model, view, base } = await this.getModelViewBase(param);

5
packages/nocodb/src/services/users/users.service.ts

@ -51,7 +51,10 @@ export class UsersService {
email: string; email: string;
lastname: any; lastname: any;
}) { }) {
return this.metaService.metaInsert2(null, null, MetaTable.USERS, { ...param, email: param.email?.toLowerCase() }); return this.metaService.metaInsert2(null, null, MetaTable.USERS, {
...param,
email: param.email?.toLowerCase(),
});
} }
async registerNewUserIfAllowed({ async registerNewUserIfAllowed({

2
packages/nocodb/src/version-upgrader/ncProjectUpgraderV2_0090000.ts

@ -605,7 +605,7 @@ async function migrateProjectModels(
const colBody: Partial<RollupColumn & Column> = { const colBody: Partial<RollupColumn & Column> = {
title: columnMeta._cn, title: columnMeta._cn,
rollup_function: columnMeta.rl rollup_function: columnMeta.rl
.fn as (typeof ROLLUP_FUNCTIONS)[number], .fn as typeof ROLLUP_FUNCTIONS[number],
}; };
colBody.fk_rollup_column_id = colBody.fk_rollup_column_id =

20
packages/nocodb/tests/unit/factory/view.ts

@ -3,7 +3,10 @@ import request from 'supertest';
import Model from '../../../src/models/Model'; import Model from '../../../src/models/Model';
import View from '../../../src/models/View'; import View from '../../../src/models/View';
const createView = async (context, {title, table, type}: {title: string, table: Model, type: ViewTypes}) => { const createView = async (
context,
{ title, table, type }: { title: string; table: Model; type: ViewTypes },
) => {
const viewTypeStr = (type) => { const viewTypeStr = (type) => {
switch (type) { switch (type) {
case ViewTypes.GALLERY: case ViewTypes.GALLERY:
@ -26,13 +29,16 @@ const createView = async (context, {title, table, type}: {title: string, table:
title, title,
type, type,
}); });
if(response.status !== 200) { if (response.status !== 200) {
throw new Error('createView',response.body.message); throw new Error(response.body.message);
} }
const view = await View.getByTitleOrId({fk_model_id: table.id, titleOrId:title}) as View; const view = (await View.getByTitleOrId({
fk_model_id: table.id,
titleOrId: title,
})) as View;
return view return view;
} };
export {createView} export { createView };

Loading…
Cancel
Save