Skip to content

Documentation / @super-line/core / defineSurface

Function: defineSurface()

defineSurface<D>(surface): D

Defined in: packages/core/src/contract.ts:249

Define an exportable contract fragment (a Directional) outside defineContract. An identity function whose const type parameter preserves literal keys and subscribe: true — a fragment declared as a plain const widens subscribe to boolean, silently degrading topics to push events once merged.

Type Parameters

D

D extends Directional

Parameters

surface

D

Returns

D

Example

ts
// a library exports its surface with prefixed keys…
export const harnessSurface = defineSurface({
  clientToServer: { 'harness.join': { input: z.object({ threadId: z.string() }), output: z.object({ ok: z.boolean() }) } },
  serverToClient: { 'harness.suspended': { payload: suspendedSchema } },
})

Released under the MIT License.