Workspace Config

Reading and writing workspace-wide settings with getConfig() and setBusinessTimezone(), including the WorkspaceConfig shape and IANA timezone validation.

Every workspace carries a small bag of business-wide settings, persisted as its own record. You read and write it through methods on the workspace itself — there is no need to reach for the underlying provider.

config.ts
import { Workspace } from "wative-core";

const ws = await Workspace.open({ path: "./my-wallet", password: "wsp-pwd" });

await ws.setBusinessTimezone("America/New_York");
await ws.getConfig(); // { businessTimezone: "America/New_York" }

All three members below require a live session. Calling them on a locked workspace throws WORKSPACE_LOCKED; on a closed one, UNSUPPORTED_OP.

getConfig() and the config snapshot

There are two ways to read the config, differing only in sync-vs-async and mutability.

MemberSignatureReturns
getConfig()getConfig(): Promise<WorkspaceConfig>A fresh plain copy of the current config.
configget config(): WorkspaceConfigA frozen shallow copy, read synchronously.

Both hand back a copy, never the live internal object, so mutating the result never changes stored state. The config getter goes further and freezes what it returns — assigning to a field on it is a silent no-op:

frozen-snapshot.ts
const snapshot = ws.config;
Object.isFrozen(snapshot); // true

snapshot.settlementWindow = "ny-close";
snapshot.settlementWindow; // undefined — the write did nothing

To change a setting, go through a writer method such as setBusinessTimezone(), which persists and then updates the in-memory copy.

setBusinessTimezone()

set-timezone.ts
setBusinessTimezone(timezone: string): Promise<void>

Sets the workspace's business timezone. The value is validated as an IANA timezone, written to the config record, and only then committed in memory. Valid IANA identifiers include region names and the Etc/ and UTC forms:

valid-values.ts
await ws.setBusinessTimezone("UTC");
await ws.getConfig(); // { businessTimezone: "UTC" }

await ws.setBusinessTimezone("Etc/UTC");
await ws.getConfig(); // { businessTimezone: "Etc/UTC" }

The setting round-trips a lock/reopen cycle like every other persisted record.

WorkspaceConfig

The config is an open-ended object with one known field:

workspace-config.ts
interface WorkspaceConfig {
  businessTimezone?: string;
  readonly [key: string]: unknown;
}

The index signature means additional keys may appear over time; businessTimezone is the one the current API reads and writes.

IANA timezone validation

An invalid timezone is rejected before anything is written. setBusinessTimezone() validates the argument by constructing an Intl.DateTimeFormat with it; a non-string, an empty/whitespace string, or an unrecognized identifier all fail the same way — a WativeError with:

  • code === "PARAMETER_ERROR", and
  • a message containing the token INVALID_BUSINESS_TIMEZONE.
reject-invalid.ts
try {
  await ws.setBusinessTimezone("Not/AZone");
} catch (err) {
  err.code;                                   // "PARAMETER_ERROR"
  /INVALID_BUSINESS_TIMEZONE/.test(err.message); // true
}

Last updated on