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

teableio / teable / 8478979078

29 Mar 2024 08:32AM UTC coverage: 82.643% (+61.0%) from 21.636%
8478979078

push

github

web-flow
feat: search api (#507)

* feat: search api

* test: add advanced test case

* feat: search responsive ui

* feat: realtime search

3942 of 4135 branches covered (95.33%)

454 of 493 new or added lines in 29 files covered. (92.09%)

26536 of 32109 relevant lines covered (82.64%)

1222.65 hits per line

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

61.67
/apps/nestjs-backend/src/features/field/model/field-dto/attachment-field.dto.ts
1
import type { IAttachmentCellValue, IAttachmentItem } from '@teable/core';
4✔
2
import { AttachmentFieldCore, generateAttachmentId } from '@teable/core';
4✔
3
import { omit } from 'lodash';
4✔
4
import type { FieldBase } from '../field-base';
4✔
5

4✔
6
export class AttachmentFieldDto extends AttachmentFieldCore implements FieldBase {
4✔
7
  get isStructuredCellValue() {
4✔
NEW
8
    return false;
×
NEW
9
  }
×
10

4✔
11
  static getTokenAndNameByString(value: string): { token: string; name: string } | undefined {
4✔
12
    const openParenIndex = value.lastIndexOf('(');
6✔
13

6✔
14
    if (openParenIndex === -1) {
6!
15
      return;
×
16
    }
×
17
    const name = value.slice(0, openParenIndex).trim();
6✔
18
    const token = value.slice(openParenIndex + 1, -1).trim();
6✔
19
    return { name, token };
6✔
20
  }
6✔
21

4✔
22
  convertCellValue2DBValue(value: unknown): unknown {
4✔
23
    return (
12✔
24
      value &&
12✔
25
      JSON.stringify((value as IAttachmentCellValue).map((item) => omit(item, ['presignedUrl'])))
4✔
26
    );
12✔
27
  }
12✔
28

4✔
29
  convertDBValue2CellValue(value: unknown): unknown {
4✔
30
    return value == null || typeof value === 'object' ? value : JSON.parse(value as string);
784✔
31
  }
784✔
32

4✔
33
  override convertStringToCellValue(
4✔
34
    value: string,
8✔
35
    attachments?: Omit<IAttachmentItem, 'id' | 'name'>[]
8✔
36
  ) {
8✔
37
    // value is ddd.svg (token)
8✔
38
    if (!attachments?.length || !value) {
8!
39
      return null;
8✔
40
    }
8!
41
    const tokensAndNames = value.split(',').map(AttachmentFieldDto.getTokenAndNameByString);
×
42
    return tokensAndNames
×
43
      .map((tokenAndName) => {
×
44
        const { token, name } = tokenAndName || {};
×
45
        if (!token) {
×
46
          return;
×
47
        }
×
48
        const attachment = attachments.find((attachment) => attachment.token === token);
×
49
        if (!attachment) {
×
50
          return;
×
51
        }
×
52
        return {
×
53
          ...attachment,
×
54
          name,
×
55
          id: generateAttachmentId(),
×
56
        };
×
57
      })
×
58
      .filter(Boolean) as IAttachmentItem[];
×
59
  }
×
60
}
4✔
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