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

teableio / teable / 10297533244

08 Aug 2024 07:06AM UTC coverage: 17.728%. Remained the same
10297533244

push

github

web-flow
fix: restrict the encoding format of attachment names to utf-8 (#802)

1387 of 2813 branches covered (49.31%)

14082 of 79435 relevant lines covered (17.73%)

1.76 hits per line

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

0.0
/apps/nextjs-app/src/backend/api/rest/table.ssr.ts
1
import type { IFieldVo, IGetFieldsQuery, IRecord, IViewVo } from '@teable/core';
×
2
import { FieldKeyType } from '@teable/core';
×
3
import type {
×
4
  AcceptInvitationLinkRo,
×
5
  AcceptInvitationLinkVo,
×
6
  IGetBaseVo,
×
7
  IGetDefaultViewIdVo,
×
8
  IGetSpaceVo,
×
9
  IUpdateNotifyStatusRo,
×
10
  ListSpaceCollaboratorVo,
×
11
  ShareViewGetVo,
×
12
  ITableFullVo,
×
13
  ITableListVo,
×
14
  ISettingVo,
×
15
  IUserMeVo,
×
16
  IRecordsVo,
×
17
  ITableVo,
×
18
} from '@teable/openapi';
×
19
import {
×
20
  ACCEPT_INVITATION_LINK,
×
21
  GET_BASE,
×
22
  GET_BASE_ALL,
×
23
  GET_DEFAULT_VIEW_ID,
×
24
  GET_FIELD_LIST,
×
25
  GET_RECORDS_URL,
×
26
  GET_RECORD_URL,
×
27
  GET_SETTING,
×
28
  GET_SPACE,
×
29
  GET_SPACE_LIST,
×
30
  GET_TABLE,
×
31
  GET_TABLE_LIST,
×
32
  GET_VIEW_LIST,
×
33
  SHARE_VIEW_GET,
×
34
  SPACE_COLLABORATE_LIST,
×
35
  UPDATE_NOTIFICATION_STATUS,
×
36
  USER_ME,
×
37
  urlBuilder,
×
38
} from '@teable/openapi';
×
39
import type { AxiosInstance } from 'axios';
×
40
import { getAxios } from './axios';
×
41

×
42
export class SsrApi {
×
43
  axios: AxiosInstance;
×
44

×
45
  // eslint-disable-next-line @typescript-eslint/no-empty-function
×
46
  constructor() {
×
47
    this.axios = getAxios();
×
48
  }
×
49

×
50
  async getTable(baseId: string, tableId: string, viewId?: string): Promise<ITableFullVo> {
×
51
    const { records } = await this.axios
×
52
      .get<IRecordsVo>(urlBuilder(GET_RECORDS_URL, { baseId, tableId }), {
×
53
        params: {
×
54
          viewId,
×
55
          fieldKeyType: FieldKeyType.Id,
×
56
        },
×
57
      })
×
58
      .then(({ data }) => data);
×
59

×
60
    const fields = await this.getFields(tableId, { viewId });
×
61
    const views = await this.axios
×
62
      .get<IViewVo[]>(urlBuilder(GET_VIEW_LIST, { tableId }))
×
63
      .then(({ data }) => data);
×
64
    const table = await this.axios
×
65
      .get<ITableVo>(urlBuilder(GET_TABLE, { baseId, tableId }), {
×
66
        params: {
×
67
          includeContent: true,
×
68
          viewId,
×
69
          fieldKeyType: FieldKeyType.Id,
×
70
        },
×
71
      })
×
72
      .then(({ data }) => data);
×
73
    return {
×
74
      ...table,
×
75
      records,
×
76
      views,
×
77
      fields,
×
78
    };
×
79
  }
×
80

×
81
  async getFields(tableId: string, query?: IGetFieldsQuery) {
×
82
    return this.axios
×
83
      .get<IFieldVo[]>(urlBuilder(GET_FIELD_LIST, { tableId }), { params: query })
×
84
      .then(({ data }) => data);
×
85
  }
×
86

×
87
  async getTables(baseId: string) {
×
88
    return this.axios
×
89
      .get<ITableListVo>(urlBuilder(GET_TABLE_LIST, { baseId }))
×
90
      .then(({ data }) => data);
×
91
  }
×
92

×
93
  async getDefaultViewId(baseId: string, tableId: string) {
×
94
    return this.axios
×
95
      .get<IGetDefaultViewIdVo>(urlBuilder(GET_DEFAULT_VIEW_ID, { baseId, tableId }))
×
96
      .then(({ data }) => data);
×
97
  }
×
98

×
99
  async getRecord(tableId: string, recordId: string) {
×
100
    return this.axios
×
101
      .get<IRecord>(urlBuilder(GET_RECORD_URL, { tableId, recordId }), {
×
102
        params: { fieldKeyType: FieldKeyType.Id },
×
103
      })
×
104
      .then(({ data }) => data);
×
105
  }
×
106

×
107
  async getBaseById(baseId: string) {
×
108
    return await this.axios
×
109
      .get<IGetBaseVo>(urlBuilder(GET_BASE, { baseId }))
×
110
      .then(({ data }) => data);
×
111
  }
×
112

×
113
  async getSpaceById(spaceId: string) {
×
114
    return await this.axios
×
115
      .get<IGetSpaceVo>(urlBuilder(GET_SPACE, { spaceId }))
×
116
      .then(({ data }) => data);
×
117
  }
×
118

×
119
  async getSpaceList() {
×
120
    return await this.axios.get<IGetSpaceVo[]>(urlBuilder(GET_SPACE_LIST)).then(({ data }) => data);
×
121
  }
×
122

×
123
  async getBaseList() {
×
124
    return await this.axios.get<IGetBaseVo[]>(GET_BASE_ALL).then(({ data }) => data);
×
125
  }
×
126

×
127
  async getSpaceCollaboratorList(spaceId: string) {
×
128
    return await this.axios
×
129
      .get<ListSpaceCollaboratorVo>(urlBuilder(SPACE_COLLABORATE_LIST, { spaceId }))
×
130
      .then(({ data }) => data);
×
131
  }
×
132

×
133
  async acceptInvitationLink(acceptInvitationLinkRo: AcceptInvitationLinkRo) {
×
134
    return this.axios
×
135
      .post<AcceptInvitationLinkVo>(ACCEPT_INVITATION_LINK, acceptInvitationLinkRo)
×
136
      .then(({ data }) => data);
×
137
  }
×
138

×
139
  async getShareView(shareId: string) {
×
140
    return this.axios
×
141
      .get<ShareViewGetVo>(urlBuilder(SHARE_VIEW_GET, { shareId }))
×
142
      .then(({ data }) => data);
×
143
  }
×
144

×
145
  async updateNotificationStatus(notificationId: string, data: IUpdateNotifyStatusRo) {
×
146
    return this.axios
×
147
      .patch<void>(urlBuilder(UPDATE_NOTIFICATION_STATUS, { notificationId }), data)
×
148
      .then(({ data }) => data);
×
149
  }
×
150

×
151
  async getSetting() {
×
152
    return this.axios.get<ISettingVo>(GET_SETTING).then(({ data }) => data);
×
153
  }
×
154

×
155
  async getUserMe() {
×
156
    return this.axios.get<IUserMeVo>(USER_ME).then(({ data }) => data);
×
157
  }
×
158
}
×
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