persona-community-5/.pnpm-store/v3/files/72/ce20dde1b635ef0ec8b9a47d197c50e9cba41409bb9806f156df9bc125cc610bba0948560f43cacab1ebf4f92ea169fda4259bc646b5f5aeae6cfd1d2b497c
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

28 lines
779 B
Plaintext

import type {AnySchemaObject} from "../types"
import {_, or, type Code} from "../compile/codegen"
import N from "../compile/names"
export function getSkipCondition(schema: AnySchemaObject, prop: string): Code | undefined {
const propSchema = schema.properties?.[prop]
if (!propSchema) return undefined
const hasReadOnly = propSchema.readOnly === true
const hasWriteOnly = propSchema.writeOnly === true
if (!hasReadOnly && !hasWriteOnly) return undefined
const conditions: Code[] = []
const apiContext = _`typeof ${N.this} == "object" && ${N.this} && ${N.this}.apiContext`
if (hasReadOnly) {
conditions.push(_`${apiContext} === "request"`)
}
if (hasWriteOnly) {
conditions.push(_`${apiContext} === "response"`)
}
return or(...conditions)
}