feat: add canvas create command#65
Conversation
| * be unit-tested without a network call. document_content is JSON-stringified | ||
| * to match how the Slack API expects nested objects over form-encoding. | ||
| */ | ||
| export function buildCreateParams(input: { |
There was a problem hiding this comment.
Major: tested function is not the one that runs
Why: buildCreateParams duplicates the param logic in SlackClient.createCanvas (slack-client.ts:461-470), but the create action only calls createCanvas. The 6 unit tests assert on buildCreateParams, so the production builder is untested and the suite stays green even if it breaks. Two copies will drift.
Fix: keep one builder (in the client), test that one, and remove buildCreateParams.
| > |---|:---:|:---:| | ||
| > | `canvas list` | ✅ | ✅ | | ||
| > | `canvas read` | ✅ | ✅ | | ||
| > | `canvas create` | ✅ (needs `canvases:write`) | ❌ | |
There was a problem hiding this comment.
Major: contradictory browser-token claim
Why: this table says canvas create with a browser token is not supported, but CHANGELOG.md:15 says it requires canvases:write "or browser auth" and the PR body says it works with both. The code routes through request() which dispatches to browserRequest, and only a standard token was live-tested, so the not-supported claim is unverified and inconsistent.
Fix: test canvases.create with a browser token, then make README and CHANGELOG agree.
| markdown: string; | ||
| } | ||
|
|
||
| export interface CanvasCreateOptions { |
There was a problem hiding this comment.
Minor: unused types
Why: CanvasCreateOptions and CanvasDocumentContent are never imported. The action's options is untyped and both builders inline JSON.stringify({type:'markdown', markdown}) instead of CanvasDocumentContent.
Fix: type the action param as CanvasCreateOptions and use CanvasDocumentContent, or remove the types.
Summary
Adds
slackcli canvas create— the C in canvas CRUD. First of a 3-PR series (create → edit → delete) building on #31 (list + read).Closes #62
What's added
canvas createsubcommand —--title,--content/--file/--stdin(mutually-exclusive markdown sources),--channel,--json,--workspace.SlackClient.createCanvas()→ wrapscanvases.create, JSON-wrapsdocument_contentas{type:"markdown", markdown}. No auth-type special-casing — routes through the existingrequest()dispatcher (works with standard + browser tokens).CanvasCreateOptions,CanvasDocumentContent.xoxb/xoxp) withcanvases:write; browser tokens (xoxc/xoxd) can't do canvas CUD; list + read work with both.Tests
src/commands/canvas.test.ts— unit tests forbuildCreateParams(title-only, markdown→document_content, channel→channel_id, empty) andresolveCanvasMarkdown(mutual exclusion, inline content, missing-file error).bun test→ 188 pass / 0 fail.bun run build→ ok.xoxptoken: created a canvas tabbed into a channel;canvas_idreturned.Manual Tests
Notes
bun run type-checksurfaces one pre-existing error insrc/lib/workspaces.ts(existsimported fromfs/promises, a Bun runtime extensiontscdoesn't model) — present onmain, untouched by this PR. This PR adds zero new type errors.