@taujs/server 0.4.0 → 0.4.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.
@@ -1,4 +1,4 @@
1
- import { FastifyRequest, FastifyPluginCallback, FastifyPluginAsync } from 'fastify';
1
+ import { FastifyRequest } from 'fastify';
2
2
  import { PluginOption } from 'vite';
3
3
 
4
4
  declare const DEBUG_CATEGORIES: readonly ["auth", "routes", "errors", "vite", "network", "ssr"];
@@ -7,18 +7,18 @@ type DebugConfig = boolean | DebugCategory[] | ({
7
7
  all?: boolean;
8
8
  } & Partial<Record<DebugCategory, boolean>>);
9
9
  interface BaseLogger {
10
- debug?(message: string, meta?: unknown): void;
11
- info?(message: string, meta?: unknown): void;
12
- warn?(message: string, meta?: unknown): void;
13
- error?(message: string, meta?: unknown): void;
14
- log?(message: string, meta?: unknown): void;
10
+ debug?(meta?: Record<string, unknown>, message?: string): void;
11
+ info?(meta?: Record<string, unknown>, message?: string): void;
12
+ warn?(meta?: Record<string, unknown>, message?: string): void;
13
+ error?(meta?: Record<string, unknown>, message?: string): void;
14
+ child?(context: Record<string, unknown>): BaseLogger;
15
15
  }
16
16
  interface Logs extends BaseLogger {
17
- debug(message: string, meta?: unknown): void;
18
- debug(category: DebugCategory, message: string, meta?: unknown): void;
19
- info(message: string, meta?: unknown): void;
20
- warn(message: string, meta?: unknown): void;
21
- error(message: string, meta?: unknown): void;
17
+ debug(meta?: unknown, message?: string): void;
18
+ debug(category: DebugCategory, meta?: unknown, message?: string): void;
19
+ info(meta?: unknown, message?: string): void;
20
+ warn(meta?: unknown, message?: string): void;
21
+ error(meta?: unknown, message?: string): void;
22
22
  child(context: Record<string, unknown>): Logs;
23
23
  isDebugEnabled(category: DebugCategory): boolean;
24
24
  }
@@ -74,75 +74,6 @@ type RouteCSPConfig = {
74
74
  }) => CSPDirectives);
75
75
  generateCSP?: (directives: CSPDirectives, nonce: string, req: FastifyRequest) => string;
76
76
  };
