mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
20 lines
970 B
TypeScript
20 lines
970 B
TypeScript
import type { LuaScript } from '../../types/level-types'
|
|
import { normalizeAllowedGlobals } from '../../lua/functions/sandbox/normalize-allowed-globals'
|
|
|
|
export function buildLuaScriptUpdate(updates: Partial<LuaScript>): Record<string, unknown> {
|
|
const data: Record<string, unknown> = {}
|
|
|
|
if (updates.name !== undefined) data.name = updates.name
|
|
if (updates.description !== undefined) data.description = updates.description
|
|
if (updates.code !== undefined) data.code = updates.code
|
|
if (updates.parameters !== undefined) data.parameters = JSON.stringify(updates.parameters)
|
|
if (updates.returnType !== undefined) data.returnType = updates.returnType
|
|
if (updates.isSandboxed !== undefined) data.isSandboxed = updates.isSandboxed
|
|
if (updates.allowedGlobals !== undefined) {
|
|
data.allowedGlobals = JSON.stringify(normalizeAllowedGlobals(updates.allowedGlobals))
|
|
}
|
|
if (updates.timeoutMs !== undefined) data.timeoutMs = updates.timeoutMs
|
|
|
|
return data
|
|
}
|