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

teableio / teable / 8537011228

03 Apr 2024 10:15AM CUT coverage: 82.825% (+61.3%) from 21.535%
8537011228

Pull #514

github

web-flow
Merge fe52186b9 into 45ee7ebb3
Pull Request #514: refactor: user and link selector

4033 of 4226 branches covered (95.43%)

343 of 372 new or added lines in 8 files covered. (92.2%)

26958 of 32548 relevant lines covered (82.83%)

1213.2 hits per line

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

69.08
/apps/nestjs-backend/src/features/share/share.controller.ts
1
/* eslint-disable @typescript-eslint/no-explicit-any */
4✔
2
import {
4✔
3
  Controller,
4✔
4
  HttpCode,
4✔
5
  Post,
4✔
6
  Res,
4✔
7
  UseGuards,
4✔
8
  Request,
4✔
9
  Get,
4✔
10
  Param,
4✔
11
  Body,
4✔
12
  Query,
4✔
13
} from '@nestjs/common';
4✔
14
import {
4✔
15
  ShareViewFormSubmitRo,
4✔
16
  shareViewFormSubmitRoSchema,
4✔
17
  shareViewRowCountRoSchema,
4✔
18
  shareViewAggregationsRoSchema,
4✔
19
  shareViewGroupPointsRoSchema,
4✔
20
  IShareViewRowCountRo,
4✔
21
  IShareViewGroupPointsRo,
4✔
22
  IShareViewAggregationsRo,
4✔
23
  rangesQuerySchema,
4✔
24
  IRangesRo,
4✔
25
  shareViewLinkRecordsRoSchema,
4✔
26
  IShareViewLinkRecordsRo,
4✔
27
  shareViewCollaboratorsRoSchema,
4✔
28
  IShareViewCollaboratorsRo,
4✔
29
} from '@teable/openapi';
4✔
30
import type {
4✔
31
  IRecord,
4✔
32
  IAggregationVo,
4✔
33
  IRowCountVo,
4✔
34
  IGroupPointsVo,
4✔
35
  ICopyVo,
4✔
36
  ShareViewGetVo,
4✔
37
  IShareViewLinkRecordsVo,
4✔
38
  IShareViewCollaboratorsVo,
4✔
39
} from '@teable/openapi';
4✔
40
import { Response } from 'express';
4✔
41
import { ZodValidationPipe } from '../../zod.validation.pipe';
4✔
42
import { Public } from '../auth/decorators/public.decorator';
4✔
43
import { TqlPipe } from '../record/open-api/tql.pipe';
4✔
44
import { AuthGuard } from './guard/auth.guard';
4✔
45
import { ShareAuthLocalGuard } from './guard/share-auth-local.guard';
4✔
46
import { ShareAuthService } from './share-auth.service';
4✔
47
import type { IShareViewInfo } from './share.service';
4✔
48
import { ShareService } from './share.service';
4✔
49

