@doist/todoist-sdk 15.2.0 → 15.3.1
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/README.md +10 -0
- package/dist/esm/utils/sanitization.js +19 -0
- package/dist/types/utils/sanitization.d.ts +17 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -178,6 +178,16 @@ const api = new TodoistApi('YOURTOKEN', { customFetch })
|
|
|
178
178
|
- File upload bodies are a `Blob`, or a `ReadableStream` when uploading from a stream — a custom fetch must pass them through unchanged
|
|
179
179
|
- Timeout parameter is optional and up to your custom implementation
|
|
180
180
|
|
|
181
|
+
## Filter Queries
|
|
182
|
+
|
|
183
|
+
Use `escapeFilterToken` for user-provided search text, handling validation and trimming in your code. Pass complete filter queries directly to `getTasksByFilter`.
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
await api.getTasksByFilter({
|
|
187
|
+
query: `search: ${escapeFilterToken(searchText)}`,
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
181
191
|
## Development and Testing
|
|
182
192
|
|
|
183
193
|
Instead of having an example app in the repository to assist development and testing, we have included [ts-node](https://github.com/TypeStrong/ts-node) as a dev dependency. This allows us to have a scratch file locally that can import and utilize the API while developing or reviewing pull requests without having to manage a separate app project.
|
|
@@ -110,3 +110,22 @@ export function getSanitizedContent(input) {
|
|
|
110
110
|
export function getSanitizedTasks(tasks) {
|
|
111
111
|
return tasks.map((task) => (Object.assign(Object.assign({}, task), { sanitizedContent: getSanitizedContent(task.content) })));
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Escapes text for use as a token in a Todoist filter query.
|
|
115
|
+
*
|
|
116
|
+
* Prefixes parentheses, pipes, ampersands, exclamation marks, commas, and
|
|
117
|
+
* backslashes with a backslash. Quotes and asterisks are left unchanged.
|
|
118
|
+
* Whitespace validation and trimming are the caller's responsibility.
|
|
119
|
+
* Pass unescaped text to this function once, before inserting it into a query.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const tasks = await api.getTasksByFilter({
|
|
123
|
+
* query: `search: ${escapeFilterToken(searchText)}`,
|
|
124
|
+
* })
|
|
125
|
+
*
|
|
126
|
+
* @param text - The text to escape, not a complete filter query
|
|
127
|
+
* @returns The escaped text, with whitespace preserved
|
|
128
|
+
*/
|
|
129
|
+
export function escapeFilterToken(text) {
|
|
130
|
+
return text.replace(/[()|&!,\\]/g, '\\$&');
|
|
131
|
+
}
|
|
@@ -33,3 +33,20 @@ export declare function getSanitizedContent(input: string): string;
|
|
|
33
33
|
* @returns Array of tasks with added sanitizedContent property
|
|
34
34
|
*/
|
|
35
35
|
export declare function getSanitizedTasks(tasks: Task[]): TaskWithSanitizedContent[];
|
|
36
|
+
/**
|
|
37
|
+
* Escapes text for use as a token in a Todoist filter query.
|
|
38
|
+
*
|
|
39
|
+
* Prefixes parentheses, pipes, ampersands, exclamation marks, commas, and
|
|
40
|
+
* backslashes with a backslash. Quotes and asterisks are left unchanged.
|
|
41
|
+
* Whitespace validation and trimming are the caller's responsibility.
|
|
42
|
+
* Pass unescaped text to this function once, before inserting it into a query.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const tasks = await api.getTasksByFilter({
|
|
46
|
+
* query: `search: ${escapeFilterToken(searchText)}`,
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* @param text - The text to escape, not a complete filter query
|
|
50
|
+
* @returns The escaped text, with whitespace preserved
|
|
51
|
+
*/
|
|
52
|
+
export declare function escapeFilterToken(text: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/todoist-sdk",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.1",
|
|
4
4
|
"description": "The official TypeScript SDK for the Todoist REST API.",
|
|
5
5
|
"author": "Doist developers",
|
|
6
6
|
"repository": "https://github.com/Doist/todoist-sdk-typescript",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"ts-node": "10.9.2",
|
|
73
73
|
"type-fest": "^5.0.0",
|
|
74
74
|
"typescript": "5.9.3",
|
|
75
|
-
"vitest": "4.1.
|
|
75
|
+
"vitest": "4.1.11"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"type-fest": "^4.12.0 || ^5.5.0"
|