Skip to content

feat(codegen): semantic question types, INPUT_OBJECT dot-notation, --no-tty flag#785

Merged
pyramation merged 3 commits intomainfrom
devin/1772752266-cli-codegen-improvements
Mar 6, 2026
Merged

feat(codegen): semantic question types, INPUT_OBJECT dot-notation, --no-tty flag#785
pyramation merged 3 commits intomainfrom
devin/1772752266-cli-codegen-improvements

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Mar 5, 2026

feat(codegen): semantic question types, INPUT_OBJECT dot-notation, --no-tty flag

Summary

Three CLI codegen improvements to the generated csdk commands:

  1. Semantic question types for table CRUD: Boolean fields now generate type: 'boolean' and JSON/GeoJSON fields generate type: 'json' instead of everything being type: 'text'. Implemented via new getQuestionTypeForField() in table-command-generator.ts.

  2. INPUT_OBJECT dot-notation flattening: When custom commands have INPUT_OBJECT args (e.g. input: SignUpInput), the inner fields are now named with dot-notation (input.email, input.password) instead of losing the parent name. A new unflattenDotNotation() utility (using nested-obj) reconstructs the nested structure from flat CLI answers. Replaces parseMutationInput in generated imports.

  3. --no-tty flag: CLI entry points now accept --no-tty as a shorthand for --tty false for non-interactive/scripted usage.

All changes propagate through codegen → regenerated constructive-cli output (141 files touched).

Dependency: Requires inquirerer@4.7.0 for 'boolean' and 'json' type support — published via dev-utils PR #69 (merged). The constructive-cli package.json has been bumped to "inquirerer": "^4.7.0".

Updates since last revision

  • inquirerer@4.7.0 published — dependency blocker resolved
  • Bumped inquirerer from ^4.6.0 to ^4.7.0 in sdk/constructive-cli/package.json
  • Regenerated all CLI code — builds cleanly with zero @ts-nocheck or type suppressions
  • CI: 41/41 checks pass

Review & Testing Checklist for Human

  • Test semantic types at runtime: Create/update a table with Boolean or JSON fields via the generated CLI and verify the prompts use confirm/json input instead of text. The boolean and json question types are new in inquirerer@4.7.0 — verify they handle edge cases (e.g., "true"/"false" string coercion, malformed JSON input).
  • Test dot-notation INPUT_OBJECT: For custom commands that flatten INPUT_OBJECT args (e.g. sign-up, verify-password), verify that:
    • CLI flags like --input.email foo work correctly
    • unflattenDotNotation() correctly reconstructs { input: { email: 'foo' } } before sending to the ORM
    • Note: Some custom commands may NOT flatten if schema introspection doesn't populate inputFields — this is expected fallback behavior
  • Verify parseMutationInputunflattenDotNotation swap: The old parseMutationInput attempted to JSON.parse string values. The new unflattenDotNotation only restructures dot-notation keys. Confirm no custom commands relied on the JSON-parsing behavior of the old function.
  • Test --no-tty flag: Run a CLI command with --no-tty and verify non-interactive mode works (no prompts, uses defaults/CLI flags only).

Recommended Test Plan

  1. Run pnpm run generate in sdk/constructive-cli to verify regeneration
  2. Test Boolean field CRUD: csdk public app-grant create --appId <uuid> --isGrant true
  3. Test JSON field CRUD: csdk public view create --name test --data '{"key":"value"}'
  4. Test --no-tty: csdk public user list --no-tty
  5. Test custom command with INPUT_OBJECT: csdk public sign-up --input.email test@example.com --input.password secret

Notes

  • Codegen tests: All 301 tests pass, 121 snapshots updated
  • Int/Float types: Currently NOT mapped to type: 'number' — they remain as type: 'text'. If this was intended to be included, it's missing from getQuestionTypeForField().
  • Partial INPUT_OBJECT flattening: Dot-notation only works where schema introspection populates inputFields on INPUT_OBJECT types. Some custom commands may not get this data and will fall back to single text input.
  • Dead code: parseMutationInput() still exists in template but is no longer imported by generated commands (replaced by unflattenDotNotation). Not a breaking change since the function is still exported.

Link to Devin Session: https://app.devin.ai/sessions/0852119907284bb4a09c1910ef213240
Requested by: @pyramation

…no-tty flag

1. Semantic question types in table CRUD commands:
   - Boolean fields use type: 'boolean' instead of 'text'
   - JSON/GeoJSON fields use type: 'json' instead of 'text'
   - Maps GraphQL scalar types to appropriate inquirerer question types

2. INPUT_OBJECT dot-notation flattening with nested-obj:
   - Flattened INPUT_OBJECT fields use dot-notation names (e.g. input.email)
   - Added unflattenDotNotation() to reconstruct nested objects from CLI answers
   - Custom commands use unflattenDotNotation instead of parseMutationInput

3. --no-tty flag support in CLI entry point:
   - Added process.argv.includes('--no-tty') check alongside existing --tty false

Updated test snapshots and regenerated constructive-cli code.
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 0b191a2 into main Mar 6, 2026
43 checks passed
@pyramation pyramation deleted the devin/1772752266-cli-codegen-improvements branch March 6, 2026 01:25
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.

1 participant