@doist/todoist-api-typescript 1.5.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.
@@ -0,0 +1,149 @@
1
+ import { Boolean, Number as NumberRunType, String, Array, Record, Static, Partial, Literal } from 'runtypes';
2
+ export declare const Int: import("runtypes").Constraint<NumberRunType, number, unknown>;
3
+ export declare type TodoistEntity = {
4
+ id: number;
5
+ };
6
+ export declare type OrderedEntity = TodoistEntity & {
7
+ order: number;
8
+ };
9
+ export declare type EntityInHierarchy = OrderedEntity & {
10
+ parentId?: number;
11
+ };
12
+ export declare const DueDate: import("runtypes").Intersect2<Record<{
13
+ recurring: Boolean;
14
+ string: String;
15
+ date: String;
16
+ }, false>, Partial<{
17
+ datetime: String;
18
+ timezone: String;
19
+ }, false>>;
20
+ export declare type DueDate = Static<typeof DueDate>;
21
+ export declare const Task: import("runtypes").Intersect2<Record<{
22
+ id: import("runtypes").Constraint<NumberRunType, number, unknown>;
23
+ order: import("runtypes").Constraint<NumberRunType, number, unknown>;
24
+ content: String;
25
+ description: String;
26
+ projectId: import("runtypes").Constraint<NumberRunType, number, unknown>;
27
+ sectionId: import("runtypes").Constraint<NumberRunType, number, unknown>;
28
+ completed: Boolean;
29
+ labelIds: Array<import("runtypes").Constraint<NumberRunType, number, unknown>, false>;
30
+ priority: import("runtypes").Constraint<NumberRunType, number, unknown>;
31
+ commentCount: import("runtypes").Constraint<NumberRunType, number, unknown>;
32
+ created: String;
33
+ url: String;
34
+ }, false>, Partial<{
35
+ parentId: import("runtypes").Constraint<NumberRunType, number, unknown>;
36
+ due: import("runtypes").Intersect2<Record<{
37
+ recurring: Boolean;
38
+ string: String;
39
+ date: String;
40
+ }, false>, Partial<{
41
+ datetime: String;
42
+ timezone: String;
43
+ }, false>>;
44
+ assignee: import("runtypes").Constraint<NumberRunType, number, unknown>;
45
+ }, false>>;
46
+ export declare type Task = Static<typeof Task>;
47
+ export declare const Project: import("runtypes").Intersect2<Record<{
48
+ id: import("runtypes").Constraint<NumberRunType, number, unknown>;
49
+ name: String;
50
+ color: import("runtypes").Constraint<NumberRunType, number, unknown>;
51
+ commentCount: import("runtypes").Constraint<NumberRunType, number, unknown>;
52
+ shared: Boolean;
53
+ favorite: Boolean;
54
+ url: String;
55
+ }, false>, Partial<{
56
+ parentId: import("runtypes").Constraint<NumberRunType, number, unknown>;
57
+ order: import("runtypes").Constraint<NumberRunType, number, unknown>;
58
+ inboxProject: Boolean;
59
+ teamInbox: Boolean;
60
+ syncId: import("runtypes").Constraint<NumberRunType, number, unknown>;
61
+ }, false>>;
62
+ export declare type Project = Static<typeof Project>;
63
+ export declare const Section: Record<{
64
+ id: import("runtypes").Constraint<NumberRunType, number, unknown>;
65
+ order: import("runtypes").Constraint<NumberRunType, number, unknown>;
66
+ name: String;
67
+ projectId: import("runtypes").Constraint<NumberRunType, number, unknown>;
68
+ }, false>;
69
+ export declare type Section = Static<typeof Section>;
70
+ export declare const Label: Record<{
71
+ id: import("runtypes").Constraint<NumberRunType, number, unknown>;
72
+ order: import("runtypes").Constraint<NumberRunType, number, unknown>;
73
+ name: String;
74
+ color: import("runtypes").Constraint<NumberRunType, number, unknown>;
75
+ favorite: Boolean;
76
+ }, false>;
77
+ export declare type Label = Static<typeof Label>;
78
+ export declare const Attachment: import("runtypes").Intersect2<Record<{
79
+ resourceType: String;
80
+ }, false>, Partial<{
81
+ fileName: String;
82
+ fileSize: import("runtypes").Constraint<NumberRunType, number, unknown>;
83
+ fileType: String;
84
+ fileUrl: String;
85
+ fileDuration: import("runtypes").Constraint<NumberRunType, number, unknown>;
86
+ uploadState: import("runtypes").Union2<Literal<"pending">, Literal<"completed">>;
87
+ image: String;
88
+ imageWidth: import("runtypes").Constraint<NumberRunType, number, unknown>;
89
+ imageHeight: import("runtypes").Constraint<NumberRunType, number, unknown>;
90
+ url: String;
91
+ title: String;
92
+ }, false>>;
93
+ export declare type Attachment = Static<typeof Attachment>;
94
+ export declare const Comment: import("runtypes").Intersect2<Record<{
95
+ id: import("runtypes").Constraint<NumberRunType, number, unknown>;
96
+ content: String;
97
+ posted: String;
98
+ }, false>, Partial<{
99
+ taskId: import("runtypes").Constraint<NumberRunType, number, unknown>;
100
+ projectId: import("runtypes").Constraint<NumberRunType, number, unknown>;
101
+ attachment: import("runtypes").Intersect2<Record<{
102
+ resourceType: String;
103
+ }, false>, Partial<{
104
+ fileName: String;
105
+ fileSize: import("runtypes").Constraint<NumberRunType, number, unknown>;
106
+ fileType: String;
107
+ fileUrl: String;
108
+ fileDuration: import("runtypes").Constraint<NumberRunType, number, unknown>;
109
+ uploadState: import("runtypes").Union2<Literal<"pending">, Literal<"completed">>;
110
+ image: String;
111
+ imageWidth: import("runtypes").Constraint<NumberRunType, number, unknown>;
112
+ imageHeight: import("runtypes").Constraint<NumberRunType, number, unknown>;
113
+ url: String;
114
+ title: String;
115
+ }, false>>;
116
+ }, false>>;
117
+ export declare type Comment = Static<typeof Comment>;
118
+ export declare const User: Record<{
119
+ id: import("runtypes").Constraint<NumberRunType, number, unknown>;
120
+ name: String;
121
+ email: String;
122
+ }, false>;
123
+ export declare type User = Static<typeof User>;
124
+ export declare type Color = TodoistEntity & {
125
+ name: string;
126
+ value: string;
127
+ };
128
+ export declare type QuickAddTaskResponse = {
129
+ id: number;
130
+ projectId: number;
131
+ content: string;
132
+ description: string;
133
+ priority: number;
134
+ sectionId: number | null;
135
+ parentId: number | null;
136
+ childOrder: number;
137
+ labels: number[];
138
+ responsibleUid: number | null;
139
+ checked: number;
140
+ dateAdded: string;
141
+ syncId: number | null;
142
+ due: {
143
+ date: string;
144
+ timezone: string | null;
145
+ isRecurring: boolean;
146
+ string: string;
147
+ lang: string;
148
+ } | null;
149
+ };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.User = exports.Comment = exports.Attachment = exports.Label = exports.Section = exports.Project = exports.Task = exports.DueDate = exports.Int = void 0;
4
+ var runtypes_1 = require("runtypes");
5
+ exports.Int = runtypes_1.Number.withConstraint(function (n) { return Number.isInteger(n) || n + " is not a valid entity id. Should be an integer"; });
6
+ exports.DueDate = (0, runtypes_1.Record)({
7
+ recurring: runtypes_1.Boolean,
8
+ string: runtypes_1.String,
9
+ date: runtypes_1.String,
10
+ }).And((0, runtypes_1.Partial)({
11
+ datetime: runtypes_1.String,
12
+ timezone: runtypes_1.String,
13
+ }));
14
+ exports.Task = (0, runtypes_1.Record)({
15
+ id: exports.Int,
16
+ order: exports.Int,
17
+ content: runtypes_1.String,
18
+ description: runtypes_1.String,
19
+ projectId: exports.Int,
20
+ sectionId: exports.Int,
21
+ completed: runtypes_1.Boolean,
22
+ labelIds: (0, runtypes_1.Array)(exports.Int),
23
+ priority: exports.Int,
24
+ commentCount: exports.Int,
25
+ created: runtypes_1.String,
26
+ url: runtypes_1.String,
27
+ }).And((0, runtypes_1.Partial)({
28
+ parentId: exports.Int,
29
+ due: exports.DueDate,
30
+ assignee: exports.Int,
31
+ }));
32
+ exports.Project = (0, runtypes_1.Record)({
33
+ id: exports.Int,
34
+ name: runtypes_1.String,
35
+ color: exports.Int,
36
+ commentCount: exports.Int,
37
+ shared: runtypes_1.Boolean,
38
+ favorite: runtypes_1.Boolean,
39
+ url: runtypes_1.String,
40
+ }).And((0, runtypes_1.Partial)({
41
+ parentId: exports.Int,
42
+ order: exports.Int,
43
+ inboxProject: runtypes_1.Boolean,
44
+ teamInbox: runtypes_1.Boolean,
45
+ syncId: exports.Int,
46
+ }));
47
+ exports.Section = (0, runtypes_1.Record)({
48
+ id: exports.Int,
49
+ order: exports.Int,
50
+ name: runtypes_1.String,
51
+ projectId: exports.Int,
52
+ });
53
+ exports.Label = (0, runtypes_1.Record)({
54
+ id: exports.Int,
55
+ order: exports.Int,
56
+ name: runtypes_1.String,
57
+ color: exports.Int,
58
+ favorite: runtypes_1.Boolean,
59
+ });
60
+ exports.Attachment = (0, runtypes_1.Record)({
61
+ resourceType: runtypes_1.String,
62
+ }).And((0, runtypes_1.Partial)({
63
+ fileName: runtypes_1.String,
64
+ fileSize: exports.Int,
65
+ fileType: runtypes_1.String,
66
+ fileUrl: runtypes_1.String,
67
+ fileDuration: exports.Int,
68
+ uploadState: (0, runtypes_1.Union)((0, runtypes_1.Literal)('pending'), (0, runtypes_1.Literal)('completed')),
69
+ image: runtypes_1.String,
70
+ imageWidth: exports.Int,
71
+ imageHeight: exports.Int,
72
+ url: runtypes_1.String,
73
+ title: runtypes_1.String,
74
+ }));
75
+ exports.Comment = (0, runtypes_1.Record)({
76
+ id: exports.Int,
77
+ content: runtypes_1.String,
78
+ posted: runtypes_1.String,
79
+ }).And((0, runtypes_1.Partial)({
80
+ taskId: exports.Int,
81
+ projectId: exports.Int,
82
+ attachment: exports.Attachment,
83
+ }));
84
+ exports.User = (0, runtypes_1.Record)({
85
+ id: exports.Int,
86
+ name: runtypes_1.String,
87
+ email: runtypes_1.String,
88
+ });
@@ -0,0 +1,8 @@
1
+ import { CustomError } from 'ts-custom-error';
2
+ export declare class TodoistRequestError extends CustomError {
3
+ message: string;
4
+ httpStatusCode?: number | undefined;
5
+ responseData?: unknown;
6
+ constructor(message: string, httpStatusCode?: number | undefined, responseData?: unknown);
7
+ isAuthenticationError: () => boolean;
8
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.TodoistRequestError = void 0;
19
+ var ts_custom_error_1 = require("ts-custom-error");
20
+ var authenticationErrorCodes = [401, 403];
21
+ var TodoistRequestError = /** @class */ (function (_super) {
22
+ __extends(TodoistRequestError, _super);
23
+ function TodoistRequestError(message, httpStatusCode, responseData) {
24
+ var _this = _super.call(this, message) || this;
25
+ _this.message = message;
26
+ _this.httpStatusCode = httpStatusCode;
27
+ _this.responseData = responseData;
28
+ _this.isAuthenticationError = function () {
29
+ if (!_this.httpStatusCode) {
30
+ return false;
31
+ }
32
+ return authenticationErrorCodes.includes(_this.httpStatusCode);
33
+ };
34
+ Object.defineProperty(_this, 'name', { value: 'TodoistRequestError' });
35
+ return _this;
36
+ }
37
+ return TodoistRequestError;
38
+ }(ts_custom_error_1.CustomError));
39
+ exports.TodoistRequestError = TodoistRequestError;
@@ -0,0 +1 @@
1
+ export declare type HttpMethod = 'POST' | 'GET' | 'DELETE';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './entities';
2
+ export * from './errors';
3
+ export * from './requests';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./entities"), exports);
14
+ __exportStar(require("./errors"), exports);
15
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,100 @@
1
+ export declare type AddTaskArgs = {
2
+ content: string;
3
+ description?: string;
4
+ projectId?: number;
5
+ sectionId?: number;
6
+ parentId?: number;
7
+ order?: number;
8
+ labelIds?: number[];
9
+ priority?: number;
10
+ dueString?: string;
11
+ dueLang?: string;
12
+ dueDate?: string;
13
+ dueDatetime?: string;
14
+ assignee?: number;
15
+ };
16
+ export declare type QuickAddTaskArgs = {
17
+ text: string;
18
+ note?: string;
19
+ reminder?: string;
20
+ autoReminder?: boolean;
21
+ };
22
+ export declare type GetTasksArgs = {
23
+ projectId?: number;
24
+ sectionId?: number;
25
+ labelId?: number;
26
+ filter?: string;
27
+ lang?: string;
28
+ ids?: number[];
29
+ };
30
+ export declare type UpdateTaskArgs = {
31
+ content?: string;
32
+ description?: string;
33
+ labelIds?: number[];
34
+ priority?: number;
35
+ dueString?: string;
36
+ dueLang?: string;
37
+ dueDate?: string;
38
+ dueDatetime?: string;
39
+ assignee?: number;
40
+ };
41
+ export declare type AddProjectArgs = {
42
+ name: string;
43
+ parentId?: number;
44
+ color?: number;
45
+ favorite?: boolean;
46
+ };
47
+ export declare type UpdateProjectArgs = {
48
+ name?: string;
49
+ color?: number;
50
+ favorite?: boolean;
51
+ };
52
+ export declare type AddSectionArgs = {
53
+ name: string;
54
+ projectId: number;
55
+ order?: number;
56
+ };
57
+ export declare type UpdateSectionArgs = {
58
+ name: string;
59
+ };
60
+ export declare type AddLabelArgs = {
61
+ name: string;
62
+ order?: number;
63
+ color?: number;
64
+ favorite?: boolean;
65
+ };
66
+ export declare type UpdateLabelArgs = {
67
+ name?: string;
68
+ order?: number;
69
+ color?: number;
70
+ favorite?: boolean;
71
+ };
72
+ export declare type GetTaskCommentsArgs = {
73
+ taskId: number;
74
+ projectId?: never;
75
+ };
76
+ export declare type GetProjectCommentsArgs = {
77
+ projectId: number;
78
+ taskId?: never;
79
+ };
80
+ declare type AddCommentArgs = {
81
+ content: string;
82
+ attachment?: {
83
+ fileName?: string;
84
+ fileUrl: string;
85
+ fileType?: string;
86
+ resourceType?: string;
87
+ };
88
+ };
89
+ export declare type AddTaskCommentArgs = AddCommentArgs & {
90
+ taskId: number;
91
+ projectId?: never;
92
+ };
93
+ export declare type AddProjectCommentArgs = AddCommentArgs & {
94
+ projectId: number;
95
+ taskId?: never;
96
+ };
97
+ export declare type UpdateCommentArgs = {
98
+ content: string;
99
+ };
100
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { Color } from '../types';
2
+ export declare const berryRed: Color;
3
+ export declare const red: Color;
4
+ export declare const orange: Color;
5
+ export declare const yellow: Color;
6
+ export declare const oliveGreen: Color;
7
+ export declare const limeGreen: Color;
8
+ export declare const green: Color;
9
+ export declare const mintGreen: Color;
10
+ export declare const turquoise: Color;
11
+ export declare const skyBlue: Color;
12
+ export declare const lightBlue: Color;
13
+ export declare const blue: Color;
14
+ export declare const grape: Color;
15
+ export declare const violet: Color;
16
+ export declare const lavender: Color;
17
+ export declare const magenta: Color;
18
+ export declare const salmon: Color;
19
+ export declare const charcoal: Color;
20
+ export declare const gray: Color;
21
+ export declare const taupe: Color;
22
+ export declare const colors: Color[];
23
+ export declare function getColor(colorId: number): Color;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getColor = exports.colors = exports.taupe = exports.gray = exports.charcoal = exports.salmon = exports.magenta = exports.lavender = exports.violet = exports.grape = exports.blue = exports.lightBlue = exports.skyBlue = exports.turquoise = exports.mintGreen = exports.green = exports.limeGreen = exports.oliveGreen = exports.yellow = exports.orange = exports.red = exports.berryRed = void 0;
4
+ exports.berryRed = { name: 'Berry Red', id: 30, value: '#b8255f' };
5
+ exports.red = { name: 'Red', id: 31, value: '#db4035' };
6
+ exports.orange = { name: 'Orange', id: 32, value: '#ff9933' };
7
+ exports.yellow = { name: 'Yellow', id: 33, value: '#fad000' };
8
+ exports.oliveGreen = { name: 'Olive Green', id: 34, value: '#afb83b' };
9
+ exports.limeGreen = { name: 'Lime Green', id: 35, value: '#7ecc49' };
10
+ exports.green = { name: 'Green', id: 36, value: '#299438' };
11
+ exports.mintGreen = { name: 'Mint Green', id: 37, value: '#6accbc' };
12
+ exports.turquoise = { name: 'Turquoise', id: 38, value: '#158fad' };
13
+ exports.skyBlue = { name: 'Sky Blue', id: 39, value: '#14aaf5' };
14
+ exports.lightBlue = { name: 'Light Blue', id: 40, value: '#96c3eb' };
15
+ exports.blue = { name: 'Blue', id: 41, value: '#4073ff' };
16
+ exports.grape = { name: 'Grape', id: 42, value: '#884dff' };
17
+ exports.violet = { name: 'Violet', id: 43, value: '#af38eb' };
18
+ exports.lavender = { name: 'Lavender', id: 44, value: '#eb96eb' };
19
+ exports.magenta = { name: 'Magenta', id: 45, value: '#e05194' };
20
+ exports.salmon = { name: 'Salmon', id: 46, value: '#ff8d85' };
21
+ exports.charcoal = { name: 'Charcoal', id: 47, value: '#808080' };
22
+ exports.gray = { name: 'Gray', id: 48, value: '#b8b8b8' };
23
+ exports.taupe = { name: 'Taupe', id: 49, value: '#ccac93' };
24
+ exports.colors = [
25
+ exports.berryRed,
26
+ exports.red,
27
+ exports.orange,
28
+ exports.yellow,
29
+ exports.oliveGreen,
30
+ exports.limeGreen,
31
+ exports.green,
32
+ exports.mintGreen,
33
+ exports.turquoise,
34
+ exports.skyBlue,
35
+ exports.lightBlue,
36
+ exports.blue,
37
+ exports.grape,
38
+ exports.violet,
39
+ exports.lavender,
40
+ exports.magenta,
41
+ exports.salmon,
42
+ exports.charcoal,
43
+ exports.gray,
44
+ exports.taupe,
45
+ ];
46
+ function getColor(colorId) {
47
+ var color = exports.colors.find(function (color) { return color.id === colorId; });
48
+ return color !== null && color !== void 0 ? color : exports.charcoal;
49
+ }
50
+ exports.getColor = getColor;
@@ -0,0 +1,2 @@
1
+ export * from './colors';
2
+ export * from './sanitization';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./colors"), exports);
14
+ __exportStar(require("./sanitization"), exports);
@@ -0,0 +1,6 @@
1
+ import { Task } from '../types';
2
+ export declare type TaskWithSanitizedContent = Task & {
3
+ sanitizedContent: string;
4
+ };
5
+ export declare function getSanitizedContent(input: string): string;
6
+ export declare function getSanitizedTasks(tasks: Task[]): TaskWithSanitizedContent[];
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getSanitizedTasks = exports.getSanitizedContent = void 0;
15
+ var BOLD_FORMAT = /(^|[\s!?,;>:]+)(?:\*\*|__|!!)(.+?)(\*\*|__|!!)(?=$|[\s!?,;><:]+)/gi;
16
+ var ITALIC_FORMAT = /(^|[\s!?,;>:]+)(?:\*|_|!)(.+?)(\*|_|!)(?=$|[\s!?,;><:]+)/gi;
17
+ var BOLD_ITALIC_FORMAT = /(^|[\s!?,;>:]+)(?:\*\*\*|___|!!!)(.+?)(\*\*\*|___|!!!)(?=$|[\s!?,;><:]+)/gi;
18
+ var CODE_BLOCK_FORMAT = /```([\s\S]*?)```/gi;
19
+ var CODE_INLINE_FORMAT = /`([^`]+)`/gi;
20
+ var TODOIST_LINK = /((?:(?:onenote:)?[\w-]+):\/\/[^\s]+)\s+[[(]([^)]+)[\])]/gi;
21
+ var MARKDOWN_LINK = /\[(.+?)\]\((.+?)\)/gi;
22
+ var GMAIL_LINK = /\[\[gmail=(.+?),\s*(.+?)\]\]/gi;
23
+ var OUTLOOK_LINK = /\[\[outlook=(.+?),\s*(.+?)\]\]/gi;
24
+ var THUNDERBIRD_LINK = /\[\[thunderbird\n(.+)\n(.+)\n\s*\]\]/gi;
25
+ var FAKE_SECTION_PREFIX = '* ';
26
+ var FAKE_SECTION_SUFFIX = ':';
27
+ function removeStyleFormatting(input) {
28
+ if (!input.includes('!') && !input.includes('*') && !input.includes('_')) {
29
+ return input;
30
+ }
31
+ function removeMarkdown(match, prefix, text) {
32
+ return "" + prefix + text;
33
+ }
34
+ input = input.replace(BOLD_ITALIC_FORMAT, removeMarkdown);
35
+ input = input.replace(BOLD_FORMAT, removeMarkdown);
36
+ input = input.replace(ITALIC_FORMAT, removeMarkdown);
37
+ return input;
38
+ }
39
+ function removeCodeFormatting(input) {
40
+ function removeMarkdown(match, text) {
41
+ return text;
42
+ }
43
+ input = input.replace(CODE_BLOCK_FORMAT, removeMarkdown);
44
+ input = input.replace(CODE_INLINE_FORMAT, removeMarkdown);
45
+ return input;
46
+ }
47
+ function removeFakeSectionFormatting(input) {
48
+ if (input.startsWith(FAKE_SECTION_PREFIX)) {
49
+ input = input.slice(FAKE_SECTION_PREFIX.length);
50
+ }
51
+ if (input.endsWith(FAKE_SECTION_SUFFIX)) {
52
+ input = input.slice(0, input.length - FAKE_SECTION_SUFFIX.length);
53
+ }
54
+ return input;
55
+ }
56
+ function removeMarkdownLinks(input) {
57
+ if (!input.includes('[') || !input.includes(']')) {
58
+ return input;
59
+ }
60
+ function removeMarkdown(match, text) {
61
+ return text;
62
+ }
63
+ return input.replace(MARKDOWN_LINK, removeMarkdown);
64
+ }
65
+ function removeTodoistLinks(input) {
66
+ if (!input.includes('(') || !input.includes(')')) {
67
+ return input;
68
+ }
69
+ function removeMarkdown(match, url, text) {
70
+ return text;
71
+ }
72
+ return input.replace(TODOIST_LINK, removeMarkdown);
73
+ }
74
+ function removeAppLinks(input) {
75
+ if (input.includes('gmail')) {
76
+ input = input.replace(GMAIL_LINK, function (match, id, text) { return text; });
77
+ }
78
+ if (input.includes('outlook')) {
79
+ input = input.replace(OUTLOOK_LINK, function (match, id, text) { return text; });
80
+ }
81
+ if (input.includes('thunderbird')) {
82
+ input = input.replace(THUNDERBIRD_LINK, function (match, text) { return text; });
83
+ }
84
+ return input;
85
+ }
86
+ function getSanitizedContent(input) {
87
+ input = removeStyleFormatting(input);
88
+ input = removeCodeFormatting(input);
89
+ input = removeFakeSectionFormatting(input);
90
+ input = removeMarkdownLinks(input);
91
+ input = removeTodoistLinks(input);
92
+ input = removeAppLinks(input);
93
+ return input;
94
+ }
95
+ exports.getSanitizedContent = getSanitizedContent;
96
+ function getSanitizedTasks(tasks) {
97
+ return tasks.map(function (task) { return (__assign(__assign({}, task), { sanitizedContent: getSanitizedContent(task.content) })); });
98
+ }
99
+ exports.getSanitizedTasks = getSanitizedTasks;
@@ -0,0 +1,2 @@
1
+ import { QuickAddTaskResponse, Task } from '../types';
2
+ export declare function getTaskFromQuickAddResponse(responseData: QuickAddTaskResponse): Task;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getTaskFromQuickAddResponse = void 0;
15
+ var showTaskEndpoint = 'https://todoist.com/showTask';
16
+ function getTaskUrlFromQuickAddResponse(responseData) {
17
+ return responseData.syncId
18
+ ? showTaskEndpoint + "?id=" + responseData.id + "&sync_id=" + responseData.syncId
19
+ : showTaskEndpoint + "?id=" + responseData.id;
20
+ }
21
+ function getTaskFromQuickAddResponse(responseData) {
22
+ var _a;
23
+ var due = responseData.due
24
+ ? __assign(__assign({ recurring: responseData.due.isRecurring, string: responseData.due.string, date: responseData.due.date }, (responseData.due.timezone !== null && { datetime: responseData.due.date })), (responseData.due.timezone !== null && { timezone: responseData.due.timezone })) : undefined;
25
+ var task = __assign(__assign(__assign({ id: responseData.id, order: responseData.childOrder, content: responseData.content, description: responseData.description, projectId: responseData.projectId, sectionId: (_a = responseData.sectionId) !== null && _a !== void 0 ? _a : 0, completed: responseData.checked === 1, labelIds: responseData.labels, priority: responseData.priority, commentCount: 0, created: responseData.dateAdded, url: getTaskUrlFromQuickAddResponse(responseData) }, (due !== undefined && { due: due })), (responseData.parentId !== null && { parentId: responseData.parentId })), (responseData.responsibleUid !== null && { assignee: responseData.responsibleUid }));
26
+ return task;
27
+ }
28
+ exports.getTaskFromQuickAddResponse = getTaskFromQuickAddResponse;
@@ -0,0 +1,13 @@
1
+ import { Label, Project, Section, Task, User, Comment } from '../types';
2
+ export declare function validateTask(input: unknown): Task;
3
+ export declare function validateTaskArray(input: unknown[]): Task[];
4
+ export declare function validateProject(input: unknown): Project;
5
+ export declare function validateProjectArray(input: unknown[]): Project[];
6
+ export declare function validateSection(input: unknown): Section;
7
+ export declare function validateSectionArray(input: unknown[]): Section[];
8
+ export declare function validateLabel(input: unknown): Label;
9
+ export declare function validateLabelArray(input: unknown[]): Label[];
10
+ export declare function validateComment(input: unknown): Comment;
11
+ export declare function validateCommentArray(input: unknown[]): Comment[];
12
+ export declare function validateUser(input: unknown): User;
13
+ export declare function validateUserArray(input: unknown[]): User[];