mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-20 09:04:08 +00:00
3e661db38c
Summary: Adding validation for api /records endpoint, that checks if the json payload is valid. Modifying POST /records endpoint to allow creating blank or partial records. Test Plan: Updated tests Reviewers: alexmojaki Reviewed By: alexmojaki Differential Revision: https://phab.getgrist.com/D3061
31 lines
803 B
TypeScript
31 lines
803 B
TypeScript
import { CellValue } from "app/plugin/GristData";
|
|
|
|
/**
|
|
* JSON schema for api /record endpoint. Used in POST method for adding new records.
|
|
*/
|
|
export interface NewRecord {
|
|
fields?: { [coldId: string]: CellValue }; // fields is optional, user can create blank records
|
|
}
|
|
|
|
/**
|
|
* JSON schema for api /record endpoint. Used in PATCH method for updating existing records.
|
|
*/
|
|
export interface Record {
|
|
id: number;
|
|
fields: { [coldId: string]: CellValue };
|
|
}
|
|
|
|
/**
|
|
* JSON schema for the body of api /record PATCH endpoint
|
|
*/
|
|
export interface RecordsPatch {
|
|
records: [Record, ...Record[]]; // at least one record is required
|
|
}
|
|
|
|
/**
|
|
* JSON schema for the body of api /record POST endpoint
|
|
*/
|
|
export interface RecordsPost {
|
|
records: [NewRecord, ...NewRecord[]]; // at least one record is required
|
|
}
|