or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-10/

Deep Config Customizers

Utilities that merge, clone, and compare workspace configuration objects using custom deep behavior rather than default structural rules.

Capabilities

Merge workspace configs with custom rules

  • Base { plugins: ["core", "ui"] } merged with incoming { plugins: ["ui", "admin", "core"] } results in { plugins: ["core", "ui", "admin"] } while leaving unrelated properties unchanged. @test
  • Base { retries: 2, metadata: { last: "ok" } } merged with incoming { retries: null, metadata: { last: null, status: "warn" } } produces { retries: 2, metadata: { last: "ok", status: "warn" } }, ignoring null overrides but keeping new keys. @test
  • Base { featureFlags: [{ id: "a", active: false }, { id: "b", active: true }] } merged with incoming { featureFlags: [{ id: "a", active: true }, { id: "c", active: true }] } yields { featureFlags: [{ id: "a", active: true }, { id: "b", active: true }, { id: "c", active: true }] }. @test

Clone config for transport

  • Cloning { lastSync: new Date("2024-03-01T10:00:00Z"), plugins: new Set(["core", "ui"]), transform: fn } returns { lastSync: "2024-03-01T10:00:00.000Z", plugins: ["core", "ui"], transform: fn } where the date becomes an ISO string, the set becomes an alphabetically sorted array, and the function reference is preserved. @test

Equivalence check with custom tolerance

  • Comparing { plugins: ["ui", "core"], retries: 2.005, lastSync: new Date("2024-03-01T10:00:00Z") } with { plugins: ["core", "ui", "core"], retries: 2.0, lastSync: "2024-03-01T10:00:00.000Z" } returns true because plugin order and duplicates are ignored, numeric differences within 0.01 are tolerated, and dates match their ISO string. @test
  • Comparing { plugins: ["core"], retries: 2 } with { plugins: ["core", "reports"], retries: 2.2 } returns false because of the missing plugin and numeric gap above the tolerance. @test

Implementation

@generates

API

export interface FeatureFlag {
  id: string;
  active: boolean;
  [key: string]: unknown;
}

export interface WorkspaceConfig {
  plugins?: string[] | Set<string>;
  retries?: number | null;
  featureFlags?: FeatureFlag[];
  lastSync?: Date | string | null;
  metadata?: Record<string, unknown>;
  transform?: () => void;
  custom?: unknown;
}

export function mergeConfigs(base: WorkspaceConfig, incoming: WorkspaceConfig): WorkspaceConfig;
export function cloneForTransport(config: WorkspaceConfig): WorkspaceConfig;
export function configsEquivalent(a: WorkspaceConfig, b: WorkspaceConfig): boolean;

Dependencies { .dependencies }

lodash { .dependency }

Utility toolkit for deep cloning, merging, and comparisons with custom traversal hooks. @satisfied-by