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

teableio / teable / 8389227144

22 Mar 2024 10:56AM UTC coverage: 26.087% (-53.9%) from 79.937%
8389227144

push

github

web-flow
refactor: move zod schema to openapi (#487)

2100 of 3363 branches covered (62.44%)

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

14879 existing lines in 182 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/record/update.ts
1
import type { RouteConfig } from '@asteasolutions/zod-to-openapi';
×
NEW
2
import type { IRecord } from '@teable/core';
×
NEW
3
import { recordSchema } from '@teable/core';
×
4
import { axios } from '../axios';
×
5
import { registerRoute, urlBuilder } from '../utils';
×
6
import { z } from '../zod';
×
NEW
7
import { fieldKeyTypeRoSchema, typecastSchema } from './get';
×
NEW
8

×
NEW
9
export const updateRecordRoSchema = z
×
NEW
10
  .object({
×
NEW
11
    fieldKeyType: fieldKeyTypeRoSchema,
×
NEW
12
    typecast: typecastSchema,
×
NEW
13
    record: z.object({
×
NEW
14
      fields: recordSchema.shape.fields,
×
NEW
15
    }),
×
NEW
16
  })
×
NEW
17
  .openapi({
×
NEW
18
    description: 'Update record by id',
×
NEW
19
  });
×
NEW
20

×
NEW
21
export type IUpdateRecordRo = z.infer<typeof updateRecordRoSchema>;
×
NEW
22

×
NEW
23
export const updateRecordsRoSchema = z
×
NEW
24
  .object({
×
NEW
25
    fieldKeyType: fieldKeyTypeRoSchema,
×
NEW
26
    typecast: typecastSchema,
×
NEW
27
    records: z.array(
×
NEW
28
      z.object({
×
NEW
29
        id: z.string(),
×
NEW
30
        fields: recordSchema.shape.fields,
×
NEW
31
      })
×
NEW
32
    ),
×
NEW
33
  })
×
NEW
34
  .openapi({
×
NEW
35
    description: 'Multiple Update records',
×
NEW
36
  });
×
NEW
37

×
NEW
38
export type IUpdateRecordsRo = z.infer<typeof updateRecordsRoSchema>;
×
39

×
40
export const UPDATE_RECORD = '/table/{tableId}/record/{recordId}';
×
41

×
42
export const UpdateRecordRoute: RouteConfig = registerRoute({
×
43
  method: 'patch',
×
44
  path: UPDATE_RECORD,
×
45
  description: 'Update a record',
×
46
  request: {
×
47
    params: z.object({
×
48
      tableId: z.string(),
×
49
      recordId: z.string(),
×
50
    }),
×
51
    body: {
×
52
      content: {
×
53
        'application/json': {
×
54
          schema: updateRecordRoSchema,
×
55
        },
×
56
      },
×
57
    },
×
58
  },
×
59
  responses: {
×
60
    200: {
×
61
      description: 'Returns record data after update.',
×
62
      content: {
×
63
        'application/json': {
×
64
          schema: recordSchema,
×
65
        },
×
66
      },
×
67
    },
×
68
  },
×
69
  tags: ['record'],
×
70
});
×
71

×
72
export const updateRecord = async (
×
73
  tableId: string,
×
74
  recordId: string,
×
75
  recordRo: IUpdateRecordRo
×
76
) => {
×
77
  return axios.patch<IRecord>(
×
78
    urlBuilder(UPDATE_RECORD, {
×
79
      tableId,
×
80
      recordId,
×
81
    }),
×
82
    recordRo
×
83
  );
×
84
};
×
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