(type: string)
| 19 | }) as any |
| 20 | |
| 21 | export 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 | |
| 50 | export function lowercaseIfString<T>(val: T) { |
| 51 | if (typeof val === "string") { |
no test coverage detected
searching dependent graphs…