4✔
50
@Controller('api/share')
4✔
51
@Public()
4✔
52
export class ShareController {
4✔
53
  constructor(
70✔
54
    private readonly shareService: ShareService,
70✔
55
    private readonly shareAuthService: ShareAuthService
70✔
56
  ) {}
70✔
57

70✔
58
  @HttpCode(200)
70✔
59
  @UseGuards(ShareAuthLocalGuard)
×
60
  @Post('/:shareId/view/auth')
×
61
  async auth(@Request() req: any, @Res({ passthrough: true }) res: Response) {
×
62
    const shareId = req.shareId;
×
63
    const password = req.password;
×
64
    const token = await this.shareAuthService.authToken({ shareId, password });
×
65
    res.cookie(shareId, token, {
×
66
      httpOnly: true,
×
67
      maxAge: 1000 * 60 * 60 * 24 * 7,
×
68
    });
×
69
    return { token };
×
70
  }
×
71

70✔
72
  @UseGuards(AuthGuard)
70✔
73
  @Get('/:shareId/view')
2✔
74
  async getShareView(@Param('shareId') shareId: string): Promise<ShareViewGetVo> {
2✔
75
    return await this.shareService.getShareView(shareId);
2✔
76
  }
2✔
77

70✔
78
  @UseGuards(AuthGuard)
70✔
79
  @Get('/:shareId/view/aggregations')
×
80
  async getViewAggregations(
×
81
    @Request() req: any,
×
82
    @Query(new ZodValidationPipe(shareViewAggregationsRoSchema), TqlPipe)
×
83
    query?: IShareViewAggregationsRo
×
84
  ): Promise<IAggregationVo> {
×
85
    const shareInfo = req.shareInfo as IShareViewInfo;
×
86
    return await this.shareService.getViewAggregations(shareInfo, query);
×
87
  }
×
88

70✔
89
  @UseGuards(AuthGuard)
70✔
90
  @Get('/:shareId/view/row-count')
×
91
  async getViewRowCount(
×
92
    @Request() req: any,
×
93
    @Query(new ZodValidationPipe(shareViewRowCountRoSchema), TqlPipe)
×
94
    query?: IShareViewRowCountRo
×
95
  ): Promise<IRowCountVo> {
×
96
    const shareInfo = req.shareInfo as IShareViewInfo;
×
97
    return await this.shareService.getViewRowCount(shareInfo, query);
×
98
  }
×
99

70✔
100
  @UseGuards(AuthGuard)
70✔
101
  @Post('/:shareId/view/form-submit')
2✔
102
  async submitRecord(
2✔
103
    @Request() req: any,
2✔
104
    @Body(new ZodValidationPipe(shareViewFormSubmitRoSchema))
2✔
105
    shareViewFormSubmitRo: ShareViewFormSubmitRo
2✔
106
  ): Promise<IRecord> {
2✔
107
    const shareInfo = req.shareInfo as IShareViewInfo;
2✔
108
    return await this.shareService.formSubmit(shareInfo, shareViewFormSubmitRo);
2✔
109
  }
2✔
110

70✔
111
  @UseGuards(AuthGuard)
70✔
112
  @Get('/:shareId/view/copy')
×
113
  async copy(
×
114
    @Request() req: any,
×
115
    @Query(new ZodValidationPipe(rangesQuerySchema), TqlPipe) shareViewCopyRo: IRangesRo
×
116
  ): Promise<ICopyVo> {
×
117
    const shareInfo = req.shareInfo as IShareViewInfo;
×
118
    return this.shareService.copy(shareInfo, shareViewCopyRo);
×
119
  }
×
120

70✔
121
  @UseGuards(AuthGuard)
70✔
NEW
122
  @Get('/:shareId/view/group-points')
×
NEW
123
  async getViewGroupPoints(
×
NEW
124
    @Request() req: any,
×
NEW
125
    @Query(new ZodValidationPipe(shareViewGroupPointsRoSchema))
×
NEW
126
    query?: IShareViewGroupPointsRo
×
NEW
127
  ): Promise<IGroupPointsVo> {
×
NEW
128
    const shareInfo = req.shareInfo as IShareViewInfo;
×
NEW
129
    return await this.shareService.getViewGroupPoints(shareInfo, query);
×
NEW
130
  }
×
131

70✔
132
  @UseGuards(AuthGuard)
70✔
133
  @Get('/:shareId/view/link-records')
4✔
134
  async viewLinkRecords(
4✔
135
    @Request() req: any,
4✔
136
    @Query(new ZodValidationPipe(shareViewLinkRecordsRoSchema))
4✔
137
    shareViewLinkRecordsRo: IShareViewLinkRecordsRo
4✔
138
  ): Promise<IShareViewLinkRecordsVo> {
4✔
139
    const shareInfo = req.shareInfo as IShareViewInfo;
4✔
140
    return this.shareService.getViewLinkRecords(shareInfo, shareViewLinkRecordsRo);
4✔
141
  }
4✔
142

70✔
143
  @UseGuards(AuthGuard)
70✔
144
  @Get('/:shareId/view/collaborators')
8✔
145
  async getViewCollaborators(
8✔
146
    @Request() req: any,
8✔
147
    @Query(new ZodValidationPipe(shareViewCollaboratorsRoSchema)) query: IShareViewCollaboratorsRo
8✔
148
  ): Promise<IShareViewCollaboratorsVo> {
8✔
149
    const shareInfo = req.shareInfo as IShareViewInfo;
8✔
150
    return this.shareService.getViewCollaborators(shareInfo, query);
8✔
151
  }
8✔
152
}
70✔
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

© 2025 Coveralls, Inc