feat: name every type the public signatures use, before the freeze (CARD-22, D19)
D19 as amended 2026-10-24: nothing that shipped in 26.9.0-beta.2 is removed. Every symbol D19 had listed for removal or review is in that release, so this change only adds exports and marks scope. - Export `AppOptions`, `ExplainNode`, `WsRequest` and `WsSocket`. Each appears in a public signature (`createApp`, `Explain.chain`, `app.upgrade`) but could not be imported. `AppOptions` is the former inline options type of `createApp`, moved verbatim into an interface. - Add `RequestHeaders`. `Headers` shadows the Fetch global wherever it is imported, so it stays only as a `@deprecated` alias of the same type. - Mark the mesh exports and `MeshConfig` `@experimental`. They stay exported and unchanged, but sit outside the freeze, like the `experimental: true` flag the mesh already needs. - The seven review candidates (`withConsoleFallback`, `UNMATCHED_ROUTE`, `HTTP_ERROR`, `VALIDATION_ERROR`, `TransportMismatchError`, `isAsyncIterable`, `buildOpenApi`) stay as they are. CHANGELOG: `### Added` for the types, `### Changed` for the mesh tag, and a new `### Deprecated` for `Headers`. No `### Breaking`. test/types/public-surface.test.ts fails to compile if any of the new names stops being exported. `deno publish --dry-run` passes. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
10 files changed
+113
-16
No files matched your search
+10
-7
@@ -114,12 +114,8 @@ interface PipelineDeps {
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an {@link App} from the given modules and options.
|
||||
* Wires providers, steps, controllers and plugins into a dependency graph; for non-mesh apps
|
||||
* the graph is finalized eagerly, otherwise finalization is deferred to {@link App.listen}.
|
||||
*/
|
||||
export function createApp(opts: {
|
||||
/** Options for {@link createApp}. */
|
||||
export interface AppOptions {
|
||||
modules: Ctor[];
|
||||
plugins?: Plugin[];
|
||||
/**
|
||||
@@ -278,7 +274,14 @@ export function createApp(opts: {
|
||||
* 20+ steps on one route usually means a step is doing too much.
|
||||
*/
|
||||
warnGraphDepth?: number | false;
|
||||
}): App {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an {@link App} from the given modules and options.
|
||||
* Wires providers, steps, controllers and plugins into a dependency graph; for non-mesh apps
|
||||
* the graph is finalized eagerly, otherwise finalization is deferred to {@link App.listen}.
|
||||
*/
|
||||
export function createApp(opts: AppOptions): App {
|
||||
// mesh is alpha: its API and wire protocol may change. Require an explicit opt-in.
|
||||
if (opts.mesh && !opts.experimental) {
|
||||
throw new Error(
|
||||
|
||||
+6
-1
@@ -125,7 +125,12 @@ export interface RoutePlan {
|
||||
args: ArgSpec[];
|
||||
}
|
||||
|
||||
/** Mesh networking options: a secret to gate this node's exports and/or remote teapots to connect to. */
|
||||
/**
|
||||
* Mesh networking options: a secret to gate this node's exports and/or remote teapots to connect to.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export interface MeshConfig {
|
||||
secret?: string;
|
||||
teapots?: Array<{ url: string; secret: string }>;
|
||||
|
||||
+4
-3
@@ -18,7 +18,7 @@ export const VERSION = '26.9.0-beta.2';
|
||||
|
||||
// Application
|
||||
export { createApp } from './app';
|
||||
export type { App, InspectLine, Explain, MeshConfig } from './app';
|
||||
export type { App, AppOptions, InspectLine, Explain, ExplainNode, MeshConfig } from './app';
|
||||
|
||||
// Graph visualization
|
||||
export { toMermaid, toDOT } from './graph-viz';
|
||||
@@ -79,7 +79,7 @@ export type { StepFn, CompiledFlow } from './flow';
|
||||
|
||||
// Parameter decorators
|
||||
export { needs, ctx, param, query, body, headers, header, cookies, cookie, inbound, abort } from './params';
|
||||
export type { Query, Headers, Context, ArgSpec, ArgDecorator } from './params';
|
||||
export type { Query, RequestHeaders, Headers, Context, ArgSpec, ArgDecorator } from './params';
|
||||
|
||||
// Cookies
|
||||
export { setCookie, parseCookies } from './cookies';
|
||||
@@ -98,13 +98,14 @@ export type { StreamEncoder, SseEvent, SseFields } from './encoders';
|
||||
|
||||
// HTTP, security & validation
|
||||
export type { RequestLimits } from './http';
|
||||
export type { WsRequest, WsSocket } from './http/ws-core';
|
||||
export type { CompressionOptions } from './http/compression';
|
||||
export { UNMATCHED_ROUTE } from './http/core';
|
||||
export type { TlsOptions, CorsOptions, SecurityOptions } from './security';
|
||||
export type { UploadedFile, MultipartBody } from './multipart';
|
||||
export type { StandardSchemaV1 } from './standard-schema';
|
||||
|
||||
// Mesh
|
||||
// Mesh — experimental (`createApp({ experimental: true })`): outside the API freeze, may change in a minor.
|
||||
export { connectLink } from './mesh/link';
|
||||
export { buildRemote, envelopeFrom } from './mesh/teacup';
|
||||
export { buildManifest, createMeshControl, MESH_CONTROL_PATH } from './mesh/teapot';
|
||||
|
||||
@@ -459,6 +459,9 @@ function backoffBounds(
|
||||
* identity — the graph captured `rpc` at boot — and reconnects underneath it.
|
||||
*
|
||||
* `Ctor` is injectable to exercise both client implementations on a single runtime.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export function connectLink(args: {
|
||||
url: string;
|
||||
|
||||
@@ -34,6 +34,9 @@ export const MESH_PROTOCOL_VERSION = 1;
|
||||
*
|
||||
* `correlation` and `url` are optional by protocol, not by intent: a teapot running an older
|
||||
* green-tea simply ignores them, which costs the correlation of that hop and nothing else.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export interface RequestEnvelope {
|
||||
method: string;
|
||||
@@ -63,6 +66,9 @@ export interface RouteEntry {
|
||||
* Steps only: a provider's value is the object it builds, which cannot cross a JSON wire, so
|
||||
* exporting one is refused at boot (`collectProviders`). Every entry here is request-scope and
|
||||
* lazy — the token exists in the teacup's graph, and running it is an RPC.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export interface Manifest {
|
||||
steps: string[];
|
||||
@@ -75,6 +81,9 @@ export interface Manifest {
|
||||
* `ping`/`pong` are application frames rather than WebSocket protocol pings on purpose: the `ws`
|
||||
* package exposes `ws.ping()`, but the platform `WebSocket` that Deno and Bun provide does not,
|
||||
* so a protocol-level heartbeat could not work on every runtime mesh claims to support.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export type Frame =
|
||||
| { type: 'hello'; v: number; secret: string }
|
||||
|
||||
+9
-1
@@ -20,6 +20,9 @@ export interface RemoteRoute {
|
||||
* `url` and `correlation` are read off `ctx.req`, the handler argument the pipeline seeds the
|
||||
* context with — so a request that crosses to a teapot arrives carrying the id it already had,
|
||||
* and its events on the far side join the same trace instead of starting a new one.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export function envelopeFrom(ctx: any): RequestEnvelope {
|
||||
const req = ctx?.req;
|
||||
@@ -37,7 +40,12 @@ export function envelopeFrom(ctx: any): RequestEnvelope {
|
||||
};
|
||||
}
|
||||
|
||||
/** Turn a link's manifest into local proxy nodes: lazy request-scope steps, and routes. */
|
||||
/**
|
||||
* Turn a link's manifest into local proxy nodes: lazy request-scope steps, and routes.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export function buildRemote(link: Link): { steps: RemoteScopeNode[]; routes: RemoteRoute[] } {
|
||||
const steps: RemoteScopeNode[] = link.manifest.steps.map((token) => ({
|
||||
name: token,
|
||||
|
||||
+15
-2
@@ -22,6 +22,9 @@ import {
|
||||
*
|
||||
* Reserved in every app, mesh or not (D17): `createApp` refuses a route that claims it, and an upgrade
|
||||
* to it on an app without a control channel closes `1008` on every adapter.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export const MESH_CONTROL_PATH = '/__mesh__/control';
|
||||
|
||||
@@ -70,7 +73,12 @@ export function controlFrameLimit(maxBodyBytes = DEFAULT_MAX_BODY_BYTES): number
|
||||
return WORST_ESCAPE * maxBodyBytes + ENVELOPE_HEADROOM;
|
||||
}
|
||||
|
||||
/** Assemble a {@link Manifest} from exported step tokens and buffered routes. */
|
||||
/**
|
||||
* Assemble a {@link Manifest} from exported step tokens and buffered routes.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export function buildManifest(args: { steps: string[]; routes: RouteEntry[] }): Manifest {
|
||||
return { steps: [...args.steps], routes: args.routes };
|
||||
}
|
||||
@@ -275,7 +283,12 @@ async function serveFrames(
|
||||
}
|
||||
}
|
||||
|
||||
/** Build a control handler that authenticates peers and serves scope/route RPCs from the manifest. */
|
||||
/**
|
||||
* Build a control handler that authenticates peers and serves scope/route RPCs from the manifest.
|
||||
*
|
||||
* @experimental Part of the mesh, which needs `createApp({ experimental: true })`: outside the
|
||||
* API freeze, so it may change in a minor release.
|
||||
*/
|
||||
export function createMeshControl(deps: MeshControlDeps): {
|
||||
path: string;
|
||||
maxFrameBytes: number;
|
||||
|
||||
+7
-2
@@ -7,7 +7,12 @@ import { parseCookies } from './cookies';
|
||||
/** Parsed URL query string as flat key/value pairs. */
|
||||
export type Query = Record<string, string>;
|
||||
/** Incoming request headers; a header may repeat, hence the array variant. */
|
||||
export type Headers = Record<string, string | string[] | undefined>;
|
||||
export type RequestHeaders = Record<string, string | string[] | undefined>;
|
||||
/**
|
||||
* @deprecated Use {@link RequestHeaders}. This name shadows the Fetch `Headers` global in any file
|
||||
* that imports it; it stays as an alias so existing imports keep compiling.
|
||||
*/
|
||||
export type Headers = RequestHeaders;
|
||||
/** Per-request bag that accumulates values produced by steps and providers. */
|
||||
export type Context = Record<string, unknown>;
|
||||
|
||||
@@ -160,7 +165,7 @@ function resolveOne(spec: ArgSpec, context: Context): unknown {
|
||||
*/
|
||||
function cookiesOf(context: Context): unknown {
|
||||
if (context.cookies === undefined) {
|
||||
const headers = context.headers as Headers | undefined;
|
||||
const headers = context.headers as RequestHeaders | undefined;
|
||||
context.cookies = parseCookies(headers?.cookie);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user