UNPKG

3.78 kBTypeScriptView Raw
1import type { RawAxiosRequestHeaders } from 'axios';
2import type { GetTaskParams, GetEntryParams, QueryParams, CollectionProp } from '../../common-types';
3import type { CreateTaskParams, UpdateTaskParams, DeleteTaskParams, TaskProps, CreateTaskProps, UpdateTaskProps } from '../../entities/task';
4import type { OptionalDefaults } from '../wrappers/wrap';
5export type TaskPlainClientAPI = {
6 /** Fetches a task
7 *
8 * @param params Space ID, Entry ID, Environment ID, and Task ID
9 * @returns the task
10 * @throws if the request fails or the task is not found
11 * @example
12 * ```javascript
13 * const task = await client.task.get({
14 * spaceId: '<space_id>',
15 * entryId: '<entry_id>',
16 * environmentId: '<environment_id>',
17 * taskId: '<task_id>',
18 * });
19 * ```
20 */
21 get(params: OptionalDefaults<GetTaskParams>): Promise<TaskProps>;
22 /** Fetches all tasks for a given entry
23 *
24 * @param params Space ID, Entry ID, Environment ID, and query parameters
25 * @returns a collection of tasks
26 * @throws if the request fails or the tasks are not found
27 * @example
28 * ```javascript
29 * const tasks = await client.task.getMany({
30 * spaceId: '<space_id>',
31 * entryId: '<entry_id>',
32 * environmentId: '<environment_id>',
33 * query: {
34 * limit: 100,
35 * }
36 * });
37 * ```
38 */
39 getMany(params: OptionalDefaults<GetEntryParams & QueryParams>): Promise<CollectionProp<TaskProps>>;
40 /** Creates a task
41 *
42 * @param params Space ID, Entry ID, Environment ID
43 * @param rawData the task to create
44 * @returns the created task
45 * @throws if the request fails or or the payload is malformed
46 * @example
47 * ```javascript
48 * const task = await client.task.create(
49 * {
50 * spaceId: '<space_id>',
51 * entryId: '<entry_id>',
52 * environmentId: '<environment_id>',
53 * },
54 * {
55 * body: "Review Translation",
56 * status: "active",
57 * assignedTo: {
58 * sys: {
59 * type: "Link",
60 * linkType: "User",
61 * id: <user_id>
62 * }
63 * }
64 * }
65 * );
66 * ```
67 */
68 create(params: OptionalDefaults<CreateTaskParams>, rawData: CreateTaskProps, headers?: RawAxiosRequestHeaders): Promise<TaskProps>;
69 /** Updates a task
70 *
71 * @param params Space ID, Entry ID, Environment ID, and Task ID
72 * @param rawData the task update
73 * @returns the updated task
74 * @throws if the request fails, the task is not found, or the payload is malformed
75 * @example
76 * ```javascript
77 * const task = await client.task.update(
78 * {
79 * spaceId: '<space_id>',
80 * entryId: '<entry_id>',
81 * environmentId: '<environment_id>',
82 * taskId: '<task_id>',
83 * },
84 * {
85 * body: "Review Translation",
86 * status: "active",
87 * assignedTo: {
88 * sys: {
89 * type: "Link",
90 * linkType: "User",
91 * id: <user_id>
92 * }
93 * }
94 * }
95 * );
96 * ```
97 */
98 update(params: OptionalDefaults<UpdateTaskParams>, rawData: UpdateTaskProps, headers?: RawAxiosRequestHeaders): Promise<TaskProps>;
99 /** Deletes a task
100 *
101 * @param params Space ID, Entry ID, Environment ID, and Task ID
102 * @throws if the request fails or the task is not found
103 * @example
104 * ```javascript
105 * await client.task.delete({
106 * spaceId: '<space_id>',
107 * entryId: '<entry_id>',
108 * environmentId: '<environment_id>',
109 * taskId: '<task_id>',
110 * });
111 * ```
112 */
113 delete(params: OptionalDefaults<DeleteTaskParams>): Promise<void>;
114};