GT ClassMethodsTranslation

checkJobStatus

API reference for the checkJobStatus method to monitor job progress

Overview

The checkJobStatus method checks the current status of one or more project jobs by their unique identifiers. This method is used to monitor the progress of asynchronous operations initiated by setupProject or enqueueFiles.

const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' });

const status = await gt.checkJobStatus(['job-123', 'job-456']);
console.log(`Job status: ${status.status}`);

To check the status of a setup job, you must first call both uploadSourceFiles and setupProject.

Reference

Parameters

NameTypeDescription
jobIdsstring[]Array of unique job identifiers to check
timeoutMs?numberOptional timeout in milliseconds for the API request

Returns

Promise<CheckJobStatusResult> - Contains the current job status and related information.

type CheckJobStatusResult = {
  jobs: {
    jobId: string;
    status: JobStatus;
    error?: { message: string };
  }[];
}
PropertyTypeDescription
jobsobject[]Array of job status objects
jobs[].jobIdstringThe job identifier that was checked
jobs[].statusJobStatusCurrent status of the job
jobs[].error?{ message: string }Error information if status is 'failed'

JobStatus

type JobStatus = 'queued' | 'processing' | 'completed' | 'failed';
  • 'queued' - Job is waiting to be processed
  • 'processing' - Job is currently being executed
  • 'completed' - Job finished successfully
  • 'failed' - Job encountered an error and failed

Example

Basic status checking

import { GT } from 'generaltranslation';

const gt = new GT({
  projectId: 'your-project-id',
  apiKey: 'your-api-key'
});


const fileRefs = [
  {
    fileId: 'file-123',
    versionId: 'version-456',
    branchId: 'branch-789',
    fileName: 'app.json',
    fileFormat: 'JSON'
  },
  {
    fileId: 'file-789',
    versionId: 'version-012',
    branchId: 'branch-789',
    fileName: 'content.md',
    fileFormat: 'MD'
  }
];

const setupResult = await gt.setupProject(fileRefs);

async function pollJobStatus(jobIds: string[]) {
  const status = await gt.checkJobStatus(jobIds);

  status.jobs.forEach(job => {
    console.log(`Job ${job.jobId}:`);
    console.log(`  Status: ${job.status}`);

    if (job.error) {
      console.log(`  Error: ${job.error.message}`);
    }
  });

  return status;
}

const jobStatus = await pollJobStatus([setupResult.jobId]);

Notes

  • Setup automatically runs when elements of context are missing.
  • Setup is responsible for corpus analysis, context generation, glossary generation, etc.
  • Job IDs are returned by setupProject or enqueueFiles and should be stored for status checking
  • You can check multiple jobs in a single call for efficiency

Next steps

How is this guide?