-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
dashboards.ts
38 lines (34 loc) · 933 Bytes
/
dashboards.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 { DirectusDashboard } from '../../../schema/dashboard.js';
import { throwIfEmpty } from '../../utils/index.js';
import type { RestCommand } from '../../types.js';
/**
* Delete multiple existing dashboards.
* @param keysOrQuery
* @returns
* @throws Will throw if keys is empty
*/
export const deleteDashboards =
<Schema extends object>(keys: DirectusDashboard<Schema>['id'][]): RestCommand<void, Schema> =>
() => {
throwIfEmpty(keys, 'Keys cannot be empty');
return {
path: `/dashboards`,
body: JSON.stringify(keys),
method: 'DELETE',
};
};
/**
* Delete an existing dashboard.
* @param key
* @returns
* @throws Will throw if key is empty
*/
export const deleteDashboard =
<Schema extends object>(key: DirectusDashboard<Schema>['id']): RestCommand<void, Schema> =>
() => {
throwIfEmpty(key, 'Key cannot be empty');
return {
path: `/dashboards/${key}`,
method: 'DELETE',
};
};