Commit 5560181
feat: idempotent workspace creation — same name+owner returns existing (#115)
* feat: idempotent workspace creation — same name+owner returns existing
Same API key + same name returns existing workspace (200).
Different API keys can share workspace names.
Changes:
- engine/workspace.ts — createWorkspace returns existing if same name+apiKeyHash
- routes/workspace.ts — returns 200 for existing, 201 for new
- sdk relay.ts — ensureWorkspace simplified (no 409 dependency)
- local main.rs — matches server idempotent behavior
- types/workspace.ts — CreateWorkspaceResult type
- openapi.yaml — updated responses (200 added, 409 removed)
- README.md — updated docs
- tests updated
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add engine integration tests for idempotent workspace creation
Tests with real SQLite DB (via FakeD1):
- New workspace returns created: true
- Same name + same API key returns existing (created: false)
- Same name + different keys creates separate workspaces
- ownerApiKeyHash lookup works
- Anonymous creates always produce new workspaces
- Conflicting key + hash throws
- getWorkspaceByName handles duplicates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* update openapi
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9f6a2c9 commit 5560181
11 files changed
Lines changed: 786 additions & 163 deletions
File tree
- packages
- local/src
- sdk-typescript/src
- __tests__
- server/src
- __tests__
- engine
- routes
- __tests__
- types/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | | - | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
251 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
53 | 69 | | |
54 | 70 | | |
55 | 71 | | |
| |||
345 | 361 | | |
346 | 362 | | |
347 | 363 | | |
348 | | - | |
| 364 | + | |
349 | 365 | | |
350 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
351 | 370 | | |
352 | 371 | | |
353 | 372 | | |
| |||
360 | 379 | | |
361 | 380 | | |
362 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
363 | 393 | | |
364 | 394 | | |
365 | 395 | | |
| |||
370 | 400 | | |
371 | 401 | | |
372 | 402 | | |
373 | | - | |
| 403 | + | |
374 | 404 | | |
375 | 405 | | |
376 | 406 | | |
377 | 407 | | |
378 | 408 | | |
379 | 409 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | 410 | | |
387 | 411 | | |
388 | 412 | | |
| |||
0 commit comments