• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 16211092160

11 Jul 2025 03:27AM UTC coverage: 81.059% (-0.06%) from 81.117%
16211092160

push

github

web-flow
perf: interaction of ai configuration (#1650)

* feat: support connection testing for AI configuration

* perf: interaction of ai configuration

* perf: improve user interaction when opening links in markdown

* chore: update i18n

* fix: type check

8145 of 8669 branches covered (93.96%)

29 of 67 new or added lines in 7 files covered. (43.28%)

1 existing line in 1 file now uncovered.

38735 of 47786 relevant lines covered (81.06%)

1703.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.93
/apps/nestjs-backend/src/features/setting/open-api/setting-open-api.controller.ts
1
/* eslint-disable sonarjs/no-duplicate-string */
4✔
2
import {
3
  BadRequestException,
4
  Body,
5
  Controller,
6
  Get,
7
  Patch,
8
  Post,
9
  UploadedFile,
10
  UseInterceptors,
11
} from '@nestjs/common';
12
import { FileInterceptor } from '@nestjs/platform-express';
13
import type { IPublicSettingVo, ISettingVo, ITestLLMVo, IUploadLogoVo } from '@teable/openapi';
14
import {
15
  IUpdateSettingRo,
16
  testLLMRoSchema,
17
  updateSettingRoSchema,
18
  ITestLLMRo,
19
} from '@teable/openapi';
20
import { ZodValidationPipe } from '../../../zod.validation.pipe';
21
import { Permissions } from '../../auth/decorators/permissions.decorator';
22
import { Public } from '../../auth/decorators/public.decorator';
23
import { SettingOpenApiService } from './setting-open-api.service';
24

25
@Controller('api/admin/setting')
26
export class SettingOpenApiController {
4✔
27
  constructor(private readonly settingOpenApiService: SettingOpenApiService) {}
441✔
28

29
  /**
441✔
30
   * Get the instance settings, now we have config for AI, there are some sensitive fields, we need check the permission before return.
31
   */
441✔
32
  @Permissions('instance|read')
441✔
33
  @Get()
34
  async getSetting(): Promise<ISettingVo> {
×
35
    return await this.settingOpenApiService.getSetting();
×
36
  }
×
37

38
  /**
441✔
39
   * Public endpoint for getting public settings without authentication
40
   */
441✔
41
  @Public()
441✔
42
  @Get('public')
43
  async getPublicSetting(): Promise<IPublicSettingVo> {
×
44
    const setting = await this.settingOpenApiService.getSetting();
×
45
    const { aiConfig, ...rest } = setting;
×
46
    return {
×
47
      ...rest,
×
48
      aiConfig: {
×
49
        enable: aiConfig?.enable ?? false,
×
50
        llmProviders:
×
51
          aiConfig?.llmProviders?.map((provider) => ({
×
52
            type: provider.type,
×
53
            name: provider.name,
×
54
            models: provider.models,
×
55
          })) ?? [],
×
56
      },
×
57
    };
×
58
  }
×
59

60
  @Patch()
441✔
61
  @Permissions('instance|update')
62
  async updateSetting(
1✔
63
    @Body(new ZodValidationPipe(updateSettingRoSchema))
1✔
64
    updateSettingRo: IUpdateSettingRo
1✔
65
  ): Promise<ISettingVo> {
1✔
66
    return await this.settingOpenApiService.updateSetting(updateSettingRo);
1✔
67
  }
1✔
68

69
  @UseInterceptors(
441✔
70
    FileInterceptor('file', {
71
      fileFilter: (_req, file, callback) => {
×
72
        if (file.mimetype.startsWith('image/')) {
×
73
          callback(null, true);
×
74
        } else {
×
75
          callback(new BadRequestException('Invalid file type'), false);
×
76
        }
×
77
      },
×
78
      limits: {
×
79
        fileSize: 500 * 1024, // limit file size is 500KB
×
80
      },
×
81
    })
82
  )
83
  @Patch('logo')
84
  @Permissions('instance|update')
85
  async uploadLogo(@UploadedFile() file: Express.Multer.File): Promise<IUploadLogoVo> {
×
86
    return this.settingOpenApiService.uploadLogo(file);
×
87
  }
×
88

89
  @Permissions('instance|update')
441✔
90
  @Post('test-llm')
NEW
91
  async testLLM(
×
NEW
92
    @Body(new ZodValidationPipe(testLLMRoSchema)) testLLMRo: ITestLLMRo
×
NEW
93
  ): Promise<ITestLLMVo> {
×
NEW
94
    return await this.settingOpenApiService.testLLM(testLLMRo);
×
NEW
95
  }
×
96
}
441✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc