-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
versions.ts
49 lines (46 loc) · 1.53 KB
/
versions.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
39
40
41
42
43
44
45
46
47
48
49
import type { DirectusVersion } from '../../../schema/version.js';
import type { ApplyQueryFields, Query } from '../../../types/index.js';
import type { RestCommand } from '../../types.js';
export type CreateContentVersionOutput<
Schema extends object,
TQuery extends Query<Schema, Item>,
Item extends object = DirectusVersion<Schema>,
> = ApplyQueryFields<Schema, Item, TQuery['fields']>;
/**
* Create multiple new Content Versions.
*
* @param items The Content Versions to create
* @param query Optional return data query
*
* @returns Returns the Content Version object for the created Content Versions.
*/
export const createContentVersions =
<Schema extends object, const TQuery extends Query<Schema, DirectusVersion<Schema>>>(
items: Partial<DirectusVersion<Schema>>[],
query?: TQuery,
): RestCommand<CreateContentVersionOutput<Schema, TQuery>[], Schema> =>
() => ({
path: `/versions`,
params: query ?? {},
body: JSON.stringify(items),
method: 'POST',
});
/**
* Create a new Content Version.
*
* @param item The Content Version to create
* @param query Optional return data query
*
* @returns Returns the Content Version object for the created Content Version.
*/
export const createContentVersion =
<Schema extends object, const TQuery extends Query<Schema, DirectusVersion<Schema>>>(
item: Partial<DirectusVersion<Schema>>,
query?: TQuery,
): RestCommand<CreateContentVersionOutput<Schema, TQuery>, Schema> =>
() => ({
path: `/versions`,
params: query ?? {},
body: JSON.stringify(item),
method: 'POST',
});