77
- type Config = {
78
- appId: string;
79
- entryPoint: string;
80
- entryClient?: string;
81
- entryServer?: string;
82
- htmlTemplate?: string;
83
- };
84
- type ProcessedConfig = {
85
- appId: string;
86
- clientRoot: string;
87
- entryClient: string;
88
- entryPoint: string;
89
- entryServer: string;
90
- htmlTemplate: string;
91
- plugins?: PluginOption[];
92
- };
93
- type SSRServerOptions = {
94
- alias?: Record<string, string>;
95
- clientRoot: string;
96
- configs: AppConfig[];
97
- routes: Route<PathToRegExpParams>[];
98
- serviceRegistry: ServiceRegistry;
99
- security?: SecurityConfig;
100
- registerStaticAssets?: false | {
101
- plugin: FastifyPluginCallback<any> | FastifyPluginAsync<any>;
102
- options?: Record<string, unknown>;
103
- };
104
- debug?: DebugConfig;
105
- devNet?: {
106
- host: string;
107
- hmrPort: number;
108
- };
109
- };
110
- type RenderCallbacks<T = unknown> = {
111
- onHead?: (headContent: string) => void;
112
- onShellReady?: () => void;
113
- onAllReady?: (initialData: T) => void;
114
- onError?: (error: unknown) => void;
115
- };
116
- type SSRManifest = {
117
- [key: string]: string[];
118
- };
119
- type ManifestEntry = {
120
- file: string;
121
- src?: string;
122
- isDynamicEntry?: boolean;
123
- imports?: string[];
124
- css?: string[];
125
- assets?: string[];
126
- };
127
- type Manifest = {
128
- [key: string]: ManifestEntry;
129
- };
130
- type RenderSSR = (initialDataResolved: Record<string, unknown>, location: string, meta?: Record<string, unknown>, signal?: AbortSignal, opts?: {
131
- logger?: Logs;
132
- }) => Promise<{
133
- headContent: string;
134
- appHtml: string;
135
- }>;
136
- type RenderStream = (serverResponse: NodeJS.WritableStream, callbacks: RenderCallbacks, initialData: Record<string, unknown> | Promise<Record<string, unknown>> | (() => Promise<Record<string, unknown>>), location: string, bootstrapModules?: string, meta?: Record<string, unknown>, cspNonce?: string, signal?: AbortSignal, opts?: {
137
- logger?: Logs;
138
- }) => {
139
- abort(): void;
140
- };
141
- type RenderModule = {
142
- renderSSR: RenderSSR;
143
- renderStream: RenderStream;
144
- };
145
- type GenericPlugin = FastifyPluginCallback<Record<string, unknown>> | FastifyPluginAsync<Record<string, unknown>>;
146
77
  type BaseMiddleware = {
147
78
  auth?: {
148
79
  redirect?: string;
@@ -183,7 +114,6 @@ interface InitialRouteParams extends Record<string, unknown> {
183
114
  serviceName?: string;
184
115
  serviceMethod?: string;
185
116
  }
186
- type RoutePathsAndAttributes<Params extends PathToRegExpParams = PathToRegExpParams> = Omit<Route<Params>, 'element'>;
187
117
 
188
118
  type CSPDirectives = Record<string, string[]>;
189
119
 
@@ -242,4 +172,4 @@ type TaujsConfig = {
242
172
 
243
173
  declare function defineConfig<T extends TaujsConfig>(config: T): T;
244
174
 
245
- export { type AppConfig as A, type BaseLogger as B, type Config as C, type DebugConfig as D, type GenericPlugin as G, type InitialRouteParams as I, type ManifestEntry as M, type ProcessedConfig as P, type RouteCSPConfig as R, type SSRServerOptions as S, type TaujsConfig as T, type ServiceRegistry as a, type RenderCallbacks as b, type SSRManifest as c, type Manifest as d, type RenderSSR as e, type RenderStream as f, type RenderModule as g, type BaseMiddleware as h, type ServiceCall as i, type DataResult as j, type DataHandler as k, type PathToRegExpParams as l, type RouteAttributes as m, type Route as n, type RoutePathsAndAttributes as o, type SecurityConfig as p, type AppRoute as q, defineConfig as r, defineServiceRegistry as s, defineService as t };
175
+ export { type AppConfig as A, type BaseLogger as B, type DebugConfig as D, type InitialRouteParams as I, type ServiceRegistry as S, type TaujsConfig as T, type SecurityConfig as a, type AppRoute as b, defineServiceRegistry as c, defineConfig as d, defineService as e };
package/dist/Config.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'fastify';
2
2
  import 'vite';
3
- export { A as AppConfig, q as AppRoute, p as SecurityConfig, T as TaujsConfig, r as defineConfig, t as defineService, s as defineServiceRegistry } from './Config-CjwAJCfZ.js';
3
+ export { A as AppConfig, b as AppRoute, a as SecurityConfig, T as TaujsConfig, d as defineConfig, e as defineService, c as defineServiceRegistry } from './Config-LCDjtT9m.js';
package/dist/index.d.ts CHANGED
@@ -1,48 +1,13 @@
1
- import { S as SSRServerOptions, T as TaujsConfig, a as ServiceRegistry, D as DebugConfig, B as BaseLogger } from './Config-CjwAJCfZ.js';
2
- export { h as BaseMiddleware, C as Config, k as DataHandler, j as DataResult, G as GenericPlugin, I as InitialRouteParams, d as Manifest, M as ManifestEntry, l as PathToRegExpParams, P as ProcessedConfig, b as RenderCallbacks, g as RenderModule, e as RenderSSR, f as RenderStream, n as Route, m as RouteAttributes, R as RouteCSPConfig, o as RoutePathsAndAttributes, c as SSRManifest, i as ServiceCall } from './Config-CjwAJCfZ.js';
3
- import { FastifyPluginAsync, FastifyInstance, FastifyPluginCallback } from 'fastify';
1
+ import { FastifyPluginCallback, FastifyPluginAsync, FastifyInstance } from 'fastify';
2
+ import { T as TaujsConfig, S as ServiceRegistry, D as DebugConfig, B as BaseLogger, A as AppConfig } from './Config-LCDjtT9m.js';
3
+ export { I as InitialRouteParams } from './Config-LCDjtT9m.js';
4
4
  import 'vite';
5
5
 
6
- declare module 'fastify' {
7
- interface FastifyRequest {
8
- cspNonce?: string;
9
- }
10
-
11
- interface FastifyInstance {
12
- /**
13
- * Optional authentication hook to be used by the taujs SSRServer.
14
- * This method must be decorated by the user when using auth middleware in `taujs.config.ts`.
15
- *
16
- * Example usage:
17
- * ```ts
18
- * fastify.decorate('authenticate', async function (req, reply) {
19
- * await req.jwtVerify();
20
- * });
21
- * ```
22
- */
23
- authenticate: (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
24
- showBanner(): void;
25
- cspNonce?: string;
26
- }
27
- }
28
-
29
- declare const TEMPLATE: {
30
- readonly defaultEntryClient: "entry-client";
31
- readonly defaultEntryServer: "entry-server";
32
- readonly defaultHtmlTemplate: "index.html";
6
+ type StaticMountEntry = {
7
+ plugin: FastifyPluginCallback<any> | FastifyPluginAsync<any>;
8
+ options?: Record<string, unknown>;
33
9
  };
34
-
35
- /**
36
- * τjs [ taujs ] Orchestration System
37
- * (c) 2024-present Aoede Ltd
38
- * Author: John Smith
39
- *
40
- * Licensed under the MIT License - attribution appreciated.
41
- * Part of the τjs [ taujs ] system for declarative, build-time orchestration of microfrontend applications,
42
- * including CSR, SSR, streaming, and middleware composition.
43
- */
44
-
45
- declare const SSRServer: FastifyPluginAsync<SSRServerOptions>;
10
+ type StaticAssetsRegistration = false | StaticMountEntry | StaticMountEntry[];
46
11
 
47
12
  type NetResolved = {
48
13
  host: string;
@@ -50,10 +15,6 @@ type NetResolved = {
50
15
  hmrPort: number;
51
16
  };
52
17
 
53
- type StaticAssetsRegistration = {
54
- plugin: FastifyPluginCallback<any> | FastifyPluginAsync<any>;
55
- options?: Record<string, unknown>;
56
- };
57
18
  type CreateServerOptions = {
58
19
  config: TaujsConfig;
59
20
  serviceRegistry: ServiceRegistry;
@@ -62,7 +23,7 @@ type CreateServerOptions = {
62
23
  fastify?: FastifyInstance;
63
24
  debug?: DebugConfig;
64
25
  logger?: BaseLogger;
65
- registerStaticAssets?: false | StaticAssetsRegistration;
26
+ staticAssets?: false | StaticAssetsRegistration;
66
27
  port?: number;
67
28
  };
68
29
  type CreateServerResult = {
@@ -71,4 +32,23 @@ type CreateServerResult = {
71
32
  };
72
33
  declare const createServer: (opts: CreateServerOptions) => Promise<CreateServerResult>;
73
34
 
74
- export { SSRServer, SSRServerOptions, TEMPLATE, createServer };
35
+ /**
36
+ * τjs [ taujs ] Orchestration System
37
+ * (c) 2024-present Aoede Ltd
38
+ * Author: John Smith
39
+ *
40
+ * Licensed under the MIT License - attribution appreciated.
41
+ * Part of the τjs [ taujs ] system for declarative, build-time orchestration of microfrontend applications,
42
+ * including CSR, SSR, streaming, and middleware composition.
43
+ */
44
+
45
+ declare function taujsBuild({ config, projectRoot, clientBaseDir, isSSRBuild, }: {
46
+ config: {
47
+ apps: AppConfig[];
48
+ };
49
+ projectRoot: string;
50
+ clientBaseDir: string;
51
+ isSSRBuild?: boolean;
52
+ }): Promise<void>;
53
+
54
+ export { createServer, taujsBuild };