-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
presets.ts
38 lines (34 loc) · 904 Bytes
/
presets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type { DirectusPreset } from '../../../schema/preset.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';
/**
* Delete multiple existing presets.
* @param keys
* @returns
* @throws Will throw if keys is empty
*/
export const deletePresets =
<Schema extends object>(keys: DirectusPreset<Schema>['id'][]): RestCommand<void, Schema> =>
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/presets`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**
* Delete an existing preset.
* @param key
* @returns
* @throws Will throw if key is empty
*/
export const deletePreset =
<Schema extends object>(key: DirectusPreset<Schema>['id']): RestCommand<void, Schema> =>
() => {
throwIfEmpty(String(key), 'Key cannot be empty');
return {
path: `/presets/${key}`,
method: 'DELETE',
};
};