createLazy: wrap nested service groups and accept partial (subset) schemas

Offen
#258 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
api

Rechercherichtung

Start with AsyncDataService.createLazy and synthesizeService in @adobe/data-rpc, which already projects nested services recursively. The issue says an implementation exists on local branch knye/create-lazy-nested (commit c3aa3f1c) but is unpushed, so confirm with maintainers before duplicating it. Done means nested object members are wrapped at any depth, partial: true checks subset schemas, and vitest --project node passes.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Problem

AsyncDataService.createLazy only wraps top-level observe / function members. A nested organizational group (an object member with its own properties, e.g. an ECS database's actions / computed) is rejected at compile time and memberKind throws on it at runtime, even though @adobe/data-rpc's synthesizeService already projects nested services recursively from the same kind of schema.

It also requires the schema to describe the loaded service completely. There is no way to lazily expose a curated subset of a larger service without hand-writing a copy of it.

Firefly Studio needs both: each App exposes its main service to runtime agents as a schema-described createLazy instance, so the schema is introspectable immediately while the app's real service (and its lazily-loaded chunk) loads only on an agent's first use. Those main services are nested (ECS actions / computed), and an app exposes less than its full main service.

Proposed change

  1. Nested groups. Wrap type: 'object' members recursively at any depth. Resolve every depth from the one root load in a single step, so calls queued before load on members at different depths still run in the order they were made.
  2. partial?: boolean (default false). When true, the gate checks that the loaded service satisfies the schema (every described member exists with an assignable type; a wrong type or unknown member is a compile error). The instance carries only the described members and is typed as the schema (plus serviceName / schema) rather than as the whole service. Without partial, the existing complete-schema gate and the instance type are unchanged, so existing callers' declaration emit is unaffected.

Status

Implemented with tests on branch knye/create-lazy-nested (local, not yet pushed): commit c3aa3f1c, bumping to 0.10.32. tsc -b clean; vitest --project node 148 files / 1808 tests pass. Verified in Firefly Platform via a local store swap: all existing createLazy consumers pass.

Vorherrschende Sprache
TypeScript
Sterne
12
Forks
8
Ø Merge
11 Std. 2 Min.
Gemergte PRs (30 T.)
23

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus adobe/data

Alle Issues in adobe/data

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.