@plitzi/sdk-server 0.30.19
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/CHANGELOG.md +192 -0
- package/README.md +870 -0
- package/dist/.gitkeep +0 -0
- package/dist/adapters/jsonAdapters.js +46 -0
- package/dist/core/createServer.js +47 -0
- package/dist/core/mimeTypes.js +41 -0
- package/dist/core/requestHandler.js +108 -0
- package/dist/core/requestParser.js +34 -0
- package/dist/core/staticFiles.js +42 -0
- package/dist/core/transports.js +51 -0
- package/dist/helpers/buildResponseHelpers.js +43 -0
- package/dist/helpers/buildServerInfo.js +55 -0
- package/dist/helpers/cache/TtlCache.js +55 -0
- package/dist/helpers/cache/cacheManager.js +25 -0
- package/dist/helpers/cache/defaults.js +9 -0
- package/dist/helpers/cache/keys.js +6 -0
- package/dist/helpers/cache/serverCaches.js +15 -0
- package/dist/helpers/compress.js +17 -0
- package/dist/helpers/escapeJson.js +4 -0
- package/dist/helpers/metrics.js +36 -0
- package/dist/helpers/normalizePlugins.js +16 -0
- package/dist/helpers/runMiddlewares.js +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/middlewares/auth.js +10 -0
- package/dist/middlewares/basicAuth.js +67 -0
- package/dist/middlewares/spaceDeployment.js +16 -0
- package/dist/modules/mcp/handler.js +34 -0
- package/dist/modules/mcp/server.js +120 -0
- package/dist/modules/rsc/handler.js +69 -0
- package/dist/modules/ssr/Component.js +20 -0
- package/dist/modules/ssr/buildBody.js +20 -0
- package/dist/modules/ssr/handler.js +36 -0
- package/dist/modules/ssr/loadPluginComponents.js +45 -0
- package/dist/modules/ssr/prepareRender.js +64 -0
- package/dist/modules/ssr/registerExternalPlugins.js +54 -0
- package/dist/modules/ssr/streamBody.js +54 -0
- package/dist/modules/ssr/template.js +10 -0
- package/dist/modules/ssr/views/template.ejs +71 -0
- package/dist/plugins/compile.js +29 -0
- package/dist/plugins/copy.js +13 -0
- package/dist/plugins/detect.js +9 -0
- package/dist/plugins/manager.js +251 -0
- package/dist/public/.gitkeep +0 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +82 -0
- package/dist/src/adapters/jsonAdapters.d.ts +7 -0
- package/dist/src/core/createServer.d.ts +2 -0
- package/dist/src/core/mimeTypes.d.ts +4 -0
- package/dist/src/core/requestHandler.d.ts +5 -0
- package/dist/src/core/requestParser.d.ts +3 -0
- package/dist/src/core/staticFiles.d.ts +2 -0
- package/dist/src/core/transports.d.ts +18 -0
- package/dist/src/helpers/buildResponseHelpers.d.ts +10 -0
- package/dist/src/helpers/buildServerInfo.d.ts +2 -0
- package/dist/src/helpers/cache/TtlCache.d.ts +15 -0
- package/dist/src/helpers/cache/cacheManager.d.ts +3 -0
- package/dist/src/helpers/cache/defaults.d.ts +1 -0
- package/dist/src/helpers/cache/index.d.ts +6 -0
- package/dist/src/helpers/cache/keys.d.ts +7 -0
- package/dist/src/helpers/cache/serverCaches.d.ts +9 -0
- package/dist/src/helpers/compress.d.ts +3 -0
- package/dist/src/helpers/escapeJson.d.ts +1 -0
- package/dist/src/helpers/metrics.d.ts +11 -0
- package/dist/src/helpers/normalizePlugins.d.ts +4 -0
- package/dist/src/helpers/runMiddlewares.d.ts +2 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/middlewares/auth.d.ts +2 -0
- package/dist/src/middlewares/basicAuth.d.ts +6 -0
- package/dist/src/middlewares/spaceDeployment.d.ts +2 -0
- package/dist/src/modules/mcp/handler.d.ts +3 -0
- package/dist/src/modules/mcp/server.d.ts +3 -0
- package/dist/src/modules/rsc/handler.d.ts +17 -0
- package/dist/src/modules/ssr/Component.d.ts +11 -0
- package/dist/src/modules/ssr/buildBody.d.ts +5 -0
- package/dist/src/modules/ssr/handler.d.ts +4 -0
- package/dist/src/modules/ssr/loadPluginComponents.d.ts +13 -0
- package/dist/src/modules/ssr/prepareRender.d.ts +13 -0
- package/dist/src/modules/ssr/registerExternalPlugins.d.ts +7 -0
- package/dist/src/modules/ssr/streamBody.d.ts +5 -0
- package/dist/src/modules/ssr/template.d.ts +6 -0
- package/dist/src/plugins/compile.d.ts +3 -0
- package/dist/src/plugins/copy.d.ts +1 -0
- package/dist/src/plugins/detect.d.ts +3 -0
- package/dist/src/plugins/manager.d.ts +40 -0
- package/dist/src/standalone/alias-loader.d.mts +1 -0
- package/dist/src/standalone/plugins/ClientInfo.d.ts +2 -0
- package/dist/src/standalone/plugins/ServerInfo.d.ts +2 -0
- package/dist/src/standalone/plugins/SharedInfo.d.ts +2 -0
- package/dist/src/standalone/plugins/styles.d.ts +5 -0
- package/dist/src/standalone/register-alias.d.mts +1 -0
- package/dist/src/standalone/server.d.ts +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TtlCache } from '../../helpers/cache';
|
|
2
|
+
import { PluginManager } from '../../plugins/manager';
|
|
3
|
+
import { SSRRequest, SSRResponseHelpers, SSRServerConfig } from '@plitzi/sdk-shared';
|
|
4
|
+
/**
|
|
5
|
+
* Handles GET /_rsc requests.
|
|
6
|
+
*
|
|
7
|
+
* Calls adapters.getRscData to get server-side data for elements marked
|
|
8
|
+
* runtime:'server' in the schema, then returns a JSON payload. The SDK
|
|
9
|
+
* client uses this payload to update server-driven portions of the page
|
|
10
|
+
* without a full navigation.
|
|
11
|
+
*
|
|
12
|
+
* Responses are cached server-side (TtlCache) and via Cache-Control headers:
|
|
13
|
+
* - main environment: no-store (development, always fresh)
|
|
14
|
+
* - Authenticated requests: Cache-Control: private, max-age=<ttl>
|
|
15
|
+
* - Unauthenticated requests: Cache-Control: public, max-age=<ttl>
|
|
16
|
+
*/
|
|
17
|
+
export declare const handleRsc: (req: SSRRequest, res: SSRResponseHelpers, config: SSRServerConfig, _pluginManager: PluginManager, cache?: TtlCache<string>) => Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OfflineDataRaw, Environment, RenderMode, Server, SSRPlugin } from '@plitzi/sdk-shared';
|
|
2
|
+
export type ComponentProps = {
|
|
3
|
+
server: Partial<Server>;
|
|
4
|
+
renderMode?: Extract<RenderMode, 'raw'>;
|
|
5
|
+
environment?: Environment;
|
|
6
|
+
previewMode?: boolean;
|
|
7
|
+
offlineData?: OfflineDataRaw;
|
|
8
|
+
plugins?: Record<string, SSRPlugin>;
|
|
9
|
+
};
|
|
10
|
+
declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins }: ComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Component;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TtlCache } from '../../helpers/cache';
|
|
2
|
+
import { RequestMetrics } from '../../helpers/metrics';
|
|
3
|
+
import { PluginManager } from '../../plugins/manager';
|
|
4
|
+
import { Environment, SSRRequest, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
|
+
export declare const buildBody: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics) => Promise<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ServerCaches } from '../../helpers/cache';
|
|
2
|
+
import { PluginManager } from '../../plugins/manager';
|
|
3
|
+
import { SSRRequest, SSRResponseHelpers, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
4
|
+
export declare const renderSSR: (req: SSRRequest, res: SSRResponseHelpers, config: SSRServerConfig, renderFn: SSRTemplateFn, pluginManager: PluginManager, caches: ServerCaches) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PluginEntry, SSRPlugin } from '@plitzi/sdk-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Dynamically imports plugin components from their compiled filesystem paths and returns
|
|
4
|
+
* a Record<keyName, FC> suitable for passing to <PlitziSdk.Plugin>.
|
|
5
|
+
*
|
|
6
|
+
* File-source plugins are cached by filePath so subsequent requests skip the import().
|
|
7
|
+
* Plugins that fail to import are added to a permanent skip-list — they are not retried
|
|
8
|
+
* and will be rendered client-side instead.
|
|
9
|
+
* Component-source plugins (already in memory via getComponents()) are merged in directly.
|
|
10
|
+
*/
|
|
11
|
+
export declare const loadPluginComponents: (entries: PluginEntry[], inlineComponents?: Record<string, unknown>) => Promise<Record<string, SSRPlugin>>;
|
|
12
|
+
/** Removes one or all entries from the component and failed-import caches. Call after plugin rebuild. */
|
|
13
|
+
export declare const invalidatePluginComponentCache: (filePath?: string) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentProps } from './Component';
|
|
2
|
+
import { TtlCache } from '../../helpers/cache';
|
|
3
|
+
import { RequestMetrics } from '../../helpers/metrics';
|
|
4
|
+
import { PluginManager } from '../../plugins/manager';
|
|
5
|
+
import { Environment, PluginEntry, SSRRequest, SSRServerConfig, SSRTemplateProps } from '@plitzi/sdk-shared';
|
|
6
|
+
export type RenderPrep = {
|
|
7
|
+
componentProps: ComponentProps;
|
|
8
|
+
entries: PluginEntry[];
|
|
9
|
+
templateParams: SSRTemplateProps & {
|
|
10
|
+
offlineData: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const prepareRender: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics) => Promise<RenderPrep>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginManager } from '../../plugins/manager';
|
|
2
|
+
import { OfflineDataRaw } from '@plitzi/sdk-shared';
|
|
3
|
+
/**
|
|
4
|
+
* Reads plugins listed in offlineData.plugins, fetches their manifests, downloads and caches
|
|
5
|
+
* JS/CSS via the PluginManager, and returns the effective plugin keys to pass to getEntries().
|
|
6
|
+
*/
|
|
7
|
+
export declare const registerExternalPlugins: (pluginManager: PluginManager, offlineData: OfflineDataRaw | undefined) => Promise<string[]>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TtlCache } from '../../helpers/cache';
|
|
2
|
+
import { RequestMetrics } from '../../helpers/metrics';
|
|
3
|
+
import { PluginManager } from '../../plugins/manager';
|
|
4
|
+
import { Environment, SSRRequest, SSRResponseHelpers, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
|
+
export declare const streamBody: (req: SSRRequest, res: SSRResponseHelpers, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, htmlCache?: TtlCache<string>, cacheKey?: string, metrics?: RequestMetrics) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const copyPlugin: (src: string, destDir: string, filename: string) => Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PluginEntry, PluginSource } from '@plitzi/sdk-shared';
|
|
2
|
+
export declare class PluginManager {
|
|
3
|
+
readonly urlPrefix = "/sdk-plugins";
|
|
4
|
+
readonly outputDir: string;
|
|
5
|
+
private readonly plugins;
|
|
6
|
+
private readonly ttlMs;
|
|
7
|
+
private readonly mem;
|
|
8
|
+
private readonly inflight;
|
|
9
|
+
private readonly failed;
|
|
10
|
+
/** Maps base plugin name → most recently registered effective key (may include @version) */
|
|
11
|
+
private readonly nameIndex;
|
|
12
|
+
private readonly devMode;
|
|
13
|
+
constructor(plugins: Record<string, PluginSource>, cacheDir?: string, ttlMs?: number, devMode?: boolean);
|
|
14
|
+
hasPlugin(name: string): boolean;
|
|
15
|
+
register(name: string, source: PluginSource): void;
|
|
16
|
+
/**
|
|
17
|
+
* Registers a plugin only if it is not yet known under its effective key.
|
|
18
|
+
* Returns the effective key (`name@version` when version is set, `name` otherwise)
|
|
19
|
+
* so the caller can pass it directly to getEntries().
|
|
20
|
+
*/
|
|
21
|
+
ensure(name: string, source: PluginSource): string;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves a caller-supplied name to the effective key stored in the plugins map.
|
|
24
|
+
* Accepts both the exact key (`plitziBuilder@1.0.0`) and the base name (`plitziBuilder`).
|
|
25
|
+
*/
|
|
26
|
+
private resolveKey;
|
|
27
|
+
private pluginDir;
|
|
28
|
+
private isExpired;
|
|
29
|
+
private toEntry;
|
|
30
|
+
private isWebUrl;
|
|
31
|
+
prepare(name: string): Promise<PluginEntry | null>;
|
|
32
|
+
private build;
|
|
33
|
+
getEntries(names: string[]): Promise<PluginEntry[]>;
|
|
34
|
+
getComponents(): Record<string, unknown>;
|
|
35
|
+
invalidate(name?: string, version?: string): Promise<void>;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
private readMeta;
|
|
38
|
+
private writeMeta;
|
|
39
|
+
private fileExists;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function resolve(specifier: any, context: any, defaultResolve: any): Promise<any>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export declare const card: (color: "green" | "blue" | "purple" | "gray" | "red") => CSSProperties;
|
|
3
|
+
export declare const titleStyle: (color: "green" | "blue" | "purple" | "gray" | "red") => CSSProperties;
|
|
4
|
+
export declare const row: CSSProperties;
|
|
5
|
+
export declare const label: CSSProperties;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plitzi/sdk-server",
|
|
3
|
+
"version": "0.30.19",
|
|
4
|
+
"license": "AGPL-3.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "https",
|
|
20
|
+
"url": "https://github.com/plitzi/plitzi-workspace.git"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
26
|
+
"@plitzi/plitzi-sdk": "0.30.19",
|
|
27
|
+
"@plitzi/sdk-shared": "0.30.19",
|
|
28
|
+
"ejs": "^5.0.2",
|
|
29
|
+
"esbuild": "^0.28.0",
|
|
30
|
+
"zod": "^4.4.1"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "^19",
|
|
34
|
+
"react-dom": "^19"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/ejs": "^3.1.5",
|
|
38
|
+
"@types/node": "^25.6.0",
|
|
39
|
+
"@types/react": "^19.2.14",
|
|
40
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
41
|
+
"eslint": "^9.39.4",
|
|
42
|
+
"eslint-plugin-import": "^2.32.0",
|
|
43
|
+
"react": "^19.2.5",
|
|
44
|
+
"react-dom": "^19.2.5",
|
|
45
|
+
"tsx": "^4.21.0",
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vite": "^8.0.10",
|
|
48
|
+
"vite-plugin-dts": "^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"start:dev": "TSX_TSCONFIG_PATH=tsconfig.app.json ALIAS_LOADER_DEBUG=1 node --import ./src/standalone/register-alias.mjs --import tsx --watch src/standalone/server.ts",
|
|
52
|
+
"start": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx src/standalone/server.ts",
|
|
53
|
+
"start:watch": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --watch src/standalone/server.ts",
|
|
54
|
+
"start:inspect": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --inspect src/standalone/server.ts",
|
|
55
|
+
"build:dev": "vite build --mode development",
|
|
56
|
+
"build:prod": "vite build",
|
|
57
|
+
"lint": "TIMING=1 eslint ./src",
|
|
58
|
+
"typecheck": "tsc -p tsconfig.app.json --noEmit"
|
|
59
|
+
}
|
|
60
|
+
}
|