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

teableio / teable / 10265336706

06 Aug 2024 11:06AM UTC coverage: 17.548% (-0.2%) from 17.734%
10265336706

Pull #793

github

web-flow
Merge e359041d4 into 1df1bc808
Pull Request #793: feat: record history

1387 of 2823 branches covered (49.13%)

6 of 1033 new or added lines in 43 files covered. (0.58%)

34 existing lines in 5 files now uncovered.

14088 of 80281 relevant lines covered (17.55%)

1.74 hits per line

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

0.0
/packages/openapi/src/record/get-record-history.ts
NEW
1
import type { RouteConfig } from '@asteasolutions/zod-to-openapi';
×
NEW
2
import { IdPrefix, fieldVoSchema } from '@teable/core';
×
NEW
3
import { axios } from '../axios';
×
NEW
4
import { itemSpaceCollaboratorSchema } from '../space';
×
NEW
5
import { registerRoute, urlBuilder } from '../utils';
×
NEW
6
import { z } from '../zod';
×
NEW
7

×
NEW
8
export const getRecordHistoryQuerySchema = z.object({
×
NEW
9
  recordId: z.string().startsWith(IdPrefix.Record).optional(),
×
NEW
10
  cursor: z.string().nullish(),
×
NEW
11
});
×
NEW
12

×
NEW
13
export const recordHistoryItemStateVoSchema = z.object({
×
NEW
14
  meta: fieldVoSchema.pick({ name: true, type: true, cellValueType: true }).merge(
×
NEW
15
    z.object({
×
NEW
16
      options: z.unknown(),
×
NEW
17
    })
×
NEW
18
  ),
×
NEW
19
  data: z.unknown(),
×
NEW
20
});
×
NEW
21

×
NEW
22
export const recordHistoryItemVoSchema = z.object({
×
NEW
23
  id: z.string(),
×
NEW
24
  recordId: z.string(),
×
NEW
25
  fieldId: z.string(),
×
NEW
26
  before: recordHistoryItemStateVoSchema,
×
NEW
27
  after: recordHistoryItemStateVoSchema,
×
NEW
28
  createdTime: z.string(),
×
NEW
29
  createdBy: z.string(),
×
NEW
30
});
×
NEW
31

×
NEW
32
export type IGetRecordHistoryQuery = z.infer<typeof getRecordHistoryQuerySchema>;
×
NEW
33

×
NEW
34
export type IRecordHistoryItemVo = z.infer<typeof recordHistoryItemVoSchema>;
×
NEW
35

×
NEW
36
export const recordHistoryVoSchema = z.object({
×
NEW
37
  historyList: z.array(recordHistoryItemVoSchema),
×
NEW
38
  userMap: z.record(
×
NEW
39
    z.string().startsWith(IdPrefix.User),
×
NEW
40
    itemSpaceCollaboratorSchema
×
NEW
41
      .pick({
×
NEW
42
        email: true,
×
NEW
43
        avatar: true,
×
NEW
44
      })
×
NEW
45
      .merge(
×
NEW
46
        z.object({
×
NEW
47
          id: z.string(),
×
NEW
48
          name: z.string(),
×
NEW
49
        })
×
NEW
50
      )
×
NEW
51
  ),
×
NEW
52
  nextCursor: z.string().nullish(),
×
NEW
53
});
×
NEW
54

×
NEW
55
export type IRecordHistoryVo = z.infer<typeof recordHistoryVoSchema>;
×
NEW
56

×
NEW
57
export const GET_RECORD_HISTORY_URL = '/table/{tableId}/record/history';
×
NEW
58

×
NEW
59
export const GetRecordHistoryRoute: RouteConfig = registerRoute({
×
NEW
60
  method: 'get',
×
NEW
61
  path: GET_RECORD_HISTORY_URL,
×
NEW
62
  description: 'Get the history list for a record',
×
NEW
63
  request: {
×
NEW
64
    params: z.object({
×
NEW
65
      tableId: z.string(),
×
NEW
66
    }),
×
NEW
67
  },
×
NEW
68
  responses: {
×
NEW
69
    200: {
×
NEW
70
      description: 'Get the history list for a record',
×
NEW
71
      content: {
×
NEW
72
        'application/json': {
×
NEW
73
          schema: recordHistoryVoSchema,
×
NEW
74
        },
×
NEW
75
      },
×
NEW
76
    },
×
NEW
77
  },
×
NEW
78
  tags: ['record'],
×
NEW
79
});
×
NEW
80

×
NEW
81
export const getRecordHistory = async (tableId: string, query: IGetRecordHistoryQuery) => {
×
NEW
82
  return axios.get<IRecordHistoryVo>(
×
NEW
83
    urlBuilder(GET_RECORD_HISTORY_URL, {
×
NEW
84
      tableId,
×
NEW
85
    }),
×
NEW
86
    { params: query }
×
NEW
87
  );
×
NEW
88
};
×
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