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

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

@ -16,10 +16,10 @@ const pg = {
return {
builder: 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(
(await args.fn(args.pt.arguments[0])).builder.toQuery()
)})${args.colAlias}`
(await args.fn(args.pt.arguments[0])).builder.toQuery(),
)})${args.colAlias}`,
),
};
},
@ -160,13 +160,13 @@ const pg = {
`${(
await Promise.all(
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('(', ')')
.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,
columnIdToUidt,
query,
clientType
clientType,
) {
if (
o?.type === 'Identifier' &&
@ -76,22 +76,22 @@ export async function convertDateFormatForConcat(
if (clientType === 'mysql2') {
query = `DATE_FORMAT(${query}, '${convertDateFormat(
meta.date_format,
clientType
clientType,
)}')`;
} else if (clientType === 'pg') {
query = `TO_CHAR(${query}, '${convertDateFormat(
meta.date_format,
clientType
clientType,
)}')`;
} else if (clientType === 'sqlite3') {
query = `strftime('${convertDateFormat(
meta.date_format,
clientType
clientType,
)}', ${query})`;
} else if (clientType === 'mssql') {
query = `FORMAT(${query}, '${convertDateFormat(
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 { AuditOperationSubTypes, AuditOperationTypes, OrgUserRoles, PluginCategory } from 'nocodb-sdk'
import {
AuditOperationSubTypes,
AuditOperationTypes,
OrgUserRoles,
PluginCategory,
} from 'nocodb-sdk';
import { T } from 'nc-help';
import { v4 as uuidv4 } from 'uuid';
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 DOMPurify from 'isomorphic-dompurify';
import {

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

@ -1,6 +1,11 @@
import { promisify } from 'util';
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 { isEmail } from 'validator';
import { T } from 'nc-help';

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

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

Loading…
Cancel
Save