Migrate custom types to shared-schemas (#17)#21
Migrate custom types to shared-schemas (#17)#21misran3 wants to merge 3 commits intoInsForge:mainfrom
Conversation
- Add DeploymentSchema to shared-schemas re-exports - Remove custom SiteDeployment interface - Update deploy.ts and status.ts to use DeploymentSchema - Fix error handling to read from metadata.error.errorMessage - Remove deploymentUrl field usage (only url exists in API) - Use typed status enum instead of string comparisons
WalkthroughThis PR consolidates deployment-related types by removing local type definitions from src/types.ts and re-exporting them from the shared-schemas package. Related deployment command files are updated to use DeploymentSchema instead of SiteDeployment, with corresponding updates to error extraction and URL determination logic. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use your project's `biome` configuration to improve the quality of JS/TS/CSS/JSON code reviews.Add a configuration file to your project to customize how CodeRabbit runs |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/deployments/status.ts (1)
41-41: Extract deployment error parsing into a local variable/helper.This inline cast chain is hard to scan and maintain; pulling it into named variables will make this branch easier to read and keep aligned with deployment polling logic.
♻️ Proposed refactor
if (json) { outputJson(d); } else { + const metadata = d.metadata as { error?: { errorMessage?: string } } | null; + const hasError = Boolean(metadata?.error); + const errorMessage = metadata?.error?.errorMessage ?? 'Unknown error'; + outputTable( ['Field', 'Value'], [ ['ID', d.id], ['Status', d.status], ['Provider', d.provider ?? '-'], ['Provider ID', d.providerDeploymentId ?? '-'], ['URL', d.url ?? '-'], ['Created', new Date(d.createdAt).toLocaleString()], ['Updated', new Date(d.updatedAt).toLocaleString()], - ...((d.metadata as Record<string, unknown> | null)?.error ? [['Error', ((d.metadata as Record<string, unknown>).error as { errorMessage?: string })?.errorMessage ?? 'Unknown error']] : []), + ...(hasError ? [['Error', errorMessage]] : []), ], ); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/deployments/status.ts` at line 41, The inline cast chain reading d.metadata should be extracted into a named local variable or small helper (e.g., getDeploymentErrorMessage or parseDeploymentError) so the branch is easier to read and reuse with the deployment polling logic; inside status.ts create a const metadata = d.metadata as Record<string, unknown> | null, then const err = metadata?.error as { errorMessage?: string } | undefined and const errorMessage = err?.errorMessage ?? 'Unknown error', and replace the inline chain with a reference to that errorMessage (or call the helper) where the Error row is built and in any polling code that needs the same parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/commands/deployments/status.ts`:
- Line 41: The inline cast chain reading d.metadata should be extracted into a
named local variable or small helper (e.g., getDeploymentErrorMessage or
parseDeploymentError) so the branch is easier to read and reuse with the
deployment polling logic; inside status.ts create a const metadata = d.metadata
as Record<string, unknown> | null, then const err = metadata?.error as {
errorMessage?: string } | undefined and const errorMessage = err?.errorMessage
?? 'Unknown error', and replace the inline chain with a reference to that
errorMessage (or call the helper) where the Error row is built and in any
polling code that needs the same parsing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ca3ad957-5773-4bb5-a063-55266a87dab4
📒 Files selected for processing (3)
src/commands/deployments/deploy.tssrc/commands/deployments/status.tssrc/types.ts
Closes #17
Summary
Migrates custom type definitions to use
@insforge/shared-schemastypes where equivalents exist:Changes
Type Migrations
CreateDeploymentResponse,StartDeploymentRequest, andDeploymentSchemato shared-schemas re-exports intypes.tstypes.tsFunctionResponseto useFunctionSchemafrom shared-schemas for the innerfunctionpropertyFile Updates
metadata.error.errorMessage, removeddeploymentUrlfield usage (onlyurlexists in API), uses typed status enumTest Plan
npm run build)npx tsc --noEmit)npm run lint)Summary by CodeRabbit