1"""Per-user engine designs with sharing, microversion history and named releases.
3A thin binding of :mod:`stardesign.documents` -- the router shared by all three
4design tools -- to this app's payload shape and route prefix. Everything of
5substance, including ``_resolve_doc`` (the one place cross-user access is
8The payload here is ``{"config": <dict>, "ui": <dict>}``; pid-designer's is
9``{nodes, edges}``. That, the prefix, and the noun are the whole difference.
11``ui`` carries the authored state that is not in ``PintleEngineConfig`` -- the
12controller commands, the time-series pressure profiles, Layer 4's vehicle
13definition, the layer run settings, the plot definition. It is opaque here, as
14the config is: the frontend owns its shape (see frontend/src/lib/designState.ts).
15It defaults to ``{}`` so every design stored before it existed still loads.
18from __future__
import annotations
22from pydantic
import BaseModel
32from backend
import storage, userdata
35class ConfigPayload(BaseModel):
42 config: dict |
None =
None
43 ui: dict |
None =
None
48 config: dict |
None =
None
49 ui: dict |
None =
None
54 backend=storage.backend,
55 body_model=ConfigPayload,
56 create_model=CreatePayload,
57 release_model=ReleasePayload,
59 "config": getattr(p,
"config",
None)
or {},
60 "ui": getattr(p,
"ui",
None)
or {},
62 release_body=
lambda p: (
63 None if p.config
is None else {
"config": p.config,
"ui": p.ui
or {}}
66 default_slug=
"design",
69 micro_interval=int(os.environ.get(
"ENGINE_MICRO_INTERVAL",
"300")),
70 empty_payload=
lambda: {
"config": {},
"ui": {}},
73router = make_router(store, prefix=
"/api/engine/documents")