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

teableio / teable / 8389034572

22 Mar 2024 10:38AM CUT coverage: 26.087% (-2.1%) from 28.208%
8389034572

Pull #487

github

web-flow
Merge 3045b1f94 into a06c6afb1
Pull Request #487: refactor: move zod schema to openapi

2100 of 3363 branches covered (62.44%)

282 of 757 new or added lines in 74 files covered. (37.25%)

224 existing lines in 8 files now uncovered.

25574 of 98035 relevant lines covered (26.09%)

5.17 hits per line

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

0.0
/packages/openapi/src/aggregation/get-group-points.ts
1
import type { RouteConfig } from '@asteasolutions/zod-to-openapi';
×
2
import { axios } from '../axios';
×
NEW
3
import { contentQueryBaseSchema } from '../record';
×
4
import { registerRoute, urlBuilder } from '../utils';
×
5
import { z } from '../zod';
×
6

×
NEW
7
export const groupPointsRoSchema = contentQueryBaseSchema.pick({
×
NEW
8
  viewId: true,
×
NEW
9
  filter: true,
×
NEW
10
  groupBy: true,
×
NEW
11
});
×
NEW
12

×
NEW
13
export type IGroupPointsRo = z.infer<typeof groupPointsRoSchema>;
×
NEW
14

×
NEW
15
export enum GroupPointType {
×
NEW
16
  Header = 0,
×
NEW
17
  Row = 1,
×
NEW
18
}
×
NEW
19

×
NEW
20
const groupHeaderPointSchema = z.object({
×
NEW
21
  id: z.string(),
×
NEW
22
  type: z.literal(GroupPointType.Header),
×
NEW
23
  depth: z.number().max(2).min(0),
×
NEW
24
  value: z.unknown(),
×
NEW
25
});
×
NEW
26

×
NEW
27
const groupRowPointSchema = z.object({
×
NEW
28
  type: z.literal(GroupPointType.Row),
×
NEW
29
  count: z.number(),
×
NEW
30
});
×
NEW
31

×
NEW
32
const groupPointSchema = z.union([groupHeaderPointSchema, groupRowPointSchema]);
×
NEW
33

×
NEW
34
export type IGroupHeaderPoint = z.infer<typeof groupHeaderPointSchema>;
×
NEW
35

×
NEW
36
export type IGroupPoint = z.infer<typeof groupPointSchema>;
×
NEW
37

×
NEW
38
export const groupPointsVoSchema = groupPointSchema.array().nullable();
×
NEW
39

×
NEW
40
export type IGroupPointsVo = z.infer<typeof groupPointsVoSchema>;
×
NEW
41

×
42
export const GET_GROUP_POINTS = '/table/{tableId}/aggregation/group-points';
×
43

×
44
export const GetGroupPointsRoute: RouteConfig = registerRoute({
×
45
  method: 'get',
×
46
  path: GET_GROUP_POINTS,
×
47
  description: 'Get group points for the view',
×
48
  request: {
×
49
    params: z.object({
×
50
      tableId: z.string(),
×
51
    }),
×
52
    query: groupPointsRoSchema,
×
53
  },
×
54
  responses: {
×
55
    200: {
×
56
      description: 'Group points for the view',
×
57
      content: {
×
58
        'application/json': {
×
59
          schema: groupPointsVoSchema,
×
60
        },
×
61
      },
×
62
    },
×
63
  },
×
64
  tags: ['aggregation'],
×
65
});
×
66

×
67
export const getGroupPoints = async (tableId: string, query?: IGroupPointsRo) => {
×
68
  return axios.get<IGroupPointsVo>(urlBuilder(GET_GROUP_POINTS, { tableId }), {
×
69
    params: {
×
70
      ...query,
×
71
      filter: JSON.stringify(query?.filter),
×
72
      groupBy: JSON.stringify(query?.groupBy),
×
73
    },
×
74
  });
×
75
};
×
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