@doist/todoist-sdk 15.0.2 → 15.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/types/sync/resources/filters.js +1 -0
- package/dist/esm/types/sync/resources/workspace-filters.js +1 -0
- package/dist/esm/utils/filter-queries.js +231 -0
- package/dist/esm/utils/filter-query-definitions.js +2789 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/task-sorting.js +2 -0
- package/dist/types/types/sync/commands/filters.d.ts +2 -0
- package/dist/types/types/sync/commands/workspace-filters.d.ts +2 -0
- package/dist/types/types/sync/resources/filters.d.ts +1 -0
- package/dist/types/types/sync/resources/workspace-filters.d.ts +1 -0
- package/dist/types/types/sync/response.d.ts +2 -0
- package/dist/types/types/webhooks/filters.d.ts +3 -0
- package/dist/types/types/webhooks/types.d.ts +3 -0
- package/dist/types/utils/filter-queries.d.ts +42 -0
- package/dist/types/utils/filter-query-definitions.d.ts +27 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/task-sorting.d.ts +6 -1
- package/dist/types/utils/validators.d.ts +4 -0
- package/package.json +1 -1
package/dist/esm/utils/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export * from './sanitization.js';
|
|
|
3
3
|
export { getTaskUrl, getProjectUrl, getSectionUrl, getLabelUrl, getFilterUrl, getWorkspaceFilterUrl, getWorkspaceUrl, getTaskCommentsUrl, getProjectCommentsUrl, getTaskCommentUrl, getProjectCommentUrl, parseTodoistUrl, TODOIST_LINK_TYPES, } from './url-helpers.js';
|
|
4
4
|
export { createCommand } from './sync-helpers.js';
|
|
5
5
|
export * from './project-helpers.js';
|
|
6
|
+
export { isDateDrivenQuery } from './filter-queries.js';
|
|
7
|
+
export { FILTER_QUERY_LANGUAGES } from './filter-query-definitions.js';
|
|
6
8
|
export * from './task-sorting.js';
|
|
7
9
|
export * from './view-options.js';
|
|
8
10
|
export { parseWebhookPayload, verifyWebhookSignature } from './webhook-parser.js';
|
|
@@ -249,6 +249,8 @@ function defaultSortOrder(sortedBy) {
|
|
|
249
249
|
*
|
|
250
250
|
* This function sorts only the tasks supplied to it. Fetch every page first
|
|
251
251
|
* when globally correct ordering is required for a paginated query.
|
|
252
|
+
*
|
|
253
|
+
* @see isDateDrivenQuery
|
|
252
254
|
*/
|
|
253
255
|
export function sortTasks(tasks, options, context = {}) {
|
|
254
256
|
var _a, _b, _c;
|
|
@@ -2,6 +2,7 @@ import type { ColorKey } from '../../../utils/colors.js';
|
|
|
2
2
|
export type FilterAddArgs = {
|
|
3
3
|
name: string;
|
|
4
4
|
query: string;
|
|
5
|
+
description?: string | null;
|
|
5
6
|
color?: ColorKey;
|
|
6
7
|
itemOrder?: number;
|
|
7
8
|
isFavorite?: boolean;
|
|
@@ -10,6 +11,7 @@ export type FilterUpdateArgs = {
|
|
|
10
11
|
id: string;
|
|
11
12
|
name?: string;
|
|
12
13
|
query?: string;
|
|
14
|
+
description?: string | null;
|
|
13
15
|
color?: ColorKey;
|
|
14
16
|
itemOrder?: number;
|
|
15
17
|
isFavorite?: boolean;
|
|
@@ -3,6 +3,7 @@ export type WorkspaceFilterAddArgs = {
|
|
|
3
3
|
workspaceId: string;
|
|
4
4
|
name: string;
|
|
5
5
|
query: string;
|
|
6
|
+
description?: string | null;
|
|
6
7
|
color?: ColorKey;
|
|
7
8
|
itemOrder?: number;
|
|
8
9
|
isFavorite?: boolean;
|
|
@@ -11,6 +12,7 @@ export type WorkspaceFilterUpdateArgs = {
|
|
|
11
12
|
id: string;
|
|
12
13
|
name?: string;
|
|
13
14
|
query?: string;
|
|
15
|
+
description?: string | null;
|
|
14
16
|
color?: ColorKey;
|
|
15
17
|
itemOrder?: number;
|
|
16
18
|
isFavorite?: boolean;
|
|
@@ -295,6 +295,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
295
295
|
id: z.ZodString;
|
|
296
296
|
name: z.ZodString;
|
|
297
297
|
query: z.ZodString;
|
|
298
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
298
299
|
color: z.ZodString;
|
|
299
300
|
isDeleted: z.ZodBoolean;
|
|
300
301
|
isFavorite: z.ZodBoolean;
|
|
@@ -726,6 +727,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
726
727
|
workspaceId: z.ZodString;
|
|
727
728
|
name: z.ZodString;
|
|
728
729
|
query: z.ZodString;
|
|
730
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
729
731
|
color: z.ZodString;
|
|
730
732
|
itemOrder: z.ZodNumber;
|
|
731
733
|
isDeleted: z.ZodBoolean;
|
|
@@ -22,6 +22,7 @@ export declare const FilterAddedPayloadSchema: z.ZodObject<{
|
|
|
22
22
|
id: z.ZodString;
|
|
23
23
|
name: z.ZodString;
|
|
24
24
|
query: z.ZodString;
|
|
25
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
26
|
color: z.ZodString;
|
|
26
27
|
isDeleted: z.ZodBoolean;
|
|
27
28
|
isFavorite: z.ZodBoolean;
|
|
@@ -48,6 +49,7 @@ export declare const FilterUpdatedPayloadSchema: z.ZodObject<{
|
|
|
48
49
|
id: z.ZodString;
|
|
49
50
|
name: z.ZodString;
|
|
50
51
|
query: z.ZodString;
|
|
52
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
53
|
color: z.ZodString;
|
|
52
54
|
isDeleted: z.ZodBoolean;
|
|
53
55
|
isFavorite: z.ZodBoolean;
|
|
@@ -74,6 +76,7 @@ export declare const FilterDeletedPayloadSchema: z.ZodObject<{
|
|
|
74
76
|
id: z.ZodString;
|
|
75
77
|
name: z.ZodString;
|
|
76
78
|
query: z.ZodString;
|
|
79
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
77
80
|
color: z.ZodString;
|
|
78
81
|
isDeleted: z.ZodBoolean;
|
|
79
82
|
isFavorite: z.ZodBoolean;
|
|
@@ -2456,6 +2456,7 @@ export declare const WebhookPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
2456
2456
|
id: z.ZodString;
|
|
2457
2457
|
name: z.ZodString;
|
|
2458
2458
|
query: z.ZodString;
|
|
2459
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2459
2460
|
color: z.ZodString;
|
|
2460
2461
|
isDeleted: z.ZodBoolean;
|
|
2461
2462
|
isFavorite: z.ZodBoolean;
|
|
@@ -2480,6 +2481,7 @@ export declare const WebhookPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
2480
2481
|
id: z.ZodString;
|
|
2481
2482
|
name: z.ZodString;
|
|
2482
2483
|
query: z.ZodString;
|
|
2484
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2483
2485
|
color: z.ZodString;
|
|
2484
2486
|
isDeleted: z.ZodBoolean;
|
|
2485
2487
|
isFavorite: z.ZodBoolean;
|
|
@@ -2504,6 +2506,7 @@ export declare const WebhookPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
2504
2506
|
id: z.ZodString;
|
|
2505
2507
|
name: z.ZodString;
|
|
2506
2508
|
query: z.ZodString;
|
|
2509
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2507
2510
|
color: z.ZodString;
|
|
2508
2511
|
isDeleted: z.ZodBoolean;
|
|
2509
2512
|
isFavorite: z.ZodBoolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type IsDateDrivenQueryOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Language the query is written in, as the account's `lang`. Unknown codes
|
|
4
|
+
* and regional variants fall back to their base language, then to English.
|
|
5
|
+
*/
|
|
6
|
+
lang?: string | null;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns whether a filter query leads with dates rather than with priority.
|
|
10
|
+
*
|
|
11
|
+
* Todoist gives every filter one of two default hierarchies, and a query that
|
|
12
|
+
* mentions dates gets the date-first one. Pass the answer to {@link sortTasks}
|
|
13
|
+
* as its `defaultOrder`:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* sortTasks(tasks, {
|
|
17
|
+
* sortedBy: savedOptions?.sortedBy,
|
|
18
|
+
* sortOrder: savedOptions?.sortOrder,
|
|
19
|
+
* defaultOrder: isDateDrivenQuery(query, { lang }) ? 'DATE_FIRST' : 'PRIORITY_FIRST',
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* The query is read in `lang`, the account language `getUser` returns, the way
|
|
24
|
+
* the API reads it. English keywords parse under every language, so `lang` only
|
|
25
|
+
* matters for a query written in the account's own: `sin fecha` is a keyword
|
|
26
|
+
* under `es` and an unreadable phrase under `en`.
|
|
27
|
+
*
|
|
28
|
+
* Commas divide a filter into subqueries and Todoist draws each one as its own
|
|
29
|
+
* list, with its own hierarchy. Classify them one at a time for exact results;
|
|
30
|
+
* a whole query answers true only when every subquery is date-driven.
|
|
31
|
+
*
|
|
32
|
+
* Two kinds of unreadable query part company here. One that breaks the grammar,
|
|
33
|
+
* such as `(today`, returns false. One that only breaks the vocabulary, such as
|
|
34
|
+
* `sin fecha` under `en`, returns true, because a word this package doesn't
|
|
35
|
+
* recognize is treated as a bare date. Pass the account's own `lang` and the
|
|
36
|
+
* question doesn't arise; get it wrong and a keyword can read as a date.
|
|
37
|
+
*
|
|
38
|
+
* The function performs no I/O.
|
|
39
|
+
*
|
|
40
|
+
* @see sortTasks
|
|
41
|
+
*/
|
|
42
|
+
export declare function isDateDrivenQuery(query: string, options?: IsDateDrivenQueryOptions): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Languages the Todoist filter parser reads queries in.
|
|
3
|
+
*
|
|
4
|
+
* English keywords parse under every one of them, so only a query written in
|
|
5
|
+
* the account's own language needs the matching code.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FILTER_QUERY_LANGUAGES: readonly ["cs", "da", "de", "en", "es", "fi", "fr", "it", "ja", "ko", "nb", "nl", "pl", "pt", "ru", "sv", "tr", "zh_cn", "zh_tw"];
|
|
8
|
+
/** A language the Todoist filter parser reads queries in. */
|
|
9
|
+
export type FilterQueryLanguage = (typeof FILTER_QUERY_LANGUAGES)[number];
|
|
10
|
+
/** Token kinds the Todoist filter lexer recognizes, in the order it tries them. */
|
|
11
|
+
export declare const FILTER_QUERY_TOKENS: readonly ["LEFT", "RIGHT", "NOT", "AND", "OR", "PRIORITY", "NO_PRIORITY", "PROJECT", "SECTION", "PROJECT_SINGLE", "LABEL", "NO_LABELS", "DUE", "DUE_BEFORE", "DUE_AFTER", "DEADLINE", "DEADLINE_BEFORE", "DEADLINE_AFTER", "DATE", "DATE_BEFORE", "DATE_AFTER", "DUE_RECURRING", "OVERDUE", "WITHIN_DAYS", "NO_DUE_DATE", "NO_DEADLINE", "NO_DATE", "NO_TIME", "CREATED", "CREATED_BEFORE", "CREATED_AFTER", "ADDED_BY", "SHARED", "ASSIGNED", "TO_ME", "TO_OTHERS", "ASSIGNED_TO", "ASSIGNED_BY", "SUBTASK", "VIEW_ALL", "ALL", "SEARCH", "WORKSPACE_SINGLE", "UNCOMPLETABLE"];
|
|
12
|
+
/** A token kind the Todoist filter lexer recognizes. */
|
|
13
|
+
export type FilterQueryToken = (typeof FILTER_QUERY_TOKENS)[number];
|
|
14
|
+
/**
|
|
15
|
+
* Tokens that make a subquery date-driven, from FilteristKt's `Grouper`.
|
|
16
|
+
*
|
|
17
|
+
* `recurring`, `no date` and `created:` are absent there too. Each says
|
|
18
|
+
* something about dates without giving the list one to lead with.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FILTER_QUERY_DATE_TOKENS: readonly ["DUE", "DUE_BEFORE", "DUE_AFTER", "DEADLINE", "DEADLINE_BEFORE", "DEADLINE_AFTER", "DATE", "DATE_BEFORE", "DATE_AFTER", "OVERDUE", "WITHIN_DAYS"];
|
|
21
|
+
/** Tokens that join or negate operands rather than standing as one. */
|
|
22
|
+
export declare const FILTER_QUERY_OPERATOR_TOKENS: readonly ["LEFT", "RIGHT", "NOT", "AND", "OR"];
|
|
23
|
+
/**
|
|
24
|
+
* Localized patterns per token, each one the body of `^\s*<pattern>\s*` and
|
|
25
|
+
* matched case-insensitively at the cursor.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FILTER_QUERY_PATTERNS: Record<FilterQueryLanguage, Record<FilterQueryToken, readonly string[]>>;
|
|
@@ -4,6 +4,10 @@ export { getTaskUrl, getProjectUrl, getSectionUrl, getLabelUrl, getFilterUrl, ge
|
|
|
4
4
|
export type { TodoistLinkType, TodoistUrlInfo } from './url-helpers.js';
|
|
5
5
|
export { createCommand } from './sync-helpers.js';
|
|
6
6
|
export * from './project-helpers.js';
|
|
7
|
+
export { isDateDrivenQuery } from './filter-queries.js';
|
|
8
|
+
export type { IsDateDrivenQueryOptions } from './filter-queries.js';
|
|
9
|
+
export { FILTER_QUERY_LANGUAGES } from './filter-query-definitions.js';
|
|
10
|
+
export type { FilterQueryLanguage } from './filter-query-definitions.js';
|
|
7
11
|
export * from './task-sorting.js';
|
|
8
12
|
export * from './view-options.js';
|
|
9
13
|
export { parseWebhookPayload, verifyWebhookSignature } from './webhook-parser.js';
|
|
@@ -9,7 +9,10 @@ export type TaskSortOptions = {
|
|
|
9
9
|
sortedBy?: SortedBy | null;
|
|
10
10
|
/** Saved or requested direction. Defaults by field when absent. */
|
|
11
11
|
sortOrder?: SortOrder | null;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Default hierarchy for this view or filter query. Today and Upcoming are
|
|
14
|
+
* date-first; for a filter, {@link isDateDrivenQuery} reads it off the query.
|
|
15
|
+
*/
|
|
13
16
|
defaultOrder: DefaultTaskOrder;
|
|
14
17
|
};
|
|
15
18
|
export type TaskSortContext = {
|
|
@@ -34,5 +37,7 @@ export type TaskSortContext = {
|
|
|
34
37
|
*
|
|
35
38
|
* This function sorts only the tasks supplied to it. Fetch every page first
|
|
36
39
|
* when globally correct ordering is required for a paginated query.
|
|
40
|
+
*
|
|
41
|
+
* @see isDateDrivenQuery
|
|
37
42
|
*/
|
|
38
43
|
export declare function sortTasks(tasks: readonly Task[], options: TaskSortOptions, context?: TaskSortContext): Task[];
|
|
@@ -752,6 +752,7 @@ export declare const validateFilter: (input: unknown) => {
|
|
|
752
752
|
isFavorite: boolean;
|
|
753
753
|
isFrozen: boolean;
|
|
754
754
|
itemOrder: number;
|
|
755
|
+
description?: string | null | undefined;
|
|
755
756
|
}, validateFilterArray: (input: unknown) => {
|
|
756
757
|
[x: string]: unknown;
|
|
757
758
|
id: string;
|
|
@@ -762,6 +763,7 @@ export declare const validateFilter: (input: unknown) => {
|
|
|
762
763
|
isFavorite: boolean;
|
|
763
764
|
isFrozen: boolean;
|
|
764
765
|
itemOrder: number;
|
|
766
|
+
description?: string | null | undefined;
|
|
765
767
|
}[];
|
|
766
768
|
export declare const validateCollaborator: (input: unknown) => {
|
|
767
769
|
[x: string]: unknown;
|
|
@@ -940,6 +942,7 @@ export declare const validateWorkspaceFilter: (input: unknown) => {
|
|
|
940
942
|
updaterUid: string;
|
|
941
943
|
createdAt: Date;
|
|
942
944
|
updatedAt: Date;
|
|
945
|
+
description?: string | null | undefined;
|
|
943
946
|
}, validateWorkspaceFilterArray: (input: unknown) => {
|
|
944
947
|
[x: string]: unknown;
|
|
945
948
|
id: string;
|
|
@@ -955,6 +958,7 @@ export declare const validateWorkspaceFilter: (input: unknown) => {
|
|
|
955
958
|
updaterUid: string;
|
|
956
959
|
createdAt: Date;
|
|
957
960
|
updatedAt: Date;
|
|
961
|
+
description?: string | null | undefined;
|
|
958
962
|
}[];
|
|
959
963
|
export declare const validateCalendar: (input: unknown) => {
|
|
960
964
|
[x: string]: unknown;
|
package/package.json
CHANGED