Skip to content

Commit 6896167

Browse files
committed
fix: v2 lint and type error
1 parent 778111d commit 6896167

382 files changed

Lines changed: 2777 additions & 664 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/nestjs-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"pre-test-e2e": "cross-env NODE_ENV=test pnpm -F @teable/db-main-prisma prisma-db-seed -- --e2e",
4747
"test-e2e": "pnpm pre-test-e2e && vitest run --config ./vitest-e2e.config.ts --silent",
4848
"test-e2e-cover": "pnpm test-e2e --coverage --bail 1 ${VITEST_SHARD:+--shard=$VITEST_SHARD}",
49-
"typecheck": "tsc --project ./tsconfig.json --noEmit",
49+
"typecheck": "tsc --project ./tsconfig.typecheck.json --noEmit",
5050
"lint": "eslint . --ext .ts,.js,.cjs,.mjs,.mdx --cache --cache-location ../../.cache/eslint/nestjs-backend.eslintcache",
5151
"fix-all-files": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs,.mdx --fix",
5252
"flamegraph-home": "npx 0x --output-dir './.debug/flamegraph/{pid}.0x' --on-port 'autocannon http://localhost:$PORT --duration 20' -- node ../../node_modules/.bin/next start",

apps/nestjs-backend/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { AttachmentsModule } from './features/attachments/attachments.module';
1414
import { AuthModule } from './features/auth/auth.module';
1515
import { BaseModule } from './features/base/base.module';
1616
import { BaseNodeModule } from './features/base-node/base-node.module';
17+
import { BaseShareModule } from './features/base-share/base-share.module';
1718
import { BuiltinAssetsInitModule } from './features/builtin-assets-init';
1819
import { CanaryModule } from './features/canary';
1920
import { ChatModule } from './features/chat/chat.module';
@@ -40,7 +41,6 @@ import { PluginPanelModule } from './features/plugin-panel/plugin-panel.module';
4041
import { SelectionModule } from './features/selection/selection.module';
4142
import { AdminOpenApiModule } from './features/setting/open-api/admin-open-api.module';
4243
import { SettingOpenApiModule } from './features/setting/open-api/setting-open-api.module';
43-
import { BaseShareModule } from './features/base-share/base-share.module';
4444
import { ShareModule } from './features/share/share.module';
4545
import { SpaceModule } from './features/space/space.module';
4646
import { TemplateOpenApiModule } from './features/template/template-open-api.module';

