Skip to content

fix(types): allow round-trip of export → create (closes #34)#35

Merged
rarce merged 3 commits into
mainfrom
feat/issue-34-types-roundtrip
May 7, 2026
Merged

fix(types): allow round-trip of export → create (closes #34)#35
rarce merged 3 commits into
mainfrom
feat/issue-34-types-roundtrip

Conversation

@rarce
Copy link
Copy Markdown
Contributor

@rarce rarce commented May 7, 2026

Summary

  • parseSchema now detects DocumentType payloads ({id, codeType, jsonSchema, ...}) and unwraps the inner jsonSchema, so types exporttypes create works without piping through jq. Raw JSON Schema input keeps the previous behavior.
  • Added an example to types create --help showing the round-trip flow.
  • Cleaned up the conversionMode cast in types create and added a comment explaining why it stays: docutray@0.1.3 does not yet declare conversionMode on DocumentType. Worth filing a follow-up in docutray-node to add it; once that ships the cast can go.

Closes #34.

Acceptance criteria

  • parseSchema detects {jsonSchema: {...}, ...} payloads and extracts jsonSchema.
  • If jsonSchema is absent, original behavior is preserved.
  • Test verifies the round-trip with a full DocumentType payload (file + inline).
  • Test verifies a raw schema ({type: 'object', ...}) still parses unchanged.
  • types create --help example shows the export → create flow.
  • conversionMode cast documented; SDK follow-up flagged.

Test plan

  • npm run build
  • npm run test — 166 tests pass (10 new in test/parse-schema.test.ts)
  • Manual smoke: docutray types export <code> -o /tmp/t.json && docutray types create --name "X" --code x_copy --description "..." --schema /tmp/t.json

🤖 Generated with Claude Code

`parseSchema` now detects full DocumentType payloads (the shape returned by
`types export` / `types get` since #33) and unwraps the inner `jsonSchema`.
Raw JSON Schema input keeps working unchanged. This removes the need for
`jq .jsonSchema` between export and create.

Also add a comment around the conversionMode cast in `types create`
explaining why it stays: `docutray@0.1.3` does not yet declare
`conversionMode` on the DocumentType type.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

@rarce rarce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review

Findings

  • Low: acceptance criterion in #34 asked for a follow-up issue in docutray-node to add conversionMode to the DocumentType type. Comment in code explains the cast but the follow-up issue is not linked. Worth opening before/after merge.

Validation

  • Tests: 166 passing (10 new in test/parse-schema.test.ts), CI matrix Node 20/22 ✅
  • Build: npm run build clean, package-verification
  • Mergeability: MERGEABLE / CLEAN

Recommendation: Ready to merge. The round-trip heuristic is correct, raw-schema path preserved, edge cases covered (jsonSchema null / non-object / array).

@rarce
Copy link
Copy Markdown
Contributor Author

rarce commented May 7, 2026

Follow-up para el cast filed: docutray/docutray-node#21. Una vez mergeado allá, el cast en src/commands/types/create.ts se puede eliminar.

rarce and others added 2 commits May 7, 2026 14:41
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
docutray-node 0.1.4 (PR #22) exposes `conversionMode` on `DocumentType`
and re-exports a shared `ConversionMode` type. Replace the unknown casts
in `types create` and `types update` with direct field access and the
imported type alias.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rarce
Copy link
Copy Markdown
Contributor Author

rarce commented May 7, 2026

Bumped docutray to ^0.1.4 (commit 980dbc7) — SDK now exposes conversionMode on DocumentType (docutray-node#22). Removed the unknown cast in types create and switched both create and update to use the exported ConversionMode type alias. All 166 tests still pass.

This closes the last open acceptance criterion of #34 ("limpiar el cast usando acceso directo si SDK lo expone").

@rarce rarce merged commit 235439c into main May 7, 2026
6 checks passed
@rarce rarce deleted the feat/issue-34-types-roundtrip branch May 7, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: round-trip de types export/create + limpieza de casts post-SDK-0.1.3

1 participant