@nmvuong92/fluxe 0.6.0 → 0.7.0

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.
@@ -1,31 +1,30 @@
1
1
  import type { ComponentType } from "react";
2
- import type { Backend } from "../backends/types";
3
2
  import type { HeadMeta } from "./seo";
4
3
  import type { Session } from "./auth";
5
4
  import type { TFn } from "./i18n";
6
- export interface Ctx<I> {
5
+ export interface Ctx<I, B = any> {
7
6
  input: I;
8
- backend: Backend;
7
+ backend: B;
9
8
  session?: Session | null;
10
9
  locale?: string;
11
10
  t?: TFn;
12
11
  }
13
- export type Loader<I, O> = (ctx: Ctx<I>) => Promise<O>;
14
- export type Action<I, O> = (ctx: Ctx<I>) => Promise<O>;
12
+ export type Loader<I, O, B = any> = (ctx: Ctx<I, B>) => Promise<O>;
13
+ export type Action<I, O, B = any> = (ctx: Ctx<I, B>) => Promise<O>;
15
14
  export type Hydration = "static" | "island";
16
- export interface CellDef<I, O> {
15
+ export interface CellDef<I, O, B = any> {
17
16
  id: string;
18
17
  route: string;
19
18
  hydration?: Hydration;
20
- loader: Loader<I, O>;
19
+ loader: Loader<I, O, B>;
21
20
  view: ComponentType<{
22
21
  data: O;
23
22
  }>;
24
- actions?: Record<string, Action<any, any>>;
23
+ actions?: Record<string, Action<any, any, B>>;
25
24
  head?: (data: O) => HeadMeta;
26
25
  layout?: string;
27
26
  requireAuth?: boolean;
28
27
  requireRole?: string;
29
28
  cache?: boolean;
30
29
  }
31
- export declare function defineCell<I, O>(c: CellDef<I, O>): CellDef<I, O>;
30
+ export declare function defineCell<I, O, B = any>(c: CellDef<I, O, B>): CellDef<I, O, B>;
@@ -15,5 +15,6 @@ export declare function makeServer(manifest: ResolutionManifest, cells: CellDef<
15
15
  i18n?: I18n;
16
16
  storage?: Storage;
17
17
  config?: FluxeConfig;
18
+ backend?: unknown;
18
19
  }): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
19
20
  export {};
@@ -98,9 +98,11 @@ export function makeServer(manifest, cells, layouts = {}, opts = {}) {
98
98
  // Cells được TIÊM từ app (DI) — engine không import ngược vào app/. Thêm trang = sửa app/app.ts.
99
99
  const matchRoute = makeRouter(cells);
100
100
  const byId = new Map(cells.map((c) => [c.id, c]));
101
- // Backend GIẢI per-cell từ manifest (Resolution Plane) cell/frontend giữ nguyên.
102
- const backends = backendsFromManifest(manifest);
103
- const backendFor = (id) => backends.byCell.get(id) ?? backends.default;
101
+ // Backend USER-OWNED (app/backend.ts) inject qua opts.backend dùng cho mọi cell.
102
+ // Nếu app không truyền → fallback driver built-in giải từ manifest (memory/sqlite) cho quick-start.
103
+ const userBackend = opts.backend;
104
+ const backends = userBackend === undefined ? backendsFromManifest(manifest) : null;
105
+ const backendFor = (id) => userBackend ?? backends.byCell.get(id) ?? backends.default;
104
106
  // Resolved Container: service realtime đăng ký LƯỜI — chỉ tạo khi thật sự dùng (SSE/action).
105
107
  // App không realtime → broker/presence KHÔNG bao giờ bootstrap. resolved() ở /_fluxe/stats.
106
108
  const container = createContainer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nmvuong92/fluxe",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "fluxe — khung fullstack tối giản, một runtime TS (RCA: Resolved Cell Architecture).",
5
5
  "license": "Apache-2.0",
6
6
  "author": "nmvuong92",