Skip to content

Commit b0a6cd7

Browse files
committed
use shared constant correctly
1 parent b04af42 commit b0a6cd7

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

apps/sim/executor/utils/block-reference.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { USER_FILE_ACCESSIBLE_PROPERTIES } from '@/lib/workflows/types'
12
import { normalizeName } from '@/executor/constants'
23
import { navigatePath } from '@/executor/variables/resolvers/reference'
34

@@ -28,8 +29,6 @@ export class InvalidFieldError extends Error {
2829
}
2930
}
3031

31-
const FILE_PROPERTIES = ['name', 'type', 'size', 'url', 'base64', 'mimeType'] as const
32-
3332
function isFileType(value: unknown): boolean {
3433
if (typeof value !== 'object' || value === null) return false
3534
const typed = value as { type?: string }
@@ -87,7 +86,12 @@ function isPathInSchema(schema: OutputSchema | undefined, pathParts: string[]):
8786
if (/^\d+$/.test(part)) {
8887
if (isFileType(current)) {
8988
const nextPart = pathParts[i + 1]
90-
return !nextPart || FILE_PROPERTIES.includes(nextPart as (typeof FILE_PROPERTIES)[number])
89+
return (
90+
!nextPart ||
91+
USER_FILE_ACCESSIBLE_PROPERTIES.includes(
92+
nextPart as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number]
93+
)
94+
)
9195
}
9296
if (isArrayType(current)) {
9397
current = getArrayItems(current)
@@ -103,14 +107,24 @@ function isPathInSchema(schema: OutputSchema | undefined, pathParts: string[]):
103107

104108
if (isFileType(fieldDef)) {
105109
const nextPart = pathParts[i + 1]
106-
return !nextPart || FILE_PROPERTIES.includes(nextPart as (typeof FILE_PROPERTIES)[number])
110+
return (
111+
!nextPart ||
112+
USER_FILE_ACCESSIBLE_PROPERTIES.includes(
113+
nextPart as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number]
114+
)
115+
)
107116
}
108117

109118
current = isArrayType(fieldDef) ? getArrayItems(fieldDef) : fieldDef
110119
continue
111120
}
112121

113-
if (isFileType(current) && FILE_PROPERTIES.includes(part as (typeof FILE_PROPERTIES)[number])) {
122+
if (
123+
isFileType(current) &&
124+
USER_FILE_ACCESSIBLE_PROPERTIES.includes(
125+
part as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number]
126+
)
127+
) {
114128
return true
115129
}
116130

@@ -122,10 +136,15 @@ function isPathInSchema(schema: OutputSchema | undefined, pathParts: string[]):
122136
if (/^\d+$/.test(nextPart)) {
123137
const afterIndex = pathParts[i + 2]
124138
return (
125-
!afterIndex || FILE_PROPERTIES.includes(afterIndex as (typeof FILE_PROPERTIES)[number])
139+
!afterIndex ||
140+
USER_FILE_ACCESSIBLE_PROPERTIES.includes(
141+
afterIndex as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number]
142+
)
126143
)
127144
}
128-
return FILE_PROPERTIES.includes(nextPart as (typeof FILE_PROPERTIES)[number])
145+
return USER_FILE_ACCESSIBLE_PROPERTIES.includes(
146+
nextPart as (typeof USER_FILE_ACCESSIBLE_PROPERTIES)[number]
147+
)
129148
}
130149
current = fieldDef
131150
continue

0 commit comments

Comments
 (0)