@savvifi/meridian-aion-web 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { renderMeridianEntityView, type RenderMeridianEntityViewInput, type RenderMeridianEntityViewResult, type MeridianDehydratedView, type EntityCaller, } from "./render-server.js";
1
+ export { renderMeridianEntityView, renderCrdLayout, type RenderMeridianEntityViewInput, type RenderMeridianEntityViewResult, type MeridianDehydratedView, type EntityCaller, type RenderCrdLayoutInput, type LayoutFetcher, type CrdRpcInvoker, } from "./render-server.js";
2
2
  export { MeridianEntityView, type MeridianEntityViewProps } from "./render-client.js";
3
3
  export { savviSkin } from "./savvi-skin.js";
4
4
  export { NotFoundSignal, isNotFoundSignal } from "./not-found.js";
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // pre-fetch page-0 -> render + dehydrate). Client: MeridianEntityView (hydrate).
5
5
  // Plus savviSkin (the brand Theme proto) and createEntityOpsInvoker (build a
6
6
  // meridian RpcInvoker over a tRPC caller/client's entities.ops).
7
- export { renderMeridianEntityView, } from "./render-server.js";
7
+ export { renderMeridianEntityView, renderCrdLayout, } from "./render-server.js";
8
8
  export { MeridianEntityView } from "./render-client.js";
9
9
  export { savviSkin } from "./savvi-skin.js";
10
10
  export { NotFoundSignal, isNotFoundSignal } from "./not-found.js";
@@ -33,3 +33,28 @@ export interface RenderMeridianEntityViewResult {
33
33
  dehydrated: MeridianDehydratedView | null;
34
34
  }
35
35
  export declare function renderMeridianEntityView(input: RenderMeridianEntityViewInput): Promise<RenderMeridianEntityViewResult>;
36
+ /** The host-supplied transport that fetches a Layout's ViewDescriptor as proto-JSON.
37
+ * Abstracted so the gRPC client (Connect / grpc-js) is a host adapter, not a dep of
38
+ * this package — it calls `LayoutService.GetLayout({ name })` and returns
39
+ * `toJson(ViewDescriptorSchema, layout.viewDescriptor)`. */
40
+ export type LayoutFetcher = (name: string) => Promise<unknown>;
41
+ /** An RpcInvoker (one method) that dispatches a panel's RpcCall. For CRD layouts the
42
+ * RpcCalls target `meridian.k8s.backend.Kubernetes`, so this must reach the K8s API
43
+ * (or the meridian-k8s backend) rather than the tRPC entity-ops root. */
44
+ export interface CrdRpcInvoker {
45
+ invoke(service: string, method: string, request: object): Promise<object>;
46
+ }
47
+ export interface RenderCrdLayoutInput {
48
+ /** CRD kind id (the CRD name), e.g. `instances.aion.savvifi.com`. */
49
+ kind: string;
50
+ /** Which layout to render. Default "detail". */
51
+ view?: "list" | "detail";
52
+ /** Fetches the ViewDescriptor proto-JSON from the meridian-k8s LayoutService. */
53
+ fetchLayout: LayoutFetcher;
54
+ /** Dispatches the layout's RpcCalls (meridian-k8s / K8s backend). */
55
+ invoker: CrdRpcInvoker;
56
+ /** Resolved color mode; default "light". */
57
+ mode?: "light" | "dark";
58
+ }
59
+ /** Fetch a meridian-k8s Layout and render it exactly like a projected entity view. */
60
+ export declare function renderCrdLayout(input: RenderCrdLayoutInput): Promise<RenderMeridianEntityViewResult>;
@@ -6,7 +6,7 @@
6
6
  // The host owns the SSR harness (renderToPipeableStream), the session-bound
7
7
  // caller, and the graph; meridian owns everything from the composition down.
8
8
  import { createElement } from "react";
9
- import { toJson } from "@bufbuild/protobuf";
9
+ import { fromJson, toJson } from "@bufbuild/protobuf";
10
10
  import { ViewDescriptorSchema } from "@savvifi/meridian-proto-ts/proto/view_pb.js";
11
11
  import { createEntityOpsInvoker, projectEntityView, } from "@savvifi/meridian-aion-projection";
12
12
  import { buildPageRequest, readPage, ViewRenderer, } from "@savvifi/meridian-web-react";
@@ -72,3 +72,30 @@ export async function renderMeridianEntityView(input) {
72
72
  dehydrated: { viewJson: toJson(ViewDescriptorSchema, view), initialData },
73
73
  };
74
74
  }
75
+ /** Fetch a meridian-k8s Layout and render it exactly like a projected entity view. */
76
+ export async function renderCrdLayout(input) {
77
+ const { kind, view = "detail", fetchLayout, invoker, mode = "light" } = input;
78
+ const name = `kinds/${kind}/layouts/${view}`;
79
+ const viewJson = await fetchLayout(name);
80
+ // Normalize through the canonical schema — the same message ViewRenderer consumes,
81
+ // whether it was projected (renderMeridianEntityView) or fetched (here).
82
+ const descriptor = fromJson(ViewDescriptorSchema, viewJson);
83
+ // Pre-fetch page-0 for the first table (non-fatal), identical to the entity path.
84
+ const initialData = {};
85
+ const table = firstTablePanel(descriptor);
86
+ if (table?.populate) {
87
+ try {
88
+ const request = buildPageRequest(table.pagination, { page: 0 });
89
+ const response = await invoker.invoke(table.populate.service, table.populate.method, request);
90
+ initialData[`${table.populate.service}.${table.populate.method}`] = readPage(table.pagination, response, table.rowsField);
91
+ }
92
+ catch {
93
+ // leave unseeded
94
+ }
95
+ }
96
+ const node = createElement(MeridianMuiProvider, { invoker, theme: savviSkin, mode }, createElement(ViewRenderer, { view: descriptor, initialData }));
97
+ return {
98
+ node,
99
+ dehydrated: { viewJson: toJson(ViewDescriptorSchema, descriptor), initialData },
100
+ };
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvifi/meridian-aion-web",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "The aion/web <-> meridian-ux render seam: renderMeridianEntityView (server — parse route, load composition, project to a ViewDescriptor, pre-fetch page-0, render + dehydrate) + MeridianEntityView (client hydration) + savviSkin. Lets an SSR host (e.g. aion/web on Hono+Vite) render entity routes through meridian instead of the legacy React path.",
6
6
  "publishConfig": {
@@ -37,10 +37,10 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@savvifi/meridian-aion-projection": "^0.2.2",
40
- "@savvifi/meridian-mui-kit": "^0.1.4",
41
- "@savvifi/meridian-proto-ts": "^0.3.0",
42
- "@savvifi/meridian-schemas": "^0.3.0",
43
- "@savvifi/meridian-web-react": "^0.3.5",
40
+ "@savvifi/meridian-mui-kit": "^0.2.0",
41
+ "@savvifi/meridian-proto-ts": "^0.5.0",
42
+ "@savvifi/meridian-schemas": "^0.5.0",
43
+ "@savvifi/meridian-web-react": "^0.4.0",
44
44
  "@bufbuild/protobuf": "2.12.1"
45
45
  },
46
46
  "peerDependencies": {