mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) add endpoints for clearing snapshots and actions
Summary: This adds a snapshots/remove and states/remove endpoint, primarily for maintenance work rather than for the end user. If some secret gets into document history, it is useful to be able to purge it in an orderly way. Test Plan: added tests Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2694
This commit is contained in:
@@ -213,9 +213,10 @@ export function optStringParam(p: any): string|undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function stringParam(p: any): string {
|
||||
if (typeof p === 'string') { return p; }
|
||||
throw new Error(`parameter should be a string: ${p}`);
|
||||
export function stringParam(p: any, allowed?: string[]): string {
|
||||
if (typeof p !== 'string') { throw new Error(`parameter should be a string: ${p}`); }
|
||||
if (allowed && !allowed.includes(p)) { throw new Error(`parameter ${p} should be one of ${allowed}`); }
|
||||
return p;
|
||||
}
|
||||
|
||||
export function integerParam(p: any): number {
|
||||
@@ -224,6 +225,13 @@ export function integerParam(p: any): number {
|
||||
throw new Error(`parameter should be an integer: ${p}`);
|
||||
}
|
||||
|
||||
export function optIntegerParam(p: any): number|undefined {
|
||||
if (typeof p === 'number') { return Math.floor(p); }
|
||||
if (typeof p === 'string') { return parseInt(p, 10); }
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
export interface RequestWithGristInfo extends Request {
|
||||
gristInfo?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user