Skip to content

patchwork

Jacob Sampson edited this page Mar 23, 2026 · 1 revision

Module: Patchwork (Services)

Generated by Cicadas Bootstrap on 2026-03-22.

Purpose

The patchwork package (@aprovan/patchwork) provides the service proxy layer — the abstraction through which widgets call external services. It defines the ServiceBackend interface and exposes callProcedure(namespace, procedure, args) as the universal method for service invocation, with createProxy for ergonomic namespace-scoped access.

Interfaces

Exports:

  • callProcedure(namespace, procedure, args) — Invoke a remote procedure on a named service
  • createProxy(namespace) — Create a proxy object where method calls map to callProcedure
  • setServiceBackend(backend) — Set the active service backend (global singleton)
  • ServiceBackend interface — { call(service, procedure, args): Promise<any> }
  • Service type definitions

Dependencies:

  • None (zero runtime dependencies — pure abstraction layer)

Subsystems

Services

  • services/proxy.tscreateProxy implementation using JavaScript Proxy to intercept method calls and route them to callProcedure
  • services/types.tsServiceBackend interface definition and related types
  • services/index.ts — Barrel export and setServiceBackend / callProcedure implementation

Key Decisions

  • Global singleton backend: A single ServiceBackend is set globally via setServiceBackend(). Widgets don't need to know about backend configuration — they just call callProcedure.
  • Namespace-based routing: Services are identified by namespace strings (e.g., "weather", "database"), allowing multiple service providers to coexist.
  • Zero dependencies: The package is a pure abstraction layer with no runtime dependencies, making it safe to bundle into any widget without bloat.
  • Proxy-based ergonomics: createProxy("weather").getForecast(args) is syntactic sugar over callProcedure("weather", "getForecast", args).

Clone this wiki locally