feat: add user-template write endpoints to TemplateClient#604
Draft
scottlovegrove wants to merge 4 commits into
Draft
feat: add user-template write endpoints to TemplateClient#604scottlovegrove wants to merge 4 commits into
scottlovegrove wants to merge 4 commits into
Conversation
doistbot
reviewed
May 15, 2026
Member
doistbot
left a comment
There was a problem hiding this comment.
This PR successfully expands the SDK's TemplateClient by introducing the full suite of write and file-import endpoints for user templates. The thorough test coverage and careful Zod schema modeling provide a solid foundation for these new capabilities. There are just a few remaining details to refine, such as addressing a bug that prevents the file upload optimization from working, strengthening types with ColorKey and enums, centralizing the URL-encoding logic, and removing some duplication in the test mocks and argument interfaces.
e17320e to
372d20a
Compare
Adds createUserTemplate, updateUserTemplate, deleteUserTemplate, previewUserTemplateFromFile, and createUserTemplateFromFile to the SDK, exposing the full /templates/user/* surface for managing user-owned templates. These endpoints are live but not in the public OpenAPI spec. - Define UpdateUserTemplateResponseSchema (TemplateSchema extended with status: 'ok'), DeleteUserTemplateResponseSchema, and PreviewUserTemplateFromFileResponseSchema, all mirroring the server TypedDicts in todoist/apps/import_export/controllers/user_templates.py. - createUserTemplate / createUserTemplateFromFile reuse the existing TemplateSchema validator since both return a plain Template. - updateUserTemplate / deleteUserTemplate reject empty templateId before hitting the network and URL-encode the path segment. - createUserTemplateFromFile forwards optional uploadedFileName so callers can chain preview → create without re-uploading the CSV. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The server returns items / notes / project_notes for /templates/user/preview_from_file, matching the wire shape of /templates/import_into_project. The rest of the SDK exposes those as tasks (items) and comments (notes), so PreviewUserTemplateFromFileResponseSchema now does the same: - items → tasks - notes + project_notes → comments (concatenated; CommentSchema already accepts both task-scoped notes via itemId and project-scoped notes via projectId) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Move encodeURIComponent into getUserTemplateEndpoint so any future caller picks up the encoding automatically, and drop the now-redundant inline encoding in updateUserTemplate / deleteUserTemplate. - Allow createUserTemplateFromFile to skip re-uploading when uploadedFileName is provided: make `file` optional, validate that at least one of file or uploadedFileName is set, and send a regular JSON POST (no multipart) when no file is supplied. - Tighten PreviewUserTemplateFromFileResponseSchema.templateType to z.enum(TEMPLATE_TYPE_VALUES) to match TemplateSchema. - Replace stringly-typed color: string | number with ColorKey | number across CreateUserTemplateArgs / UpdateUserTemplateArgs / CreateUserTemplateFromFileArgs. - Extract a shared TemplateFileUpload alias (Pick<UploadFileArgs, 'file' | 'fileName'>) and reuse it across CreateProjectFromTemplateArgs, ImportTemplateIntoProjectArgs, PreviewUserTemplateFromFileArgs, and CreateUserTemplateFromFileArgs. - Derive MOCK_TEMPLATE_CAMEL dynamically via camelCaseKeys(MOCK_TEMPLATE_API). - Add tests for deleteUserTemplate URL-encoding, JSON-only import path (uploadedFileName without file), and the missing-input rejection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
372d20a to
96099fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacks on top of #603. Adds the full
/templates/user/*surface to the SDK:createUserTemplate—POST /templates/userupdateUserTemplate(id, args)—PUT /templates/user/{id}deleteUserTemplate(id)—DELETE /templates/user/{id}previewUserTemplateFromFile—POST /templates/user/preview_from_file(multipart)createUserTemplateFromFile—POST /templates/user/import(multipart, acceptsuploadedFileNamefrom a prior preview)updateUserTemplate/deleteUserTemplatevalidatetemplateIdis non-empty before any network call and URL-encode the path segment.Test plan
npm run check(oxlint + oxfmt) passesnpm test— 602 tests pass (9 new)uploadedFileNamepass-through🤖 Generated with Claude Code