OpenDecree TypeScript SDK - v0.3.0-alpha.1
    Preparing search index...

    Class ConfigClient

    ConfigClient provides a promise-based API for reading and writing OpenDecree configuration values.

    const client = new ConfigClient('localhost:9090', { subject: 'myapp' });
    try {
    const fee = await client.get('tenant-id', 'payments.fee');
    const retries = await client.get('tenant-id', 'payments.retries', Number);
    } finally {
    client.close();
    }
    Index

    Constructors

    Accessors

    • get serverInfo(): Promise<ServerInfo>

      The server's info (version, commit, features), fetched once and cached. Returns a promise that resolves to the ServerInfo.

      Returns Promise<ServerInfo>

    Methods

    • Async dispose pattern support — use with await using.

      Returns Promise<void>

    • Dispose pattern support (TypeScript 5.2+).

      Returns void

    • Check that the server version is compatible with this SDK. Fetches the server info (cached) and compares against SUPPORTED_SERVER_VERSION.

      Returns Promise<void>

      IncompatibleServerError if the server is outside the supported range.

      UnavailableError if the server is unreachable.

    • Close the underlying gRPC channels.

      Returns void

    • Get a config value as a string (default).

      Parameters

      • tenantId: string
      • fieldPath: string

      Returns Promise<string>

    • Get a config value converted to the specified type.

      Parameters

      • tenantId: string
      • fieldPath: string
      • type: NumberConstructor
      • Optionaloptions: { signal?: AbortSignal; timeout?: number }

      Returns Promise<number>

    • Get a config value as a string (default).

      Parameters

      • tenantId: string
      • fieldPath: string
      • type: BooleanConstructor
      • Optionaloptions: { signal?: AbortSignal; timeout?: number }

      Returns Promise<boolean>

    • Get a config value as a string (default).

      Parameters

      • tenantId: string
      • fieldPath: string
      • type: StringConstructor
      • Optionaloptions: { signal?: AbortSignal; timeout?: number }

      Returns Promise<string>

    • Get a config value with nullable support. Returns null if the field has no value instead of throwing.

      Parameters

      • tenantId: string
      • fieldPath: string
      • type: NumberConstructor
      • options: { nullable: true; signal?: AbortSignal; timeout?: number }

      Returns Promise<number | null>

    • Get a config value as a string (default).

      Parameters

      • tenantId: string
      • fieldPath: string
      • type: BooleanConstructor
      • options: { nullable: true; signal?: AbortSignal; timeout?: number }

      Returns Promise<boolean | null>

    • Get a config value as a string (default).

      Parameters

      • tenantId: string
      • fieldPath: string
      • type: StringConstructor
      • options: { nullable: true; signal?: AbortSignal; timeout?: number }

      Returns Promise<string | null>

    • Get all config values for a tenant.

      Parameters

      • tenantId: string
      • Optionaloptions: { signal?: AbortSignal; timeout?: number }

      Returns Promise<Record<string, string>>

      A record mapping field paths to their string values.

    • Set a config value. The value is sent as a string — the server coerces it to the schema-defined type. For type-safe writes, prefer setNumber(), setBool(), setTime(), or setDuration().

      Parameters

      • tenantId: string
      • fieldPath: string
      • value: string
      • Optionaloptions: {
            expectedChecksum?: string;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<void>

    • Set a boolean config value. Sends the native boolean as a proto boolValue.

      Parameters

      • tenantId: string
      • fieldPath: string
      • value: boolean
      • Optionaloptions: {
            expectedChecksum?: string;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<void>

    • Set a duration config value. The value must be a duration string (e.g. "1h30m", "300s") — the server parses and validates the format.

      Parameters

      • tenantId: string
      • fieldPath: string
      • value: string
      • Optionaloptions: {
            expectedChecksum?: string;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<void>

    • Atomically set multiple config values.

      Parameters

      • tenantId: string
      • values: Record<string, SetValue>

        Record mapping field paths to typed values (string, number, boolean, or Date).

      • Optionaloptions: {
            description?: string;
            expectedChecksums?: Record<string, string>;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

        Optional description for the audit log, idempotency key for safe DEADLINE_EXCEEDED retries, and per-field expected checksums for optimistic concurrency control.

      Returns Promise<void>

    • Set a config field to null.

      Parameters

      • tenantId: string
      • fieldPath: string
      • Optionaloptions: {
            expectedChecksum?: string;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<void>

    • Set a numeric config value. Sends the native number as a proto numberValue.

      Parameters

      • tenantId: string
      • fieldPath: string
      • value: number
      • Optionaloptions: {
            expectedChecksum?: string;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<void>

    • Set a timestamp config value. Sends the Date as a proto timeValue.

      Parameters

      • tenantId: string
      • fieldPath: string
      • value: Date
      • Optionaloptions: {
            expectedChecksum?: string;
            idempotencyKey?: string;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<void>

    • Replace the bearer token used for all subsequent RPCs (including watcher reconnects).

      Switches the client to JWT auth mode: removes any metadata-header credentials (x-subject, x-role, x-tenant-id) that may have been set at construction time.

      Parameters

      • token: string

        Raw JWT (without the "Bearer " prefix).

      Returns void

    • Create a config watcher for a tenant.

      Returns a ConfigWatcher that can register fields and subscribe to live configuration changes. Call field() to register fields, then start() to load the initial snapshot and begin streaming.

      Parameters

      • tenantId: string

        The tenant ID to watch.

      Returns ConfigWatcher

      A new ConfigWatcher instance.

      const watcher = client.watch('tenant-id');
      const fee = watcher.field('payments.fee', Number, { default: 0.01 });
      await watcher.start();
      console.log(fee.value);