(schema: OutputSchema | undefined, pathParts: string[])
| 102 | } |
| 103 | |
| 104 | function isPathInSchema(schema: OutputSchema | undefined, pathParts: string[]): boolean { |
| 105 | if (!schema || pathParts.length === 0) { |
| 106 | return true |
| 107 | } |
| 108 | |
| 109 | let current: unknown = schema |
| 110 | |
| 111 | for (let i = 0; i < pathParts.length; i++) { |
| 112 | const part = pathParts[i] |
| 113 | |
| 114 | if (current === null || current === undefined) { |
| 115 | return false |
| 116 | } |
| 117 | |
| 118 | if (isOpaqueSchemaNode(current)) { |
| 119 | return true |
| 120 | } |
| 121 | |
| 122 | if (/^\d+$/.test(part)) { |
| 123 | if (isFileType(current)) { |
| 124 | const nextPart = pathParts[i + 1] |
| 125 | return ( |
| 126 | !nextPart || |
| 127 | USER_FILE_ACCESSIBLE_PROPERTIES.includes( |
| 128 | nextPart as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number] |
| 129 | ) |
| 130 | ) |
| 131 | } |
| 132 | if (isArrayType(current)) { |
| 133 | current = getArrayItems(current) |
| 134 | } |
| 135 | continue |
| 136 | } |
| 137 | |
| 138 | const arrayMatch = part.match(/^([^[]+)\[(\d+)\]$/) |
| 139 | if (arrayMatch) { |
| 140 | const [, prop] = arrayMatch |
| 141 | const fieldDef = lookupField(current, prop) |
| 142 | if (!fieldDef) return false |
| 143 | |
| 144 | if (isFileType(fieldDef)) { |
| 145 | const nextPart = pathParts[i + 1] |
| 146 | return ( |
| 147 | !nextPart || |
| 148 | USER_FILE_ACCESSIBLE_PROPERTIES.includes( |
| 149 | nextPart as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number] |
| 150 | ) |
| 151 | ) |
| 152 | } |
| 153 | |
| 154 | current = isArrayType(fieldDef) ? getArrayItems(fieldDef) : fieldDef |
| 155 | continue |
| 156 | } |
| 157 | |
| 158 | if ( |
| 159 | isFileType(current) && |
| 160 | USER_FILE_ACCESSIBLE_PROPERTIES.includes( |
| 161 | part as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number] |
no test coverage detected