MCPcopy Create free account
hub / github.com/effect-app/libs / makeUpdateETag

Function makeUpdateETag

packages/infra/src/Store/utils.ts:21–48  ·  view source on GitHub ↗
(type: string)

Source from the content-addressed store, hash-verified

19 }) as any
20
21export const makeUpdateETag = (type: string) =>
22 Effect.fnUntraced(function*<IdKey extends keyof E, E extends PersistenceModelType<{}>>(
23 e: E,
24 idKey: IdKey,
25 current: Option.Option<E>
26 ) {
27 if (e._etag) {
28 if (Option.isNone(current)) {
29 return yield* new OptimisticConcurrencyException({
30 type,
31 id: e[idKey] as string,
32 current: "",
33 found: e._etag,
34 code: 409
35 })
36 }
37 }
38 if (Option.isSome(current) && current.value._etag !== e._etag) {
39 return yield* new OptimisticConcurrencyException({
40 type,
41 id: current.value[idKey] as string,
42 current: current.value._etag,
43 found: e._etag,
44 code: 412
45 })
46 }
47 return makeETag(e)
48 })
49
50export function lowercaseIfString<T>(val: T) {
51 if (typeof val === "string") {

Callers 1

makeMemoryStoreIntFunction · 0.90

Calls 1

makeETagFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…