-
-
Notifications
You must be signed in to change notification settings - Fork 0
Server Manifests And Clients
Status: Manifest creation and runtime clients are current. Generated module and CLI workflows are experimental.
A layer server manifest is a serializable inventory of layer-owned routes, actions, methods, validation metadata, runtime hints, cache/CORS metadata, and diagnostics.
const manifest = createLayerServerManifest([AuthLayer, UserLayer]);The manifest is built from resolved layer definitions. Duplicate action names, invalid route declarations, and metadata conflicts are reported as diagnostics rather than hidden by declaration order.
const client = createLayerServerManifestClient(manifest);
const user = await client.action('users', 'refreshUser', {
userId: 'u1',
});
const response = await client.route('/api/users/[id]', {
method: 'GET',
params: { id: 'u1' },
});Literal manifests constrain layer names, action names, route paths, HTTP methods, and dynamic params at compile time.
createLayerRoutePath and createLayerRouteUrl replace colon or bracket params
and encode dynamic values. Required catch-alls require values. Optional
catch-alls may omit their segment.
const source = generateLayerServerClientModule(manifest, {
factoryName: 'createApiClient',
manifestName: 'serverManifest',
});The generated module exports a literal manifest, client factory, and inferred client type. Generation should be deterministic and reviewed like source code.
Manifest clients distinguish:
- unknown manifest routes/actions before dispatch;
- transport and HTTP failures;
- typed action failures;
- structured layer server error bodies;
- structured validation error bodies.
Use isLayerClientError, status helpers, and body helpers rather than parsing
error messages.
The manifest currently describes layer server capabilities. It is not yet the single source for client page routes, layouts, route metadata, and server files. That unification is tracked by #218.