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

Function isRelationCheck

packages/infra/src/Store/codeFilter.ts:68–90  ·  view source on GitHub ↗
(f: readonly FilterResult[], isRelation: string | null)

Source from the content-addressed store, hash-verified

66// right now we ignore scoped combinations, because they allow us to scope relation checks too.
67// probably best to create a separate keyword and dsl for relation checks, so we can remove all the special casing alltogether..
68export const isRelationCheck = (f: readonly FilterResult[], isRelation: string | null) => {
69 const withPath = f.filter((_) => "path" in _)
70 if (withPath.length && withPath.every((_) => "path" in _ && _.path.includes(".-1."))) {
71 const first = withPath[0] as { path: string }
72 const rel = first.path.split(".-1.")[0]
73 if (isRelation && rel !== isRelation) {
74 throw new Error(`expected ${isRelation} relation but found ${rel}`)
75 }
76 if (!f.filter((_) => "path" in _).every((_) => "path" in _ && _.path.startsWith(rel + ".-1."))) {
77 throw new Error(
78 `Cannot mix relation checks of different props, expected all to be "${rel}"`
79 )
80 }
81 return rel
82 }
83 if (f.some((_) => "path" in _ && _.path.includes(".-1."))) {
84 throw new Error(
85 "Cannot mix relation checks with non-relation checks in the same filter scope. create a separate one"
86 )
87 }
88
89 return false
90}
91
92export const codeFilter3 = <E>(state: readonly FilterResult[]) => (sut: E) => codeFilter3_(state, sut)
93const codeFilter3__ = <E>(

Callers 3

printFunction · 0.90
printFunction · 0.90
codeFilter3__Function · 0.85

Calls 3

filterMethod · 0.80
someMethod · 0.80
splitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…