Errors and utilities

Types and constants

client.models is a Models, client.documents a Documents, client.jobs a Jobs, client.extractionSchemas an ExtractionSchemas, client.domains a Domains, client.storageConnections a StorageConnections, client.workspaces a Workspaces, client.workspaces.files a WorkspaceFiles and client.search a Search. 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 for Zero retention or a legacy expired result; Classify may include a partial one while still running, with reason_status), error, credits (final once usage_final is true), usage_final, cost? (when available, the recorded customer wallet charge; may be absent or null on deployments without component pricing), timing? (server measurements for every document kind, or null), created_at, started_at?, finished_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.

DocumentJob declares created_at?: string, started_at?: string | null and finished_at?: string | null. Start is null before execution and can stay null for a job ended before start; finish is null until NDI finishes. Both can be absent on a reduced running response during settlement, and a job Drex closes as cancelled for funding omits started_at even if NDI ran it. See Job timing.

Document timing

DocumentJob.timing?: DocumentTiming | null uses the original server request for both timers. Upload, browser network/rendering and idle time awaiting a later client read are excluded. Individual missing measurements are null. Finished newly measured Parse, Extract, Split, Classify and Ground jobs carry the object. Historical/unmeasured jobs and fallback list items may omit it or return null.

For Parse, first_response_ms measures the first usable server-published preview, even if your SDK call waits for the complete result and never reads previews. When the server confirms that no preview was published and total timing is available, it equals total_ms; unavailable measurements remain null. Waiting for completion does not select a delivery mode. Other document kinds use final total for first response and leave document finalization null; Classify's partial labels are not separately measured. See Job timing and Parse streaming.

TypeWhat it is
DocumentTimingreceived_at: string, observed_at: string, completed_at: string | null, elapsed_ms: number | null, total_ms: number | null, first_response_ms: number | null, breakdown: DocumentTimingBreakdown. Durations are milliseconds.
DocumentTimingBreakdownNullable millisecond values: preparation_ms, queue_ms, ndi_processing_ms, result_preparation_ms, delivery_wait_ms, document_finalization_ms. The first four sum to the total. delivery_wait_ms is excluded; document_finalization_ms is already inside NDI processing.

Each breakdown value is null until its endpoints are available and consistent: queue needs creation/start, NDI processing needs start/finish, result preparation needs finish/final response preparation, and document finalization needs preview publication/finish. delivery_wait_ms remains null until completion. Successful atomic jobs can keep document_finalization_ms: null. See Job timing for every field's availability; do not replace unknown components with zero.

Document costs

An optional cost?: DocumentCost | null on DocumentJob records the customer wallet charge and is null until settlement. These types are in nace-sdk 0.4.0 and later; npm's 0.3.0 was published without its build and can't be installed, so upgrade from 0.2.0 straight to 0.4.0.

TypeWhat it is
DocumentCostcurrency: "USD", pricing_version: string, total_usd: string, lines: DocumentCostLine[]. Exact decimal USD; separate from NDI’s service tariff.
DocumentCostLineoperation ("parse", "split", "classify", "extract", "ground"), quantity: number, unit ("page", "target"), execution ("fresh", "reused"), unit_price_usd: string, amount_usd: string, reuse_reason: string | null.

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.

Domain types

TypeWhat it is
DomainSummaryOne domain version, as list shows it: domain_id, slug, display_name, owner, version, status, parent_slug, class_count and selectable, true once published. owner is "platform", "tenant" or another string a newer service sends; status is "draft", "published" or another string a newer service sends.
DomainA DomainSummary plus taxonomy and published_at, null for a draft.
DomainValidationWhat a write found wrong with the taxonomy: valid, errors (each with code, path and message) and effective_class_count.
DomainWriteWhat every domain write returns: the saved domain and its validation.
DomainPageitems (DomainSummary[]), next_cursor, null on the last page, and total_count.

See Domains.

Storage connection types