apps/nestjs-backend/src/event-emitter/listeners/trash.listener.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export class TrashListener {
7575
case Events.APP_DELETE: {
7676
resourceId = payload.appId;
7777
resourceType = ResourceType.App;
78-
const app = await this.prismaService.app.findUnique({
78+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
79+
const app = await (this.prismaService as any).app.findUnique({
7980
where: { id: resourceId },
8081
select: { id: true, baseId: true, deletedTime: true },
8182
});
@@ -86,7 +87,8 @@ export class TrashListener {
8687
case Events.WORKFLOW_DELETE: {
8788
resourceId = payload.workflowId;
8889
resourceType = ResourceType.Workflow;
89-
const workflow = await this.prismaService.workflow.findUnique({
90+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
91+
const workflow = await (this.prismaService as any).workflow.findUnique({
9092
where: { id: resourceId },
9193
select: { id: true, baseId: true, deletedTime: true },
9294
});

apps/nestjs-backend/src/features/attachments/attachments.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import { AttachmentsStorageService } from './attachments-storage.service';
3333
import StorageAdapter from './plugins/adapter';
3434
import type { LocalStorage } from './plugins/local';
3535
import { InjectStorageAdapter } from './plugins/storage';
36-
import { getExtensionPreview, getSafeUploadContentType } from './utils';
36+
import { getSafeUploadContentType } from './plugins/utils';
37+
import { getExtensionPreview } from './utils';
3738
@Injectable()
3839
export class AttachmentsService {
3940
private logger = new Logger(AttachmentsService.name);

apps/nestjs-backend/src/features/attachments/plugins/local.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import type { IClsStore } from '../../../types/cls';
1818
import { FileUtils } from '../../../utils';
1919
import { Encryptor } from '../../../utils/encryptor';
2020
import { second } from '../../../utils/second';
21-
import { isBodyParserFallback } from '../utils';
2221
import StorageAdapter from './adapter';
2322
import type { ILocalFileUpload, IObjectMeta, IPresignParams, IRespHeaders } from './types';
23+
import { isBodyParserFallback } from './utils';
2424

2525
interface ITokenEncryptor {
2626
expiresDate: number;

apps/nestjs-backend/src/features/attachments/plugins/utils.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
12
import { getPublicFullStorageUrl as getPublicFullStorageUrlOpenApi } from '@teable/openapi';
23
import { baseConfig } from '../../../configs/base.config';
34
import { storageConfig } from '../../../configs/storage';
45
import type { ThumbnailSize } from './types';
56

7+
const OCTET_STREAM = 'application/octet-stream';
8+
const JSON_PREFIX = 'application/json';
9+
10+
/**
11+
* Check if a content type would be intercepted by Express body parser (e.g. application/json).
12+
* When uploading internally via localhost, these types cause the stream to be consumed
13+
* before reaching the upload handler, so we need to fall back to application/octet-stream.
14+
* This only applies to local storage where the upload goes through the same Express server.
15+
*/
16+
export const getSafeUploadContentType = (contentType: string): string => {
17+
const { provider } = storageConfig();
18+
if (provider === 'local' && contentType && contentType.startsWith(JSON_PREFIX)) {
19+
return OCTET_STREAM;
20+
}
21+
return contentType;
22+
};
23+
24+
/**
25+
* Check if a mimetype mismatch is caused by the body parser fallback.
26+
* Returns true if the request used octet-stream as a substitute for a JSON content type.
27+
*/
28+
export const isBodyParserFallback = (mimetype: string, expectedType: string): boolean => {
29+
const { provider } = storageConfig();
30+
if (provider === 'local' && mimetype === OCTET_STREAM && expectedType.startsWith(JSON_PREFIX)) {
31+
return true;
32+
}
33+
return false;
34+
};
35+
636
/**
737
* public bucket storage url path
838
*/

apps/nestjs-backend/src/features/attachments/utils.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
/* eslint-disable @typescript-eslint/naming-convention */
2-
const OCTET_STREAM = 'application/octet-stream';
3-
const JSON_PREFIX = 'application/json';
4-
5-
/**
6-
* Check if a content type would be intercepted by Express body parser (e.g. application/json).
7-
* When uploading internally via localhost, these types cause the stream to be consumed
8-
* before reaching the upload handler, so we need to fall back to application/octet-stream.
9-
*/
10-
export const getSafeUploadContentType = (contentType: string): string => {
11-
if (contentType && contentType.startsWith(JSON_PREFIX)) {
12-
return OCTET_STREAM;
13-
}
14-
return contentType;
15-
};
16-
17-
/**
18-
* Check if a mimetype mismatch is caused by the body parser fallback.
19-
* Returns true if the request used octet-stream as a substitute for a JSON content type.
20-
*/
21-
export const isBodyParserFallback = (mimetype: string, expectedType: string): boolean => {
22-
return mimetype === OCTET_STREAM && expectedType.startsWith(JSON_PREFIX);
23-
};
24-
251
export const getExtensionPreview = (contentType: string) => {
262
const imageExtensions = [
273
'jif',

apps/nestjs-backend/src/features/canary/interceptors/v2-indicator.interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
type CallHandler,
77
Logger,
88
} from '@nestjs/common';
9-
import * as Sentry from '@sentry/nestjs';
109
import { trace } from '@opentelemetry/api';
10+
import * as Sentry from '@sentry/nestjs';
1111
import type { Response } from 'express';
1212
import { ClsService } from 'nestjs-cls';
1313
import type { Observable } from 'rxjs';

apps/nestjs-backend/src/features/field/field-calculate/field-supplement.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import { FormulaFieldDto } from '../model/field-dto/formula-field.dto';
8080
import type { LinkFieldDto } from '../model/field-dto/link-field.dto';
8181
import { RollupFieldDto } from '../model/field-dto/rollup-field.dto';
8282

83+
// eslint-disable-next-line @typescript-eslint/naming-convention
8384
type LinkFieldReference = Pick<IFieldVo, 'name' | 'isMultipleCellValue'> & {
8485
options: Pick<ILinkFieldOptionsRo, 'relationship' | 'foreignTableId'> &
8586
Partial<Pick<ILinkFieldOptions, 'fkHostTableName' | 'selfKeyName' | 'foreignKeyName'>>;

apps/nestjs-backend/src/features/field/model/field-dto/created-time-field.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class CreatedTimeFieldDto extends CreatedTimeFieldCore implements FieldBa
2020
return input.toISOString();
2121
}
2222
if (typeof input === 'string') {
23-
const hasTimezone = /[zZ]|[+-]\d{2}:\d{2}$/.test(input);
23+
const hasTimezone = /z|[+-]\d{2}:\d{2}$/i.test(input);
2424
const parsed = new Date(hasTimezone ? input : `${input}Z`);
2525
if (!Number.isNaN(parsed.getTime())) {
2626
return parsed.toISOString();

0 commit comments

Comments
 (0)