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

Function argsKey

packages/effect/src/ui/Query.ts:2759–2782  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

2757 const drop = lazy(() => dropUndefinedOf(args.ast))
2758 const codec = lazy(() => makeCodec(args, options.success, error))
2759 const argsKey = (value: unknown): string => {
2760 const encode = encodeArgs()
2761 let encoded: unknown
2762 try {
2763 encoded = encode(value)
2764 } catch {
2765 // The Schema issue prints the value, so it isn't passed on.
2766 throw new Error(
2767 "[Query] " + quote(name) +
2768 ": the args don't encode with the query's args Schema"
2769 )
2770 }
2771 try {
2772 return canonical(encoded)
2773 } catch (leaf) {
2774 throw new Error(
2775 "[Query] " + quote(name) +
2776 ": the encoded args hold a value JSON can't carry (" +
2777 (leaf instanceof NonJsonLeaf ? leaf.kind : "unknown") +
2778 "). Give the args Schema a JSON encoding.",
2779 { cause: leaf }
2780 )
2781 }
2782 }
2783 const logKey = (value: unknown, key: string): string => {
2784 const encode = encodeLogArgs()
2785 if (encode === undefined) return key

Callers

nothing calls this directly

Calls 4

encodeArgsFunction · 0.85
encodeFunction · 0.70
quoteFunction · 0.70
canonicalFunction · 0.50

Tested by

no test coverage detected