feat: add Sunsama API TypeScript wrapper as workspace package - #3
feat: add Sunsama API TypeScript wrapper as workspace package#3devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Add @workspace/sunsama-api integration library based on robertn702/sunsama-api. Provides type-safe access to Sunsama's GraphQL API for daily planning and task management. Features: - Full TypeScript support with comprehensive type definitions - GraphQL client with cookie-based authentication - Task CRUD, scheduling, reordering, and subtask management - Calendar event creation and updates - Yjs-powered collaborative editing for task notes - HTML/Markdown conversion utilities - Zod validation for input safety - MongoDB ObjectId-style task ID generation Co-Authored-By: adamer <adamer@hunght1890.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| sequence: null, | ||
| followers: [], | ||
| recommendedTimeEstimate: null, | ||
| timeEstimate: options?.timeEstimate || null, |
There was a problem hiding this comment.
🟡 timeEstimate: 0 silently converted to null due to || operator
At task-lifecycle.ts:333, options?.timeEstimate || null uses the logical OR operator, which treats 0 as falsy. If a user passes timeEstimate: 0 to explicitly set zero minutes (e.g., to clear the estimate on a new task), it gets converted to null ("no estimate"). The updateTaskPlannedTime method at task-updates.ts:256-257 explicitly documents 0 as a valid value for clearing the time estimate, confirming that 0 is semantically meaningful. The nullish coalescing operator ?? should be used instead.
| timeEstimate: options?.timeEstimate || null, | |
| timeEstimate: options?.timeEstimate ?? null, |
Was this helpful? React with 👍 or 👎 to provide feedback.
| * @internal | ||
| */ | ||
| private static getNextCounter(): number { | ||
| SunsamaClientBase._counter = (SunsamaClientBase._counter + 1) % 0xffffff; |
There was a problem hiding this comment.
🟡 ObjectId counter off-by-one: % 0xffffff never produces the max 3-byte value
In the getNextCounter method, (counter + 1) % 0xffffff produces values in the range [0, 0xfffffe] (0 to 16777214), skipping 0xffffff (16777215). A 3-byte counter should cover the full range [0, 0xffffff], so the modulus should be 0x1000000 (16777216). Additionally, the initial value at base.ts:301 (Math.floor(Math.random() * 0xffffff)) also never produces 0xffffff; it should be Math.floor(Math.random() * 0x1000000).
| SunsamaClientBase._counter = (SunsamaClientBase._counter + 1) % 0xffffff; | |
| SunsamaClientBase._counter = (SunsamaClientBase._counter + 1) % 0x1000000; |
Was this helpful? React with 👍 or 👎 to provide feedback.
- Fix ObjectId counter off-by-one: use 0x1000000 modulus to cover full 3-byte range - Fix timeEstimate: use ?? instead of || so 0 is not silently converted to null Co-Authored-By: adamer <adamer@hunght1890.com>
Summary
Thêm package
@workspace/sunsama-apivào monorepo tạilib/integrations/sunsama-api/, dựa trên robertn702/sunsama-api.Package này cung cấp TypeScript wrapper type-safe cho Sunsama GraphQL API, hỗ trợ quản lý công việc hàng ngày (daily planning & task management).
Tính năng chính:
SunsamaClientvới xác thực email/password hoặc session tokenCấu trúc:
Sử dụng trong các package khác:
Review & Testing Checklist for Human
pnpm installvàpnpm run typecheckpass thành công@workspace/sunsama-apicó thể import được từ các package khác (ví dụ: api-server)Notes
lib/integrations/sunsama-api/theo workspace patternlib/integrations/*đã có sẵn trongpnpm-workspace.yamldist/,*.tsbuildinfo) đã được gitignoreLink to Devin session: https://app.devin.ai/sessions/03643b5d5c78409099bb9567ea048010
Requested by: @TanUIUX