Errors and utilities

Types and constants

client.models is a Models, client.documents a Documents, client.jobs a Jobs and client.extractionSchemas an ExtractionSchemas. The decision types are in Answer types and Request types, and the parameter types in each method's section above. The document types:

Job types

TypeWhat it is
DocumentJobA job as the document service sends it: job_id, kind (a DocumentOperation), status (a JobStatus), result, usually once it has succeeded (null again once retention drops it; Classify may include a partial one while still running, with reason_status), error, credits (final once usage_final is true), usage_final, created_at, and every other field the service sends, such as result_state: "available", or why a finished job's result is null ("expired" or "not_retained").
DocumentJobListitems (DocumentJob[]) and next_cursor, null on the last page.
DocumentOperation"parse" | "split" | "classify" | "extract" | "ground", or another string a newer service sends.
JobStatus"queued" | "running" | "succeeded" | "failed" | "cancelled", or another string a newer service sends.
JobEventOne event from jobs.events: sequence, at, status, progress, message.

Source types

TypeWhat it is
SourceInput, Source, UrlSource, WorkspaceFileSource, ParseResultSourceSee Sources.

Upload types

TypeWhat it is
UploadedFileworkspace_id, file_id, path and the service's other file fields.
UploadGrant, UploadSession, UploadSessionStatus, FileDeletionSee Uploads.
OnConflict"reject" | "new_version".
FileContentBlob | Uint8Array | ArrayBuffer.

Job file types

TypeWhat it is
JobRequestThe request echo from jobs.getRequest: request_type and the request's fields.
FileLinkurl and expires_at, in Unix seconds.
RowsPage, RowsColumnA page from jobs.rows, and one of its columns.

Schema types

TypeWhat it is
ExtractionSchema, ExtractionSchemaListSee Saved schemas.

Constants

Client constants

The defaults and environment variable names the client uses:

ConstantValueDescription
DEFAULT_BASE_URL"https://console.nace.ai"The API root when neither baseURL nor NACE_BASE_URL is set.
DEFAULT_MODEL"drex-latest"The model when neither defaultModel nor NACE_DEFAULT_DECISION_MODEL is set.
DEFAULT_TIMEOUT_MS60000The default timeout.
ENV{ apiKey, baseURL, defaultModel, logLevel }The environment variable for each option, from "NACE_API_KEY" to "NACE_LOG_LEVEL". EnvVar is the union of the four names.
LEGACY_ENV{ NACE_API_KEY, NACE_BASE_URL, NACE_DEFAULT_DECISION_MODEL, NACE_LOG_LEVEL }Each variable's name before the rename, "DREX_API_KEY" to "DREX_LOG_LEVEL", read when the new one is unset or blank.
LOG_LEVELS["debug", "info", "warn", "error", "off"]Every LogLevel.
VERSION"0.2.0"The package version, sent as User-Agent and X-Nace-SDK: nace-sdk/<VERSION>.

Document constants

The document tools and jobs:

ConstantValueDescription
DOCUMENT_OPERATIONS["parse", "split", "classify", "extract", "ground"]The five tools.
JOB_STATUSES["queued", "running", "succeeded", "failed", "cancelled"]Every job status.
TERMINAL_STATUSESReadonlySet of "succeeded", "failed", "cancelled"The statuses a job finishes in.
MAX_WAIT_SECONDS60The longest wait_seconds.
MAX_ROWS_PAGE_SIZE100The largest jobs.rows limit.
UPLOAD_SESSION_THRESHOLD_BYTES33554432 (32 MiB)The size from which upload sends a file in parts.
import { TERMINAL_STATUSES } from "nace-sdk";

const job = await client.jobs.get(jobId);
if (!TERMINAL_STATUSES.has(job.status)) console.log("still running");

On this page