<Self, ROut = never>(
name: string,
options?: PrototypeOptions
): Context.ServiceClass<Self, string, Record<string, never>> & {
isPrototype: true
kind: ProtocolKind | undefined
ipc: "unix" | "nPipe"
onConflict: OnConflict
url: undefined
path: undefined
[catalogSym]: ROut | undefined
make: {
(
cloneName: string,
target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
): IpcNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: `ws://${string}` | `wss://${string}`
readonly kind?: "WebSocket"
readonly onConflict?: OnConflict
}
): WsNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind: "WebSocket"
readonly onConflict?: OnConflict
}
): WsNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind: "Http"
readonly onConflict?: OnConflict
}
): HttpNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
): UrlNodeTagClass<Self, ROut>
}
instance: (
suffix?: string
) => NodeTagClass<
Self,
ROut,
| BareAddress
| IpcAddress
| HttpAddress
| WsAddress
| UrlAddressLoose
| MultiAddress<ProtocolKind>
> & {
instanceSuffix?: string | undefined
isDynamicInstance: true
dynamicPrototypeKey: string
}
listen: <Serves extends ServeLayerList>(
serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>,
listenOptions?: NamelessListenOptions
) => (
suffix?: string
) => Layer.Layer<
Layer.Success<Serves[number]> | ListenNode,
never,
Layer.Services<Serves[number]>
>
}Prototype Node template (D7) — a Node kind, nested on Node as Prototype.
No address until cloned:
class MailWorker extends Prototype<MailWorker, Mail>("app/MailWorker") {}
// Named clone with a fixed address (class ctor):
class East extends MailWorker.make("East", { path: "/tmp/east.sock" }) {}
// Dynamic instances — same protocol siblings + Lookup pipe as unix/http/ws/nPipe:
const mailWorker = MailWorker.listen([Hyperlink.serve(Mail, impl)])
mailWorker().pipe(Layer.provide(Lookup.layer))
mailWorker("w1").pipe(Layer.provide(Lookup.layer))Lookup is not baked in — pipe Lookup.layer / layerOptions / client like the
protocol listen siblings.
export const const Prototype: <Self, ROut = never>(
name: string,
options?: PrototypeOptions
) => Context.ServiceClass<
Self,
string,
Record<string, never>
> & {
[catalogSym]: ROut | undefined
isPrototype: true
kind: any
ipc: "unix" | "nPipe"
onConflict: any
url: undefined
path: undefined
make: {
(
cloneName: string,
target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
): IpcNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url:
| `ws://${string}`
| `wss://${string}`
readonly kind?: "WebSocket"
readonly onConflict?: OnConflict
}
): WsNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind: "WebSocket"
readonly onConflict?: OnConflict
}
): WsNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind: "Http"
readonly onConflict?: OnConflict
}
): HttpNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
): UrlNodeTagClass<Self, ROut>
}
instance: (suffix?: string) => any
listen: <Serves extends ServeLayerList>(
serves: Serves &
ServesForCatalog<
Exclude<ROut, undefined>,
Serves
>,
listenOptions?: NamelessListenOptions
) => (
suffix?: string
) => Layer.Layer<
Layer.Success<Serves[number]> | ListenNode,
never,
Layer.Services<Serves[number]>
>
}
Prototype Node template (D7) — a Node kind, nested on
Node
as Prototype.
No address until cloned:
class MailWorker extends Prototype<MailWorker, Mail>("app/MailWorker") {}
// Named clone with a fixed address (class ctor):
class East extends MailWorker.make("East", { path: "/tmp/east.sock" }) {}
// Dynamic instances — same protocol siblings + Lookup pipe as unix/http/ws/nPipe:
const mailWorker = MailWorker.listen([Hyperlink.serve(Mail, impl)])
mailWorker().pipe(Layer.provide(Lookup.layer))
mailWorker("w1").pipe(Layer.provide(Lookup.layer))
Lookup is not baked in — pipe Lookup.layer / layerOptions / client like the
protocol listen siblings.
Prototype = <function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut = never>(
name: stringname: string,
options: PrototypeOptions | undefinedoptions?: type PrototypeOptions = {
readonly kind?: ProtocolKind
readonly ipc?: "unix" | "nPipe"
readonly onConflict?: OnConflict
}
Prototype ctor options — kind picks the listen sibling; ipc selects unix vs nPipe.
PrototypeOptions,
) => {
const const protoOnConflict: anyprotoOnConflict = options: PrototypeOptions | undefinedoptions?.onConflict?: anyonConflict;
const const instance: (suffix?: string) => anyinstance = (suffix: string | undefinedsuffix?: string) => {
const const key: stringkey =
suffix: string | undefinedsuffix !== var undefinedundefined && suffix: stringsuffix.String.length: numberReturns the length of a String object.
length > 0 ? `${name: stringname}#${suffix: stringsuffix}` : name: stringname;
return var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<any, {
instanceSuffix?: string | undefined;
isDynamicInstance: true;
dynamicPrototypeKey: string;
}>(target: any, source: {
instanceSuffix?: string | undefined;
isDynamicInstance: true;
dynamicPrototypeKey: string;
}): any (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.
assign(
import TagTag<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>()(
const key: stringkey,
const protoOnConflict: anyprotoOnConflict !== var undefinedundefined
? { onConflict: anyonConflict: const protoOnConflict: anyprotoOnConflict }
: var undefinedundefined,
),
{
isDynamicInstance: trueisDynamicInstance: true as type const = trueconst,
dynamicPrototypeKey: stringdynamicPrototypeKey: name: stringname,
...(suffix: string | undefinedsuffix !== var undefinedundefined && suffix: stringsuffix.String.length: numberReturns the length of a String object.
length > 0
? { instanceSuffix?: string | undefinedinstanceSuffix: suffix: stringsuffix }
: {}),
},
);
};
function function (local function) make(cloneName: string, target: {
readonly path: string;
readonly kind?: "IpcSocket";
readonly onConflict?: OnConflict;
}): IpcNodeTagClass<Self, ROut> (+4 overloads)
make(
cloneName: stringcloneName: string,
target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
target: {
readonly path: stringpath: string;
readonly kind?: "IpcSocket" | undefinedkind?: "IpcSocket";
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
},
): import IpcNodeTagClassIpcNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>;
function function (local function) make(cloneName: string, target: {
readonly url: `ws://${string}` | `wss://${string}`;
readonly kind?: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut> (+4 overloads)
make(
cloneName: stringcloneName: string,
target: {
readonly url:
| `ws://${string}`
| `wss://${string}`
readonly kind?: "WebSocket"
readonly onConflict?: OnConflict
}
target: {
readonly url: `ws://${string}` | `wss://${string}`url: `ws://${string}` | `wss://${string}`;
readonly kind?: "WebSocket" | undefinedkind?: "WebSocket";
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
},
): import WsNodeTagClassWsNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>;
function function (local function) make(cloneName: string, target: {
readonly url: string;
readonly kind: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut> (+4 overloads)
make(
cloneName: stringcloneName: string,
target: {
readonly url: string
readonly kind: "WebSocket"
readonly onConflict?: OnConflict
}
target: {
readonly url: stringurl: string;
readonly kind: "WebSocket"kind: "WebSocket";
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
},
): import WsNodeTagClassWsNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>;
function function (local function) make(cloneName: string, target: {
readonly url: string;
readonly kind: "Http";
readonly onConflict?: OnConflict;
}): HttpNodeTagClass<Self, ROut> (+4 overloads)
make(
cloneName: stringcloneName: string,
target: {
readonly url: string
readonly kind: "Http"
readonly onConflict?: OnConflict
}
target: {
readonly url: stringurl: string;
readonly kind: "Http"kind: "Http";
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
},
): import HttpNodeTagClassHttpNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>;
function function (local function) make(cloneName: string, target: {
readonly url: string;
readonly kind?: ProtocolKind;
readonly onConflict?: OnConflict;
}): UrlNodeTagClass<Self, ROut> (+4 overloads)
make(
cloneName: stringcloneName: string,
target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target: {
readonly url: stringurl: string;
readonly kind?: anykind?: import ProtocolKindProtocolKind;
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
},
): import UrlNodeTagClassUrlNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>;
function function (local function) make(cloneName: string, target: {
readonly path: string;
readonly kind?: "IpcSocket";
readonly onConflict?: OnConflict;
}): IpcNodeTagClass<Self, ROut> (+4 overloads)
make(
cloneName: stringcloneName: string,
target: | {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
| {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target:
| {
readonly path: stringpath: string;
readonly kind?: "IpcSocket" | undefinedkind?: "IpcSocket";
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
}
| {
readonly url: stringurl: string;
readonly kind?: anykind?: import ProtocolKindProtocolKind;
readonly onConflict?: anyonConflict?: import OnConflictOnConflict;
},
): import IpcNodeTagClassIpcNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut> | import UrlNodeTagClassUrlNodeTagClass<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut> {
const const onConflict: anyonConflict = target: | {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
| {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target.onConflict?: anyonConflict ?? const protoOnConflict: anyprotoOnConflict;
// Branch so each Tag call hits a dialable overload (not the loose union catch-all).
if ("path" in target: | {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
| {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target) {
return import TagTag<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>()(`${name: stringname}#${cloneName: stringcloneName}`, {
path: stringpath: target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
target.path: stringpath,
...(target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
target.kind?: "IpcSocket" | undefinedkind !== var undefinedundefined ? { kind: "IpcSocket"kind: target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
target.kind?: "IpcSocket"kind } : {}),
...(const onConflict: anyonConflict !== var undefinedundefined ? { onConflict: anyonConflict } : {}),
});
}
return import TagTag<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut>()(`${name: stringname}#${cloneName: stringcloneName}`, {
url: stringurl: target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target.url: stringurl,
...(target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target.kind?: anykind !== var undefinedundefined ? { kind: anykind: target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
target.kind?: anykind } : {}),
...(const onConflict: anyonConflict !== var undefinedundefined ? { onConflict: anyonConflict } : {}),
});
}
return var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.assign<Context.ServiceClass<Self, string, Record<string, never>>, {
[catalogSym]: ROut | undefined;
isPrototype: true;
kind: any;
ipc: "unix" | "nPipe";
onConflict: any;
url: undefined;
path: undefined;
make: {
(cloneName: string, target: {
readonly path: string;
readonly kind?: "IpcSocket";
readonly onConflict?: OnConflict;
}): IpcNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: `ws://${string}` | `wss://${string}`;
readonly kind?: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind: "Http";
readonly onConflict?: OnConflict;
}): HttpNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind?: ProtocolKind;
readonly onConflict?: OnConflict;
}): UrlNodeTagClass<Self, ROut>;
};
instance: (suffix?: string) => any;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}>(target: Context.ServiceClass<...>, source: {
[catalogSym]: ROut | undefined;
isPrototype: true;
kind: any;
ipc: "unix" | "nPipe";
onConflict: any;
url: undefined;
path: undefined;
make: {
(cloneName: string, target: {
readonly path: string;
readonly kind?: "IpcSocket";
readonly onConflict?: OnConflict;
}): IpcNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: `ws://${string}` | `wss://${string}`;
readonly kind?: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind: "Http";
readonly onConflict?: OnConflict;
}): HttpNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind?: ProtocolKind;
readonly onConflict?: OnConflict;
}): UrlNodeTagClass<Self, ROut>;
};
instance: (suffix?: string) => any;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}): Context.ServiceClass<...> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
kind: any;
ipc: "unix" | "nPipe";
onConflict: any;
url: undefined;
path: undefined;
make: {
(cloneName: string, target: {
readonly path: string;
readonly kind?: "IpcSocket";
readonly onConflict?: OnConflict;
}): IpcNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: `ws://${string}` | `wss://${string}`;
readonly kind?: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind: "WebSocket";
readonly onConflict?: OnConflict;
}): WsNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind: "Http";
readonly onConflict?: OnConflict;
}): HttpNodeTagClass<Self, ROut>;
(cloneName: string, target: {
readonly url: string;
readonly kind?: ProtocolKind;
readonly onConflict?: OnConflict;
}): UrlNodeTagClass<Self, ROut>;
};
instance: (suffix?: string) => any;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
} (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a
target object. Returns the target object.
assign(import ContextContext.const Service: <Self, Record<string, never>>() => <Identifier, E, R, Args>(id: Identifier, options?: {
readonly make: ((...args: Args) => Effect<Record<string, never>, E, R>) | Effect<Record<string, never>, E, R> | undefined;
} | undefined) => Context.ServiceClass<Self, Identifier, Record<string, never>> & ([unassigned] extends [R] ? unknown : {
readonly make: [Args] extends [never] ? Effect<Record<string, never>, E, R> : (...args: Args) => Effect<...>;
}) (+2 overloads)
Creates a Context service key.
When to use
Use when you need to define a context service key for a dependency that must
be provided by the surrounding context.
Details
Call Context.Service("Key") for a function-style key, or use the two-stage
form Context.Service<Self, Shape>()("Key") for class-style service
declarations. The returned key can be yielded as an Effect and passed to
Context.make, Context.add, and the Context getter functions.
Gotchas
The string key is the runtime identity of the service. Reusing the same key
string for unrelated services makes them occupy the same slot in a
Context.
Example (Creating service keys)
import { Context } from "effect"
// Create a simple service
const Database = Context.Service<{
query: (sql: string) => string
}>("Database")
// Create a service class
class Config extends Context.Service<Config, {
port: number
}>()("Config") {}
// Use the services to create contexts
const db = Context.make(Database, {
query: (sql) => `Result: ${sql}`
})
const config = Context.make(Config, { port: 8080 })
Service<function (type parameter) Self in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
Self, type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<string, never>>()(name: stringname), {
isPrototype: trueisPrototype: true as type const = trueconst,
kind: anykind: options: PrototypeOptions | undefinedoptions?.kind?: anykind,
ipc: "unix" | "nPipe"ipc: options: PrototypeOptions | undefinedoptions?.ipc?: "unix" | "nPipe" | undefinedIpc transport when kind is unset / "IpcSocket". Default "unix".
ipc ?? ("unix" as type const = "unix"const),
onConflict: anyonConflict: const protoOnConflict: anyprotoOnConflict ?? ("inherit" as type const = "inherit"const),
url: undefinedurl: var undefinedundefined as undefined,
path: undefinedpath: var undefinedundefined as undefined,
[import catalogSymcatalogSym]: var undefinedundefined as function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut | undefined,
make: {
(
cloneName: string,
target: {
readonly path: string
readonly kind?: "IpcSocket"
readonly onConflict?: OnConflict
}
): IpcNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url:
| `ws://${string}`
| `wss://${string}`
readonly kind?: "WebSocket"
readonly onConflict?: OnConflict
}
): WsNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind: "WebSocket"
readonly onConflict?: OnConflict
}
): WsNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind: "Http"
readonly onConflict?: OnConflict
}
): HttpNodeTagClass<Self, ROut>
(
cloneName: string,
target: {
readonly url: string
readonly kind?: ProtocolKind
readonly onConflict?: OnConflict
}
): UrlNodeTagClass<Self, ROut>
}
make,
/**
* Dynamic instance Node — wire key `prototypeKey#suffix`, for {@link listen} /
* {@link peersLayer} `self`. Prefer `.listen(serves)` to spawn.
* Omit `suffix` to mint one at listen.
*/
instance: (suffix?: string) => anyDynamic instance Node — wire key prototypeKey#suffix, for
listen
/
peersLayer
self. Prefer .listen(serves) to spawn.
Omit suffix to mint one at listen.
instance,
/**
* Curry a serve list into a dynamic-instance factory — sugar over
* {@link unix} / {@link http} / {@link ws} / {@link nPipe}
* `(proto.instance(suffix), serves)` by `kind` / `ipc`.
* Same Lookup story as those siblings: pipe `Lookup.layer` when advertise needs it.
* Keep in sync with the protocol listen siblings (handoff § Protocol listen siblings).
* Returns a **Layer** only — after `Layer.build`, the minted Node is
* {@link ListenNode} in context.
*/
listen: <Serves extends ServeLayerList>(
serves: Serves &
ServesForCatalog<
Exclude<ROut, undefined>,
Serves
>,
listenOptions?: NamelessListenOptions
) => (
suffix?: string
) => Layer.Layer<
Layer.Success<Serves[number]> | ListenNode,
never,
Layer.Services<Serves[number]>
>
Curry a serve list into a dynamic-instance factory — sugar over
unix
/
http
/
ws
/
nPipe
(proto.instance(suffix), serves) by kind / ipc.
Same Lookup story as those siblings: pipe Lookup.layer when advertise needs it.
Keep in sync with the protocol listen siblings (handoff § Protocol listen siblings).
Returns a Layer only — after Layer.build, the minted Node is
ListenNode
in context.
listen: <function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves extends import ServeLayerListServeLayerList>(
serves: anyserves: function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves & import ServesForCatalogServesForCatalog<type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) ROut in <Self, ROut = never>(name: string, options?: PrototypeOptions): Context.ServiceClass<Self, string, Record<string, never>> & {
[catalogSym]: ROut | undefined;
isPrototype: true;
... 7 more ...;
listen: <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions) => ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>);
}
ROut, undefined>, function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves>,
listenOptions: anylistenOptions?: import NamelessListenOptionsNamelessListenOptions,
): ((
suffix: string | undefinedsuffix?: string,
) => import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<
import LayerLayer.type Success<T extends Layer.Any> =
T extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _ROut
: never
Extracts the service output type (ROut) from a Layer type.
When to use
Use to derive the services provided by an existing or generic Layer without
restating its ROut type parameter.
Success<function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves[number]> | import ListenNodeListenNode,
never,
import LayerLayer.type Services<T extends Layer.Any> =
T extends infer L
? L extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _RIn
: never
: never
Extracts the service requirements (RIn) from a Layer type.
When to use
Use to derive the dependency requirements of a generic or inferred Layer
without restating its RIn type parameter.
Services<function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves[number]>
>) =>
(suffix: string | undefinedsuffix?: string) => {
// Explicit type args — avoid re-inferring `Serves` from the already-proven
// intersection (nested `ServesForCatalog` would otherwise fail to unify).
const const node: anynode = const instance: (suffix?: string) => anyinstance(suffix: string | undefinedsuffix);
if (options: PrototypeOptions | undefinedoptions?.kind?: anykind === "Http") {
return import httphttp<typeof const node: anynode, function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves>(const node: anynode, serves: anyserves, listenOptions: anylistenOptions);
}
if (options: PrototypeOptions | undefinedoptions?.kind?: anykind === "WebSocket") {
return import wsws<typeof const node: anynode, function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves>(const node: anynode, serves: anyserves, listenOptions: anylistenOptions);
}
if (options: PrototypeOptions | undefinedoptions?.ipc?: "unix" | "nPipe" | undefinedIpc transport when kind is unset / "IpcSocket". Default "unix".
ipc === "nPipe") {
return import nPipenPipe<typeof const node: anynode, function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves>(const node: anynode, serves: anyserves, listenOptions: anylistenOptions);
}
return import unixunix<typeof const node: anynode, function (type parameter) Serves in <Serves extends ServeLayerList>(serves: Serves & ServesForCatalog<Exclude<ROut, undefined>, Serves>, listenOptions?: NamelessListenOptions): ((suffix?: string) => Layer.Layer<Layer.Success<Serves[number]> | ListenNode, never, Layer.Services<Serves[number]>>)Serves>(const node: anynode, serves: anyserves, listenOptions: anylistenOptions);
},
});
};