(tag: unknown): ProtocolKind | undefinedThe declared ProtocolKind of the Node a tag is bound to (how a client reaches it —
Http/WebSocket/IpcSocket), or undefined for a nodeless/bare tag or a node with no declared
kind. A structural read (like kindOf) — the server uses it to reject a node-bound HyperService
served over a mismatched transport (ProtocolKindMismatch).
export const const nodeKindOf: (
tag: unknown
) => ProtocolKind | undefined
The declared
ProtocolKind
of the
Node
a tag is bound to (how a client reaches it —
Http/WebSocket/IpcSocket), or undefined for a nodeless/bare tag or a node with no declared
kind. A structural read (like
kindOf
) — the server uses it to reject a node-bound HyperService
served over a mismatched transport (
ProtocolKindMismatch
).
nodeKindOf = (tag: unknowntag: unknown): type ProtocolKind = "Http" | "WebSocket" | "IpcSocket"The transport a
Node
speaks — tag-style names (apps rarely type this alias; they write
the literals or get inference from url / path):
"Http" — RpcClient.layerProtocolHttp (servers / CLIs)
"WebSocket" — browser WS (layerProtocolWebsocket / client layerProtocolSocket over WS)
"IpcSocket" — Unix-domain socket (same-machine; see
ipcServer
)
Stamped on the node so the topology is self-describing about how to reach it — connect/client
derive the transport from it. Inferred from a ws(s):// url, an http target, or { path } →
IpcSocket; otherwise declare it explicitly.
ProtocolKind | undefined => {
const const node: NodeKey<unknown> | undefinednode = const nodeOf: (
tag: unknown
) => NodeKey<unknown> | undefined
The
Node
a tag is bound to (its transport key), or undefined for a nodeless/bare tag
or any non-tag. Accepts unknown so a Group member passes straight in — walk a group tree and
collect the distinct nodes to know which nodes back its services.
nodeOf(tag: unknowntag);
if (const node: NodeKey<unknown> | undefinednode !== var undefinedundefined && import PredicatePredicate.const hasProperty: <"kind">(self: unknown, property: "kind") => self is { [K in "kind"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(const node: NodeKey<unknown>const node: {
key: string;
Service: {
protocol: Context.Service.Shape<typeof RpcClient.Protocol>;
ping: Effect.Effect<number, NodeUnreachable>;
status: { readonly get: Effect.Effect<NodeStatusSnapshot, NodeUnreachable>; readonly changes: Stream.Stream<NodeStatusSnapshot, NodeUnreachable> };
logs: { readonly stream: Stream.Stream<LogEntry, NodeUnreachable>; readonly query: (options: { readonly limit: number }) => Effect.Effect<ReadonlyArray<LogEntry>, NodeUnreachable> };
};
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
node, "kind")) {
const const k: unknownk = const node: NodeKey<unknown> & {
kind: unknown
}
node.kind: unknownkind;
return const k: unknownk === "Http" || const k: unknownk === "WebSocket" || const k: unknownk === "IpcSocket" ? const k:
| "Http"
| "WebSocket"
| "IpcSocket"
k : var undefinedundefined;
}
return var undefinedundefined;
};