Skip to content

feat(inquiries): finish the tRPC→SDK migration (16 client methods + 7 endpoints missing) #443

Open

Description

@thinkclay

Split from #440. The reported symptom is "Unable to load inquiry" on /jobs/applications/:id/inquiry; the cause is that the tRPC→SDK migration for inquiries was never finished.

Cause

getByApplication does not exist on the SDK. packages/scf-core/utils/inquiries-sdk-hooks.ts:190 does:

return (client.inquiries as unknown as InquiryCapabilityClient).getByApplication(applicationId)

The as unknown as cast suppresses the type error, so it fails at runtime and the route's error || !data branch renders the red message. The type file admits it: "tRPC migration - methods may not exist on SDK yet". Only the legacy tRPC router has a real implementation.

Scope

  • Of the 19 methods on InquiryCapabilityClient, the SDK implements 3. 16 are missing, all reached through the same unsafe cast (16 occurrences in inquiries-sdk-hooks.ts): createTemplate, updateTemplate, deleteTemplate, applyTemplate, getSmartDefaults, createBulk, getByApplication, getMultiple, send, addComment, markCommentRead, acceptSection, submitCapabilityResponse, update, changeStatus.
  • packages/supabase/functions/api/routes/inquiries.ts exposes only GET /v1/inquiries and POST /v1/inquiries. 7 of the SDK's own 9 paths 404: getById, respond, templates, bulk/mark-read, bulk/archive, getTemplates, getHistory.
  • The route conflates three states into one red error: fetch failure, no inquiry exists, and nonexistent application. core.application_inquiries is empty locally, so every application shows the error even once the method exists.

Suggested sequencing

  1. getByApplication end-to-end (API route + SDK method + hook, cast removed) plus a real empty state on the route — unblocks the reported bug.
  2. Port the remaining 15 methods and their endpoints.
  3. Drop InquiryCapabilityClient and the casts once the SDK surface is complete.
  4. Lint rule banning as unknown as on SDK clients — that cast is what let this ship silently.

Activity

  1. thinkclay commented on Jul 30, 2026

    @thinkclay
    ContributorAuthor

    Step 1 is done; the sequencing in the description needs revising

    getByApplication shipped end-to-end in #475 + Scaffald/sdk#11: the endpoint, the SDK method, the cast removed at that one call site, and the empty state split out of the error branch on both inquiry routes. The reported page loads.

    15 methods still missing, all still reached through as unknown as InquiryCapabilityClient in inquiries-sdk-hooks.ts: createTemplate, updateTemplate, deleteTemplate, applyTemplate, getSmartDefaults, createBulk, getMultiple, send, addComment, markCommentRead, acceptSection, submitCapabilityResponse, update, changeStatus.

    Resolve #476 before porting the rest

    The description's step 2 said "port the remaining 15 methods." That is now blocked on a naming decision, because core.inquiries does not exist in the database (#476). Two unrelated concepts share the name inquiries:

    Concept Table State
    Sender/recipient messaging (sender_id, subject, message) core.inquiries never created — list/create/respond/templates/bulk* all 500
    ATS capability inquiry core.application_inquiries (+ 6 related tables) exists; this is what the app's inquiry pages need

    Whether the remaining 15 belong on client.inquiries or on a new client.applicationInquiries depends on which concept survives. Porting them under the current name would cement the conflation.

    Two things to expect when you do port them

    1. Don't trust the tRPC source as a schema reference. Its getByApplication selects applied_at and application_score; neither column exists on core.applications, so that query 400s. Real columns are created_at and score_total. Validate every select against a live DB — that is how this surfaced.
    2. Removing a cast is where the real bugs appear. The single cast removed in fix(inquiries): make the application inquiry page actually load #475 immediately exposed two wrong types that had been invisible: InquiryComment was missing three NOT NULL fields, and capabilityResponses denied null on two nullable columns. Expect similar per method, and treat that as the point of the exercise rather than an obstacle.

    Also still open from the description: the lint rule banning as unknown as on SDK clients. Worth doing last, once the surface is complete, so it does not just block work in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: hightype: backend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions