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

Function messageIdForPrimaryKey

packages/cluster/src/SqlMessageStorage.ts:54–59  ·  view source on GitHub ↗
(primaryKey: string)

Source from the content-addressed store, hash-verified

52
53 const encoder = new TextEncoder()
54 const messageIdForPrimaryKey = (primaryKey: string): Effect.Effect<string> =>
55 primaryKey.length <= 255
56 ? Effect.succeed(primaryKey)
57 : Effect.promise(() => globalThis.crypto.subtle.digest("SHA-256", encoder.encode(primaryKey))).pipe(
58 Effect.map((digest) => Encoding.encodeHex(new Uint8Array(digest)))
59 )
60
61 const messageIdEnforcesWidth = sql.onDialectOrElse({
62 mssql: () => true,

Callers 1

Calls 3

encodeMethod · 0.80
pipeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected