trigger.dev icon indicating copy to clipboard operation
trigger.dev copied to clipboard

[TRI-1923] React hooks should return basic metadata about the Job

Open matt-aitken opened this issue 1 year ago • 0 comments

If you want to build a UI that shows runs across multiple jobs it's difficult because the hooks return no info about the job.

I suggest we return the job "id" from them (which is actually the slug in the database).

{
  job {
   //note that this is what we call the "slug" in the database
    id: "......",
  },
  //rest of the payload
}

This would creating v3 versions of the following API endpoints that return the job.id

  1. https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/routes/api.v2.runs.%24runId.ts
  2. https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/routes/api.v2.runs.%24runId.statuses.ts
  3. https://github.com/triggerdotdev/trigger.dev/blob/main/apps/webapp/app/routes/api.v2.events.%24eventId.ts

Core schema updates (add job.id)

  • GetRunStatusesSchema: https://github.com/triggerdotdev/trigger.dev/blob/29edcd3df96e333b123c0124c764588db71fb382/packages/core/src/schemas/api.ts#L1061
  • GetRunSchema: https://github.com/triggerdotdev/trigger.dev/blob/29edcd3df96e333b123c0124c764588db71fb382/packages/core/src/schemas/runs.ts#L107
  • GetEventSchema: https://github.com/triggerdotdev/trigger.dev/blob/29edcd3df96e333b123c0124c764588db71fb382/packages/core/src/schemas/events.ts#L4

The SDK API client URLs need updating to be v3 instead of v2

  • getEvent
  • getRun
  • getRunStatuses https://github.com/triggerdotdev/trigger.dev/blob/main/packages/trigger-sdk/src/apiClient.ts#L446

The React package URLs need updating to be v3 instead of v2:

  • https://github.com/triggerdotdev/trigger.dev/blob/main/packages/react/src/events.ts
  • https://github.com/triggerdotdev/trigger.dev/blob/main/packages/react/src/runs.ts
  • https://github.com/triggerdotdev/trigger.dev/blob/main/packages/react/src/statuses.ts

TRI-1923

matt-aitken avatar Feb 06 '24 14:02 matt-aitken