Browse Source

chore: lint

pull/5444/head
Wing-Kam Wong 2 years ago
parent
commit
dd08439e0c
  1. 15
      packages/nocodb-nest/src/db/formulav2/formulaQueryBuilderv2.ts
  2. 14
      packages/nocodb-nest/src/db/functionMappings/pg.ts
  3. 10
      packages/nocodb-nest/src/helpers/formulaFnHelper.ts
  4. 7
      packages/nocodb-nest/src/modules/project-users/project-users.service.ts
  5. 1
      packages/nocodb-nest/src/modules/tables/tables.service.ts
  6. 7
      packages/nocodb-nest/src/modules/users/users.service.ts
  7. 2
      packages/nocodb-nest/src/plugins/vultr/index.ts

15
packages/nocodb-nest/src/db/formulav2/formulaQueryBuilderv2.ts

@ -3,7 +3,10 @@ import { jsepCurlyHook, UITypes } from 'nocodb-sdk';
import mapFunctionName from '../mapFunctionName'; import mapFunctionName from '../mapFunctionName';
import genRollupSelectv2 from '../genRollupSelectv2'; import genRollupSelectv2 from '../genRollupSelectv2';
import FormulaColumn from '../../models/FormulaColumn'; import FormulaColumn from '../../models/FormulaColumn';
import { convertDateFormatForConcat, validateDateWithUnknownFormat } from '../../helpers/formulaFnHelper'; import {
convertDateFormatForConcat,
validateDateWithUnknownFormat,
} from '../../helpers/formulaFnHelper';
import { CacheGetType, CacheScope } from '../../utils/globals'; import { CacheGetType, CacheScope } from '../../utils/globals';
import NocoCache from '../../cache/NocoCache'; import NocoCache from '../../cache/NocoCache';
import type { XKnex } from '../CustomKnex'; import type { XKnex } from '../CustomKnex';
@ -640,7 +643,7 @@ async function _formulaQueryBuilder(
arg, arg,
columnIdToUidt, columnIdToUidt,
query, query,
knex.clientType() knex.clientType(),
); );
} else { } else {
// sqlite3: special handling - See BinaryExpression // sqlite3: special handling - See BinaryExpression
@ -657,9 +660,9 @@ async function _formulaQueryBuilder(
} }
} }
return query; return query;
}) }),
) )
).join()})${colAlias}`.replace(/\?/g, '\\?') ).join()})${colAlias}`.replace(/\?/g, '\\?'),
), ),
}; };
} else if (pt.type === 'Literal') { } else if (pt.type === 'Literal') {
@ -741,13 +744,13 @@ async function _formulaQueryBuilder(
pt.left?.arguments?.[0], pt.left?.arguments?.[0],
columnIdToUidt, columnIdToUidt,
left, left,
knex.clientType() knex.clientType(),
); );
right = await convertDateFormatForConcat( right = await convertDateFormatForConcat(
pt.right?.arguments?.[0], pt.right?.arguments?.[0],
columnIdToUidt, columnIdToUidt,
right, right,
knex.clientType() knex.clientType(),
); );
// handle NULL values when calling CONCAT for sqlite3 // handle NULL values when calling CONCAT for sqlite3

14
packages/nocodb-nest/src/db/functionMappings/pg.ts

@ -16,10 +16,10 @@ const pg = {
return { return {
builder: args.knex.raw( builder: args.knex.raw(
`POSITION(${args.knex.raw( `POSITION(${args.knex.raw(
(await args.fn(args.pt.arguments[1])).builder.toQuery() (await args.fn(args.pt.arguments[1])).builder.toQuery(),
)} in ${args.knex.raw( )} in ${args.knex.raw(
(await args.fn(args.pt.arguments[0])).builder.toQuery() (await args.fn(args.pt.arguments[0])).builder.toQuery(),
)})${args.colAlias}` )})${args.colAlias}`,
), ),
}; };
}, },
@ -160,13 +160,13 @@ const pg = {
`${( `${(
await Promise.all( await Promise.all(
args.pt.arguments.map(async (ar) => args.pt.arguments.map(async (ar) =>
(await args.fn(ar, '', 'OR')).builder.toQuery() (await args.fn(ar, '', 'OR')).builder.toQuery(),
) ),
) )
).join(' OR ')}` ).join(' OR ')}`,
) )
.wrap('(', ')') .wrap('(', ')')
.toQuery()} THEN TRUE ELSE FALSE END ${args.colAlias}` .toQuery()} THEN TRUE ELSE FALSE END ${args.colAlias}`,
), ),
}; };
}, },

10
packages/nocodb-nest/src/helpers/formulaFnHelper.ts

@ -60,7 +60,7 @@ export async function convertDateFormatForConcat(
o, o,
columnIdToUidt, columnIdToUidt,
query, query,
clientType clientType,
) { ) {
if ( if (
o?.type === 'Identifier' && o?.type === 'Identifier' &&
@ -76,22 +76,22 @@ export async function convertDateFormatForConcat(
if (clientType === 'mysql2') { if (clientType === 'mysql2') {
query = `DATE_FORMAT(${query}, '${convertDateFormat( query = `DATE_FORMAT(${query}, '${convertDateFormat(
meta.date_format, meta.date_format,
clientType clientType,
)}')`; )}')`;
} else if (clientType === 'pg') { } else if (clientType === 'pg') {
query = `TO_CHAR(${query}, '${convertDateFormat( query = `TO_CHAR(${query}, '${convertDateFormat(
meta.date_format, meta.date_format,
clientType clientType,
)}')`; )}')`;
} else if (clientType === 'sqlite3') { } else if (clientType === 'sqlite3') {
query = `strftime('${convertDateFormat( query = `strftime('${convertDateFormat(
meta.date_format, meta.date_format,
clientType clientType,
)}', ${query})`; )}', ${query})`;
} else if (clientType === 'mssql') { } else if (clientType === 'mssql') {
query = `FORMAT(${query}, '${convertDateFormat( query = `FORMAT(${query}, '${convertDateFormat(
meta.date_format, meta.date_format,
clientType clientType,
)}')`; )}')`;
} }
} }

7
packages/nocodb-nest/src/modules/project-users/project-users.service.ts

@ -1,5 +1,10 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AuditOperationSubTypes, AuditOperationTypes, OrgUserRoles, PluginCategory } from 'nocodb-sdk' import {
AuditOperationSubTypes,
AuditOperationTypes,
OrgUserRoles,
PluginCategory,
} from 'nocodb-sdk';
import { T } from 'nc-help'; import { T } from 'nc-help';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import * as ejs from 'ejs'; import * as ejs from 'ejs';

1
packages/nocodb-nest/src/modules/tables/tables.service.ts

@ -1,4 +1,3 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import DOMPurify from 'isomorphic-dompurify'; import DOMPurify from 'isomorphic-dompurify';
import { import {

7
packages/nocodb-nest/src/modules/users/users.service.ts

@ -1,6 +1,11 @@
import { promisify } from 'util'; import { promisify } from 'util';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AuditOperationSubTypes, AuditOperationTypes, OrgUserRoles, validatePassword } from 'nocodb-sdk' import {
AuditOperationSubTypes,
AuditOperationTypes,
OrgUserRoles,
validatePassword,
} from 'nocodb-sdk';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { isEmail } from 'validator'; import { isEmail } from 'validator';
import { T } from 'nc-help'; import { T } from 'nc-help';

2
packages/nocodb-nest/src/plugins/vultr/index.ts

@ -25,7 +25,7 @@ const config: XcPluginConfig = {
label: 'Host Name', label: 'Host Name',
placeholder: 'e.g.: ewr1.vultrobjects.com', placeholder: 'e.g.: ewr1.vultrobjects.com',
type: XcType.SingleLineText, type: XcType.SingleLineText,
required: true required: true,
}, },
{ {
key: 'access_key', key: 'access_key',

Loading…
Cancel
Save