MCPcopy Create free account
hub / github.com/Effect-TS/effect / custom

Function custom

packages/effect/src/unstable/rpc/Rpc.ts:1002–1042  ·  view source on GitHub ↗
(
  f: (options: Custom.OutDefault) => (Def & Custom.OutDefault)["out"]
)

Source from the content-addressed store, hash-verified

1000 * @since 4.0.0
1001 */
1002export const custom = <Def extends Custom>(
1003 f: (options: Custom.OutDefault) => (Def & Custom.OutDefault)["out"]
1004) =>
1005<
1006 const Tag extends string,
1007 Payload extends Schema.Top | Schema.Struct.Fields = Schema.Void,
1008 Success extends Schema.Top = Schema.Void,
1009 Error extends Schema.Top = Schema.Never,
1010 const Stream extends boolean = false,
1011 Out extends Custom.OutDefault = Custom.Kind<Def, Success, Error>
1012>(tag: Tag, options?: {
1013 readonly payload?: Payload
1014 readonly success?: Success
1015 readonly error?: Error
1016 readonly defect?: DefectSchema
1017 readonly stream?: Stream
1018 readonly primaryKey?: [Payload] extends [Schema.Struct.Fields] ? ((
1019 payload: Payload extends Schema.Struct.Fields ? Struct.Simplify<Schema.Struct<Payload>["Type"]> : Payload["Type"]
1020 ) => string) :
1021 never
1022}): Rpc<
1023 Tag,
1024 Payload extends Schema.Struct.Fields ? Schema.Struct<Payload> : Payload,
1025 Stream extends true ? RpcSchema.Stream<Out["success"], Out["error"]> : Out["success"],
1026 Stream extends true ? typeof Schema.Never : Out["error"]
1027> => {
1028 const success = options?.success ?? Schema.Void
1029 const error = options?.error ?? Schema.Never
1030 const defect = options?.defect ?? Schema.Defect()
1031 const out = f({
1032 success,
1033 error,
1034 defect
1035 })
1036 return make(tag, {
1037 ...out,
1038 primaryKey: options?.primaryKey,
1039 payload: options?.payload,
1040 stream: options?.stream
1041 }) as any
1042}
1043
1044/**
1045 * Defines the type-level contract for an RPC custom constructor.

Callers 2

Client.test.tsFile · 0.50
Client.test.tsFile · 0.50

Calls 2

makeFunction · 0.70
fFunction · 0.50

Tested by

no test coverage detected