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

Aperta
#258 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
12
Fork
8
Merge medio
11h 2m
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di adobe/data

Tutte le issue di adobe/data

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.