TypeWhat it is
StorageConnectionA storage connection: id, name, destination, status, can_manage, external_id, aws_trusted_principal_arn (older; use aws_trusted_principal_arns), aws_trusted_principal_arns, credentials_pending, validation_running, credential_generation, validated_at, reactivation_requires_approval, revoked_reason, revoked_at and created_at. status is "draft", "ready", "degraded", "revoked" or another string a newer service sends; revoked_reason is "owner", "administrator", "member_removed", "user_disabled", another string a newer service sends, or null.
StorageConnectionPageitems (StorageConnection[]) and next_cursor, null on the last page.
StorageDestinationS3Destination | AzureBlobDestination.
S3Destinationtype ("s3"), bucket, region and prefix.
AzureBlobDestinationtype ("azure_blob"), account, container and prefix.
StorageCredentialAwsRoleCredential | AzureServicePrincipalCredential.
AwsRoleCredentialtype ("aws_role") and role_arn.
AzureServicePrincipalCredentialtype ("azure_service_principal"), tenant_id, client_id and client_secret.
StorageSetupOptionsS3SetupOptions | AzureSetupOptions.
S3SetupOptionstype ("s3"), access_method, aws_account_id, role_name and kms_key_arn.
AzureSetupOptionstype ("azure_blob"), subscription_id, resource_group, tenant_id and client_id.
StorageConnectionSetupoptions, trust_policy, permissions_policy, cloudformation_template, launch_url, role_arn and azure_cli.
WorkspaceStorageWhere a workspace keeps its files: type, connection_id, provider, location and health. type is "managed", "tenant_bucket", "external" (your own bucket or container) or another string a newer service sends; provider is "s3", "azure_blob", another string a newer service sends, or null; health is the connection's status, or null. For a workspace you were invited into, connection_id and location are null.

See Storage connections.

Workspace types

TypeWhat it is
WorkspaceA workspace: workspace_id, name, owner_user_id, access, domain_id, domain_slug, domain_version, config_version, storage (a WorkspaceStorage), created_at, updated_at and status, which is "active", "deleting", "unavailable" (in a list, a workspace the service no longer has: delete it to drop it) or another string a newer service sends.
WorkspacePageitems (Workspace[]), next_cursor, null on the last page, and total_count.
WorkspaceStatsfiles_total, bytes_total, files_by_ingestion_status, pages_ingested, index_documents, last_ingestion_at, next_expiry_at and files_expiring_within_7d.
WorkspaceAccesslabels and default_label. Each label has a name and a description; a workspace takes up to 16.
IngestionStatus"discovered" | "queued" | "ingesting" | "ingested" | "stale" | "expired" | "failed" | "not_required", or another string a newer service sends.

Workspace file types

TypeWhat it is
WorkspaceFileA file in a workspace: file_id, workspace_id, path, file_name, file_type, size_bytes, version, observed_hash, ingested_hash, ingestion_status, ingested_at, category, access_label, access_label_source, expires_at, labels, created_at and updated_at.
WorkspaceFilePageitems (WorkspaceFile[]), next_cursor, total_count and coverage.
WorkspaceFileDetailA WorkspaceFile plus download_url, preview_url and download_url_expires_at.
WorkspaceFileMetadatafile, lane, page_count, sheet_names, duration_ms, summary, keywords, documents, sheets, media, outputs, representations and last_error.
WorkspaceFileVersionversion, size_bytes, observed_hash, ingested_hash, ingested_at, created_at, replaced_at (null on the current one) and is_current.
WorkspaceFileVersionPageitems (WorkspaceFileVersion[]) and next_cursor.
WorkspaceFileOutputA derived file: output_id, kind, path, generation, created_at, download_url, preview_url and download_url_expires_at.
WorkspaceFileOutputMembersmembers (each with path, file_name, size_bytes, download_url and preview_url), total_count and download_url_expires_at.

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.7.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.
MAX_WORKSPACE_PAGE_SIZE200The largest limit of workspaces.list, workspaces.files.list, workspaces.files.versions and workspaces.files.outputMembers, and the page size workspaces.iterAll reads.
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");

Parse preview types

TypeWhat it is
ParsePreviewUnitindex (one-based integer), revision (string), content_url (authenticated string URL).
ParsePreviewSnapshotjob_id (string), status (queued/running/succeeded/failed/cancelled), nullable generation (string), nullable kind (page/sheet/section/segment), nullable total (integer), units (ParsePreviewUnit collection), more (boolean), optional nullable first_ready_at and all_ready_at (ISO timestamp strings). Terminal snapshots contain no units.
ParsePreviewContentgeneration (string), index (integer), label (string), markdown (string), truncated (boolean), ready_at (ISO timestamp string).

These provisional previews do not replace the final Parse result. See Streaming.

On this page