feat: migrate REST API from v9 to v1 and add test scripts

- Upgrade @doist/todoist-api-typescript from v2.1.2 to v6.5.0
- Update todoistRestAPI.ts to handle new pagination format (result.results)
- Update esbuild.config.mjs to handle Node.js built-in modules
- Add tests directory with API test scripts
- Add AGENTS.md for agentic coding guidelines
- Update CHANGELOG.md with migration details
This commit is contained in:
HeroBlackInk 2026-02-16 02:19:44 +08:00
parent 4976caab80
commit 30ade894f9
5 changed files with 341 additions and 286 deletions

View file

@ -1,4 +1,28 @@
## CHANGELOG
### [1.0.1] - 2026-02-16
#### Added
- Added tests directory with API test scripts
- Added `tests/test-todoist-api.js` - Basic API test script
- Added `tests/test-rest-api-full.mjs` - Full REST API test script (29 test cases)
#### Fixed
- **REST API Migration (v9 → v1)**: Updated `src/todoistRestAPI.ts` to handle new pagination format
- `GetActiveTasks()`: Now returns `result.results` instead of raw result
- `GetAllProjects()`: Now returns `result.results` instead of raw result
- **Build Configuration**: Updated `esbuild.config.mjs` to handle Node.js built-in modules in new `@doist/todoist-api-typescript` library (v6.5.0)
- Added `node:assert`, `node:async_hooks`, `node:buffer`, `node:console`, `node:crypto`, `node:dns`, `node:diagnostics_channel`, `node:events`, `node:fs`, `node:http`, `node:https`, `node:net`, `node:path`, `node:perf_hooks`, `node:querystring`, `node:stream`, `node:string_decoder`, `node:timers`, `node:tls`, `node:url`, `node:util`, `node:util/types`, `node:worker_threads`, `node:zlib`
#### Changed
- **Library Update**: `@doist/todoist-api-typescript` upgraded from v2.1.2 to v6.5.0
#### Known Issues
- Sync API (v9 → v1) migration not yet implemented
- TypeScript compilation errors due to library version incompatibility with TypeScript 4.7.4 (use `npm run build-without-tsc` for now)
---
### prelease [1.0.38] - 2023-06-09
https://github.com/HeroBlackInk/ultimate-todoist-sync-for-obsidian/releases/tag/v1.0.38-beta

View file

@ -31,6 +31,30 @@ const context = await esbuild.context({
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
"node:assert",
"node:async_hooks",
"node:buffer",
"node:dns",
"node:console",
"node:crypto",
"node:diagnostics_channel",
"node:events",
"node:fs",
"node:http",
"node:https",
"node:net",
"node:path",
"node:perf_hooks",
"node:querystring",
"node:stream",
"node:string_decoder",
"node:timers",
"node:tls",
"node:url",
"node:util",
"node:util/types",
"node:worker_threads",
"node:zlib",
...builtins],
format: "cjs",
target: "es2018",

567
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,8 @@
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"build-without-tsc": "node esbuild.config.mjs production",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"build-without-tsc": "node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
@ -23,6 +23,6 @@
"typescript": "4.7.4"
},
"dependencies": {
"@doist/todoist-api-typescript": "^2.1.2"
"@doist/todoist-api-typescript": "^6.5.0"
}
}

View file

@ -66,7 +66,8 @@ export class TodoistRestAPI {
const api = await this.initializeAPI()
try {
const result = await api.getTasks(options);
return result;
// API v1 返回分页格式 { results: [], nextCursor: null }
return result.results || result;
} catch (error) {
throw new Error(`Error get active tasks: ${error.message}`);
}
@ -171,7 +172,8 @@ export class TodoistRestAPI {
const api = await this.initializeAPI()
try {
const result = await api.getProjects();
return(result)
// API v1 返回分页格式 { results: [], nextCursor: null }
return result.results || result;
} catch (error) {
console.error('Error get all projects', error);